jwawownt32.pas 21 KB

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