Ejemplo n.º 1
0
VOID LpThreadNotificationRoutine( PEX_THREAD_REGISTRATION pxThreadReg, PKTHREAD pThread, BOOL Creating )
{
	if( Creating && ( pThread->CreateOptions & 0x100 ) )
	{
		DbgPrint( "Xbox Kernel Version %d.%d.%d\n", XboxKrnlVersion->Major, XboxKrnlVersion->Minor, XboxKrnlVersion->Build );
		wprintf( L"Loaded game executable. Path = %s\n", ( *XexExecutableModuleHandle )->FullDllName.Buffer );

		DWORD dwGameTitleId = XamGetCurrentTitleId();

		if ( dwGameTitleId == NULL )
		{
			DbgPrint( "Unable to pull the games Title ID, patching aborted.\n" );
			return;
		}

		for( int i = 0; i < DRIVESCOUNT; i++ )
		{
			MountPath( APPMOUNTAS, pszDrivesToCheck[ i ] );
			DbgPrint( "Mounted path \'%s\'\n", pszDrivesToCheck[ i ] );
			DbgPrint( "Checking for %08X.patch\n", dwGameTitleId );

			CHAR szFullPatchPath[ MAX_PATH ];
			sprintf_s( szFullPatchPath, MAX_PATH, "XGP:\\Patches\\%08X.patch", dwGameTitleId );

			HANDLE hFile = CreateFile( szFullPatchPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL );

			if ( hFile == INVALID_HANDLE_VALUE )
			{
				DbgPrint( "Unable to open file \'%s\' error %08X\n", szFullPatchPath, GetLastError() );
				continue;				
			}

			DWORD dwFileSize = GetFileSize( hFile, NULL );

			if ( dwFileSize <= 0  )
			{
				DbgPrint( "Bad file size. dwFileSize = %08X\n", dwFileSize );
				continue;
			}

			DbgPrint( "File size = %d bytes\n", dwFileSize );

			PBYTE pFileBuffer = new BYTE[ dwFileSize ];
			DWORD dwBytesRead = 0;
			ReadFile( hFile, pFileBuffer, dwFileSize, &dwBytesRead, NULL );

			DbgPrint( "Read %d byte\n", dwBytesRead );

			CloseHandle( hFile );

			DoPatches( pFileBuffer, dwFileSize );

			delete pFileBuffer;
//Unmount:
//			UnmountPath( APPMOUNTAS );
		}

		DbgPrint( "Everything is done!\n" );
	}
}
Ejemplo n.º 2
0
void GameCheck( void )
{
	// Setup Button Combo's
	//SetButtonCombinations();

	// Set up a label so we can jump back to this code if we leave the title id
Start:
	while (XamGetCurrentTitleId() != GAME_TITLE_ID) { Sleep(0); }
	DebugPrint("Game has been launched");

	// Poke initial bytes into the xex in Memory
	InitialXexSetup();

	// We have entered the game, do our update code
	while (XamGetCurrentTitleId() == GAME_TITLE_ID) { Update(); }

	// The loop broke, which means they aren't on the game anymore
	DebugPrint("Game has been exited");
	goto Start;
}