Example #1
0
void RSManager::reloadScao() {
	SAFEDELETE(ssao); 
	ssao = new SSAO(d3ddev, Settings::get().getRenderWidth(), Settings::get().getRenderHeight(), Settings::get().getSsaoStrength()-1, SSAO::SCAO);
	SDLOG(0, "Reloaded SSAO\n");
}
Example #2
0
GENERATE_INTERCEPT_HEADER(D3DXCreateTextureFromFileInMemory, HRESULT, WINAPI, _In_ LPDIRECT3DDEVICE9 pDevice, _In_ LPCVOID pSrcData, _In_ UINT SrcDataSize, _Out_ LPDIRECT3DTEXTURE9 *ppTexture) {
	SDLOG(4, "DetouredD3DXCreateTextureFromFileInMemory\n");
	HRESULT res = TrueD3DXCreateTextureFromFileInMemory(pDevice, pSrcData, SrcDataSize, ppTexture);
	if(RSManager::exists()) RSManager::getDX9().registerD3DXCreateTextureFromFileInMemory(pSrcData, (SrcDataSize == 2147483647u || SrcDataSize == 4294967295u) ? 256 : SrcDataSize, *ppTexture);
	return res;
}
Example #3
0
GENERATE_INTERCEPT_HEADER(GetDeviceCaps, int, WINAPI, _In_opt_ HDC hdc, _In_ int index) {
	SDLOG(1, "DetouredGetDeviceCaps %p %s\n", hdc, GetDeviceCapsParamToString(index));
	int ret = TrueGetDeviceCaps(hdc, index);
	return ret;
}
Example #4
0
GENERATE_INTERCEPT_HEADER(GetMessagePos, DWORD, WINAPI) {
	SDLOG(12, "DetouredGetMessagePos\n");
	DWORD ret = TrueGetMessagePos();
	return ret;
}
Example #5
0
GENERATE_INTERCEPT_HEADER(DirectInputCreateW, HRESULT, WINAPI, HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTW *ppDI, LPUNKNOWN punkOuter) {
	SDLOG(0, "DetouredDirectInputCreateW!\n");
	return TrueDirectInputCreateW(hinst, dwVersion, ppDI, punkOuter);
}
Example #6
0
GENERATE_INTERCEPT_HEADER(CreateDXGIFactory1, HRESULT, WINAPI, _In_ REFIID riid, _Out_ void **ppFactory) {
	SDLOG(0, "DetouredCreateDXGIFactory1\n");
	return TrueCreateDXGIFactory1(riid, ppFactory);
}
Example #7
0
GENERATE_INTERCEPT_HEADER(SetCursor, HCURSOR, WINAPI, _In_opt_ HCURSOR hCursor) {
	SDLOG(2, "DetouredSetCursor %p\n", hCursor);
	return TrueSetCursor(hCursor);
}
Example #8
0
BOOL APIENTRY hkIDXGIFactory1::IsCurrent() {
	SDLOG(20, "hkIDXGIFactory1::IsCurrent\n");
	return pWrapped->IsCurrent();
}
Example #9
0
HRESULT APIENTRY hkIDirect3D9::QueryInterface(REFIID riid,  void **ppvObj) {
	SDLOG(1, "hkIDirect3D9::QueryInterface\n");
	return m_pD3Dint->QueryInterface(riid,  ppvObj);
}
Example #10
0
DWORD WINAPI DetouredTimeGetTime() {
	SDLOG(13, "T %6lu: Detouring: TimeGetTime - real: %10lu, returned: %10lu\n", GetCurrentThreadId(), TrueTimeGetTime(), TrueTimeGetTime() + timeIncrease);
	//timeIncrease += 16;
	return TrueTimeGetTime() + timeIncrease;
}
Example #11
0
HRESULT WINAPI DetouredD3DXCreateTextureFromFileInMemory(_In_ LPDIRECT3DDEVICE9 pDevice, _In_ LPCVOID pSrcData, _In_ UINT SrcDataSize, _Out_ LPDIRECT3DTEXTURE9 *ppTexture) {
	SDLOG(4, "DetouredD3DXCreateTextureFromFileInMemory\n");
	HRESULT res = TrueD3DXCreateTextureFromFileInMemory(pDevice, pSrcData, SrcDataSize, ppTexture);
	RSManager::get().registerD3DXCreateTextureFromFileInMemory(pSrcData, SrcDataSize, *ppTexture);
	return res;
}
Example #12
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");
}
Example #13
0
HRESULT RSManager::redirectDrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) {
	//if(onHudRT) {
	//	SDLOG(0, "HUD render: primitive type: %d, MinIndex: %u, NumVertices: %u, PrimitiveCount: %u, IndexDataFormat: %s\n", PrimitiveType, MinIndex, NumVertices, PrimitiveCount, D3DFormatToString(IndexDataFormat));

	//	// Print vertex decl type
	//	IDirect3DVertexDeclaration9* vDecl;
	//	d3ddev->GetVertexDeclaration(&vDecl);
	//	D3DVERTEXELEMENT9 decl[MAXD3DDECLLENGTH];
	//	UINT numElements;
	//	vDecl->GetDeclaration(decl, &numElements);
	//	for(size_t i=0; i<numElements; ++i) {
	//		SDLOG(0, "element %u -- stream: %d, offset: %d, type: %s, usage: %s\n", i, decl->Stream, decl->Offset, D3DDeclTypeToString((D3DDECLTYPE)decl->Type), D3DDeclUsageToString((D3DDECLUSAGE)decl->Usage));
	//	}
	//	vDecl->Release();
	//	
	//	// Print indices
	//	//SDLOG(0, "Indices: \n");
	//	//INT16 *indices = (INT16*)pIndexData;
	//	//for(size_t i=0; i<PrimitiveCount+2; ++i) {
	//	//	SDLOG(0, "%8hd, ", indices[i]);
	//	//}
	//	//SDLOG(0, "\n");

	//	// Print vertices
	//	SDLOG(0, "Vertices: \n");
	//	INT16 *values = (INT16*)pVertexStreamZeroData;
	//	for(size_t i=0; i<NumVertices*4*2; ++i) {
	//		SDLOG(0, "%8hd, ", values[i]);
	//		if((i+1)%2 == 0) SDLOG(0, "; ");
	//		if((i+1)%8 == 0) SDLOG(0, "\n");
	//	}

	//	//return d3ddev->DrawIndexedPrimitiveUP(PrimitiveType, MinIndex, NumVertices, PrimitiveCount, pIndexData, IndexDataFormat, hudVertices, VertexStreamZeroStride);
	//}
	if(hudStarted && hideHud) {
		return D3D_OK;
	}
	bool isTargetIndicator = false;
	if(pausedHudRT) {
		IDirect3DBaseTexture9 *t;
		d3ddev->GetTexture(0, &t);
		// check for target indicator
		if(isTextureHudHealthbar(t)) {
			INT16 *vertices = (INT16*)pVertexStreamZeroData;
			if(vertices[3] > -2000) {
				resumeHudRendering();
			}
		} else {
			resumeHudRendering();
		}
		t->Release();
	}
	if(onHudRT) {
		IDirect3DBaseTexture9 *t;
		d3ddev->GetTexture(0, &t);
		SDLOG(4, "On HUD, redirectDrawIndexedPrimitiveUP texture: %s\n", getTextureName(t));
		if((hddp < 5 && isTextureHudHealthbar(t)) || (hddp >= 5 && hddp < 7 && isTextureCategoryIconsHumanityCount(t)) || (hddp>=7 && !isTextureCategoryIconsHumanityCount(t))) hddp++;
		// check for target indicator
		if(isTextureHudHealthbar(t)) {
			INT16 *vertices = (INT16*)pVertexStreamZeroData;
			if(vertices[3] < -2000) {
				isTargetIndicator = true;
				pauseHudRendering();
			}
		}
		t->Release();
		if(hddp == 8) {
			finishHudRendering();
		} else if(!isTargetIndicator) {
			//d3ddev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA);
			//d3ddev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_ADD);
			//d3ddev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
			//d3ddev->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
		}
	}
	HRESULT hr = d3ddev->DrawIndexedPrimitiveUP(PrimitiveType, MinIndex, NumVertices, PrimitiveCount, pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
	//if(onHudRT) {
	//	if(takeScreenshot) dumpSurface("HUD_IndexPrimUP", rgbaBuffer1Surf);
	//}
	return hr;
}
Example #14
0
void RSManager::reloadGauss() {
	SAFEDELETE(gauss); 
	gauss = new GAUSS(d3ddev, Settings::get().getDOFOverrideResolution()*16/9, Settings::get().getDOFOverrideResolution());
	SDLOG(0, "Reloaded GAUSS\n");
}
Example #15
0
HRESULT APIENTRY hkIDirect3D9::CheckDeviceType(UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed) {
	SDLOG(0, "CheckDeviceType\n");
	return m_pD3Dint->CheckDeviceType(Adapter, CheckType, DisplayFormat, BackBufferFormat, Windowed);
}
Example #16
0
HRESULT APIENTRY hkIDirect3D9::GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9 *pIdentifier) {
	SDLOG(0, "GetAdapterIdentifier ------\n");
	return m_pD3Dint->GetAdapterIdentifier(Adapter, Flags, pIdentifier);
}
Example #17
0
UINT APIENTRY hkIDirect3D9::GetAdapterCount() {
	SDLOG(0, "GetAdapterCount ------\n");
	return m_pD3Dint->GetAdapterCount();
}
Example #18
0
HMONITOR APIENTRY hkIDirect3D9::GetAdapterMonitor(UINT Adapter) {
	SDLOG(0, "GetAdapterMonitor adapter %u ------\n", Adapter);
	HMONITOR res = m_pD3Dint->GetAdapterMonitor(Adapter);
	SDLOG(0, "-> %p\n", res);
	return res;
}
Example #19
0
GENERATE_INTERCEPT_HEADER(CreateDXGIFactory2, HRESULT, WINAPI, _In_ UINT flags, _In_ const IID &riid, _Out_ void **ppFactory) {
	SDLOG(0, "DetouredCreateDXGIFactory2\n");
	return TrueCreateDXGIFactory2(flags, riid, ppFactory);
}
Example #20
0
HRESULT APIENTRY hkIDirect3D9::GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9 *pCaps) {
	SDLOG(0, "GetDeviceCaps %u %x %p ------\n", Adapter, DeviceType, pCaps);
	return m_pD3Dint->GetDeviceCaps(Adapter, DeviceType, pCaps);
}
Example #21
0
GENERATE_INTERCEPT_HEADER(ShowCursor, int, WINAPI, _In_ BOOL bShow) {
	SDLOG(2, "DetouredShowCursor %s\n", bShow ? "true" : "false");
	return TrueShowCursor(Settings::get().getHideMouseCursor() ? false : bShow);
}
Example #22
0
HRESULT APIENTRY hkIDirect3D9::RegisterSoftwareDevice(void *pInitializeFunction) {
	SDLOG(0, "RegisterSoftwareDevice ------\n");
	return m_pD3Dint->RegisterSoftwareDevice(pInitializeFunction);
}
Example #23
0
GENERATE_INTERCEPT_HEADER(DirectInputCreateEx, HRESULT, WINAPI, HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter) {
	SDLOG(0, "DetouredDirectInputCreateEx!\n");
	return TrueDirectInputCreateEx(hinst, dwVersion, riidltf, ppvOut, punkOuter);
}
Example #24
0
ULONG APIENTRY hkIDirect3D9::Release() {
	SDLOG(20, "Release hkIDirect3D9 ------ %p \n", this);
	return m_pD3Dint->Release();
}
Example #25
0
GENERATE_INTERCEPT_HEADER(D3DXCreateTexture, HRESULT, WINAPI, _In_ LPDIRECT3DDEVICE9 pDevice, _In_ UINT Width, _In_ UINT Height, 
						  _In_ UINT MipLevels, _In_ DWORD Usage, _In_ D3DFORMAT Format, _In_ D3DPOOL Pool, _Out_ LPDIRECT3DTEXTURE9 *ppTexture) {
	SDLOG(4, "DetouredD3DXCreateTexture\n");
	HRESULT res = TrueD3DXCreateTexture(pDevice, Width, Height, MipLevels, Usage, Format, Pool, ppTexture);
	return res;
}
Example #26
0
ULONG APIENTRY hkIDirect3D9::AddRef() {
	SDLOG(1, "hkIDirect3D9::AddRef\n");
	return m_pD3Dint->AddRef();
}
Example #27
0
GENERATE_INTERCEPT_HEADER(EnumDisplaySettingsExW, BOOL, WINAPI, _In_ LPCWSTR lpszDeviceName, _In_ DWORD iModeNum, _Out_ DEVMODEW *lpDevMode, _In_ DWORD dwFlags) {
	SDLOG(2, "EnumDisplaySettingsExW %s -- %u\n", lpszDeviceName ? CW2A(lpszDeviceName) : "NULL", iModeNum);
	return DetouredEnumDisplaySettingsTemplate(lpszDeviceName, iModeNum, lpDevMode, dwFlags, TrueEnumDisplaySettingsExW);
}
Example #28
0
HRESULT APIENTRY hkIDirect3D9::CheckDeviceFormatConversion(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SourceFormat,D3DFORMAT TargetFormat) {
	SDLOG(0, "CheckDeviceFormatConversion\n");
	return m_pD3Dint->CheckDeviceFormatConversion(Adapter, DeviceType, SourceFormat, TargetFormat);
}
Example #29
0
GENERATE_INTERCEPT_HEADER(GetMonitorInfoW, BOOL, WINAPI, _In_ HMONITOR hMonitor, _Inout_ LPMONITORINFO lpmi) {
	SDLOG(1, "DetouredGetMonitorInfoW %p\n", hMonitor);
	BOOL ret = TrueGetMonitorInfoW(hMonitor, lpmi);
	adjustMonitorInfo(lpmi);
	return ret;
}
Example #30
0
void RSManager::enableTakeScreenshot() {
	takeScreenshot = true; 
	SDLOG(0, "takeScreenshot: %s\n", takeScreenshot?"true":"false");
}