diff --git a/.cproject b/.cproject index c53c9a5..43ef20e 100644 --- a/.cproject +++ b/.cproject @@ -18,8 +18,9 @@ - diff --git a/.gitattributes b/.gitattributes index e8e71c2..e391785 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,17 +1,10 @@ * text=auto !eol /.cproject -text /.project -text +.settings/org.eclipse.cdt.codan.core.prefs -text /README.txt -text -uMod_DX9/makefile.gcc -text -uMod_DX9/makefile.vc -text -uMod_DX9/uMod_ArrayHandler.cpp -text -uMod_DX9/uMod_ArrayHandler.h -text uMod_DX9/uMod_DX9_dll.cpp -text uMod_DX9/uMod_DX9_dll.h -text -uMod_DX9/uMod_DX9_dll_DIRECT_INJECTION.def -text -uMod_DX9/uMod_DX9_dll_HOOK_INJECTION.def -text -uMod_DX9/uMod_DX9_dll_NO_INJECTION.def -text -uMod_DX9/uMod_Defines.h -text uMod_DX9/uMod_IDirect3D9.cpp -text uMod_DX9/uMod_IDirect3D9.h -text uMod_DX9/uMod_IDirect3D9Ex.cpp -text @@ -26,22 +19,34 @@ uMod_DX9/uMod_IDirect3DTexture9.cpp -text uMod_DX9/uMod_IDirect3DTexture9.h -text uMod_DX9/uMod_IDirect3DVolumeTexture9.cpp -text uMod_DX9/uMod_IDirect3DVolumeTexture9.h -text -uMod_DX9/uMod_Main.h -text uMod_DX9/uMod_TextureClient_DX9.cpp -text uMod_DX9/uMod_TextureClient_DX9.h -text -uMod_DX9/uMod_TextureFunction.cpp -text -uMod_DX9/uMod_TextureFunction.h -text +uMod_DXMain/makefile.gcc -text +uMod_DXMain/makefile.vc -text +uMod_DXMain/uMod_ArrayHandler.cpp -text +uMod_DXMain/uMod_ArrayHandler.h -text +uMod_DXMain/uMod_DX9_dll_DIRECT_INJECTION.def -text +uMod_DXMain/uMod_DX9_dll_HOOK_INJECTION.def -text +uMod_DXMain/uMod_DX9_dll_NO_INJECTION.def -text +uMod_DXMain/uMod_DXMain_dll.cpp -text +uMod_DXMain/uMod_DXMain_dll.h -text +uMod_DXMain/uMod_Defines.h -text +uMod_DXMain/uMod_Main.h -text uMod_DXMain/uMod_TextureClient.cpp -text uMod_DXMain/uMod_TextureClient.h -text +uMod_DXMain/uMod_TextureFunction.cpp -text +uMod_DXMain/uMod_TextureFunction.h -text uMod_DXMain/uMod_TextureServer.cpp -text uMod_DXMain/uMod_TextureServer.h -text /uMod_Error.h -text uMod_GUI/bin/README_Deutsch.txt -text uMod_GUI/bin/README_English.txt -text +uMod_GUI/bin/README_French.txt -text uMod_GUI/bin/languages/Example_uMod_LanguagePack_English.txt -text uMod_GUI/bin/languages/uMod_LanguagePackU_Deutsch.txt -text uMod_GUI/bin/languages/uMod_LanguagePackU_French.txt -text uMod_GUI/bin/languages/uMod_LanguagePackU_Russian.txt -text +uMod_GUI/bin/languages/uMod_LanguagePack_Italian.txt -text uMod_GUI/config.gcc -text uMod_GUI/config.vc -text uMod_GUI/makefile.gcc -text diff --git a/.project b/.project index c62d3ee..0272272 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - uMod + uMod 2 diff --git a/.settings/org.eclipse.cdt.codan.core.prefs b/.settings/org.eclipse.cdt.codan.core.prefs new file mode 100644 index 0000000..e6a7634 --- /dev/null +++ b/.settings/org.eclipse.cdt.codan.core.prefs @@ -0,0 +1,66 @@ +#Sun Mar 11 21:51:23 CET 2012 +eclipse.preferences.version=1 +org.eclipse.cdt.codan.checkers.errnoreturn=Warning +org.eclipse.cdt.codan.checkers.errnoreturn.params={implicit\=>false} +org.eclipse.cdt.codan.checkers.errreturnvalue=Error +org.eclipse.cdt.codan.checkers.errreturnvalue.params={} +org.eclipse.cdt.codan.checkers.noreturn=Error +org.eclipse.cdt.codan.checkers.noreturn.params={implicit\=>false} +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={} +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={} +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={no_break_comment\=>"no break",last_case_param\=>true,empty_case_param\=>false} +org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning +org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={unknown\=>false,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error +org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={} +org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error +org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={} +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={} +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={paramNot\=>false} +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={else\=>false,afterelse\=>false} +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={} +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={} +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={exceptions\=>("@(\#)","$Id")} +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} diff --git a/uMod_DX9/makefile.gcc b/uMod_DX9/makefile.gcc deleted file mode 100644 index 1a8c827..0000000 --- a/uMod_DX9/makefile.gcc +++ /dev/null @@ -1,117 +0,0 @@ -ifdef NI - -ifdef LOG_MESSAGE -precompiler_flag = /D "LOG_MESSAGE" /D "NO_INJECTION" -else -precompiler_flag = /D "NO_INJECTION" -endif - -def_file = /DEF:"uMod_DX9_dll_NO_INJECTION.def" -obj_suff = NI.obj -dll = d3d9.dll - -else - -ifdef DI -ifdef LOG_MESSAGE -precompiler_flag = /D "LOG_MESSAGE" /D "DIRECT_INJECTION" -else -precompiler_flag = /D "DIRECT_INJECTION" -endif - -def_file = /DEF:"uMod_DX9_dll_DIRECT_INJECTION.def" -obj_suff = DI.obj -dll = uMod_d3d9_DI.dll - -else - -ifdef LOG_MESSAGE -precompiler_flag = /D "LOG_MESSAGE" /D "HOOK_INJECTION" -else -precompiler_flag = /D "HOOK_INJECTION" -endif - -def_file = /DEF:"uMod_DX9_dll_HOOK_INJECTION.def" -obj_suff = HI.obj -dll = uMod_d3d9_HI.dll -endif -endif - - -CXX = cl -CLINK = link.exe -DEFINES = /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "_WINDLL" /D "_MBCS" -CFLAGS = /I "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include" /nologo /W3 /WX- /O2 ${DEFINES} ${precompiler_flag} /Gm- /EHsc /MT /GS /fp:precise /Zc:wchar_t -LFLAGS = /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86" /DLL "Winmm.lib" "d3dx9.lib" "dxguid.lib" "user32.lib" "Kernel32.lib" ${def_file} /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE:NO /NXCOMPAT:NO /MACHINE:X86 - -obj = obj -bin = bin - -objects = ${obj}\uMod_DX9_dll.${obj_suff} \ - ${obj}\uMod_IDirect3D9.${obj_suff} \ - ${obj}\uMod_IDirect3D9Ex.${obj_suff} \ - ${obj}\uMod_IDirect3DDevice9.${obj_suff} \ - ${obj}\uMod_IDirect3DDevice9Ex.${obj_suff} \ - ${obj}\uMod_TextureFunction.${obj_suff} \ - ${obj}\uMod_IDirect3DTexture9.${obj_suff} \ - ${obj}\uMod_IDirect3DVolumeTexture9.${obj_suff} \ - ${obj}\uMod_IDirect3DCubeTexture9.${obj_suff} \ - ${obj}\uMod_ArrayHandler.${obj_suff} \ - ${obj}\uMod_TextureClient.${obj_suff} \ - ${obj}\uMod_TextureServer.${obj_suff} - -headers = uMod_Main.h \ - uMod_Defines.h \ - uMod_DX9_dll.h \ - uMod_IDirect3D9.h \ - uMod_IDirect3DDevice9.h \ - uMod_TextureFunction.h \ - uMod_IDirect3DTexture9.h \ - uMod_IDirect3DVolumeTexture9.h \ - uMod_IDirect3DCubeTexture9.h \ - uMod_ArrayHandler.h \ - uMod_TextureClient.h \ - uMod_TextureServer.h - -${bin}\d3d9.dll: ${objects} - ${CLINK} ${LFLAGS} ${objects} /OUT:${bin}\${dll} - copy ${bin}\${dll} ..\uMod_GUI\bin\${dll} - -${obj}\uMod_DX9_dll.${obj_suff}: uMod_DX9_dll.cpp ${headers} - ${CXX} ${CFLAGS} /c $< /Fo$@ - -${obj}\uMod_IDirect3D9.${obj_suff}: uMod_IDirect3D9.cpp ${headers} - ${CXX} ${CFLAGS} /c $< /Fo$@ - -${obj}\uMod_IDirect3D9Ex.${obj_suff}: uMod_IDirect3D9Ex.cpp ${headers} - ${CXX} ${CFLAGS} /c $< /Fo$@ - -${obj}\uMod_IDirect3DDevice9.${obj_suff}: uMod_IDirect3DDevice9.cpp ${headers} - ${CXX} ${CFLAGS} /c $< /Fo$@ - -${obj}\uMod_IDirect3DDevice9Ex.${obj_suff}: uMod_IDirect3DDevice9Ex.cpp ${headers} - ${CXX} ${CFLAGS} /c $< /Fo$@ - -${obj}\uMod_TextureFunction.${obj_suff}: uMod_TextureFunction.cpp ${headers} - ${CXX} ${CFLAGS} /c $< /Fo$@ - -${obj}\uMod_IDirect3DTexture9.${obj_suff}: uMod_IDirect3DTexture9.cpp ${headers} - ${CXX} ${CFLAGS} /c $< /Fo$@ - -${obj}\uMod_IDirect3DVolumeTexture9.${obj_suff}: uMod_IDirect3DVolumeTexture9.cpp ${headers} - ${CXX} ${CFLAGS} /c $< /Fo$@ - -${obj}\uMod_IDirect3DCubeTexture9.${obj_suff}: uMod_IDirect3DCubeTexture9.cpp ${headers} - ${CXX} ${CFLAGS} /c $< /Fo$@ - -${obj}\uMod_ArrayHandler.${obj_suff}: uMod_ArrayHandler.cpp ${headers} - ${CXX} ${CFLAGS} /c $< /Fo$@ - -${obj}\uMod_TextureClient.${obj_suff}: uMod_TextureClient.cpp ${headers} - ${CXX} ${CFLAGS} /c $< /Fo$@ - -${obj}\uMod_TextureServer.${obj_suff}: uMod_TextureServer.cpp ${headers} - ${CXX} ${CFLAGS} /c $< /Fo$@ - -clean: - del ${objects} ${bin}\${dll} \ No newline at end of file diff --git a/uMod_DX9/uMod_DX9_dll.cpp b/uMod_DX9/uMod_DX9_dll.cpp index 1b6e62b..ec46e21 100644 --- a/uMod_DX9/uMod_DX9_dll.cpp +++ b/uMod_DX9/uMod_DX9_dll.cpp @@ -25,7 +25,9 @@ along with Universal Modding Engine. If not, see */ -#include "uMod_Main.h" +#include "uMod_DX9_dll.h" +#include "uMod_IDirect3D9.h" +#include "uMod_IDirect3D9Ex.h" //#include "detours.h" //#include "detourxs/detourxs/detourxs.h" @@ -36,10 +38,7 @@ along with Universal Modding Engine. If not, see /* * global variable which are not linked external */ -HINSTANCE gl_hOriginalDll = NULL; -HINSTANCE gl_hThisInstance = NULL; -uMod_TextureServer* gl_TextureServer = NULL; -HANDLE gl_ServerThread = NULL; +HINSTANCE gl_hOriginal_DX9_Dll = NULL; typedef IDirect3D9 *(APIENTRY *Direct3DCreate9_type)(UINT); typedef HRESULT (APIENTRY *Direct3DCreate9Ex_type)(UINT SDKVersion, IDirect3D9Ex **ppD3D); @@ -47,7 +46,6 @@ typedef HRESULT (APIENTRY *Direct3DCreate9Ex_type)(UINT SDKVersion, IDirect3D9Ex #ifndef NO_INJECTION Direct3DCreate9_type Direct3DCreate9_fn; // we need to store the pointer to the original Direct3DCreate9 function after we have done a detour Direct3DCreate9Ex_type Direct3DCreate9Ex_fn; // we need to store the pointer to the original Direct3DCreate9 function after we have done a detour -HHOOK gl_hHook = NULL; #endif @@ -56,96 +54,39 @@ HHOOK gl_hHook = NULL; /* * global variable which are linked external */ -unsigned int gl_ErrorState = 0u; -#ifdef LOG_MESSAGE -FILE* gl_File = NULL; -#endif - - -#ifdef DIRECT_INJECTION -void Nothing(void) {(void)NULL;} -#endif -/* - * dll entry routine, here we initialize or clean up - */ -BOOL WINAPI DllMain( HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) +void InitDX9(void) { - UNREFERENCED_PARAMETER(lpReserved); - - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - { - InitInstance(hModule); - break; - } - case DLL_PROCESS_DETACH: - { - ExitInstance(); - break; - } - default: break; - } - - return (true); -} - - -DWORD WINAPI ServerThread( LPVOID lpParam ) -{ - UNREFERENCED_PARAMETER(lpParam); - if (gl_TextureServer!=NULL) gl_TextureServer->MainLoop(); //This is and endless mainloop, it sleep till something is written into the pipe. - return (0); -} - -void InitInstance(HINSTANCE hModule) -{ - - DisableThreadLibraryCalls( hModule ); //reduce overhead - - gl_hThisInstance = (HINSTANCE) hModule; - - wchar_t game[MAX_PATH]; - if (HookThisProgram( game)) //ask if we need to hook this program - { - OpenMessage(); - Message("InitInstance: %lu\n", hModule); - - gl_TextureServer = new uMod_TextureServer(game); //create the server which listen on the pipe and prepare the update for the texture clients - - LoadOriginalDll(); + LoadOriginal_DX9_Dll(); #ifndef NO_INJECTION - // we detour the original Direct3DCreate9 to our MyDirect3DCreate9 - Direct3DCreate9_fn = (Direct3DCreate9_type) GetProcAddress(gl_hOriginalDll, "Direct3DCreate9"); - if (Direct3DCreate9_fn!=NULL) - { - Message("Detour: Direct3DCreate9\n"); - Direct3DCreate9_fn = (Direct3DCreate9_type)DetourFunc( (BYTE*)Direct3DCreate9_fn, (BYTE*)uMod_Direct3DCreate9, 5); - } - - Direct3DCreate9Ex_fn = (Direct3DCreate9Ex_type) GetProcAddress(gl_hOriginalDll, "Direct3DCreate9Ex"); - if (Direct3DCreate9Ex_fn!=NULL) - { - Message("Detour: Direct3DCreate9Ex\n"); - Direct3DCreate9Ex_fn = (Direct3DCreate9Ex_type)DetourFunc( (BYTE*)Direct3DCreate9Ex_fn, (BYTE*)uMod_Direct3DCreate9Ex, 7); - } -#endif - - if (gl_TextureServer->OpenPipe(game)) //open the pipe and send the name+path of this executable - { - Message("InitInstance: Pipe not opened\n"); - return; - } - - gl_ServerThread = CreateThread( NULL, 0, ServerThread, NULL, 0, NULL); //creating a thread for the mainloop - if (gl_ServerThread==NULL) {Message("InitInstance: Serverthread not started\n");} - + // we detour the original Direct3DCreate9 to our MyDirect3DCreate9 + Direct3DCreate9_fn = (Direct3DCreate9_type) GetProcAddress(gl_hOriginal_DX9_Dll, "Direct3DCreate9"); + if (Direct3DCreate9_fn!=NULL) + { + Message("Detour: Direct3DCreate9\n"); + Direct3DCreate9_fn = (Direct3DCreate9_type)DetourFunc( (BYTE*)Direct3DCreate9_fn, (BYTE*)uMod_Direct3DCreate9, 5); } + + Direct3DCreate9Ex_fn = (Direct3DCreate9Ex_type) GetProcAddress(gl_hOriginal_DX9_Dll, "Direct3DCreate9Ex"); + if (Direct3DCreate9Ex_fn!=NULL) + { + Message("Detour: Direct3DCreate9Ex\n"); + Direct3DCreate9Ex_fn = (Direct3DCreate9Ex_type)DetourFunc( (BYTE*)Direct3DCreate9Ex_fn, (BYTE*)uMod_Direct3DCreate9Ex, 7); + } +#endif } -void LoadOriginalDll(void) +void ExitDX9(void) +{ + // Release the system's d3d9.dll + if (gl_hOriginal_DX9_Dll!=NULL) + { + FreeLibrary(gl_hOriginal_DX9_Dll); + gl_hOriginal_DX9_Dll = NULL; + } +} +void LoadOriginal_DX9_Dll(void) { char buffer[MAX_PATH]; GetSystemDirectory(buffer,MAX_PATH); //get the system directory, we need to open the original d3d9.dll @@ -154,40 +95,14 @@ void LoadOriginalDll(void) strcat_s( buffer, MAX_PATH,"\\d3d9.dll"); // try to load the system's d3d9.dll, if pointer empty - if (!gl_hOriginalDll) gl_hOriginalDll = LoadLibrary(buffer); + if (!gl_hOriginal_DX9_Dll) gl_hOriginal_DX9_Dll = LoadLibrary(buffer); - if (!gl_hOriginalDll) + if (!gl_hOriginal_DX9_Dll) { ExitProcess(0); // exit the hard way } } -void ExitInstance() -{ - if (gl_TextureServer!=NULL) - { - gl_TextureServer->ClosePipe(); //This must be done before the server thread is killed, because the server thread will endless wait on the ReadFile() - } - if (gl_ServerThread!=NULL) - { - CloseHandle(gl_ServerThread); // kill the server thread - gl_ServerThread = NULL; - } - if (gl_TextureServer!=NULL) - { - delete gl_TextureServer; //delete the texture server - gl_TextureServer = NULL; - } - - // Release the system's d3d9.dll - if (gl_hOriginalDll!=NULL) - { - FreeLibrary(gl_hOriginalDll); - gl_hOriginalDll = NULL; - } - - CloseMessage(); -} #ifdef NO_INJECTION /* @@ -198,10 +113,10 @@ IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion) { Message("WINAPI Direct3DCreate9\n"); - if (!gl_hOriginalDll) LoadOriginalDll(); // looking for the "right d3d9.dll" + if (!gl_hOriginal_DX9_Dll) LoadOriginal_DX9_Dll(); // looking for the "right d3d9.dll" // find original function in original d3d9.dll - Direct3DCreate9_type D3DCreate9_fn = (Direct3DCreate9_type) GetProcAddress( gl_hOriginalDll, "Direct3DCreate9"); + Direct3DCreate9_type D3DCreate9_fn = (Direct3DCreate9_type) GetProcAddress( gl_hOriginal_DX9_Dll, "Direct3DCreate9"); if (!D3DCreate9_fn) @@ -225,10 +140,10 @@ HRESULT WINAPI Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex **ppD3D) { Message("WINAPI Direct3DCreate9Ex\n"); - if (!gl_hOriginalDll) LoadOriginalDll(); // looking for the "right d3d9.dll" + if (!gl_hOriginal_DX9_Dll) LoadOriginal_DX9_Dll(); // looking for the "right d3d9.dll" // find original function in original d3d9.dll - Direct3DCreate9Ex_type D3DCreate9Ex_fn = (Direct3DCreate9Ex_type) GetProcAddress( gl_hOriginalDll, "Direct3DCreate9Ex"); + Direct3DCreate9Ex_type D3DCreate9Ex_fn = (Direct3DCreate9Ex_type) GetProcAddress( gl_hOriginal_DX9_Dll, "Direct3DCreate9Ex"); if (!D3DCreate9Ex_fn) @@ -256,66 +171,53 @@ typedef HRESULT (APIENTRY *Direct3DCreate9Ex_type)(UINT SDKVersion, IDirect3D9Ex typedef int (WINAPI *D3DPERF_BeginEvent_type)( D3DCOLOR , LPCWSTR ); int WINAPI D3DPERF_BeginEvent( D3DCOLOR col, LPCWSTR wszName ) { - D3DPERF_BeginEvent_type fn = (D3DPERF_BeginEvent_type) GetProcAddress( gl_hOriginalDll, "D3DPERF_BeginEvent"); + D3DPERF_BeginEvent_type fn = (D3DPERF_BeginEvent_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_BeginEvent"); return fn( col, wszName); } typedef int (WINAPI *D3DPERF_EndEvent_type)( void ); int WINAPI D3DPERF_EndEvent( void ) { - D3DPERF_EndEvent_type fn = (D3DPERF_EndEvent_type) GetProcAddress( gl_hOriginalDll, "D3DPERF_EndEvent"); + D3DPERF_EndEvent_type fn = (D3DPERF_EndEvent_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_EndEvent"); return fn(); } typedef void (WINAPI *D3DPERF_SetMarker_type)( D3DCOLOR , LPCWSTR ); void WINAPI D3DPERF_SetMarker( D3DCOLOR col, LPCWSTR wszName ) { - D3DPERF_SetMarker_type fn = (D3DPERF_SetMarker_type) GetProcAddress( gl_hOriginalDll, "D3DPERF_SetMarker"); + D3DPERF_SetMarker_type fn = (D3DPERF_SetMarker_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_SetMarker"); return fn( col, wszName); } typedef void (WINAPI *D3DPERF_SetRegion_type)( D3DCOLOR, LPCWSTR ); void WINAPI D3DPERF_SetRegion( D3DCOLOR col, LPCWSTR wszName ) { - D3DPERF_SetRegion_type fn = (D3DPERF_SetRegion_type) GetProcAddress( gl_hOriginalDll, "D3DPERF_SetRegion"); + D3DPERF_SetRegion_type fn = (D3DPERF_SetRegion_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_SetRegion"); return fn( col, wszName); } typedef BOOL (WINAPI *D3DPERF_QueryRepeatFrame_type)( void ); BOOL WINAPI D3DPERF_QueryRepeatFrame( void ) { - D3DPERF_QueryRepeatFrame_type fn = (D3DPERF_QueryRepeatFrame_type) GetProcAddress( gl_hOriginalDll, "D3DPERF_QueryRepeatFrame"); + D3DPERF_QueryRepeatFrame_type fn = (D3DPERF_QueryRepeatFrame_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_QueryRepeatFrame"); return fn( ); } typedef void (WINAPI *D3DPERF_SetOptions_type)( DWORD ); void WINAPI D3DPERF_SetOptions( DWORD dwOptions ) { - D3DPERF_SetOptions_type fn = (D3DPERF_SetOptions_type) GetProcAddress( gl_hOriginalDll, "D3DPERF_SetOptions"); + D3DPERF_SetOptions_type fn = (D3DPERF_SetOptions_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_SetOptions"); return fn( dwOptions); } typedef DWORD (WINAPI *D3DPERF_GetStatus_type)( void ); DWORD WINAPI D3DPERF_GetStatus( void ) { - D3DPERF_GetStatus_type fn = (D3DPERF_GetStatus_type) GetProcAddress( gl_hOriginalDll, "D3DPERF_GetStatus"); + D3DPERF_GetStatus_type fn = (D3DPERF_GetStatus_type) GetProcAddress( gl_hOriginal_DX9_Dll, "D3DPERF_GetStatus"); return fn( ); } -bool HookThisProgram( wchar_t *ret) //this function always return true, it is needed for the name and path of the executable -{ - wchar_t Executable[MAX_PATH]; - GetModuleFileNameW( GetModuleHandle( NULL ), Executable, MAX_PATH ); //ask for name and path of this executable - - int len = 0; - while (Executable[len]) {ret[len] = Executable[len]; len++;} - ret[len] = 0; - return (true); -} - - - #else /* @@ -331,10 +233,10 @@ IDirect3D9 *APIENTRY uMod_Direct3DCreate9(UINT SDKVersion) // BEGIN - LoadOriginalDll(); + LoadOriginal_DX9_Dll(); - RetourFunc((BYTE*) GetProcAddress( gl_hOriginalDll, "Direct3DCreate9"), (BYTE*)Direct3DCreate9_fn, 5); - Direct3DCreate9_fn = (Direct3DCreate9_type) GetProcAddress( gl_hOriginalDll, "Direct3DCreate9"); + RetourFunc((BYTE*) GetProcAddress( gl_hOriginal_DX9_Dll, "Direct3DCreate9"), (BYTE*)Direct3DCreate9_fn, 5); + Direct3DCreate9_fn = (Direct3DCreate9_type) GetProcAddress( gl_hOriginal_DX9_Dll, "Direct3DCreate9"); /* if (Direct3DCreate9Ex_fn!=NULL) @@ -377,7 +279,7 @@ HRESULT APIENTRY uMod_Direct3DCreate9Ex( UINT SDKVersion, IDirect3D9Ex **ppD3D) // BEGIN - LoadOriginalDll(); + LoadOriginal_DX9_Dll(); /* if (Direct3DCreate9_fn!=NULL) { @@ -385,8 +287,8 @@ HRESULT APIENTRY uMod_Direct3DCreate9Ex( UINT SDKVersion, IDirect3D9Ex **ppD3D) Direct3DCreate9_fn = (Direct3DCreate9_type) GetProcAddress( gl_hOriginalDll, "Direct3DCreate9"); } */ - RetourFunc((BYTE*) GetProcAddress( gl_hOriginalDll, "Direct3DCreate9Ex"), (BYTE*)Direct3DCreate9Ex_fn, 7); - Direct3DCreate9Ex_fn = (Direct3DCreate9Ex_type) GetProcAddress( gl_hOriginalDll, "Direct3DCreate9Ex"); + RetourFunc((BYTE*) GetProcAddress( gl_hOriginal_DX9_Dll, "Direct3DCreate9Ex"), (BYTE*)Direct3DCreate9Ex_fn, 7); + Direct3DCreate9Ex_fn = (Direct3DCreate9Ex_type) GetProcAddress( gl_hOriginal_DX9_Dll, "Direct3DCreate9Ex"); // END IDirect3D9Ex *pIDirect3D9Ex_orig = NULL; @@ -417,100 +319,5 @@ HRESULT APIENTRY uMod_Direct3DCreate9Ex( UINT SDKVersion, IDirect3D9Ex **ppD3D) return (ret); } -bool HookThisProgram( wchar_t *ret) -{ - wchar_t Executable[MAX_PATH]; - wchar_t Game[MAX_PATH]; - GetModuleFileNameW( GetModuleHandle( NULL ), Executable, MAX_PATH ); //ask for name and path of this executable -#ifdef HOOK_INJECTION - //we use the gloabal hook - - FILE* file; - wchar_t *app_path = _wgetenv( L"APPDATA"); //asc for the user application directory - wchar_t file_name[MAX_PATH]; - swprintf_s( file_name, MAX_PATH, L"%ls\\%ls\\%ls", app_path, uMod_APP_DIR, uMod_APP_DX9); - if (_wfopen_s( &file, file_name, L"rt,ccs=UTF-16LE")) return (false); // open the file in utf-16 LE mode - - - //MessageBoxW( NULL, Executable, L"test", 0); - while (!feof(file)) - { - if ( fgetws( Game, MAX_PATH, file) != NULL ) //get each line of the file - { - //MessageBoxW( NULL, Game, L"test", 0); - int len = 0; - while (Game[len]) - { - if (Game[len]==L'\r' || Game[len]==L'\n') {Game[len]=0; break;} //removing the new line symbols - len++; - } - if ( _wcsicmp( Executable, Game ) == 0 ) //compare both strings - { - for (int i=0; i #ifndef uMod_DX9_DLL_H_ #define uMod_DX9_DLL_H_ -void InitInstance(HINSTANCE hModule); -void ExitInstance(void); -void LoadOriginalDll(void); -bool HookThisProgram( wchar_t *ret); -DWORD WINAPI ServerThread( LPVOID lpParam); - +#include "../uMod_DXMain/uMod_Main.h" +void LoadOriginal_DX9_Dll(void); +void InitDX9(); +void ExitDX9(); #ifndef NO_INJECTION -void *DetourFunc(BYTE *src, const BYTE *dst, const int len); -bool RetourFunc(BYTE *src, BYTE *restore, const int len); IDirect3D9 *APIENTRY uMod_Direct3DCreate9(UINT SDKVersion); HRESULT APIENTRY uMod_Direct3DCreate9Ex( UINT SDKVersion, IDirect3D9Ex **ppD3D); -#ifdef HOOK_INJECTION -LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam); -void InstallHook(void); -void RemoveHook(void); -#endif - - -#ifdef DIRECT_INJECTION -void Nothing(void); -#endif - #endif #endif diff --git a/uMod_DX9/uMod_IDirect3D9.cpp b/uMod_DX9/uMod_IDirect3D9.cpp index ac415a4..dd1e700 100644 --- a/uMod_DX9/uMod_IDirect3D9.cpp +++ b/uMod_DX9/uMod_IDirect3D9.cpp @@ -20,7 +20,9 @@ along with Universal Modding Engine. If not, see -#include "uMod_Main.h" +#include "..\uMod_DXMain\uMod_Main.h" +#include "uMod_IDirect3D9.h" +#include "uMod_IDirect3DDevice9.h" #ifndef PRE_MESSAGE #define PRE_MESSAGE "uMod_IDirect3D9" diff --git a/uMod_DX9/uMod_IDirect3D9.h b/uMod_DX9/uMod_IDirect3D9.h index b6ff69b..cafb670 100644 --- a/uMod_DX9/uMod_IDirect3D9.h +++ b/uMod_DX9/uMod_IDirect3D9.h @@ -30,8 +30,7 @@ along with Universal Modding Engine. If not, see #include #include -#include "uMod_TextureServer.h" -#include "uMod_TextureClient.h" +#include "..\uMod_DXMain\uMod_TextureServer.h" class uMod_IDirect3D9 : public IDirect3D9 { diff --git a/uMod_DX9/uMod_IDirect3D9Ex.cpp b/uMod_DX9/uMod_IDirect3D9Ex.cpp index 0259b3e..f9ce98a 100644 --- a/uMod_DX9/uMod_IDirect3D9Ex.cpp +++ b/uMod_DX9/uMod_IDirect3D9Ex.cpp @@ -20,7 +20,10 @@ along with Universal Modding Engine. If not, see -#include "uMod_Main.h" +#include "../uMod_DXMain/uMod_Main.h" +#include "uMod_IDirect3D9Ex.h" +#include "uMod_IDirect3DDevice9.h" +#include "uMod_IDirect3DDevice9Ex.h" @@ -29,6 +32,8 @@ along with Universal Modding Engine. If not, see #define m_pIDirect3D9 m_pIDirect3D9Ex #define PRE_MESSAGE "uMod_IDirect3D9Ex" +#define uMod_IDirect3D9_H_ + #include "uMod_IDirect3D9.cpp" diff --git a/uMod_DX9/uMod_IDirect3D9Ex.h b/uMod_DX9/uMod_IDirect3D9Ex.h index aab671c..772cd75 100644 --- a/uMod_DX9/uMod_IDirect3D9Ex.h +++ b/uMod_DX9/uMod_IDirect3D9Ex.h @@ -30,8 +30,8 @@ along with Universal Modding Engine. If not, see #include #include -#include "uMod_TextureServer.h" -#include "uMod_TextureClient.h" +#include "..\uMod_DXMain\uMod_TextureServer.h" + class uMod_IDirect3D9Ex : public IDirect3D9Ex { diff --git a/uMod_DX9/uMod_IDirect3DCubeTexture9.cpp b/uMod_DX9/uMod_IDirect3DCubeTexture9.cpp index 169ff96..6898934 100644 --- a/uMod_DX9/uMod_IDirect3DCubeTexture9.cpp +++ b/uMod_DX9/uMod_IDirect3DCubeTexture9.cpp @@ -22,7 +22,10 @@ along with Universal Modding Engine. If not, see */ -#include "uMod_Main.h" +#include "../uMod_DXMain/uMod_Main.h" +#include "../uMod_DXMain/uMod_TextureFunction.h" +#include "uMod_IDirect3DDevice9.h" +#include "uMod_IDirect3DCubeTexture9.h" //this function yields for the non switched texture object HRESULT APIENTRY uMod_IDirect3DCubeTexture9::QueryInterface(REFIID riid, void** ppvObj) diff --git a/uMod_DX9/uMod_IDirect3DCubeTexture9.h b/uMod_DX9/uMod_IDirect3DCubeTexture9.h index 67678a1..18862a5 100644 --- a/uMod_DX9/uMod_IDirect3DCubeTexture9.h +++ b/uMod_DX9/uMod_IDirect3DCubeTexture9.h @@ -31,7 +31,7 @@ along with Universal Modding Engine. If not, see #include #include -#include "uMod_Defines.h" +#include "..\uMod_DXMain\uMod_Defines.h" diff --git a/uMod_DX9/uMod_IDirect3DDevice9.cpp b/uMod_DX9/uMod_IDirect3DDevice9.cpp index 9d04ca1..ac36b90 100644 --- a/uMod_DX9/uMod_IDirect3DDevice9.cpp +++ b/uMod_DX9/uMod_IDirect3DDevice9.cpp @@ -18,7 +18,8 @@ along with Universal Modding Engine. If not, see -#include "uMod_Main.h" +#include "..\uMod_DXMain\uMod_Main.h" +#include "uMod_IDirect3DDevice9.h" #ifndef RETURN_QueryInterface #define RETURN_QueryInterface 0x01000000L @@ -28,6 +29,10 @@ along with Universal Modding Engine. If not, see #define PRE_MESSAGE "uMod_IDirect3DDevice9" #endif +#ifndef DEF_DX_VERSION +#define DEF_DX_VERSION VERSION_DX9 +#endif + int uMod_IDirect3DDevice9::CreateSingleTexture(void) { @@ -136,7 +141,8 @@ uMod_IDirect3DDevice9::uMod_IDirect3DDevice9( IDirect3DDevice9* pOriginal, uMod_ NormalRendering = true; uMod_Server = server; - uMod_Client = new uMod_TextureClient( uMod_Server, this); //get a new texture client for this device + uMod_Client = new uMod_TextureClient_DX9( this, DEF_DX_VERSION); //get a new texture client for this device + uMod_Client->ConnectToServer( uMod_Server); LastCreatedTexture = NULL; LastCreatedVolumeTexture = NULL; diff --git a/uMod_DX9/uMod_IDirect3DDevice9.h b/uMod_DX9/uMod_IDirect3DDevice9.h index aaa10ea..e247c7c 100644 --- a/uMod_DX9/uMod_IDirect3DDevice9.h +++ b/uMod_DX9/uMod_IDirect3DDevice9.h @@ -28,12 +28,13 @@ along with Universal Modding Engine. If not, see #ifndef uMod_IDirect3DDevice9_H_ #define uMod_IDirect3DDevice9_H_ -#include -#include +#include "..\uMod_DXMain\uMod_Main.h" +#include "uMod_TextureClient_DX9.h" #include "uMod_IDirect3DTexture9.h" #include "uMod_IDirect3DVolumeTexture9.h" #include "uMod_IDirect3DCubeTexture9.h" +class uMod_TextureClient_DX9; class uMod_IDirect3DDevice9 : public IDirect3DDevice9 { @@ -165,7 +166,7 @@ public: - uMod_TextureClient* GetuMod_Client(void) {return (uMod_Client);} + uMod_TextureClient_DX9* GetuMod_Client(void) {return (uMod_Client);} uMod_IDirect3DTexture9* GetLastCreatedTexture(void) {return (LastCreatedTexture);} int SetLastCreatedTexture(uMod_IDirect3DTexture9* pTexture) {LastCreatedTexture=pTexture; return (RETURN_OK);} @@ -205,7 +206,7 @@ public: uMod_IDirect3DCubeTexture9* LastCreatedCubeTexture; uMod_TextureServer* uMod_Server; - uMod_TextureClient* uMod_Client; + uMod_TextureClient_DX9* uMod_Client; }; #endif diff --git a/uMod_DX9/uMod_IDirect3DDevice9Ex.cpp b/uMod_DX9/uMod_IDirect3DDevice9Ex.cpp index 1cf90e7..c712410 100644 --- a/uMod_DX9/uMod_IDirect3DDevice9Ex.cpp +++ b/uMod_DX9/uMod_IDirect3DDevice9Ex.cpp @@ -18,7 +18,8 @@ along with Universal Modding Engine. If not, see -#include "uMod_Main.h" +#include "..\uMod_DXMain\uMod_Main.h" +#include "uMod_IDirect3DDevice9Ex.h" #define uMod_IDirect3DDevice9 uMod_IDirect3DDevice9Ex #define IDirect3DDevice9 IDirect3DDevice9Ex @@ -26,7 +27,9 @@ along with Universal Modding Engine. If not, see #define RETURN_QueryInterface 0x01000001L #define PRE_MESSAGE "uMod_IDirect3DDevice9Ex" +#define DEF_DX_VERSION VERSION_DX9EX +#define uMod_IDirect3DDevice9_H_ #include "uMod_IDirect3DDevice9.cpp" diff --git a/uMod_DX9/uMod_IDirect3DDevice9Ex.h b/uMod_DX9/uMod_IDirect3DDevice9Ex.h index c7daeca..a1d2137 100644 --- a/uMod_DX9/uMod_IDirect3DDevice9Ex.h +++ b/uMod_DX9/uMod_IDirect3DDevice9Ex.h @@ -20,12 +20,13 @@ along with Universal Modding Engine. If not, see #ifndef uMod_IDirect3DDevice9Ex_H_ #define uMod_IDirect3DDevice9Ex_H_ -#include -#include +#include "..\uMod_DXMain\uMod_Main.h" +#include "uMod_TextureClient_DX9.h" #include "uMod_IDirect3DTexture9.h" #include "uMod_IDirect3DVolumeTexture9.h" #include "uMod_IDirect3DCubeTexture9.h" +class uMod_TextureClient_DX9; class uMod_IDirect3DDevice9Ex : public IDirect3DDevice9Ex { @@ -177,7 +178,7 @@ public: // END: The original DX9 function definitions - uMod_TextureClient* GetuMod_Client(void) {return (uMod_Client);} + uMod_TextureClient_DX9* GetuMod_Client(void) {return (uMod_Client);} uMod_IDirect3DTexture9* GetLastCreatedTexture(void) {return (LastCreatedTexture);} int SetLastCreatedTexture(uMod_IDirect3DTexture9* pTexture) {LastCreatedTexture=pTexture; return (RETURN_OK);} @@ -218,7 +219,7 @@ public: uMod_IDirect3DCubeTexture9* LastCreatedCubeTexture; uMod_TextureServer* uMod_Server; - uMod_TextureClient* uMod_Client; + uMod_TextureClient_DX9* uMod_Client; }; #endif diff --git a/uMod_DX9/uMod_IDirect3DTexture9.cpp b/uMod_DX9/uMod_IDirect3DTexture9.cpp index d2a8506..aabf1bd 100644 --- a/uMod_DX9/uMod_IDirect3DTexture9.cpp +++ b/uMod_DX9/uMod_IDirect3DTexture9.cpp @@ -22,7 +22,10 @@ along with Universal Modding Engine. If not, see */ -#include "uMod_Main.h" +#include "../uMod_DXMain/uMod_Main.h" +#include "../uMod_DXMain/uMod_TextureFunction.h" +#include "uMod_IDirect3DDevice9.h" +#include "uMod_IDirect3DTexture9.h" //this function yields for the non switched texture object HRESULT APIENTRY uMod_IDirect3DTexture9::QueryInterface(REFIID riid, void** ppvObj) diff --git a/uMod_DX9/uMod_IDirect3DTexture9.h b/uMod_DX9/uMod_IDirect3DTexture9.h index bef1bec..9827677 100644 --- a/uMod_DX9/uMod_IDirect3DTexture9.h +++ b/uMod_DX9/uMod_IDirect3DTexture9.h @@ -31,7 +31,7 @@ along with Universal Modding Engine. If not, see #include #include -#include "uMod_Defines.h" +#include "..\uMod_DXMain\uMod_Defines.h" diff --git a/uMod_DX9/uMod_IDirect3DVolumeTexture9.cpp b/uMod_DX9/uMod_IDirect3DVolumeTexture9.cpp index a9942eb..353b34d 100644 --- a/uMod_DX9/uMod_IDirect3DVolumeTexture9.cpp +++ b/uMod_DX9/uMod_IDirect3DVolumeTexture9.cpp @@ -22,7 +22,10 @@ along with Universal Modding Engine. If not, see */ -#include "uMod_Main.h" +#include "../uMod_DXMain/uMod_Main.h" +#include "../uMod_DXMain/uMod_TextureFunction.h" +#include "uMod_IDirect3DDevice9.h" +#include "uMod_IDirect3DVolumeTexture9.h" HRESULT APIENTRY uMod_IDirect3DVolumeTexture9::QueryInterface(REFIID riid, void** ppvObj) { diff --git a/uMod_DX9/uMod_IDirect3DVolumeTexture9.h b/uMod_DX9/uMod_IDirect3DVolumeTexture9.h index 0c2c81a..262bfe1 100644 --- a/uMod_DX9/uMod_IDirect3DVolumeTexture9.h +++ b/uMod_DX9/uMod_IDirect3DVolumeTexture9.h @@ -31,7 +31,7 @@ along with Universal Modding Engine. If not, see #include #include -#include "uMod_Defines.h" +#include "..\uMod_DXMain\uMod_Defines.h" diff --git a/uMod_DX9/uMod_TextureClient_DX9.cpp b/uMod_DX9/uMod_TextureClient_DX9.cpp index cf493f9..52c5d3e 100644 --- a/uMod_DX9/uMod_TextureClient_DX9.cpp +++ b/uMod_DX9/uMod_TextureClient_DX9.cpp @@ -18,51 +18,22 @@ along with Universal Modding Engine. If not, see -#include "uMod_Main.h" +#include "..\uMod_DXMain\uMod_Main.h" +#include "uMod_TextureClient_DX9.h" -uMod_TextureClient::uMod_TextureClient(uMod_TextureServer* server, IDirect3DDevice9* device) +uMod_TextureClient_DX9::uMod_TextureClient_DX9( IDirect3DDevice9* device, const int version) + : uMod_TextureClient( version) { - Message("uMod_TextureClient::uMod_TextureClient(void): %lu\n", this); - Server = server; + Message("uMod_TextureClient_DX9::uMod_TextureClient_DX9(void): %lu\n", this); D3D9Device = device; - BoolSaveAllTextures = false; - BoolSaveSingleTexture = false; - KeyBack = 0; - KeySave = 0; - KeyNext = 0; - SavePath[0]=0; - GameName[0]=0; - - NumberToMod = 0; - FileToMod = NULL; - - if (Server!=NULL) - { - if (Server->AddClient( this, &FileToMod, &NumberToMod)) - { - Server=NULL; - NumberToMod = 0; - FileToMod = NULL; - } - else - { - for (int i=0; iRemoveClient(this); + Message("uMod_TextureClient_DX9::~uMod_TextureClient(void): %lu\n", this); + if (Server!=NULL) Server->RemoveClient( this, Version); if (Mutex!=NULL) CloseHandle(Mutex); @@ -75,7 +46,7 @@ uMod_TextureClient::~uMod_TextureClient(void) } -int uMod_TextureClient::AddTexture( uMod_IDirect3DTexture9* pTexture) +int uMod_TextureClient_DX9::AddTexture( uMod_IDirect3DTexture9* pTexture) { void *cpy; long ret = D3D9Device->QueryInterface( IID_IDirect3DTexture9, &cpy); @@ -84,7 +55,7 @@ int uMod_TextureClient::AddTexture( uMod_IDirect3DTexture9* pTexture) if (pTexture->FAKE) return (RETURN_OK); // this is a fake texture - Message("uMod_TextureClient::AddTexture( %lu): %lu (thread: %lu)\n", pTexture, this, GetCurrentThreadId()); + Message("uMod_TextureClient_DX9::AddTexture( %lu): %lu (thread: %lu)\n", pTexture, this, GetCurrentThreadId()); MyTypeHash hash; if (int ret = pTexture->GetHash( hash)) @@ -105,7 +76,7 @@ int uMod_TextureClient::AddTexture( uMod_IDirect3DTexture9* pTexture) return (LookUpToMod(pTexture)); // check if this texture should be modded } -int uMod_TextureClient::AddTexture( uMod_IDirect3DVolumeTexture9* pTexture) +int uMod_TextureClient_DX9::AddTexture( uMod_IDirect3DVolumeTexture9* pTexture) { void *cpy; long ret = D3D9Device->QueryInterface( IID_IDirect3DTexture9, &cpy); @@ -114,7 +85,7 @@ int uMod_TextureClient::AddTexture( uMod_IDirect3DVolumeTexture9* pTexture) if (pTexture->FAKE) return (RETURN_OK); // this is a fake texture - Message("uMod_TextureClient::AddTexture( Volume: %lu): %lu (thread: %lu)\n", pTexture, this, GetCurrentThreadId()); + Message("uMod_TextureClient_DX9::AddTexture( Volume: %lu): %lu (thread: %lu)\n", pTexture, this, GetCurrentThreadId()); MyTypeHash hash; if (int ret = pTexture->GetHash( hash)) @@ -135,7 +106,7 @@ int uMod_TextureClient::AddTexture( uMod_IDirect3DVolumeTexture9* pTexture) return (LookUpToMod(pTexture)); // check if this texture should be modded } -int uMod_TextureClient::AddTexture( uMod_IDirect3DCubeTexture9* pTexture) +int uMod_TextureClient_DX9::AddTexture( uMod_IDirect3DCubeTexture9* pTexture) { void *cpy; long ret = D3D9Device->QueryInterface( IID_IDirect3DTexture9, &cpy); @@ -144,7 +115,7 @@ int uMod_TextureClient::AddTexture( uMod_IDirect3DCubeTexture9* pTexture) if (pTexture->FAKE) return (RETURN_OK); // this is a fake texture - Message("uMod_TextureClient::AddTexture( Cube: %lu): %lu (thread: %lu)\n", pTexture, this, GetCurrentThreadId()); + Message("uMod_TextureClient_DX9::AddTexture( Cube: %lu): %lu (thread: %lu)\n", pTexture, this, GetCurrentThreadId()); MyTypeHash hash; if (int ret = pTexture->GetHash( hash)) @@ -166,9 +137,9 @@ int uMod_TextureClient::AddTexture( uMod_IDirect3DCubeTexture9* pTexture) } -int uMod_TextureClient::CheckAgainNonAdded(void) +int uMod_TextureClient_DX9::CheckAgainNonAdded(void) { - Message("uMod_TextureClient::CheckAgainNonAdded( %u, %u, %u): %lu\n", NonAdded_OriginalTextures.GetNumber(), + Message("uMod_TextureClient_DX9::CheckAgainNonAdded( %u, %u, %u): %lu\n", NonAdded_OriginalTextures.GetNumber(), NonAdded_OriginalVolumeTextures.GetNumber(), NonAdded_OriginalCubeTextures.GetNumber(), this); Bool_CheckAgainNonAdded = false; @@ -214,13 +185,13 @@ int uMod_TextureClient::CheckAgainNonAdded(void) LookUpToMod(pTexture); // check if this texture should be modded } } - Message("uMod_TextureClient::CheckAgainNonAdded() END: %lu\n", this); + Message("uMod_TextureClient_DX9::CheckAgainNonAdded() END: %lu\n", this); return (RETURN_OK); } -int uMod_TextureClient::RemoveTexture( uMod_IDirect3DTexture9* pTexture) // is called from a texture, if it is finally released +int uMod_TextureClient_DX9::RemoveTexture( uMod_IDirect3DTexture9* pTexture) // is called from a texture, if it is finally released { - Message("uMod_TextureClient::RemoveTexture( %lu, %#lX): %lu\n", pTexture, pTexture->Hash, this); + Message("uMod_TextureClient_DX9::RemoveTexture( %lu, %#lX): %lu\n", pTexture, pTexture->Hash, this); if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR); if (pTexture->FAKE) @@ -246,9 +217,9 @@ int uMod_TextureClient::RemoveTexture( uMod_IDirect3DTexture9* pTexture) // is c return (RETURN_OK); } -int uMod_TextureClient::RemoveTexture( uMod_IDirect3DVolumeTexture9* pTexture) // is called from a texture, if it is finally released +int uMod_TextureClient_DX9::RemoveTexture( uMod_IDirect3DVolumeTexture9* pTexture) // is called from a texture, if it is finally released { - Message("uMod_TextureClient::RemoveTexture( Volume %lu, %#lX): %lu\n", pTexture, pTexture->Hash, this); + Message("uMod_TextureClient_DX9::RemoveTexture( Volume %lu, %#lX): %lu\n", pTexture, pTexture->Hash, this); if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR); if (pTexture->FAKE) @@ -274,9 +245,9 @@ int uMod_TextureClient::RemoveTexture( uMod_IDirect3DVolumeTexture9* pTexture) / return (RETURN_OK); } -int uMod_TextureClient::RemoveTexture( uMod_IDirect3DCubeTexture9* pTexture) // is called from a texture, if it is finally released +int uMod_TextureClient_DX9::RemoveTexture( uMod_IDirect3DCubeTexture9* pTexture) // is called from a texture, if it is finally released { - Message("uMod_TextureClient::RemoveTexture( Cube %lu, %#lX): %lu\n", pTexture, pTexture->Hash, this); + Message("uMod_TextureClient_DX9::RemoveTexture( Cube %lu, %#lX): %lu\n", pTexture, pTexture->Hash, this); if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR); if (pTexture->FAKE) @@ -303,16 +274,16 @@ int uMod_TextureClient::RemoveTexture( uMod_IDirect3DCubeTexture9* pTexture) // } -int uMod_TextureClient::SaveAllTextures(bool val) +int uMod_TextureClient_DX9::SaveAllTextures(bool val) { - Message("uMod_TextureClient::SaveAllTextures( %d): %lu\n", val, this); + Message("uMod_TextureClient_DX9::SaveAllTextures( %d): %lu\n", val, this); BoolSaveAllTextures=val; return (RETURN_OK); } -int uMod_TextureClient::SaveSingleTexture(bool val) +int uMod_TextureClient_DX9::SaveSingleTexture(bool val) { - Message("uMod_TextureClient::SaveSingleTexture( %d): %lu\n", val, this); + Message("uMod_TextureClient_DX9::SaveSingleTexture( %d): %lu\n", val, this); if (BoolSaveSingleTexture && !val) //if BoolSaveSingleTexture is set to false and was previously true we switch the SingleTexture back { uMod_IDirect3DTexture9* pTexture; @@ -328,99 +299,55 @@ int uMod_TextureClient::SaveSingleTexture(bool val) } -int uMod_TextureClient::SetSaveDirectory( wchar_t *dir) -{ - Message("uMod_TextureClient::SetSaveDirectory( %ls): %lu\n", dir, this); - int i = 0; - for (i=0; iHash, pTexture->m_D3Dtex, this); return (RETURN_TEXTURE_NOT_SAVED);} + if (SavePath[0]==0) {Message("uMod_TextureClient_DX9::SaveTexture( %#lX, %lu): %lu, SavePath not set\n", pTexture->Hash, pTexture->m_D3Dtex, this); return (RETURN_TEXTURE_NOT_SAVED);} wchar_t file[MAX_PATH]; if (GameName[0]) swprintf_s( file, MAX_PATH, L"%ls\\%ls_T_%#lX.dds", SavePath, GameName, pTexture->Hash); else swprintf_s( file, MAX_PATH, L"%ls\\T_%#lX.dds", SavePath, pTexture->Hash); - Message("uMod_TextureClient::SaveTexture( %ls): %lu\n", file, this); + Message("uMod_TextureClient_DX9::SaveTexture( %ls): %lu\n", file, this); if (D3D_OK!=D3DXSaveTextureToFileW( file, D3DXIFF_DDS, pTexture->m_D3Dtex, NULL)) return (RETURN_TEXTURE_NOT_SAVED); return (RETURN_OK); } -int uMod_TextureClient::SaveTexture(uMod_IDirect3DVolumeTexture9* pTexture) +int uMod_TextureClient_DX9::SaveTexture(uMod_IDirect3DVolumeTexture9* pTexture) { if (pTexture==NULL) return (RETURN_BAD_ARGUMENT); - if (SavePath[0]==0) {Message("uMod_TextureClient::SaveTexture( %#lX, %lu): %lu, SavePath not set\n", pTexture->Hash, pTexture->m_D3Dtex, this); return (RETURN_TEXTURE_NOT_SAVED);} + if (SavePath[0]==0) {Message("uMod_TextureClient_DX9::SaveTexture( %#lX, %lu): %lu, SavePath not set\n", pTexture->Hash, pTexture->m_D3Dtex, this); return (RETURN_TEXTURE_NOT_SAVED);} wchar_t file[MAX_PATH]; if (GameName[0]) swprintf_s( file, MAX_PATH, L"%ls\\%ls_V_%#lX.dds", SavePath, GameName, pTexture->Hash); else swprintf_s( file, MAX_PATH, L"%ls\\V_%#lX.dds", SavePath, pTexture->Hash); - Message("uMod_TextureClient::SaveTexture( %ls): %lu\n", file, this); + Message("uMod_TextureClient_DX9::SaveTexture( %ls): %lu\n", file, this); if (D3D_OK!=D3DXSaveTextureToFileW( file, D3DXIFF_DDS, pTexture->m_D3Dtex, NULL)) return (RETURN_TEXTURE_NOT_SAVED); return (RETURN_OK); } -int uMod_TextureClient::SaveTexture(uMod_IDirect3DCubeTexture9* pTexture) +int uMod_TextureClient_DX9::SaveTexture(uMod_IDirect3DCubeTexture9* pTexture) { if (pTexture==NULL) return (RETURN_BAD_ARGUMENT); - if (SavePath[0]==0) {Message("uMod_TextureClient::SaveTexture( %#lX, %lu): %lu, SavePath not set\n", pTexture->Hash, pTexture->m_D3Dtex, this); return (RETURN_TEXTURE_NOT_SAVED);} + if (SavePath[0]==0) {Message("uMod_TextureClient_DX9::SaveTexture( %#lX, %lu): %lu, SavePath not set\n", pTexture->Hash, pTexture->m_D3Dtex, this); return (RETURN_TEXTURE_NOT_SAVED);} wchar_t file[MAX_PATH]; if (GameName[0]) swprintf_s( file, MAX_PATH, L"%ls\\%ls_C_%#lX.dds", SavePath, GameName, pTexture->Hash); else swprintf_s( file, MAX_PATH, L"%ls\\C_%#lX.dds", SavePath, pTexture->Hash); - Message("uMod_TextureClient::SaveTexture( %ls): %lu\n", file, this); + Message("uMod_TextureClient_DX9::SaveTexture( %ls): %lu\n", file, this); if (D3D_OK!=D3DXSaveTextureToFileW( file, D3DXIFF_DDS, pTexture->m_D3Dtex, NULL)) return (RETURN_TEXTURE_NOT_SAVED); return (RETURN_OK); } - - -int uMod_TextureClient::AddUpdate(TextureFileStruct* update, int number) //client must delete the update array -{ - Message("AddUpdate( %lu, %d): %lu\n", update, number, this); - if (int ret = LockMutex()) {gl_ErrorState |= uMod_ERROR_TEXTURE; return (ret);} - if (Update!=NULL) delete [] Update; - Update = update; - NumberOfUpdate = number; - return (UnlockMutex()); -} - - - -int uMod_TextureClient::MergeUpdate(void) +int uMod_TextureClient_DX9::MergeUpdate(void) { if (NumberOfUpdate<0) {return (RETURN_OK);} if (int ret = LockMutex()) {gl_ErrorState |= uMod_ERROR_TEXTURE ; return (ret);} - Message("uMod_TextureClient::MergeUpdate(): %lu\n", this); + Message("uMod_TextureClient_DX9::MergeUpdate(): %lu\n", this); for (int i=0; i=0; i--) FileToMod[pos_old].Textures[i]->Release(); // we release the fake textures + for (int i=FileToMod[pos_old].NumberOfTextures-1; i>=0; i--) + ((IDirect3DBaseTexture9*) FileToMod[pos_old].Textures[i])->Release(); // we release the fake textures if (FileToMod[pos_old].Textures!=NULL) delete [] FileToMod[pos_old].Textures; // we delete the memory FileToMod[pos_old].NumberOfTextures = 0; FileToMod[pos_old].Textures = NULL; @@ -464,12 +392,12 @@ int uMod_TextureClient::MergeUpdate(void) { if (FileToMod[pos_old].NumberOfTextures>0) { - Update[pos_new].Textures = new IDirect3DBaseTexture9*[FileToMod[pos_old].NumberOfTextures]; + Update[pos_new].Textures = (void**) new IDirect3DBaseTexture9*[FileToMod[pos_old].NumberOfTextures]; } for (int i=0; iQueryInterface( IID_IDirect3D9, (void**)&base_texture); + int ret = ((IDirect3DBaseTexture9*) FileToMod[pos_old].Textures[i])->QueryInterface( IID_IDirect3D9, (void**)&base_texture); switch (ret) { case 0x01000000L: @@ -555,7 +483,8 @@ int uMod_TextureClient::MergeUpdate(void) while (pos_old=0; i--) FileToMod[pos_old].Textures[i]->Release(); // we release the fake textures + for (int i=FileToMod[pos_old].NumberOfTextures-1; i>=0; i--) + ((IDirect3DBaseTexture9*) FileToMod[pos_old].Textures[i])->Release(); // we release the fake textures //for (int i=0; iRelease(); // we release the fake textures if (FileToMod[pos_old].Textures!=NULL) delete [] FileToMod[pos_old].Textures; // we delete the memory FileToMod[pos_old].Textures = NULL; @@ -619,7 +548,7 @@ int uMod_TextureClient::MergeUpdate(void) if (to_lookup != NULL) delete [] to_lookup; - Message("uMod_TextureClient::MergeUpdate() END: %lu\n", this); + Message("uMod_TextureClient_DX9::MergeUpdate() END: %lu\n", this); CheckAgainNonAdded(); return (UnlockMutex()); @@ -627,104 +556,27 @@ int uMod_TextureClient::MergeUpdate(void) -int uMod_TextureClient::LockMutex(void) +int uMod_TextureClient_DX9::LookUpToMod( uMod_IDirect3DTexture9* pTexture, int num_index_list, int *index_list) // should only be called for original textures { - if (( gl_ErrorState & (uMod_ERROR_FATAL | uMod_ERROR_MUTEX) )) return (RETURN_NO_MUTEX); - if (WAIT_OBJECT_0!=WaitForSingleObject( Mutex, 100)) return (RETURN_MUTEX_LOCK); //waiting 100ms, to wait infinite pass INFINITE - return (RETURN_OK); -} - -int uMod_TextureClient::UnlockMutex(void) -{ - if (ReleaseMutex(Mutex)==0) return (RETURN_MUTEX_UNLOCK); - return (RETURN_OK); -} - - - - - -int uMod_TextureClient::LookUpToMod( MyTypeHash hash, int num_index_list, int *index_list) -{ - if(NumberToMod>0) - { - if (index_list==NULL || num_index_list==0) - { - if (hashFileToMod[NumberToMod-1].Hash) return (-1); - int pos = NumberToMod/2; - int begin = 0; - int end = NumberToMod-1; - - // We look in the middle of the interval and each step we halve the interval, - // unless we find the texture or the size of the interval is less than 3. - // Note: contradicting to normal C-code here the interval includes the index "begin" and "end"! - while (begin+1 FileToMod[pos].Hash) // the new interval is the right half of the actual interval - { - begin = pos+1; // the new interval does not contain the index "pos" - pos = (begin + end)/2; // set "pos" somewhere inside the new interval - } - else if (hash < FileToMod[pos].Hash) // the new interval is the left half of the actual interval - { - end = pos-1; // the new interval does not contain the index "pos" - pos = (begin + end)/2; // set "pos" somewhere inside the new interval - } - else {return (pos); break;} // we hit the correct hash - } - for ( pos=begin; pos<=end; pos++) if (FileToMod[pos].Hash==hash) return (pos); - } - else - { - if (hashFileToMod[index_list[num_index_list-1]].Hash) return (-1); - int pos = num_index_list/2; - int begin = 0; - int end = num_index_list-1; - - // We look in the middle of the interval and each step we halve the interval, - // unless we find the texture or the size of the interval is less than 3. - // Note: contradicting to normal C-code here the interval includes the index "begin" and "end"! - while (begin+1 FileToMod[index_list[pos]].Hash) // the new interval is the right half of the actual interval - { - begin = pos+1; // the new interval does not contain the index "pos" - pos = (begin + end)/2; // set "pos" somewhere inside the new interval - } - else if (hash < FileToMod[index_list[pos]].Hash) // the new interval is the left half of the actual interval - { - end = pos-1; // the new interval does not contain the index "pos" - pos = (begin + end)/2; // set "pos" somewhere inside the new interval - } - else {return (index_list[pos]); break;} // we hit the correct hash - } - for ( pos=begin; pos<=end; pos++) if (FileToMod[index_list[pos]].Hash==hash) return (index_list[pos]); - } - } - return (-1); -} - -int uMod_TextureClient::LookUpToMod( uMod_IDirect3DTexture9* pTexture, int num_index_list, int *index_list) // should only be called for original textures -{ - Message("uMod_TextureClient::LookUpToMod( %lu): hash: %#lX, %lu\n", pTexture, pTexture->Hash, this); + Message("uMod_TextureClient_DX9::LookUpToMod( %lu): hash: %#lX, %lu\n", pTexture, pTexture->Hash, this); if (pTexture->CrossRef_D3Dtex!=NULL) return (RETURN_OK); // bug, this texture is already switched - int index = LookUpToMod( pTexture->Hash, num_index_list, index_list); + int index = GetIndex( pTexture->Hash, num_index_list, index_list); if (index>=0) { uMod_IDirect3DTexture9 *fake_Texture; if (int ret = LoadTexture( & (FileToMod[index]), &fake_Texture)) return (ret); if (SwitchTextures( fake_Texture, pTexture)) { - Message("uMod_TextureClient::LookUpToMod(): textures not switched %#lX\n", FileToMod[index].Hash); + Message("uMod_TextureClient_DX9::LookUpToMod(): textures not switched %#lX\n", FileToMod[index].Hash); fake_Texture->Release(); } else { IDirect3DBaseTexture9 **temp = new IDirect3DBaseTexture9*[FileToMod[index].NumberOfTextures+1]; - for (int j=0; jReference = index; @@ -733,27 +585,27 @@ int uMod_TextureClient::LookUpToMod( uMod_IDirect3DTexture9* pTexture, int num_i return (RETURN_OK); } -int uMod_TextureClient::LookUpToMod( uMod_IDirect3DVolumeTexture9* pTexture, int num_index_list, int *index_list) // should only be called for original textures +int uMod_TextureClient_DX9::LookUpToMod( uMod_IDirect3DVolumeTexture9* pTexture, int num_index_list, int *index_list) // should only be called for original textures { - Message("uMod_TextureClient::LookUpToMod( Volume %lu): hash: %#lX, %lu\n", pTexture, pTexture->Hash, this); + Message("uMod_TextureClient_DX9::LookUpToMod( Volume %lu): hash: %#lX, %lu\n", pTexture, pTexture->Hash, this); if (pTexture->CrossRef_D3Dtex!=NULL) return (RETURN_OK); // bug, this texture is already switched - int index = LookUpToMod( pTexture->Hash, num_index_list, index_list); + int index = GetIndex( pTexture->Hash, num_index_list, index_list); if (index>=0) { uMod_IDirect3DVolumeTexture9 *fake_Texture; if (int ret = LoadTexture( & (FileToMod[index]), &fake_Texture)) return (ret); if (SwitchTextures( fake_Texture, pTexture)) { - Message("uMod_TextureClient::LookUpToMod(): textures not switched %#lX\n", FileToMod[index].Hash); + Message("uMod_TextureClient_DX9::LookUpToMod(): textures not switched %#lX\n", FileToMod[index].Hash); fake_Texture->Release(); } else { IDirect3DBaseTexture9 **temp = new IDirect3DBaseTexture9*[FileToMod[index].NumberOfTextures+1]; - for (int j=0; jReference = index; @@ -762,27 +614,27 @@ int uMod_TextureClient::LookUpToMod( uMod_IDirect3DVolumeTexture9* pTexture, int return (RETURN_OK); } -int uMod_TextureClient::LookUpToMod( uMod_IDirect3DCubeTexture9* pTexture, int num_index_list, int *index_list) // should only be called for original textures +int uMod_TextureClient_DX9::LookUpToMod( uMod_IDirect3DCubeTexture9* pTexture, int num_index_list, int *index_list) // should only be called for original textures { - Message("uMod_TextureClient::LookUpToMod( Cube %lu): hash: %#lX, %lu\n", pTexture, pTexture->Hash, this); + Message("uMod_TextureClient_DX9::LookUpToMod( Cube %lu): hash: %#lX, %lu\n", pTexture, pTexture->Hash, this); if (pTexture->CrossRef_D3Dtex!=NULL) return (RETURN_OK); // bug, this texture is already switched - int index = LookUpToMod( pTexture->Hash, num_index_list, index_list); + int index = GetIndex( pTexture->Hash, num_index_list, index_list); if (index>=0) { uMod_IDirect3DCubeTexture9 *fake_Texture; if (int ret = LoadTexture( & (FileToMod[index]), &fake_Texture)) return (ret); if (SwitchTextures( fake_Texture, pTexture)) { - Message("uMod_TextureClient::LookUpToMod(): textures not switched %#lX\n", FileToMod[index].Hash); + Message("uMod_TextureClient_DX9::LookUpToMod(): textures not switched %#lX\n", FileToMod[index].Hash); fake_Texture->Release(); } else { IDirect3DBaseTexture9 **temp = new IDirect3DBaseTexture9*[FileToMod[index].NumberOfTextures+1]; - for (int j=0; jReference = index; @@ -794,7 +646,7 @@ int uMod_TextureClient::LookUpToMod( uMod_IDirect3DCubeTexture9* pTexture, int n -int uMod_TextureClient::LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DTexture9 **ppTexture) // to load fake texture from a file in memory +int uMod_TextureClient_DX9::LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DTexture9 **ppTexture) // to load fake texture from a file in memory { Message("LoadTexture( %lu, %lu, %#lX): %lu\n", file_in_memory, ppTexture, file_in_memory->Hash, this); if (D3D_OK != D3DXCreateTextureFromFileInMemoryEx( D3D9Device, file_in_memory->pData, file_in_memory->Size, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, (IDirect3DTexture9 **) ppTexture)) @@ -814,7 +666,7 @@ int uMod_TextureClient::LoadTexture( TextureFileStruct* file_in_memory, uMod_IDi return (RETURN_OK); } -int uMod_TextureClient::LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DVolumeTexture9 **ppTexture) // to load fake texture from a file in memory +int uMod_TextureClient_DX9::LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DVolumeTexture9 **ppTexture) // to load fake texture from a file in memory { Message("LoadTexture( Volume %lu, %lu, %#lX): %lu\n", file_in_memory, ppTexture, file_in_memory->Hash, this); if (D3D_OK != D3DXCreateVolumeTextureFromFileInMemoryEx( D3D9Device, file_in_memory->pData, file_in_memory->Size, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, (IDirect3DVolumeTexture9 **) ppTexture)) @@ -834,7 +686,7 @@ int uMod_TextureClient::LoadTexture( TextureFileStruct* file_in_memory, uMod_IDi return (RETURN_OK); } -int uMod_TextureClient::LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DCubeTexture9 **ppTexture) // to load fake texture from a file in memory +int uMod_TextureClient_DX9::LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DCubeTexture9 **ppTexture) // to load fake texture from a file in memory { Message("LoadTexture( Cube %lu, %lu, %#lX): %lu\n", file_in_memory, ppTexture, file_in_memory->Hash, this); if (D3D_OK != D3DXCreateCubeTextureFromFileInMemoryEx( D3D9Device, file_in_memory->pData, file_in_memory->Size, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, (IDirect3DCubeTexture9 **) ppTexture)) diff --git a/uMod_DX9/uMod_TextureClient_DX9.h b/uMod_DX9/uMod_TextureClient_DX9.h index 1d532bf..b6912be 100644 --- a/uMod_DX9/uMod_TextureClient_DX9.h +++ b/uMod_DX9/uMod_TextureClient_DX9.h @@ -18,12 +18,16 @@ along with Universal Modding Engine. If not, see -#ifndef uMod_TEXTUREHANDLER_HPP -#define uMod_TEXTUREHANDLER_HPP +#ifndef uMod_TEXTURECLIENT_DX9_HPP +#define uMod_TEXTURECLIENT_DX9_HPP -#include "uMod_IDirect3DTexture9.h" -#include "uMod_IDirect3DDevice9.h" #include "..\uMod_Error.h" +#include "..\uMod_DXMain\uMod_TextureClient.h" +#include "uMod_IDirect3DTexture9.h" +#include "uMod_IDirect3DVolumeTexture9.h" +#include "uMod_IDirect3DCubeTexture9.h" +#include "uMod_IDirect3DDevice9.h" +#include "uMod_IDirect3DDevice9Ex.h" class uMod_TextureServer; @@ -34,11 +38,11 @@ class uMod_TextureServer; * All other functions are called from the render thread instance of the game itself. */ -class uMod_TextureClient +class uMod_TextureClient_DX9 : public uMod_TextureClient { public: - uMod_TextureClient(uMod_TextureServer* server, IDirect3DDevice9* device); - ~uMod_TextureClient(void); + uMod_TextureClient_DX9( IDirect3DDevice9* device, const int version); + virtual ~uMod_TextureClient_DX9(void); int AddTexture( uMod_IDirect3DTexture9* tex); //called from uMod_IDirect3DDevice9::CreateTexture(...) or uMod_IDirect3DDevice9::BeginScene() int AddTexture( uMod_IDirect3DVolumeTexture9* tex); //called from uMod_IDirect3DVolumeTexture9::CreateTexture(...) or uMod_IDirect3DDevice9::BeginScene() @@ -51,31 +55,19 @@ public: int SaveAllTextures(bool val); //called from the Server int SaveSingleTexture(bool val); //called from the Server - int SetSaveDirectory( wchar_t *dir); //called from the Server - int SetGameName( wchar_t *dir); //called from the Server - int SaveTexture(uMod_IDirect3DTexture9* pTexture); //called from uMod_IDirect3DDevice9::BeginScene() (save button) or from AddTexture(...) (SaveAllTextures) int SaveTexture(uMod_IDirect3DVolumeTexture9* pTexture); //called from uMod_IDirect3DDevice9::BeginScene() (save button) or from AddTexture(...) (SaveAllTextures) int SaveTexture(uMod_IDirect3DCubeTexture9* pTexture); //called from uMod_IDirect3DDevice9::BeginScene() (save button) or from AddTexture(...) (SaveAllTextures) - - - int SetKeyBack( int key) {if (key>0) KeyBack = key; return (RETURN_OK);} //called from the Server - int SetKeySave( int key) {if (key>0) KeySave = key; return (RETURN_OK);} //called from the Server - int SetKeyNext( int key) {if (key>0) KeyNext = key; return (RETURN_OK);} //called from the Server - - int SetFontColour( DWORD r, DWORD g, DWORD b) {FontColour = D3DCOLOR_ARGB(255, r,g,b); return (RETURN_OK);} //called from the Server - int SetTextureColour( DWORD r, DWORD g, DWORD b) {TextureColour = D3DCOLOR_ARGB(255, r,g,b); return (RETURN_OK);} //called from the Server - - - int AddUpdate(TextureFileStruct* update, int number); //called from the Server, client object must delete update array int MergeUpdate(void); //called from uMod_IDirect3DDevice9::BeginScene() - int LookUpToMod( uMod_IDirect3DTexture9* pTexture, int num_index_list=0, int *index_list=NULL); // called at the end AddTexture(...) and from Device->UpdateTexture(...) - int LookUpToMod( uMod_IDirect3DVolumeTexture9* pTexture, int num_index_list=0, int *index_list=NULL); // called at the end AddTexture(...) and from Device->UpdateTexture(...) - int LookUpToMod( uMod_IDirect3DCubeTexture9* pTexture, int num_index_list=0, int *index_list=NULL); // called at the end AddTexture(...) and from Device->UpdateTexture(...) + int LookUpToMod( uMod_IDirect3DTexture9* pTexture, int num_index_list=0, int *index_list=(int*)0); // called at the end AddTexture(...) and from Device->UpdateTexture(...) + + int LookUpToMod( uMod_IDirect3DVolumeTexture9* pTexture, int num_index_list=0, int *index_list=(int*)0); // called at the end AddTexture(...) and from Device->UpdateTexture(...) + + int LookUpToMod( uMod_IDirect3DCubeTexture9* pTexture, int num_index_list=0, int *index_list=(int*)0); // called at the end AddTexture(...) and from Device->UpdateTexture(...) uMod_TextureHandler OriginalTextures; // stores the pointer to the uMod_IDirect3DTexture9 objects created by the game uMod_TextureHandler OriginalVolumeTextures; // stores the pointer to the uMod_IDirect3DVolumeTexture9 objects created by the game @@ -90,33 +82,9 @@ public: uMod_TextureHandler NonAdded_OriginalVolumeTextures; // stores the pointer to the uMod_IDirect3DVolumeTexture9 objects created by the game uMod_TextureHandler NonAdded_OriginalCubeTextures; // stores the pointer to the uMod_IDirect3DCubeTexture9 objects created by the game - bool BoolSaveAllTextures; - bool BoolSaveSingleTexture; - int KeyBack; - int KeySave; - int KeyNext; - - D3DCOLOR FontColour; - D3DCOLOR TextureColour; - private: - uMod_TextureServer* Server; IDirect3DDevice9* D3D9Device; - wchar_t SavePath[MAX_PATH]; - wchar_t GameName[MAX_PATH]; - TextureFileStruct* Update; - int NumberOfUpdate; - - int LockMutex(); - int UnlockMutex(); - HANDLE Mutex; - - int NumberToMod; // number of texture to be modded - TextureFileStruct* FileToMod; // array which stores the file in memory and the hash of each texture to be modded - - - int LookUpToMod( MyTypeHash hash, int num_index_list, int *index_list); // called from LookUpToMod(...); int LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DTexture9 **ppTexture); // called if a target texture is found int LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DVolumeTexture9 **ppTexture); // called if a target texture is found int LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DCubeTexture9 **ppTexture); // called if a target texture is found diff --git a/uMod_DXMain/makefile.gcc b/uMod_DXMain/makefile.gcc new file mode 100644 index 0000000..ade310e --- /dev/null +++ b/uMod_DXMain/makefile.gcc @@ -0,0 +1,153 @@ + + +ifdef DX10 +ifdef DX9 +DX_XX_Flag = /D DEF_USE_DX9 /D DEF_USE_DX10 +DX_XX_File = 9_10 +else +DX_XX_Flag = /D DEF_USE_DX10 +DX_XX_File = 10 +endif + +else +DX_XX_Flag = /D DEF_USE_DX9 +DX_XX_File = 9 +endif + + + +ifdef NI + +ifdef LOG_MESSAGE +precompiler_flag = /D "LOG_MESSAGE" /D "NO_INJECTION" +else +precompiler_flag = /D "NO_INJECTION" +endif + +def_file = /DEF:"uMod_DX$(DX_XX_File)_dll_NO_INJECTION.def" +obj_suff = NI.obj +dll = d3d$(DX_XX_File).dll + +else + +ifdef DI +ifdef LOG_MESSAGE +precompiler_flag = /D "LOG_MESSAGE" /D "DIRECT_INJECTION" +else +precompiler_flag = /D "DIRECT_INJECTION" +endif + +def_file = /DEF:"uMod_DX$(DX_XX_File)_dll_DIRECT_INJECTION.def" +obj_suff = DI.obj +dll = uMod_d3d$(DX_XX_File)_DI.dll + +else + +ifdef LOG_MESSAGE +precompiler_flag = /D "LOG_MESSAGE" /D "HOOK_INJECTION" +else +precompiler_flag = /D "HOOK_INJECTION" +endif + +def_file = /DEF:"uMod_DX$(DX_XX_File)_dll_HOOK_INJECTION.def" +obj_suff = HI.obj +dll = uMod_d3d$(DX_XX_File)_HI.dll +endif +endif + + +CXX = cl +CLINK = link.exe +DEFINES = /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "_WINDLL" /D "_MBCS" $(DX_XX_Flag) +CFLAGS = /I "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include" /nologo /W3 /WX- /O2 ${DEFINES} ${precompiler_flag} /Gm- /EHsc /MT /GS /fp:precise /Zc:wchar_t +LFLAGS = /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86" /DLL "Winmm.lib" "d3dx9.lib" "d3dx10.lib" "dxguid.lib" "user32.lib" "Kernel32.lib" ${def_file} /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE:NO /NXCOMPAT:NO /MACHINE:X86 + +obj = obj +bin = bin + +objects = \ + ${obj}\uMod_TextureFunction.$(DX_XX_File).${obj_suff} \ + ${obj}\uMod_ArrayHandler.$(DX_XX_File).${obj_suff} \ + ${obj}\uMod_TextureClient.$(DX_XX_File).${obj_suff} \ + ${obj}\uMod_TextureServer.$(DX_XX_File).${obj_suff} \ + ${obj}\uMod_DXMain_dll.$(DX_XX_File).${obj_suff} \ + \ + ${obj}\uMod_DX9_dll.${obj_suff} \ + ${obj}\uMod_TextureClient_DX9.${obj_suff} \ + ${obj}\uMod_IDirect3D9.${obj_suff} \ + ${obj}\uMod_IDirect3D9Ex.${obj_suff} \ + ${obj}\uMod_IDirect3DDevice9.${obj_suff} \ + ${obj}\uMod_IDirect3DDevice9Ex.${obj_suff} \ + ${obj}\uMod_IDirect3DTexture9.${obj_suff} \ + ${obj}\uMod_IDirect3DVolumeTexture9.${obj_suff} \ + ${obj}\uMod_IDirect3DCubeTexture9.${obj_suff} + +headers = uMod_Main.h \ + uMod_DXMain_dll.h \ + uMod_Defines.h \ + uMod_TextureFunction.h \ + uMod_ArrayHandler.h \ + uMod_TextureClient.h \ + uMod_TextureServer.h + +DX9_headers = \ + ..\uMod_DX9\uMod_DX9_dll.h \ + ..\uMod_DX9\uMod_TextureClient_DX9.h \ + ..\uMod_DX9\uMod_IDirect3D9.h \ + ..\uMod_DX9\uMod_IDirect3DDevice9.h \ + ..\uMod_DX9\uMod_IDirect3DTexture9.h \ + ..\uMod_DX9\uMod_IDirect3DVolumeTexture9.h \ + ..\uMod_DX9\uMod_IDirect3DCubeTexture9.h + + +${bin}\d3d9.dll: ${objects} + ${CLINK} ${LFLAGS} ${objects} /OUT:${bin}\${dll} + copy ${bin}\${dll} ..\uMod_GUI\bin\${dll} + + +${obj}\uMod_DXMain_dll.$(DX_XX_File).${obj_suff}: uMod_DXMain_dll.cpp ${headers} + ${CXX} ${CFLAGS} /c $< /Fo$@ + +${obj}\uMod_ArrayHandler.$(DX_XX_File).${obj_suff}: uMod_ArrayHandler.cpp ${headers} + ${CXX} ${CFLAGS} /c $< /Fo$@ + +${obj}\uMod_TextureClient.$(DX_XX_File).${obj_suff}: uMod_TextureClient.cpp ${headers} + ${CXX} ${CFLAGS} /c $< /Fo$@ + +${obj}\uMod_TextureServer.$(DX_XX_File).${obj_suff}: uMod_TextureServer.cpp ${headers} + ${CXX} ${CFLAGS} /c $< /Fo$@ + +${obj}\uMod_TextureFunction.$(DX_XX_File).${obj_suff}: uMod_TextureFunction.cpp ${headers} ${DX9_headers} + ${CXX} ${CFLAGS} /c $< /Fo$@ + + +${obj}\uMod_DX9_dll.${obj_suff}: ..\uMod_DX9\uMod_DX9_dll.cpp ${headers} ${DX9_headers} + ${CXX} ${CFLAGS} /c $< /Fo$@ + +${obj}\uMod_TextureClient_DX9.${obj_suff}: ..\uMod_DX9\uMod_TextureClient_DX9.cpp ${headers} ${DX9_headers} + ${CXX} ${CFLAGS} /c $< /Fo$@ + +${obj}\uMod_IDirect3D9.${obj_suff}: ..\uMod_DX9\uMod_IDirect3D9.cpp ${headers} ${DX9_headers} + ${CXX} ${CFLAGS} /c $< /Fo$@ + +${obj}\uMod_IDirect3D9Ex.${obj_suff}: ..\uMod_DX9\uMod_IDirect3D9Ex.cpp ${headers} ${DX9_headers} + ${CXX} ${CFLAGS} /c $< /Fo$@ + +${obj}\uMod_IDirect3DDevice9.${obj_suff}: ..\uMod_DX9\uMod_IDirect3DDevice9.cpp ${headers} ${DX9_headers} + ${CXX} ${CFLAGS} /c $< /Fo$@ + +${obj}\uMod_IDirect3DDevice9Ex.${obj_suff}: ..\uMod_DX9\uMod_IDirect3DDevice9Ex.cpp ${headers} ${DX9_headers} + ${CXX} ${CFLAGS} /c $< /Fo$@ + +${obj}\uMod_IDirect3DTexture9.${obj_suff}: ..\uMod_DX9\uMod_IDirect3DTexture9.cpp ${headers} ${DX9_headers} + ${CXX} ${CFLAGS} /c $< /Fo$@ + +${obj}\uMod_IDirect3DVolumeTexture9.${obj_suff}: ..\uMod_DX9\uMod_IDirect3DVolumeTexture9.cpp ${headers} ${DX9_headers} + ${CXX} ${CFLAGS} /c $< /Fo$@ + +${obj}\uMod_IDirect3DCubeTexture9.${obj_suff}: ..\uMod_DX9\uMod_IDirect3DCubeTexture9.cpp ${headers} + ${CXX} ${CFLAGS} /c $< /Fo$@ + + +clean: + del ${objects} ${bin}\${dll} \ No newline at end of file diff --git a/uMod_DX9/makefile.vc b/uMod_DXMain/makefile.vc similarity index 100% rename from uMod_DX9/makefile.vc rename to uMod_DXMain/makefile.vc diff --git a/uMod_DX9/uMod_ArrayHandler.cpp b/uMod_DXMain/uMod_ArrayHandler.cpp similarity index 96% rename from uMod_DX9/uMod_ArrayHandler.cpp rename to uMod_DXMain/uMod_ArrayHandler.cpp index add6aca..b345b2a 100644 --- a/uMod_DX9/uMod_ArrayHandler.cpp +++ b/uMod_DXMain/uMod_ArrayHandler.cpp @@ -24,6 +24,8 @@ along with Universal Modding Engine. If not, see +/* + uMod_FileHandler::uMod_FileHandler(void) { @@ -103,4 +105,4 @@ int uMod_FileHandler::Remove(TextureFileStruct* file) } return (RETURN_OK); } - +*/ diff --git a/uMod_DX9/uMod_ArrayHandler.h b/uMod_DXMain/uMod_ArrayHandler.h similarity index 93% rename from uMod_DX9/uMod_ArrayHandler.h rename to uMod_DXMain/uMod_ArrayHandler.h index c8b6fd7..aa2a1db 100644 --- a/uMod_DX9/uMod_ArrayHandler.h +++ b/uMod_DXMain/uMod_ArrayHandler.h @@ -22,7 +22,7 @@ along with Universal Modding Engine. If not, see #define uMod_FIELDHANDLER_H_ #include "..\uMod_GlobalDefines.h" -#include "uMod_IDirect3DTexture9.h" + typedef struct { @@ -31,11 +31,11 @@ typedef struct unsigned int Size; // size of file int NumberOfTextures; int Reference; // for a fast delete in the FileHandler - IDirect3DBaseTexture9 **Textures; // pointer to the fake textures + void **Textures; // pointer to the fake textures MyTypeHash Hash; // hash value } TextureFileStruct; - +/* class uMod_FileHandler // array to store TextureFileStruct { @@ -56,6 +56,7 @@ protected: int FieldCounter; TextureFileStruct*** Files; }; +*/ @@ -81,6 +82,7 @@ private: +typedef uMod_TextureHandler uMod_FileHandler; diff --git a/uMod_DX9/uMod_DX9_dll_DIRECT_INJECTION.def b/uMod_DXMain/uMod_DX9_dll_DIRECT_INJECTION.def similarity index 100% rename from uMod_DX9/uMod_DX9_dll_DIRECT_INJECTION.def rename to uMod_DXMain/uMod_DX9_dll_DIRECT_INJECTION.def diff --git a/uMod_DX9/uMod_DX9_dll_HOOK_INJECTION.def b/uMod_DXMain/uMod_DX9_dll_HOOK_INJECTION.def similarity index 100% rename from uMod_DX9/uMod_DX9_dll_HOOK_INJECTION.def rename to uMod_DXMain/uMod_DX9_dll_HOOK_INJECTION.def diff --git a/uMod_DX9/uMod_DX9_dll_NO_INJECTION.def b/uMod_DXMain/uMod_DX9_dll_NO_INJECTION.def similarity index 100% rename from uMod_DX9/uMod_DX9_dll_NO_INJECTION.def rename to uMod_DXMain/uMod_DX9_dll_NO_INJECTION.def diff --git a/uMod_DXMain/uMod_DXMain_dll.cpp b/uMod_DXMain/uMod_DXMain_dll.cpp new file mode 100644 index 0000000..e05a647 --- /dev/null +++ b/uMod_DXMain/uMod_DXMain_dll.cpp @@ -0,0 +1,248 @@ +/* +This file is part of Universal Modding Engine. + + +Universal Modding Engine is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Universal Modding Engine is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Universal Modding Engine. If not, see . +*/ + +/* + + + NEVER USE THIS CODE FOR ILLEGAL PURPOSE + + +*/ + + +#include "uMod_Main.h" + +//#include "detours.h" +//#include "detourxs/detourxs/detourxs.h" + +/* +#include "detourxs/detourxs/ADE32.cpp" +#include "detourxs/detourxs/detourxs.cpp" +*/ +/* + * global variable which are not linked external + */ + +HINSTANCE gl_hThisInstance = NULL; +uMod_TextureServer* gl_TextureServer = NULL; +HANDLE gl_ServerThread = NULL; + + +/* + * global variable which are linked external + */ +unsigned int gl_ErrorState = 0u; + +#ifdef LOG_MESSAGE +FILE* gl_File = NULL; +#endif + + +#ifdef DIRECT_INJECTION +void Nothing(void) {(void)NULL;} +#endif +/* + * dll entry routine, here we initialize or clean up + */ +BOOL WINAPI DllMain( HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) +{ + UNREFERENCED_PARAMETER(lpReserved); + + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + { + InitInstance(hModule); + break; + } + case DLL_PROCESS_DETACH: + { + ExitInstance(); + break; + } + default: break; + } + + return (true); +} + + +DWORD WINAPI ServerThread( LPVOID lpParam ) +{ + UNREFERENCED_PARAMETER(lpParam); + if (gl_TextureServer!=NULL) gl_TextureServer->MainLoop(); //This is and endless mainloop, it sleep till something is written into the pipe. + return (0); +} + +void InitInstance(HINSTANCE hModule) +{ + + DisableThreadLibraryCalls( hModule ); //reduce overhead + + gl_hThisInstance = (HINSTANCE) hModule; + + wchar_t game[MAX_PATH]; + if (HookThisProgram( game)) //ask if we need to hook this program + { + OpenMessage(); + Message("InitInstance: %lu\n", hModule); + + gl_TextureServer = new uMod_TextureServer(game); //create the server which listen on the pipe and prepare the update for the texture clients + +#ifdef DEF_USE_DX9 + InitDX9(); +#endif + + + if (gl_TextureServer->OpenPipe(game)) //open the pipe and send the name+path of this executable + { + Message("InitInstance: Pipe not opened\n"); + return; + } + + gl_ServerThread = CreateThread( NULL, 0, ServerThread, NULL, 0, NULL); //creating a thread for the mainloop + if (gl_ServerThread==NULL) {Message("InitInstance: Serverthread not started\n");} + + } +} + +void ExitInstance() +{ + if (gl_TextureServer!=NULL) + { + gl_TextureServer->ClosePipe(); //This must be done before the server thread is killed, because the server thread will endless wait on the ReadFile() + } + if (gl_ServerThread!=NULL) + { + CloseHandle(gl_ServerThread); // kill the server thread + gl_ServerThread = NULL; + } + if (gl_TextureServer!=NULL) + { + delete gl_TextureServer; //delete the texture server + gl_TextureServer = NULL; + } + +#ifdef DEF_USE_DX9 + ExitDX9(); +#endif + + CloseMessage(); +} + + + +bool HookThisProgram( wchar_t *ret) +{ + wchar_t Executable[MAX_PATH]; + wchar_t Game[MAX_PATH]; + GetModuleFileNameW( GetModuleHandle( NULL ), Executable, MAX_PATH ); //ask for name and path of this executable + +#ifdef HOOK_INJECTION + //we use the gloabal hook + + FILE* file; + wchar_t *app_path = _wgetenv( L"APPDATA"); //asc for the user application directory + wchar_t file_name[MAX_PATH]; + swprintf_s( file_name, MAX_PATH, L"%ls\\%ls\\%ls", app_path, uMod_APP_DIR, uMod_APP_DX9); + if (_wfopen_s( &file, file_name, L"rt,ccs=UTF-16LE")) return (false); // open the file in utf-16 LE mode + + + //MessageBoxW( NULL, Executable, L"test", 0); + while (!feof(file)) + { + if ( fgetws( Game, MAX_PATH, file) != NULL ) //get each line of the file + { + //MessageBoxW( NULL, Game, L"test", 0); + int len = 0; + while (Game[len]) + { + if (Game[len]==L'\r' || Game[len]==L'\n') {Game[len]=0; break;} //removing the new line symbols + len++; + } + if ( _wcsicmp( Executable, Game ) == 0 ) //compare both strings + { + for (int i=0; i. +*/ + + + +#ifndef uMod_DXMAIN_DLL_H_ +#define uMod_DXMAIN_DLL_H_ + +#ifdef DEF_USE_DX9 +#include "../uMod_DX9/uMod_DX9_dll.h" +#endif + +void InitInstance(HINSTANCE hModule); +void ExitInstance(void); + +bool HookThisProgram( wchar_t *ret); +DWORD WINAPI ServerThread( LPVOID lpParam); + + + +#ifndef NO_INJECTION + +void *DetourFunc(BYTE *src, const BYTE *dst, const int len); +bool RetourFunc(BYTE *src, BYTE *restore, const int len); + + +#ifdef HOOK_INJECTION +LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam); +void InstallHook(void); +void RemoveHook(void); +#endif + + +#ifdef DIRECT_INJECTION +void Nothing(void); +#endif + +#endif + +#endif diff --git a/uMod_DX9/uMod_Defines.h b/uMod_DXMain/uMod_Defines.h similarity index 93% rename from uMod_DX9/uMod_Defines.h rename to uMod_DXMain/uMod_Defines.h index 4cf9ff6..2f54104 100644 --- a/uMod_DX9/uMod_Defines.h +++ b/uMod_DXMain/uMod_Defines.h @@ -22,7 +22,6 @@ along with Universal Modding Engine. If not, see #define uMod_DEFINES_H_ - #ifdef LOG_MESSAGE extern FILE *gl_File; @@ -56,11 +55,14 @@ typedef unsigned long DWORD32; #define STDMETHOD(method) virtual HRESULT method #define STDMETHOD_(ret, method) virtual ret method #define sprintf_s(...) +#define swprintf_s(...) +#define strcat_s(...) #define fprintf(...) #define fclose(...) #define fseek(...) #define ftell(...) 0 #define fflush(...) +#define qsort(...) typedef LONG HRESULT; #define UNREFERENCED_PARAMETER(...) diff --git a/uMod_DX9/uMod_Main.h b/uMod_DXMain/uMod_Main.h similarity index 84% rename from uMod_DX9/uMod_Main.h rename to uMod_DXMain/uMod_Main.h index 6655982..e76d971 100644 --- a/uMod_DX9/uMod_Main.h +++ b/uMod_DXMain/uMod_Main.h @@ -43,9 +43,10 @@ along with Universal Modding Engine. If not, see #include "../uMod_GlobalDefines.h" #include "../uMod_Error.h" #include "uMod_Defines.h" -#include "uMod_DX9_dll.h" -#include "uMod_TextureFunction.h" +#include "uMod_DXMain_dll.h" +//#include "uMod_TextureFunction.h" +/* #include "uMod_IDirect3D9.h" #include "uMod_IDirect3D9Ex.h" @@ -55,12 +56,16 @@ along with Universal Modding Engine. If not, see #include "uMod_IDirect3DCubeTexture9.h" #include "uMod_IDirect3DTexture9.h" #include "uMod_IDirect3DVolumeTexture9.h" +*/ #include "uMod_ArrayHandler.h" #include "uMod_TextureServer.h" #include "uMod_TextureClient.h" +extern HINSTANCE gl_hThisInstance; +extern uMod_TextureServer* gl_TextureServer; +extern HANDLE gl_ServerThread; extern unsigned int gl_ErrorState; #endif diff --git a/uMod_DXMain/uMod_TextureClient.cpp b/uMod_DXMain/uMod_TextureClient.cpp index cf493f9..1b76330 100644 --- a/uMod_DXMain/uMod_TextureClient.cpp +++ b/uMod_DXMain/uMod_TextureClient.cpp @@ -21,11 +21,10 @@ along with Universal Modding Engine. If not, see #include "uMod_Main.h" -uMod_TextureClient::uMod_TextureClient(uMod_TextureServer* server, IDirect3DDevice9* device) +uMod_TextureClient::uMod_TextureClient(const int version) : Version(version) { Message("uMod_TextureClient::uMod_TextureClient(void): %lu\n", this); - Server = server; - D3D9Device = device; + Server = NULL; BoolSaveAllTextures = false; BoolSaveSingleTexture = false; KeyBack = 0; @@ -37,24 +36,10 @@ uMod_TextureClient::uMod_TextureClient(uMod_TextureServer* server, IDirect3DDevi NumberToMod = 0; FileToMod = NULL; - if (Server!=NULL) - { - if (Server->AddClient( this, &FileToMod, &NumberToMod)) - { - Server=NULL; - NumberToMod = 0; - FileToMod = NULL; - } - else - { - for (int i=0; iRemoveClient(this); + if (Server!=NULL) Server->RemoveClient(this, Version); if (Mutex!=NULL) CloseHandle(Mutex); @@ -75,259 +60,25 @@ uMod_TextureClient::~uMod_TextureClient(void) } -int uMod_TextureClient::AddTexture( uMod_IDirect3DTexture9* pTexture) +int uMod_TextureClient::ConnectToServer(uMod_TextureServer* server) { - void *cpy; - long ret = D3D9Device->QueryInterface( IID_IDirect3DTexture9, &cpy); - if (ret == 0x01000000L) ((uMod_IDirect3DDevice9*)D3D9Device)->SetLastCreatedTexture(NULL); //this texture must no be added twice - else ((uMod_IDirect3DDevice9Ex*) D3D9Device)->SetLastCreatedTexture(NULL); //this texture must no be added twice - - if (pTexture->FAKE) return (RETURN_OK); // this is a fake texture - - Message("uMod_TextureClient::AddTexture( %lu): %lu (thread: %lu)\n", pTexture, this, GetCurrentThreadId()); - - MyTypeHash hash; - if (int ret = pTexture->GetHash( hash)) + Server = server; + if (Server!=NULL) { - Bool_CheckAgainNonAdded = true; - NonAdded_OriginalTextures.Add( pTexture); - return (ret); - } - - pTexture->Hash = hash; - - if (BoolSaveAllTextures) SaveTexture(pTexture); - - if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR); - - OriginalTextures.Add( pTexture); // add the texture to the list of original texture - - return (LookUpToMod(pTexture)); // check if this texture should be modded -} - -int uMod_TextureClient::AddTexture( uMod_IDirect3DVolumeTexture9* pTexture) -{ - void *cpy; - long ret = D3D9Device->QueryInterface( IID_IDirect3DTexture9, &cpy); - if (ret == 0x01000000L) ((uMod_IDirect3DDevice9*)D3D9Device)->SetLastCreatedVolumeTexture(NULL); //this texture must no be added twice - else ((uMod_IDirect3DDevice9Ex*) D3D9Device)->SetLastCreatedVolumeTexture(NULL); //this texture must no be added twice - - if (pTexture->FAKE) return (RETURN_OK); // this is a fake texture - - Message("uMod_TextureClient::AddTexture( Volume: %lu): %lu (thread: %lu)\n", pTexture, this, GetCurrentThreadId()); - - MyTypeHash hash; - if (int ret = pTexture->GetHash( hash)) - { - Bool_CheckAgainNonAdded = true; - NonAdded_OriginalVolumeTextures.Add( pTexture); - return (ret); - } - - pTexture->Hash = hash; - - if (BoolSaveAllTextures) SaveTexture(pTexture); - - if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR); - - OriginalVolumeTextures.Add( pTexture); // add the texture to the list of original texture - - return (LookUpToMod(pTexture)); // check if this texture should be modded -} - -int uMod_TextureClient::AddTexture( uMod_IDirect3DCubeTexture9* pTexture) -{ - void *cpy; - long ret = D3D9Device->QueryInterface( IID_IDirect3DTexture9, &cpy); - if (ret == 0x01000000L) ((uMod_IDirect3DDevice9*)D3D9Device)->SetLastCreatedCubeTexture(NULL); //this texture must no be added twice - else ((uMod_IDirect3DDevice9Ex*) D3D9Device)->SetLastCreatedCubeTexture(NULL); //this texture must no be added twice - - if (pTexture->FAKE) return (RETURN_OK); // this is a fake texture - - Message("uMod_TextureClient::AddTexture( Cube: %lu): %lu (thread: %lu)\n", pTexture, this, GetCurrentThreadId()); - - MyTypeHash hash; - if (int ret = pTexture->GetHash( hash)) - { - Bool_CheckAgainNonAdded = true; - NonAdded_OriginalCubeTextures.Add( pTexture); - return (ret); - } - - pTexture->Hash = hash; - - if (BoolSaveAllTextures) SaveTexture(pTexture); - - if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR); - - OriginalCubeTextures.Add( pTexture); // add the texture to the list of original texture - - return (LookUpToMod(pTexture)); // check if this texture should be modded -} - - -int uMod_TextureClient::CheckAgainNonAdded(void) -{ - Message("uMod_TextureClient::CheckAgainNonAdded( %u, %u, %u): %lu\n", NonAdded_OriginalTextures.GetNumber(), - NonAdded_OriginalVolumeTextures.GetNumber(), NonAdded_OriginalCubeTextures.GetNumber(), this); - - Bool_CheckAgainNonAdded = false; - - int num = NonAdded_OriginalTextures.GetNumber(); - for (int i=num-1; i>=0; i--) - { - uMod_IDirect3DTexture9* pTexture = NonAdded_OriginalTextures[i]; - - MyTypeHash hash; - if (pTexture->GetHash( hash) == 0) + if (Server->AddClient( this, FileToMod, NumberToMod, Version)) { - NonAdded_OriginalTextures.Remove(pTexture); - OriginalTextures.Add( pTexture); // add the texture to the list of original texture - LookUpToMod(pTexture); // check if this texture should be modded + Server=NULL; + NumberToMod = 0; + FileToMod = NULL; } - } - - num = NonAdded_OriginalVolumeTextures.GetNumber(); - for (int i=num-1; i>=0; i--) - { - uMod_IDirect3DVolumeTexture9* pTexture = NonAdded_OriginalVolumeTextures[i]; - - MyTypeHash hash; - if (pTexture->GetHash( hash) == 0) + else { - NonAdded_OriginalVolumeTextures.Remove(pTexture); - OriginalVolumeTextures.Add( pTexture); // add the texture to the list of original texture - LookUpToMod(pTexture); // check if this texture should be modded + for (int i=0; i=0; i--) - { - uMod_IDirect3DCubeTexture9* pTexture = NonAdded_OriginalCubeTextures[i]; - - MyTypeHash hash; - if (pTexture->GetHash( hash) == 0) - { - NonAdded_OriginalCubeTextures.Remove(pTexture); - OriginalCubeTextures.Add( pTexture); // add the texture to the list of original texture - LookUpToMod(pTexture); // check if this texture should be modded - } - } - Message("uMod_TextureClient::CheckAgainNonAdded() END: %lu\n", this); - return (RETURN_OK); -} - -int uMod_TextureClient::RemoveTexture( uMod_IDirect3DTexture9* pTexture) // is called from a texture, if it is finally released -{ - Message("uMod_TextureClient::RemoveTexture( %lu, %#lX): %lu\n", pTexture, pTexture->Hash, this); - - if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR); - if (pTexture->FAKE) - { - // we need to set the corresponding FileToMod[X].pTexture to NULL, to avoid a link to a non existing texture object - int ref = pTexture->Reference; - if (ref>=0 && refHash, this); - - if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR); - if (pTexture->FAKE) - { - // we need to set the corresponding FileToMod[X].pTexture to NULL, to avoid a link to a non existing texture object - int ref = pTexture->Reference; - if (ref>=0 && refHash, this); - - if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR); - if (pTexture->FAKE) - { - // we need to set the corresponding FileToMod[X].pTexture to NULL, to avoid a link to a non existing texture object - int ref = pTexture->Reference; - if (ref>=0 && refQueryInterface( IID_IDirect3DTexture9, &cpy); - if (ret == 0x01000000L) pTexture = ((uMod_IDirect3DDevice9*)D3D9Device)->GetSingleTexture(); //this texture must no be added twice - else pTexture = ((uMod_IDirect3DDevice9Ex*) D3D9Device)->GetSingleTexture(); //this texture must no be added twice - - if (pTexture!=NULL) UnswitchTextures(pTexture); - } - BoolSaveSingleTexture = val; - return (RETURN_OK); -} - - int uMod_TextureClient::SetSaveDirectory( wchar_t *dir) { Message("uMod_TextureClient::SetSaveDirectory( %ls): %lu\n", dir, this); @@ -358,50 +109,6 @@ int uMod_TextureClient::SetGameName( wchar_t *name) -int uMod_TextureClient::SaveTexture(uMod_IDirect3DTexture9* pTexture) -{ - if (pTexture==NULL) return (RETURN_BAD_ARGUMENT); - if (SavePath[0]==0) {Message("uMod_TextureClient::SaveTexture( %#lX, %lu): %lu, SavePath not set\n", pTexture->Hash, pTexture->m_D3Dtex, this); return (RETURN_TEXTURE_NOT_SAVED);} - - wchar_t file[MAX_PATH]; - if (GameName[0]) swprintf_s( file, MAX_PATH, L"%ls\\%ls_T_%#lX.dds", SavePath, GameName, pTexture->Hash); - else swprintf_s( file, MAX_PATH, L"%ls\\T_%#lX.dds", SavePath, pTexture->Hash); - Message("uMod_TextureClient::SaveTexture( %ls): %lu\n", file, this); - - if (D3D_OK!=D3DXSaveTextureToFileW( file, D3DXIFF_DDS, pTexture->m_D3Dtex, NULL)) return (RETURN_TEXTURE_NOT_SAVED); - return (RETURN_OK); -} - -int uMod_TextureClient::SaveTexture(uMod_IDirect3DVolumeTexture9* pTexture) -{ - if (pTexture==NULL) return (RETURN_BAD_ARGUMENT); - if (SavePath[0]==0) {Message("uMod_TextureClient::SaveTexture( %#lX, %lu): %lu, SavePath not set\n", pTexture->Hash, pTexture->m_D3Dtex, this); return (RETURN_TEXTURE_NOT_SAVED);} - - wchar_t file[MAX_PATH]; - if (GameName[0]) swprintf_s( file, MAX_PATH, L"%ls\\%ls_V_%#lX.dds", SavePath, GameName, pTexture->Hash); - else swprintf_s( file, MAX_PATH, L"%ls\\V_%#lX.dds", SavePath, pTexture->Hash); - Message("uMod_TextureClient::SaveTexture( %ls): %lu\n", file, this); - - if (D3D_OK!=D3DXSaveTextureToFileW( file, D3DXIFF_DDS, pTexture->m_D3Dtex, NULL)) return (RETURN_TEXTURE_NOT_SAVED); - return (RETURN_OK); -} - -int uMod_TextureClient::SaveTexture(uMod_IDirect3DCubeTexture9* pTexture) -{ - if (pTexture==NULL) return (RETURN_BAD_ARGUMENT); - if (SavePath[0]==0) {Message("uMod_TextureClient::SaveTexture( %#lX, %lu): %lu, SavePath not set\n", pTexture->Hash, pTexture->m_D3Dtex, this); return (RETURN_TEXTURE_NOT_SAVED);} - - wchar_t file[MAX_PATH]; - if (GameName[0]) swprintf_s( file, MAX_PATH, L"%ls\\%ls_C_%#lX.dds", SavePath, GameName, pTexture->Hash); - else swprintf_s( file, MAX_PATH, L"%ls\\C_%#lX.dds", SavePath, pTexture->Hash); - Message("uMod_TextureClient::SaveTexture( %ls): %lu\n", file, this); - - if (D3D_OK!=D3DXSaveTextureToFileW( file, D3DXIFF_DDS, pTexture->m_D3Dtex, NULL)) return (RETURN_TEXTURE_NOT_SAVED); - return (RETURN_OK); -} - - - int uMod_TextureClient::AddUpdate(TextureFileStruct* update, int number) //client must delete the update array { @@ -414,219 +121,6 @@ int uMod_TextureClient::AddUpdate(TextureFileStruct* update, int number) //clie } - -int uMod_TextureClient::MergeUpdate(void) -{ - if (NumberOfUpdate<0) {return (RETURN_OK);} - if (int ret = LockMutex()) {gl_ErrorState |= uMod_ERROR_TEXTURE ; return (ret);} - - Message("uMod_TextureClient::MergeUpdate(): %lu\n", this); - - for (int i=0; i0) to_lookup = new int[NumberOfUpdate]; - int num_to_lookup = 0; - - /* - * FileToMod contains the old files (textures) which should replace the target textures (if they are loaded by the game) - * Update contains the new files (textures) which should replace the target textures (if they are loaded by the game) - * - * Both arrays (FileToMod and Update) are sorted according to their hash values. - * - * First we go through both arrays linearly and - * 1) take over the old entry if the hash is the same, - * 2) release old fake texture (if target texture exist and is not in the Update) - * 3) or mark newly added fake texture (if they are not in FileToMod) - */ - - while (pos_old Update[pos_new].Hash) // this fake texture is new - { - to_lookup[num_to_lookup++] = pos_new++; // keep this fake texture in mind, we must search later for it through all original textures - // we increase only the new counter by one - } - else if (FileToMod[pos_old].Hash < Update[pos_new].Hash) // this fake texture is not in the update - { - for (int i=FileToMod[pos_old].NumberOfTextures-1; i>=0; i--) FileToMod[pos_old].Textures[i]->Release(); // we release the fake textures - if (FileToMod[pos_old].Textures!=NULL) delete [] FileToMod[pos_old].Textures; // we delete the memory - FileToMod[pos_old].NumberOfTextures = 0; - FileToMod[pos_old].Textures = NULL; - - pos_old++; // we increase only the old counter by one - } - else // the hash value is the same, thus this texture is in the array FileToMod as well as in the array Update - { - if (Update[pos_new].ForceReload) - { - if (FileToMod[pos_old].NumberOfTextures>0) - { - Update[pos_new].Textures = new IDirect3DBaseTexture9*[FileToMod[pos_old].NumberOfTextures]; - } - for (int i=0; iQueryInterface( IID_IDirect3D9, (void**)&base_texture); - switch (ret) - { - case 0x01000000L: - { - uMod_IDirect3DTexture9 *pTexture = (uMod_IDirect3DTexture9*) FileToMod[pos_old].Textures[i];// - uMod_IDirect3DTexture9 *pRefTexture = pTexture->CrossRef_D3Dtex; - pTexture->Release(); - i--; //after the Release of the old fake texture FileToMod[pos_old].Textures[i] is overwritten by entries with index greater than i - - uMod_IDirect3DTexture9 *fake_Texture; - if (int ret = LoadTexture( & (Update[pos_new]), &fake_Texture)) return (ret); - if (SwitchTextures( fake_Texture, pRefTexture)) - { - Message("MergeUpdate(): textures not switched %#lX\n", pRefTexture->Hash); - fake_Texture->Release(); - } - else - { - Update[pos_new].Textures[Update[pos_new].NumberOfTextures++] = fake_Texture; - fake_Texture->Reference = pos_new; - } - break; - } - case 0x01000001L: - { - uMod_IDirect3DVolumeTexture9 *pTexture = (uMod_IDirect3DVolumeTexture9*) FileToMod[pos_old].Textures[i];// - uMod_IDirect3DVolumeTexture9 *pRefTexture = pTexture->CrossRef_D3Dtex; - pTexture->Release(); - i--; //after the Release of the old fake texture FileToMod[pos_old].Textures[i] is overwritten by entries with index greater than i - - uMod_IDirect3DVolumeTexture9 *fake_Texture; - if (int ret = LoadTexture( & (Update[pos_new]), &fake_Texture)) return (ret); - if (SwitchTextures( fake_Texture, pRefTexture)) - { - Message("MergeUpdate(): textures not switched %#lX\n", pRefTexture->Hash); - fake_Texture->Release(); - } - else - { - Update[pos_new].Textures[Update[pos_new].NumberOfTextures++] = fake_Texture; - fake_Texture->Reference = pos_new; - } - break; - } - case 0x01000002L: - { - uMod_IDirect3DCubeTexture9 *pTexture = (uMod_IDirect3DCubeTexture9*) FileToMod[pos_old].Textures[i];// - uMod_IDirect3DCubeTexture9 *pRefTexture = pTexture->CrossRef_D3Dtex; - pTexture->Release(); - i--; //after the Release of the old fake texture FileToMod[pos_old].Textures[i] is overwritten by entries with index greater than i - - uMod_IDirect3DCubeTexture9 *fake_Texture; - if (int ret = LoadTexture( & (Update[pos_new]), &fake_Texture)) return (ret); - if (SwitchTextures( fake_Texture, pRefTexture)) - { - Message("MergeUpdate(): textures not switched %#lX\n", pRefTexture->Hash); - fake_Texture->Release(); - } - else - { - Update[pos_new].Textures[Update[pos_new].NumberOfTextures++] = fake_Texture; - fake_Texture->Reference = pos_new; - } - break; - } - default: - break; // this is no fake texture and QueryInterface failed, because IDirect3DBaseTexture9 object cannot be a IDirect3D9 object ;) - } - } - } - else // the texture might be loaded or not - { - Update[pos_new].NumberOfTextures = FileToMod[pos_old].NumberOfTextures; - Update[pos_new].Textures = FileToMod[pos_old].Textures; - FileToMod[pos_old].NumberOfTextures = 0; - FileToMod[pos_old].Textures = NULL; - } - // we increase both counters by one - pos_old++; - pos_new++; - } - } - - while (pos_old=0; i--) FileToMod[pos_old].Textures[i]->Release(); // we release the fake textures - //for (int i=0; iRelease(); // we release the fake textures - if (FileToMod[pos_old].Textures!=NULL) delete [] FileToMod[pos_old].Textures; // we delete the memory - FileToMod[pos_old].Textures = NULL; - pos_old++; - } - while (pos_new0) - { - uMod_IDirect3DTexture9* single_texture; - void *cpy; - long ret = D3D9Device->QueryInterface( IID_IDirect3DTexture9, &cpy); - if (ret == 0x01000000L) single_texture = ((uMod_IDirect3DDevice9*)D3D9Device)->GetSingleTexture(); //this texture must no be added twice - else single_texture = ((uMod_IDirect3DDevice9Ex*) D3D9Device)->GetSingleTexture(); //this texture must no be added twice - - int num = OriginalTextures.GetNumber(); - for (int i=0; iCrossRef_D3Dtex==NULL || OriginalTextures[i]->CrossRef_D3Dtex==single_texture) - { - UnswitchTextures(OriginalTextures[i]); //this we can do always, so we unswitch the single texture - LookUpToMod( OriginalTextures[i], num_to_lookup, to_lookup); - } - - uMod_IDirect3DVolumeTexture9 *single_volume_texture; - if (ret == 0x01000000L) single_volume_texture = ((uMod_IDirect3DDevice9*)D3D9Device)->GetSingleVolumeTexture(); //this texture must no be added twice - else single_volume_texture = ((uMod_IDirect3DDevice9Ex*) D3D9Device)->GetSingleVolumeTexture(); //this texture must no be added twice - num = OriginalVolumeTextures.GetNumber(); - for (int i=0; iCrossRef_D3Dtex==NULL || OriginalVolumeTextures[i]->CrossRef_D3Dtex==single_volume_texture) - { - UnswitchTextures(OriginalVolumeTextures[i]); //this we can do always, so we unswitch the single texture - LookUpToMod( OriginalVolumeTextures[i], num_to_lookup, to_lookup); - } - - uMod_IDirect3DCubeTexture9 *single_cube_texture; - if (ret == 0x01000000L) single_cube_texture = ((uMod_IDirect3DDevice9*)D3D9Device)->GetSingleCubeTexture(); //this texture must no be added twice - else single_cube_texture = ((uMod_IDirect3DDevice9Ex*) D3D9Device)->GetSingleCubeTexture(); //this texture must no be added twice - num = OriginalCubeTextures.GetNumber(); - for (int i=0; iCrossRef_D3Dtex==NULL || OriginalCubeTextures[i]->CrossRef_D3Dtex==single_cube_texture) - { - UnswitchTextures(OriginalCubeTextures[i]); //this we can do always, so we unswitch the single texture - LookUpToMod( OriginalCubeTextures[i], num_to_lookup, to_lookup); - } - } - - - - if (to_lookup != NULL) delete [] to_lookup; - - Message("uMod_TextureClient::MergeUpdate() END: %lu\n", this); - - CheckAgainNonAdded(); - return (UnlockMutex()); -} - - - int uMod_TextureClient::LockMutex(void) { if (( gl_ErrorState & (uMod_ERROR_FATAL | uMod_ERROR_MUTEX) )) return (RETURN_NO_MUTEX); @@ -641,10 +135,7 @@ int uMod_TextureClient::UnlockMutex(void) } - - - -int uMod_TextureClient::LookUpToMod( MyTypeHash hash, int num_index_list, int *index_list) +int uMod_TextureClient::GetIndex( MyTypeHash hash, int num_index_list, int *index_list) { if(NumberToMod>0) { @@ -703,157 +194,3 @@ int uMod_TextureClient::LookUpToMod( MyTypeHash hash, int num_index_list, int *i } return (-1); } - -int uMod_TextureClient::LookUpToMod( uMod_IDirect3DTexture9* pTexture, int num_index_list, int *index_list) // should only be called for original textures -{ - Message("uMod_TextureClient::LookUpToMod( %lu): hash: %#lX, %lu\n", pTexture, pTexture->Hash, this); - if (pTexture->CrossRef_D3Dtex!=NULL) return (RETURN_OK); // bug, this texture is already switched - int index = LookUpToMod( pTexture->Hash, num_index_list, index_list); - if (index>=0) - { - uMod_IDirect3DTexture9 *fake_Texture; - if (int ret = LoadTexture( & (FileToMod[index]), &fake_Texture)) return (ret); - if (SwitchTextures( fake_Texture, pTexture)) - { - Message("uMod_TextureClient::LookUpToMod(): textures not switched %#lX\n", FileToMod[index].Hash); - fake_Texture->Release(); - } - else - { - IDirect3DBaseTexture9 **temp = new IDirect3DBaseTexture9*[FileToMod[index].NumberOfTextures+1]; - for (int j=0; jReference = index; - } - } - return (RETURN_OK); -} - -int uMod_TextureClient::LookUpToMod( uMod_IDirect3DVolumeTexture9* pTexture, int num_index_list, int *index_list) // should only be called for original textures -{ - Message("uMod_TextureClient::LookUpToMod( Volume %lu): hash: %#lX, %lu\n", pTexture, pTexture->Hash, this); - if (pTexture->CrossRef_D3Dtex!=NULL) return (RETURN_OK); // bug, this texture is already switched - int index = LookUpToMod( pTexture->Hash, num_index_list, index_list); - if (index>=0) - { - uMod_IDirect3DVolumeTexture9 *fake_Texture; - if (int ret = LoadTexture( & (FileToMod[index]), &fake_Texture)) return (ret); - if (SwitchTextures( fake_Texture, pTexture)) - { - Message("uMod_TextureClient::LookUpToMod(): textures not switched %#lX\n", FileToMod[index].Hash); - fake_Texture->Release(); - } - else - { - IDirect3DBaseTexture9 **temp = new IDirect3DBaseTexture9*[FileToMod[index].NumberOfTextures+1]; - for (int j=0; jReference = index; - } - } - return (RETURN_OK); -} - -int uMod_TextureClient::LookUpToMod( uMod_IDirect3DCubeTexture9* pTexture, int num_index_list, int *index_list) // should only be called for original textures -{ - Message("uMod_TextureClient::LookUpToMod( Cube %lu): hash: %#lX, %lu\n", pTexture, pTexture->Hash, this); - if (pTexture->CrossRef_D3Dtex!=NULL) return (RETURN_OK); // bug, this texture is already switched - int index = LookUpToMod( pTexture->Hash, num_index_list, index_list); - if (index>=0) - { - uMod_IDirect3DCubeTexture9 *fake_Texture; - if (int ret = LoadTexture( & (FileToMod[index]), &fake_Texture)) return (ret); - if (SwitchTextures( fake_Texture, pTexture)) - { - Message("uMod_TextureClient::LookUpToMod(): textures not switched %#lX\n", FileToMod[index].Hash); - fake_Texture->Release(); - } - else - { - IDirect3DBaseTexture9 **temp = new IDirect3DBaseTexture9*[FileToMod[index].NumberOfTextures+1]; - for (int j=0; jReference = index; - } - } - return (RETURN_OK); -} - - - - -int uMod_TextureClient::LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DTexture9 **ppTexture) // to load fake texture from a file in memory -{ - Message("LoadTexture( %lu, %lu, %#lX): %lu\n", file_in_memory, ppTexture, file_in_memory->Hash, this); - if (D3D_OK != D3DXCreateTextureFromFileInMemoryEx( D3D9Device, file_in_memory->pData, file_in_memory->Size, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, (IDirect3DTexture9 **) ppTexture)) - //if (D3D_OK != D3DXCreateTextureFromFileInMemory( D3D9Device, file_in_memory->pData, file_in_memory->Size, (IDirect3DTexture9 **) ppTexture)) - { - *ppTexture=NULL; - return (RETURN_TEXTURE_NOT_LOADED); - } - (*ppTexture)->FAKE = true; - - void *cpy; - long ret = D3D9Device->QueryInterface( IID_IDirect3DTexture9, &cpy); - if (ret == 0x01000000L) ((uMod_IDirect3DDevice9*)D3D9Device)->SetLastCreatedTexture(NULL); //this texture must no be added twice - else ((uMod_IDirect3DDevice9Ex*) D3D9Device)->SetLastCreatedTexture(NULL); //this texture must no be added twice - - Message("LoadTexture( %lu, %#lX): DONE\n", *ppTexture, file_in_memory->Hash); - return (RETURN_OK); -} - -int uMod_TextureClient::LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DVolumeTexture9 **ppTexture) // to load fake texture from a file in memory -{ - Message("LoadTexture( Volume %lu, %lu, %#lX): %lu\n", file_in_memory, ppTexture, file_in_memory->Hash, this); - if (D3D_OK != D3DXCreateVolumeTextureFromFileInMemoryEx( D3D9Device, file_in_memory->pData, file_in_memory->Size, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, (IDirect3DVolumeTexture9 **) ppTexture)) - //if (D3D_OK != D3DXCreateVolumeTextureFromFileInMemory( D3D9Device, file_in_memory->pData, file_in_memory->Size, (IDirect3DVolumeTexture9 **) ppTexture)) - { - *ppTexture=NULL; - return (RETURN_TEXTURE_NOT_LOADED); - } - (*ppTexture)->FAKE = true; - - void *cpy; - long ret = D3D9Device->QueryInterface( IID_IDirect3DTexture9, &cpy); - if (ret == 0x01000000L) ((uMod_IDirect3DDevice9*)D3D9Device)->SetLastCreatedVolumeTexture(NULL); //this texture must no be added twice - else ((uMod_IDirect3DDevice9Ex*) D3D9Device)->SetLastCreatedVolumeTexture(NULL); //this texture must no be added twice - - Message("LoadTexture( Volume %lu, %#lX): DONE\n", *ppTexture, file_in_memory->Hash); - return (RETURN_OK); -} - -int uMod_TextureClient::LoadTexture( TextureFileStruct* file_in_memory, uMod_IDirect3DCubeTexture9 **ppTexture) // to load fake texture from a file in memory -{ - Message("LoadTexture( Cube %lu, %lu, %#lX): %lu\n", file_in_memory, ppTexture, file_in_memory->Hash, this); - if (D3D_OK != D3DXCreateCubeTextureFromFileInMemoryEx( D3D9Device, file_in_memory->pData, file_in_memory->Size, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, (IDirect3DCubeTexture9 **) ppTexture)) - //if (D3D_OK != D3DXCreateCubeTextureFromFileInMemory( D3D9Device, file_in_memory->pData, file_in_memory->Size, (IDirect3DCubeTexture9 **) ppTexture)) - { - *ppTexture=NULL; - return (RETURN_TEXTURE_NOT_LOADED); - } - (*ppTexture)->FAKE = true; - - void *cpy; - long ret = D3D9Device->QueryInterface( IID_IDirect3DTexture9, &cpy); - if (ret == 0x01000000L) ((uMod_IDirect3DDevice9*)D3D9Device)->SetLastCreatedCubeTexture(NULL); //this texture must no be added twice - else ((uMod_IDirect3DDevice9Ex*) D3D9Device)->SetLastCreatedCubeTexture(NULL); //this texture must no be added twice - - Message("LoadTexture( Cube %lu, %#lX): DONE\n", *ppTexture, file_in_memory->Hash); - return (RETURN_OK); -} - - - - diff --git a/uMod_DXMain/uMod_TextureClient.h b/uMod_DXMain/uMod_TextureClient.h index a0a35f4..499536f 100644 --- a/uMod_DXMain/uMod_TextureClient.h +++ b/uMod_DXMain/uMod_TextureClient.h @@ -18,12 +18,12 @@ along with Universal Modding Engine. If not, see -#ifndef uMod_TEXTUREHANDLER_HPP -#define uMod_TEXTUREHANDLER_HPP +#ifndef uMod_TEXTURECLIENT_HPP +#define uMod_TEXTURECLIENT_HPP #include #include -#include "../uMod_GlobalDefines.h" +#include "..\uMod_GlobalDefines.h" #include "..\uMod_Error.h" @@ -38,22 +38,28 @@ class uMod_TextureServer; class uMod_TextureClient { public: - uMod_TextureClient(uMod_TextureServer* server); - ~uMod_TextureClient(void); + uMod_TextureClient(const int version); + virtual ~uMod_TextureClient(void); + + /** + * Connect to the server. (called from the instance, which creates the client, e.g. uMod_IDirect3DDevice9::uMod_IDirect3DDevice9) + * @return RETURN_OK on success + */ + int ConnectToServer(uMod_TextureServer* server); /** * Enable/Disable the "save all texture" mode. (called from the server) * @param val * @return RETURN_OK on success */ - int SaveAllTextures(bool val); + virtual int SaveAllTextures(bool val) = 0; /** * Enable/Disable the "save all texture" mode. (called from the server) * @param val * @return RETURN_OK on success */ - int SaveSingleTexture(bool val); + virtual int SaveSingleTexture(bool val) = 0; /** * Set the directory, wher the texture should be stored (called from the server) @@ -113,11 +119,13 @@ public: * @return RETURN_OK on success */ int AddUpdate(TextureFileStruct* update, int number); + + /** * Merge the latest update (called from client -> e.g. uMod_IDirect3DDevice9::BeginScene()) * @return RETURN_OK on success */ - int MergeUpdate(void); + virtual int MergeUpdate(void) = 0; bool BoolSaveAllTextures; //< true if all textures should be saved @@ -129,7 +137,8 @@ public: D3DCOLOR FontColour; //< color of the message ("save single texture" mode) D3DCOLOR TextureColour; //< color of the texture ("save single texture" mode) -private: + + const int Version; uMod_TextureServer* Server; //< Pointer to the server wchar_t SavePath[MAX_PATH]; //< saving directory wchar_t GameName[MAX_PATH]; //< game name @@ -152,8 +161,7 @@ private: int NumberToMod; //< number of texture to be modded TextureFileStruct* FileToMod; //< array which stores the file in memory and the hash of each texture to be modded - - int LookUpToMod( MyTypeHash hash, int num_index_list, int *index_list); // called from LookUpToMod(...); + int GetIndex( MyTypeHash hash, int num_index_list=0, int *index_list=(int*)0); // called from LookUpToMod(...); }; diff --git a/uMod_DX9/uMod_TextureFunction.cpp b/uMod_DXMain/uMod_TextureFunction.cpp similarity index 100% rename from uMod_DX9/uMod_TextureFunction.cpp rename to uMod_DXMain/uMod_TextureFunction.cpp diff --git a/uMod_DX9/uMod_TextureFunction.h b/uMod_DXMain/uMod_TextureFunction.h similarity index 100% rename from uMod_DX9/uMod_TextureFunction.h rename to uMod_DXMain/uMod_TextureFunction.h diff --git a/uMod_DXMain/uMod_TextureServer.cpp b/uMod_DXMain/uMod_TextureServer.cpp index 4d977e5..205d323 100644 --- a/uMod_DXMain/uMod_TextureServer.cpp +++ b/uMod_DXMain/uMod_TextureServer.cpp @@ -79,7 +79,7 @@ uMod_TextureServer::~uMod_TextureServer(void) Pipe.Out = INVALID_HANDLE_VALUE; } -int uMod_TextureServer::AddClient(uMod_TextureClient *client, TextureFileStruct** update, int* number) // called from a client +int uMod_TextureServer::AddClient(uMod_TextureClient *client, TextureFileStruct* &update, int &number, const int version) // called from a client { Message("AddClient(%lu): %lu\n", client, this); if (int ret = LockMutex()) @@ -95,6 +95,7 @@ int uMod_TextureServer::AddClient(uMod_TextureClient *client, TextureFileStruct* client->SaveAllTextures(BoolSaveAllTextures); client->SaveSingleTexture(BoolSaveSingleTexture); client->SetSaveDirectory(SavePath); + if (KeyBack > 0) client->SetKeyBack(KeyBack); if (KeySave > 0) client->SetKeySave(KeySave); if (KeyNext > 0) client->SetKeyNext(KeyNext); @@ -135,10 +136,23 @@ int uMod_TextureServer::AddClient(uMod_TextureClient *client, TextureFileStruct* } Clients[NumberOfClients++] = client; - return (UnlockMutex()); + if (int ret = UnlockMutex()) return (ret); + + if (Pipe.Out != INVALID_HANDLE_VALUE) + { + MsgStruct msg; + msg.Control = CONTROL_ADD_CLIENT; + msg.Value = version; + + unsigned long num; + bool ret2 = WriteFile( Pipe.Out, (const void*) &msg, sizeof(msg), &num, NULL); + if (!ret2 || sizeof(msg)!=num) {return (RETURN_PIPE_ERROR);} + if (!FlushFileBuffers(Pipe.Out)) {return (RETURN_PIPE_ERROR);} + } + return (RETURN_OK); } -int uMod_TextureServer::RemoveClient(uMod_TextureClient *client) // called from a client +int uMod_TextureServer::RemoveClient(uMod_TextureClient *client, const int version) // called from a client { Message("RemoveClient(%lu): %lu\n", client); if (int ret = LockMutex()) @@ -153,7 +167,24 @@ int uMod_TextureServer::RemoveClient(uMod_TextureClient *client) // called from Clients[i] = Clients[NumberOfClients]; break; } - return (UnlockMutex()); + + int ret = UnlockMutex(); + if (ret!=RETURN_OK) return (ret); + + + if (Pipe.Out != INVALID_HANDLE_VALUE) + { + MsgStruct msg; + msg.Control = CONTROL_REMOVE_CLIENT; + msg.Value = version; + + unsigned long num; + bool ret2 = WriteFile( Pipe.Out, (const void*) &msg, sizeof(msg), &num, NULL); + if (!ret2 || sizeof(msg)!=num) {return (RETURN_PIPE_ERROR);} + if (!FlushFileBuffers(Pipe.Out)) {return (RETURN_PIPE_ERROR);} + } + + return (RETURN_OK); } int uMod_TextureServer::AddFile( char* buffer, unsigned int size, MyTypeHash hash, bool force) // called from Mainloop() @@ -493,7 +524,7 @@ int uMod_TextureServer::PropagateUpdate(uMod_TextureClient* client) // called fr { TextureFileStruct* update; int number; - if (int ret = PrepareUpdate( &update, &number)) return (ret); + if (int ret = PrepareUpdate( update, number)) return (ret); client->AddUpdate(update, number); } else @@ -502,7 +533,7 @@ int uMod_TextureServer::PropagateUpdate(uMod_TextureClient* client) // called fr { TextureFileStruct* update; int number; - if (int ret = PrepareUpdate( &update, &number)) return (ret); + if (int ret = PrepareUpdate( update, number)) return (ret); Clients[i]->AddUpdate(update, number); } } @@ -528,7 +559,7 @@ int TextureFileStruct_Compare( const void * elem1, const void * elem2 ) return (0); } -int uMod_TextureServer::PrepareUpdate(TextureFileStruct** update, int* number) // called from the PropagateUpdate() and AddClient. +int uMod_TextureServer::PrepareUpdate(TextureFileStruct* &update, int &number) // called from the PropagateUpdate() and AddClient. // Prepare an update for one client. The allocated memory must deleted by the client. { Message("PrepareUpdate(%lu, %d): %lu\n", update, number, this); @@ -549,8 +580,8 @@ int uMod_TextureServer::PrepareUpdate(TextureFileStruct** update, int* number) / } - *update = temp; - *number = num; + update = temp; + number = num; return (RETURN_OK); } #undef cpy_file_struct @@ -806,12 +837,23 @@ int uMod_TextureServer::ClosePipe(void) //called from ExitInstance, this must be { Message("ClosePipe:\n"); + + // We close the outgoing pipe first. // The GUI will notice that the opposite side of it incoming pipe is closed // and closes it outgoing (our incoming) pipe and thus cancel the ReadFile() in the Mainloop() if (Pipe.Out != INVALID_HANDLE_VALUE) { + + MsgStruct msg; + msg.Control = CONTROL_GAME_EXIT; + + unsigned long num; + bool ret2 = WriteFile( Pipe.Out, (const void*) &msg, sizeof(msg), &num, NULL); + if (!ret2 || sizeof(msg)!=num) {return (RETURN_PIPE_ERROR);} + if (!FlushFileBuffers(Pipe.Out)) {return (RETURN_PIPE_ERROR);} + DisconnectNamedPipe(Pipe.Out); CloseHandle(Pipe.Out); Pipe.Out = INVALID_HANDLE_VALUE; diff --git a/uMod_DXMain/uMod_TextureServer.h b/uMod_DXMain/uMod_TextureServer.h index 8a31580..6cd1458 100644 --- a/uMod_DXMain/uMod_TextureServer.h +++ b/uMod_DXMain/uMod_TextureServer.h @@ -39,45 +39,153 @@ class uMod_TextureClient; class uMod_TextureServer { public: + /** + * The server is created from the dll entry routine. + * @param name Name of the game executable (without the extension) + */ uMod_TextureServer(wchar_t *name); ~uMod_TextureServer(void); - int AddClient(uMod_TextureClient *client, TextureFileStruct** update, int* number); // called from a Client - int RemoveClient(uMod_TextureClient *client); // called from a Client + /** + * Each client connect itself to the server via this function. + * @param client This-pointer of the client + * @param update Current texture to be modded + * @param number Number of modded textures + * @param Version Version of DirectX. + * @return RETURN_OK on success + */ + int AddClient(uMod_TextureClient *client, TextureFileStruct* &update, int &number, const int version); // called from a Client + /** + * On destruction of client, it disconnect from the server. + * @param client This-pointer of the client + * @return RETURN_OK on success + */ + int RemoveClient(uMod_TextureClient *client, const int version); // called from a Client + + /** + * Opens the pipe to the GUI (called from the dll entry routine) + * @param name Name of the game + * @return RETURN_OK on success + */ int OpenPipe(wchar_t *name); // called on initialization of our d3d9 fake dll + + /** + * Close the Pipe to the GUI (called if dll entry is called to attach from the game) + * @return RETURN_OK on success + */ int ClosePipe(void); // called on exit of our d3d9 fake dll + + /** + * The mainloop reads from the pipe (blocking reading). It is running in a separate server thread. + * @return RETURN_OK on success + */ int MainLoop(void); // is executed in a server thread - // following functions are only public for testing purpose !! - // they should be private and only be called from the Mainloop - - int AddFile( char* buffer, unsigned int size, MyTypeHash hash, bool force); // called from Mainloop(), if the content of the texture is sent - int AddFile( wchar_t* file_name, MyTypeHash hash, bool force); // called from Mainloop(), if the name and the path to the file is sent - int RemoveFile( MyTypeHash hash); // called from Mainloop() - - int SaveAllTextures(bool val); // called from Mainloop() - int SaveSingleTexture(bool val); // called from Mainloop() - - int SetSaveDirectory( wchar_t *dir); // called from Mainloop() - - - int SetKeyBack( int key); // called from Mainloop() - int SetKeySave( int key); // called from Mainloop() - int SetKeyNext( int key); // called from Mainloop() - - int SetFontColour(DWORD colour); // called from Mainloop() - int SetTextureColour(DWORD colour); // called from Mainloop() private: + /** + * Add a file to the list of texture to be modded (called from the mainloop). + * @param buffer hold the file content of the texture + * @param size size of the file content + * @param hash hash of the texture to be replaced + * @param force set to TRUE to force a reload of the texture + * @return RETURN_OK on success + */ + int AddFile( char* buffer, unsigned int size, MyTypeHash hash, bool force); // called from Mainloop(), if the content of the texture is sent + + /** + * Add a file to the list of texture to be modded (called from the mainloop). + * @param file_name Name and path to the file to be loaded. + * @param hash hash of the texture to be replaced + * @param force set to TRUE to force a reload of the texture + * @return RETURN_OK on success + */ + int AddFile( wchar_t* file_name, MyTypeHash hash, bool force); // called from Mainloop(), if the name and the path to the file is sent + + /** + * Remove a texture (called from the mainloop). + * @param hash Hash of the target texture. + * @return RETURN_OK on success + */ + int RemoveFile( MyTypeHash hash); // called from Mainloop() + + /** + * Save all texture, which are loade by the game (called from the mainloop). + * @param val Set TRUE to enable the mode. + * @return + */ + int SaveAllTextures(bool val); // called from Mainloop() + + /** + * (called from the mainloop). + * @param val + * @return + */ + int SaveSingleTexture(bool val); // called from Mainloop() + + /** + * (called from the mainloop). + * @param dir + * @return + */ + int SetSaveDirectory( wchar_t *dir); // called from Mainloop() + + /** + * (called from the mainloop). + * @param key + * @return + */ + int SetKeyBack( int key); // called from Mainloop() + + /** + * (called from the mainloop). + * @param key + * @return + */ + int SetKeySave( int key); // called from Mainloop() + + /** + * (called from the mainloop). + * @param key + * @return + */ + int SetKeyNext( int key); // called from Mainloop() + + /** + * (called from the mainloop). + * @param colour + * @return + */ + int SetFontColour(DWORD colour); // called from Mainloop() + + /** + * (called from the mainloop). + * @param colour + * @return + */ + int SetTextureColour(DWORD colour); // called from Mainloop() + bool BoolSaveAllTextures; bool BoolSaveSingleTexture; wchar_t SavePath[MAX_PATH]; wchar_t GameName[MAX_PATH]; + /** + * Send the files to be modded (Update) to a client (called from the mainloop). + * @param client Pointer to a client (if NULL is passed, the data is send to all clients) + * @return + */ int PropagateUpdate(uMod_TextureClient* client=NULL); // called from Mainloop() if texture are loaded or removed - int PrepareUpdate(TextureFileStruct** update, int* number); // called from PropagateUpdate() and AddClient() + + /** + * Prepare the texture data for the clients (e.g. Load the texture from disk, sort the texture according the hash values) (called from the mainloop). + * @param update + * @param number + * @return + */ + int PrepareUpdate(TextureFileStruct* &update, int &number); // called from PropagateUpdate() and AddClient() // generate a copy of the current texture to be modded // the file content of the textures are not copied, the clients get the pointer to the file content // but the arrays allocate by this function, must be deleted by the client diff --git a/uMod_Error.h b/uMod_Error.h index d7a790e..46f865c 100644 --- a/uMod_Error.h +++ b/uMod_Error.h @@ -49,6 +49,7 @@ along with Universal Modding Engine. If not, see #define RETURN_FILE_NOT_LOADED -51 #define RETURN_PIPE_NOT_OPENED 60 +#define RETURN_PIPE_ERROR 61 diff --git a/uMod_GUI/bin/README_French.txt b/uMod_GUI/bin/README_French.txt new file mode 100644 index 0000000..e15a079 --- /dev/null +++ b/uMod_GUI/bin/README_French.txt @@ -0,0 +1,110 @@ +ATTENTION : Vous utilisez ce programme à vous risque ! +1) Si le programme plante, vous n'aurez probablement aucune aide des développeurs, + mais vous pouvez envoyer le bogue sur http://code.google.com/p/texmod/issues/list +2) Les jeux peuvent détecter les modifications de uMod, vous prenez le risque de bannir + votre compte en ligne ! +3) C'est un projet open-source. Le code peut être récupéré, modifié et compilé + par tout le monde. Téléchargez Universal Modding Engine seulement sur des sources sûres ! + Ne télécharger pas et n'utiliser pas d'autres versions modifiées de ce logiciel, + par exemple des versions envoyées par votre équipe ou votre guilde ! + Le site officiel : http://code.google.com/p/texmod/downloads/list + +Universal Modding Engine utilise le D3DX9_43.dll (32bit). En raison de la licence CLUF cette dll +ne peut pas être livrée avec Universal Modding Engine . Si vous n'avez pas D3DX9_43.dll +d'installé sur votre système, Universal Modding Engine va vous afficher un message +au démarrage du programme. + + +Que fait Universal Modding Engine (uMod) V1.0 ? + +-Extraire et sauvegarder des textures d'un jeu DX9 (la texture d'origine peut se modifier) +-Extraire et sauvegarder toutes les textures d'un jeu DX9 +-Charger des textures dans un jeu pour remplacer les textures d'origines +-Supporte les textures DDS +-Supporte les fichiers compressés (ZIP) pour faire un MOD (modifier plusieurs textures à la fois) +-Supporte les fichiers de TexMod *.tpf + +Toutes les options peuvent s'activer ou se désactiver, pendant que le jeu est lancé ! +Ainsi, vous pouvez rechercher une texture dans le jeu, l'enregistrer sur disque, la modifier, +la charger dans le jeu, éditer une autre texture, la charger dans le jeu, etc..., +Activer ou désactiver des MODs sans aucun redémarrage du jeu. + +Remarque : Si vous cochez "Sauvegarder toutes les textures", les textures qui seront enregistrées, +sont les textures chargées dans le jeu après le moment où vous avez coché la case. +Si vous activez cette option, pendant qu'une carte est chargée, vous n'allez probablement rien enregistrer, +parce que toutes les textures sont déjà chargées. Changez de Carte ou rechargez-là. + +Les fichiers compressés peuvent inclure le fichier "texmod.def" qui contient le hash et le nom du fichier. +Chaque ligne doit avoir le format "hash|filename.dds" +Si elle ne contient pas un "texmod.def" chaque fichier sera décompressé et seuls les fichiers ayant +le format "*_hash.dds" seront utilisés. +Le fichier zip peut inclure un fichier "Comment.txt". Le contenu sera affiché comme commentaire +dans l'interface graphique. + +Si vous chargez des textures seules, elles doivent correspondre au format "*_hash.dds" + + +Comment Universal Modding Engine interagit avec les jeux ? + +Universal Modding Engine intercepte la connexion entre le jeu et DirectX. +Il est nécessaire, que Universal Modding Engine soit lancé avant le jeu. + +L'interface graphique de Universal Modding Engine est comme un serveur. +Un jeu correctement intercepté par Universal Modding Engine-dll se connectera au démarrage sur le serveur. +L'interface graphique de Universal Modding Engine peut gérer plusieurs jeux en même temps. Il sera +également traiter chaque jeu en tant que processus indépendant (si le même jeu +a été lancé plus d'une fois). + + +Comment Universal Modding Engine fonctionne ? + +Il y a trois façon pour que Universal Modding Engine intercepte la connexion à DirectX : +(Ne PAS utiliser plus d'une méthode à la fois !) + +1) Ajouter l'exécutable du jeu dans le menu "Réglages->Ajouter un jeu" + Pour Steam, voir plus bas. + + Problèmes connus : Guild Wars (Win XP) + +2) Lancer le jeu directement via le menu uMod + "Réglages->Lancer le jeu avec uMod" ou + "Réglages->Lancer le jeu avec uMod (en ligne de commande)". + Le jeu se lance directement. + +3) Copier le d3d9.dll (depuis le répertoire de Universal Modding Engine) dans votre dossier de jeu. + Certain jeu recherche les DLLs dans leur répertoire avant d'aller chercher les DLLs dans + le dossier du système. + Cette méthode ne fonctionne que sur certain jeu. + ATTENTION : Ne jamais copier ce fichier DLL dans votre répertoire système !!! + + Problèmes connus : Guild Wars + +Si vous avez choisi la première ou la troisième méthode, il vous suffit de lancer Universal Modding Engine +et de lancer le jeu séparément. Ne PAS lancer le jeu via uMod. + +Si le jeu se lance et tout fonctionne, un nouveau onglet va s'ouvrir directement dans uMod. +Dans cet onglet vous pouvez modifier le jeu. Appuyer sur "Mettre à jour" +pour envoyer les changements au jeu. Vous pouvez sauvegarder vos paramètres actuels comme thème. +Un thème peut être lancé par défaut au démarrage d'un jeu. + +Pour charger une texture ou un mod, vous devez cocher la case du fichier. Si vous voulez décharger un mod, +il faut simplement décocher la case et cliquer sur "Mettre à jour". + +En cliquant sur "Mettre à jour", seules les textures chargées dans uMod seront misent à jour +(si une texture chargée est supprimée de la liste, cela va juste décocher la texture). +Cliquez sur "Mettre à jour (Recharger)" pour recharger les fichiers de texture sur le disque dur. +(Si vous venez de modifier une texture déjà chargée par exemple). + +En raison du fait que plusieurs mods peuvent modifier la même texture, seuls le mod / la texture +du premier fichier de la liste est pris en compte pour la modification. L'action de ce mod +(c'est à dire le chargement ou le déchargement) est effectuée, indépendamment des autres mods. + + +Comment faire pour que Universal Modding Engine fonctionne avec Steam ? + +Universal Modding Engine cherche le nom et le chemin du fichier binaire exécuté. +Ainsi vous ne devez pas ajouter Steam.exe mais plutôt le game.exe +exemple : C:\Steam\SteamApps\acoount_name\portal\hl2.exe +Si vous ne trouvez pas l'exécutable, il suffit de commencer le jeu et +d'utiliser "le Gestionnaire des tâches" pour rechercher dans quel dossier il se trouve en +faisant un clique droit sur le nom de l'exécutable "Propriétés"->"Emplacement". \ No newline at end of file diff --git a/uMod_GUI/bin/languages/uMod_LanguagePack_Italian.txt b/uMod_GUI/bin/languages/uMod_LanguagePack_Italian.txt new file mode 100644 index 0000000..ad81e27 --- /dev/null +++ b/uMod_GUI/bin/languages/uMod_LanguagePack_Italian.txt @@ -0,0 +1,75 @@ +# by mirHL| + +MenuHelp:Aiuto| +MenuAbout:Informazioni| +MenuAcknowledgement:Riconoscimenti| +MenuStartGame:Avvia il gioco da uMod| +MenuStartGameCMD:Avvia il gioco da uMod (con riga di comando)| +MenuUseHook:Usa hook globale| +MenuAddGame:Aggiungi gioco| +MenuDeleteGame:Rimuovi gioco| +MenuLoadTemplate:Carica template| +MenuSaveTemplate:Salva template| +MenuSaveTemplateAs:Salva template come...| +MenuSetDefaultTemplate:Imposta template come predefinito| +MenuLanguage:Cambia lingua (Change language)| +MenuExit:Esci| +MainMenuMain:Comandi| +MainMenuHelp:Aiuto| + + +ButtonOpen:Apri texture/archivio| +ButtonDirectory:Imposta cartella lavoro| +ButtonUpdate:Aggiorna| +ButtonReload:Aggiorna (ricarica)| + + +ChooseFile:Seleziona un file| +ChooseDir:Seleziona una cartella| +CheckBoxSaveSingleTexture:Salva singole texture| +TextCtrlTemplate:Template: | +CheckBoxSaveAllTextures:Salva tutte le texture| +TextCtrlSavePath:Percorso lavori: | +SelectLanguage:Seleziona una lingua| +StartGame:Seleziona il gioco da far partire.| +CommandLine:Imposta opzioni da riga di comando.| +ChooseGame:Seleziona un eseguibile di un gioco.| +DeleteGame:Seleziona i giochi da rimuovere.| +GameAlreadyAdded:Il gioco è già stato aggiunto.| +ExitGameAnyway:Chiudere uMod mentre il gioco è in esecuzione potrebbe farlo crashare. +Uscire comunque?| +NoComment:Nessun commento.| +Author:Autore: | + + +Error_GameIsHooked:L'hook globale è attivo e questo è in conflitto col lancio! Per favore rimuovi il gioco dalla lista o spegni l'hook.| +Error_ProcessNotStarted:Il gioco non è potuto essere avviato.| +Error_RemoveHook:Rimuovere l'Hook mentre il gioco è in esecuzione potrebbe farlo crashare.| +Error_FileNotSupported:Questo tipo di file non è supportato:| +Error_DLLNotFound: +Impossibile caricare la dll. +La dll injection non funzionerà. +Questo accade perchè D3DX9_43.dll non è installato nel sistema. +Installa DirectX End-User Runtime Web Installer.| +Error_FktNotFound:Impossibile caricare una funzione fuori della dll. +La dll injection non funzionerà.| +Error_AlreadyRunning:Un altro processo di uMod è in esecuzione.| +Error_Send:Impossibile arrivare al gioco.| +Error_KeyTwice:Hai assegnato due volte lo stesso tasto.| +Error_NoSavePath:Non hai selezionato un percorso di salvataggio.| +Error_KeyNotSet:Qualche tasto non è assegnato.| +Error_SaveFile:Impossibile salvare il file.| +Error_NoPipe:Pipe non è aperto.| +Error_WritePipe:impossibile scrivere in pipe.| +Error_FlushPipe:Impossibile ripulire pipe buffer.| +Error_Hash:Impossibile trovare l'hash, forse il file non è chiamato *_HASH.dds| +Error_FileOpen:Impossibile aprire il file.| +Error_FileRead:Impossibile leggere il file.| +Error_Memory:Impossibile allocare abbastanza memoria| +Error_Unzip:Impossibile scomprimere.| +Error_ZipEntry:Impossibile trovare Zip entry.| +KeyBack:Precedente| +KeySave:Salva| +KeyNext:Successivo| +FontColour:Colore caratteri (RGB):| +TextureColour:Colore texture (RGB):| \ No newline at end of file diff --git a/uMod_GUI/uMod_Client.cpp b/uMod_GUI/uMod_Client.cpp index 4d99934..bafe779 100644 --- a/uMod_GUI/uMod_Client.cpp +++ b/uMod_GUI/uMod_Client.cpp @@ -46,7 +46,8 @@ uMod_Client::~uMod_Client(void) void* uMod_Client::Entry(void) { char buffer[SMALL_BUFSIZE]; - while (1) + bool run = true; + while (run) { unsigned long size; bool ret = ReadFile( @@ -56,28 +57,48 @@ void* uMod_Client::Entry(void) &size, // number of bytes read NULL); // not overlapped I/O - if (ret || GetLastError()==ERROR_MORE_DATA) + if (ret)// || GetLastError()==ERROR_MORE_DATA) { unsigned int pos=0; MsgStruct *commands; bool update_textures = false; - while (posControl) { + case CONTROL_ADD_CLIENT: + { + uMod_Event event( uMod_EVENT_TYPE, ID_Add_Device); + event.SetValue(commands->Value); + event.SetClient(this); + wxPostEvent( MainFrame, event); + break; + } + case CONTROL_REMOVE_CLIENT: + { + uMod_Event event( uMod_EVENT_TYPE, ID_Delete_Device); + event.SetValue(commands->Value); + event.SetClient(this); + wxPostEvent( MainFrame, event); + break; + } + case CONTROL_GAME_EXIT: + { + run = false; + pos=size; + break; + } } - */ + pos+=sizeof(MsgStruct);// + add_length; } } - else - { - break; - } + else if (GetLastError()!=ERROR_MORE_DATA) run = false; } CloseHandle(Pipe.In); Pipe.In = INVALID_HANDLE_VALUE; diff --git a/uMod_GUI/uMod_Event.h b/uMod_GUI/uMod_Event.h index 5c09fe9..312da55 100644 --- a/uMod_GUI/uMod_Event.h +++ b/uMod_GUI/uMod_Event.h @@ -38,7 +38,13 @@ public: // You *must* copy here the data to be transported uMod_Event( const uMod_Event &event ) - : wxCommandEvent(event) { this->SetText( event.GetText()); PipeIn=((uMod_Event&)event).GetPipeIn(); PipeOut=((uMod_Event&)event).GetPipeOut(); Name=((uMod_Event&)event).GetName(); Client=((uMod_Event&)event).GetClient();} + : wxCommandEvent(event) + { this->SetText( event.GetText()); + Value=((uMod_Event&)event).GetValue(); + PipeIn=((uMod_Event&)event).GetPipeIn(); PipeOut=((uMod_Event&)event).GetPipeOut(); + Name=((uMod_Event&)event).GetName(); + Client=((uMod_Event&)event).GetClient(); + } // Required for sending with wxPostEvent() wxEvent* Clone() const { return new uMod_Event(*this); } @@ -46,11 +52,13 @@ public: wxString GetText() const { return m_Text; } void SetText( const wxString& text ) { m_Text = text; } + int GetValue(void) {return Value;} wxString GetName(void) {return Name;} HANDLE GetPipeIn(void) {return PipeIn;} HANDLE GetPipeOut(void) {return PipeOut;} uMod_Client * GetClient(void) {return Client;} + void SetValue(int value) {Value=value;} void SetName( wxString name) {Name=name;} void SetPipeIn( HANDLE pipe) {PipeIn=pipe;} void SetPipeOut( HANDLE pipe) {PipeOut=pipe;} @@ -58,6 +66,7 @@ public: private: + int Value; wxString Name; HANDLE PipeIn; HANDLE PipeOut; diff --git a/uMod_GUI/uMod_GUI.cpp b/uMod_GUI/uMod_GUI.cpp index 2023593..293fce1 100644 --- a/uMod_GUI/uMod_GUI.cpp +++ b/uMod_GUI/uMod_GUI.cpp @@ -60,6 +60,8 @@ BEGIN_EVENT_TABLE(uMod_Frame, wxFrame) EVT_COMMAND (ID_Add_Game, uMod_EVENT_TYPE, uMod_Frame::OnAddGame) EVT_COMMAND (ID_Delete_Game, uMod_EVENT_TYPE, uMod_Frame::OnDeleteGame) + EVT_COMMAND (ID_Add_Device, uMod_EVENT_TYPE, uMod_Frame::OnAddDevice) + EVT_COMMAND (ID_Delete_Device, uMod_EVENT_TYPE, uMod_Frame::OnRemoveDevice) END_EVENT_TABLE() IMPLEMENT_APP(MyApp) @@ -260,10 +262,7 @@ void uMod_Frame::OnAddGame( wxCommandEvent &event) delete page; return; } - name = name.AfterLast('\\'); - name = name.AfterLast('/'); - name = name.BeforeLast('.'); - Notebook->AddPage( page, name, true); + Notebook->AddPage( page, page->GetPageName(), true); Clients[NumberOfGames] = client; NumberOfGames++; @@ -286,6 +285,29 @@ void uMod_Frame::OnDeleteGame( wxCommandEvent &event) } } +void uMod_Frame::OnAddDevice( wxCommandEvent &event) +{ + uMod_Client *client = ((uMod_Event&)event).GetClient(); + for (int i=0; iGetPage(i); + page->AddDXDevice(((uMod_Event&)event).GetValue()); + Notebook->SetPageText( i, page->GetPageName()); + return; + } +} + +void uMod_Frame::OnRemoveDevice( wxCommandEvent &event) +{ + uMod_Client *client = ((uMod_Event&)event).GetClient(); + for (int i=0; iGetPage(i); + page->RemoveDXDevice(((uMod_Event&)event).GetValue()); + Notebook->SetPageText( i, page->GetPageName()); + return; + } +} void uMod_Frame::OnClose(wxCloseEvent& event) { diff --git a/uMod_GUI/uMod_GUI.h b/uMod_GUI/uMod_GUI.h index 3a47af1..4f74519 100644 --- a/uMod_GUI/uMod_GUI.h +++ b/uMod_GUI/uMod_GUI.h @@ -31,10 +31,33 @@ public: ~uMod_Frame(void); - + /** + * A game has started and opend a pipe to the GUI. The Server thus create an event and send it to the main frame. + * @param event + */ void OnAddGame( wxCommandEvent &event); + /** + * A game has quite and closed it pipe to the GUI. The Server thus create an event and send it to the main frame. + * @param event + */ void OnDeleteGame( wxCommandEvent &event); + /** + * A game has created a DX device. The Server thus create an event and send it to the main frame. + * @param event + */ + void OnAddDevice( wxCommandEvent &event); + /** + * A game has deleted a DX device. The Server thus create an event and send it to the main frame. + * @param event + */ + void OnRemoveDevice( wxCommandEvent &event); + + + /** + * The user tries to close the GUI. + * @param WXUNUSED + */ void OnClose(wxCloseEvent& WXUNUSED(event)); diff --git a/uMod_GUI/uMod_GamePage.cpp b/uMod_GUI/uMod_GamePage.cpp index 34b330a..19a5fed 100644 --- a/uMod_GUI/uMod_GamePage.cpp +++ b/uMod_GUI/uMod_GamePage.cpp @@ -25,6 +25,9 @@ uMod_GamePage::uMod_GamePage( wxNotebook *parent, const wxString &exe, const wxS ExeName = exe; TemplateName = save; + + CounterDX9 = 0; CounterDX9EX = 0; + CounterDX10 = 0; CounterDX10EX = 0; //SetBackgroundColour( *wxLIGHT_GREY); //SetBackgroundColour( wxColour( "LIGHT GREY")); @@ -185,6 +188,79 @@ int uMod_GamePage::AddTexture( const wxString &file_name) return UpdateGame(); } + +wxString uMod_GamePage::GetPageName(void) +{ + wxString ret; + ret = ExeName; + + ret = ret.AfterLast('\\'); + ret = ret.AfterLast('/'); + ret = ret.BeforeLast('.'); + if (CounterDX9 || CounterDX9EX || CounterDX10 || CounterDX10EX) + { + wxString temp; + ret.append(" ("); + if (CounterDX9) + { + temp.Printf("DX9: %d", CounterDX9); + ret.append(temp); + } + if (CounterDX9EX) + { + if (!temp.IsEmpty()) ret.append(","); + temp.Printf("DX9EX: %d", CounterDX9EX); + ret.append(temp); + } + if (CounterDX10) + { + if (!temp.IsEmpty()) ret.append(","); + temp.Printf("DX10: %d", CounterDX10); + ret.append(temp); + } + if (CounterDX10EX) + { + if (!temp.IsEmpty()) ret.append(","); + temp.Printf("DX10EX: %d", CounterDX10EX); + ret.append(temp); + } + ret.append(")"); + } + return ret; +} + +int uMod_GamePage::AddDXDevice(int version) +{ + switch (version) + { + case VERSION_DX9: + CounterDX9++; break; + case VERSION_DX9EX: + CounterDX9EX++; break; + case VERSION_DX10: + CounterDX10++; break; + case VERSION_DX10EX: + CounterDX10EX++; break; + } + return 0; +} + +int uMod_GamePage::RemoveDXDevice(int version) +{ + switch (version) + { + case VERSION_DX9: + if (CounterDX9>0) CounterDX9--; break; + case VERSION_DX9EX: + if (CounterDX9EX>0) CounterDX9EX--; break; + case VERSION_DX10: + if (CounterDX10>0) CounterDX10--; break; + case VERSION_DX10EX: + if (CounterDX10EX>0) CounterDX10EX--; break; + } + return 0; +} + int uMod_GamePage::GetSettings(void) { int key_back = ChoiceKeyBack->GetSelection(); diff --git a/uMod_GUI/uMod_GamePage.h b/uMod_GUI/uMod_GamePage.h index d1bc27e..cfc2f8d 100644 --- a/uMod_GUI/uMod_GamePage.h +++ b/uMod_GUI/uMod_GamePage.h @@ -53,10 +53,18 @@ public: int UpdateLanguage(void); + wxString GetPageName(void); + int AddDXDevice(int version); + int RemoveDXDevice(int version); + + wxString LastError; private: + int CounterDX9, CounterDX9EX; + int CounterDX10, CounterDX10EX; + int GetSettings(void); int SetColour( wxTextCtrl** txt, int *colour); int GetColour( wxTextCtrl* txt, int def); diff --git a/uMod_GUI/uMod_Main.h b/uMod_GUI/uMod_Main.h index 9a15bfe..20ed801 100644 --- a/uMod_GUI/uMod_Main.h +++ b/uMod_GUI/uMod_Main.h @@ -98,6 +98,8 @@ enum ID_Menu_SetDefaultTemplate, ID_Add_Game, ID_Delete_Game, + ID_Add_Device, + ID_Delete_Device, ID_Button_Texture, //this entry must be the last!! }; diff --git a/uMod_GUI/uMod_Sender.cpp b/uMod_GUI/uMod_Sender.cpp index 59db37f..2e0521e 100644 --- a/uMod_GUI/uMod_Sender.cpp +++ b/uMod_GUI/uMod_Sender.cpp @@ -32,6 +32,7 @@ uMod_Sender::uMod_Sender(PipeStruct &pipe) : Pipe(pipe) uMod_Sender::~uMod_Sender(void) { if (Buffer!=NULL) delete [] Buffer; + if (OldTextures!=NULL) delete [] OldTextures; } diff --git a/uMod_GlobalDefines.h b/uMod_GlobalDefines.h index 00e72fb..bad1377 100644 --- a/uMod_GlobalDefines.h +++ b/uMod_GlobalDefines.h @@ -52,6 +52,7 @@ typedef struct #define CONTROL_FORCE_RELOAD_TEXTURE_DATA 4 #define CONTROL_ADD_TEXTURE_DATA 5 #define CONTROL_MORE_TEXTURES 6 +#define CONTROL_END_TEXTURES 7 #define CONTROL_SAVE_ALL 10 @@ -66,6 +67,15 @@ typedef struct #define CONTROL_TEXTURE_COLOUR 31 +#define CONTROL_GAME_EXIT 100 +#define CONTROL_ADD_CLIENT 101 +#define CONTROL_REMOVE_CLIENT 102 +#define VERSION_DX9 90 +#define VERSION_DX9EX 91 +#define VERSION_DX10 100 +#define VERSION_DX10EX 101 +#define VERSION_DX11 110 +#define VERSION_DX11EX 111 #endif