예제 #1
0
void InstallHooks()
{
	// notice the memory allocted here gets never freed o_O
	if(!detoured_GetSoundtime) detoured_GetSoundtime = (GetSoundtime_t) DetourApply((BYTE *)HL_ADDR_GET(GetSoundtime), (BYTE *)touring_GetSoundtime, (int)HL_ADDR_GET(DTOURSZ_GetSoundtime));
	if(!detoured_S_PaintChannels) detoured_S_PaintChannels = (S_PaintChannels_t) DetourApply((BYTE *)HL_ADDR_GET(S_PaintChannels), (BYTE *)touring_S_PaintChannels, (int)HL_ADDR_GET(DTOURSZ_S_PaintChannels));
	if(!detoured_S_TransferPaintBuffer) detoured_S_TransferPaintBuffer = (S_TransferPaintBuffer_t) DetourApply((BYTE *)HL_ADDR_GET(S_TransferPaintBuffer), (BYTE *)touring_S_TransferPaintBuffer, (int)HL_ADDR_GET(DTOURSZ_S_TransferPaintBuffer));
	if(!detoured_SND_PickChannel) detoured_SND_PickChannel = (SND_PickChannel_t)DetourApply((BYTE *)HL_ADDR_GET(SND_PickChannel), (BYTE *)touring_SND_PickChannel, (int)HL_ADDR_GET(DTOURSZ_SND_PickChannel));
}
예제 #2
0
void Hook_R_DrawSkyBoxEx()
{
	if( !g_Old_R_DrawSkyBoxEx && 0 != HL_ADDR_GET(R_DrawSkyBoxEx) )
	{
		g_Old_R_DrawSkyBoxEx = (R_DrawSkyBoxEx_t) DetourApply((BYTE *)HL_ADDR_GET(R_DrawSkyBoxEx), (BYTE *)New_R_DrawSkyBoxEx, (int)HL_ADDR_GET(R_DrawSkyBoxEx_DSZ));
	}
}
예제 #3
0
void Hook_CL_Disconnect()
{
	if( !g_Old_CL_Disconnect && 0 != HL_ADDR_GET(CL_Disconnect) )
	{
		g_Old_CL_Disconnect = (CL_Disconnect_t) DetourApply((BYTE *)HL_ADDR_GET(CL_Disconnect), (BYTE *)New_CL_Disconnect, (int)HL_ADDR_GET(CL_Disconnect_DSZ));
	}
}
예제 #4
0
파일: FPS.cpp 프로젝트: green-s/dsfix
//----------------------------------------------------------------------------------------
// 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");
}
예제 #5
0
파일: FPS.cpp 프로젝트: wT-/dsfix
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");
}
void Hook_R_DrawEntitiesOnList()
{
	if( !g_Old_R_DrawEntitiesOnList && 0 != HL_ADDR_GET(R_DrawEntitiesOnList) ) 
	{
		g_Old_R_DrawEntitiesOnList = (R_DrawEntitiesOnList_t) DetourApply((BYTE *)HL_ADDR_GET(R_DrawEntitiesOnList), (BYTE *)New_R_DrawEntitiesOnList, (int)HL_ADDR_GET(DTOURSZ_R_DrawEntitiesOnList));
	}
}
예제 #7
0
void Hook_Host_Frame()
{
	if( !g_Old_HostFrame && 0 != HL_ADDR_GET(Host_Frame) )
	{
		g_phost_frametime = (double *)HL_ADDR_GET(host_frametime);
		g_Old_HostFrame = (Host_Frame_t) DetourApply((BYTE *)HL_ADDR_GET(Host_Frame), (BYTE *)New_Host_Frame, (int)HL_ADDR_GET(Host_Frame_DSZ));
	}
}
예제 #8
0
bool csgo_CViewRender_Install(void)
{
	static bool firstResult = true;
	static bool firstRun = true;
	if(!firstRun) return firstResult;
	firstRun = false;

	if(AFXADDR_GET(csgo_CViewRender_RenderView_VGui_DrawHud_In) && AFXADDR_GET(csgo_CViewRender_RenderView_VGui_DrawHud_Out))
	{
		{
			detoured_csgo_CViewRender_RenderView_VGui_DrawHud_In = (void *)DetourApply((BYTE *)AFXADDR_GET(csgo_CViewRender_RenderView_VGui_DrawHud_In), (BYTE *)touring_csgo_CViewRender_RenderView_VGui_DrawHud_In, 0x5);

			// fix-up code relocation:
			DWORD * pCalladdr = (DWORD *)((BYTE *)detoured_csgo_CViewRender_RenderView_VGui_DrawHud_In + 0x1);
			*pCalladdr = *pCalladdr - ((DWORD)detoured_csgo_CViewRender_RenderView_VGui_DrawHud_In - AFXADDR_GET(csgo_CViewRender_RenderView_VGui_DrawHud_In));
		}
		{
			detoured_csgo_CViewRender_RenderView_VGui_DrawHud_Out = (void *)DetourApply((BYTE *)AFXADDR_GET(csgo_CViewRender_RenderView_VGui_DrawHud_Out), (BYTE *)touring_csgo_CViewRender_RenderView_VGui_DrawHud_Out, 0x5);
		}
	}
	else
		firstResult = false;

	if (AFXADDR_GET(csgo_CCSViewRender_vtable)
		&& AFXADDR_GET(csgo_CCSViewRender_RenderSmokeOverlay_OnLoadOldAlpha)
		&& AFXADDR_GET(csgo_CCSViewRender_RenderSmokeOverlay_OnCompareAlphaBeforeDraw))
	{
		int * vtable = (int*)AFXADDR_GET(csgo_CCSViewRender_vtable);

		//DetourIfacePtr((DWORD *)&(vtable[5]), touring_CCSViewRender_Render, (DetourIfacePtr_fn &)detoured_CCSViewRender_Render);
		DetourIfacePtr((DWORD *)&(vtable[6]), touring_CCSViewRender_RenderView, (DetourIfacePtr_fn &)detoured_CCSViewRender_RenderView);

		detoured_csgo_CViewRender_RenderSmokeOverlay_OnLoadOldAlpha = (void *)DetourApply((BYTE *)AFXADDR_GET(csgo_CCSViewRender_RenderSmokeOverlay_OnLoadOldAlpha), (BYTE *)touring_csgo_CViewRender_RenderSmokeOverlay_OnLoadOldAlpha, 8);	
		detoured_csgo_CViewRender_RenderSmokeOverlay_OnCompareAlphaBeforeDraw = (void *)DetourApply((BYTE *)AFXADDR_GET(csgo_CCSViewRender_RenderSmokeOverlay_OnCompareAlphaBeforeDraw), (BYTE *)touring_csgo_CViewRender_RenderSmokeOverlay_OnCompareAlphaBeforeDraw, 7);
	}
	else
		firstResult = false;

	return firstResult;
}
예제 #9
0
bool Hook_csgo_RecvProxy_Int32ToInt8(void)
{
	static bool firstResult = false;
	static bool firstRun = true;
	if (!firstRun) return firstResult;
	firstRun = false;

	if (AFXADDR_GET(csgo_RecvProxy_Int32ToInt8))
	{
		detoured_csgo_RecvProxy_Int32ToInt8 = (csgo_RecvProxy_Int32ToInt8_t)DetourApply((BYTE *)AFXADDR_GET(csgo_RecvProxy_Int32ToInt8), (BYTE *)touring_csgo_RecvProxy_Int32ToInt8, (int)0x06);

		firstResult = true;
	}

	return firstResult;
}
예제 #10
0
파일: FPS.cpp 프로젝트: Asmodean-/dsfix
//----------------------------------------------------------------------------------------
// 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");
}
예제 #11
0
void Hook_R_PolyBlend()
{
	if (!g_Old_R_PolyBlend && (HL_ADDR_GET(R_PolyBlend)!=NULL))
			g_Old_R_PolyBlend = (R_PolyBlend_t) DetourApply((BYTE *)HL_ADDR_GET(R_PolyBlend), (BYTE *)New_R_PolyBlend, (int)HL_ADDR_GET(DTOURSZ_R_PolyBlend));
}
예제 #12
0
void Hook_Mod_LeafPvs()
{
	if (!g_Old_Mod_LeafPVS && (HL_ADDR_GET(Mod_LeafPVS)!=NULL))
		g_Old_Mod_LeafPVS = (Mod_LeafPVS_t) DetourApply((BYTE *)HL_ADDR_GET(Mod_LeafPVS), (BYTE *)New_Mod_LeafPVS, (int)HL_ADDR_GET(DTOURSZ_Mod_LeafPVS));
}
예제 #13
0
bool Hook_csgo_C_BasePlayer_RecvProxy_ObserverTarget(void)
{
	static bool firstResult = false;
	static bool firstRun = true;
	if (!firstRun) return firstResult;
	firstRun = false;

	if (AFXADDR_GET(csgo_C_BasePlayer_RecvProxy_ObserverTarget))
	{
		detoured_csgo_C_BasePlayer_RecvProxy_ObserverTarget = (csgo_C_BasePlayer_RecvProxy_ObserverTarget_t)DetourApply((BYTE *)AFXADDR_GET(csgo_C_BasePlayer_RecvProxy_ObserverTarget), (BYTE *)touring_csgo_C_BasePlayer_RecvProxy_ObserverTarget, (int)0x06);

		firstResult = true;
	}

	return firstResult;
}