News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Using Window Message in a DLL

Started by Titan, January 05, 2005, 10:22:18 PM

Previous topic - Next topic

Titan

Hi, I'm injecting a DLL into a process, and I'd like to be able to receive it's messages so I read them as you would in your own program.  If I'm too confusing I'll try to clear it up;):

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

    .IF uMsg==WM_DESTROY
        invoke PostQuitMessage,NULL
    .ELSEIF uMsg==WM_CHAR
    push wParam
    pop char
    xor eax,eax
    ret
WndProc endp

That would be in your normal program.. how you read messages, stored in "uMsg".  I'm wondering how I can do this in my DLL.  I don't know if this is possible.. but it seems all things are possible in assembly! ;)

Thanks,
Titan

QvasiModo

I'm not sure I understand the question... why would DLL injection bother you when processing window (or thread) messages? :eek

Titan

No, I need to process the messeges IN my DLL itself!  I don't have access to the main program.  Is there a way to get hook the uMsg of a window?  Or emulate the WndProc in my DLL so I can get the uMsg?:)

hutch--

titan,

Quote
I don't have access to the main program.

This sounds suspiciously like a forum rule violation. We have no way of determining if you have the legal right to modify the functionality of the main program so unles you can explain to us what you are doing and why, we will have to close this thread.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Titan

One day I was playing around with depencies, to see what DLLs some programs used, and I noticed that the Google Toolbar is a DLL injected into Internet Explorer which peeked my curiousity.  I don't plan on modifying any program, I simply want to play around to see if I can "add on" using some of the messages you get in uMsg(like hotkeying and painting).  I'm sorry if this is against the rules.  If not, can you help out?

Thanks,
Titan

hutch--

It sounds OK so we can leave the topic here at the moment. It looks like you are trying to find the interface to add a DLL to the Internet Explorer program which is not a problem at all. I don't directly know how it is done but it sounds like a hook procedure rather than the code injection technique that tends to be used for "other" purposes.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Ash_

i attempted this a while back so i could make a plugin for MSN Messenger.the way i did it was to inject my dll. which i see you have done.

then Create a Thread pointing to your function which will have the subclassing code in it. this will be executed on DLL_PROCESS_ATTACH.

then use the SetWindowLong api call with the first argument of the handle of the process you want to hook. like the main window or a text box. then the second arg as the constant GWL_WNDPROC. (which is the procedure called when events happen for that window.) then the 3rd (from memory  :wink ) i think you use "addr yourprocname" have all the calls you want to intercept and stuff. make sure to store the old wndproc somewhere which is stored in eax when you make the SetWindowLong api call. and youll have to call "CallWindowProc" with the value from SetWindowLong. otherwise the messages the original window procedure parses wont get parsed.

umm also check out Icztutes Tutorial 20 it shows an example on subclassing.

hope this helps.