jwawownt32.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. {******************************************************************************}
  2. { }
  3. { 32 bit Generic Thunks API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: wownt32.h, released June 2000. The original Pascal }
  9. { code is: WowNT32.pas, released December 2000. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. unit JwaWowNT32;
  43. {$WEAKPACKAGEUNIT}
  44. {$HPPEMIT ''}
  45. {$HPPEMIT '#include "wownt32.h"'}
  46. {$HPPEMIT ''}
  47. {$I jediapilib.inc}
  48. interface
  49. uses
  50. JwaWinType;
  51. //
  52. // 16:16 -> 0:32 Pointer translation.
  53. //
  54. // WOWGetVDMPointer will convert the passed in 16-bit address
  55. // to the equivalent 32-bit flat pointer. If fProtectedMode
  56. // is TRUE, the function treats the upper 16 bits as a selector
  57. // in the local descriptor table. If fProtectedMode is FALSE,
  58. // the upper 16 bits are treated as a real-mode segment value.
  59. // In either case the lower 16 bits are treated as the offset.
  60. //
  61. // The return value is NULL if the selector is invalid.
  62. //
  63. // NOTE: Limit checking is not performed in the retail build
  64. // of Windows NT. It is performed in the checked (debug) build
  65. // of WOW32.DLL, which will cause NULL to be returned when the
  66. // limit is exceeded by the supplied offset.
  67. //
  68. function WOWGetVDMPointer(vp, dwBytes: DWORD; fProtectedMode: BOOL): LPVOID; stdcall;
  69. {$EXTERNALSYM WOWGetVDMPointer}
  70. //
  71. // The following two functions are here for compatibility with
  72. // Windows 95. On Win95, the global heap can be rearranged,
  73. // invalidating flat pointers returned by WOWGetVDMPointer, while
  74. // a thunk is executing. On Windows NT, the 16-bit VDM is completely
  75. // halted while a thunk executes, so the only way the heap will
  76. // be rearranged is if a callback is made to Win16 code.
  77. //
  78. // The Win95 versions of these functions call GlobalFix to
  79. // lock down a segment's flat address, and GlobalUnfix to
  80. // release the segment.
  81. //
  82. // The Windows NT implementations of these functions do *not*
  83. // call GlobalFix/GlobalUnfix on the segment, because there
  84. // will not be any heap motion unless a callback occurs.
  85. // If your thunk does callback to the 16-bit side, be sure
  86. // to discard flat pointers and call WOWGetVDMPointer again
  87. // to be sure the flat address is correct.
  88. //
  89. function WOWGetVDMPointerFix(vp, dwBytes: DWORD; fProtectedMode: BOOL): LPVOID; stdcall;
  90. {$EXTERNALSYM WOWGetVDMPointerFix}
  91. procedure WOWGetVDMPointerUnfix(vp: DWORD); stdcall;
  92. {$EXTERNALSYM WOWGetVDMPointerUnfix}
  93. //
  94. // Win16 memory management.
  95. //
  96. // These functions can be used to manage memory in the Win16
  97. // heap. The following four functions are identical to their
  98. // Win16 counterparts, except that they are called from Win32
  99. // code.
  100. //
  101. function WOWGlobalAlloc16(wFlags: WORD; cb: DWORD): WORD; stdcall;
  102. {$EXTERNALSYM WOWGlobalAlloc16}
  103. function WOWGlobalFree16(hMem: WORD): WORD; stdcall;
  104. {$EXTERNALSYM WOWGlobalFree16}
  105. function WOWGlobalLock16(hMem: WORD): DWORD; stdcall;
  106. {$EXTERNALSYM WOWGlobalLock16}
  107. function WOWGlobalUnlock16(hMem: WORD): BOOL; stdcall;
  108. {$EXTERNALSYM WOWGlobalUnlock16}
  109. //
  110. // The following three functions combine two common operations in
  111. // one switch to 16-bit mode.
  112. //
  113. function WOWGlobalAllocLock16(wFlags: WORD; cb: DWORD; var phMem: WORD): DWORD; stdcall;
  114. {$EXTERNALSYM WOWGlobalAllocLock16}
  115. function WOWGlobalUnlockFree16(vpMem: DWORD): WORD; stdcall;
  116. {$EXTERNALSYM WOWGlobalUnlockFree16}
  117. function WOWGlobalLockSize16(hMem: WORD; pcb: PDWORD): DWORD; stdcall;
  118. {$EXTERNALSYM WOWGlobalLockSize16}
  119. //
  120. // Yielding the Win16 nonpreemptive scheduler
  121. //
  122. // The following two functions are provided for Win32 code called
  123. // via Generic Thunks which needs to yield the Win16 scheduler so
  124. // that tasks in that VDM can execute while the thunk waits for
  125. // something to complete. These two functions are functionally
  126. // identical to calling back to 16-bit code which calls Yield or
  127. // DirectedYield.
  128. //
  129. procedure WOWYield16; stdcall;
  130. {$EXTERNALSYM WOWYield16}
  131. procedure WOWDirectedYield16(htask16: WORD); stdcall;
  132. {$EXTERNALSYM WOWDirectedYield16}
  133. //
  134. // 16 <--> 32 Handle mapping functions.
  135. //
  136. // NOTE: While some of these functions perform trivial
  137. // conversions, these functions must be used to maintain
  138. // compatibility with future versions of Windows NT which
  139. // may require different handle mapping.
  140. //
  141. type
  142. _WOW_HANDLE_TYPE = (
  143. WOW_TYPE_HWND,
  144. WOW_TYPE_HMENU,
  145. WOW_TYPE_HDWP,
  146. WOW_TYPE_HDROP,
  147. WOW_TYPE_HDC,
  148. WOW_TYPE_HFONT,
  149. WOW_TYPE_HMETAFILE,
  150. WOW_TYPE_HRGN,
  151. WOW_TYPE_HBITMAP,
  152. WOW_TYPE_HBRUSH,
  153. WOW_TYPE_HPALETTE,
  154. WOW_TYPE_HPEN,
  155. WOW_TYPE_HACCEL,
  156. WOW_TYPE_HTASK,
  157. WOW_TYPE_FULLHWND);
  158. {$EXTERNALSYM _WOW_HANDLE_TYPE}
  159. WOW_HANDLE_TYPE = _WOW_HANDLE_TYPE;
  160. {$EXTERNALSYM WOW_HANDLE_TYPE}
  161. TWowHandleType = WOW_HANDLE_TYPE;
  162. function WOWHandle32(Handle: WORD; Type_: WOW_HANDLE_TYPE): HANDLE; stdcall;
  163. {$EXTERNALSYM WOWHandle32}
  164. function WOWHandle16(Handle: HANDLE; Type_: WOW_HANDLE_TYPE): WORD; stdcall;
  165. {$EXTERNALSYM WOWHandle16}
  166. function HWND_32(h16: WORD): HANDLE;
  167. {$EXTERNALSYM HWND_32}
  168. function HMENU_32(h16: WORD): HANDLE;
  169. {$EXTERNALSYM HMENU_32}
  170. function HDWP_32(h16: WORD): HANDLE;
  171. {$EXTERNALSYM HDWP_32}
  172. function HDROP_32(h16: WORD): HANDLE;
  173. {$EXTERNALSYM HDROP_32}
  174. function HDC_32(h16: WORD): HANDLE;
  175. {$EXTERNALSYM HDC_32}
  176. function HFONT_32(h16: WORD): HANDLE;
  177. {$EXTERNALSYM HFONT_32}
  178. function HMETAFILE_32(h16: WORD): HANDLE;
  179. {$EXTERNALSYM HMETAFILE_32}
  180. function HRGN_32(h16: WORD): HANDLE;
  181. {$EXTERNALSYM HRGN_32}
  182. function HBITMAP_32(h16: WORD): HANDLE;
  183. {$EXTERNALSYM HBITMAP_32}
  184. function HBRUSH_32(h16: WORD): HANDLE;
  185. {$EXTERNALSYM HBRUSH_32}
  186. function HPALETTE_32(h16: WORD): HANDLE;
  187. {$EXTERNALSYM HPALETTE_32}
  188. function HPEN_32(h16: WORD): HANDLE;
  189. {$EXTERNALSYM HPEN_32}
  190. function HACCEL_32(h16: WORD): HANDLE;
  191. {$EXTERNALSYM HACCEL_32}
  192. function HTASK_32(h16: WORD): HANDLE;
  193. {$EXTERNALSYM HTASK_32}
  194. function FULLHWND_32(h16: WORD): HANDLE;
  195. {$EXTERNALSYM FULLHWND_32}
  196. function HWND_16(h32: HANDLE): WORD;
  197. {$EXTERNALSYM HWND_16}
  198. function HMENU_16(h32: HANDLE): WORD;
  199. {$EXTERNALSYM HMENU_16}
  200. function HDWP_16(h32: HANDLE): WORD;
  201. {$EXTERNALSYM HDWP_16}
  202. function HDROP_16(h32: HANDLE): WORD;
  203. {$EXTERNALSYM HDROP_16}
  204. function HDC_16(h32: HANDLE): WORD;
  205. {$EXTERNALSYM HDC_16}
  206. function HFONT_16(h32: HANDLE): WORD;
  207. {$EXTERNALSYM HFONT_16}
  208. function HMETAFILE_16(h32: HANDLE): WORD;
  209. {$EXTERNALSYM HMETAFILE_16}
  210. function HRGN_16(h32: HANDLE): WORD;
  211. {$EXTERNALSYM HRGN_16}
  212. function HBITMAP_16(h32: HANDLE): WORD;
  213. {$EXTERNALSYM HBITMAP_16}
  214. function HBRUSH_16(h32: HANDLE): WORD;
  215. {$EXTERNALSYM HBRUSH_16}
  216. function HPALETTE_16(h32: HANDLE): WORD;
  217. {$EXTERNALSYM HPALETTE_16}
  218. function HPEN_16(h32: HANDLE): WORD;
  219. {$EXTERNALSYM HPEN_16}
  220. function HACCEL_16(h32: HANDLE): WORD;
  221. {$EXTERNALSYM HACCEL_16}
  222. function HTASK_16(h32: HANDLE): WORD;
  223. {$EXTERNALSYM HTASK_16}
  224. //
  225. // Generic Callbacks.
  226. //
  227. // WOWCallback16 can be used in Win32 code called
  228. // from 16-bit (such as by using Generic Thunks) to call back to
  229. // the 16-bit side. The function called must be declared similarly
  230. // to the following:
  231. //
  232. // LONG FAR PASCAL CallbackRoutine(DWORD dwParam);
  233. //
  234. // If you are passing a pointer, declare the parameter as such:
  235. //
  236. // LONG FAR PASCAL CallbackRoutine(VOID FAR *vp);
  237. //
  238. // NOTE: If you are passing a pointer, you'll need to get the
  239. // pointer using WOWGlobalAlloc16 or WOWGlobalAllocLock16
  240. //
  241. // If the function called returns a WORD instead of a DWORD, the
  242. // upper 16 bits of the return value is undefined. Similarly, if
  243. // the function called has no return value, the entire return value
  244. // is undefined.
  245. //
  246. // WOWCallback16Ex allows any combination of arguments up to
  247. // WCB16_MAX_CBARGS bytes total to be passed to the 16-bit routine.
  248. // cbArgs is used to properly clean up the 16-bit stack after calling
  249. // the routine. Regardless of the value of cbArgs, WCB16_MAX_CBARGS
  250. // bytes will always be copied from pArgs to the 16-bit stack. If
  251. // pArgs is less than WCB16_MAX_CBARGS bytes from the end of a page,
  252. // and the next page is inaccessible, WOWCallback16Ex will incur an
  253. // access violation.
  254. //
  255. // If cbArgs is larger than the WCB16_MAX_ARGS which the running
  256. // system supports, the function returns FALSE and GetLastError
  257. // returns ERROR_INVALID_PARAMETER. Otherwise the function
  258. // returns TRUE and the DWORD pointed to by pdwRetCode contains
  259. // the return code from the callback routine. If the callback
  260. // routine returns a WORD, the HIWORD of the return code is
  261. // undefined and should be ignored using LOWORD(dwRetCode).
  262. //
  263. // WOWCallback16Ex can call routines using the PASCAL and CDECL
  264. // calling conventions. The default is to use the PASCAL
  265. // calling convention. To use CDECL, pass WCB16_CDECL in the
  266. // dwFlags parameter.
  267. //
  268. // The arguments pointed to by pArgs must be in the correct
  269. // order for the callback routine's calling convention.
  270. // To call the PASCAL routine SetWindowText,
  271. //
  272. // LONG FAR PASCAL SetWindowText(HWND hwnd, LPCSTR lpsz);
  273. //
  274. // pArgs would point to an array of words:
  275. //
  276. // WORD SetWindowTextArgs[] = {OFFSETOF(lpsz), SELECTOROF(lpsz), hwnd};
  277. //
  278. // In other words, the arguments are placed in the array in reverse
  279. // order with the least significant word first for DWORDs and offset
  280. // first for FAR pointers.
  281. //
  282. // To call the CDECL routine wsprintf, for example
  283. //
  284. // LPSTR lpszFormat = "%d %s";
  285. // int _cdecl wsprintf(lpsz, lpszFormat, nValue. lpszString);
  286. //
  287. // pArgs would point to the array:
  288. //
  289. // WORD wsprintfArgs[] = {OFFSETOF(lpsz), SELECTOROF(lpsz),
  290. // OFFSETOF(lpszFormat), SELECTOROF(lpszFormat),
  291. // nValue,
  292. // OFFSETOF(lpszString), SELECTOROF(lpszString)};
  293. //
  294. // In other words, the arguments are placed in the array in the order
  295. // listed in the function prototype with the least significant word
  296. // first for DWORDs and offset first for FAR pointers.
  297. //
  298. function WOWCallback16(vpfn16: DWORD; dwParam: DWORD): DWORD; stdcall;
  299. {$EXTERNALSYM WOWCallback16}
  300. const
  301. WCB16_MAX_CBARGS = 16;
  302. {$EXTERNALSYM WCB16_MAX_CBARGS}
  303. WCB16_PASCAL = $0;
  304. {$EXTERNALSYM WCB16_PASCAL}
  305. WCB16_CDECL = $1;
  306. {$EXTERNALSYM WCB16_CDECL}
  307. function WOWCallback16Ex(vpfn16, dwFlags, cbArgs: DWORD; pArgs: PVOID; pdwRetCode: PDWORD): BOOL; stdcall;
  308. {$EXTERNALSYM WOWCallback16Ex}
  309. implementation
  310. const
  311. wow32lib = 'wow32.dll';
  312. function HWND_32(h16: WORD): HANDLE;
  313. begin
  314. Result := WOWHandle32(h16, WOW_TYPE_HWND);
  315. end;
  316. function HMENU_32(h16: WORD): HANDLE;
  317. begin
  318. Result := WOWHandle32(h16, WOW_TYPE_HMENU);
  319. end;
  320. function HDWP_32(h16: WORD): HANDLE;
  321. begin
  322. Result := WOWHandle32(h16, WOW_TYPE_HDWP);
  323. end;
  324. function HDROP_32(h16: WORD): HANDLE;
  325. begin
  326. Result := WOWHandle32(h16, WOW_TYPE_HDROP);
  327. end;
  328. function HDC_32(h16: WORD): HANDLE;
  329. begin
  330. Result := WOWHandle32(h16, WOW_TYPE_HDC);
  331. end;
  332. function HFONT_32(h16: WORD): HANDLE;
  333. begin
  334. Result := WOWHandle32(h16, WOW_TYPE_HFONT);
  335. end;
  336. function HMETAFILE_32(h16: WORD): HANDLE;
  337. begin
  338. Result := WOWHandle32(h16, WOW_TYPE_HMETAFILE);
  339. end;
  340. function HRGN_32(h16: WORD): HANDLE;
  341. begin
  342. Result := WOWHandle32(h16, WOW_TYPE_HRGN);
  343. end;
  344. function HBITMAP_32(h16: WORD): HANDLE;
  345. begin
  346. Result := WOWHandle32(h16, WOW_TYPE_HBITMAP);
  347. end;
  348. function HBRUSH_32(h16: WORD): HANDLE;
  349. begin
  350. Result := WOWHandle32(h16, WOW_TYPE_HBRUSH);
  351. end;
  352. function HPALETTE_32(h16: WORD): HANDLE;
  353. begin
  354. Result := WOWHandle32(h16, WOW_TYPE_HPALETTE);
  355. end;
  356. function HPEN_32(h16: WORD): HANDLE;
  357. begin
  358. Result := WOWHandle32(h16, WOW_TYPE_HPEN);
  359. end;
  360. function HACCEL_32(h16: WORD): HANDLE;
  361. begin
  362. Result := WOWHandle32(h16, WOW_TYPE_HACCEL);
  363. end;
  364. function HTASK_32(h16: WORD): HANDLE;
  365. begin
  366. Result := WOWHandle32(h16, WOW_TYPE_HTASK);
  367. end;
  368. function FULLHWND_32(h16: WORD): HANDLE;
  369. begin
  370. Result := WOWHandle32(h16, WOW_TYPE_FULLHWND);
  371. end;
  372. function HWND_16(h32: HANDLE): WORD;
  373. begin
  374. Result := WOWHandle16(h32, WOW_TYPE_HWND);
  375. end;
  376. function HMENU_16(h32: HANDLE): WORD;
  377. begin
  378. Result := WOWHandle16(h32, WOW_TYPE_HMENU);
  379. end;
  380. function HDWP_16(h32: HANDLE): WORD;
  381. begin
  382. Result := WOWHandle16(h32, WOW_TYPE_HDWP);
  383. end;
  384. function HDROP_16(h32: HANDLE): WORD;
  385. begin
  386. Result := WOWHandle16(h32, WOW_TYPE_HDROP);
  387. end;
  388. function HDC_16(h32: HANDLE): WORD;
  389. begin
  390. Result := WOWHandle16(h32, WOW_TYPE_HDC);
  391. end;
  392. function HFONT_16(h32: HANDLE): WORD;
  393. begin
  394. Result := WOWHandle16(h32, WOW_TYPE_HFONT);
  395. end;
  396. function HMETAFILE_16(h32: HANDLE): WORD;
  397. begin
  398. Result := WOWHandle16(h32, WOW_TYPE_HMETAFILE);
  399. end;
  400. function HRGN_16(h32: HANDLE): WORD;
  401. begin
  402. Result := WOWHandle16(h32, WOW_TYPE_HRGN);
  403. end;
  404. function HBITMAP_16(h32: HANDLE): WORD;
  405. begin
  406. Result := WOWHandle16(h32, WOW_TYPE_HBITMAP);
  407. end;
  408. function HBRUSH_16(h32: HANDLE): WORD;
  409. begin
  410. Result := WOWHandle16(h32, WOW_TYPE_HBRUSH);
  411. end;
  412. function HPALETTE_16(h32: HANDLE): WORD;
  413. begin
  414. Result := WOWHandle16(h32, WOW_TYPE_HPALETTE);
  415. end;
  416. function HPEN_16(h32: HANDLE): WORD;
  417. begin
  418. Result := WOWHandle16(h32, WOW_TYPE_HPEN);
  419. end;
  420. function HACCEL_16(h32: HANDLE): WORD;
  421. begin
  422. Result := WOWHandle16(h32, WOW_TYPE_HACCEL);
  423. end;
  424. function HTASK_16(h32: HANDLE): WORD;
  425. begin
  426. Result := WOWHandle16(h32, WOW_TYPE_HTASK);
  427. end;
  428. {$IFDEF DYNAMIC_LINK}
  429. var
  430. _WOWGetVDMPointer: Pointer;
  431. function WOWGetVDMPointer;
  432. begin
  433. GetProcedureAddress(_WOWGetVDMPointer, wow32lib, 'WOWGetVDMPointer');
  434. asm
  435. MOV ESP, EBP
  436. POP EBP
  437. JMP [_WOWGetVDMPointer]
  438. end;
  439. end;
  440. var
  441. _WOWGetVDMPointerFix: Pointer;
  442. function WOWGetVDMPointerFix;
  443. begin
  444. GetProcedureAddress(_WOWGetVDMPointerFix, wow32lib, 'WOWGetVDMPointerFix');
  445. asm
  446. MOV ESP, EBP
  447. POP EBP
  448. JMP [_WOWGetVDMPointerFix]
  449. end;
  450. end;
  451. var
  452. _WOWGetVDMPointerUnfix: Pointer;
  453. procedure WOWGetVDMPointerUnfix;
  454. begin
  455. GetProcedureAddress(_WOWGetVDMPointerUnfix, wow32lib, 'WOWGetVDMPointerUnfix');
  456. asm
  457. MOV ESP, EBP
  458. POP EBP
  459. JMP [_WOWGetVDMPointerUnfix]
  460. end;
  461. end;
  462. var
  463. _WOWGlobalAlloc16: Pointer;
  464. function WOWGlobalAlloc16;
  465. begin
  466. GetProcedureAddress(_WOWGlobalAlloc16, wow32lib, 'WOWGlobalAlloc16');
  467. asm
  468. MOV ESP, EBP
  469. POP EBP
  470. JMP [_WOWGlobalAlloc16]
  471. end;
  472. end;
  473. var
  474. _WOWGlobalFree16: Pointer;
  475. function WOWGlobalFree16;
  476. begin
  477. GetProcedureAddress(_WOWGlobalFree16, wow32lib, 'WOWGlobalFree16');
  478. asm
  479. MOV ESP, EBP
  480. POP EBP
  481. JMP [_WOWGlobalFree16]
  482. end;
  483. end;
  484. var
  485. _WOWGlobalLock16: Pointer;
  486. function WOWGlobalLock16;
  487. begin
  488. GetProcedureAddress(_WOWGlobalLock16, wow32lib, 'WOWGlobalLock16');
  489. asm
  490. MOV ESP, EBP
  491. POP EBP
  492. JMP [_WOWGlobalLock16]
  493. end;
  494. end;
  495. var
  496. _WOWGlobalUnlock16: Pointer;
  497. function WOWGlobalUnlock16;
  498. begin
  499. GetProcedureAddress(_WOWGlobalUnlock16, wow32lib, 'WOWGlobalUnlock16');
  500. asm
  501. MOV ESP, EBP
  502. POP EBP
  503. JMP [_WOWGlobalUnlock16]
  504. end;
  505. end;
  506. var
  507. _WOWGlobalAllocLock16: Pointer;
  508. function WOWGlobalAllocLock16;
  509. begin
  510. GetProcedureAddress(_WOWGlobalAllocLock16, wow32lib, 'WOWGlobalAllocLock16');
  511. asm
  512. MOV ESP, EBP
  513. POP EBP
  514. JMP [_WOWGlobalAllocLock16]
  515. end;
  516. end;
  517. var
  518. _WOWGlobalUnlockFree16: Pointer;
  519. function WOWGlobalUnlockFree16;
  520. begin
  521. GetProcedureAddress(_WOWGlobalUnlockFree16, wow32lib, 'WOWGlobalUnlockFree16');
  522. asm
  523. MOV ESP, EBP
  524. POP EBP
  525. JMP [_WOWGlobalUnlockFree16]
  526. end;
  527. end;
  528. var
  529. _WOWGlobalLockSize16: Pointer;
  530. function WOWGlobalLockSize16;
  531. begin
  532. GetProcedureAddress(_WOWGlobalLockSize16, wow32lib, 'WOWGlobalLockSize16');
  533. asm
  534. MOV ESP, EBP
  535. POP EBP
  536. JMP [_WOWGlobalLockSize16]
  537. end;
  538. end;
  539. var
  540. _WOWYield16: Pointer;
  541. procedure WOWYield16;
  542. begin
  543. GetProcedureAddress(_WOWYield16, wow32lib, 'WOWYield16');
  544. asm
  545. MOV ESP, EBP
  546. POP EBP
  547. JMP [_WOWYield16]
  548. end;
  549. end;
  550. var
  551. _WOWDirectedYield16: Pointer;
  552. procedure WOWDirectedYield16;
  553. begin
  554. GetProcedureAddress(_WOWDirectedYield16, wow32lib, 'WOWDirectedYield16');
  555. asm
  556. MOV ESP, EBP
  557. POP EBP
  558. JMP [_WOWDirectedYield16]
  559. end;
  560. end;
  561. var
  562. _WOWHandle32: Pointer;
  563. function WOWHandle32;
  564. begin
  565. GetProcedureAddress(_WOWHandle32, wow32lib, 'WOWHandle32');
  566. asm
  567. MOV ESP, EBP
  568. POP EBP
  569. JMP [_WOWHandle32]
  570. end;
  571. end;
  572. var
  573. _WOWHandle16: Pointer;
  574. function WOWHandle16;
  575. begin
  576. GetProcedureAddress(_WOWHandle16, wow32lib, 'WOWHandle16');
  577. asm
  578. MOV ESP, EBP
  579. POP EBP
  580. JMP [_WOWHandle16]
  581. end;
  582. end;
  583. var
  584. _WOWCallback16: Pointer;
  585. function WOWCallback16;
  586. begin
  587. GetProcedureAddress(_WOWCallback16, wow32lib, 'WOWCallback16');
  588. asm
  589. MOV ESP, EBP
  590. POP EBP
  591. JMP [_WOWCallback16]
  592. end;
  593. end;
  594. var
  595. _WOWCallback16Ex: Pointer;
  596. function WOWCallback16Ex;
  597. begin
  598. GetProcedureAddress(_WOWCallback16Ex, wow32lib, 'WOWCallback16Ex');
  599. asm
  600. MOV ESP, EBP
  601. POP EBP
  602. JMP [_WOWCallback16Ex]
  603. end;
  604. end;
  605. {$ELSE}
  606. function WOWGetVDMPointer; external wow32lib name 'WOWGetVDMPointer';
  607. function WOWGetVDMPointerFix; external wow32lib name 'WOWGetVDMPointerFix';
  608. procedure WOWGetVDMPointerUnfix; external wow32lib name 'WOWGetVDMPointerUnfix';
  609. function WOWGlobalAlloc16; external wow32lib name 'WOWGlobalAlloc16';
  610. function WOWGlobalFree16; external wow32lib name 'WOWGlobalFree16';
  611. function WOWGlobalLock16; external wow32lib name 'WOWGlobalLock16';
  612. function WOWGlobalUnlock16; external wow32lib name 'WOWGlobalUnlock16';
  613. function WOWGlobalAllocLock16; external wow32lib name 'WOWGlobalAllocLock16';
  614. function WOWGlobalUnlockFree16; external wow32lib name 'WOWGlobalUnlockFree16';
  615. function WOWGlobalLockSize16; external wow32lib name 'WOWGlobalLockSize16';
  616. procedure WOWYield16; external wow32lib name 'WOWYield16';
  617. procedure WOWDirectedYield16; external wow32lib name 'WOWDirectedYield16';
  618. function WOWHandle32; external wow32lib name 'WOWHandle32';
  619. function WOWHandle16; external wow32lib name 'WOWHandle16';
  620. function WOWCallback16; external wow32lib name 'WOWCallback16';
  621. function WOWCallback16Ex; external wow32lib name 'WOWCallback16Ex';
  622. {$ENDIF DYNAMIC_LINK}
  623. end.