Sign in to follow this  
Followers 0
monoceres

Subclassing a window

3 posts in this topic

So I tried to follow Valiks advice in this post and I nearly succeeded, at least I think so :o

I injected the code, so far so good.

I replaced the default WndProc with my own. Also without problems.

Filtering a message, now this is where the problems arise :P

My code for the injected dll look like this:

#include <windows.h>

WNDPROC original;

LRESULT CALLBACK SubWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{

    if (msg==WM_CLOSE)
        return 0;
    
    return DefWindowProc(hwnd,msg,wParam,lParam);
 //return CallWindowProcW(original,hwnd,msg,wParam,lParam);

}


BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
                     )
{
    HWND hwnd;
    hModule;
    lpReserved;
    

    switch (ul_reason_for_call)
    {
        case DLL_PROCESS_ATTACH:
            MessageBoxW(NULL,L"I am now injected, hehehe",L"Injected",NULL);
            hwnd=FindWindowW(NULL,L"Sample");
            original=(WNDPROC)SetWindowLongW(hwnd,GWL_WNDPROC,(long)SubWndProc);
        case DLL_THREAD_ATTACH:
        case DLL_THREAD_DETACH:
        case DLL_PROCESS_DETACH:
            break;
    }
    return TRUE;
}

If I inject it as it is now I totally screw up the window (duh), but if I call the original WndProc WM_CLOSE is still sent to it.

I guess I have got everything upside-down again...

Thanks in advance :P


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites



Hmm this is weird. It works perfectly when trying with vlc instead of the autoit app I tested with first.

Is autoit processing messages in a special way?


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Is autoit processing messages in a special way?

Assuredly.

Lar.


f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0