I'm really overwhelmed here. I've made a DLL with a window procedure in it, and in another project I've attempted to use CreateRemoteThread() to load the library into the other process. It simply won't work. I'll try to debug it myself, but in the meantime, here's a bit of my code:
Dll main file:
Code:
#include <windows.h>
#define DLL_EXPORT
#include "bfSubClass.h"
BOOL WINAPI DllEntryPoint(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
{
HWND hList;
hList=FindListView();
SubClass(hList,ListProc);
MessageBox(NULL,"Dll loaded","Notify",MB_OK);
}
case DLL_PROCESS_DETACH:
{
HWND hList;
hList=FindListView();
SendMessage(hList,WM_USER+1,2,0);
}
default:
break;
}
return TRUE;
}
HWND FindListView(void)
{
DWORD dwProcId;
DWORD dwGetProcId;
HWND hFind=NULL;
HWND hChildFind=NULL;
dwProcId=GetCurrentProcessId();
hFind=FindWindow("DC++",NULL);
GetWindowThreadProcessId(hFind,&dwGetProcId);
if (dwGetProcId==dwProcId)
hChildFind=FindWindowEx(hFind,NULL,"SysListView32",NULL);
return hChildFind;
}
BOOL DS SubClass(HWND hSub,WNDPROC lpfnWndProc)
{
WNDPROC oldProc;
oldProc=(WNDPROC)SetWindowLong(hSub,GWL_WNDPROC,(LONG)lpfnWndProc);
SendMessage(hSub,WM_USER+1,1,(LPARAM)oldProc);
return TRUE;
}
LRESULT CALLBACK ListProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
static WNDPROC oldProc;
switch (msg)
{
case (WM_USER+1):
if ( (wParam==1) && (lParam) )
oldProc=(WNDPROC)lParam;
if ( (wParam==2) && (!lParam) )
SetWindowLong(hwnd,GWL_WNDPROC,(LONG)oldProc);
case WM_LBUTTONUP:
MessageBox(NULL,"YO BUTTON CLICKED","NOTIFY",MB_OK);
break;
default:
break;
}
return CallWindowProc(oldProc,hwnd,msg,wParam,lParam);
}
Dll header:
Code:
#ifndef bfSCH
#define bfSCH
#ifndef DLL_EXPORT
#define DS __declspec(dllimport)
#else
#define DS __declspec(dllexport)
#endif
HWND DS FindListView(void);
BOOL DS SubClass(HWND,WNDPROC);
LRESULT CALLBACK DS ListProc(HWND,UINT,WPARAM,LPARAM);
#endif
Is there anything wrong with that?