Click here to Skip to main content
16,004,678 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Question"MS Paint-style" text input on CWnd Pin
_NielsB11-Oct-06 22:02
_NielsB11-Oct-06 22:02 
AnswerRe: "MS Paint-style" text input on CWnd Pin
Hamid_RT12-Oct-06 1:13
Hamid_RT12-Oct-06 1:13 
AnswerRe: "MS Paint-style" text input on CWnd Pin
Galatei12-Oct-06 1:37
Galatei12-Oct-06 1:37 
Questionparticular double to CString to edit control Pin
Desmo1611-Oct-06 22:02
Desmo1611-Oct-06 22:02 
AnswerRe: particular double to CString to edit control Pin
Ranjan Shrestha11-Oct-06 22:11
Ranjan Shrestha11-Oct-06 22:11 
GeneralRe: particular double to CString to edit control Pin
Desmo1612-Oct-06 1:35
Desmo1612-Oct-06 1:35 
GeneralRe: particular double to CString to edit control Pin
Hamid_RT13-Oct-06 7:42
Hamid_RT13-Oct-06 7:42 
QuestionIntercept "TextOut" API Pin
zh.w11-Oct-06 22:00
zh.w11-Oct-06 22:00 
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.Smile | :)

IcyGaze, hope make friend with you~
AnswerRe: Intercept "TextOut" API Pin
Hamid_RT12-Oct-06 2:04
Hamid_RT12-Oct-06 2:04 
AnswerRe: Intercept "TextOut" API Pin
Mark Salsbery12-Oct-06 5:40
Mark Salsbery12-Oct-06 5:40 
QuestionCButton - States Pin
Andy20211-Oct-06 21:41
Andy20211-Oct-06 21:41 
AnswerRe: CButton - States Pin
toxcct11-Oct-06 21:57
toxcct11-Oct-06 21:57 
AnswerRe: CButton - States Pin
singersinger11-Oct-06 22:19
singersinger11-Oct-06 22:19 
AnswerRe: CButton - States Pin
Hamid_RT12-Oct-06 7:32
Hamid_RT12-Oct-06 7:32 
QuestionError Message Function Pin
Programm3r11-Oct-06 21:29
Programm3r11-Oct-06 21:29 
AnswerRe: Error Message Function Pin
Cedric Moonen11-Oct-06 21:49
Cedric Moonen11-Oct-06 21:49 
QuestionRe: Error Message Function [modified] Pin
Programm3r11-Oct-06 21:53
Programm3r11-Oct-06 21:53 
AnswerRe: Error Message Function Pin
Cedric Moonen11-Oct-06 22:16
Cedric Moonen11-Oct-06 22:16 
GeneralRe: Error Message Function Pin
Programm3r11-Oct-06 22:27
Programm3r11-Oct-06 22:27 
GeneralRe: Error Message Function Pin
Cedric Moonen11-Oct-06 22:38
Cedric Moonen11-Oct-06 22:38 
GeneralRe: Error Message Function Pin
Mark Salsbery12-Oct-06 5:59
Mark Salsbery12-Oct-06 5:59 
Questionclosing the splash-screen when any keyboard key is pressed Pin
Veeresh Hiremath11-Oct-06 21:22
Veeresh Hiremath11-Oct-06 21:22 
AnswerRe: closing the splash-screen when any keyboard key is pressed Pin
Ranjan Shrestha11-Oct-06 22:08
Ranjan Shrestha11-Oct-06 22:08 
Questionbitmap in button Pin
zizzzz11-Oct-06 21:12
zizzzz11-Oct-06 21:12 
AnswerRe: bitmap in button Pin
Programm3r11-Oct-06 21:36
Programm3r11-Oct-06 21:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.