The following code is responding to the WM_DDE_DATA message posted by other app. The "lParam" holds a memory handle (the lower word) and an atom handle (the upper word). I can retrieve the atom but when I try to acces the memory using the memory handle, Windows say to me "Invalid parameter". The source code is posted below. Any ideas? Practically the "GlobalLock" function is not working correctly.

Thanks!

WndProc proc hWin :DWORD,
uMsg :DWORD,
wParam :DWORD,
lParam :DWORD

.if uMsg == WM_DDE_DATA

xor eax,eax
mov ax,word ptr lParam
mov hData,eax ;result1
mov ax,word ptr lParam+2
mov aItem,eax ;result2

invoke GlobalLock,hData ;obtain shared memory pointer (from memory handle)
.if eax==0
;error
invoke GetLastError
invoke FormatMessage,FORMAT_MESSAGE_FROM_SYSTEM,0,eax,0,addr buffer_date,20000,0
invoke MessageBox,0,addr buffer_date,addr szClassName,MB_OK

.else
;pointer ok
add eax,3
invoke MessageBox,0,eax,addr szDisplayName,MB_OK
.endif
Posted on 2003-04-22 05:50:40 by icezone
Maybe you mixed up in the part on extracting the pointer and the handle.
Posted on 2003-04-22 07:07:36 by roticv

Maybe you mixed up in the part on extracting the pointer and the handle.



I checked that with the softice debugger! The parameter passed to the GlobalUnlock function is correct because I have another spying app wich is showing the same numbers as those in hData.

Anyway, this piece of code was used in a DDE transaction, but I found another way of doing it (using DDEML functions) and now I can acces the data passed by the other app to me, so it really works!
Posted on 2003-04-22 09:01:38 by icezone
xor eax,eax
mov ax,word ptr lParam
mov hData,eax ;result1
mov ax,word ptr lParam+2
mov aItem,eax ;result2
This could be interpreted as using lParam as an address instead of data.

The following code could not be misinterpreted:
mov eax,lParam

movzx eax,ax ;handle now in eax
mov ecx,lParam
shr ecx,16 ;atom now in ecx
Raymond
Posted on 2003-04-22 09:48:43 by Raymond
hehe... why not use and instead of movzx? I thought and with acculmator is 1 byte shorter and abit faster?
Posted on 2003-04-22 09:52:34 by roticv