Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

872 lines
29 KiB

  1. #ifndef _SHELLPRV_H_
  2. #define _SHELLPRV_H_
  3. // We now always rely on Win2k or Millennium at least.
  4. #define OVERRIDE_SHLWAPI_PATH_FUNCTIONS // see comment in shsemip.h
  5. #define _SHELL32_
  6. #define _WIN32_DCOM // for COINIT_DISABLE_OLE1DDE
  7. #ifdef __cplusplus
  8. #define NO_INCLUDE_UNION
  9. #endif /* __cplusplus */
  10. #define NOWINDOWSX
  11. #ifndef STRICT
  12. #define STRICT
  13. #endif
  14. #define OEMRESOURCE // FSMenu needs the menu triangle
  15. #define INC_OLE2
  16. #define CONST_VTABLE
  17. // Disable a few warnings so we can include the system header files at /W4.
  18. #include "w4warn.h"
  19. #pragma warning(disable:4706) // assignment within conditional expression
  20. #pragma warning(disable:4127) // conditional expression is constant
  21. #pragma warning(disable:4131) // 'CreateInfoFile' : uses old-style declarator
  22. #pragma warning(disable:4221) // nonstandard extension used : 'pFrom' : cannot be initialized using address of automatic variable 'szBBPathToNuke'
  23. #pragma warning(disable:4245) // 'initializing' : conversion from 'const int' to 'const DWORD', signed/unsigned mismatch
  24. #pragma warning(disable:4057) // '=' : 'CHAR *' differs in indirection to slightly different base types from 'PBYTE '
  25. #pragma warning(disable:4189) // 'fWrite' : local variable is initialized but not referenced
  26. #pragma warning(disable:4701) // local variable 'lListIndex' may be used without having been initialized
  27. #pragma warning(disable:4213) // nonstandard extension used : cast on l-value
  28. #pragma warning(disable:4702) // unreachable code
  29. #pragma warning(disable:4127) // conditional expression is constant
  30. #pragma warning(disable:4210) // nonstandard extension used : function given file scope
  31. #pragma warning(disable:4055) // 'type cast' : from data pointer 'IDataObject *' to function pointer 'FARPROC '
  32. #pragma warning(disable:4267) // '=' : conversion from 'size_t' to 'UINT', possible loss of data
  33. #pragma warning(disable:4328) // indirection alignment of formal parameter 4 (2) is greater than the actual argument alignment (1)
  34. // These NT headers must come before <windows.h> or you get redefinition
  35. // errors! It's a miracle the system builds at all...
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif /* __cplusplus */
  39. #include <nt.h> // Some of the NT specific code needs Rtl functions
  40. #include <ntrtl.h> // which requires all of these header files...
  41. #include <nturtl.h>
  42. #include <ntseapi.h>
  43. #include <dfsfsctl.h>
  44. #ifdef __cplusplus
  45. } /* End of extern "C" */
  46. #endif /* __cplusplus */
  47. #define CC_INTERNAL // this is because docfind uses the commctrl internal prop sheet structures
  48. //--------------------------------------------------------------------------
  49. //
  50. // The order of these is critical for ATL.
  51. //
  52. // 1. ATL has its own definition of InlineIsEqualGUID that conflicts with
  53. // the definition in <objbase.h>, so we must explicitly include
  54. // <ole2.h> to get the <objbase.h> definition, then use a hacky macro
  55. // to disable the ATL version so it doesn't conflict with the OLE one.
  56. //
  57. // 2. ATL has methods called SubclassWindow, which conflicts with a
  58. // macro in <windowsx.h>, so we must include <windowsx.h> after ATL.
  59. //
  60. // 3. We want ATL to use the shell debug macros, so we must include
  61. // <debug.h> before ATL so it can see the shell debug macros.
  62. //
  63. // 4. VariantInit is such a trivial function that we inline it in order
  64. // to avoid pulling in OleAut32.
  65. //
  66. // 5. We want ATL to use the shell version of the ANSI/UNICODE conversion
  67. // functions (because the shell versions can be called from C).
  68. //
  69. #include <oaidl.h>
  70. #include <docobj.h>
  71. #include <windows.h>
  72. #include "shfusion.h"
  73. #include <ole2.h> // Get the real InlineIsEqualGUID
  74. #define _ATL_NO_DEBUG_CRT // Use the shell debug macros
  75. #include <stddef.h>
  76. #include <debug.h> // Get the shell debug macros
  77. #include <shconv.h> // Shell version of <atlconv.h>
  78. #define VariantInit(p) memset(p, 0, sizeof(*(p)))
  79. #ifdef __cplusplus
  80. #define _ATL_APARTMENT_THREADED
  81. #ifndef _SYS_GUID_OPERATORS_
  82. // Re-route the ATL version of InlineIsEqualGUID
  83. #define InlineIsEqualGUID ATL_InlineIsEqualGUID
  84. #endif
  85. #include <atlbase.h>
  86. //You may derive a class from CComModule and use it if you want to override
  87. //something, but do not change the name of _Module
  88. extern CComModule _Module;
  89. #include <atlcom.h>
  90. #include <atlhost.h>
  91. #include <atlctl.h>
  92. #include <atliface.h>
  93. #include <atlwin.h>
  94. #ifndef _SYS_GUID_OPERATORS_
  95. #undef InlineIsEqualGUID // Return InlineIsEqualGUID to its normal state
  96. #endif
  97. #include <memt.h>
  98. #endif /* __cplusplus */
  99. // end of ATL Stuff
  100. //--------------------------------------------------------------------------
  101. #ifndef _SYS_GUID_OPERATORS_
  102. #ifdef _OLE32_ // {
  103. // turning on _OLE32_ (which we did for delay load stuff) gives us f-a-t
  104. // versions of IsEqualGUID. undo that here (hack on top of a hack...)
  105. #undef IsEqualGUID
  106. #ifdef __cplusplus
  107. __inline BOOL IsEqualGUID(IN REFGUID rguid1, IN REFGUID rguid2)
  108. {
  109. return !memcmp(&rguid1, &rguid2, sizeof(GUID));
  110. }
  111. #else // ! __cplusplus
  112. #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
  113. #endif // __cplusplus
  114. #endif // }
  115. #endif
  116. #ifdef __cplusplus
  117. extern "C" { /* Assume C declarations for C++ */
  118. #endif /* __cplusplus */
  119. // This flag indicates that we are on a system where data alignment is a concern
  120. #if (defined(UNICODE) && (defined(_MIPS_) || defined(_ALPHA_) || defined(_PPC_)))
  121. #define ALIGNMENT_SCENARIO
  122. #endif
  123. #include <windowsx.h>
  124. #include <winnetp.h>
  125. // Dependencies among header files:
  126. //
  127. // <oaidl.h> must come before <shlwapi.h> if you want to have
  128. // OLE command target helper functions.
  129. //
  130. #include <hlink.h> // must include before shellp in order to get IBrowserService2!
  131. #include <commctrl.h>
  132. #include <shellapi.h>
  133. #include <wininet.h>
  134. #include <shlobj.h>
  135. #include <shlwapi.h>
  136. #include <commdlg.h>
  137. #include <port32.h> // in shell\inc
  138. #define DISALLOW_Assert
  139. #include <linkinfo.h>
  140. #include <shlobjp.h>
  141. #include <shsemip.h>
  142. #include <docobj.h>
  143. #include <shguidp.h>
  144. #include <ieguidp.h>
  145. #include <shellp.h>
  146. #include <shdocvw.h>
  147. #include <iethread.h>
  148. #include "browseui.h"
  149. #include <ccstock.h>
  150. #include <ccstock2.h>
  151. #include <objidl.h>
  152. #include "apithk.h"
  153. #define SECURITY_WIN32
  154. #include <security.h>
  155. #include <mlang.h>
  156. #include <regapix.h> // MAXIMUM_SUB_KEY_LENGTH, MAXIMUM_VALUE_NAME_LENGTH, MAXIMUM_DATA_LENGTH
  157. #include <heapaloc.h>
  158. #include <fmifs.h>
  159. #define STRSAFE_NO_DEPRECATE
  160. #include <strsafe.h>
  161. #include "util.h"
  162. #include "varutil.h"
  163. #include "cstrings.h"
  164. #include "securent.h"
  165. #include "winprtp.h"
  166. #include "qistub.h"
  167. #ifdef DEBUG
  168. #include "dbutil.h"
  169. #endif
  170. #define CP_HEBREW 1255
  171. #define CP_ARABIC 1256
  172. EXTERN_C const ITEMIDLIST c_idlDesktop; // NULL IDList
  173. #undef CharNext
  174. #undef CharPrev
  175. #define CharNext(x) ((x)+1)
  176. #define CharPrev(y,x) ((x)-1)
  177. #define IsDBCSLeadByte(x) ((x), FALSE)
  178. // these functions are not available on NT
  179. #undef ReinitializeCriticalSection
  180. #undef LoadLibrary16
  181. #undef FreeLibrary16
  182. #undef GetProcAddress16
  183. #define ReinitializeCriticalSection #error_ReinitializeCriticalSection_not_available_on_NT
  184. #define LoadLibrary16 #error_LoadLibrary16_not_available_on_NT
  185. #define FreeLibrary16 #error_FreeLibrary16_not_available_on_NT
  186. #define GetProcAddress16 #error_GetProcAddress16_not_available_on_NT
  187. #define GetModuleHandle16(sz) (0)
  188. #define GetModuleFileName16(hinst, buf, cch) buf[0]='\0'
  189. DWORD
  190. SetPrivilegeAttribute(
  191. IN LPCTSTR PrivilegeName,
  192. IN DWORD NewPrivilegeAttributes,
  193. OUT DWORD *OldPrivilegeAttribute
  194. );
  195. // drivesx.c
  196. BOOL IsUnavailableNetDrive(int iDrive);
  197. BOOL IsDisconnectedNetDrive(int iDrive);
  198. BOOL IsAudioDisc(LPTSTR pszDrive);
  199. BOOL IsDVDDisc(int iDrive);
  200. // futil.c
  201. BOOL IsShared(LPNCTSTR pszPath, BOOL fUpdateCache);
  202. DWORD GetConnection(LPCTSTR lpDev, LPTSTR lpPath, UINT cbPath, BOOL bConvertClosed);
  203. // rundll32.c
  204. HWND _CreateStubWindow(POINT* ppt, HWND hwndParent);
  205. #define STUBM_SETDATA (WM_USER)
  206. #define STUBM_GETDATA (WM_USER + 1)
  207. #define STUBM_SETICONTITLE (WM_USER + 2)
  208. #define STUBCLASS_PROPSHEET 1
  209. #define STUBCLASS_FORMAT 2
  210. // shlexe.c
  211. BOOL IsDarwinEnabled();
  212. STDAPI ParseDarwinID(LPTSTR pszDarwinDescriptor, LPTSTR pszDarwinCommand, DWORD cchDarwinCommand);
  213. // shprsht.c
  214. typedef struct {
  215. HWND hwndStub;
  216. HANDLE hClassPidl;
  217. HICON hicoStub;
  218. } UNIQUESTUBINFO;
  219. STDAPI_(BOOL) EnsureUniqueStub(LPITEMIDLIST pidl, int iClass, POINT *ppt, UNIQUESTUBINFO *pusi);
  220. STDAPI_(void) FreeUniqueStub(UNIQUESTUBINFO *pusi);
  221. STDAPI_(void) SHFormatDriveAsync(HWND hwnd, UINT drive, UINT fmtID, UINT options);
  222. // bitbuck.c
  223. void RelayMessageToChildren(HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
  224. BOOL IsFileInBitBucket(LPCTSTR pszPath);
  225. BOOL CreateWriteCloseFile(HWND hwnd, LPCTSTR pszFileName, void *pv, DWORD cbData);
  226. // idlist.c
  227. STDAPI_(BOOL) SHIsValidPidl(LPCITEMIDLIST pidl);
  228. STDAPI_(BOOL) IsExeTSAware(LPCTSTR pszExe);
  229. // exec stuff
  230. /* common exe code with error handling */
  231. #define SECL_USEFULLPATHDIR 0x00000001
  232. #define SECL_NO_UI 0x00000002
  233. #define SECL_SEPARATE_VDM 0x00000004
  234. #define SECL_LOG_USAGE 0x00000008
  235. BOOL ShellExecCmdLine(HWND hwnd, LPCTSTR lpszCommand, LPCTSTR lpszDir,
  236. int nShow, LPCTSTR lpszTitle, DWORD dwFlags);
  237. #define ISSHELLEXECSUCCEEDED(hinst) ((UINT_PTR)hinst>32)
  238. #define ISWINEXECSUCCEEDED(hinst) ((UINT_PTR)hinst>=32)
  239. void _ShellExecuteError(LPSHELLEXECUTEINFO pei, LPCTSTR lpTitle, DWORD dwErr);
  240. // fsnotify.c (private stuff) ----------------------
  241. BOOL SHChangeNotifyInit();
  242. STDAPI_(void) SHChangeNotifyTerminate(BOOL bLastTerm, BOOL bProcessShutdown);
  243. void SHChangeNotifyReceiveEx(LONG lEvent, UINT uFlags, LPCITEMIDLIST pidl, LPCITEMIDLIST pidlExtra, DWORD dwEventTime);
  244. LRESULT SHChangeNotify_OnNotify(WPARAM wParam, LPARAM lParam);
  245. LRESULT SHChangeNotify_OnChangeRegistration(WPARAM wParam, LPARAM lParam);
  246. LRESULT SHChangeNotify_OnNotifySuspendResume(WPARAM wParam, LPARAM lParam);
  247. LRESULT SHChangeNotify_OnDeviceChange(ULONG_PTR code, struct _DEV_BROADCAST_HDR *pbh);
  248. void SHChangeNotify_DesktopInit();
  249. void SHChangeNotify_DesktopTerm();
  250. STDAPI_(void) SHChangeNotifyRegisterAlias(LPCITEMIDLIST pidlReal, LPCITEMIDLIST pidlAlias);
  251. void _Shell32ThreadAddRef(BOOL fLeaveSuspended);
  252. void _Shell32ThreadRelease(UINT nClients);
  253. void _Shell32ThreadAwake(void);
  254. // Entry points for managing registering name to IDList translations.
  255. void NPTRegisterNameToPidlTranslation(LPCTSTR pszPath, LPCITEMIDLIST pidl);
  256. LPWSTR NPTMapNameToPidl(LPCWSTR pszPath, LPCITEMIDLIST *ppidl);
  257. // path.c (private stuff) ---------------------
  258. #define PQD_NOSTRIPDOTS 0x00000001
  259. STDAPI_(void) PathQualifyDef(LPTSTR psz, LPCTSTR szDefDir, DWORD dwFlags);
  260. STDAPI_(BOOL) PathIsRemovable(LPCTSTR pszPath);
  261. STDAPI_(BOOL) PathIsRemote(LPCTSTR pszPath);
  262. STDAPI_(BOOL) PathIsTemporary(LPCTSTR pszPath);
  263. STDAPI_(BOOL) PathIsWild(LPCTSTR pszPath);
  264. STDAPI_(BOOL) PathIsLnk(LPCTSTR pszFile);
  265. STDAPI_(BOOL) PathIsSlow(LPCTSTR pszFile, DWORD dwFileAttr);
  266. STDAPI_(BOOL) PathIsInvalid(LPCTSTR pPath);
  267. STDAPI_(BOOL) PathIsBinaryExe(LPCTSTR szFile);
  268. STDAPI_(BOOL) PathMergePathName(LPTSTR pPath, LPCTSTR pName);
  269. STDAPI_(BOOL) PathGetMountPointFromPath(LPCTSTR pcszPath, LPTSTR pszMountPoint, int cchMountPoint);
  270. STDAPI_(BOOL) PathIsShortcutToProgram(LPCTSTR pszFile);
  271. #if (defined(UNICODE) && (defined(_MIPS_) || defined(_ALPHA_) || defined(_PPC_)))
  272. #else
  273. #define uaPathFindExtension PathFindExtension
  274. #endif
  275. void SpecialFolderIDTerminate();
  276. void ReleaseRootFolders();
  277. extern HINSTANCE g_hinst;
  278. // get the desktop HWND if it is this process...
  279. HWND GetInProcDesktop();
  280. // Is Mirroring APIs enabled (BiDi Memphis and NT5 only)
  281. extern BOOL g_bMirroredOS;
  282. // Is DATE_LTRREADING supported by GetDateFormat() API? (it is supported in all the BiDi platforms.)
  283. extern BOOL g_bBiDiPlatform;
  284. // for control panel and printers folder:
  285. extern TCHAR const c_szNull[];
  286. extern TCHAR const c_szDotDot[];
  287. extern TCHAR const c_szRunDll[];
  288. extern TCHAR const c_szNewObject[];
  289. // lang platform
  290. extern UINT g_uCodePage;
  291. // other stuff
  292. #define HINST_THISDLL g_hinst
  293. //
  294. // Trace/dump/break flags specific to shell32.
  295. // (Standard flags defined in shellp.h)
  296. //
  297. // Trace flags
  298. #define TF_IMAGE 0x00000010 // Image/icon related stuff
  299. #define TF_PROPERTY 0x00000020 // Property traces
  300. #define TF_PATH 0x00000040 // Path whacking traces
  301. #define TF_MENU 0x00000080 // Menu stuff
  302. #define TF_ALLOC 0x00000100 // Allocation traces
  303. #define TF_REG 0x00000200 // Registry traces
  304. #define TF_DDE 0x00000400 // Shell progman DDE message tracing
  305. #define TF_HASH 0x00000800 // Hash table stuff
  306. #define TF_ASSOC 0x00001000 // File/URL Association traces
  307. #define TF_FILETYPE 0x00002000 // File Type stuff
  308. #define TF_SHELLEXEC 0x00004000 // ShellExecute stuff
  309. #define TF_OLE 0x00008000 // OLE-specific stuff
  310. #define TF_DEFVIEW 0x00010000 // Defview
  311. #define TF_PERF 0x00020000 // Performance timings
  312. #define TF_FSNOTIFY 0x00040000 // FSNotify stuff
  313. #define TF_LIFE 0x00080000 // Object lifetime traces
  314. #define TF_IDLIST 0x00100000 // "PIDLy" things
  315. #define TF_FSTREE 0x00200000 // FSTree traces
  316. #define TF_PRINTER 0x00400000 // Printer traces
  317. //#define TF_QISTUB 0x00800000 // defined in unicpp\shellprv.h
  318. #define TF_DOCFIND 0x01000000 // DocFind
  319. #define TF_MENUBAND 0x02000000 // menubands
  320. #define TF_CPANEL 0x10000000 // Control Panel
  321. #define TF_CUSTOM1 0x40000000 // Custom messages #1
  322. #define TF_CUSTOM2 0x80000000 // Custom messages #2
  323. // "Olde names"
  324. #define DM_ALLOC TF_ALLOC
  325. #define DM_REG TF_REG
  326. // Function trace flags
  327. #define FTF_DEFVIEW 0x00000004 // DefView calls
  328. #define FTF_DDE 0x00000008 // DDE functions
  329. #define FTF_CPANEL 0x00000010 // Control Panel
  330. // Dump flags
  331. #define DF_INTSHCUT 0x00000001 // Internet shortcut structures
  332. #define DF_HASH 0x00000002 // Hash table
  333. #define DF_FSNPIDL 0x00000004 // Pidl for FSNotify
  334. #define DF_URLPROP 0x00000008 // URL property structures
  335. #define DF_DEBUGQI 0x00000010
  336. #define DF_DEBUGQINOREF 0x00000020
  337. #define DF_ICONCACHE 0x00000040 // Icon cache
  338. #define DF_CLASSFLAGS 0x00000080 // File class cache
  339. #define DF_DELAYLOADDLL 0x00000100 // Delay load
  340. // Break flags
  341. #define BF_ONLOADED 0x00000010 // Stop when loaded
  342. #define BF_COCREATEINSTANCE 0x10000000 // On CoCreateInstance failure
  343. // Debugging strings
  344. #define GEN_DEBUGSTRW(str) ((str) ? (str) : L"<Null Str>")
  345. #define GEN_DEBUGSTRA(str) ((str) ? (str) : "<Null Str>")
  346. #ifdef UNICODE
  347. #define GEN_DEBUGSTR GEN_DEBUGSTRW
  348. #else // UNICODE
  349. #define GEN_DEBUGSTR GEN_DEBUGSTRA
  350. #endif // UNICODE
  351. // Note: raymondc - ATOMICRELEASE isn't particularly atomic. There is a race
  352. // condition if two people try to ATOMICRELEASE the same thing simultaneously.
  353. // shorthand
  354. #ifndef ATOMICRELEASE
  355. #ifdef __cplusplus
  356. #define ATOMICRELEASET(p, type) { if(p) { type* punkT=p; p=NULL; punkT->Release();} }
  357. #else
  358. #define ATOMICRELEASET(p, type) { if(p) { type* punkT=p; p=NULL; punkT->lpVtbl->Release(punkT);} }
  359. #endif
  360. // doing this as a function instead of inline seems to be a size win.
  361. //
  362. #ifdef NOATOMICRELESEFUNC
  363. #define ATOMICRELEASE(p) ATOMICRELEASET(p, IUnknown)
  364. #else
  365. # ifdef __cplusplus
  366. # define ATOMICRELEASE(p) IUnknown_SafeReleaseAndNullPtr(p)
  367. # else
  368. # define ATOMICRELEASE(p) IUnknown_AtomicRelease((void **)&p)
  369. # endif
  370. #endif
  371. #endif //ATOMICRELEASE
  372. #ifdef SAFERELEASE
  373. #undef SAFERELEASE
  374. #endif
  375. #define SAFERELEASE(p) ATOMICRELEASE(p)
  376. // fileicon.c
  377. void FileIconTerm(void);
  378. #define CCH_KEYMAX 64 // DOC: max size of a reg key (under shellex)
  379. void ReplaceParams(LPTSTR szDst, LPCTSTR szFile);
  380. #ifdef __IPropertyStorage_INTERFACE_DEFINED__
  381. WINSHELLAPI HRESULT SHPropVariantClear(PROPVARIANT * ppropvar);
  382. WINSHELLAPI HRESULT SHFreePropVariantArray(ULONG cel, PROPVARIANT * ppropvar);
  383. WINSHELLAPI HRESULT SHPropVariantCopy(PROPVARIANT * ppropvar, const PROPVARIANT * ppropvarFrom);
  384. #endif
  385. //
  386. // fsassoc.c
  387. //
  388. #define GCD_MUSTHAVEOPENCMD 0x0001
  389. #define GCD_ADDEXETODISPNAME 0x0002 // must be used with GCD_MUSTHAVEOPENCMD
  390. #define GCD_ALLOWPSUDEOCLASSES 0x0004 // .ext type extensions
  391. // Only valid when used with FillListWithClasses
  392. #define GCD_MUSTHAVEEXTASSOC 0x0008 // There must be at least one extension assoc
  393. BOOL GetClassDescription(HKEY hkClasses, LPCTSTR pszClass, LPTSTR szDisplayName, int cbDisplayName, UINT uFlags);
  394. //
  395. // Registry key handles
  396. //
  397. extern HKEY g_hklmApprovedExt; // For approved shell extensions
  398. // always zero, see init.c
  399. extern const LARGE_INTEGER g_li0;
  400. extern const ULARGE_INTEGER g_uli0;
  401. // from fstree.cpp and drives.cpp
  402. STDAPI SFVCB_OnAddPropertyPages(IN DWORD pv, IN SFVM_PROPPAGE_DATA * ppagedata);
  403. //
  404. // this used to be in shprst.c
  405. //
  406. #define MAX_FILE_PROP_PAGES 32
  407. HKEY NetOpenProviderClass(HDROP);
  408. void OpenNetResourceProperties(HWND, HDROP);
  409. // msgbox.c
  410. // Constructs strings like ShellMessagebox "xxx %1%s yyy %2%s..."
  411. LPTSTR WINCAPI ShellConstructMessageString(HINSTANCE hAppInst, LPCTSTR lpcText, ...);
  412. // Copy.c
  413. #define SPEED_SLOW 400
  414. DWORD GetPathSpeed(LPCTSTR pszPath);
  415. // SharedFldr.cpp
  416. STDAPI_(BOOL) SHShowSharedFolders();
  417. // mulprsht.c
  418. STDAPI_(BOOL) SHEncryptFile(LPCTSTR pszPath, BOOL fEncrypt);
  419. // wuutil.c
  420. void cdecl SetFolderStatusText(HWND hwndStatus, int iField, UINT ids,...);
  421. #ifdef DEBUG
  422. extern BOOL g_bInDllEntry;
  423. #undef SendMessage
  424. #define SendMessage SendMessageD
  425. LRESULT WINAPI SendMessageD(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
  426. //
  427. // The DEBUG build validates that every class we register is in the
  428. // unregister list so we don't leak classes at unload.
  429. //
  430. #undef RegisterClass
  431. #undef RegisterClassEx
  432. #define RegisterClass RegisterClassD
  433. #define RegisterClassEx RegisterClassExD
  434. ATOM WINAPI RegisterClassD(CONST WNDCLASS *lpWndClass);
  435. ATOM WINAPI RegisterClassExD(CONST WNDCLASSEX *lpWndClass);
  436. #endif // DEBUG
  437. #ifdef UNICODE
  438. #define RealRegisterClass RegisterClassW
  439. #define RealRegisterClassEx RegisterClassExW
  440. #else
  441. #define RealRegisterClass RegisterClassA
  442. #define RealRegisterClassEx RegisterClassExA
  443. #endif
  444. //
  445. // In DEBUG, send FindWindow through a wrapper that ensures that the
  446. // critical section is not taken. FindWindow sends interthreadmessages,
  447. // which is not obvious.
  448. //
  449. #ifdef DEBUG
  450. #undef FindWindow
  451. #undef FindWindowEx
  452. #define FindWindow FindWindowD
  453. #define FindWindowEx FindWindowExD
  454. STDAPI_(HWND) FindWindowD (LPCTSTR lpClassName, LPCTSTR lpWindowName);
  455. STDAPI_(HWND) FindWindowExD(HWND hwndParent, HWND hwndChildAfter, LPCTSTR lpClassName, LPCTSTR lpWindowName);
  456. #ifdef UNICODE
  457. #define RealFindWindowEx FindWindowExW
  458. #else
  459. #define RealFindWindowEx FindWindowExA
  460. #endif // UNICODE
  461. #endif // DEBUG
  462. // our wrapper for GetCompressedFileSize, which is NT only
  463. STDAPI_(DWORD) SHGetCompressedFileSizeW(LPCWSTR pszFileName, LPDWORD pFileSizeHigh);
  464. #undef GetCompressedFileSize
  465. #define GetCompressedFileSize SHGetCompressedFileSize
  466. #ifdef UNICODE
  467. #define SHGetCompressedFileSize SHGetCompressedFileSizeW
  468. #else
  469. #define SHGetCompressedFileSize #error // not implemented, because its an nt only API
  470. #endif // UNICODE
  471. #define ASSERTDLLENTRY ASSERT(g_bInDllEntry);
  472. //
  473. // STATIC macro
  474. //
  475. #ifndef STATIC
  476. #ifdef DEBUG
  477. #define STATIC
  478. #else
  479. #define STATIC static
  480. #endif
  481. #endif
  482. //
  483. // Debug helper functions
  484. //
  485. //
  486. // Validation functions
  487. //
  488. BOOL IsValidPSHELLEXECUTEINFO(LPSHELLEXECUTEINFO pei);
  489. #define FillExecInfo(_info, _hwnd, _verb, _file, _params, _dir, _show) \
  490. (_info).hwnd = _hwnd; \
  491. (_info).lpVerb = _verb; \
  492. (_info).lpFile = _file; \
  493. (_info).lpParameters = _params; \
  494. (_info).lpDirectory = _dir; \
  495. (_info).nShow = _show; \
  496. (_info).fMask = 0; \
  497. (_info).cbSize = SIZEOF(SHELLEXECUTEINFO);
  498. #ifdef DEBUG
  499. #if 1
  500. __inline DWORD clockrate() {LARGE_INTEGER li; QueryPerformanceFrequency(&li); return li.LowPart;}
  501. __inline DWORD clock() {LARGE_INTEGER li; QueryPerformanceCounter(&li); return li.LowPart;}
  502. #else
  503. __inline DWORD clockrate() {return 1000;}
  504. __inline DWORD clock() {return GetTickCount();}
  505. #endif
  506. #define TIMEVAR(t) DWORD t ## T; DWORD t ## N
  507. #define TIMEIN(t) t ## T = 0, t ## N = 0
  508. #define TIMESTART(t) t ## T -= clock(), t ## N ++
  509. #define TIMESTOP(t) t ## T += clock()
  510. #define TIMEFMT(t) ((DWORD)(t) / clockrate()), (((DWORD)(t) * 1000 / clockrate())%1000)
  511. #define TIMEOUT(t) if (t ## N) TraceMsg(TF_PERF, #t ": %ld calls, %ld.%03ld sec (%ld.%03ld)", t ## N, TIMEFMT(t ## T), TIMEFMT(t ## T / t ## N))
  512. #else
  513. #define TIMEVAR(t)
  514. #define TIMEIN(t)
  515. #define TIMESTART(t)
  516. #define TIMESTOP(t)
  517. #define TIMEFMT(t)
  518. #define TIMEOUT(t)
  519. #endif
  520. // in extract.c
  521. STDAPI_(DWORD) GetExeType(LPCTSTR pszFile);
  522. STDAPI_(UINT) ExtractIcons(LPCTSTR szFileName, int nIconIndex, int cxIcon, int cyIcon, HICON *phicon, UINT *piconid, UINT nIcons, UINT flags);
  523. /*
  524. in pickicon.c
  525. Return Values for PickIconDlgWithTitle()
  526. User Operation Return Values
  527. Cancel -> HRESULT_FROM_WIN32(ERROR_CANCELLED)
  528. Ok -> S_OK
  529. RestoreDefault -> S_FALSE
  530. */
  531. STDAPI PickIconDlgWithTitle(HWND hwnd, LPCTSTR pszTitle, BOOL bShowRestoreButton, LPTSTR pszIconPath, UINT cbIconPath, int *piIconIndex);
  532. // defxicon.c
  533. STDAPI SHCreateDefExtIconKey(HKEY hkey, LPCTSTR pszModule, int iIcon, int iIconOpen, int iDefIcon, int iShortcutIcon, UINT uFlags, REFIID riid, void **pxiconOut);
  534. STDAPI SHCreateDefExtIcon(LPCTSTR pszModule, int iIcon, int iIconOpen, UINT uFlags, int iDefIcon, REFIID riid, void **pxiconOut);
  535. STDAPI_(UINT) SHSysErrorMessageBox(HWND hwnd, LPCTSTR pszTitle, UINT idTemplate, DWORD err, LPCTSTR pszParam, UINT dwFlags);
  536. //======Hash Item=============================================================
  537. typedef struct _HashTable **HHASHTABLE;
  538. #define PHASHITEM LPCTSTR
  539. typedef void (CALLBACK *HASHITEMCALLBACK)(HHASHTABLE hht, LPCTSTR sz, UINT wUsage, DWORD_PTR param);
  540. STDAPI_(LPCTSTR) FindHashItem (HHASHTABLE hht, LPCTSTR lpszStr);
  541. STDAPI_(LPCTSTR) AddHashItem (HHASHTABLE hht, LPCTSTR lpszStr);
  542. STDAPI_(LPCTSTR) DeleteHashItem(HHASHTABLE hht, LPCTSTR lpszStr);
  543. STDAPI_(LPCTSTR) PurgeHashItem (HHASHTABLE hht, LPCTSTR lpszStr);
  544. #define GetHashItemName(pht, sz, lpsz, cch) StringCchCopy(lpsz, cch, sz)
  545. HHASHTABLE WINAPI CreateHashItemTable(UINT wBuckets, UINT wExtra);
  546. void WINAPI DestroyHashItemTable(HHASHTABLE hht);
  547. void WINAPI SetHashItemData(HHASHTABLE hht, LPCTSTR lpszStr, int n, DWORD_PTR dwData);
  548. DWORD_PTR WINAPI GetHashItemData(HHASHTABLE hht, LPCTSTR lpszStr, int n);
  549. void * WINAPI GetHashItemDataPtr(HHASHTABLE hht, LPCTSTR lpszStr);
  550. void WINAPI EnumHashItems(HHASHTABLE hht, HASHITEMCALLBACK callback, DWORD_PTR dwParam);
  551. #ifdef DEBUG
  552. void WINAPI DumpHashItemTable(HHASHTABLE hht);
  553. #endif
  554. //======== Text thunking stuff ===========================================================
  555. typedef struct _THUNK_TEXT_
  556. {
  557. LPTSTR m_pStr[1];
  558. } ThunkText;
  559. #ifdef UNICODE
  560. typedef CHAR XCHAR;
  561. typedef LPSTR LPXSTR;
  562. typedef const XCHAR * LPCXSTR;
  563. #define lstrlenX(r) lstrlenA(r)
  564. #else // unicode
  565. typedef WCHAR XCHAR;
  566. typedef LPWSTR LPXSTR;
  567. typedef const XCHAR * LPCXSTR;
  568. #define lstrlenX(r) lstrlenW(r)
  569. #endif // unicode
  570. ThunkText * ConvertStrings(UINT cCount, ...);
  571. #include "uastrfnc.h"
  572. #ifdef __cplusplus
  573. } /* End of extern "C" { */
  574. #endif /* __cplusplus */
  575. #include <help.h>
  576. //======== Discriminate inclusion ========================================
  577. #ifndef NO_INCLUDE_UNION // define this to avoid including all
  578. // of the extra files that were not
  579. // previously included in shellprv.h
  580. #include <wchar.h>
  581. #include <tchar.h>
  582. #include <process.h>
  583. #include <wowshlp.h>
  584. #include <vdmapi.h>
  585. #include "shell.h"
  586. #include "dde.h"
  587. #include <regstr.h>
  588. #include "findhlp.h"
  589. #include <dlgs.h>
  590. #include <msprintx.h>
  591. #include <pif.h>
  592. #include <windisk.h>
  593. #include <brfcasep.h>
  594. #include <trayp.h>
  595. #include <brfcasep.h>
  596. #include <wutilsp.h>
  597. #include "bitbuck.h"
  598. #include "drawpie.h"
  599. #include "fileop.h"
  600. #include "pidl.h"
  601. #include "ids.h"
  602. #include <newexe.h>
  603. #include "ole2dup.h"
  604. #include "os.h"
  605. #include "privshl.h"
  606. #include "reglist.h"
  607. #include "shell32p.h"
  608. #include "shitemid.h"
  609. #include "undo.h"
  610. #include "views.h"
  611. // NT shell uses 32-bit version of this pifmgr code.
  612. #ifndef NO_PIF_HDRS
  613. #include "pifmgrp.h"
  614. #include "piffntp.h"
  615. #include "pifinfp.h"
  616. #include "doshelp.h"
  617. #include "machinep.h" // Japanese domestic machine (NEC) support
  618. #endif
  619. #endif // NO_INCLUDE_UNION
  620. #include "shdguid.h"
  621. #define SetWindowBits SHSetWindowBits
  622. #define IsSameObject SHIsSameObject
  623. #define IsChildOrSelf SHIsChildOrSelf
  624. #define MenuIndexFromID SHMenuIndexFromID
  625. #define _GetMenuFromID SHGetMenuFromID
  626. #define GetCurColorRes SHGetCurColorRes
  627. #define WaitForSendMessageThread SHWaitForSendMessageThread
  628. #define MAX_URL_STRING INTERNET_MAX_URL_LENGTH
  629. // Stack allocated BSTR (to avoid calling SysAllocString)
  630. typedef struct _SA_BSTR {
  631. ULONG cb;
  632. WCHAR wsz[MAX_URL_STRING];
  633. } SA_BSTR;
  634. // A "fake" variants for use on the stack - usable for [in] parameters only!!!
  635. typedef struct _SA_BSTRGUID {
  636. UINT cb;
  637. WCHAR wsz[39];
  638. } SA_BSTRGUID;
  639. #define InitFakeBSTR(pSA_BSTR, guid) SHStringFromGUIDW((guid), (pSA_BSTR)->wsz, ARRAYSIZE((pSA_BSTR)->wsz)), (pSA_BSTR)->cb = (38*sizeof(WCHAR))
  640. //
  641. // The cb field of a BSTR is the count of bytes, not including the
  642. // terminating L('\0').
  643. //
  644. //
  645. // DECLARE_CONST_BSTR - Goes into header file (if any)
  646. // DEFINE_CONST_BSTR - Creates the variable, must already be declared
  647. // MAKE_CONST_BSTR - Combines DECLARE and DEFINE
  648. //
  649. #define DECLARE_CONST_BSTR(name, str) \
  650. extern const struct BSTR##name { ULONG cb; WCHAR wsz[sizeof(str)/sizeof(WCHAR)]; } name
  651. #define DEFINE_CONST_BSTR(name, str) \
  652. const struct BSTR##name name = { sizeof(str) - sizeof(WCHAR), str }
  653. #define MAKE_CONST_BSTR(name, str) \
  654. const struct BSTR##name { ULONG cb; WCHAR wsz[sizeof(str)/sizeof(WCHAR)]; } \
  655. name = { sizeof(str) - sizeof(WCHAR), str }
  656. DECLARE_CONST_BSTR(s_sstrIDMember, L"id");
  657. DECLARE_CONST_BSTR(s_sstrSubSRCMember, L"subscribed_url");
  658. DECLARE_CONST_BSTR(s_sstrSRCMember, L"src");
  659. //======== Header file hacks =============================================================
  660. //
  661. // The compiler will tell us if we are defining these NT5-only parameters
  662. // incorrectly. If you get "invalid redefinition" errors, it means that
  663. // the definition in windows.h changed and we need to change to match.
  664. //
  665. #define ASFW_ANY ((DWORD)-1)
  666. #define CMIDM_LINK 0x0001
  667. #define CMIDM_COPY 0x0002
  668. #define CMIDM_MOVE 0x0003
  669. // Downlevel shutdown dialog function
  670. DWORD DownlevelShellShutdownDialog(HWND hwndParent, DWORD dwItems, LPCTSTR szUsername);
  671. // from shell32\unicode\format.c
  672. STDAPI_(DWORD) SHChkDskDriveEx(HWND hwnd, LPWSTR pszDrive);
  673. //
  674. // On NT, sometimes CreateDirectory succeeds in creating the directory, but, you can not do
  675. // anything with it that directory. This happens if the directory name being created does
  676. // not have room for an 8.3 name to be tagged onto the end of it,
  677. // i.e., lstrlen(new_directory_name)+12 must be less or equal to MAX_PATH.
  678. //
  679. // the magic # "12" is 8 + 1 + 3 for and 8.3 name.
  680. //
  681. // The following macro is used in places where we need to detect this to make
  682. // MoveFile to be consistent with CreateDir(files os.c and copy.c use this)
  683. //
  684. #define IsDirPathTooLongForCreateDir(pszDir) ((lstrlen(pszDir) + 12) > MAX_PATH)
  685. // call the shlwapi version of this, note we have an export from shell32 that forwards to this
  686. #define ShellMessageBoxW ShellMessageBoxWrapW
  687. #define REGSTR_EXPLORER_ADVANCED (REGSTR_PATH_EXPLORER TEXT("\\Advanced"))
  688. #define RECTHEIGHT(rc) ((rc).bottom - (rc).top)
  689. #define RECTWIDTH(rc) ((rc).right - (rc).left)
  690. STDAPI_(BOOL) IsGuimodeSetupRunning();
  691. #endif // _SHELLPRV_H_