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.

1360 lines
35 KiB

  1. /*++
  2. *
  3. * WOW v1.0
  4. *
  5. * Copyright (c) 1991, Microsoft Corporation
  6. *
  7. * WDDEML.C
  8. * WOW32 16-bit DDEML API support
  9. *
  10. * History:
  11. * Jan-23-1993 Chandan Chauhan (ChandanC)
  12. * Created.
  13. *
  14. * Things needed:
  15. * CALLBACK to user to find out if a given data handle has been initialized.
  16. * Have DdeDataBuf routines check the handle tables before converting DIBS
  17. * and METAFILEPICT formatted data so we don't have a leak.
  18. *
  19. --*/
  20. #include "precomp.h"
  21. #pragma hdrstop
  22. #include "wowclip.h"
  23. #include "wddeml32.h"
  24. #include "wowddeml.h"
  25. MODNAME(wddeml32.c);
  26. #ifdef DEBUG
  27. #define WOW32SAFEASSERTWARN(exp,msg) {\
  28. if ((exp) == 0) {\
  29. LOGDEBUG(1,(" WOW32 ERROR: %s failed", msg));\
  30. WOW32ASSERT(FALSE); \
  31. }\
  32. }
  33. #else
  34. #define WOW32SAFEASSERTWARN(exp,msg)
  35. #endif
  36. #ifdef DEBUG
  37. WORD ddeloglevel = 3;
  38. #define LOGDDEMLENTRY(pFrame) LOGARGS(ddeloglevel, pFrame)
  39. #define LOGDDEMLRETURN(pFrame, ret) LOGRETURN(ddeloglevel, pFrame, ret)
  40. #else
  41. #define LOGDDEMLENTRY(pFrame)
  42. #define LOGDDEMLRETURN(pFrame, ret)
  43. #endif
  44. BIND1632 aCallBack[MAX_CONVS] = {0};
  45. BIND1632 aAccessData[MAX_CONVS] = {0};
  46. ULONG FASTCALL WD32DdeInitialize(PVDMFRAME pFrame)
  47. {
  48. ULONG ul;
  49. DWORD IdInst;
  50. PDWORD16 p;
  51. register PDDEINITIALIZE16 parg16;
  52. LOGDDEMLENTRY(pFrame);
  53. GETARGPTR(pFrame, sizeof(DDEINITIALIZE16), parg16);
  54. GETMISCPTR (parg16->f1, p);
  55. IdInst = *p;
  56. ul = (ULONG)DdeInitialize(&IdInst, W32DdemlCallBack,
  57. parg16->f3, parg16->f4);
  58. // There Could have been a Task Switch Before GetMessage Returned so Don't
  59. // Trust any 32 bit flat pointers we have, memory could have been compacted or
  60. // moved.
  61. FREEARGPTR(parg16);
  62. FREEVDMPTR(pFrame);
  63. GETFRAMEPTR(((PTD)CURRENTPTD())->vpStack, pFrame);
  64. GETARGPTR(pFrame, sizeof(DDEINITIALIZE16), parg16);
  65. if (!*p) {
  66. WOWDdemlBind ((DWORD)parg16->f2, IdInst, aCallBack);
  67. }
  68. *p = IdInst;
  69. WOW32SAFEASSERTWARN(!ul, "WD32DdeInitialize\n");
  70. FREEMISCPTR(p);
  71. FREEARGPTR(parg16);
  72. LOGDDEMLRETURN(pFrame, ul);
  73. FREEVDMPTR(pFrame);
  74. RETURN(ul);
  75. }
  76. ULONG FASTCALL WD32DdeUninitialize(PVDMFRAME pFrame)
  77. {
  78. ULONG ul;
  79. register PDDEUNINITIALIZE16 parg16;
  80. LOGDDEMLENTRY(pFrame);
  81. GETARGPTR(pFrame, sizeof(DDEUNINITIALIZE16), parg16);
  82. ul = (ULONG)DdeUninitialize(parg16->f1);
  83. // There Could have been a Task Switch Before GetMessage Returned so Don't
  84. // Trust any 32 bit flat pointers we have, memory could have been compacted or
  85. // moved.
  86. FREEARGPTR(parg16);
  87. FREEVDMPTR(pFrame);
  88. GETFRAMEPTR(((PTD)CURRENTPTD())->vpStack, pFrame);
  89. GETARGPTR(pFrame, sizeof(DDEUNINITIALIZE16), parg16);
  90. if (ul) {
  91. WOWDdemlUnBind ((DWORD)parg16->f1, aCallBack);
  92. }
  93. WOW32SAFEASSERTWARN(ul, "WD32DdeUninitialize\n");
  94. FREEARGPTR(parg16);
  95. LOGDDEMLRETURN(pFrame, ul);
  96. RETURN(ul);
  97. }
  98. ULONG FASTCALL WD32DdeConnectList(PVDMFRAME pFrame)
  99. {
  100. ULONG ul;
  101. CONVCONTEXT CC;
  102. register PDDECONNECTLIST16 parg16;
  103. LOGDDEMLENTRY(pFrame);
  104. GETARGPTR(pFrame, sizeof(DDECONNECTLIST16), parg16);
  105. W32GetConvContext (parg16->f5, &CC);
  106. ul = (ULONG)DdeConnectList(parg16->f1, parg16->f2,
  107. parg16->f3, parg16->f4,
  108. (parg16->f5) ? &CC : NULL);
  109. FREEARGPTR(parg16);
  110. LOGDDEMLRETURN(pFrame, ul);
  111. RETURN(ul);
  112. }
  113. ULONG FASTCALL WD32DdeQueryNextServer(PVDMFRAME pFrame)
  114. {
  115. ULONG ul;
  116. register PDDEQUERYNEXTSERVER16 parg16;
  117. LOGDDEMLENTRY(pFrame);
  118. GETARGPTR(pFrame, sizeof(DDEQUERYNEXTSERVER16), parg16);
  119. ul = (ULONG)DdeQueryNextServer(parg16->f1, parg16->f2);
  120. // There Could have been a Task Switch Before GetMessage Returned so Don't
  121. // Trust any 32 bit flat pointers we have, memory could have been compacted or
  122. // moved.
  123. FREEARGPTR(parg16);
  124. FREEVDMPTR(pFrame);
  125. #ifdef DEBUG
  126. GETFRAMEPTR(((PTD)CURRENTPTD())->vpStack, pFrame);
  127. LOGDDEMLRETURN(pFrame, ul);
  128. FREEVDMPTR(pFrame);
  129. #endif
  130. RETURN(ul);
  131. }
  132. ULONG FASTCALL WD32DdeDisconnectList(PVDMFRAME pFrame)
  133. {
  134. ULONG ul;
  135. register PDDEDISCONNECTLIST16 parg16;
  136. LOGDDEMLENTRY(pFrame);
  137. GETARGPTR(pFrame, sizeof(DDEDISCONNECTLIST16), parg16);
  138. ul = (ULONG)DdeDisconnectList(parg16->f1);
  139. WOW32SAFEASSERTWARN(ul, "WD32DdeDisconnectList\n");
  140. // There Could have been a Task Switch Before GetMessage Returned so Don't
  141. // Trust any 32 bit flat pointers we have, memory could have been compacted or
  142. // moved.
  143. FREEARGPTR(parg16);
  144. #ifdef DEBUG
  145. GETFRAMEPTR(((PTD)CURRENTPTD())->vpStack, pFrame);
  146. LOGDDEMLRETURN(pFrame, ul);
  147. FREEVDMPTR(pFrame);
  148. #endif
  149. RETURN(ul);
  150. }
  151. ULONG FASTCALL WD32DdeConnect(PVDMFRAME pFrame)
  152. {
  153. ULONG ul;
  154. CONVCONTEXT CC;
  155. register PDDECONNECT16 parg16;
  156. LOGDDEMLENTRY(pFrame);
  157. GETARGPTR(pFrame, sizeof(DDECONNECT16), parg16);
  158. W32GetConvContext (parg16->f4, &CC);
  159. ul = (ULONG)DdeConnect(parg16->f1, parg16->f2,
  160. parg16->f3, (parg16->f4) ? &CC : NULL);
  161. // There Could have been a Task Switch Before GetMessage Returned so Don't
  162. // Trust any 32 bit flat pointers we have, memory could have been compacted or
  163. // moved.
  164. FREEARGPTR(parg16);
  165. #ifdef DEBUG
  166. GETFRAMEPTR(((PTD)CURRENTPTD())->vpStack, pFrame);
  167. LOGDDEMLRETURN(pFrame, ul);
  168. FREEVDMPTR(pFrame);
  169. #endif
  170. RETURN(ul);
  171. }
  172. ULONG FASTCALL WD32DdeDisconnect(PVDMFRAME pFrame)
  173. {
  174. ULONG ul;
  175. register PDDEDISCONNECT16 parg16;
  176. LOGDDEMLENTRY(pFrame);
  177. GETARGPTR(pFrame, sizeof(DDEDISCONNECT16), parg16);
  178. ul = (ULONG)DdeDisconnect(parg16->f1);
  179. WOW32SAFEASSERTWARN(ul, "WD32DdeDisconnect\n");
  180. // There Could have been a Task Switch Before GetMessage Returned so Don't
  181. // Trust any 32 bit flat pointers we have, memory could have been compacted or
  182. // moved.
  183. FREEARGPTR(parg16);
  184. #ifdef DEBUG
  185. GETFRAMEPTR(((PTD)CURRENTPTD())->vpStack, pFrame);
  186. LOGDDEMLRETURN(pFrame, ul);
  187. FREEVDMPTR(pFrame);
  188. #endif
  189. RETURN(ul);
  190. }
  191. ULONG FASTCALL WD32DdeQueryConvInfo(PVDMFRAME pFrame)
  192. {
  193. ULONG ul;
  194. DWORD cb16;
  195. CONVINFO ConvInfo;
  196. CONVINFO16 ConvInfo16;
  197. PCONVINFO16 pCI16;
  198. register PDDEQUERYCONVINFO16 parg16;
  199. LOGDDEMLENTRY(pFrame);
  200. GETARGPTR(pFrame, sizeof(DDEQUERYCONVINFO16), parg16);
  201. // Initialize the size to be of NT CONVINFO structure
  202. ConvInfo.cb = sizeof(CONVINFO);
  203. ul = (ULONG)DdeQueryConvInfo(parg16->f1, parg16->f2, &ConvInfo);
  204. // There Could have been a Task Switch Before GetMessage Returned so Don't
  205. // Trust any 32 bit flat pointers we have, memory could have been compacted or
  206. // moved.
  207. FREEARGPTR(parg16);
  208. FREEVDMPTR(pFrame);
  209. GETFRAMEPTR(((PTD)CURRENTPTD())->vpStack, pFrame);
  210. GETARGPTR(pFrame, sizeof(DDEQUERYCONVINFO16), parg16);
  211. if (ul && parg16->f3) {
  212. GETMISCPTR(parg16->f3, pCI16);
  213. cb16 = pCI16->cb;
  214. RtlCopyMemory (&ConvInfo16, &ConvInfo, (LPBYTE)&ConvInfo.wFmt - (LPBYTE)&ConvInfo);
  215. ConvInfo16.wFmt = (WORD) ConvInfo.wFmt;
  216. ConvInfo16.wType = (WORD) ConvInfo.wType;
  217. ConvInfo16.wStatus = (WORD) ConvInfo.wStatus;
  218. ConvInfo16.wConvst = (WORD) ConvInfo.wConvst;
  219. ConvInfo16.wLastError = (WORD) ConvInfo.wLastError;
  220. ConvInfo16.hConvList = (DWORD) ConvInfo.hConvList;
  221. ConvInfo16.ConvCtxt.cb = (WORD) ConvInfo.ConvCtxt.cb;
  222. ConvInfo16.ConvCtxt.wFlags = (WORD) ConvInfo.ConvCtxt.wFlags;
  223. ConvInfo16.ConvCtxt.wCountryID = (WORD) ConvInfo.ConvCtxt.wCountryID;
  224. ConvInfo16.ConvCtxt.iCodePage = (INT16) ConvInfo.ConvCtxt.iCodePage;
  225. ConvInfo16.ConvCtxt.dwLangID = (DWORD) ConvInfo.ConvCtxt.dwLangID;
  226. ConvInfo16.ConvCtxt.dwSecurity = (DWORD) ConvInfo.ConvCtxt.dwSecurity;
  227. ConvInfo16.hwnd = (HWND16) ConvInfo.hwnd;
  228. ConvInfo16.hwndPartner = (HWND16) ConvInfo.hwndPartner;
  229. if (pCI16->cb > sizeof(CONVINFO16) || pCI16->cb == 0) {
  230. /*
  231. * If cb field is screwey assume it wasn't initialized properly
  232. * by the app. Set it to the old CONVINFO16 size. (pre hwnd days)
  233. */
  234. pCI16->cb = sizeof(CONVINFO16) - sizeof(HAND16) - sizeof(HAND16);;
  235. }
  236. RtlCopyMemory (pCI16, (PVOID)&ConvInfo16, cb16);
  237. pCI16->cb = cb16;
  238. FREEMISCPTR(pCI16);
  239. }
  240. else {
  241. WOW32SAFEASSERTWARN(ul, "WD32QueryConvInfo\n");
  242. }
  243. FREEARGPTR(parg16);
  244. LOGDDEMLRETURN(pFrame, ul);
  245. FREEVDMPTR(pFrame);
  246. RETURN(ul);
  247. }
  248. ULONG FASTCALL WD32DdeSetUserHandle(PVDMFRAME pFrame)
  249. {
  250. ULONG ul;
  251. register PDDESETUSERHANDLE16 parg16;
  252. LOGDDEMLENTRY(pFrame);
  253. GETARGPTR(pFrame, sizeof(DDESETUSERHANDLE16), parg16);
  254. ul = (ULONG)DdeSetUserHandle(parg16->f1, parg16->f2, parg16->f3);
  255. WOW32SAFEASSERTWARN(ul, "WD32DdeSetUserHandle\n");
  256. // There Could have been a Task Switch Before GetMessage Returned so Don't
  257. // Trust any 32 bit flat pointers we have, memory could have been compacted or
  258. // moved.
  259. FREEARGPTR(parg16);
  260. #ifdef DEBUG
  261. GETFRAMEPTR(((PTD)CURRENTPTD())->vpStack, pFrame);
  262. LOGDDEMLRETURN(pFrame, ul);
  263. FREEVDMPTR(pFrame);
  264. #endif
  265. RETURN(ul);
  266. }
  267. ULONG FASTCALL WD32DdeClientTransaction(PVDMFRAME pFrame)
  268. {
  269. ULONG ul = 1;
  270. LPBYTE lpByte = NULL;
  271. DWORD Uresult;
  272. PVOID p;
  273. PDWORD16 pul;
  274. register PDDECLIENTTRANSACTION16 parg16;
  275. DWORD cbData;
  276. DWORD cbOffset;
  277. LOGDDEMLENTRY(pFrame);
  278. GETARGPTR(pFrame, sizeof(DDECLIENTTRANSACTION16), parg16);
  279. cbData = parg16->f2;
  280. cbOffset = 0;
  281. if (parg16->f1 && cbData && cbData != -1) { // -1 means p is a data handle
  282. GETMISCPTR(parg16->f1, p);
  283. ul = (ULONG)DdeDataBuf16to32 (p, &lpByte, &cbData, &cbOffset, parg16->f5);
  284. WOW32SAFEASSERTWARN(ul, "WD32DdeClientTransaction:data conversion failed.\n");
  285. FREEMISCPTR(p);
  286. }
  287. if (ul) {
  288. ul = (ULONG)DdeClientTransaction(lpByte ? lpByte : (LPBYTE)parg16->f1,
  289. cbData,
  290. parg16->f3,
  291. parg16->f4,
  292. parg16->f5,
  293. parg16->f6,
  294. parg16->f7,
  295. &Uresult);
  296. }
  297. if (lpByte) {
  298. free_w (lpByte);
  299. }
  300. // There Could have been a Task Switch Before GetMessage Returned so Don't
  301. // Trust any 32 bit flat pointers we have, memory could have been compacted or
  302. // moved.
  303. FREEARGPTR(parg16);
  304. FREEVDMPTR(pFrame);
  305. GETFRAMEPTR(((PTD)CURRENTPTD())->vpStack, pFrame);
  306. GETARGPTR(pFrame, sizeof(DDECLIENTTRANSACTION16), parg16);
  307. if (ul && parg16->f8) {
  308. GETMISCPTR (parg16->f8, pul);
  309. *pul = Uresult;
  310. FREEMISCPTR(pul);
  311. }
  312. FREEARGPTR(parg16);
  313. LOGDDEMLRETURN(pFrame, ul);
  314. FREEVDMPTR(pFrame);
  315. RETURN(ul);
  316. }
  317. ULONG FASTCALL WD32DdeAbandonTransaction(PVDMFRAME pFrame)
  318. {
  319. ULONG ul;
  320. register PDDEABANDONTRANSACTION16 parg16;
  321. LOGDDEMLENTRY(pFrame);
  322. GETARGPTR(pFrame, sizeof(DDEABANDONTRANSACTION16), parg16);
  323. ul = (ULONG)DdeAbandonTransaction(parg16->f1, parg16->f2, parg16->f3);
  324. WOW32SAFEASSERTWARN(ul, "WD32DdeAbandonTransaction\n");
  325. // There Could have been a Task Switch Before GetMessage Returned so Don't
  326. // Trust any 32 bit flat pointers we have, memory could have been compacted or
  327. // moved.
  328. FREEARGPTR(parg16);
  329. #ifdef DEBUG
  330. GETFRAMEPTR(((PTD)CURRENTPTD())->vpStack, pFrame);
  331. LOGDDEMLRETURN(pFrame, ul);
  332. FREEVDMPTR(pFrame);
  333. #endif
  334. RETURN(ul);
  335. }
  336. ULONG FASTCALL WD32DdePostAdvise(PVDMFRAME pFrame)
  337. {
  338. ULONG ul;
  339. register PDDEPOSTADVISE16 parg16;
  340. LOGDDEMLENTRY(pFrame);
  341. GETARGPTR(pFrame, sizeof(DDEPOSTADVISE16), parg16);
  342. ul = (ULONG)DdePostAdvise(parg16->f1, parg16->f2, parg16->f3);
  343. WOW32SAFEASSERTWARN(ul, "WD32DdePostAdvise\n");
  344. // There Could have been a Task Switch Before GetMessage Returned so Don't
  345. // Trust any 32 bit flat pointers we have, memory could have been compacted or
  346. // moved.
  347. FREEARGPTR(parg16);
  348. #ifdef DEBUG
  349. GETFRAMEPTR(((PTD)CURRENTPTD())->vpStack, pFrame);
  350. LOGDDEMLRETURN(pFrame, ul);
  351. FREEVDMPTR(pFrame);
  352. #endif
  353. RETURN(ul);
  354. }
  355. ULONG FASTCALL WD32DdeCreateDataHandle(PVDMFRAME pFrame)
  356. {
  357. ULONG ul = 1;
  358. LPBYTE lpByte = NULL;
  359. register PDDECREATEDATAHANDLE16 parg16;
  360. DWORD cbData;
  361. DWORD cbOffset;
  362. PVOID p;
  363. LOGDDEMLENTRY(pFrame);
  364. GETARGPTR(pFrame, sizeof(DDECREATEDATAHANDLE16), parg16);
  365. cbData = parg16->f3;
  366. cbOffset = parg16->f4;
  367. GETMISCPTR(parg16->f2, p);
  368. if (p != NULL) {
  369. ul = DdeDataBuf16to32 (p, &lpByte, &cbData, &cbOffset, parg16->f6);
  370. WOW32SAFEASSERTWARN(ul, "WD32DdeCreateDataHandle:data conversion failed.\n");
  371. }
  372. FREEMISCPTR(p);
  373. if (ul) {
  374. ul = (ULONG)DdeCreateDataHandle(parg16->f1,
  375. lpByte ? lpByte : 0,
  376. cbData,
  377. cbOffset,
  378. parg16->f5,
  379. parg16->f6,
  380. parg16->f7);
  381. }
  382. // There Could have been a Task Switch Before GetMessage Returned so Don't
  383. // Trust any 32 bit flat pointers we have, memory could have been compacted or
  384. // moved.
  385. FREEARGPTR(parg16);
  386. FREEVDMPTR(pFrame);
  387. if (lpByte) {
  388. free_w (lpByte);
  389. }
  390. WOW32SAFEASSERTWARN(ul, "WD32DdeCreateDataHandle\n");
  391. #ifdef DEBUG
  392. GETFRAMEPTR(((PTD)CURRENTPTD())->vpStack, pFrame);
  393. LOGDDEMLRETURN(pFrame, ul);
  394. FREEVDMPTR(pFrame);
  395. #endif
  396. RETURN(ul);
  397. }
  398. ULONG FASTCALL WD32DdeAddData(PVDMFRAME pFrame)
  399. {
  400. ULONG ul = 0;
  401. LPBYTE lpByte = NULL;
  402. UINT DataFormat;
  403. register PDDEADDDATA16 parg16;
  404. DWORD cbData;
  405. DWORD cbOffset;
  406. PVOID p;
  407. LOGDDEMLENTRY(pFrame);
  408. GETARGPTR(pFrame, sizeof(DDEADDDATA16), parg16);
  409. DataFormat = DdeGetDataHandleFormat ((DWORD)parg16->f1); // -1 is an error
  410. if (DataFormat != -1) {
  411. cbData = parg16->f3;
  412. cbOffset = parg16->f4;
  413. GETMISCPTR(parg16->f2, p);
  414. if (DdeDataBuf16to32 (p, &lpByte, &cbData, &cbOffset, DataFormat)) {
  415. ul = (ULONG)DdeAddData(parg16->f1, lpByte, cbData, cbOffset);
  416. } else {
  417. WOW32SAFEASSERTWARN(0, "WD32DdeAddData:data conversion failed.\n");
  418. }
  419. // memory may have moved - invalidate all flat pointers
  420. FREEARGPTR(parg16);
  421. FREEVDMPTR(pFrame);
  422. FREEMISCPTR(p);
  423. WOW32SAFEASSERTWARN(ul, "WD32DdeAddData\n");
  424. if (lpByte) {
  425. free_w (lpByte);
  426. }
  427. }
  428. #ifdef DEBUG
  429. GETFRAMEPTR(((PTD)CURRENTPTD())->vpStack, pFrame);
  430. LOGDDEMLRETURN(pFrame, ul);
  431. FREEVDMPTR(pFrame);
  432. #endif
  433. RETURN(ul);
  434. }
  435. ULONG FASTCALL WD32DdeGetData(PVDMFRAME pFrame)
  436. {
  437. ULONG ul;
  438. LPBYTE lpByte = NULL;
  439. UINT DataFormat;
  440. PVOID p;
  441. register PDDEGETDATA16 parg16;
  442. LOGDDEMLENTRY(pFrame);
  443. GETARGPTR(pFrame, sizeof(DDEGETDATA16), parg16);
  444. DataFormat = DdeGetDataHandleFormat (parg16->f1); // -1 is an error
  445. if (DataFormat != -1) {
  446. if (parg16->f2) {
  447. if ((lpByte = malloc_w(parg16->f3)) == NULL) {
  448. FREEARGPTR(parg16);
  449. LOGDDEMLRETURN(pFrame, 0);
  450. RETURN(0);
  451. }
  452. }
  453. DdeDataSize16to32(&(parg16->f3), &(parg16->f4), DataFormat);
  454. ul = (ULONG)DdeGetData(parg16->f1, lpByte, parg16->f3, parg16->f4);
  455. // memory may have moved - invalidate all flat pointers
  456. FREEVDMPTR(pFrame);
  457. FREEARGPTR(parg16);
  458. GETFRAMEPTR(((PTD)CURRENTPTD())->vpStack, pFrame);
  459. GETARGPTR(pFrame, sizeof(DDEGETDATA16), parg16);
  460. GETMISCPTR (parg16->f2, p);
  461. if (!DdeDataBuf32to16 (p, lpByte, parg16->f3, parg16->f4, DataFormat)) {
  462. WOW32SAFEASSERTWARN(0, "WD32DdeGetData:data conversion failed.\n");
  463. ul = 0;
  464. }
  465. FREEMISCPTR (p);
  466. WOW32SAFEASSERTWARN(ul, "WD32DdeGetData failed\n");
  467. if (lpByte) {
  468. free_w (lpByte);
  469. }
  470. }
  471. FREEARGPTR(parg16);
  472. LOGDDEMLRETURN(pFrame, ul);
  473. RETURN(ul);
  474. }
  475. ULONG FASTCALL WD32DdeAccessData(PVDMFRAME pFrame)
  476. {
  477. VPVOID vp = 0;
  478. DWORD cbData;
  479. DWORD cbData16;
  480. PVOID p;
  481. PDWORD16 pd16;
  482. LPBYTE lpByte;
  483. register PDDEACCESSDATA16 parg16;
  484. DWORD DataFormat;
  485. HAND16 h16;
  486. LOGDDEMLENTRY(pFrame);
  487. GETARGPTR(pFrame, sizeof(DDEACCESSDATA16), parg16);
  488. DataFormat = DdeGetDataHandleFormat (parg16->f1); // -1 is an error
  489. if (DataFormat != -1) {
  490. lpByte = DdeAccessData(parg16->f1, &cbData);
  491. if (lpByte) {
  492. cbData16 = cbData;
  493. DdeDataSize32to16(&cbData16, NULL, DataFormat);
  494. if (vp = GlobalAllocLock16(GMEM_MOVEABLE, cbData16, &h16)) {
  495. // 16-bit memory may have moved - invalidate all flat pointers
  496. FREEARGPTR(parg16);
  497. FREEFRAMEPTR(pFrame);
  498. GETFRAMEPTR(((PTD)CURRENTPTD())->vpStack, pFrame);
  499. GETARGPTR(pFrame, sizeof(DDEACCESSDATA16), parg16);
  500. GETMISCPTR (vp, p);
  501. if (!DdeIsDataHandleInitialized(parg16->f1) ||
  502. DdeDataBuf32to16 (p, lpByte, cbData, 0, DataFormat)) {
  503. if (parg16->f2) {
  504. GETMISCPTR (parg16->f2, pd16);
  505. *pd16 = cbData16;
  506. FREEMISCPTR(pd16);
  507. }
  508. WOWDdemlBind (h16, (DWORD)parg16->f1, aAccessData);
  509. } else {
  510. WOW32SAFEASSERTWARN(0, "WD32DdeAccessData:data conversion failed.\n");
  511. GlobalUnlockFree16(h16);
  512. vp = NULL;
  513. }
  514. FREEMISCPTR (p);
  515. }
  516. }
  517. }
  518. WOW32SAFEASSERTWARN(vp, "WD32DdeAccessData\n");
  519. FREEARGPTR(parg16);
  520. LOGDDEMLRETURN(pFrame, vp);
  521. RETURN((ULONG)vp);
  522. }
  523. ULONG FASTCALL WD32DdeUnaccessData(PVDMFRAME pFrame)
  524. {
  525. VPVOID vp;
  526. ULONG ul = 1;
  527. DWORD cbData;
  528. DWORD cbOffset = 0;
  529. LPBYTE lpByte;
  530. PVOID p;
  531. register PDDEUNACCESSDATA16 parg16;
  532. UINT DataFormat;
  533. HAND16 h16;
  534. LOGDDEMLENTRY(pFrame);
  535. GETARGPTR(pFrame, sizeof(DDEUNACCESSDATA16), parg16);
  536. DataFormat = DdeGetDataHandleFormat (parg16->f1); // -1 is an error
  537. if (DataFormat != -1) {
  538. h16 = (VPVOID)WOWDdemlGetBind16 ((DWORD)parg16->f1, aAccessData);
  539. GlobalUnlock16(h16);
  540. vp = GlobalLock16(h16, NULL);
  541. if (!DdeIsDataHandleReadOnly((HDDEDATA)parg16->f1)) {
  542. lpByte = DdeAccessData(parg16->f1, &cbData);
  543. DdeDataSize32to16(&cbData, &cbOffset, DataFormat);
  544. GETMISCPTR (vp, p);
  545. ul = DdeDataBuf16to32 (p, &lpByte, &cbData, &cbOffset, DataFormat);
  546. WOW32SAFEASSERTWARN(ul, "WD32DdeAccessData:data conversion failed.\n");
  547. FREEMISCPTR (p);
  548. }
  549. WOWDdemlUnBind ((DWORD)parg16->f1, aAccessData);
  550. GlobalUnlockFree16(GlobalLock16(h16, NULL));
  551. if (ul) {
  552. ul = GETBOOL16(DdeUnaccessData(parg16->f1));
  553. }
  554. } else {
  555. ul = 0;
  556. }
  557. WOW32SAFEASSERTWARN(ul, "WD32DdeAccessData\n");
  558. FREEARGPTR(parg16);
  559. LOGDDEMLRETURN(pFrame, ul);
  560. RETURN(ul);
  561. }
  562. ULONG FASTCALL WD32DdeFreeDataHandle(PVDMFRAME pFrame)
  563. {
  564. ULONG ul = 0;
  565. register PDDEFREEDATAHANDLE16 parg16;
  566. LOGDDEMLENTRY(pFrame);
  567. GETARGPTR(pFrame, sizeof(DDEFREEDATAHANDLE16), parg16);
  568. ul = (ULONG)DdeFreeDataHandle(parg16->f1);
  569. WOW32SAFEASSERTWARN(ul, "WD32DdeFreeDataHandle\n");
  570. FREEARGPTR(parg16);
  571. LOGDDEMLRETURN(pFrame, ul);
  572. RETURN(ul);
  573. }
  574. ULONG FASTCALL WD32DdeGetLastError(PVDMFRAME pFrame)
  575. {
  576. ULONG ul = 0;
  577. register PDDEGETLASTERROR16 parg16;
  578. LOGDDEMLENTRY(pFrame);
  579. GETARGPTR(pFrame, sizeof(DDEGETLASTERROR16), parg16);
  580. ul = (ULONG)DdeGetLastError(parg16->f1);
  581. FREEARGPTR(parg16);
  582. LOGDDEMLRETURN(pFrame, ul);
  583. RETURN(ul);
  584. }
  585. ULONG FASTCALL WD32DdeCreateStringHandle(PVDMFRAME pFrame)
  586. {
  587. ULONG ul = 0;
  588. LPSTR p;
  589. register PDDECREATESTRINGHANDLE16 parg16;
  590. LOGDDEMLENTRY(pFrame);
  591. GETARGPTR(pFrame, sizeof(DDECREATESTRINGHANDLE16), parg16);
  592. GETPSZPTR (parg16->f2, p);
  593. ul = (ULONG)DdeCreateStringHandle(parg16->f1, p, INT32(parg16->f3));
  594. FREEPSZPTR(p);
  595. FREEARGPTR(parg16);
  596. LOGDDEMLRETURN(pFrame, ul);
  597. RETURN(ul);
  598. }
  599. ULONG FASTCALL WD32DdeFreeStringHandle(PVDMFRAME pFrame)
  600. {
  601. ULONG ul = 0;
  602. register PDDEFREESTRINGHANDLE16 parg16;
  603. LOGDDEMLENTRY(pFrame);
  604. GETARGPTR(pFrame, sizeof(DDEFREESTRINGHANDLE16), parg16);
  605. ul = (ULONG)DdeFreeStringHandle(parg16->f1, parg16->f2);
  606. WOW32SAFEASSERTWARN(ul, "WD32DdeFreeStringHandle\n");
  607. FREEARGPTR(parg16);
  608. LOGDDEMLRETURN(pFrame, ul);
  609. RETURN(ul);
  610. }
  611. ULONG FASTCALL WD32DdeQueryString(PVDMFRAME pFrame)
  612. {
  613. ULONG ul = 0;
  614. LPSTR lpByte = NULL;
  615. register PDDEQUERYSTRING16 parg16;
  616. LOGDDEMLENTRY(pFrame);
  617. GETARGPTR(pFrame, sizeof(DDEQUERYSTRING16), parg16);
  618. GETMISCPTR(parg16->f3, lpByte);
  619. ul = (ULONG)DdeQueryString(parg16->f1,
  620. parg16->f2,
  621. lpByte,
  622. parg16->f4,
  623. (int)UINT32(parg16->f5));
  624. if (lpByte)
  625. FREEMISCPTR(lpByte);
  626. WOW32SAFEASSERTWARN(ul, "WD32DdeQueryString\n");
  627. FREEARGPTR(parg16);
  628. LOGDDEMLRETURN(pFrame, ul);
  629. RETURN(ul);
  630. }
  631. ULONG FASTCALL WD32DdeKeepStringHandle(PVDMFRAME pFrame)
  632. {
  633. ULONG ul = 0;
  634. register PDDEKEEPSTRINGHANDLE16 parg16;
  635. LOGDDEMLENTRY(pFrame);
  636. GETARGPTR(pFrame, sizeof(DDEKEEPSTRINGHANDLE16), parg16);
  637. ul = (ULONG)DdeKeepStringHandle(parg16->f1, parg16->f2);
  638. WOW32SAFEASSERTWARN(ul, "WD32DdeKeepStringHandle\n");
  639. FREEARGPTR(parg16);
  640. LOGDDEMLRETURN(pFrame, ul);
  641. RETURN(ul);
  642. }
  643. ULONG FASTCALL WD32DdeEnableCallback(PVDMFRAME pFrame)
  644. {
  645. ULONG ul = 0;
  646. register PDDEENABLECALLBACK16 parg16;
  647. LOGDDEMLENTRY(pFrame);
  648. GETARGPTR(pFrame, sizeof(DDEENABLECALLBACK16), parg16);
  649. ul = (ULONG)DdeEnableCallback(parg16->f1, parg16->f2, parg16->f3);
  650. WOW32SAFEASSERTWARN(ul, "WD32DdeEnableCallBack\n");
  651. FREEARGPTR(parg16);
  652. LOGDDEMLRETURN(pFrame, ul);
  653. RETURN(ul);
  654. }
  655. ULONG FASTCALL WD32DdeNameService(PVDMFRAME pFrame)
  656. {
  657. ULONG ul = 0;
  658. register PDDENAMESERVICE16 parg16;
  659. LOGDDEMLENTRY(pFrame);
  660. GETARGPTR(pFrame, sizeof(DDENAMESERVICE16), parg16);
  661. ul = (ULONG)DdeNameService(parg16->f1, parg16->f2, parg16->f3, UINT32(parg16->f4));
  662. WOW32SAFEASSERTWARN(ul, "WD32DdeNameService\n");
  663. FREEARGPTR(parg16);
  664. LOGDDEMLRETURN(pFrame, ul);
  665. RETURN(ul);
  666. }
  667. ULONG FASTCALL WD32DdeCmpStringHandles(PVDMFRAME pFrame)
  668. {
  669. ULONG ul = 0;
  670. register PDDECMPSTRINGHANDLES16 parg16;
  671. LOGDDEMLENTRY(pFrame);
  672. GETARGPTR(pFrame, sizeof(DDECMPSTRINGHANDLES16), parg16);
  673. ul = (ULONG)DdeCmpStringHandles(parg16->f1, parg16->f2);
  674. FREEARGPTR(parg16);
  675. LOGDDEMLRETURN(pFrame, ul);
  676. RETURN(ul);
  677. }
  678. ULONG FASTCALL WD32DdeReconnect(PVDMFRAME pFrame)
  679. {
  680. ULONG ul = 0;
  681. register PDDERECONNECT16 parg16;
  682. LOGDDEMLENTRY(pFrame);
  683. GETARGPTR(pFrame, sizeof(DDERECONNECT16), parg16);
  684. ul = (ULONG)DdeReconnect(parg16->f1);
  685. FREEARGPTR(parg16);
  686. LOGDDEMLRETURN(pFrame, ul);
  687. RETURN(ul);
  688. }
  689. HDDEDATA W32DdemlCallBack(UINT type, UINT fmt, HCONV hconv, HSZ hsz1,
  690. HSZ hsz2, HDDEDATA hData, DWORD dwData1,
  691. DWORD dwData2)
  692. {
  693. DWORD IdInst;
  694. VPVOID vp, vpCC;
  695. LONG lReturn;
  696. PARM16 Parm16;
  697. BOOL fSuccess;
  698. HAND16 hCC16;
  699. LOGDEBUG(ddeloglevel, ("Calling WIN16 DDEMLCALLBACK(%08lx, %08lx, %08lx, %08lx, %08lx, %08lx, %08lx, %08lx)\n",
  700. type, fmt, hconv, hsz1, hsz2, hData, dwData1, dwData2));
  701. IdInst = DdeGetCallbackInstance ();
  702. vp = (VPVOID) WOWDdemlGetBind16 (IdInst, aCallBack);
  703. Parm16.Ddeml.type = (WORD)type;
  704. Parm16.Ddeml.fmt = (WORD)fmt;
  705. Parm16.Ddeml.hconv = hconv;
  706. Parm16.Ddeml.hsz1 = hsz1;
  707. Parm16.Ddeml.hsz2 = hsz2;
  708. Parm16.Ddeml.hData = hData;
  709. if (type == XTYP_CONNECT || type == XTYP_WILDCONNECT) {
  710. /*
  711. * On XTYP_CONNECT and XTYP_WILDCONNECT transactions, dwData1 is a
  712. * pointer to a CONVCONTEXT structure.
  713. */
  714. vpCC = GlobalAllocLock16(GHND, sizeof(CONVCONTEXT16), &hCC16);
  715. // WARNING: 16-bit memory may move - invalidate any flat pointers now
  716. Parm16.Ddeml.dwData1 = vpCC;
  717. if (vpCC) {
  718. W32PutConvContext(vpCC, (PCONVCONTEXT)dwData1);
  719. }
  720. } else {
  721. Parm16.Ddeml.dwData1 = dwData1;
  722. }
  723. Parm16.Ddeml.dwData2 = dwData2;
  724. fSuccess = CallBack16(RET_DDEMLCALLBACK, &Parm16, vp, (PVPVOID)&lReturn);
  725. // WARNING: 16-bit memory may move - invalidate any flat pointers now
  726. if (type == XTYP_CONNECT || type == XTYP_WILDCONNECT) {
  727. GlobalUnlockFree16(vpCC);
  728. }
  729. if (!fSuccess) {
  730. WOW32SAFEASSERTWARN(NULL, "WOW::CallBack16 for DDEML failed.\n");
  731. lReturn = 0;
  732. }
  733. LOGDEBUG(ddeloglevel, ("DDEMLCALLBACK:%08lx\n", lReturn));
  734. return (lReturn);
  735. }
  736. VOID WOWDdemlBind (DWORD x16, DWORD x32, BIND1632 aBind[])
  737. {
  738. int i;
  739. for (i=0; i < MAX_CONVS; i++) {
  740. if (aBind[i].x32 == 0) {
  741. aBind[i].x32 = x32;
  742. aBind[i].x16 = x16;
  743. return;
  744. }
  745. }
  746. LOGDEBUG(0,("WOW::WOWDdemlBind is all FULL!!!\n"));
  747. }
  748. VOID WOWDdemlUnBind (DWORD x32, BIND1632 aBind[])
  749. {
  750. int i;
  751. for (i=0; i < MAX_CONVS; i++) {
  752. if (aBind[i].x32 == x32) {
  753. aBind[i].x32 = 0;
  754. aBind[i].x16 = 0;
  755. return;
  756. }
  757. }
  758. LOGDEBUG(0,("WOW::WOWDdemlUnBind can't find x32 !!!\n"));
  759. }
  760. DWORD WOWDdemlGetBind16 (DWORD x32, BIND1632 aBind[])
  761. {
  762. int i;
  763. for (i=0; i < MAX_CONVS; i++) {
  764. if (aBind[i].x32 == x32) {
  765. return(aBind[i].x16);
  766. }
  767. }
  768. LOGDEBUG(0,("WOW::WOWDdemlGetBind16 can't find x16 !!!\n"));
  769. }
  770. DWORD WOWDdemlGetBind32 (DWORD x16, BIND1632 aBind[])
  771. {
  772. int i;
  773. for (i=0; i < MAX_CONVS; i++) {
  774. if (aBind[i].x16 == x16) {
  775. return(aBind[i].x32);
  776. }
  777. }
  778. LOGDEBUG(0,("WOW::WOWDdemlGetBind32 can't find x16 !!!\n"));
  779. }
  780. BOOL DdeDataBuf16to32(
  781. PVOID p16DdeData, // flat pointer to 16 bit DDE data buffer
  782. LPBYTE *pp32DdeData, // we malloc_w this in this function if not pNULL - must be freed!
  783. PDWORD pcbData, // IN:16 bit cbData OUT:32 bit cbData
  784. PDWORD pcbOffset, // IN:16 bit cbOffset OUT:32 bit cbOffset
  785. UINT format) // format of the data
  786. {
  787. PHANDLE p;
  788. HAND16 hMF16;
  789. HANDLE hMF32;
  790. switch (format) {
  791. case CF_PALETTE:
  792. /*
  793. * GDI palette handle
  794. */
  795. if (*pcbOffset) {
  796. WOW32SAFEASSERTWARN(NULL, "WOW::DdeDataBuf16to32: PALETTE cbOffset is non NULL\n");
  797. return(FALSE);
  798. break;
  799. }
  800. if (*pcbData != sizeof(HAND16)) {
  801. WOW32SAFEASSERTWARN(NULL, "WOW::DdeDataBuf16to32: PALETTE cbData is wrong size\n");
  802. return(FALSE);
  803. }
  804. if (*pp32DdeData == NULL) {
  805. p = (PHANDLE)*pp32DdeData = malloc_w(sizeof(HANDLE));
  806. } else {
  807. p = (PHANDLE)*pp32DdeData;
  808. }
  809. *p = HPALETTE32(*(HAND16 *)p16DdeData);
  810. *pcbData = sizeof(HANDLE);
  811. break;
  812. case CF_DSPBITMAP:
  813. case CF_BITMAP:
  814. /*
  815. * GDI bitmap handle
  816. */
  817. if (*pcbOffset) {
  818. WOW32SAFEASSERTWARN(NULL, "WOW::DdeDataBuf16to32: BITMAP cbOffset is non NULL\n");
  819. return(FALSE);
  820. break;
  821. }
  822. if (*pcbData != sizeof(HAND16)) {
  823. WOW32SAFEASSERTWARN(NULL, "WOW::DdeDataBuf16to32: BITMAP cbData is wrong size\n");
  824. return(FALSE);
  825. }
  826. /*
  827. * Convert 16 bit handle to 32 bit bitmap handle and place into
  828. * 32 bit buffer.
  829. */
  830. if (*pp32DdeData == NULL) {
  831. p = (PHANDLE)*pp32DdeData = malloc_w(sizeof(HANDLE));
  832. } else {
  833. p = (PHANDLE)*pp32DdeData;
  834. }
  835. *p = HBITMAP32(*(HAND16 *)p16DdeData);
  836. *pcbData = sizeof(HANDLE);
  837. break;
  838. case CF_DIB:
  839. /*
  840. * GlobalDataHandle to DIB Bits
  841. */
  842. if (*pcbOffset) {
  843. WOW32SAFEASSERTWARN(NULL, "WOW::DdeDataBuf16to32: DIB cbOffset is wrong\n");
  844. return(FALSE);
  845. }
  846. if (*pcbData != sizeof(HAND16)) {
  847. WOW32SAFEASSERTWARN(NULL, "WOW::DdeDataBuf16to32: DIB cbData is wrong size\n");
  848. return(FALSE);
  849. }
  850. if (*pp32DdeData == NULL) {
  851. p = (PHANDLE)*pp32DdeData = malloc_w(sizeof(HANDLE));
  852. } else {
  853. p = (PHANDLE)*pp32DdeData;
  854. }
  855. if (p == NULL) {
  856. WOW32SAFEASSERTWARN(NULL, "WOW::DdeDataBuf16to32: DIB malloc failed.\n");
  857. return(FALSE);
  858. }
  859. *p = ConvertDIB32(*(HAND16 *)p16DdeData);
  860. if (*p == NULL) {
  861. return(FALSE);
  862. }
  863. DDEAddhandle((HAND16)-1, (HAND16)-1, *(HAND16 *)p16DdeData, *p);
  864. *pcbData = sizeof(HANDLE);
  865. break;
  866. case CF_DSPMETAFILEPICT:
  867. case CF_METAFILEPICT:
  868. /*
  869. * GlobalDataHandle holding a METAFILEPICT struct which
  870. * references a GDI metafile handle.
  871. */
  872. if (*pcbOffset) {
  873. WOW32SAFEASSERTWARN(NULL, "WOW::DdeDataBuf16to32: METAFILEPICT cbOffset is not 0\n");
  874. return(FALSE);
  875. }
  876. if (*pcbData != sizeof(HAND16)) {
  877. WOW32SAFEASSERTWARN(NULL, "WOW::DdeDataBuf16to32: METAFILEPICT cbData is wrong size\n");
  878. return(FALSE);
  879. }
  880. if (*pp32DdeData == NULL) {
  881. p = (PHANDLE)*pp32DdeData = malloc_w(sizeof(HANDLE));
  882. } else {
  883. p = (PHANDLE)*pp32DdeData;
  884. }
  885. if (p == NULL) {
  886. WOW32SAFEASSERTWARN(NULL, "WOW::DdeDataBuf16to32: METAFILEPICT malloc failed.\n");
  887. return(FALSE);
  888. }
  889. *p = ConvertMetaFile32(*(HAND16 *)p16DdeData, &hMF16, &hMF32);
  890. if (*p == NULL) {
  891. return(FALSE);
  892. }
  893. DDEAddhandle((HAND16)-1, (HAND16)-1, hMF16, hMF32);
  894. DDEAddhandle((HAND16)-1, (HAND16)-1, *(HAND16 *)p16DdeData, *p);
  895. *pcbData = sizeof(HANDLE);
  896. break;
  897. default:
  898. if (*pp32DdeData == NULL) {
  899. *pp32DdeData = malloc_w(*pcbData);
  900. }
  901. memcpy(*pp32DdeData, p16DdeData, *pcbData);
  902. }
  903. return(TRUE);
  904. }
  905. BOOL DdeDataBuf32to16(
  906. PVOID p16DdeData, // flat pointer to 16 bit app buffer for data
  907. PVOID p32DdeData, // source 32 bit buffer
  908. DWORD cbData, // IN:32 bit size
  909. DWORD cbOffset, // IN:32 bit offset
  910. UINT format) // format of data
  911. {
  912. PHANDLE p;
  913. HAND16 hMF16;
  914. HANDLE hMF32;
  915. switch (format) {
  916. case CF_PALETTE:
  917. /*
  918. * GDI palette handle
  919. */
  920. if (cbOffset) {
  921. WOW32SAFEASSERTWARN(NULL, "WOW::DdeDataBuf32to16: PALETTE cbOffset is non NULL\n");
  922. return(FALSE);
  923. break;
  924. }
  925. if (cbData != sizeof(HANDLE)) {
  926. WOW32SAFEASSERTWARN(NULL, "WOW::DdeDataBuf32to16: PALETTE cbData is wrong size\n");
  927. return(FALSE);
  928. }
  929. *(HAND16 *)p16DdeData = GETHPALETTE16(*(HANDLE *)p32DdeData);
  930. break;
  931. case CF_DSPBITMAP:
  932. case CF_BITMAP:
  933. /*
  934. * GDI bitmap handle
  935. */
  936. if (cbOffset) {
  937. WOW32SAFEASSERTWARN(NULL, "WOW::DdeDataBuf32to16: BITMAP cbOffset is non NULL\n");
  938. return(FALSE);
  939. break;
  940. }
  941. if (cbData != sizeof(HANDLE)) {
  942. WOW32SAFEASSERTWARN(NULL, "WOW::DdeDataBuf32to16: BITMAP cbData is wrong size\n");
  943. return(FALSE);
  944. }
  945. /*
  946. * Convert 16 bit handle to 32 bit bitmap handle and place into
  947. * 32 bit buffer.
  948. */
  949. *(HAND16 *)p16DdeData = GETHBITMAP16(*(HBITMAP *)p32DdeData);
  950. break;
  951. case CF_DIB:
  952. /*
  953. * GlobalDataHandle to DIB Bits
  954. */
  955. if (cbOffset) {
  956. WOW32SAFEASSERTWARN(NULL, "WOW::DdeDataBuf32to16: DIB cbOffset is wrong\n");
  957. return(FALSE);
  958. }
  959. if (cbData != sizeof(HANDLE)) {
  960. WOW32SAFEASSERTWARN(NULL, "WOW::DdeDataBuf32to16: DIB cbData is wrong size\n");
  961. return(FALSE);
  962. }
  963. *(HAND16 *)p16DdeData = ConvertDIB16(*(HANDLE *)p32DdeData);
  964. if (*(HAND16 *)p16DdeData == NULL) {
  965. return(FALSE);
  966. }
  967. DDEAddhandle((HAND16)-1, (HAND16)-1, *(HAND16 *)p16DdeData, *(HANDLE *)p32DdeData);
  968. break;
  969. case CF_DSPMETAFILEPICT:
  970. case CF_METAFILEPICT:
  971. /*
  972. * GlobalDataHandle holding a METAFILEPICT struct which
  973. * references a GDI metafile handle.
  974. */
  975. if (cbOffset) {
  976. WOW32SAFEASSERTWARN(NULL, "WOW::DdeDataBuf32to16: METAFILEPICT cbOffset is not 0\n");
  977. return(FALSE);
  978. }
  979. if (cbData != sizeof(HANDLE)) {
  980. WOW32SAFEASSERTWARN(NULL, "WOW::DdeDataBuf32to16: METAFILEPICT cbData is wrong size\n");
  981. return(FALSE);
  982. }
  983. *(HAND16 *)p16DdeData = ConvertMetaFile16(*(HANDLE *)p32DdeData, &hMF16, &hMF32);
  984. if (*(HAND16 *)p16DdeData == NULL) {
  985. return(FALSE);
  986. }
  987. DDEAddhandle((HAND16)-1, (HAND16)-1, hMF16, hMF32);
  988. DDEAddhandle((HAND16)-1, (HAND16)-1, *(HAND16 *)p16DdeData, *(HANDLE *)p32DdeData);
  989. break;
  990. default:
  991. memcpy(p16DdeData, p32DdeData, cbData);
  992. }
  993. return(TRUE);
  994. }
  995. VOID DdeDataSize16to32(
  996. DWORD *pcbData,
  997. DWORD *pcbOff,
  998. UINT format)
  999. {
  1000. switch (format) {
  1001. case CF_DSPBITMAP:
  1002. case CF_BITMAP:
  1003. case CF_DIB:
  1004. case CF_PALETTE:
  1005. case CF_DSPMETAFILEPICT:
  1006. case CF_METAFILEPICT:
  1007. *pcbData = sizeof(HANDLE);
  1008. }
  1009. }
  1010. VOID DdeDataSize32to16(
  1011. DWORD *pcbData,
  1012. DWORD *pcbOff,
  1013. UINT format)
  1014. {
  1015. switch (format) {
  1016. case CF_DSPBITMAP:
  1017. case CF_BITMAP:
  1018. case CF_DIB:
  1019. case CF_PALETTE:
  1020. case CF_DSPMETAFILEPICT:
  1021. case CF_METAFILEPICT:
  1022. *pcbData = sizeof(HAND16);
  1023. }
  1024. }
  1025. VOID W32GetConvContext (VPVOID vp, PCONVCONTEXT pCC32)
  1026. {
  1027. PCONVCONTEXT16 pCC16;
  1028. GETMISCPTR (vp, pCC16);
  1029. if (pCC16) {
  1030. WOW32SAFEASSERTWARN((pCC16->cb == sizeof(CONVCONTEXT16)),"WOW::W32GetConvContext: Bad value in cb\n");
  1031. pCC32->cb = sizeof(CONVCONTEXT);
  1032. pCC32->wFlags = pCC16->wFlags;
  1033. pCC32->wCountryID = pCC16->wCountryID;
  1034. pCC32->iCodePage = pCC16->iCodePage;
  1035. pCC32->dwLangID = pCC16->dwLangID;
  1036. pCC32->dwSecurity = pCC16->dwSecurity;
  1037. /*
  1038. * WOW apps don't know anything about NT security so just pass on the
  1039. * default QOS that the system grants to know-nothing apps.
  1040. */
  1041. pCC32->qos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE);
  1042. pCC32->qos.ImpersonationLevel = SecurityImpersonation;
  1043. pCC32->qos.ContextTrackingMode = SECURITY_STATIC_TRACKING;
  1044. pCC32->qos.EffectiveOnly = TRUE;
  1045. }
  1046. FREEMISCPTR(pCC16);
  1047. }
  1048. VOID W32PutConvContext (VPVOID vp, PCONVCONTEXT pCC32)
  1049. {
  1050. PCONVCONTEXT16 pCC16;
  1051. GETMISCPTR (vp, pCC16);
  1052. if (pCC16) {
  1053. WOW32SAFEASSERTWARN((pCC32->cb == sizeof(CONVCONTEXT)),"WOW::W32PutConvContext: Bad value in cb\n");
  1054. pCC16->cb = sizeof(CONVCONTEXT16);
  1055. pCC16->wFlags = pCC32->wFlags;
  1056. pCC16->wCountryID = pCC32->wCountryID;
  1057. pCC16->iCodePage = pCC32->iCodePage;
  1058. pCC16->dwLangID = pCC32->dwLangID;
  1059. pCC16->dwSecurity = pCC32->dwSecurity;
  1060. }
  1061. FREEMISCPTR(pCC16);
  1062. }