iPromise Grandmaster Cheater
Reputation: -1
Joined: 27 Jun 2009 Posts: 529 Location: Canada
|
Posted: Fri May 13, 2011 3:56 pm Post subject: Failed to initialize function inside target virtual memory |
|
|
Hey guys,
I know i've been asking for a lot of help these days, i'm sorry if i'm annoying you all.
I'm trying to initialize my own function which creates a message box inside my target memories address space. I'm using CreateRemoteThread to do the job, and for some reason, no matter how much I tried to fix it or diagnose the problem, it won't work? Please help, am I doing anything incorrect for it to not initialize the function correctly?
| Code: |
#include <Windows.h>
#include <TlHelp32.h>
#include <iostream>
using namespace std;
// Testing Purposes
#define THREAD PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ
DWORD getProcessID ( string processName )
{
while ( true )
{
PROCESSENTRY32 PE;
PE.dwSize = sizeof ( PROCESSENTRY32 );
HANDLE hSnapshot = CreateToolhelp32Snapshot ( TH32CS_SNAPALL, 0 );
if ( Process32First ( hSnapshot, &PE ) )
{
while ( Process32Next ( hSnapshot, &PE) )
{
if ( !strcmp ( PE.szExeFile, processName.c_str () ) )
{
return PE.th32ProcessID;
}
}
}
Sleep ( 100 );
}
return 0;
}
HANDLE getHandle ( DWORD dwProcessID )
{
return OpenProcess ( THREAD, false, dwProcessID );
}
DWORD WINAPI ThreadProc ( LPVOID lpParameter )
{
MessageBoxA ( 0, "remote thread", 0, 0 );
return 0;
}
int main ()
{
// Get ProcessID
DWORD dwProcessID = ::getProcessID ( "tutorial.exe" );
// Begin the injection
if ( dwProcessID )
{
HANDLE hHandle = ::getHandle ( dwProcessID );
if ( hHandle )
{
HANDLE hThread = ::CreateRemoteThread ( hHandle, NULL, 0, (LPTHREAD_START_ROUTINE) &ThreadProc, NULL, 0, NULL );
if ( hThread )
{
cout << "Reached this point." << endl;
}
else
{
cout << "Failed to reach this point." << endl;
}
}
else
{
cout << "Failed to open handle." << endl;
}
}
else
{
cout << "Failed to get correct process id." << endl;
}
// Fin.
cin.get ();
return EXIT_SUCCESS;
}
|
|
|