Exemple #1
0
void applyFPSPatch() {
	enableGFWLCompatibility();

	// Get imageBase
	HANDLE exeHandle = NULL;
	originalBase = 0x0400000;
	exeHandle = GetModuleHandle(NULL);

	if(exeHandle != NULL)
		imageBase = (DWORD)exeHandle;

	// Patches
	//--------------------------------------------------------------
	DWORD address;
	DWORD data;

	// Override D3D Presentation Interval
	address = convertAddress(0x010275AE); 
	data = 5; //Set to immediate
	writeToAddress(&data, address, sizeof(data));

	// Detour Render loop entry
	address = convertAddress(0x00BD6000);
	DetourApply((BYTE*)address, (BYTE*)renderLoopEntry, 6, 0);
		
	SDLOG(0, "FPS rate unlocked\n");
}
Exemple #2
0
//----------------------------------------------------------------------------------------
// Game Patches
//----------------------------------------------------------------------------------------
void applyFPSPatch() {
	enableGFWLCompatibility();

	// Get imageBase
	HANDLE exeHandle = NULL;
	originalBase = 0x0400000;
	exeHandle = GetModuleHandle(NULL);

	if(exeHandle != NULL)
		imageBase = (DWORD)exeHandle;

	// Init counter for frame-rate calculations
	lastRenderTime = 0.0f;
	QueryPerformanceFrequency(&timerFreq);
	QueryPerformanceCounter(&counterAtStart);

	// Binary patches
	//--------------------------------------------------------------
	DWORD address;
	DWORD data;

	// Override D3D Presentation Interval
	address = convertAddress(ADDR_PRESINT);
	data = 5; //Set to immediate
	writeToAddress(&data, address, sizeof(data));

	// Detour call to getDrawThreadMsgCommand
	address = convertAddress(ADDR_GETCMD);
	DetourApply((BYTE*)address, (BYTE*)getDrawThreadMsgCommand, 5, CALLOP);
		
	SDLOG(0, "FPS rate unlocked\n");
}
Exemple #3
0
//----------------------------------------------------------------------------------------
// Game Patches
//----------------------------------------------------------------------------------------
void applyFPSPatch() {

	SDLOG(0, "Starting FPS unlock...\n");
#ifndef WITHOUT_GFWL_LIB
	SDLOG(0, "Applying GFWL compatibility\n");
	enableGFWLCompatibility();
#endif

	// Get image info
	MODULEINFO moduleInfo;
	PIMAGE_DOS_HEADER dosHeader;
	PIMAGE_NT_HEADERS ntHeader;
    IMAGE_FILE_HEADER header;

	if(GetModuleInformation(GetCurrentProcess(), GetModuleHandle(NULL), &moduleInfo, sizeof(moduleInfo)))
	{
		ImageBase = (DWORD)moduleInfo.lpBaseOfDll;
		SDLOG(0, "ImageBase at 0x%08X\n", ImageBase);

		dosHeader = (PIMAGE_DOS_HEADER)ImageBase;
		ntHeader = (PIMAGE_NT_HEADERS)((DWORD)(dosHeader) + (dosHeader->e_lfanew));
		header = ntHeader->FileHeader;
		DWORD TimeStamp = header.TimeDateStamp;
				SDLOG(0, "Executable timestamp: 0x%08X, config: 0x%08X\n", TimeStamp, EXE_TIMESTAMP);

		// Perform pattern matching if timestamp differs
		if (TimeStamp != EXE_TIMESTAMP) {
			SDLOG(0, "Trying pattern matching...\n");

			DWORD address;
			address = GetMemoryAddressFromPattern(NULL, TS_PATTERN, TS_OFFSET);
			if(address != NULL) {
				SDLOG(0, "ADDR_TS found at 0x%08X\n", address);
				ADDR_TS = address;
			}
			else {
				SDLOG(0, "Could not match ADDR_TS pattern, FPS not unlocked\n");
				return;
			}
			address = GetMemoryAddressFromPattern(NULL, PRESINT_PATTERN, PRESINT_OFFSET);
			if(address != NULL) {
				SDLOG(0, "ADDR_PRESINT found at 0x%08X\n", address);
				ADDR_PRESINT = address;
			}
			else {
				SDLOG(0, "Could not match ADDR_PRESINT pattern, FPS not unlocked\n");
				return;
			}
			address = GetMemoryAddressFromPattern(NULL, GETCMD_PATTERN, GETCMD_OFFSET);
			if(address != NULL) {
				SDLOG(0, "ADDR_GETCMD found at 0x%08X\n", address);
				ADDR_GETCMD = address;
			}
			else {
				SDLOG(0, "Could not match ADDR_GETCMD pattern, FPS not unlocked\n");
				return;
			}
			SDLOG(0, "Pattern matching successful\n");
		}
		else
			SDLOG(0, "Using configured addresses\n");
	}
	else
	{
		SDLOG(0, "GetModuleInformation failed, FPS not unlocked\n");
		return;
	}

	// Init counter for frame-rate calculations
	lastRenderTime = 0.0f;
	QueryPerformanceFrequency(&timerFreq);
	QueryPerformanceCounter(&counterAtStart);

	// Binary patches
	//--------------------------------------------------------------
	DWORD address;
	DWORD data;

	// Override D3D Presentation Interval
	address = convertAddress(ADDR_PRESINT);
	data = 5; //Set to immediate
	writeToAddress(&data, address, sizeof(data));

	// Detour call to getDrawThreadMsgCommand
	address = convertAddress(ADDR_GETCMD);
	DetourApply((BYTE*)address, (BYTE*)getDrawThreadMsgCommand, 5, CALLOP);
		
	SDLOG(0, "FPS unlocked\n");
}