The code is as follows:
DLL:
#include
# define MYFIRSTDLL extern "C" __declspec (dllexport)
# include "firstdll. H"
HINSTANCE g_hInstance=NULL;
HHOOK g_hHook=NULL;
HWND hW=NULL;
WNDPROC lpOldProc;
Int the hello (int a, int b) {
Return (a + b);
}
BOOL WINAPI DllMain (HINSTANCE HINSTANCE, dwords fdwReason, PVOID fImpLoad) {
The switch (fdwReason)
{
Case DLL_PROCESS_ATTACH:
G_hInstance=hInstance;
break;
Case DLL_PROCESS_DETACH:
break;
}
Return (TRUE);
}
Void ahhh () {
MessageBox (NULL, TEXT (" hello "), TEXT (" hello "), MB_OK);
}
LRESULT a CALLBACK SubclassWndProc (HWND HWND, UINT uMsg, WPARAM WPARAM, LPARAM LPARAM)
{
The switch (uMsg)
{
Case WM_CLOSE:
MessageBox (NULL, TEXT (" shut out doesn't shut off gas is not "), TEXT (" remind "), MB_OK);
Default:
break;
}
return 0;
}
LRESULT WINAPI GetMsgProc (int nCode, WPARAM WPARAM, LPARAM LPARAM) {
LpOldProc=(WNDPROC) SetWindowLongPtr (hW, GWLP_WNDPROC LONG_PTR SubclassWndProc);
If (lpOldProc!=NULL)
Return TRUE;
The else
Return FALSE;
}
BOOL WINAPI SetFirstHook (DWORD dwThreadId, HWND HWND) {
G_hHook=SetWindowsHookEx (WH_GETMESSAGE GetMsgProc, g_hInstance, dwThreadId);
HW=hWnd;
Return TRUE;
}
Be injected programs:
#include
Int WINAPI WinMain (HINSTANCE, HINSTANCE, PTSTR, int) {
MessageBox (NULL, TEXT (" leisure "), TEXT (" leisure "), MB_OK);
}
Injection procedure:
#include
# include "firstdll. H"
# pragma comment (lib, "FirstDLL. Lib")
Int WINAPI WinMain (HINSTANCE, HINSTANCE, PTSTR, int) {
HWND Wnd=FindWindow (NULL, TEXT (" leisure "));
If (Wnd==NULL) MessageBox (NULL, TEXT (" can't find the window "), NULL, MB_OK);
The else {
SetFirstHook (GetWindowThreadProcessId (Wnd, NULL), Wnd);
MessageBox (NULL, TEXT (" into the successful "), NULL, MB_OK);
}
}
CodePudding user response:
You injection is not successful, or not successful? Are you sure you export the function name ok? Your code is too much, have time to see you