/** * Loads stereo mode effect file. ***/ void StereoView::InitShaderEffects() { shaderEffect[ANAGLYPH_RED_CYAN] = "AnaglyphRedCyan.fx"; shaderEffect[ANAGLYPH_RED_CYAN_GRAY] = "AnaglyphRedCyanGray.fx"; shaderEffect[ANAGLYPH_YELLOW_BLUE] = "AnaglyphYellowBlue.fx"; shaderEffect[ANAGLYPH_YELLOW_BLUE_GRAY] = "AnaglyphYellowBlueGray.fx"; shaderEffect[ANAGLYPH_GREEN_MAGENTA] = "AnaglyphGreenMagenta.fx"; shaderEffect[ANAGLYPH_GREEN_MAGENTA_GRAY] = "AnaglyphGreenMagentaGray.fx"; shaderEffect[SIDE_BY_SIDE] = "SideBySide.fx"; shaderEffect[DIY_RIFT] = "SideBySideRift.fx"; shaderEffect[OVER_UNDER] = "OverUnder.fx"; shaderEffect[INTERLEAVE_HORZ] = "InterleaveHorz.fx"; shaderEffect[INTERLEAVE_VERT] = "InterleaveVert.fx"; shaderEffect[CHECKERBOARD] = "Checkerboard.fx"; char viewPath[512]; ProxyHelper helper = ProxyHelper(); helper.GetPath(viewPath, "fx\\"); strcat_s(viewPath, 512, shaderEffect[stereo_mode].c_str()); if (FAILED(D3DXCreateEffectFromFile(m_pActualDevice, viewPath, NULL, NULL, D3DXFX_DONOTSAVESTATE, NULL, &viewEffect, NULL))) { OutputDebugString("Effect creation failed\n"); } }
void ParsePaths() { proxyDllW = (LPCWSTR)malloc(512*sizeof(wchar_t)); ProxyHelper helper = ProxyHelper(); dllDir = _strdup(helper.GetPath("bin\\").c_str()); proxyDll = _strdup(helper.GetPath("bin\\d3d9.dll").c_str()); mbstowcs_s(NULL, (wchar_t*)proxyDllW, 512, proxyDll, 512); }
void ParsePaths() { dllDir = (LPCSTR)malloc(512*sizeof(char)); proxyDll = (LPCSTR)malloc(512*sizeof(char)); proxyDllW = (LPCWSTR)malloc(512*sizeof(wchar_t)); ProxyHelper helper = ProxyHelper(); helper.GetPath((char*)dllDir, "bin\\"); helper.GetPath((char*)proxyDll, "bin\\d3d9.dll"); mbstowcs_s(NULL, (wchar_t*)proxyDllW, 512, proxyDll, 512); }
void OculusRiftView::InitShaderEffects() { shaderEffect[OCULUS_RIFT] = "OculusRift.fx"; shaderEffect[OCULUS_RIFT_CROPPED] = "OculusRiftCropped.fx"; char viewPath[512]; ProxyHelper helper = ProxyHelper(); helper.GetPath(viewPath, "fx\\"); strcat_s(viewPath, 512, shaderEffect[stereo_mode].c_str()); D3DXCreateEffectFromFile(device, viewPath, NULL, NULL, 0, NULL, &viewEffect, NULL); }
HRESULT WINAPI BaseDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface) { // load configuration file ProxyHelper helper = ProxyHelper(); ProxyHelper::ProxyConfig cfg; bool stereoificatorCfgLoaded = helper.LoadConfig(cfg); if (cfg.forceAdapterNumber >= (int)GetAdapterCount()) { OutputDebugString("[ERR] forceAdapterNumber outside of range of valid adapters. Using original Adapter instead.\n"); } // Create real interface HRESULT hResult = m_pD3D->CreateDevice( (cfg.forceAdapterNumber >= (int)GetAdapterCount() || (cfg.forceAdapterNumber < 0)) ? Adapter : cfg.forceAdapterNumber, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface); if(FAILED(hResult)) return hResult; OutputDebugString("[OK] Normal D3D device created\n"); char buf[64]; sprintf_s(buf, "Number of back buffers = %d\n", pPresentationParameters->BackBufferCount); OutputDebugString(buf); if(!stereoificatorCfgLoaded) { OutputDebugString("[ERR] Config loading failed, config could not be loaded. Returning normal D3DDevice. Stereoificator will not be active.\n"); return hResult; } OutputDebugString("[OK] Config loading - OK\n"); char buf1[32]; LPCSTR psz = NULL; wsprintf(buf1,"Config type: %d", cfg.game_type); psz = buf1; OutputDebugString(psz); OutputDebugString("\n"); // Create and return proxy D3DProxyDevice* newDev = new D3DProxyDevice(*ppReturnedDeviceInterface, this, cfg); *ppReturnedDeviceInterface = newDev; OutputDebugString("[OK] Stereoificator D3D device created.\n"); return hResult; }
/** * Create D3D device proxy. * First it creates the device, then it loads the game configuration * calling the ProxyHelper class. Last it creates and returns the * device proxy calling D3DProxyDeviceFactory::Get(). ***/ HRESULT WINAPI BaseDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface) { // Create real interface HRESULT hResult = m_pD3D->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface); if(FAILED(hResult)) return hResult; OutputDebugString("[OK] Normal D3D device created\n"); char buf[64]; sprintf_s(buf, "Number of back buffers = %d\n", pPresentationParameters->BackBufferCount); OutputDebugString(buf); // load configuration file ProxyHelper helper = ProxyHelper(); ProxyHelper::ProxyConfig cfg; ProxyHelper::OculusProfile oculusProfile; if(!helper.LoadConfig(cfg, oculusProfile)) { OutputDebugString("[ERR] Config loading failed, config could not be loaded. Returning normal D3DDevice. Vireio will not be active.\n"); return hResult; } // load HUD/GUI settings helper.LoadHUDConfig(cfg); helper.LoadGUIConfig(cfg); OutputDebugString("[OK] Config loading - OK\n"); if(cfg.stereo_mode == StereoView::DISABLED) { OutputDebugString("[WARN] stereo_mode == disabled. Returning normal D3DDevice. Vireio will not be active.\n"); return hResult; } OutputDebugString("[OK] Stereo mode is enabled.\n"); char buf1[32]; LPCSTR psz = NULL; wsprintf(buf1,"Config type: %d", cfg.game_type); psz = buf1; OutputDebugString(psz); OutputDebugString("\n"); // Create and return proxy *ppReturnedDeviceInterface = D3DProxyDeviceFactory::Get(cfg, *ppReturnedDeviceInterface, this); OutputDebugString("[OK] Vireio D3D device created.\n"); return hResult; }
void StereoView::InitShaderEffects() { shaderEffect[SIDE_BY_SIDE] = "SideBySide.fx"; char viewPath[512]; ProxyHelper helper = ProxyHelper(); helper.GetPath(viewPath, "fx\\"); strcat_s(viewPath, 512, shaderEffect[stereo_mode].c_str()); if (FAILED(D3DXCreateEffectFromFile(m_pActualDevice, viewPath, NULL, NULL, D3DXFX_DONOTSAVESTATE, NULL, &viewEffect, NULL))) { OutputDebugString("Effect creation failed\n"); } }
// CBT Hook-style injection. BOOL APIENTRY DllMain( HINSTANCE hModule, DWORD fdwReason, LPVOID lpReserved ) { if (fdwReason == DLL_PROCESS_ATTACH) // When initializing.... { hDLL = hModule; // We don't need thread notifications for what we're doing. Thus, get // rid of them, thereby eliminating some of the overhead of this DLL DisableThreadLibraryCalls(hModule); // Only hook the APIs if this is the right process. GetModuleFileName(GetModuleHandle(NULL), targetExe, sizeof(targetExe)); PathStripPath(targetExe); GetModuleFileName(GetModuleHandle(NULL), targetPath, sizeof(targetPath)); targetPathString = std::string(targetPath); targetPathString = targetPathString.substr(0, targetPathString.find_last_of("\\/")); OutputDebugString("HIJACKDLL checking process: "); OutputDebugString(targetExe); OutputDebugString("\n"); ParsePaths(); ProxyHelper helper = ProxyHelper(); if (helper.HasProfile(targetExe)) { if (HookAPICalls(&D3DHook)) { OutputDebugString("HookAPICalls(D3D): TRUE\n"); } else if(HookAPICalls(&KernelHook)) { OutputDebugString("HookAPICalls(Kernel): TRUE\n"); } else { OutputDebugString("HookAPICalls(Both): FALSE\n"); } SetDllDirectory(dllDir); SaveExeName(targetExe); } } return TRUE; }
/** * Loads Oculus Rift shader effect files. ***/ void OculusRiftView::InitShaderEffects() { //Currently, RiftUp DK1 and DK2 share the same shader effects shaderEffect[RIFTUP] = "OculusRift.fx"; shaderEffect[OCULUS_RIFT_DK1] = "OculusRift.fx"; shaderEffect[OCULUS_RIFT_DK1_CROPPED] = "OculusRiftCropped.fx"; shaderEffect[OCULUS_RIFT_DK2] = "OculusRiftDK2.fx"; shaderEffect[OCULUS_RIFT_DK2_CROPPED] = "OculusRiftDK2Cropped.fx"; char viewPath[512]; ProxyHelper helper = ProxyHelper(); helper.GetPath(viewPath, "fx\\"); strcat_s(viewPath, 512, shaderEffect[stereo_mode].c_str()); D3DXCreateEffectFromFile(m_pActualDevice, viewPath, NULL, NULL, 0, NULL, &viewEffect, NULL); }
/** * Create D3D device proxy. * First it creates the device, then it loads the game configuration * calling the ProxyHelper class. Last it creates and returns the * device proxy calling D3DProxyDeviceFactory::Get(). ***/ HRESULT WINAPI BaseDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface) { // Create real interface HRESULT hResult = m_pD3D->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface); if (FAILED(hResult)) return hResult; OutputDebugString("[OK] Normal D3D device created\n"); char buf[64]; sprintf_s(buf, "Number of back buffers = %d\n", pPresentationParameters->BackBufferCount); OutputDebugString(buf); sprintf_s(buf, "Format of back buffers = %x\n", pPresentationParameters->BackBufferFormat); OutputDebugString(buf); // for debug reasons, output the d3dswapeffect parameter switch (pPresentationParameters->SwapEffect) { case D3DSWAPEFFECT::D3DSWAPEFFECT_COPY: OutputDebugString("D3DSWAPEFFECT_COPY"); break; case D3DSWAPEFFECT::D3DSWAPEFFECT_DISCARD: OutputDebugString("D3DSWAPEFFECT_DISCARD"); break; case D3DSWAPEFFECT::D3DSWAPEFFECT_FLIP: OutputDebugString("D3DSWAPEFFECT_FLIP"); break; case D3DSWAPEFFECT::D3DSWAPEFFECT_FLIPEX: OutputDebugString("D3DSWAPEFFECT_FLIPEX"); break; case D3DSWAPEFFECT::D3DSWAPEFFECT_OVERLAY: OutputDebugString("D3DSWAPEFFECT_OVERLAY"); break; default: char buf[256]; sprintf_s(buf, 256, "D3DPRESENT_PARAMETERS::SwapEffect %x", pPresentationParameters->SwapEffect); OutputDebugString(buf); break; } // if no back buffer present (=D3DFMT_UNKNOWN), return base device - TODO !!! // DOES NOT WORK since the shaders will not be wrapped by the base device // create a special device for that..... /*if ((pPresentationParameters->BackBufferCount == 0) && (pPresentationParameters->BackBufferFormat == D3DFORMAT::D3DFMT_UNKNOWN)) { *ppReturnedDeviceInterface = new BaseDirect3DDevice9(*ppReturnedDeviceInterface, this); return hResult; }*/ // load configuration file ProxyHelper helper = ProxyHelper(); ProxyHelper::ProxyConfig cfg; ProxyHelper::OculusProfile oculusProfile; if (!helper.LoadConfig(cfg, oculusProfile)) { OutputDebugString("[ERR] Config loading failed, config could not be loaded. Returning normal D3DDevice. Vireio will not be active.\n"); return hResult; } OutputDebugString("[OK] Config loading - OK\n"); if (cfg.stereo_mode == StereoView::DISABLED) { OutputDebugString("[WARN] stereo_mode == disabled. Returning normal D3DDevice. Vireio will not be active.\n"); return hResult; } OutputDebugString("[OK] Stereo mode is enabled.\n"); char buf1[32]; LPCSTR psz = NULL; wsprintf(buf1, "Config type: %d", cfg.game_type); psz = buf1; OutputDebugString(psz); OutputDebugString("\n"); // Create and return proxy *ppReturnedDeviceInterface = D3DProxyDeviceFactory::Get(cfg, *ppReturnedDeviceInterface, this); OutputDebugString("[OK] Vireio D3D device created.\n"); return hResult; }
// CBT Hook-style injection. BOOL APIENTRY DllMain( HINSTANCE hModule, DWORD fdwReason, LPVOID lpReserved ) { if (fdwReason == DLL_PROCESS_ATTACH) // When initializing.... { hDLL = hModule; // We don't need thread notifications for what we're doing. Thus, get // rid of them, thereby eliminating some of the overhead of this DLL DisableThreadLibraryCalls(hModule); // Only hook the APIs if this is the right process. GetModuleFileName(GetModuleHandle(NULL), targetExe, sizeof(targetExe)); PathStripPath(targetExe); /*if(std::string(targetExe) == "GitHub.exe") { OutputDebugString("Ignoring process: "); OutputDebugString(targetExe); OutputDebugString("\n"); return TRUE; }*/ GetModuleFileName(GetModuleHandle(NULL), targetPath, sizeof(targetPath)); targetPathString = std::string(targetPath); targetPathString = targetPathString.substr(0, targetPathString.find_last_of("\\/") + 1); OutputDebugString("HIJACKDLL checking process: "); OutputDebugString(targetExe); OutputDebugString("\n"); #ifndef x64 ParsePaths(); #endif ProxyHelper helper = ProxyHelper(); if (helper.HasProfile(targetExe, targetPathString.c_str())) { #ifndef x64 //Need to check that the d3d9.dll is actually in the game folder - If it is, then we don't need to hook API calls //using the methods below as d3d9 will just be loaded by the game's executable if (!fileExists(targetPathString + "D3D9.dll")) { if (HookAPICalls(&D3DHook)) { OutputDebugString("HookAPICalls(D3D): TRUE\n"); } else if(HookAPICalls(&KernelHook)) { OutputDebugString("HookAPICalls(Kernel): TRUE\n"); } else { OutputDebugString("HookAPICalls(Both): FALSE\n"); } SetDllDirectory(dllDir); } else { OutputDebugString(std::string("D3D9.dll found in game directory (" + targetPathString + ") - Bypassing API injection").c_str()); } #endif } else { OutputDebugString((std::string("Game profile not found for: ") + targetExe).c_str()); } } return TRUE; }