Code Injection

MedRamBO

Mitglied
Hi leute,

ich versuche hier etwas in einen Prozess zu injekten. Alles ganz ok. Ich warte erst bis der Prozess da ist. Dann läuft ne Sleep time runter. Dann wird injekted. Nun hab ich probiert das in so fern zu ändern, dass die Sleeptime erst runter zählt wenn der Prozess auch wirklich das Aktive Fenster ist. Das scheint allerdings Probleme zu bereiten, da die while Schleife nie verlassen wird. Hat jemand eine Idee?

Code:
// Code Injection
DWORD WINAPI Injection( LPVOID lpParam )
{
	while( 1 )
	{
		HANDLE ProcessSnapshot;

		ProcessSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
		ProcessEntry.dwSize = sizeof( PROCESSENTRY32 );
		Process32First( ProcessSnapshot, &ProcessEntry );

		while( Process32Next( ProcessSnapshot, &ProcessEntry ) )
		{
			if( strcmp( ProcessEntry.szExeFile, Globals.SelectedGame.GetString() ) == 0 ) //SelectedGame hält "BF2"
			{
				while( !strstr( ActiveWindowName, Globals.WindowName.GetString() ) )
				{
					GetWindowText( GetActiveWindow(), ActiveWindowName, sizeof( ActiveWindowName ) );
					Sleep(50);
				}

				Sleep( Globals.SleepTime );

				CString Transfer_Data( StreamerPath );

				INJECTINFO Info;
				ZeroMemory(&Info,sizeof(INJECTINFO));
				Info.SourceType = SOURCE_MEMORY;
				Info.DLLSize = Lenght;
				Info.Target = (char*)Globals.SelectedGame.GetString();
				Info.Options = INJECT_RANDOMHEAD | INJECT_RANDOMTAIL | INJECT_DESTROYHEADERS | INJECT_RANDOMPOSITION;
				Info.Memory = FileBuffer;
				Info.TargetType = TARGET_PROCESS;

				Info.RandomMax = 1024 * 5; //Add at most 5k to Head,Tail or both

				StealthInject(&Info,NULL,Transfer_Data.GetBuffer(),Transfer_Data.GetLength() + 1);

				ExitProcess( 0 );
			}
			Sleep( 50 );
		}
		Sleep( 100 );
	}
	return 0;
}
 
Zuletzt bearbeitet:
Keiner ne Idee? :confused: Hehe

Es geht halt hauptsächlich um diesen Auszug:
Code:
while( !strstr( ActiveWindowName, Globals.WindowName.GetString() ) )
{
	GetWindowText( GetActiveWindow(), ActiveWindowName, sizeof( ActiveWindowName ) );
	Sleep(50);
}
 
Zurück