User forums > General (but related to Code::Blocks)

How to compile DLL in PE32?

<< < (2/2)

deepdish:
Thanks for replies, I did manage to compile using 32bit minigw and choosing PE32 somewhere in options. Also attached the dll and it does its job renaming the window(which is what is was supposed to do) but not as good as expected, it does rename window but when I minimize the application for a blink of a second old name comes back and dll changes it back after(I need constant change) and also when I login via user the application changes the window name to username - windowname, and since usernames are different its impossible to catch every instance without using wildcards in this code to rename the window back, im sure there is a better solution out there for this task:

main.cpp

--- Code: ---#include "main.h"
#include "Winuser.h"
#include <process.h>


void TitleReplaceHookThread(void *param)
{
    DWORD pid = 0;
    DWORD current_pid = GetCurrentProcessId();
while(true)
{
Sleep(1);
HWND hWnd = FindWindow(NULL, "Original Application Name");
GetWindowThreadProcessId(hWnd,&pid);
if(hWnd&&current_pid==pid)
        {
        SetWindowText(hWnd, "My Custom Name");
        break;
        }
}
}

extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
    switch (fdwReason)
    {
        case DLL_PROCESS_ATTACH:
             HANDLE hThread;
            hThread = (HANDLE)_beginthread(TitleReplaceHookThread, 0, NULL);
            CloseHandle(hThread);
            break;
    }
    return TRUE;
}

--- End code ---

main.h

--- Code: ---#ifndef __MAIN_H__
#define __MAIN_H__

#include <windows.h>

#ifdef BUILD_DLL
    #define DLL_EXPORT __declspec(dllexport)
#else
    #define DLL_EXPORT __declspec(dllimport)
#endif

#endif

--- End code ---

Also I found the static pointer which is responsible for renaming the window in the first place, the preferred choice would be to block that pointer via code, I have no idea how hard is it to write such code, I can pay for a code which can modify this.

Navigation

[0] Message Index

[*] Previous page

Go to full version