Hi all! Look. typedef (WINAPI *TextOutAType)(HDC,int,int,LPCSTR,int); TextOutAType oldTextOutAaddr=0; //here is ourself function BOOL WINAPI MyTextOutA(HDC hdc, int nXStart, int nYStart, LPCSTR string, int cbString) { MessageBox(0,string,"aha",0); return oldTextOutAaddr(hdc,nXStart,nYStart,string,cbString); } BOOL HookApiTextOutA(const HMODULE hModule) { IMAGE_DOS_HEADER *pdos; IMAGE_NT_HEADERS *pnt; IMAGE_DATA_DIRECTORY *pSymbolTable; IMAGE_IMPORT_DESCRIPTOR *pimport; pdos=(IMAGE_DOS_HEADER*)hModule; pnt=(IMAGE_NT_HEADERS*)((DWORD)pdos + pdos->e_lfanew); pSymbolTable=&pnt->OptionalHeader.DataDirectory[1]; pimport=(IMAGE_IMPORT_DESCRIPTOR*)((DWORD)pdos + pSymbolTable->VirtualAddress); while(pimport->FirstThunk){ IMAGE_THUNK_DATA *pold,*pnew; pold = (IMAGE_THUNK_DATA*)((DWORD)pdos + pimport->OriginalFirstThunk); pnew = (IMAGE_THUNK_DATA*)((DWORD)pdos + pimport->FirstThunk); while(pold->u1.Function){ if(IMAGE_ORDINAL_FLAG != (pold->u1.Ordinal & IMAGE_ORDINAL_FLAG)) { IMAGE_IMPORT_BY_NAME *pname; pname = (IMAGE_IMPORT_BY_NAME*)((DWORD)pdos + *((DWORD*)pold)); PROC *ppfn=(PROC*)(pnew->u1.Function); if(strcmp("TextOutA",(char*)pname->Name)==0) { oldTextOutAaddr=(TextOutAType)(ppfn); //here is system API "TextOutA" address DWORD addr=(DWORD)MyTextOutA; DWORD written=0; DWORD oldProtect=NULL; VirtualProtect(&pnew->u1.Function,sizeof(DWORD),PAGE_WRITECOPY,&oldProtect); WriteProcessMemory(GetCurrentProcess(),&pnew->u1.Function, &addr,sizeof(DWORD), &written); } } pold++; pnew++; } pimport++; } return TRUE; } Now,when we use TextOutA,it's using "MyTextOutA" first in fact. TO: Mark Salsbery,this isn't a joke.:) IcyGaze, hope make friend with you~
zh w
Posts
-
Intercept "TextOut" API -
How I can learn my english嘿嘿~ 首先感谢各位的 Reply.有你们的帮助下,我想我的英语会进步很快! Last, nice to meet you~
-
How I can learn my englishwhat do you mean?!:confused: -- modified at 3:44 Wednesday 11th October, 2006
-
how can get words form screenthanks all the same. intercept API can help us do more useful things. get words from windows screen just only a little section...
-
how can get words form screenfirst intercept "TextOut", second replacing it,use our function "MyTextOut" : MyTextOut(int nXStart, int nYStart, LPCSTR lpszString,int cbString) { //do anything //here is "TextOut" to do } !when we use the "TextOut",it run "MyTextOut" first in fact. -- modified at 3:41 Wednesday 11th October, 2006
-
how can get words form screenHookApi,example "TextOutA",but how do it.
-
How I can learn my englishthanks! I need moer information for Visual C++,so I get here. Sorry,the syntax may be is error.
-
How I can learn my englishMy engliah is very poor,so I hope someone can help me. ......
-
Pay me to learn:) hello everyone~