Mã:
#include "StdAfx.h"
#pragma data_seg(".shared")
#pragma comment(lib,"User32.lib")
#pragma comment(lib,"Advapi32.lib")
DWORD ProtectingPid = 0;
#pragma data_seg()
HMODULE MyModuleHandle;
HHOOK hhk = NULL;
DWORD MyPid = 0;
unsigned char Store[10];
long _stdcall SelfInject();
long _stdcall SelfEject();
LRESULT CALLBACK GetMsgProc(int nCode,WPARAM wParam,LPARAM lParam);
HWND _stdcall CreateWindowExW2( DWORD dwExStyle,
LPCWSTR lpClassName,
LPCWSTR lpWindowName,
DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam
);
void HookAPI();
void UnHookAPI();
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD reason,
LPVOID lpReserved
)
{
if (reason == DLL_PROCESS_ATTACH)
{
HookAPI();
MyModuleHandle = (HMODULE)hModule;
MyPid = GetCurrentProcessId();
}
else if (reason == DLL_PROCESS_DETACH)
{
UnHookAPI();
}
return TRUE;
}
long _stdcall SelfInject()
{
ProtectingPid = MyPid;
hhk = SetWindowsHookEx(WH_GETMESSAGE,GetMsgProc,MyModuleHandle,0);
return (hhk != NULL);
}
long _stdcall SelfEject()
{
return UnhookWindowsHookEx(hhk);
}
LRESULT CALLBACK GetMsgProc(int nCode,WPARAM wParam,LPARAM lParam)
{
return CallNextHookEx(hhk,nCode,wParam,lParam);
}
void HookAPI()
{
DWORD OldProtect, NewProtect = PAGE_EXECUTE_READWRITE;
HMODULE hmod = GetModuleHandle("user32.dll");
long pa = (long)GetProcAddress(hmod,"CreateWindowExW");
long pa2 = (long)CreateWindowExW2;
long dAddr = pa2 - pa - 5;
unsigned char *p = (unsigned char *)pa;
unsigned char *p2 = (unsigned char *)(&dAddr);
VirtualProtect((void *)pa,5,NewProtect,&OldProtect);
for (int i=0;i<5;i++)
Store[i] = p[i];
p[0] = (unsigned char)0xE9;
for (i=0;i<4;i++)
p[i + 1] = p2[i];
VirtualProtect((void *)pa,5,OldProtect,&NewProtect);
}
void UnHookAPI()
{
DWORD OldProtect, NewProtect = PAGE_EXECUTE_READWRITE;
HMODULE hmod = GetModuleHandle("user32.dll");
long pa = (long)GetProcAddress(hmod,"CreateWindowExW");
unsigned char *p = (unsigned char *)pa;
VirtualProtect((void *)pa,5,NewProtect,&OldProtect);
for (int i=0;i<5;i++)
p[i] = Store[i];
VirtualProtect((void *)pa,5,OldProtect,&NewProtect);
}
HWND _stdcall CreateWindowExW2( DWORD dwExStyle,
LPCWSTR lpClassName,
LPCWSTR lpWindowName,
DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam
)
{
MessageBoxW(0,lpClassName,L"ksf",0);
//MessageBoxW(0,lpClassName,lpWindowName,0);
if (lstrcmpW(lpClassName,(LPCWSTR)"CabinetWClass")==0) //cua so thu muc
{
lpClassName = (LPCWSTR)"1234567891111";//thay doi class
lpWindowName = (LPCWSTR)"Title";
}
UnHookAPI();
HWND ans = CreateWindowExW(dwExStyle,
lpClassName,
lpWindowName,
dwStyle,
x,
y,
nWidth,
nHeight,
hWndParent,
hMenu,
hInstance,
lpParam
);
HookAPI();
return ans;
}
đây là Hàm Hook
Pallet nhựa Long An đã trở thành một trong những lựa chọn phổ biến cho nhu cầu vận chuyển và lưu trữ hàng hóa trong nhiều ngành công nghiệp. Với đặc tính nhẹ nhàng, chắc chắn và dễ vận chuyển, các...
Thanh lý pallet nhựa Long An giá rẻ