my code:
...
DWORD WINAPI myGWTHPID(HWND hWnd, LPDWORD lpdwProcessId){
__asm
{
MOV EDI,EDI
PUSH EBP
MOV EBP,ESP
JMP [DLLFunc]
}
}
int main(){
hInst = LoadLibraryA("user32.dll");
DLLFunc = (DWORD)GetProcAddress(hInst, "GetWindowThreadProcessId" + 5);
HWND hwn= FindWindowA(NULL,"Untitled - Notepad");
cout<<"Window handle: "<<hwn<<"\n";
DWORD pID;
myGWTHPID(hwn,&pID);
cout<<"Process id: "<<pID;
getch();
return 0;
}
The problem seems to be with "myGWTHPID" function, it generates the following error:
Unhandled exception at 0x00000000 in test.exe: 0xC0000005: Access violation.
I'm guessing it's messing with the registers but I have no idea how to fix it.
Please help :$