Blame | Last modification | View Log | RSS feed
#include <iostream>#include <windows.h>#include <TCHAR.h>#include "..\Direct3D-Hook\Direct3D-Hook.h"#include "../../Base Engine/Common/String.h"int main ( int argc, char **argv )/*int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)*/{String filename;if ( argc >= 2 )filename = argv[1];if ( filename.Right(4).lower() != ".exe" ){if ( filename.Empty() )filename = "x3.exe";elsefilename += "/x3.exe";}filename = filename.FindReplace ( "/", "\\" );std::cout << "Running Program: " << filename.c_str() << std::endl;// check if the file existsFILE *id = fopen ( filename.c_str(), "r+" );if ( !id ){std::cout<< "Could not find the main executable to run, exiting..." << std::endl;return 1;}fclose ( id );// Create/update the registry entryHKEY regKey = 0;if(ERROR_SUCCESS != RegCreateKeyEx(HKEY_CURRENT_USER, L"Software\\Direct3D-Hook", 0, 0, 0, KEY_READ | KEY_WRITE,0, ®Key, 0)){std::cout<< "Could not open or create registry key: HKEY_CURRENT_USER\\Software\\Direct3D-Hook"<< std::endl<< "Press enter to exit..."<< std::endl;std::cin.ignore();return 2;}/* if ( ERROR_SUCCESS != RegSetValueEx(regKey, 0, 0, REG_SZ,reinterpret_cast<char*>((char *)filename.c_str()),(filename.Length() + 1) * sizeof(char)) )*/// if ( ERROR_SUCCESS != RegSetValueEx(regKey, 0, 0, REG_SZ, _t(filename.c_str()), filename.Length() + 1) )if ( ERROR_SUCCESS != RegSetValueExA ( regKey, 0, 0, REG_SZ, reinterpret_cast<BYTE*>("x3.exe"), 6 ) ){std::cout<< "Could not update key value."<< std::endl<< "Press enter to exit..."<< std::endl;std::cin.ignore();return 3;}std::cout<< "Hooking Direct3D...";InstallHook();String f = filename;for ( int i = 2; i < argc; i++ )f += String(" ") + argv[i];system ( f.c_str() );RemoveHook();return 0;}