xref: /reactos/dll/win32/shell32/wine/pidl.h (revision 9dedcb67)
1 /*
2  * internal pidl functions
3  *
4  * Copyright 1998 Juergen Schmied
5  * Copyright 2004 Juan Lang
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  *
21  * NOTES:
22  *
23  * DO NOT use these definitions outside the shell32.dll!
24  *
25  * The contents of a pidl should never be used directly from an application.
26  *
27  * Undocumented:
28  * MS says: the abID of SHITEMID should be treated as binary data and not
29  * be interpreted by applications. Applies to everyone but MS itself.
30  * Word95 interprets the contents of abID (Filesize/Date) so we have to go
31  * for binary compatibility here.
32  */
33 
34 #ifndef __WINE_PIDL_H
35 #define __WINE_PIDL_H
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42 * the pidl does cache fileattributes to speed up SHGetAttributes when
43 * displaying a big number of files.
44 *
45 * a pidl of NULL means the desktop
46 *
47 * The structure of the pidl seems to be a union. The first byte of the
48 * PIDLDATA describes the type of pidl.
49 *
50 *	object        ! first byte /  ! format       ! living space
51 *	              ! size
52 *	----------------------------------------------------------------
53 *	my computer	0x1F/20		guid (2)	(usual)
54 *	network		0x1F		guid
55 *	bitbucket	0x1F		guid
56 *	drive		0x23/25		drive		(usual)
57 *	drive		0x25/25		drive		(lnk/persistent)
58 *	drive		0x29/25		drive
59 *	shell extension	0x2E		guid
60 *	drive		0x2F		drive		(lnk/persistent)
61 *	folder/file	0x30		folder/file (1)	(lnk/persistent)
62 *	folder		0x31		folder		(usual)
63 *	valueA		0x32		file		(ANSI file name)
64 *	valueW		0x34		file		(Unicode file name)
65 *	workgroup	0x41		network (3)
66 *	computer	0x42		network (4)
67 *	net provider	0x46		network
68 *	whole network	0x47		network (5)
69 *	MSITStore	0x61		htmlhlp (7)
70 *	printers/ras connections 	0x70		guid
71 *	history/favorites 0xb1		file
72 *	share		0xc3		network (6)
73 *
74 * guess: the persistent elements are non tracking
75 *
76 * (1) dummy byte is used, attributes are empty
77 * (2) IID_MyComputer = 20D04FE0L-3AEA-1069-A2D8-08002B30309D
78 * (3) two strings	"workgroup" "Microsoft Network"
79 * (4) two strings	"\\sirius" "Microsoft Network"
80 * (5) one string	"Entire Network"
81 * (6) two strings	"\\sirius\c" "Microsoft Network"
82 * (7) contains string   "mk:@MSITStore:C:\path\file.chm::/path/filename.htm"
83 *		GUID	871C5380-42A0-1069-A2EA-08002B30309D
84 */
85 
86 #define PT_CPLAPPLET	0x00
87 #define PT_GUID		0x1F
88 #define PT_DRIVE	0x23
89 #define PT_DRIVE2	0x25
90 #define PT_DRIVE3	0x29
91 #define PT_SHELLEXT	0x2E
92 #define PT_DRIVE1	0x2F
93 #define PT_FOLDER1	0x30
94 #define PT_FOLDER	0x31
95 #define PT_VALUE	0x32
96 #define PT_VALUEW	0x34
97 #define PT_FOLDERW	0x35
98 #define PT_WORKGRP	0x41
99 #define PT_COMP		0x42
100 #define PT_NETPROVIDER	0x46
101 #define PT_NETWORK	0x47
102 #define PT_IESPECIAL1	0x61
103 #define PT_YAGUID	0x70 /* yet another guid.. */
104 #define PT_IESPECIAL2	0xb1
105 #define PT_SHARE	0xc3
106 
107 #ifdef __REACTOS__
108 #define PT_FOLDERTYPEMASK       0x70
109 #define PT_DESKTOP_REGITEM      0x1F // => SHDID_ROOT_REGITEM
110 #define PT_COMPUTER_REGITEM     0x2E // => SHDID_COMPUTER_?
111 #define PT_FS                   0x30 // Win95 SHSimpleIDListFromPath
112 #define PT_FS_FOLDER_FLAG       0x01
113 #define PT_FS_FILE_FLAG         0x02
114 #define PT_FS_UNICODE_FLAG      0x04
115 //      PT_NET_REGITEM          0x4? // => SHDID_NET_OTHER
116 #define PT_CONTROLS_OLDREGITEM  0x70
117 #define PT_CONTROLS_NEWREGITEM  0x71
118 #endif
119 
120 static inline BYTE _ILGetType(LPCITEMIDLIST pidl)
121 {
122     return pidl && pidl->mkid.cb >= 3 ? pidl->mkid.abID[0] : 0;
123 }
124 
125 static inline BYTE _ILGetFSType(LPCITEMIDLIST pidl)
126 {
127     const BYTE type = _ILGetType(pidl);
128     return (type & PT_FOLDERTYPEMASK) == PT_FS ? type : 0;
129 }
130 
131 #include "pshpack1.h"
132 typedef BYTE PIDLTYPE;
133 
134 typedef struct tagPIDLCPanelStruct
135 {
136     BYTE dummy;			/*01 is 0x00 */
137     DWORD iconIdx;		/*02 negative icon ID */
138     WORD offsDispName;		/*06*/
139     WORD offsComment;		/*08*/
140     WCHAR szName[1];		/*10*/ /* terminated by 0x00, followed by display name and comment string */
141 } PIDLCPanelStruct;
142 
143 #ifdef __REACTOS__
144 
145 typedef struct tagPIDLFontStruct
146 {
147     BYTE dummy;
148     WORD offsFile;
149     WCHAR szName[1];
150 } PIDLFontStruct;
151 
152 typedef struct tagPIDLPrinterStruct
153 {
154     BYTE dummy;
155     DWORD Attributes;
156     WORD offsServer;
157     WCHAR szName[1];
158 } PIDLPrinterStruct;
159 
160 typedef struct tagPIDLRecycleStruct
161 {
162     FILETIME LastModification;
163     FILETIME DeletionTime;
164     ULARGE_INTEGER FileSize;
165     ULARGE_INTEGER PhysicalFileSize;
166     DWORD Attributes;
167     WCHAR szName[1];
168 } PIDLRecycleStruct;
169 
170 #endif /* !__REACTOS__ */
171 
172 typedef struct tagGUIDStruct
173 {
174     BYTE dummy; /* offset 01 is unknown */
175     GUID guid;  /* offset 02 */
176 } GUIDStruct;
177 
178 typedef struct tagDriveStruct
179 {
180     CHAR szDriveName[20];	/*01*/
181     WORD unknown;		/*21*/
182 } DriveStruct;
183 
184 typedef struct tagFileStruct
185 {
186     BYTE dummy;			/*01 is 0x00 for files or dirs */
187     DWORD dwFileSize;		/*02*/
188     WORD uFileDate;		/*06*/
189     WORD uFileTime;		/*08*/
190     WORD uFileAttribs;		/*10*/
191     CHAR szNames[1];		/*12*/
192     /* Here are coming two strings. The first is the long name.
193     The second the dos name when needed or just 0x00 */
194 } FileStruct;
195 
196 /* At least on WinXP, this struct is appended with 2-byte-alignment to FileStruct. There follows
197  * a WORD member after the wszName string, which gives the offset from the beginning of the PIDL
198  * to the FileStructW member. */
199 typedef struct tagFileStructW {
200     WORD cbLen;
201     BYTE dummy1[6];
202     WORD uCreationDate;
203     WORD uCreationTime;
204     WORD uLastAccessDate;
205     WORD uLastAccessTime;
206     BYTE dummy2[4];
207     WCHAR wszName[1];
208 } FileStructW;
209 
210 typedef struct tagValueW
211 {
212     WCHAR name[1];
213 } ValueWStruct;
214 
215 typedef struct tagPIDLDATA
216 {	PIDLTYPE type;			/*00*/
217 	union
218 	{
219 	  struct tagGUIDStruct guid;
220 	  struct tagDriveStruct drive;
221 	  struct tagFileStruct file;
222 	  struct
223 	  { WORD dummy;		/*01*/
224 	    CHAR szNames[1];	/*03*/
225 	  } network;
226 	  struct
227 	  { WORD dummy;		/*01*/
228 	    DWORD dummy1;	/*02*/
229 	    CHAR szName[1];	/*06*/ /* terminated by 0x00 0x00 */
230 	  } htmlhelp;
231 	  struct tagPIDLCPanelStruct cpanel;
232           struct tagValueW valueW;
233 #ifdef __REACTOS__
234           struct tagPIDLFontStruct cfont;
235           struct tagPIDLPrinterStruct cprinter;
236           struct tagPIDLRecycleStruct crecycle;
237 #endif
238 	}u;
239 } PIDLDATA, *LPPIDLDATA;
240 #include "poppack.h"
241 
242 /*
243  * getting special values from simple pidls
244  */
245 DWORD   _ILSimpleGetTextW   (LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize) DECLSPEC_HIDDEN;
246 BOOL    _ILGetFileDate      (LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize) DECLSPEC_HIDDEN;
247 DWORD   _ILGetFileSize      (LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize) DECLSPEC_HIDDEN;
248 BOOL    _ILGetExtension     (LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize) DECLSPEC_HIDDEN;
249 void    _ILGetFileType      (LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize) DECLSPEC_HIDDEN;
250 DWORD   _ILGetFileAttributes(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize) DECLSPEC_HIDDEN;
251 BOOL    _ILGetFileDateTime  (LPCITEMIDLIST pidl, FILETIME *ft) DECLSPEC_HIDDEN;
252 DWORD   _ILGetDrive         (LPCITEMIDLIST, LPWSTR, UINT) DECLSPEC_HIDDEN;
253 
254 /*
255  * testing simple pidls
256  */
257 BOOL	_ILIsUnicode		(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
258 BOOL	_ILIsDesktop		(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
259 BOOL	_ILIsMyComputer		(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
260 #ifdef __REACTOS__
261 BOOL	_ILIsMyDocuments	(LPCITEMIDLIST pidl);
262 BOOL	_ILIsBitBucket		(LPCITEMIDLIST pidl);
263 BOOL	_ILIsNetHood		(LPCITEMIDLIST pidl);
264 BOOL    _ILIsControlPanel   (LPCITEMIDLIST pidl);
265 #endif
266 BOOL	_ILIsDrive		(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
267 BOOL	_ILIsFolder		(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
268 BOOL	_ILIsValue		(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
269 BOOL	_ILIsSpecialFolder	(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
270 BOOL	_ILIsPidlSimple		(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
271 BOOL	_ILIsCPanelStruct	(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
272 static inline BOOL _ILIsEmpty(LPCITEMIDLIST pidl) { return _ILIsDesktop(pidl); }
273 UINT _ILGetDepth(LPCITEMIDLIST pidl);
274 
275 /*
276  * simple pidls
277  */
278 
279 /* Creates a PIDL with guid format and type type, which must be one of PT_GUID,
280  * PT_SHELLEXT, or PT_YAGUID.
281  */
282 LPITEMIDLIST	_ILCreateGuid(PIDLTYPE type, REFIID guid) DECLSPEC_HIDDEN;
283 
284 #ifndef __REACTOS__
285 /* Like _ILCreateGuid, but using the string szGUID. */
286 LPITEMIDLIST	_ILCreateGuidFromStrA(LPCSTR szGUID) DECLSPEC_HIDDEN;
287 LPITEMIDLIST	_ILCreateGuidFromStrW(LPCWSTR szGUID) DECLSPEC_HIDDEN;
288 #endif
289 
290 /* Commonly used PIDLs representing file system objects. */
291 LPITEMIDLIST	_ILCreateDesktop	(void) DECLSPEC_HIDDEN;
292 LPITEMIDLIST	_ILCreateFromFindDataW(const WIN32_FIND_DATAW *stffile) DECLSPEC_HIDDEN;
293 HRESULT		_ILCreateFromPathW	(LPCWSTR szPath, LPITEMIDLIST* ppidl) DECLSPEC_HIDDEN;
294 
295 /* Other helpers */
296 LPITEMIDLIST	_ILCreateMyComputer	(void) DECLSPEC_HIDDEN;
297 LPITEMIDLIST	_ILCreateMyDocuments	(void) DECLSPEC_HIDDEN;
298 LPITEMIDLIST	_ILCreateIExplore	(void) DECLSPEC_HIDDEN;
299 LPITEMIDLIST	_ILCreateControlPanel	(void) DECLSPEC_HIDDEN;
300 LPITEMIDLIST	_ILCreatePrinters	(void) DECLSPEC_HIDDEN;
301 LPITEMIDLIST	_ILCreateNetwork	(void) DECLSPEC_HIDDEN;
302 LPITEMIDLIST	_ILCreateNetHood	(void) DECLSPEC_HIDDEN;
303 #ifdef __REACTOS__
304 LPITEMIDLIST	_ILCreateAdminTools	(void);
305 #endif
306 LPITEMIDLIST	_ILCreateBitBucket	(void) DECLSPEC_HIDDEN;
307 LPITEMIDLIST	_ILCreateDrive		(LPCWSTR) DECLSPEC_HIDDEN;
308 LPITEMIDLIST    _ILCreateEntireNetwork  (void) DECLSPEC_HIDDEN;
309 
310 /*
311  * helper functions (getting struct-pointer)
312  */
313 LPPIDLDATA	_ILGetDataPointer	(LPCITEMIDLIST) DECLSPEC_HIDDEN;
314 LPSTR		_ILGetTextPointer	(LPCITEMIDLIST) DECLSPEC_HIDDEN;
315 IID		*_ILGetGUIDPointer	(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
316 FileStructW     *_ILGetFileStructW      (LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
317 
318 /*
319  * debug helper
320  */
321 void	pdump	(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
322 BOOL	pcheck	(LPCITEMIDLIST pidl) DECLSPEC_HIDDEN;
323 
324 /*
325  * aPidl helper
326  */
327 void _ILFreeaPidl(LPITEMIDLIST * apidl, UINT cidl) DECLSPEC_HIDDEN;
328 PITEMID_CHILD* _ILCopyaPidl(PCUITEMID_CHILD_ARRAY apidlsrc, UINT cidl) DECLSPEC_HIDDEN;
329 LPITEMIDLIST * _ILCopyCidaToaPidl(LPITEMIDLIST* pidl, const CIDA * cida) DECLSPEC_HIDDEN;
330 
331 BOOL ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type) DECLSPEC_HIDDEN;
332 
333 #ifdef __cplusplus
334 } /* extern "C" */
335 #endif
336 
337 #endif /* __WINE_PIDL_H */
338