When my program calls my dll, does my dll have to create a windows hook to subclass my dialog? Or can I just SetWindowLong since my .exe called it.
SetWindowLong will work because the dll is loaded into the same process as the dialog. You would only need to use a hook if the dll was loaded into another process.
I can't get it to work. I'm using FindWindow to get the HWND of my dialog. I know that part works.
invoke SetWindowLong,eax,GWL_WNDPROC,addr MyWndProc ; eax is the window handle.
mov hOldProc,eax
test eax,eax
jnz swlpass
<error code>
swlpass:
return TRUE ;If error at startup, return 0
...
MyWndProc proc hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
mov uMsg,eax
.if eax==WM_SHOWWINDOW
szText ztxt,"GOOD"
invoke MessageBox,hWnd,addr ztxt,addr ztxt,0
.endif
invoke CallWindowProc, hOldProc, hWnd, uMsg, wParam, lParam
ret
MyWndProc endp
My error message box pops up...
invoke SetWindowLong,eax,GWL_WNDPROC,addr MyWndProc ; eax is the window handle.
mov hOldProc,eax
test eax,eax
jnz swlpass
<error code>
swlpass:
return TRUE ;If error at startup, return 0
...
MyWndProc proc hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
mov uMsg,eax
.if eax==WM_SHOWWINDOW
szText ztxt,"GOOD"
invoke MessageBox,hWnd,addr ztxt,addr ztxt,0
.endif
invoke CallWindowProc, hOldProc, hWnd, uMsg, wParam, lParam
ret
MyWndProc endp
My error message box pops up...
Has the window been created when you call the dll? That is the only thing I can see that would result in a zero return from SetWindowLong. Try GetLastError to see what the problem is:
invoke GetLastError
invoke FormatMessage, FORMAT_MESSAGE_FROM_SYSTEM, NULL, eax, NULL, pTempBuffer, 128, NULL
invoke MessageBox, NULL, pTempBuffer, NULL, MB_OK
You are right, it's calling the dll before the window is created.
This is so weird... I coded a timer to detect when window is open; works. Then it does setwindowlong and returns 0! Why would it return 0? The window is there... The .exe is calling the dll...
---------------
Ok I fixed the problem above, but now my program freezes? Could you show me an example of how you would setup a PROC for the window when using SetWindowLong?
------------------------------------
lol now I fixed the problem above... Posted before I actually checked myself.
Thanks
---------------
Ok I fixed the problem above, but now my program freezes? Could you show me an example of how you would setup a PROC for the window when using SetWindowLong?
------------------------------------
lol now I fixed the problem above... Posted before I actually checked myself.
Thanks