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.

830 lines
22 KiB

  1. /*++
  2. *
  3. * WOW v1.0
  4. *
  5. * Copyright (c) 1991, Microsoft Corporation
  6. *
  7. * WUSER31.C
  8. * WOW32 16-bit Win 3.1 User API support
  9. *
  10. * History:
  11. * Created 16-Mar-1992 by Chandan S. Chauhan (ChandanC)
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. MODNAME(wuser31.c);
  16. ULONG FASTCALL WU32DlgDirSelectComboBoxEx(PVDMFRAME pFrame)
  17. {
  18. ULONG ul;
  19. PSZ psz2;
  20. VPVOID vp;
  21. register PDLGDIRSELECTCOMBOBOXEX16 parg16;
  22. GETARGPTR(pFrame, sizeof(DLGDIRSELECTCOMBOBOXEX16), parg16);
  23. GETVDMPTR(parg16->f2, INT32(parg16->f3), psz2);
  24. vp = parg16->f2;
  25. // note: this calls back to 16-bit code and could invalidate the flat ptrs
  26. ul = GETBOOL16(DlgDirSelectComboBoxEx(
  27. HWND32(parg16->f1),
  28. psz2,
  29. INT32(parg16->f3),
  30. WORD32(parg16->f4) // we zero-extend window IDs everywhere
  31. ));
  32. // special case to keep common dialog structs in sync (see wcommdlg.c)
  33. Check_ComDlg_pszptr(CURRENTPTD()->CommDlgTd, vp);
  34. FLUSHVDMPTR(parg16->f2, INT32(parg16->f3), psz2);
  35. FREEVDMPTR(psz2);
  36. FREEARGPTR(parg16);
  37. RETURN (ul);
  38. }
  39. ULONG FASTCALL WU32DlgDirSelectEx(PVDMFRAME pFrame)
  40. {
  41. ULONG ul;
  42. PSZ psz2;
  43. VPVOID vp;
  44. register PDLGDIRSELECTEX16 parg16;
  45. GETARGPTR(pFrame, sizeof(DLGDIRSELECTEX16), parg16);
  46. GETVDMPTR(parg16->f2, INT32(parg16->f3), psz2);
  47. vp = parg16->f2;
  48. ul = GETBOOL16(DlgDirSelectEx(
  49. HWND32(parg16->f1),
  50. psz2,
  51. INT32(parg16->f3),
  52. WORD32(parg16->f4)
  53. ));
  54. // special case to keep common dialog structs in sync (see wcommdlg.c)
  55. Check_ComDlg_pszptr(CURRENTPTD()->CommDlgTd, vp);
  56. FLUSHVDMPTR(parg16->f2, INT32(parg16->f3), psz2);
  57. FREEVDMPTR(psz2);
  58. FREEARGPTR(parg16);
  59. RETURN (ul);
  60. }
  61. ULONG FASTCALL WU32GetClipCursor(PVDMFRAME pFrame)
  62. {
  63. RECT Rect;
  64. register PGETCLIPCURSOR16 parg16;
  65. GETARGPTR(pFrame, sizeof(GETCLIPCURSOR16), parg16);
  66. GetClipCursor(&Rect);
  67. PUTRECT16(parg16->f1, &Rect);
  68. FREEARGPTR(parg16);
  69. RETURN (0); // GetClipCursor has no return value
  70. }
  71. ULONG FASTCALL WU32GetDCEx(PVDMFRAME pFrame)
  72. {
  73. ULONG ul;
  74. register PGETDCEX16 parg16;
  75. HAND16 htask16 = pFrame->wTDB;
  76. GETARGPTR(pFrame, sizeof(GETDCEX16), parg16);
  77. ul = GETHDC16(GetDCEx(HWND32(parg16->f1),
  78. HRGN32(parg16->f2),
  79. DWORD32(parg16->f3)));
  80. if (ul)
  81. StoreDC(htask16, parg16->f1, (HAND16)ul);
  82. FREEARGPTR(parg16);
  83. RETURN (ul);
  84. }
  85. ULONG FASTCALL WU32RedrawWindow(PVDMFRAME pFrame)
  86. {
  87. ULONG ul;
  88. RECT Rect, *p2;
  89. register PREDRAWWINDOW16 parg16;
  90. GETARGPTR(pFrame, sizeof(REDRAWWINDOW16), parg16);
  91. p2 = GETRECT16 (parg16->f2, &Rect);
  92. ul = GETBOOL16(RedrawWindow(HWND32(parg16->f1),
  93. p2,
  94. HRGN32(parg16->f3),
  95. WORD32(parg16->f4)));
  96. FREEARGPTR(parg16);
  97. RETURN (ul);
  98. }
  99. ULONG FASTCALL WU32ScrollWindowEx(PVDMFRAME pFrame)
  100. {
  101. ULONG ul;
  102. register PSCROLLWINDOWEX16 parg16;
  103. RECT RectScroll, *p4;
  104. RECT RectClip, *p5;
  105. RECT RectUpdate;
  106. GETARGPTR(pFrame, sizeof(SCROLLWINDOWEX16), parg16);
  107. p4 = GETRECT16 (parg16->f4, &RectScroll);
  108. p5 = GETRECT16 (parg16->f5, &RectClip);
  109. ul = GETINT16(ScrollWindowEx(HWND32(parg16->f1),
  110. INT32(parg16->f2),
  111. INT32(parg16->f3),
  112. p4,
  113. p5,
  114. HRGN32(parg16->f6),
  115. &RectUpdate,
  116. UINT32(parg16->f8)));
  117. PUTRECT16 (parg16->f7, &RectUpdate);
  118. FREEARGPTR(parg16);
  119. RETURN (ul);
  120. }
  121. ULONG FASTCALL WU32SystemParametersInfo(PVDMFRAME pFrame)
  122. {
  123. ULONG ul = 0;
  124. register PSYSTEMPARAMETERSINFO16 parg16;
  125. UINT wParam;
  126. LONG vParam;
  127. LOGFONT lf;
  128. INT iMouse[3];
  129. PVOID lpvParam;
  130. PWORD16 lpw;
  131. PDWORD16 lpdw;
  132. RECT rect;
  133. #ifndef _X86_
  134. DWORD dwSize;
  135. LPBYTE lpFree = NULL;
  136. #endif
  137. GETARGPTR(pFrame, sizeof(SYSTEMPARAMETERSINFO16), parg16);
  138. // Assume these parameters fly straight through; fix them up per option
  139. // if they don't
  140. wParam = parg16->f2;
  141. lpvParam = &vParam;
  142. switch (parg16->f1) {
  143. case SPI_GETICONTITLELOGFONT:
  144. wParam = sizeof(LOGFONT);
  145. lpvParam = &lf;
  146. break;
  147. case SPI_SETICONTITLELOGFONT:
  148. GETLOGFONT16(parg16->f3, &lf);
  149. wParam = sizeof(LOGFONT);
  150. lpvParam = &lf;
  151. break;
  152. case SPI_GETMOUSE:
  153. case SPI_SETMOUSE:
  154. lpvParam = iMouse;
  155. break;
  156. case SPI_SETDESKPATTERN:
  157. // For the pattern if wParam == -1 then no string for lpvParam copy as is
  158. if (parg16->f2 == 0xFFFF) {
  159. wParam = 0xFFFFFFFF;
  160. lpvParam = (PVOID)parg16->f3;
  161. break;
  162. }
  163. // Otherwise fall through and do a string check
  164. case SPI_SETDESKWALLPAPER:
  165. // lpvParam (f3) is may be 0,-1 or a string
  166. if (parg16->f3 == 0xFFFF) {
  167. lpvParam = (PVOID)0xFFFFFFFF;
  168. break;
  169. }
  170. if (parg16->f3 == 0) {
  171. lpvParam = (PVOID)NULL;
  172. break;
  173. }
  174. // Otherwise fall through and do a string copy
  175. case SPI_LANGDRIVER:
  176. GETPSZPTR(parg16->f3, lpvParam);
  177. break;
  178. //
  179. // SPI_GET structures pointed to by pvParam, size in first dword of struct.
  180. // Note all these assume the Win16 and Win32 structures are equal.
  181. // These are all new for Win95 and thankfully that's true. However unlike
  182. // Win95 we need to ensure the buffer passed to Win32 is aligned on RISC.
  183. // To have common code to thunk all these various structures, we align to
  184. // 16 bytes.
  185. //
  186. case SPI_GETACCESSTIMEOUT:
  187. case SPI_GETANIMATION:
  188. case SPI_GETNONCLIENTMETRICS:
  189. case SPI_GETMINIMIZEDMETRICS:
  190. case SPI_GETICONMETRICS:
  191. case SPI_GETFILTERKEYS:
  192. case SPI_GETSTICKYKEYS:
  193. case SPI_GETTOGGLEKEYS:
  194. case SPI_GETMOUSEKEYS:
  195. case SPI_GETSOUNDSENTRY:
  196. #ifndef _X86_
  197. GETMISCPTR(parg16->f3, lpdw);
  198. dwSize = *lpdw;
  199. lpFree = malloc_w(dwSize + 16);
  200. lpvParam = (LPVOID)(((DWORD)lpFree + 16) & ~(16 - 1));
  201. *(PDWORD16)lpvParam = dwSize;
  202. break;
  203. #endif // otherwise fall through to simple struct case
  204. //
  205. // SPI_SET structures pointed to by pvParam, size in first dword of struct.
  206. // Note all these assume the Win16 and Win32 structures are equal.
  207. // These are all new for Win95 and thankfully that's true. However unlike
  208. // Win95 we need to ensure the buffer passed to Win32 is aligned on RISC.
  209. // To have common code to thunk all these various structures, we align to
  210. // 16 bytes.
  211. //
  212. case SPI_SETANIMATION:
  213. case SPI_SETICONMETRICS:
  214. case SPI_SETMINIMIZEDMETRICS:
  215. case SPI_SETNONCLIENTMETRICS:
  216. case SPI_SETACCESSTIMEOUT:
  217. #ifndef _X86_
  218. GETMISCPTR(parg16->f3, lpdw);
  219. dwSize = *lpdw;
  220. lpFree = malloc_w(dwSize + 16);
  221. lpvParam = (LPVOID)(((DWORD)lpFree + 16) & ~(16 - 1));
  222. RtlCopyMemory(lpvParam, lpdw, dwSize);
  223. break;
  224. #endif // otherwise fall through to simple struct case
  225. //
  226. // structures pointed to by pvParam, size in uiParam or first dword.
  227. // Note all these assume the Win16 and Win32 structures are equal.
  228. // These are all new for Win95 and thankfully that's true.
  229. //
  230. case SPI_GETHIGHCONTRAST:
  231. case SPI_GETSERIALKEYS:
  232. case SPI_SETDEFAULTINPUTLANG:
  233. case SPI_SETFILTERKEYS:
  234. case SPI_SETHIGHCONTRAST:
  235. case SPI_SETMOUSEKEYS:
  236. case SPI_SETSERIALKEYS:
  237. case SPI_SETSHOWSOUNDS:
  238. case SPI_SETSOUNDSENTRY:
  239. case SPI_SETSTICKYKEYS:
  240. case SPI_SETTOGGLEKEYS:
  241. GETMISCPTR(parg16->f3, lpvParam);
  242. break;
  243. //
  244. // pvParam points to WORD or BOOL
  245. //
  246. case SPI_GETBEEP:
  247. case SPI_GETBORDER:
  248. case SPI_GETDRAGFULLWINDOWS:
  249. case SPI_GETFASTTASKSWITCH:
  250. case SPI_GETFONTSMOOTHING:
  251. case SPI_GETGRIDGRANULARITY:
  252. case SPI_GETICONTITLEWRAP:
  253. case SPI_GETKEYBOARDSPEED:
  254. case SPI_GETKEYBOARDDELAY:
  255. case SPI_GETKEYBOARDPREF:
  256. case SPI_GETLOWPOWERACTIVE:
  257. case SPI_GETLOWPOWERTIMEOUT:
  258. case SPI_GETMENUDROPALIGNMENT:
  259. case SPI_GETMOUSETRAILS:
  260. case SPI_GETPOWEROFFACTIVE:
  261. case SPI_GETPOWEROFFTIMEOUT:
  262. case SPI_GETSCREENREADER:
  263. case SPI_GETSCREENSAVEACTIVE:
  264. case SPI_GETSCREENSAVETIMEOUT:
  265. case SPI_GETSHOWSOUNDS:
  266. case SPI_SCREENSAVERRUNNING:
  267. break;
  268. //
  269. // pvParam points to DWORD
  270. //
  271. case SPI_GETDEFAULTINPUTLANG:
  272. break;
  273. //
  274. // pvParam not used
  275. //
  276. case SPI_GETWINDOWSEXTENSION:
  277. case SPI_ICONHORIZONTALSPACING:
  278. case SPI_ICONVERTICALSPACING:
  279. case SPI_SETBEEP:
  280. case SPI_SETBORDER:
  281. case SPI_SETDOUBLECLICKTIME:
  282. case SPI_SETDOUBLECLKHEIGHT:
  283. case SPI_SETDOUBLECLKWIDTH:
  284. case SPI_SETDRAGFULLWINDOWS:
  285. case SPI_SETDRAGHEIGHT:
  286. case SPI_SETDRAGWIDTH:
  287. case SPI_SETFASTTASKSWITCH:
  288. case SPI_SETFONTSMOOTHING:
  289. case SPI_SETGRIDGRANULARITY:
  290. case SPI_SETHANDHELD:
  291. case SPI_SETICONTITLEWRAP:
  292. case SPI_SETKEYBOARDDELAY:
  293. case SPI_SETKEYBOARDPREF:
  294. case SPI_SETKEYBOARDSPEED:
  295. case SPI_SETLANGTOGGLE:
  296. case SPI_SETLOWPOWERACTIVE:
  297. case SPI_SETLOWPOWERTIMEOUT:
  298. case SPI_SETMENUDROPALIGNMENT:
  299. case SPI_SETMOUSEBUTTONSWAP:
  300. case SPI_SETMOUSETRAILS:
  301. case SPI_SETPENWINDOWS:
  302. case SPI_SETPOWEROFFACTIVE:
  303. case SPI_SETPOWEROFFTIMEOUT:
  304. case SPI_SETSCREENREADER:
  305. case SPI_SETSCREENSAVEACTIVE:
  306. case SPI_SETSCREENSAVETIMEOUT:
  307. break;
  308. //
  309. // pvParam points to a RECT
  310. //
  311. case SPI_GETWORKAREA:
  312. case SPI_SETWORKAREA:
  313. GETRECT16(parg16->f3, &rect);
  314. lpvParam = ▭
  315. break;
  316. default:
  317. #ifdef DEBUG
  318. {
  319. DWORD dwSaveOptions = flOptions;
  320. flOptions |= OPT_DEBUG;
  321. LOGDEBUG(0, ("WARNING SystemParametersInfo case %d not pre-thunked in WOW!\n", parg16->f1));
  322. flOptions = dwSaveOptions;
  323. }
  324. #endif
  325. break;
  326. }
  327. ul = SystemParametersInfo(
  328. UINT32(parg16->f1),
  329. wParam,
  330. lpvParam,
  331. UINT32(parg16->f4)
  332. );
  333. switch (parg16->f1) {
  334. case SPI_GETICONTITLELOGFONT:
  335. PUTLOGFONT16(parg16->f3, sizeof(LOGFONT), lpvParam);
  336. break;
  337. case SPI_SETICONTITLELOGFONT:
  338. break;
  339. case SPI_GETMOUSE:
  340. case SPI_SETMOUSE:
  341. PUTINTARRAY16(parg16->f3, 3, lpvParam);
  342. break;
  343. case SPI_LANGDRIVER:
  344. case SPI_SETDESKWALLPAPER:
  345. FREEPSZPTR(lpvParam);
  346. break;
  347. case SPI_ICONHORIZONTALSPACING:
  348. case SPI_ICONVERTICALSPACING:
  349. // optional outee
  350. if (!parg16->f3)
  351. break;
  352. // fall through
  353. //
  354. // pvParam points to WORD or BOOL
  355. //
  356. case SPI_GETBEEP:
  357. case SPI_GETBORDER:
  358. case SPI_GETDRAGFULLWINDOWS:
  359. case SPI_GETFASTTASKSWITCH:
  360. case SPI_GETFONTSMOOTHING:
  361. case SPI_GETGRIDGRANULARITY:
  362. case SPI_GETICONTITLEWRAP:
  363. case SPI_GETKEYBOARDSPEED:
  364. case SPI_GETKEYBOARDDELAY:
  365. case SPI_GETKEYBOARDPREF:
  366. case SPI_GETLOWPOWERACTIVE:
  367. case SPI_GETLOWPOWERTIMEOUT:
  368. case SPI_GETMENUDROPALIGNMENT:
  369. case SPI_GETMOUSETRAILS:
  370. case SPI_GETPOWEROFFACTIVE:
  371. case SPI_GETPOWEROFFTIMEOUT:
  372. case SPI_GETSCREENREADER:
  373. case SPI_GETSCREENSAVEACTIVE:
  374. case SPI_GETSCREENSAVETIMEOUT:
  375. case SPI_GETSHOWSOUNDS:
  376. case SPI_SCREENSAVERRUNNING:
  377. GETVDMPTR(FETCHDWORD(parg16->f3), sizeof(*lpw), lpw);
  378. *lpw = (WORD)(*(LPLONG)lpvParam);
  379. FLUSHVDMPTR(FETCHDWORD(parg16->f3), sizeof(*lpw), lpw);
  380. FREEVDMPTR(lpw);
  381. break;
  382. //
  383. // pvParam points to DWORD
  384. //
  385. case SPI_GETDEFAULTINPUTLANG:
  386. GETVDMPTR(FETCHDWORD(parg16->f3), sizeof(*lpdw), lpdw);
  387. *lpdw = *(LPDWORD)lpvParam;
  388. FLUSHVDMPTR(FETCHDWORD(parg16->f3), sizeof(*lpdw), lpdw);
  389. FREEVDMPTR(lpdw);
  390. break;
  391. //
  392. // SPI_GET structures pointed to by pvParam, size in first dword of struct.
  393. // Note all these assume the Win16 and Win32 structures are equal.
  394. // These are all new for Win95 and thankfully that's true. However unlike
  395. // Win95 we need to ensure the buffer passed to Win32 is aligned. In order
  396. // to have common code to thunk all these various structures, we align to
  397. // 16 bytes.
  398. //
  399. case SPI_GETACCESSTIMEOUT:
  400. case SPI_GETANIMATION:
  401. case SPI_GETNONCLIENTMETRICS:
  402. case SPI_GETMINIMIZEDMETRICS:
  403. case SPI_GETICONMETRICS:
  404. case SPI_GETFILTERKEYS:
  405. case SPI_GETSTICKYKEYS:
  406. case SPI_GETTOGGLEKEYS:
  407. case SPI_GETMOUSEKEYS:
  408. case SPI_GETSOUNDSENTRY:
  409. #ifndef _X86_
  410. RtlCopyMemory(lpdw, lpvParam, dwSize);
  411. FREEMISCPTR(lpdw);
  412. break;
  413. #endif // otherwise fall through to simple struct case
  414. //
  415. // SPI_SET structures pointed to by pvParam, size in first dword of struct.
  416. // Note all these assume the Win16 and Win32 structures are equal.
  417. // These are all new for Win95 and thankfully that's true. However unlike
  418. // Win95 we need to ensure the buffer passed to Win32 is aligned. In order
  419. // to have common code to thunk all these various structures, we align to
  420. // 16 bytes.
  421. //
  422. case SPI_SETANIMATION:
  423. case SPI_SETICONMETRICS:
  424. case SPI_SETMINIMIZEDMETRICS:
  425. case SPI_SETNONCLIENTMETRICS:
  426. case SPI_SETACCESSTIMEOUT:
  427. #ifndef _X86_
  428. FREEMISCPTR(lpdw);
  429. break;
  430. #endif // otherwise fall through to simple struct case
  431. //
  432. // structures pointed to by pvParam, size in uiParam or first dword.
  433. // Note all these assume the Win16 and Win32 structures are equal.
  434. // These are all new for Win95 and thankfully that's true.
  435. //
  436. case SPI_GETHIGHCONTRAST:
  437. case SPI_GETSERIALKEYS:
  438. case SPI_SETDEFAULTINPUTLANG:
  439. case SPI_SETFILTERKEYS:
  440. case SPI_SETHIGHCONTRAST:
  441. case SPI_SETMOUSEKEYS:
  442. case SPI_SETSERIALKEYS:
  443. case SPI_SETSHOWSOUNDS:
  444. case SPI_SETSOUNDSENTRY:
  445. case SPI_SETSTICKYKEYS:
  446. case SPI_SETTOGGLEKEYS:
  447. FREEMISCPTR(lpvParam);
  448. break;
  449. //
  450. // pvParam not used
  451. //
  452. case SPI_GETWINDOWSEXTENSION:
  453. case SPI_SETBEEP:
  454. case SPI_SETBORDER:
  455. case SPI_SETDOUBLECLICKTIME:
  456. case SPI_SETDOUBLECLKHEIGHT:
  457. case SPI_SETDOUBLECLKWIDTH:
  458. case SPI_SETDRAGFULLWINDOWS:
  459. case SPI_SETDRAGHEIGHT:
  460. case SPI_SETDRAGWIDTH:
  461. case SPI_SETFASTTASKSWITCH:
  462. case SPI_SETFONTSMOOTHING:
  463. case SPI_SETGRIDGRANULARITY:
  464. case SPI_SETHANDHELD:
  465. case SPI_SETICONTITLEWRAP:
  466. case SPI_SETKEYBOARDDELAY:
  467. case SPI_SETKEYBOARDPREF:
  468. case SPI_SETKEYBOARDSPEED:
  469. case SPI_SETLANGTOGGLE:
  470. case SPI_SETLOWPOWERACTIVE:
  471. case SPI_SETLOWPOWERTIMEOUT:
  472. case SPI_SETMENUDROPALIGNMENT:
  473. case SPI_SETMOUSEBUTTONSWAP:
  474. case SPI_SETMOUSETRAILS:
  475. case SPI_SETPENWINDOWS:
  476. case SPI_SETPOWEROFFACTIVE:
  477. case SPI_SETPOWEROFFTIMEOUT:
  478. case SPI_SETSCREENREADER:
  479. case SPI_SETSCREENSAVEACTIVE:
  480. case SPI_SETSCREENSAVETIMEOUT:
  481. break;
  482. //
  483. // pvParam points to a RECT
  484. //
  485. case SPI_GETWORKAREA:
  486. case SPI_SETWORKAREA:
  487. PUTRECT16(parg16->f3, &rect);
  488. break;
  489. default:
  490. #ifdef DEBUG
  491. {
  492. DWORD dwSaveOptions = flOptions;
  493. flOptions |= OPT_DEBUG;
  494. LOGDEBUG(0, ("WARNING SystemParametersInfo case %d not post-thunked in WOW!\n", parg16->f1));
  495. flOptions = dwSaveOptions;
  496. }
  497. #endif
  498. break;
  499. }
  500. #ifndef _X86_
  501. if (lpFree) {
  502. free_w(lpFree);
  503. }
  504. #endif
  505. FREEARGPTR(parg16);
  506. RETURN (ul);
  507. }
  508. ULONG FASTCALL WU32SetWindowPlacement(PVDMFRAME pFrame)
  509. {
  510. ULONG ul = 0;
  511. register PSETWINDOWPLACEMENT16 parg16;
  512. WINDOWPLACEMENT wndpl;
  513. GETARGPTR(pFrame, sizeof(SETWINDOWPLACEMENT16), parg16);
  514. WINDOWPLACEMENT16TO32(parg16->f2, &wndpl);
  515. ul = GETBOOL16(SetWindowPlacement(HWND32(parg16->f1),
  516. &wndpl));
  517. FREEARGPTR(parg16);
  518. RETURN (ul);
  519. }
  520. ULONG FASTCALL WU32GetWindowPlacement(PVDMFRAME pFrame)
  521. {
  522. ULONG ul = 0;
  523. register PGETWINDOWPLACEMENT16 parg16;
  524. WINDOWPLACEMENT wndpl;
  525. GETARGPTR(pFrame, sizeof(GETWINDOWPLACEMENT16), parg16);
  526. wndpl.length = sizeof(WINDOWPLACEMENT);
  527. ul = GETBOOL16(GetWindowPlacement(HWND32(parg16->f1),
  528. &wndpl));
  529. WINDOWPLACEMENT32TO16(parg16->f2, &wndpl);
  530. FREEARGPTR(parg16);
  531. RETURN (ul);
  532. }
  533. ULONG FASTCALL WU32GetFreeSystemResources(PVDMFRAME pFrame)
  534. {
  535. ULONG ul = 90;
  536. UNREFERENCED_PARAMETER( pFrame );
  537. RETURN (ul);
  538. }
  539. ULONG FASTCALL WU32ExitWindowsExec(PVDMFRAME pFrame)
  540. {
  541. ULONG ul = 0;
  542. register PEXITWINDOWSEXEC16 parg16;
  543. LPSTR lpstrProgName;
  544. LPSTR lpstrCmdLine;
  545. UINT lengthProgName;
  546. UINT lengthCmdLine;
  547. BYTE abT[512];
  548. GETARGPTR(pFrame, sizeof(EXITWINDOWSEXEC16), parg16);
  549. GETPSZPTR(parg16->vpProgName, lpstrProgName);
  550. GETPSZPTR(parg16->vpCmdLine, lpstrCmdLine);
  551. lengthProgName = (lpstrProgName) ? strlen(lpstrProgName) : 0;
  552. lengthCmdLine = (lpstrCmdLine) ? strlen(lpstrCmdLine) : 0;
  553. WOW32ASSERT(sizeof(abT) > (lengthProgName+lengthCmdLine+2));
  554. strcpy(abT, "" );
  555. if ( lpstrProgName ) {
  556. strcpy(abT, lpstrProgName );
  557. }
  558. if ( lpstrCmdLine ) {
  559. strcat(abT, " " );
  560. strcat(abT, lpstrCmdLine );
  561. }
  562. //
  563. // We write the commandline to registry "WOW/EWExecCmdLine"
  564. // If the system logs off successfully, after reboot, we read
  565. // the registry and exec the specfied app before launching any
  566. // wow app in any wow vdm. We donot launch the app before logoff
  567. // because winlogon doesn't allow any app to be execed during
  568. // the logoff process.
  569. // - nanduri
  570. // only one exitwindowsexec call at a time.
  571. // if value/key exists, return error.
  572. if (!W32EWExecData(EWEXEC_QUERY, abT, sizeof(abT))) {
  573. HANDLE hevT;
  574. // only one exitwindowsexec call at a time.
  575. // if event exits, return error.
  576. if (hevT = CreateEvent(NULL, TRUE, FALSE, WOWSZ_EWEXECEVENT)) {
  577. if (GetLastError() == 0) {
  578. // wake up any waiting threads (in w32ewexecer)
  579. SetEvent(hevT);
  580. // Write the data to the registry
  581. if (W32EWExecData(EWEXEC_SET, abT, strlen(abT)+1)) {
  582. DWORD dwlevel;
  583. DWORD dwflags;
  584. if (!GetProcessShutdownParameters(&dwlevel, &dwflags)) {
  585. dwlevel = 0x280; // default level per docs
  586. dwflags = 0;
  587. }
  588. //
  589. // 0xff = last system reserved level Logically makes this last user
  590. // process to shutdown. This takes care of Multiple WOW VDMs
  591. //
  592. SetProcessShutdownParameters(0xff, 0);
  593. //
  594. // EWX_NOTIFY private bit for WOW. Generates queue message
  595. // WM_ENDSESSION, if any process cancels logoff/shutdown.
  596. if (ExitWindowsEx(EWX_LOGOFF | EWX_NOTIFY, 0)) {
  597. MSG msg;
  598. //
  599. // PeekMessage yields to other WOW tasks. We effectively
  600. // freeze the current task by removing all input messages.
  601. // Loop terminates only if WM_ENDSESSION message has been
  602. // received. This message is posted by winsrv if any process
  603. // in the system cancels logoff.
  604. //
  605. while (TRUE) {
  606. if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
  607. if ((msg.message >= WM_MOUSEFIRST &&
  608. msg.message <= WM_MOUSELAST) ||
  609. (msg.message >= WM_KEYFIRST &&
  610. msg.message <= WM_KEYLAST) ||
  611. (msg.message >= WM_NCMOUSEMOVE &&
  612. msg.message <= WM_NCMBUTTONDBLCLK)) {
  613. // don't dispatch the message
  614. }
  615. else if (msg.message == WM_ENDSESSION) {
  616. WOW32ASSERT((msg.hwnd == 0) && (msg.wParam == 0));
  617. break;
  618. }
  619. else {
  620. TranslateMessage(&msg);
  621. DispatchMessage(&msg);
  622. }
  623. }
  624. }
  625. }
  626. //
  627. // Here if logoff was cancelled.
  628. // Set defaults and delete the associated value from registry.
  629. //
  630. SetProcessShutdownParameters(dwlevel, dwflags);
  631. if (!W32EWExecData(EWEXEC_DEL, (LPSTR)NULL, 0)) {
  632. WOW32ASSERT(FALSE);
  633. }
  634. }
  635. }
  636. CloseHandle(hevT);
  637. }
  638. }
  639. LOGDEBUG(0,("WOW: ExitWindowsExec failed\r\n"));
  640. FREEARGPTR(parg16);
  641. return 0;
  642. }
  643. ULONG FASTCALL WU32MapWindowPoints(PVDMFRAME pFrame)
  644. {
  645. LPPOINT p3;
  646. register PMAPWINDOWPOINTS16 parg16;
  647. POINT BufferT[128];
  648. GETARGPTR(pFrame, sizeof(MAPWINDOWPOINTS16), parg16);
  649. p3 = STACKORHEAPALLOC(parg16->f4 * sizeof(POINT), sizeof(BufferT), BufferT);
  650. if ( p3 ) {
  651. getpoint16(parg16->f3, parg16->f4, p3);
  652. MapWindowPoints(
  653. HWND32(parg16->f1),
  654. HWND32(parg16->f2),
  655. p3,
  656. INT32(parg16->f4)
  657. );
  658. PUTPOINTARRAY16(parg16->f3, parg16->f4, p3);
  659. STACKORHEAPFREE(p3, BufferT);
  660. }
  661. else {
  662. FREEARGPTR(parg16);
  663. RETURN(0);
  664. }
  665. FREEARGPTR(parg16);
  666. RETURN(1);
  667. }