Source code of Windows XP (NT5)
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.

773 lines
20 KiB

  1. /*****************************************************************************
  2. *
  3. * map.h - Main private header file
  4. *
  5. *****************************************************************************/
  6. /*****************************************************************************
  7. *
  8. * Coding conventions:
  9. *
  10. * + Follow standard shell coding conventions.
  11. *
  12. * + Standard K&R brace placement and indentation style.
  13. *
  14. * + Indent by 4 spaces.
  15. *
  16. * + Fully-brace all dependent clauses. Never write "if (c) foo();"
  17. *
  18. * + Do not return in the middle of a function. If forced,
  19. * use a "goto exit". This way, you can stick entry/exit stuff
  20. * later without getting caught out. (I learned this rule the
  21. * hard way.)
  22. *
  23. * + Declare variables with narrowest possible scope.
  24. *
  25. * + Always test for success, not failure! The compiler will
  26. * thank you.
  27. *
  28. *****************************************************************************/
  29. /*****************************************************************************
  30. *
  31. * NOTE! This code was written for readability, not efficiency.
  32. *
  33. * I'm trusting the compiler to do optimizations like these:
  34. *
  35. * "Parameter alias":
  36. *
  37. * Function(LPFOO pfoo)
  38. * {
  39. * LPBAR pbar = (LPBAR)pfoo;
  40. * ... use pbar and never mention pfoo again ...
  41. * }
  42. *
  43. * --> becomes
  44. *
  45. * Function(LPFOO pfoo)
  46. * {
  47. * #define pbar ((LPBAR)pfoo)
  48. * ... use pbar and never mention pfoo again ...
  49. * #undef pbar
  50. * }
  51. *
  52. * "Speculative Execution":
  53. *
  54. * Function(PFOO pfoo)
  55. * {
  56. * BOOL fRc;
  57. * if (... condition 1 ...) {
  58. * ... complicated stuff ...
  59. * *pfoo = result;
  60. * fRc = 1;
  61. * } else { // condition 1 failed
  62. * *pfoo = 0;
  63. * fRc = 0;
  64. * }
  65. * return fRc;
  66. * }
  67. *
  68. * --> becomes
  69. *
  70. * Function(PFOO pfoo)
  71. * {
  72. * BOOL fRc = 0;
  73. * *pfoo = 0;
  74. * if (... condition 1 ...) {
  75. * ... complicated stuff ...
  76. * *pfoo = result;
  77. * fRc = 1;
  78. * }
  79. * return fRc;
  80. * }
  81. *
  82. * "Single Exit":
  83. *
  84. * Function(...)
  85. * {
  86. * BOOL fRc;
  87. * if (... condition 1 ...) {
  88. * ...
  89. * if (... condition 2 ...) {
  90. * ...
  91. * fRc = 1;
  92. * } else { // condition 2 failed
  93. * ... clean up ...
  94. * fRc = 0;
  95. * }
  96. * } else { // condition 1 failed
  97. * ... clean up ...
  98. * fRc = 0;
  99. * }
  100. * return fRc;
  101. * }
  102. *
  103. * --> becomes
  104. *
  105. * Function(...)
  106. * {
  107. * if (... condition 1 ...) {
  108. * ...
  109. * if (... condition 2 ...) {
  110. * ...
  111. * return 1;
  112. * } else { // condition 2 failed
  113. * ... clean up ...
  114. * return 0;
  115. * }
  116. * } else { // condition 1 failed
  117. * ... clean up ...
  118. * return 0;
  119. * }
  120. * NOTREACHED;
  121. * }
  122. *
  123. *
  124. *
  125. *****************************************************************************/
  126. #define STRICT
  127. #undef WIN32_LEAN_AND_MEAN
  128. #define WIN32_LEAN_AND_MEAN
  129. #define NOIME
  130. #define NOSERVICE
  131. #undef WINVER
  132. #undef _WIN32_WINDOWS
  133. #define WINVER 0x0400 /* Windows 4.0 compatible */
  134. #define _WIN32_WINDOWS 0x0400 /* Windows 4.0 compatible */
  135. #include <windows.h>
  136. #ifdef RC_INVOKED /* Define some tags to speed up rc.exe */
  137. #define __RPCNDR_H__ /* Don't need RPC network data representation */
  138. #define __RPC_H__ /* Don't need RPC */
  139. #include <oleidl.h> /* Get the DROPEFFECT stuff */
  140. #define _OLE2_H_ /* But none of the rest */
  141. #define _WINDEF_
  142. #define _WINBASE_
  143. #define _WINGDI_
  144. #define NONLS
  145. #define _WINCON_
  146. #define _WINREG_
  147. #define _WINNETWK_
  148. #define _INC_COMMCTRL
  149. #define _INC_SHELLAPI
  150. #else
  151. #include <windowsx.h>
  152. #include <regstr.h>
  153. #endif
  154. #include <shlobj.h>
  155. #include <shellapi.h>
  156. #ifdef DBG /* NT build process uses DBG */
  157. #define DEBUG
  158. #endif
  159. /*****************************************************************************
  160. *
  161. * Int64 goo.
  162. *
  163. *****************************************************************************/
  164. #define SetWindowPointer(hwnd, i, p) SetWindowLongPtr(hwnd, i, (LRESULT)(p))
  165. #define GetWindowPointer(hwnd, i) (void *)GetWindowLongPtr(hwnd, i)
  166. /*****************************************************************************
  167. *
  168. * Stuff
  169. *
  170. *****************************************************************************/
  171. #define IToClass(T, f, p) CONTAINING_RECORD(p, T, f)
  172. #define _IOffset(T, f) FIELD_OFFSET(T, f)
  173. /*****************************************************************************
  174. *
  175. * Resource identifiers
  176. *
  177. *****************************************************************************/
  178. /*****************************************************************************
  179. *
  180. * Dialogs
  181. *
  182. *****************************************************************************/
  183. #define IDC_STATIC -1
  184. #define IDD_MAIN 1
  185. #define IDC_FROM 16
  186. #define IDC_TO 17
  187. /*****************************************************************************
  188. *
  189. * Strings
  190. *
  191. *****************************************************************************/
  192. #define IDS_KEYFIRST 32
  193. #define IDS_CAPSLOCK 32
  194. #define IDS_LCTRL 33
  195. #define IDS_RCTRL 34
  196. #define IDS_LALT 35
  197. #define IDS_RALT 36
  198. #define IDS_LSHIFT 37
  199. #define IDS_RSHIFT 38
  200. #define IDS_LWIN 39
  201. #define IDS_RWIN 40
  202. #define IDS_APPS 41
  203. #define IDS_KEYLAST 41
  204. #define IDS_NUMKEYS (IDS_KEYLAST - IDS_KEYFIRST + 1)
  205. #ifndef RC_INVOKED
  206. /*****************************************************************************
  207. *
  208. * Stuff I'm tired of typing over and over.
  209. *
  210. *****************************************************************************/
  211. typedef LPITEMIDLIST PIDL, *PPIDL;
  212. typedef LPCITEMIDLIST PCIDL;
  213. typedef LPSHELLFOLDER PSF;
  214. typedef LPVOID PV;
  215. typedef LPVOID *PPV;
  216. typedef LPCVOID PCV;
  217. typedef REFIID RIID;
  218. typedef LPUNKNOWN PUNK;
  219. /*****************************************************************************
  220. *
  221. * Baggage - Stuff I carry everywhere
  222. *
  223. *****************************************************************************/
  224. #define INTERNAL NTAPI /* Called only within a translation unit */
  225. #define EXTERNAL NTAPI /* Called from other translation units */
  226. #define INLINE static __inline
  227. #define BEGIN_CONST_DATA data_seg(".text", "CODE")
  228. #define END_CONST_DATA data_seg(".data", "DATA")
  229. #define OBJAT(T, v) (*(T *)(v)) /* Pointer punning */
  230. #define PUN(T, v) OBJAT(T, &(v)) /* General-purpose type-punning */
  231. /*
  232. * Convert a count of TCHAR's to a count of bytes.
  233. */
  234. #define cbCtch(ctch) ((ctch) * sizeof(TCHAR))
  235. /*
  236. * Convert an object (X) to a count of bytes (cb).
  237. */
  238. #define cbX(X) sizeof(X)
  239. /*
  240. * Convert an array name (A) to a generic count (c).
  241. */
  242. #define cA(a) (cbX(a)/cbX(a[0]))
  243. /*
  244. * Convert an array name (A) to a pointer to its Max.
  245. * (I.e., one past the last element.)
  246. */
  247. #define pvMaxA(a) (&a[cA(a)])
  248. #define pvSubPvCb(pv, cb) ((PV)((PBYTE)pv - (cb)))
  249. #define pvAddPvCb(pv, cb) ((PV)((PBYTE)pv + (cb)))
  250. #define cbSubPvPv(p1, p2) ((PBYTE)(p1) - (PBYTE)(p2))
  251. /*
  252. * Round cb up to the nearest multiple of cbAlign. cbAlign must be
  253. * a power of 2 whose evaluation entails no side-effects.
  254. */
  255. #define ROUNDUP(cb, cbAlign) ((((cb) + (cbAlign) - 1) / (cbAlign)) * (cbAlign))
  256. /*
  257. * lfNeVV
  258. *
  259. * Given two values, return zero if they are equal and nonzero if they
  260. * are different. This is the same as (v1) != (v2), except that the
  261. * return value on unequal is a random nonzero value instead of 1.
  262. * (lf = logical flag)
  263. *
  264. * lfNePvPv
  265. *
  266. * The same as lfNeVV, but for pointers.
  267. *
  268. * lfPv
  269. *
  270. * Nonzero if pv is not null.
  271. *
  272. */
  273. #define lfNeVV(v1, v2) ((v1) - (v2))
  274. #define lfNePvPv(v1, v2) lfNeVV((DWORD)(PV)(v1), (DWORD)(PV)(v2))
  275. #define lfPv(pv) ((BOOL)(PV)(pv))
  276. /*
  277. * land -- Logical and. Evaluate the first. If the first is zero,
  278. * then return zero. Otherwise, return the second.
  279. */
  280. #define fLandFF(f1, f2) ((f1) ? (f2) : 0)
  281. /*
  282. * lor -- Logical or. Evaluate the first. If the first is nonzero,
  283. * return it. Otherwise, return the second.
  284. *
  285. * Unfortunately, due to the stupidity of the C language, this can
  286. * be implemented only with a GNU extension. In the non-GNU case,
  287. * we return 1 if the first is nonzero.
  288. */
  289. #if defined(__GNUC__)
  290. #define fLorFF(f1, f2) ({ typeof (f1) _f = f1; if (!_f) _f = f2; _f; })
  291. #else
  292. #define fLorFF(f1, f2) ((f1) ? 1 : (f2))
  293. #endif
  294. /*
  295. * limp - logical implication. True unless the first is nonzero and
  296. * the second is zero.
  297. */
  298. #define fLimpFF(f1, f2) (!(f1) || (f2))
  299. /*
  300. * leqv - logical equivalence. True if both are zero or both are nonzero.
  301. */
  302. #define fLeqvFF(f1, f2) (!(f1) == !(f2))
  303. /*
  304. * InOrder - checks that i1 <= i2 < i3.
  305. */
  306. #define fInOrder(i1, i2, i3) ((unsigned)((i2)-(i1)) < (unsigned)((i3)-(i1)))
  307. /*
  308. * CopyPvPvCb - Copy some memory around
  309. * MovePvPvCb - Move some memory around
  310. */
  311. #define CopyPvPvCb RtlCopyMemory
  312. #define MovePvPvCb RtlMoveMemory
  313. /*
  314. * memeq - Reverse of memcmp
  315. */
  316. #define memeq !memcmp
  317. /*
  318. * fPvPfnCmpPv - Compare two objects for equality using the comparison
  319. * function and the desired outcome. E.g.,
  320. *
  321. * fPvPfnCmpPv(psz1, lstrcmpi, >, psz2)
  322. *
  323. * returns nonzero if psz1 is greater than psz2 according
  324. * to lstrcmpi.
  325. */
  326. #define fPvPfnCmpPv(p1, pfn, cmp, p2) (pfn(p1, p2) cmp 0)
  327. /*
  328. * lstreq - nonzero if two strings (according to lstrcmp) are equal
  329. * lstrne - nonzero if two strings (according to lstrcmp) are different
  330. *
  331. * lstrieq - nonzero if two strings (according to lstrcmpi) are equal
  332. * lstrine - nonzero if two strings (according to lstrcmpi) are different
  333. *
  334. * lstrieqA - nonzero if two strings (according to lstrcmpiA) are equal
  335. * lstrineA - nonzero if two strings (according to lstrcmpiA) are different
  336. */
  337. #define lstreq !lstrcmp
  338. #define lstrne lstrcmp
  339. #define lstrieq !lstrcmpi
  340. #define lstrine lstrcmpi
  341. #define lstrieqA !lstrcmpiA
  342. #define lstrineA lstrcmpiA
  343. /*****************************************************************************
  344. *
  345. * Wrappers and other quickies
  346. *
  347. *****************************************************************************/
  348. #define pvExchangePpvPv(ppv, pv) \
  349. InterlockedExchangePointer(ppv, pv)
  350. #define hresUs(us) MAKE_HRESULT(SEVERITY_SUCCESS, 0, (USHORT)(us))
  351. #define hresLe(le) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, (USHORT)(le))
  352. #define ILIsSimple(pidl) (ILIsEmpty(_ILNext(pidl)))
  353. /*****************************************************************************
  354. *
  355. * Static globals: Initialized at PROCESS_ATTACH and never modified.
  356. *
  357. *****************************************************************************/
  358. HINSTANCE g_hinst; /* My instance handle */
  359. DEFINE_GUID(CLSID_KeyRemap, 0x176AA2C0, 0x9E15, 0x11cf,
  360. 0xbf,0xc7,0x44,0x45,0x53,0x54,0,0);
  361. /*****************************************************************************
  362. *
  363. * Dynamic Globals. There should be as few of these as possible.
  364. *
  365. * All access to dynamic globals must be thread-safe.
  366. *
  367. *****************************************************************************/
  368. ULONG g_cRef; /* Global reference count */
  369. /*****************************************************************************
  370. *
  371. * mapcf.c - Class Factory
  372. *
  373. *****************************************************************************/
  374. STDMETHODIMP CMapFactory_New(RIID riid, PPV ppvObj);
  375. /*****************************************************************************
  376. *
  377. * mappsx.c - IPropSheetExt, IShellExtInit
  378. *
  379. *****************************************************************************/
  380. STDMETHODIMP CMapPsx_New(RIID riid, PPV ppvObj);
  381. /*****************************************************************************
  382. *
  383. * mapps.c - Property sheet
  384. *
  385. *****************************************************************************/
  386. INT_PTR CALLBACK MapPs_DlgProc(HWND hdlg, UINT wm, WPARAM wParam, LPARAM lParam);
  387. /*****************************************************************************
  388. *
  389. * Common object managers.
  390. *
  391. *****************************************************************************/
  392. typedef struct PREVTBL0 { /* Simple (non-OLE) object */
  393. void (NTAPI *FinalizeProc)(PV pv); /* Finalization procedure */
  394. } PREVTBL0, *PPREVTBL0;
  395. typedef struct PREVTBL { /* Primary interface */
  396. REFIID riid; /* Type of this object */
  397. void (NTAPI *FinalizeProc)(PV pv); /* Finalization procedure */
  398. } PREVTBL, *PPREVTBL;
  399. typedef struct PREVTBL2 { /* Secondary interface */
  400. ULONG lib; /* offset from start of object */
  401. } PREVTBL2, *PPREVTBL2;
  402. #ifdef DEBUG
  403. #define Simple_Interface(C) Primary_Interface(C, IUnknown); \
  404. Default_QueryInterface(C) \
  405. Default_AddRef(C) \
  406. Default_Release(C)
  407. #define Simple_Vtbl(C) Primary_Vtbl(C)
  408. #define Simple_Interface_Begin(C) Primary_Interface_Begin(C, IUnknown)
  409. #define Simple_Interface_End(C) Primary_Interface_End(C, IUnknown)
  410. #else
  411. #define Simple_Interface(C) Primary_Interface(C, IUnknown)
  412. #define Simple_Vtbl(C) Primary_Vtbl(C)
  413. #define Simple_Interface_Begin(C) \
  414. struct S_##C##Vtbl c_####C##VI = { { \
  415. &IID_##IUnknown, \
  416. C##_Finalize, \
  417. }, { \
  418. Common##_QueryInterface, \
  419. Common##_AddRef, \
  420. Common##_Release, \
  421. #define Simple_Interface_End(C) Primary_Interface_End(C, IUnknown)
  422. #endif
  423. #define Primary_Interface(C, I) \
  424. extern struct S_##C##Vtbl { \
  425. PREVTBL prevtbl; \
  426. I##Vtbl vtbl; \
  427. } c_##C##VI \
  428. #define Primary_Vtbl(C) &c_##C##VI.vtbl
  429. #define Primary_Interface_Begin(C, I) \
  430. struct S_##C##Vtbl c_####C##VI = { { \
  431. &IID_##I, \
  432. C##_Finalize, \
  433. }, { \
  434. C##_QueryInterface, \
  435. C##_AddRef, \
  436. C##_Release, \
  437. #define Primary_Interface_End(C, I) \
  438. } }; \
  439. #define Secondary_Interface(C, I) \
  440. extern struct S_##I##_##C##Vtbl { \
  441. PREVTBL2 prevtbl; \
  442. I##Vtbl vtbl; \
  443. } c_##I##_##C##VI \
  444. #define Secondary_Vtbl(C, I) &c_##I##_##C##VI.vtbl
  445. #define Secondary_Interface_Begin(C, I, nm) \
  446. struct S_##I##_##C##Vtbl c_##I##_##C##VI = { { \
  447. _IOffset(C, nm), \
  448. }, { \
  449. Forward_QueryInterface, \
  450. Forward_AddRef, \
  451. Forward_Release, \
  452. #define Secondary_Interface_End(C, I, nm) \
  453. } }; \
  454. STDMETHODIMP Common_QueryInterface(PV, REFIID, PPV);
  455. STDMETHODIMP_(ULONG) _Common_AddRef(PV pv);
  456. STDMETHODIMP_(ULONG) _Common_Release(PV pv);
  457. /*
  458. * In DEBUG, go through the vtbl for additional squirties.
  459. */
  460. #ifdef DEBUG
  461. #define Common_AddRef(punk) \
  462. ((IUnknown *)(punk))->lpVtbl->AddRef((IUnknown *)(punk))
  463. #define Common_Release(punk) \
  464. ((IUnknown *)(punk))->lpVtbl->Release((IUnknown *)(punk))
  465. #else
  466. #define Common_AddRef _Common_AddRef
  467. #define Common_Release _Common_Release
  468. #endif
  469. void EXTERNAL Common_Finalize(PV);
  470. STDMETHODIMP _Common_New(ULONG cb, PV vtbl, PPV ppvObj);
  471. #define Common_NewCb(cb, C, ppvObj) _Common_New(cb, Primary_Vtbl(C), ppvObj)
  472. #define Common_New(C, ppvObj) Common_NewCb(cbX(C), C, ppvObj)
  473. STDMETHODIMP Forward_QueryInterface(PV pv, REFIID riid, PPV ppvObj);
  474. STDMETHODIMP_(ULONG) Forward_AddRef(PV pv);
  475. STDMETHODIMP_(ULONG) Forward_Release(PV pv);
  476. /*****************************************************************************
  477. *
  478. * Common_CopyAddRef
  479. *
  480. * Copy a pointer and increment its reference count.
  481. *
  482. * Cannot be a macro because Common_AddRef evaluates its argument
  483. * twice.
  484. *
  485. *****************************************************************************/
  486. INLINE void Common_CopyAddRef(PV pvDst, PV pvSrc)
  487. {
  488. PPV ppvDst = pvDst;
  489. *ppvDst = pvSrc;
  490. Common_AddRef(pvSrc);
  491. }
  492. /*****************************************************************************
  493. *
  494. * Invoking OLE methods.
  495. *
  496. * Invoke_Release is called with a pointer to the object, not with
  497. * the object itself. It zeros out the variable on the release.
  498. *
  499. *****************************************************************************/
  500. void EXTERNAL Invoke_AddRef(PV pv);
  501. void EXTERNAL Invoke_Release(PV pv);
  502. /*****************************************************************************
  503. *
  504. * assert.c - Assertion stuff
  505. *
  506. *****************************************************************************/
  507. #define AssertNow(c) switch(0) case 0: case c:
  508. #define CAssertNowPP(c,l) INLINE void Assert##l(void) { AssertNow(c); }
  509. #define CAssertNowP(c,l) CAssertNowPP(c,l)
  510. #define CAssertNow(c) CAssertNowP(c,__LINE__)
  511. typedef enum {
  512. sqflAlways = 0x00000000, /* Unconditional */
  513. sqflDll = 0x00000001, /* Dll bookkeeping */
  514. sqflFactory = 0x00000002, /* IClassFactory */
  515. sqflPsx = 0x00000004, /* IPropSheetExt */
  516. sqflPs = 0x00000008, /* Property sheet */
  517. sqflCommon = 0x00000000, /* common.c */
  518. sqflError = 0x80000000, /* Errors */
  519. } SQFL; /* squiffle */
  520. void EXTERNAL SquirtSqflPtszV(SQFL sqfl, LPCTSTR ptsz, ...);
  521. int EXTERNAL AssertPtszPtszLn(LPCTSTR ptszExpr, LPCTSTR ptszFile, int iLine);
  522. #ifndef DEBUG
  523. #define SquirtSqflPtszV sizeof
  524. #endif
  525. /*****************************************************************************
  526. *
  527. * Procedure enter/exit tracking.
  528. *
  529. * Start a procedure with
  530. *
  531. * EnterProc(ProcedureName, (_ "format", arg, arg, arg, ...));
  532. *
  533. * The format string is documented in EmitPal.
  534. *
  535. * End a procedure with one of the following:
  536. *
  537. * ExitProc();
  538. *
  539. * Procedure returns no value.
  540. *
  541. * ExitProcX();
  542. *
  543. * Procedure returns an arbitrary DWORD.
  544. *
  545. * ExitOleProc();
  546. *
  547. * Procedure returns an HRESULT (named "hres").
  548. *
  549. * ExitOleProcPpv(ppvOut);
  550. *
  551. * Procedure returns an HRESULT (named "hres") and, on success,
  552. * puts a new object in ppvOut.
  553. *
  554. *****************************************************************************/
  555. #define cpvArgMax 10 /* Max of 10 args per procedure */
  556. typedef struct ARGLIST {
  557. LPCSTR pszProc;
  558. LPCSTR pszFormat;
  559. PV rgpv[cpvArgMax];
  560. } ARGLIST, *PARGLIST;
  561. void EXTERNAL ArgsPalPszV(PARGLIST pal, LPCSTR psz, ...);
  562. void EXTERNAL EnterSqflPszPal(SQFL sqfl, LPCTSTR psz, PARGLIST pal);
  563. void EXTERNAL ExitSqflPalHresPpv(SQFL, PARGLIST, HRESULT, PPV);
  564. #ifdef DEBUG
  565. SQFL sqflCur;
  566. #define AssertFPtsz(c, ptsz) \
  567. ((c) ? 0 : AssertPtszPtszLn(ptsz, TEXT(__FILE__), __LINE__))
  568. #define ValidateF(c) \
  569. ((c) ? 0 : AssertPtszPtszLn(TEXT(#c), TEXT(__FILE__), __LINE__))
  570. #define D(x) x
  571. #define SetupEnterProc(nm) \
  572. static CHAR s_szProc[] = #nm; \
  573. ARGLIST _al[1] \
  574. #define _ _al,
  575. #define ppvBool ((PPV)1)
  576. #define ppvVoid ((PPV)2)
  577. #define DoEnterProc(v) \
  578. ArgsPalPszV v; \
  579. EnterSqflPszPal(sqfl, s_szProc, _al) \
  580. #define EnterProc(nm, v) \
  581. SetupEnterProc(nm); \
  582. DoEnterProc(v) \
  583. #define ExitOleProcPpv(ppv) \
  584. ExitSqflPalHresPpv(sqfl, _al, hres, (PPV)(ppv)) \
  585. #define ExitOleProc() \
  586. ExitOleProcPpv(0) \
  587. #define ExitProc() \
  588. ExitSqflPalHresPpv(sqfl, _al, 0, ppvVoid) \
  589. #define ExitProcX(x) \
  590. ExitSqflPalHresPpv(sqfl, _al, (HRESULT)(x), ppvBool) \
  591. #else
  592. #define AssertFPtsz(c, ptsz)
  593. #define ValidateF(c) (c)
  594. #define D(x)
  595. #define SetupEnterProc(nm)
  596. #define DoEnterProc(v)
  597. #define EnterProc(nm, v)
  598. #define ExitOleProcPpv(ppv)
  599. #define ExitOleProc()
  600. #define ExitProc()
  601. #endif
  602. #define AssertF(c) AssertFPtsz(c, TEXT(#c))
  603. /*****************************************************************************
  604. *
  605. * Macros that forward to the common handlers after squirting.
  606. * Use these only in DEBUG.
  607. *
  608. * It is assumed that sqfl has been #define'd to the appropriate sqfl.
  609. *
  610. *****************************************************************************/
  611. #ifdef DEBUG
  612. #define Default_QueryInterface(Class) \
  613. STDMETHODIMP \
  614. Class##_QueryInterface(PV pv, RIID riid, PPV ppvObj) \
  615. { \
  616. SquirtSqflPtszV(sqfl, TEXT(#Class) TEXT("_QueryInterface()")); \
  617. return Common_QueryInterface(pv, riid, ppvObj); \
  618. } \
  619. #define Default_AddRef(Class) \
  620. STDMETHODIMP_(ULONG) \
  621. Class##_AddRef(PV pv) \
  622. { \
  623. ULONG ulRc = _Common_AddRef(pv); \
  624. SquirtSqflPtszV(sqfl, TEXT(#Class) \
  625. TEXT("_AddRef(%08x) -> %d"), pv, ulRc); \
  626. return ulRc; \
  627. } \
  628. #define Default_Release(Class) \
  629. STDMETHODIMP_(ULONG) \
  630. Class##_Release(PV pv) \
  631. { \
  632. ULONG ulRc = _Common_Release(pv); \
  633. SquirtSqflPtszV(sqfl, TEXT(#Class) \
  634. TEXT("_Release(%08x) -> %d"), pv, ulRc); \
  635. return ulRc; \
  636. } \
  637. #endif
  638. /*****************************************************************************
  639. *
  640. * mem.c
  641. *
  642. * Be extremely careful with FreePv, because it doesn't work if
  643. * the pointer is null.
  644. *
  645. *****************************************************************************/
  646. STDMETHODIMP EXTERNAL ReallocCbPpv(UINT cb, PV ppvObj);
  647. STDMETHODIMP EXTERNAL AllocCbPpv(UINT cb, PV ppvObj);
  648. #define FreePpv(ppv) ReallocCbPpv(0, ppv)
  649. #define FreePv(pv) LocalFree((HLOCAL)(pv))
  650. #endif /* !RC_INVOKED */