如何获取当前鼠标上的字符串内容?高分送? 在一个CView为基类的界面上,显示数行字符串,我需要获取在鼠标上当前一行字符串的内容,如何实现?谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 #include <windows.h>#include <STDIO.H>HHOOK hMouseHook;LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);static char fname[64],modulename[64],trash[640];static BOOL BeenHooked=FALSE;BOOL flag=FALSE;DWORD SysFunc1,SysFunc2,SysFunc3,SysFunc4;DWORD MyFunc1,MyFunc2,MyFunc3,MyFunc4;BOOL ChangeFuncEntry(HANDLE,int);BOOL IsSysDll(char *name);void SendText(HDC hdc,LPCSTR lpszString,UINT cbString);//list all moduleschar modules[100][16];static int index=0;static RECT rect;BOOL APIENTRY DllMain(HANDLE hModule,DWORD reason,LPVOID lpReserved){ switch( reason ) { case DLL_PROCESS_ATTACH: GetModuleFileName(GetModuleHandle(NULL),modulename,64); CharLower(modulename); //MessageBox(NULL,modulename,"inject into process",MB_OK); //wsprintf(trash,"%ld %ld\n%ld %ld\n%ld %ld\n%ld %ld",SysFunc1,MyFunc1,SysFunc2,MyFunc2,SysFunc3,MyFunc3,SysFunc4,MyFunc4); //MessageBox(NULL,"",trash,MB_OK); /*if(strcmp(modulename,"notepad.exe")) flag=TRUE; MessageBox(NULL,modulename,"inject into process",MB_OK);*/ break; case DLL_PROCESS_DETACH: break; } return TRUE;}BOOL InstallMouseHook() { hMouseHook =SetWindowsHookEx(WH_MOUSE,(HOOKPROC)MouseProc,GetModuleHandle("hookdll.dll"),0);//GetCurrentThreadId()); if ( hMouseHook == NULL) return FALSE; return TRUE ;}BOOL UninstallMouseHook(){ UnhookWindowsHookEx(hMouseHook); return TRUE;}LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam){ LPMOUSEHOOKSTRUCT lpMouseHookStruct; HWND hwnd; POINT MousePoint; static POINT old; int i; char modulelist[1600]; DWORD base; MEMORY_BASIC_INFORMATION mbi;//"E:\Program Files\DevStudio\SharedIDE\bin\Msdev.exe"//"c:\\temp\\testhook\\debug\\testhook.exe" if (nCode < 0) // do not process the message return CallNextHookEx(hMouseHook, nCode, wParam, lParam); //if(strcmp(modulename,"c:\\notepad.exe")) // return CallNextHookEx(hMouseHook, nCode, wParam, lParam); base=0; while(VirtualQuery (base, &mbi, sizeof (mbi))>0) { if(mbi.Type==MEM_IMAGE) ChangeFuncEntry((DWORD)mbi.BaseAddress,1); base=(DWORD)mbi.BaseAddress+mbi.RegionSize; } //if(!BeenHooked) { /*BeenHooked=TRUE; ChangeFuncEntry(GetModuleHandle(NULL),1); ChangeFuncEntry(GetModuleHandle("imm32.dll"),1); ChangeFuncEntry(GetModuleHandle("comctl32.dll"),1); ChangeFuncEntry(GetModuleHandle("shell32.dll"),1); ChangeFuncEntry(GetModuleHandle("comdlg32.dll"),1); ChangeFuncEntry(GetModuleHandle("advapi32.dll"),1); ChangeFuncEntry(GetModuleHandle("rpcrt4.dll"),1); ChangeFuncEntry(GetModuleHandle("user32.dll"),1); ChangeFuncEntry(GetModuleHandle("kernel32.dll"),1); ChangeFuncEntry(GetModuleHandle("ntdll.dll"),1); ChangeFuncEntry(GetModuleHandle("msvcrt.dll"),1); //for msdev ChangeFuncEntry(GetModuleHandle("devshl.dll"),1); ChangeFuncEntry(GetModuleHandle("mfc42.dll"),1); ChangeFuncEntry(GetModuleHandle("oleaut32.dll"),1); ChangeFuncEntry(GetModuleHandle("lz32.dll"),1); ChangeFuncEntry(GetModuleHandle("version.dll"),1); ChangeFuncEntry(GetModuleHandle("ole32.dll"),1); */ /*UnChangeFuncEntry(GetModuleHandle(NULL)); UnChangeFuncEntry(GetModuleHandle("imm32.dll")); UnChangeFuncEntry(GetModuleHandle("comctl32.dll")); UnChangeFuncEntry(GetModuleHandle("shell32.dll")); UnChangeFuncEntry(GetModuleHandle("comdlg32.dll")); UnChangeFuncEntry(GetModuleHandle("advapi32.dll")); UnChangeFuncEntry(GetModuleHandle("rpcrt4.dll")); UnChangeFuncEntry(GetModuleHandle("user32.dll")); UnChangeFuncEntry(GetModuleHandle("kernel32.dll")); UnChangeFuncEntry(GetModuleHandle("ntdll.dll")); UnChangeFuncEntry(GetModuleHandle("msvcrt.dll")); //for msdev UnChangeFuncEntry(GetModuleHandle("devshl.dll")); UnChangeFuncEntry(GetModuleHandle("mfc42.dll")); UnChangeFuncEntry(GetModuleHandle("oleaut32.dll")); UnChangeFuncEntry(GetModuleHandle("lz32.dll")); UnChangeFuncEntry(GetModuleHandle("version.dll")); UnChangeFuncEntry(GetModuleHandle("ole32.dll")); */ } if ( wParam == WM_MOUSEMOVE ) { lpMouseHookStruct = (LPMOUSEHOOKSTRUCT)lParam; MousePoint=lpMouseHookStruct->pt; //if(old.x==MousePoint.x&&old.y==MousePoint.y) // return CallNextHookEx(hMouseHook, nCode, wParam, lParam); old.x=MousePoint.x; old.y=MousePoint.y; hwnd=WindowFromPoint(MousePoint); ScreenToClient(hwnd,&MousePoint); rect.left=MousePoint.x-100; rect.top=MousePoint.y-3; rect.right=MousePoint.x+100; rect.bottom=MousePoint.y+3; InvalidateRect(hwnd,&rect,FALSE); //InvalidateRect(hwnd,NULL,FALSE); } return CallNextHookEx(hMouseHook, nCode, wParam, lParam);} BOOL ChangeFuncEntry(HMODULE hmodule,int level){ PIMAGE_DOS_HEADER pDOSHeader; PIMAGE_NT_HEADERS pNTHeader; PIMAGE_IMPORT_DESCRIPTOR pImportDesc; BOOL bSuccess = FALSE; char buffer[1024],buffer1[1024]; static int times=0; //int i,j; BOOL you=FALSE; DWORD MyFunc1; DWORD dwProtect,temp; /*if(!strcmp(modulename,"c:\\notepad.exe")) { GetModuleFileName(hmodule,fname,64); wsprintf(buffer,"module is %s.level=%d",fname,level); MessageBox(NULL,buffer,"",MB_OK); }*/ /*get system functions and my functions' entry*/ SysFunc1=(DWORD)GetProcAddress(GetModuleHandle("gdi32.dll"),"TextOutA"); MyFunc1= (DWORD)GetProcAddress(GetModuleHandle("hookdll.dll"),"MyTextOutA"); SysFunc2=(DWORD)GetProcAddress(GetModuleHandle("gdi32.dll"),"TextOutW"); MyFunc2= (DWORD)GetProcAddress(GetModuleHandle("hookdll.dll"),"MyTextOutW"); SysFunc3=(DWORD)GetProcAddress(GetModuleHandle("gdi32.dll"),"ExtTextOutA"); MyFunc3= (DWORD)GetProcAddress(GetModuleHandle("hookdll.dll"),"MyExtTextOutA"); SysFunc4=(DWORD)GetProcAddress(GetModuleHandle("gdi32.dll"),"ExtTextOutW"); MyFunc4= (DWORD)GetProcAddress(GetModuleHandle("hookdll.dll"),"MyExtTextOutW"); pDOSHeader=(PIMAGE_DOS_HEADER)hmodule; wsprintf(buffer,"textoua are %ld %ld\n%ld %ld\n%ld %ld\n%ld %ld\n",SysFunc1,MyFunc1,SysFunc2,MyFunc2,SysFunc3,MyFunc3,SysFunc4,MyFunc4); //MessageBox(NULL,buffer,"",MB_OK); if (IsBadReadPtr(hmodule, sizeof(PIMAGE_NT_HEADERS))) return FALSE; if (pDOSHeader->e_magic != IMAGE_DOS_SIGNATURE) return FALSE; pNTHeader=(PIMAGE_NT_HEADERS)((DWORD)pDOSHeader+(DWORD)pDOSHeader->e_lfanew); if (pNTHeader->Signature != IMAGE_NT_SIGNATURE) return FALSE; pImportDesc = (PIMAGE_IMPORT_DESCRIPTOR)((DWORD)hmodule+(DWORD)pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress); if (pImportDesc == (PIMAGE_IMPORT_DESCRIPTOR)pNTHeader) return FALSE; while (pImportDesc->Name) { PIMAGE_THUNK_DATA pThunk; strcpy(buffer,(char*)((DWORD)hmodule+(DWORD)pImportDesc->Name)); CharLower(buffer); /*if(!strcmp(buffer,"kernel32.dll")|| //!strcmp(buffer,"user32.dll")|| !strcmp(buffer,"imm32.dll")|| //!strcmp(buffer,"comctl32.dll")|| //!strcmp(buffer,"comdlg32.dll")|| !strcmp(buffer,"ntdll.dll")|| !strcmp(buffer,"advapi32.dll")|| !strcmp(buffer,"hookdll.dll")) //MessageBox(NULL,buffer,"system dll",MB_OK); //return 0;*/ if(strcmp(buffer,"gdi32.dll")) { pImportDesc++; continue; } else //if(!strcmp(buffer,"gdi32.dll")) { //GetModuleFileName(hmodule,fname,64); //wsprintf(buffer,"find gdi32 in %s",fname); //wsprintf(buffer1,"level is %d",level); //MessageBox(NULL,buffer,buffer1,MB_OK); pThunk=(PIMAGE_THUNK_DATA)((DWORD)hmodule+(DWORD)pImportDesc->FirstThunk); while (pThunk->u1.Function) { if ((pThunk->u1.Function) == SysFunc1) { //MessageBox(NULL,fname,"textoua textoua textoua textoua textoua",MB_OK); if(!IsBadWritePtr((LPVOID)(&pThunk->u1.Function), sizeof(DWORD))) (pThunk->u1.Function)=MyFunc1; else { if(VirtualProtect((LPVOID)(&pThunk->u1.Function), sizeof(DWORD),PAGE_EXECUTE_READWRITE, &dwProtect)) { (pThunk->u1.Function)=MyFunc1; VirtualProtect((LPVOID)(&pThunk->u1.Function), sizeof(DWORD),dwProtect,&temp); } else MessageBox(NULL,fname,"textoua UNABLE UNABLE UNABLE UNABLE ",MB_OK); } } else if((pThunk->u1.Function) == SysFunc2) { //MessageBox(NULL,fname,"textouw textouw textouw textouw textouw",MB_OK); if(!IsBadWritePtr((LPVOID)(&pThunk->u1.Function), sizeof(DWORD))) (pThunk->u1.Function)=MyFunc2; else { if(VirtualProtect((LPVOID)(&pThunk->u1.Function), sizeof(DWORD),PAGE_EXECUTE_READWRITE, &dwProtect)) { (pThunk->u1.Function)=MyFunc2; VirtualProtect((LPVOID)(&pThunk->u1.Function), sizeof(DWORD),dwProtect,&temp); } else MessageBox(NULL,fname,"textou2 UNABLE UNABLE UNABLE UNABLE ",MB_OK); } } else if((pThunk->u1.Function) == SysFunc3) { //MessageBox(NULL,fname,"exttextoua exttextoua exttextoua exttextoua",MB_OK); if(!IsBadWritePtr((LPVOID)(&pThunk->u1.Function), sizeof(DWORD))) (pThunk->u1.Function)=MyFunc3; else { if(VirtualProtect((LPVOID)(&pThunk->u1.Function), sizeof(DWORD),PAGE_EXECUTE_READWRITE, &dwProtect)) { (pThunk->u1.Function)=MyFunc3; VirtualProtect((LPVOID)(&pThunk->u1.Function), sizeof(DWORD),dwProtect,&temp); } else MessageBox(NULL,fname,"exttextoua UNABLE UNABLE UNABLE UNABLE ",MB_OK); } } else if((pThunk->u1.Function) == SysFunc4) { //MessageBox(NULL,fname,"exttextouw exttextouw exttextouw exttextouw",MB_OK); if(!IsBadWritePtr((LPVOID)(&pThunk->u1.Function), sizeof(DWORD))) { (pThunk->u1.Function)=MyFunc4; VirtualProtect((LPVOID)(&pThunk->u1.Function), sizeof(DWORD),dwProtect,&temp); } else { if(VirtualProtect((LPVOID)(&pThunk->u1.Function), sizeof(DWORD),PAGE_EXECUTE_READWRITE, &dwProtect)) (pThunk->u1.Function)=MyFunc4; else MessageBox(NULL,fname,"exttextouw UNABLE UNABLE UNABLE UNABLE ",MB_OK); } } pThunk++; } return 1;//already found gdi32 } //else if(!strcmp(buffer,"imm32.dll")||!strcmp(buffer,"comctl32.dll")||!strcmp(buffer,"user32.dll")) // ChangeFuncEntry(GetModuleHandle(buffer),0); /*else { //if(recursive) ChangeFuncEntry(GetModuleHandle(buffer),level+1); }*/ pImportDesc++; } return bSuccess; } 呵呵,就和金山词霸一样的,hook api后发送重绘消息 屏幕取词,baidu一下类似试例麻袋装,呵呵丰收了 强制刷新屏幕上鼠标旁边的一个矩型,然后HOOK API,看看它重绘的时候,调用了哪些函数. GetCursor得到鼠标位置WindowFromPoint得到鼠标下面的窗口.GetWidnowText得到该窗口文字. EDIT派生问题 函数内(new)开辟内存空间报错! 请教如何在实时采集并显示的视频上画图 请教GetEnvironmentVariable的问题 请教:VC6.0 std::list 声明的对象 在VC2005的dll中操作无效/内存出错 求电子书? 如何在属性页保证按ok后不退出(检查冲突做出提示的情况下)?我在propertyPage里OnOk里作了屏蔽还是退出:( 《VC技术内幕》简单问题请教 拆分字段,在线给分! 请问如何编写winamp那样的贴图对话框? 用核心变成中的方法将DLL注入到explorer中,explorer就象死掉一样,怎么回事啊? MSComm问题
#include <STDIO.H>HHOOK hMouseHook;
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);
static char fname[64],modulename[64],trash[640];
static BOOL BeenHooked=FALSE;
BOOL flag=FALSE;
DWORD SysFunc1,SysFunc2,SysFunc3,SysFunc4;
DWORD MyFunc1,MyFunc2,MyFunc3,MyFunc4;BOOL ChangeFuncEntry(HANDLE,int);
BOOL IsSysDll(char *name);
void SendText(HDC hdc,LPCSTR lpszString,UINT cbString);
//list all modules
char modules[100][16];
static int index=0;
static RECT rect;BOOL APIENTRY DllMain(HANDLE hModule,DWORD reason,LPVOID lpReserved)
{
switch( reason )
{
case DLL_PROCESS_ATTACH:
GetModuleFileName(GetModuleHandle(NULL),modulename,64);
CharLower(modulename);
//MessageBox(NULL,modulename,"inject into process",MB_OK);
//wsprintf(trash,"%ld %ld\n%ld %ld\n%ld %ld\n%ld %ld",SysFunc1,MyFunc1,SysFunc2,MyFunc2,SysFunc3,MyFunc3,SysFunc4,MyFunc4);
//MessageBox(NULL,"",trash,MB_OK);
/*if(strcmp(modulename,"notepad.exe"))
flag=TRUE;
MessageBox(NULL,modulename,"inject into process",MB_OK);*/
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}BOOL InstallMouseHook()
{
hMouseHook =SetWindowsHookEx(WH_MOUSE,(HOOKPROC)MouseProc,GetModuleHandle("hookdll.dll"),0);//GetCurrentThreadId());
if ( hMouseHook == NULL)
return FALSE;
return TRUE ;
}
BOOL UninstallMouseHook()
{
UnhookWindowsHookEx(hMouseHook);
return TRUE;
}
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
LPMOUSEHOOKSTRUCT lpMouseHookStruct;
HWND hwnd;
POINT MousePoint;
static POINT old;
int i;
char modulelist[1600];
DWORD base;
MEMORY_BASIC_INFORMATION mbi;//"E:\Program Files\DevStudio\SharedIDE\bin\Msdev.exe"
//"c:\\temp\\testhook\\debug\\testhook.exe"
if (nCode < 0) // do not process the message
return CallNextHookEx(hMouseHook, nCode, wParam, lParam);
//if(strcmp(modulename,"c:\\notepad.exe"))
// return CallNextHookEx(hMouseHook, nCode, wParam, lParam); base=0;
while(VirtualQuery (base, &mbi, sizeof (mbi))>0)
{
if(mbi.Type==MEM_IMAGE)
ChangeFuncEntry((DWORD)mbi.BaseAddress,1);
base=(DWORD)mbi.BaseAddress+mbi.RegionSize;
}
//if(!BeenHooked)
{
/*BeenHooked=TRUE;
ChangeFuncEntry(GetModuleHandle(NULL),1);
ChangeFuncEntry(GetModuleHandle("imm32.dll"),1);
ChangeFuncEntry(GetModuleHandle("comctl32.dll"),1);
ChangeFuncEntry(GetModuleHandle("shell32.dll"),1);
ChangeFuncEntry(GetModuleHandle("comdlg32.dll"),1);
ChangeFuncEntry(GetModuleHandle("advapi32.dll"),1);
ChangeFuncEntry(GetModuleHandle("rpcrt4.dll"),1);
ChangeFuncEntry(GetModuleHandle("user32.dll"),1);
ChangeFuncEntry(GetModuleHandle("kernel32.dll"),1);
ChangeFuncEntry(GetModuleHandle("ntdll.dll"),1);
ChangeFuncEntry(GetModuleHandle("msvcrt.dll"),1);
//for msdev
ChangeFuncEntry(GetModuleHandle("devshl.dll"),1);
ChangeFuncEntry(GetModuleHandle("mfc42.dll"),1);
ChangeFuncEntry(GetModuleHandle("oleaut32.dll"),1);
ChangeFuncEntry(GetModuleHandle("lz32.dll"),1);
ChangeFuncEntry(GetModuleHandle("version.dll"),1);
ChangeFuncEntry(GetModuleHandle("ole32.dll"),1);
*/
/*UnChangeFuncEntry(GetModuleHandle(NULL));
UnChangeFuncEntry(GetModuleHandle("imm32.dll"));
UnChangeFuncEntry(GetModuleHandle("comctl32.dll"));
UnChangeFuncEntry(GetModuleHandle("shell32.dll"));
UnChangeFuncEntry(GetModuleHandle("comdlg32.dll"));
UnChangeFuncEntry(GetModuleHandle("advapi32.dll"));
UnChangeFuncEntry(GetModuleHandle("rpcrt4.dll"));
UnChangeFuncEntry(GetModuleHandle("user32.dll"));
UnChangeFuncEntry(GetModuleHandle("kernel32.dll"));
UnChangeFuncEntry(GetModuleHandle("ntdll.dll"));
UnChangeFuncEntry(GetModuleHandle("msvcrt.dll"));
//for msdev
UnChangeFuncEntry(GetModuleHandle("devshl.dll"));
UnChangeFuncEntry(GetModuleHandle("mfc42.dll"));
UnChangeFuncEntry(GetModuleHandle("oleaut32.dll"));
UnChangeFuncEntry(GetModuleHandle("lz32.dll"));
UnChangeFuncEntry(GetModuleHandle("version.dll"));
UnChangeFuncEntry(GetModuleHandle("ole32.dll"));
*/
}
if ( wParam == WM_MOUSEMOVE ) {
lpMouseHookStruct = (LPMOUSEHOOKSTRUCT)lParam;
MousePoint=lpMouseHookStruct->pt;
//if(old.x==MousePoint.x&&old.y==MousePoint.y)
// return CallNextHookEx(hMouseHook, nCode, wParam, lParam);
old.x=MousePoint.x;
old.y=MousePoint.y; hwnd=WindowFromPoint(MousePoint);
ScreenToClient(hwnd,&MousePoint);
rect.left=MousePoint.x-100;
rect.top=MousePoint.y-3;
rect.right=MousePoint.x+100;
rect.bottom=MousePoint.y+3;
InvalidateRect(hwnd,&rect,FALSE);
//InvalidateRect(hwnd,NULL,FALSE);
}
return CallNextHookEx(hMouseHook, nCode, wParam, lParam);
}
BOOL ChangeFuncEntry(HMODULE hmodule,int level)
{
PIMAGE_DOS_HEADER pDOSHeader;
PIMAGE_NT_HEADERS pNTHeader;
PIMAGE_IMPORT_DESCRIPTOR pImportDesc;
BOOL bSuccess = FALSE;
char buffer[1024],buffer1[1024];
static int times=0;
//int i,j;
BOOL you=FALSE;
DWORD MyFunc1;
DWORD dwProtect,temp; /*if(!strcmp(modulename,"c:\\notepad.exe"))
{
GetModuleFileName(hmodule,fname,64);
wsprintf(buffer,"module is %s.level=%d",fname,level);
MessageBox(NULL,buffer,"",MB_OK);
}*/
/*get system functions and my functions' entry*/
SysFunc1=(DWORD)GetProcAddress(GetModuleHandle("gdi32.dll"),"TextOutA");
MyFunc1= (DWORD)GetProcAddress(GetModuleHandle("hookdll.dll"),"MyTextOutA");
SysFunc2=(DWORD)GetProcAddress(GetModuleHandle("gdi32.dll"),"TextOutW");
MyFunc2= (DWORD)GetProcAddress(GetModuleHandle("hookdll.dll"),"MyTextOutW");
SysFunc3=(DWORD)GetProcAddress(GetModuleHandle("gdi32.dll"),"ExtTextOutA");
MyFunc3= (DWORD)GetProcAddress(GetModuleHandle("hookdll.dll"),"MyExtTextOutA");
SysFunc4=(DWORD)GetProcAddress(GetModuleHandle("gdi32.dll"),"ExtTextOutW");
MyFunc4= (DWORD)GetProcAddress(GetModuleHandle("hookdll.dll"),"MyExtTextOutW");
pDOSHeader=(PIMAGE_DOS_HEADER)hmodule;
wsprintf(buffer,"textoua are %ld %ld\n%ld %ld\n%ld %ld\n%ld %ld\n",SysFunc1,MyFunc1,SysFunc2,MyFunc2,SysFunc3,MyFunc3,SysFunc4,MyFunc4);
//MessageBox(NULL,buffer,"",MB_OK);
if (IsBadReadPtr(hmodule, sizeof(PIMAGE_NT_HEADERS)))
return FALSE;
if (pDOSHeader->e_magic != IMAGE_DOS_SIGNATURE)
return FALSE;
pNTHeader=(PIMAGE_NT_HEADERS)((DWORD)pDOSHeader+(DWORD)pDOSHeader->e_lfanew);
if (pNTHeader->Signature != IMAGE_NT_SIGNATURE)
return FALSE;
pImportDesc = (PIMAGE_IMPORT_DESCRIPTOR)((DWORD)hmodule+(DWORD)pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
if (pImportDesc == (PIMAGE_IMPORT_DESCRIPTOR)pNTHeader)
return FALSE;
while (pImportDesc->Name)
{
PIMAGE_THUNK_DATA pThunk;
strcpy(buffer,(char*)((DWORD)hmodule+(DWORD)pImportDesc->Name));
CharLower(buffer); /*if(!strcmp(buffer,"kernel32.dll")||
//!strcmp(buffer,"user32.dll")||
!strcmp(buffer,"imm32.dll")||
//!strcmp(buffer,"comctl32.dll")||
//!strcmp(buffer,"comdlg32.dll")||
!strcmp(buffer,"ntdll.dll")||
!strcmp(buffer,"advapi32.dll")||
!strcmp(buffer,"hookdll.dll"))
//MessageBox(NULL,buffer,"system dll",MB_OK);
//return 0;*/
if(strcmp(buffer,"gdi32.dll"))
{
pImportDesc++;
continue;
}
else //if(!strcmp(buffer,"gdi32.dll"))
{
//GetModuleFileName(hmodule,fname,64);
//wsprintf(buffer,"find gdi32 in %s",fname);
//wsprintf(buffer1,"level is %d",level);
//MessageBox(NULL,buffer,buffer1,MB_OK);
pThunk=(PIMAGE_THUNK_DATA)((DWORD)hmodule+(DWORD)pImportDesc->FirstThunk);
while (pThunk->u1.Function)
{
if ((pThunk->u1.Function) == SysFunc1)
{
//MessageBox(NULL,fname,"textoua textoua textoua textoua textoua",MB_OK);
if(!IsBadWritePtr((LPVOID)(&pThunk->u1.Function), sizeof(DWORD)))
(pThunk->u1.Function)=MyFunc1;
else
{
if(VirtualProtect((LPVOID)(&pThunk->u1.Function), sizeof(DWORD),PAGE_EXECUTE_READWRITE, &dwProtect))
{
(pThunk->u1.Function)=MyFunc1;
VirtualProtect((LPVOID)(&pThunk->u1.Function), sizeof(DWORD),dwProtect,&temp);
}
else
MessageBox(NULL,fname,"textoua UNABLE UNABLE UNABLE UNABLE ",MB_OK);
}
}
else if((pThunk->u1.Function) == SysFunc2)
{
//MessageBox(NULL,fname,"textouw textouw textouw textouw textouw",MB_OK);
if(!IsBadWritePtr((LPVOID)(&pThunk->u1.Function), sizeof(DWORD)))
(pThunk->u1.Function)=MyFunc2;
else
{
if(VirtualProtect((LPVOID)(&pThunk->u1.Function), sizeof(DWORD),PAGE_EXECUTE_READWRITE, &dwProtect))
{
(pThunk->u1.Function)=MyFunc2;
VirtualProtect((LPVOID)(&pThunk->u1.Function), sizeof(DWORD),dwProtect,&temp);
} else
MessageBox(NULL,fname,"textou2 UNABLE UNABLE UNABLE UNABLE ",MB_OK);
}
}
else if((pThunk->u1.Function) == SysFunc3)
{
//MessageBox(NULL,fname,"exttextoua exttextoua exttextoua exttextoua",MB_OK);
if(!IsBadWritePtr((LPVOID)(&pThunk->u1.Function), sizeof(DWORD)))
(pThunk->u1.Function)=MyFunc3;
else
{
if(VirtualProtect((LPVOID)(&pThunk->u1.Function), sizeof(DWORD),PAGE_EXECUTE_READWRITE, &dwProtect))
{
(pThunk->u1.Function)=MyFunc3;
VirtualProtect((LPVOID)(&pThunk->u1.Function), sizeof(DWORD),dwProtect,&temp);
} else
MessageBox(NULL,fname,"exttextoua UNABLE UNABLE UNABLE UNABLE ",MB_OK);
}
}
else if((pThunk->u1.Function) == SysFunc4)
{
//MessageBox(NULL,fname,"exttextouw exttextouw exttextouw exttextouw",MB_OK);
if(!IsBadWritePtr((LPVOID)(&pThunk->u1.Function), sizeof(DWORD)))
{
(pThunk->u1.Function)=MyFunc4;
VirtualProtect((LPVOID)(&pThunk->u1.Function), sizeof(DWORD),dwProtect,&temp);
}
else
{
if(VirtualProtect((LPVOID)(&pThunk->u1.Function), sizeof(DWORD),PAGE_EXECUTE_READWRITE, &dwProtect))
(pThunk->u1.Function)=MyFunc4;
else
MessageBox(NULL,fname,"exttextouw UNABLE UNABLE UNABLE UNABLE ",MB_OK);
}
}
pThunk++;
}
return 1;//already found gdi32
}
//else if(!strcmp(buffer,"imm32.dll")||!strcmp(buffer,"comctl32.dll")||!strcmp(buffer,"user32.dll"))
// ChangeFuncEntry(GetModuleHandle(buffer),0);
/*else
{
//if(recursive)
ChangeFuncEntry(GetModuleHandle(buffer),level+1);
}*/
pImportDesc++;
}
return bSuccess;
}
WindowFromPoint得到鼠标下面的窗口.
GetWidnowText得到该窗口文字.