uMod2 Alpha Version: known bugs: I disabled the remove device function inside the gui, because something in the event handling goes terrible wrong.

Implemented a some new features.
This commit is contained in:
code@koerner-de.net
2012-07-15 18:59:03 +00:00
parent d99107a919
commit 0bc7eebede
69 changed files with 7973 additions and 2391 deletions
+49 -17
View File
@@ -19,9 +19,9 @@ endif
ifdef NI
ifdef LOG_MESSAGE
precompiler_flag = /D "LOG_MESSAGE" /D "NO_INJECTION"
precompiler_flag = /D "LOG_MESSAGE" /D "INJECTION_METHOD=3"
else
precompiler_flag = /D "NO_INJECTION"
precompiler_flag = /D "INJECTION_METHOD=3"
endif
def_file = /DEF:"uMod_DX$(DX_XX_File)_dll_NO_INJECTION.def"
@@ -32,9 +32,9 @@ else
ifdef DI
ifdef LOG_MESSAGE
precompiler_flag = /D "LOG_MESSAGE" /D "DIRECT_INJECTION"
precompiler_flag = /D "LOG_MESSAGE" /D "INJECTION_METHOD=2"
else
precompiler_flag = /D "DIRECT_INJECTION"
precompiler_flag = /D "INJECTION_METHOD=2"
endif
def_file = /DEF:"uMod_DX$(DX_XX_File)_dll_DIRECT_INJECTION.def"
@@ -44,9 +44,9 @@ dll = uMod_d3d$(DX_XX_File)_DI.dll
else
ifdef LOG_MESSAGE
precompiler_flag = /D "LOG_MESSAGE" /D "HOOK_INJECTION"
precompiler_flag = /D "LOG_MESSAGE" /D "INJECTION_METHOD=1"
else
precompiler_flag = /D "HOOK_INJECTION"
precompiler_flag = /D "INJECTION_METHOD=1"
endif
def_file = /DEF:"uMod_DX$(DX_XX_File)_dll_HOOK_INJECTION.def"
@@ -58,11 +58,19 @@ endif
CXX = cl
CLINK = link.exe
DEFINES = /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "_WINDLL" /D "_MBCS" $(DX_XX_Flag)
DEFINES = /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_WINDLL" /D "_MBCS" /D "_UNICODE" "/D UNICODE" $(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
CFLAGS = /I "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include" /nologo /W3 /WX- /O2 /Oi /Oy- /GL ${DEFINES} ${precompiler_flag} /Gm- /EHsc /MT /Gy- /fp:precise /Zc:wchar_t /Zc:forScope /Gd /TP /analyze-
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
CFLAGS = /I "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include" /nologo /W3 /WX- /O2 /Oi /Oy- /GL \
${DEFINES} ${precompiler_flag} /Gm- /EHsc /MT /GS- /Gy- /fp:precise /Zc:wchar_t /Zc:forScope /Gd /TP /analyze-
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} /MANIFEST:NO \
/SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86
#/nologo /W3 /WX- /O2 /Oi /Oy- /GL /D WIN32 /D NDEBUG /D _WINDOWS /D _USRDLL /D D3DSTARTERKIT_EXPORTS /D _WINDLL /D _UNICODE /D UNICODE /Gm- /EHsc /MT /GS- /Gy- /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Release\\" /Fd"Release\vc100.pdb" /Gd /TP /analyze-
obj = obj
bin = bin
@@ -83,13 +91,13 @@ objects = \
${obj}\uMod_IDirect3DVolumeTexture9.${obj_suff} \
${obj}\uMod_IDirect3DCubeTexture9.${obj_suff} \
\
${obj}\uMod_DX10_dll.${obj_suff}
#\
#${obj}\cpu.obj \
#${obj}\disasm.obj \
#${obj}\disasm_x86.obj \
#${obj}\mhook.obj \
#${obj}\misc.obj
${obj}\uMod_DX10_dll.${obj_suff} \
${obj}\uMod_ID3D10Device.${obj_suff} \
${obj}\uMod_ID3D10Device1.${obj_suff} \
${obj}\uMod_ID3D10Texture1D.${obj_suff} \
${obj}\uMod_ID3D10Texture2D.${obj_suff} \
${obj}\uMod_ID3D10Texture3D.${obj_suff} \
${obj}\uMod_IDXGISwapChain.${obj_suff}
headers = uMod_Main.h \
@@ -110,7 +118,13 @@ DX9_headers = \
..\uMod_DX9\uMod_IDirect3DCubeTexture9.h
DX10_headers = \
..\uMod_DX10\uMod_DX10_dll.h
..\uMod_DX10\uMod_DX10_dll.h \
..\uMod_DX10\uMod_ID3D10Device.h \
..\uMod_DX10\uMod_ID3D10Device1.h \
..\uMod_DX10\uMod_ID3D10Texture1D.h \
..\uMod_DX10\uMod_ID3D10Texture2D.h \
..\uMod_DX10\uMod_ID3D10Texture3D.h \
..\uMod_DX10\uMod_IDXGISwapChain.h
${bin}\d3d9.dll: ${objects}
${CLINK} ${LFLAGS} ${objects} /OUT:${bin}\${dll}
@@ -164,5 +178,23 @@ ${obj}\uMod_IDirect3DCubeTexture9.${obj_suff}: ..\uMod_DX9\uMod_IDirect3DCubeTex
${obj}\uMod_DX10_dll.${obj_suff}: ..\uMod_DX10\uMod_DX10_dll.cpp ${headers} ${DX10_headers}
${CXX} ${CFLAGS} /c $< /Fo$@
${obj}\uMod_ID3D10Device.${obj_suff}: ..\uMod_DX10\uMod_ID3D10Device.cpp ${headers} ${DX10_headers}
${CXX} ${CFLAGS} /c $< /Fo$@
${obj}\uMod_ID3D10Device1.${obj_suff}: ..\uMod_DX10\uMod_ID3D10Device1.cpp ${headers} ${DX10_headers} ..\uMod_DX10\uMod_ID3D10Device.cpp
${CXX} ${CFLAGS} /c $< /Fo$@
${obj}\uMod_ID3D10Texture1D.${obj_suff}: ..\uMod_DX10\uMod_ID3D10Texture1D.cpp ${headers} ${DX10_headers}
${CXX} ${CFLAGS} /c $< /Fo$@
${obj}\uMod_ID3D10Texture2D.${obj_suff}: ..\uMod_DX10\uMod_ID3D10Texture2D.cpp ${headers} ${DX10_headers}
${CXX} ${CFLAGS} /c $< /Fo$@
${obj}\uMod_ID3D10Texture3D.${obj_suff}: ..\uMod_DX10\uMod_ID3D10Texture3D.cpp ${headers} ${DX10_headers}
${CXX} ${CFLAGS} /c $< /Fo$@
${obj}\uMod_IDXGISwapChain.${obj_suff}: ..\uMod_DX10\uMod_IDXGISwapChain.cpp ${headers} ${DX10_headers}
${CXX} ${CFLAGS} /c $< /Fo$@
clean:
del ${objects} ${bin}\${dll}
+159 -76
View File
@@ -1,117 +1,200 @@
!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"
!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 "INJECTION_METHOD=3"
!else
precompiler_flag = /D "INJECTION_METHOD=3"
!endif
def_file = /DEF:"uMod_DX$(DX_XX_File)_dll_NO_INJECTION.def"
obj_suff = NI.obj
dll = d3d9.dll
dll = d3d$(DX_XX_File).dll
!ELSE
!else
!IFDEF DI
!IFDEF LOG_MESSAGE
precompiler_flag = /D "LOG_MESSAGE" /D "DIRECT_INJECTION"
!ELSE
precompiler_flag = /D "DIRECT_INJECTION"
!ENDIF
!ifdef DI
!ifdef LOG_MESSAGE
precompiler_flag = /D "LOG_MESSAGE" /D "INJECTION_METHOD=2"
!else
precompiler_flag = /D "INJECTION_METHOD=2"
!endif
def_file = /DEF:"uMod_DX9_dll_DIRECT_INJECTION.def"
def_file = /DEF:"uMod_DX$(DX_XX_File)_dll_DIRECT_INJECTION.def"
obj_suff = DI.obj
dll = uMod_d3d9_DI.dll
dll = uMod_d3d$(DX_XX_File)_DI.dll
!ELSE
!else
!IFDEF LOG_MESSAGE
precompiler_flag = /D "LOG_MESSAGE" /D "HOOK_INJECTION"
!ELSE
precompiler_flag = /D "HOOK_INJECTION"
!ENDIF
!ifdef LOG_MESSAGE
precompiler_flag = /D "LOG_MESSAGE" /D "INJECTION_METHOD=1"
!else
precompiler_flag = /D "INJECTION_METHOD=1"
!endif
def_file = /DEF:"uMod_DX9_dll_HOOK_INJECTION.def"
def_file = /DEF:"uMod_DX$(DX_XX_File)_dll_HOOK_INJECTION.def"
obj_suff = HI.obj
dll = uMod_d3d9_HI.dll
!ENDIF
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"
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
DEFINES = /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_WINDLL" /D "_MBCS" /D "_UNICODE" "/D UNICODE" $(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
CFLAGS = /I "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include" /nologo /W3 /WX- /O2 /Oi /Oy- /GL \
$(DEFINES) $(precompiler_flag) /Gm- /EHsc /MT /GS- /Gy- /fp:precise /Zc:wchar_t /Zc:forScope /Gd /TP /analyze-
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) /MANIFEST:NO \
/SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86
#/nologo /W3 /WX- /O2 /Oi /Oy- /GL /D WIN32 /D NDEBUG /D _WINDOWS /D _USRDLL /D D3DSTARTERKIT_EXPORTS /D _WINDLL /D _UNICODE /D UNICODE /Gm- /EHsc /MT /GS- /Gy- /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Release\\" /Fd"Release\vc100.pdb" /Gd /TP /analyze-
obj = obj
bin = bin
objects = $(obj)\uMod_DX9_dll.$(obj_suff) \
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_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)
\
$(obj)\uMod_DX10_dll.$(obj_suff) \
$(obj)\uMod_ID3D10Device.$(obj_suff) \
$(obj)\uMod_ID3D10Device1.$(obj_suff) \
$(obj)\uMod_ID3D10Texture1D.$(obj_suff) \
$(obj)\uMod_ID3D10Texture2D.$(obj_suff) \
$(obj)\uMod_ID3D10Texture3D.$(obj_suff) \
$(obj)\uMod_IDXGISwapChain.$(obj_suff)
headers = uMod_Main.h \
uMod_DXMain_dll.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
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
DX10_headers = \
..\uMod_DX10\uMod_DX10_dll.h \
..\uMod_DX10\uMod_ID3D10Device.h \
..\uMod_DX10\uMod_ID3D10Device1.h \
..\uMod_DX10\uMod_ID3D10Texture1D.h \
..\uMod_DX10\uMod_ID3D10Texture2D.h \
..\uMod_DX10\uMod_ID3D10Texture3D.h \
..\uMod_DX10\uMod_IDXGISwapChain.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$@ uMod_DX9_dll.cpp
$(obj)\uMod_IDirect3D9.$(obj_suff): uMod_IDirect3D9.cpp $(headers)
$(CXX) $(CFLAGS) /c /Fo$@ uMod_IDirect3D9.cpp
$(obj)\uMod_IDirect3D9Ex.$(obj_suff): uMod_IDirect3D9Ex.cpp $(headers)
$(CXX) $(CFLAGS) /c /Fo$@ uMod_IDirect3D9Ex.cpp
$(obj)\uMod_IDirect3DDevice9.$(obj_suff): uMod_IDirect3DDevice9.cpp $(headers)
$(CXX) $(CFLAGS) /c /Fo$@ uMod_IDirect3DDevice9.cpp
$(obj)\uMod_IDirect3DDevice9Ex.$(obj_suff): uMod_IDirect3DDevice9Ex.cpp $(headers)
$(CXX) $(CFLAGS) /c /Fo$@ uMod_IDirect3DDevice9Ex.cpp
$(obj)\uMod_TextureFunction.$(obj_suff): uMod_TextureFunction.cpp $(headers)
$(CXX) $(CFLAGS) /c /Fo$@ uMod_TextureFunction.cpp
$(obj)\uMod_IDirect3DTexture9.$(obj_suff): uMod_IDirect3DTexture9.cpp $(headers)
$(CXX) $(CFLAGS) /c /Fo$@ uMod_IDirect3DTexture9.cpp
$(obj)\uMod_IDirect3DVolumeTexture9.$(obj_suff): uMod_IDirect3DVolumeTexture9.cpp $(headers)
$(CXX) $(CFLAGS) /c /Fo$@ uMod_IDirect3DVolumeTexture9.cpp
$(obj)\uMod_IDirect3DCubeTexture9.$(obj_suff): uMod_IDirect3DCubeTexture9.cpp $(headers)
$(CXX) $(CFLAGS) /c /Fo$@ uMod_IDirect3DCubeTexture9.cpp
$(obj)\uMod_ArrayHandler.$(obj_suff): uMod_ArrayHandler.cpp $(headers)
$(CXX) $(CFLAGS) /c /Fo$@ uMod_ArrayHandler.cpp
$(obj)\uMod_TextureClient.$(obj_suff): uMod_TextureClient.cpp $(headers)
$(CXX) $(CFLAGS) /c /Fo$@ uMod_TextureClient.cpp
$(obj)\uMod_TextureServer.$(obj_suff): uMod_TextureServer.cpp $(headers)
$(CXX) $(CFLAGS) /c /Fo$@ uMod_TextureServer.cpp
$(obj)\uMod_DXMain_dll.$(DX_XX_File).$(obj_suff): uMod_DXMain_dll.cpp $(headers)
$(CXX) $(CFLAGS) /c uMod_DXMain_dll.cpp /Fo$@
$(obj)\uMod_ArrayHandler.$(DX_XX_File).$(obj_suff): uMod_ArrayHandler.cpp $(headers)
$(CXX) $(CFLAGS) /c uMod_ArrayHandler.cpp /Fo$@
$(obj)\uMod_TextureClient.$(DX_XX_File).$(obj_suff): uMod_TextureClient.cpp $(headers)
$(CXX) $(CFLAGS) /c uMod_TextureClient.cpp /Fo$@
$(obj)\uMod_TextureServer.$(DX_XX_File).$(obj_suff): uMod_TextureServer.cpp $(headers)
$(CXX) $(CFLAGS) /c uMod_TextureServer.cpp /Fo$@
$(obj)\uMod_TextureFunction.$(DX_XX_File).$(obj_suff): uMod_TextureFunction.cpp $(headers) $(DX9_headers)
$(CXX) $(CFLAGS) /c uMod_TextureFunction.cpp /Fo$@
$(obj)\uMod_DX9_dll.$(obj_suff): ..\uMod_DX9\uMod_DX9_dll.cpp $(headers) $(DX9_headers)
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_DX9_dll.cpp /Fo$@
$(obj)\uMod_TextureClient_DX9.$(obj_suff): ..\uMod_DX9\uMod_TextureClient_DX9.cpp $(headers) $(DX9_headers)
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_TextureClient_DX9.cpp /Fo$@
$(obj)\uMod_IDirect3D9.$(obj_suff): ..\uMod_DX9\uMod_IDirect3D9.cpp $(headers) $(DX9_headers)
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_IDirect3D9.cpp /Fo$@
$(obj)\uMod_IDirect3D9Ex.$(obj_suff): ..\uMod_DX9\uMod_IDirect3D9Ex.cpp $(headers) $(DX9_headers)
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_IDirect3D9Ex.cpp /Fo$@
$(obj)\uMod_IDirect3DDevice9.$(obj_suff): ..\uMod_DX9\uMod_IDirect3DDevice9.cpp $(headers) $(DX9_headers)
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_IDirect3DDevice9.cpp /Fo$@
$(obj)\uMod_IDirect3DDevice9Ex.$(obj_suff): ..\uMod_DX9\uMod_IDirect3DDevice9Ex.cpp $(headers) $(DX9_headers)
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_IDirect3DDevice9Ex.cpp /Fo$@
$(obj)\uMod_IDirect3DTexture9.$(obj_suff): ..\uMod_DX9\uMod_IDirect3DTexture9.cpp $(headers) $(DX9_headers)
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_IDirect3DTexture9.cpp /Fo$@
$(obj)\uMod_IDirect3DVolumeTexture9.$(obj_suff): ..\uMod_DX9\uMod_IDirect3DVolumeTexture9.cpp $(headers) $(DX9_headers)
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_IDirect3DVolumeTexture9.cpp /Fo$@
$(obj)\uMod_IDirect3DCubeTexture9.$(obj_suff): ..\uMod_DX9\uMod_IDirect3DCubeTexture9.cpp $(headers)
$(CXX) $(CFLAGS) /c ..\uMod_DX9\uMod_IDirect3DCubeTexture9.cpp /Fo$@
$(obj)\uMod_DX10_dll.$(obj_suff): ..\uMod_DX10\uMod_DX10_dll.cpp $(headers) $(DX10_headers)
$(CXX) $(CFLAGS) /c ..\uMod_DX10\uMod_DX10_dll.cpp /Fo$@
$(obj)\uMod_ID3D10Device.$(obj_suff): ..\uMod_DX10\uMod_ID3D10Device.cpp $(headers) $(DX10_headers)
$(CXX) $(CFLAGS) /c ..\uMod_DX10\uMod_ID3D10Device.cpp /Fo$@
$(obj)\uMod_ID3D10Device1.$(obj_suff): ..\uMod_DX10\uMod_ID3D10Device1.cpp $(headers) $(DX10_headers) ..\uMod_DX10\uMod_ID3D10Device.cpp
$(CXX) $(CFLAGS) /c ..\uMod_DX10\uMod_ID3D10Device1.cpp /Fo$@
$(obj)\uMod_ID3D10Texture1D.$(obj_suff): ..\uMod_DX10\uMod_ID3D10Texture1D.cpp $(headers) $(DX10_headers)
$(CXX) $(CFLAGS) /c ..\uMod_DX10\uMod_ID3D10Texture1D.cpp /Fo$@
$(obj)\uMod_ID3D10Texture2D.$(obj_suff): ..\uMod_DX10\uMod_ID3D10Texture2D.cpp $(headers) $(DX10_headers)
$(CXX) $(CFLAGS) /c ..\uMod_DX10\uMod_ID3D10Texture2D.cpp /Fo$@
$(obj)\uMod_ID3D10Texture3D.$(obj_suff): ..\uMod_DX10\uMod_ID3D10Texture3D.cpp $(headers) $(DX10_headers)
$(CXX) $(CFLAGS) /c ..\uMod_DX10\uMod_ID3D10Texture3D.cpp /Fo$@
$(obj)\uMod_IDXGISwapChain.$(obj_suff): ..\uMod_DX10\uMod_IDXGISwapChain.cpp $(headers) $(DX10_headers)
$(CXX) $(CFLAGS) /c ..\uMod_DX10\uMod_IDXGISwapChain.cpp /Fo$@
clean:
del $(objects) $(bin)\$(dll)
+65 -60
View File
@@ -23,61 +23,66 @@ along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>
#include "..\uMod_GlobalDefines.h"
/**
* On entry hold the pointer to the fake texture data (file content)
* and the pointer to all game texture which are replaced by this texture.
*/
typedef struct
{
bool ForceReload; // to force a reload of the texture (if it is already modded)
char* pData; // store texture file as file in memory
unsigned int Size; // size of file
int NumberOfTextures;
int Reference; // for a fast delete in the FileHandler
void **Textures; // pointer to the fake textures
MyTypeHash Hash; // hash value
bool ForceReload; //!< to force a reload of the texture (only important, if it is already modded)
char* pData; //!< store texture file as file in memory
unsigned int Size; //!< size of file (\a pData)
int NumberOfTextures; //!< Number of textures loaded by the game, which match the hash and thus are switched
int Reference; //!< for a fast delete in the FileHandler
void **Textures; //!< pointer to all texture loade by the game, which match the hash and thus are switched
DWORD64 Hash; //!< hash value
} TextureFileStruct;
/*
class uMod_FileHandler // array to store TextureFileStruct
{
public:
uMod_FileHandler(void);
~uMod_FileHandler(void);
int Add( TextureFileStruct* file);
int Remove( TextureFileStruct* file);
int GetNumber(void) {return (Number);}
TextureFileStruct *operator [] (int i) {if (i<0||i>=Number) return (NULL); else return (Files[i/FieldLength][i%FieldLength]);}
protected:
static const int FieldLength = 1024;
long Number;
int FieldCounter;
TextureFileStruct*** Files;
};
*/
/**
* A simple vector class for pointers. The Object or struct must have a member variable \a int \a Reference.
* This class stores the entries in chunks of memory. The address of each chunk is stored in \a Content.
*/
template <class T>
class uMod_TextureHandler // array to store uMod_IDirect3DTexture9, uMod_IDirect3DVolumeTexture9 or uMod_IDirect3DCubeTexture9
class uMod_TextureHandler
{
public:
uMod_TextureHandler(void);
~uMod_TextureHandler(void);
int Add( T* texture);
int Remove( T* texture);
/**
* Append an entry at the end of the vector
* @param entry
* @return RETURN_OK on success
*/
int Add( T* entry);
/**
* Remove this entry from the vector
* @param entry
* @return RETURN_OK on success
*/
int Remove( T* entry);
/**
* Returns the number of entries.
* @return
*/
int GetNumber(void) {return (Number);}
T *operator [] (int i) {if (i<0||i>=Number) return (NULL); else return (Textures[i/FieldLength][i%FieldLength]);}
/**
* Return the pointer to the \a i the object
* @param i index
* @return
*/
T *operator [] (int i) {if (i<0||i>=Number) return (NULL); else return (Content[i/FieldLength][i%FieldLength]);}
private:
static const int FieldLength = 1024;
long Number;
int FieldCounter;
T*** Textures;
static const int FieldLength = 1024; //!< size of one chunk of memory
long Number; //!< Number of entries.
int FieldCounter; //!< Number of allocated chunks.
T*** Content;//!< vector of pointers, which point to the chunks
};
@@ -100,27 +105,27 @@ uMod_TextureHandler<T>::uMod_TextureHandler(void)
Number = 0;
FieldCounter = 0;
Textures = NULL;
Content = NULL;
}
template <class T>
uMod_TextureHandler<T>::~uMod_TextureHandler(void)
{
Message("~uMod_TextureHandler(void): %lu\n", this);
if (Textures!=NULL)
if (Content!=NULL)
{
for (int i=0; i<FieldCounter; i++) if (Textures[i] != NULL) delete [] Textures[i];
delete [] Textures;
for (int i=0; i<FieldCounter; i++) if (Content[i] != NULL) delete [] Content[i];
delete [] Content;
}
}
template <class T>
int uMod_TextureHandler<T>::Add(T* pTexture)
int uMod_TextureHandler<T>::Add(T* entry)
{
Message("uMod_TextureHandler::Add( %lu): %lu\n", pTexture, this);
Message("uMod_TextureHandler::Add( %lu): %lu\n", entry, this);
if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR);
if (pTexture->Reference>=0) return (RETURN_TEXTURE_ALLREADY_ADDED);
if (entry->Reference>=0) return (RETURN_TEXTURE_ALLREADY_ADDED);
if (Number/FieldLength==FieldCounter)
{
@@ -132,50 +137,50 @@ int uMod_TextureHandler<T>::Add(T* pTexture)
return (RETURN_NO_MEMORY);
}
for (int i=0; i<FieldCounter; i++) temp[i] = Textures[i];
for (int i=0; i<FieldCounter; i++) temp[i] = Content[i];
for (int i=FieldCounter; i<FieldCounter+10; i++) temp[i] = NULL;
FieldCounter += 10;
if (Textures!=NULL) delete [] Textures;
if (Content!=NULL) delete [] Content;
Textures = temp;
Content = temp;
}
if (Number%FieldLength==0)
{
try {if (Textures[Number/FieldLength]==NULL) Textures[Number/FieldLength] = new T*[FieldLength];}
try {if (Content[Number/FieldLength]==NULL) Content[Number/FieldLength] = new T*[FieldLength];}
catch (...)
{
Textures[Number/FieldLength]=NULL;
Content[Number/FieldLength]=NULL;
gl_ErrorState |= uMod_ERROR_MEMORY | uMod_ERROR_TEXTURE;
return (RETURN_NO_MEMORY);
}
}
Textures[Number/FieldLength][Number%FieldLength] = pTexture;
pTexture->Reference = Number++;
Content[Number/FieldLength][Number%FieldLength] = entry;
entry->Reference = Number++;
return (RETURN_OK);
}
template <class T>
int uMod_TextureHandler<T>::Remove(T* pTexture) //will be called, if a texture is completely released
int uMod_TextureHandler<T>::Remove(T* entry) //will be called, if a texture is completely released
{
Message("uMod_TextureHandler::Remove( %lu): %lu\n", pTexture, this);
Message("uMod_TextureHandler::Remove( %lu): %lu\n", entry, this);
if (gl_ErrorState & uMod_ERROR_FATAL) return (RETURN_FATAL_ERROR);
int ref = pTexture->Reference;
int ref = entry->Reference;
if (ref<0|| ref>=Number) return (RETURN_OK); // it is not in this list
if (Textures[ref/FieldLength][ref%FieldLength]!=pTexture) return (RETURN_OK); // it is not in this list
if (Content[ref/FieldLength][ref%FieldLength]!=entry) return (RETURN_OK); // it is not in this list
if (ref<(--Number))
{
Textures[ref/FieldLength][ref%FieldLength] = Textures[Number/FieldLength][Number%FieldLength];
Textures[ref/FieldLength][ref%FieldLength]->Reference = ref;
Content[ref/FieldLength][ref%FieldLength] = Content[Number/FieldLength][Number%FieldLength];
Content[ref/FieldLength][ref%FieldLength]->Reference = ref;
}
pTexture->Reference = -1;
entry->Reference = -1;
return (RETURN_OK);
}
@@ -0,0 +1,5 @@
LIBRARY "uMod_d3d10_DI"
EXPORTS
uMod_D3D10CreateDeviceAndSwapChain @1
uMod_D3D10CreateDeviceAndSwapChain1 @2
Nothing @3
+37 -78
View File
@@ -24,16 +24,13 @@ along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>
*/
#ifdef __CDT_PARSER__
#define INJECTION_METHOD 0
#endif
#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
*/
@@ -52,10 +49,11 @@ unsigned int gl_ErrorState = 0u;
FILE* gl_File = NULL;
#endif
#ifdef DIRECT_INJECTION
#if INJECTION_METHOD == DIRECT_INJECTION
void Nothing(void) {(void)NULL;}
#endif
/*
* dll entry routine, here we initialize or clean up
*/
@@ -96,11 +94,11 @@ void InitInstance(HINSTANCE hModule)
gl_hThisInstance = (HINSTANCE) hModule;
wchar_t game[MAX_PATH];
if (HookThisProgram( game, MAX_PATH)) //ask if we need to hook this program
wchar_t game[10*MAX_PATH];
if (HookThisProgram( game, 10*MAX_PATH)) //ask if we need to hook this program
{
OpenMessage();
Message("InitInstance: %lu\n", hModule);
Message("InitInstance: %lu (%ls)\n", hModule, game);
gl_TextureServer = new uMod_TextureServer(game); //create the server which listen on the pipe and prepare the update for the texture clients
@@ -112,7 +110,7 @@ void InitInstance(HINSTANCE hModule)
#endif
if (gl_TextureServer->OpenPipe(game)) //open the pipe and send the name+path of this executable
if (gl_TextureServer->OpenPipe(game, INJECTION_METHOD)) //open the pipe and send the name+path of this executable
{
Message("InitInstance: Pipe not opened\n");
return;
@@ -152,27 +150,35 @@ void ExitInstance()
}
bool HookThisProgram( wchar_t *ret, const int ret_len)
{
const unsigned int max_len = ret_len < MAX_PATH ? MAX_PATH : ret_len;
const int max_len = ret_len < MAX_PATH ? MAX_PATH : ret_len;
wchar_t *Executable = NULL;
wchar_t *Game = NULL;
if (GetMemory( Executable, max_len))
{
ret[0]=0;
return false;
}
GetModuleFileNameW( GetModuleHandle( NULL ), Executable, max_len ); //ask for name and path of this executable
#if INJECTION_METHOD==DIRECT_INJECTION || INJECTION_METHOD==NO_INJECTION
// we inject directly
int i=0;
while (i<max_len && i<ret_len-1 && Executable[i]) {ret[i]=Executable[i]; i++;}
ret[i]=0;
delete [] Executable;
return true;
#elif INJECTION_METHOD==HOOK_INJECTION
//we use the gloabal hook
wchar_t *Game = NULL;
if (GetMemory( Game, max_len))
{
delete [] Executable;
ret[0]=0;
return false;
}
GetModuleFileNameW( GetModuleHandle( NULL ), Executable, max_len ); //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
@@ -186,14 +192,12 @@ bool HookThisProgram( wchar_t *ret, const int ret_len)
}
swprintf_s( file_name, max_len, 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
delete [] file_name;
//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 (len<max_len-1 &&Game[len])
{
@@ -216,54 +220,18 @@ bool HookThisProgram( wchar_t *ret, const int ret_len)
fclose(file);
return (false);
#else
// we inject directly
int i=0;
while (i<max_len && i<ret_len-1 && Game[i]) {ret[i]=Game[i]; i++;}
ret[i]=0;
delete [] Executable;
delete [] Game;
return true;
#error No injection method was set.
return false;
#endif
}
#ifndef NO_INJECTION
/*
void *DetourFunc(BYTE *src, const BYTE *dst, const int len)
{
BYTE *jmp = (BYTE*)malloc(len+5);
DWORD dwback;
VirtualProtect(src, len, PAGE_READWRITE, &dwback);
memcpy(jmp, src, len); jmp += len;
jmp[0] = 0xE9;
*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
src[0] = 0xE9;
*(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
VirtualProtect(src, len, dwback, &dwback);
return (jmp-len);
}
void *DetourFunc(BYTE *src, const BYTE *dst, const int len)
{
BYTE *jmp = (BYTE*)malloc(len+5);
DWORD dwback;
VirtualProtect(src, len, PAGE_READWRITE, &dwback);
memcpy(jmp, src, len); jmp += len;
jmp[0] = 0xE9;
*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
src[0] = 0xE9;
*(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
VirtualProtect(src, len, dwback, &dwback);
return (jmp-len);
}
*/
#if INJECTION_METHOD==DIRECT_INJECTION || INJECTION_METHOD==HOOK_INJECTION
void *DetourFunc(BYTE *src, const BYTE *dst, const int len)
{
BYTE *jmp = (BYTE*)malloc(len+5);
DWORD dwback = 0;
//VirtualProtect(jmp, len+5, PAGE_EXECUTE_READWRITE, &dwback); //This is the addition needed for Windows 7 RC
//(jmp, len+5, PAGE_EXECUTE_READWRITE, &dwback); //This is the addition needed for Windows 7 RC
VirtualProtect(src, len, PAGE_READWRITE, &dwback);
memcpy(jmp, src, len); jmp += len;
jmp[0] = 0xE9;
@@ -274,18 +242,7 @@ void *DetourFunc(BYTE *src, const BYTE *dst, const int len)
VirtualProtect(src, len, dwback, &dwback);
return (jmp-len);
}
/*
bool RetourFunc( BYTE *src, BYTE *restore, const int len )
{
DWORD dwback;
if(!VirtualProtect(src, len, PAGE_READWRITE, &dwback)) { return false; }
if(!memcpy(src, restore, len)) { return false; }
restore[0] = 0xE9;
*(DWORD*)(restore+1) = (DWORD)(src - restore) - 5;
if(!VirtualProtect(src, len, dwback, &dwback)) { return false; }
return true;
}
*/
bool RetourFunc(BYTE *src, BYTE *restore, const int len)
{
DWORD dwback;
@@ -296,8 +253,10 @@ bool RetourFunc(BYTE *src, BYTE *restore, const int len)
if(!VirtualProtect(src, len, dwback, &dwback)) { return (false); }
return (true);
}
#endif
#ifdef HOOK_INJECTION
#if INJECTION_METHOD==HOOK_INJECTION
/*
* We do not change something, if our hook function is called.
* We need this hook only to get our dll loaded into a starting program.
@@ -319,4 +278,4 @@ void RemoveHook(void)
UnhookWindowsHookEx( gl_hHook );
}
#endif
#endif
+51 -5
View File
@@ -29,31 +29,77 @@ along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>
#include "../uMod_DX10/uMod_DX10_dll.h"
#endif
/**
* This function is called during the dll load sequence (dll entry)
* @param[in] hModule
*/
void InitInstance(HINSTANCE hModule);
/**
* This function is called, when the dll gets unloaded.
*/
void ExitInstance(void);
/**
* Returns true if this game shall be injected (DirectX hook). It returns also the name and path of the game executable.
* This function always return true, when compiled for "Direct Injection" of for "No Injection".
* @param[out] ret buffer where the name and path of the game executable should be stored
* @param[in] max_len length of the buffer
* @return
*/
bool HookThisProgram( wchar_t *ret, const int max_len);
/**
* This function is called, when the server thread is created. It only calls the mainloop function of the \a TextureServer.
* @param[in] lpParam Pointer to the \a TextureServer.
*/
DWORD WINAPI ServerThread( LPVOID lpParam);
#ifndef NO_INJECTION
#if INJECTION_METHOD==DIRECT_INJECTION || INJECTION_METHOD==HOOK_INJECTION
/**
* Detour a function to another function.
* @param[in] src pointer to function which shall be detoured
* @param[in] dst pointer to function which shall be called instead
* @param[in] len number of byte to be stored
* @return trampoline = pointer to detoured function
*/
void *DetourFunc(BYTE *src, const BYTE *dst, const int len);
/**
* Retour the function.
* @param src pointer to the detoured function
* @param restore trampoline = pointer to the detoured function
* @param len number of saved bytes
* @return
*/
bool RetourFunc(BYTE *src, BYTE *restore, const int len);
#endif
#ifdef HOOK_INJECTION
#if INJECTION_METHOD==HOOK_INJECTION
/**
* This function is insert into the hook.
*/
LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam);
/**
* This function install the hook, our dll will be loaded into each running process (if we have sufficient permission).
*/
void InstallHook(void);
/**
* This function remove the hook, our dll will get unloaded from each process.
*/
void RemoveHook(void);
#endif
#ifdef DIRECT_INJECTION
#if INJECTION_METHOD==DIRECT_INJECTION
/**
* Dummy function need for the "Direct Injection" mehtod.
*/
void Nothing(void);
#endif
#endif
#endif
+12 -3
View File
@@ -26,15 +26,15 @@ along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>
extern FILE *gl_File;
#define Message(...) {if (gl_File!=NULL) {fprintf( gl_File, __VA_ARGS__); fflush(gl_File);}}
#ifdef HOOK_INJECTION
#if INJECTION_METHOD == HOOK_INJECTION
#define OpenMessage(...) {if (fopen_s( &gl_File, "uMod_log.txt", "wt")) gl_File=NULL; else fprintf( gl_File, "HI R40: 0000002\n");}
#endif
#ifdef DIRECT_INJECTION
#if INJECTION_METHOD == DIRECT_INJECTION
#define OpenMessage(...) {if (fopen_s( &gl_File, "uMod_log.txt", "wt")) gl_File=NULL; else fprintf( gl_File, "DI R40: 0000002\n");}
#endif
#ifdef NO_INJECTION
#if INJECTION_METHOD == NO_INJECTION
#define OpenMessage(...) {if (fopen_s( &gl_File, "uMod_log.txt", "wt")) gl_File=NULL; else fprintf( gl_File, "NI R40: 0000002\n");}
#endif
@@ -42,8 +42,17 @@ extern FILE *gl_File;
#else
/**
* Open the file for logging (if LOG_MESSAGE=1 was passed during compilation)
*/
#define OpenMessage(...)
/**
* Print a message (like printf) into the file ant flush the content to disk (if LOG_MESSAGE=1 was passed during compilation)
*/
#define Message(...)
/**
* Close the file for logging (if LOG_MESSAGE=1 was passed during compilation)
*/
#define CloseMessage(...)
#endif
+15 -13
View File
@@ -50,28 +50,30 @@ along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>
#include "uMod_Defines.h"
#include "uMod_DXMain_dll.h"
//#include "uMod_TextureFunction.h"
/*
#include "uMod_IDirect3D9.h"
#include "uMod_IDirect3D9Ex.h"
#include "uMod_IDirect3DDevice9.h"
#include "uMod_IDirect3DDevice9Ex.h"
#include "uMod_IDirect3DCubeTexture9.h"
#include "uMod_IDirect3DTexture9.h"
#include "uMod_IDirect3DVolumeTexture9.h"
*/
#include "uMod_ArrayHandler.h"
#include "uMod_TextureServer.h"
#include "uMod_TextureClient.h"
/**
* global variable: HINSTANCE
*/
extern HINSTANCE gl_hThisInstance;
/**
* gloabal variable: pointer to TextureServer
*/
extern uMod_TextureServer* gl_TextureServer;
/**
* gloabal variable: pointer to the server thread
*/
extern HANDLE gl_ServerThread;
/**
* gloabal variable: error state. This is not supported at the moment.
*/
extern unsigned int gl_ErrorState;
#endif
+12 -1
View File
@@ -27,6 +27,9 @@ uMod_TextureClient::uMod_TextureClient(const int version) : Version(version)
Server = NULL;
BoolSaveAllTextures = false;
BoolSaveSingleTexture = false;
BoolShowTextureString = false;
BoolComputeCRC = false;
KeyBack = 0;
KeySave = 0;
KeyNext = 0;
@@ -42,6 +45,14 @@ uMod_TextureClient::uMod_TextureClient(const int version) : Version(version)
NumberOfUpdate = -1;
FontColour = D3DCOLOR_ARGB(255,255,0,0);
TextureColour = D3DCOLOR_ARGB(255,0,255,0);
WidthFilter = 0u;
HeightFilter = 0u;
DepthFilter = 0u;
FormatFilter = 0u;
FileFormat = uMod_D3DXIFF_DDS;
}
uMod_TextureClient::~uMod_TextureClient(void)
@@ -135,7 +146,7 @@ int uMod_TextureClient::UnlockMutex(void)
}
int uMod_TextureClient::GetIndex( MyTypeHash hash, int num_index_list, int *index_list)
int uMod_TextureClient::GetIndex( DWORD64 hash, int num_index_list, int *index_list)
{
if(NumberToMod>0)
{
+82 -25
View File
@@ -29,7 +29,7 @@ along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>
class uMod_TextureServer;
/*
/**
* An object of this class is owned by each d3dXX device.
* functions called by the Server are called from the server thread instance.
* All other functions are called from the render thread instance of the game itself.
@@ -61,6 +61,21 @@ public:
*/
virtual int SaveSingleTexture(bool val) = 0;
/**
* Enable/Disable the string in the left upper corner during save single texture mode (called from the mainloop).
* @param[in] val
* @return
*/
int ShowTextureString(bool val) {BoolShowTextureString = val; return (RETURN_OK);}
/**
* Enable/Disable the hashing with CRC32, which is needed to support also tpf mods (called from the mainloop).
* @param[in] val
* @return
*/
int SupportTPF(bool val) {BoolComputeCRC = val; return (RETURN_OK);}
/**
* Set the directory, wher the texture should be stored (called from the server)
* @param dir
@@ -96,21 +111,47 @@ public:
/**
* Set the font color "during save single" texture mode. (called from the server)
* @param r red value (0..255)
* @param g green value (0..255)
* @param b blue value (0..255)
* @param colour
* @return
*/
int SetFontColour( DWORD r, DWORD g, DWORD b) {FontColour = D3DCOLOR_ARGB(255, r,g,b); return (RETURN_OK);}
int SetFontColour( DWORD64 colour) {FontColour = (D3DCOLOR) colour; return (RETURN_OK);}
/**
* Set the texture color "during save single" texture mode. (called from the server)
* @param r red value (0..255)
* @param g green value (0..255)
* @param b blue value (0..255)
* @param colour
* @return RETURN_OK
*/
int SetTextureColour( DWORD r, DWORD g, DWORD b) {TextureColour = D3DCOLOR_ARGB(255, r,g,b); return (RETURN_OK);}
int SetTextureColour( DWORD64 colour) {TextureColour = (D3DCOLOR) colour; return (RETURN_OK);}
/**
* @param[in] format
* @return
*/
int SetFileFormat(DWORD64 format) {FileFormat = format; return (RETURN_OK);}
/**
* @param[in] format
* @return
*/
int SetFormatFilter(DWORD64 format) {FormatFilter = format; return (RETURN_OK);}
/**
* @param[in] size
* @return
*/
int SetWidthFilter(DWORD64 size) {WidthFilter = size; return (RETURN_OK);}
/**
* @param[in] size
* @return
*/
int SetHeightFilter(DWORD64 size) {HeightFilter = size; return (RETURN_OK);}
/**
* @param[in] size
* @return
*/
int SetDepthFilter(DWORD64 size) {DepthFilter = size; return (RETURN_OK);}
/**
* The server add an update to the client.(called from server)
@@ -128,23 +169,32 @@ public:
virtual int MergeUpdate(void) = 0;
bool BoolSaveAllTextures; //< true if all textures should be saved
bool BoolSaveSingleTexture; //< true if "save single texture" mode is enabled
int KeyBack; //< key value for going to the previous texture
int KeySave; //< key value for saving the current texture
int KeyNext; //< key value for going to the next texture
bool BoolSaveAllTextures; //!< true if all textures should be saved
bool BoolSaveSingleTexture; //!< true if "save single texture" mode is enabled
bool BoolShowTextureString; //!< true if a string should be displayed during "save single texture" mode is enabled
bool BoolComputeCRC; //!< if true also the crc32 is calculated, which is need to support tpf
D3DCOLOR FontColour; //< color of the message ("save single texture" mode)
D3DCOLOR TextureColour; //< color of the texture ("save single texture" mode)
int KeyBack; //!< key value for going to the previous texture
int KeySave; //!< key value for saving the current texture
int KeyNext; //!< key value for going to the next texture
D3DCOLOR FontColour; //!< color of the message ("save single texture" mode)
D3DCOLOR TextureColour; //!< color of the texture ("save single texture" mode)
DWORD64 FileFormat; //!< file format to which the texture should be saved
DWORD64 FormatFilter; //!< texture format which should be saved (all==0, else bitwise 1=save,0=don't save)
DWORD64 WidthFilter; //!< filter min<<32 max, texture size must be min<=size<=max
DWORD64 HeightFilter; //!< filter min<<32 max, texture size must be min<=size<=max
DWORD64 DepthFilter; //!< filter min<<32 max, texture size must be min<=size<=max
const int Version;
uMod_TextureServer* Server; //< Pointer to the server
wchar_t SavePath[MAX_PATH]; //< saving directory
wchar_t GameName[MAX_PATH]; //< game name
uMod_TextureServer* Server; //!< Pointer to the server
wchar_t SavePath[MAX_PATH]; //!< saving directory
wchar_t GameName[MAX_PATH]; //!< game name
TextureFileStruct* Update; //< array which stores the file in memory and the hash of each texture to be modded
int NumberOfUpdate; //< number of texture to be modded
TextureFileStruct* Update; //!< array which stores the file in memory and the hash of each texture to be modded
int NumberOfUpdate; //!< number of texture to be modded
/**
* Lock the mutex. The mutex protect the AddUpdate and MergeUpdate function to be called simultaneously.
@@ -156,12 +206,19 @@ public:
* @return RETURN_OK on success
*/
int UnlockMutex();
HANDLE Mutex; //< The mutex protect the AddUpdate and MergeUpdate function to be called simultaneously.
HANDLE Mutex; //!< The mutex protect the AddUpdate and MergeUpdate function to be called simultaneously.
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 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 GetIndex( MyTypeHash hash, int num_index_list=0, int *index_list=(int*)0); // called from LookUpToMod(...);
/**
* Find the given hash value in the \a FileToMod list. A vector with index can be passed. If so, only these index are considered in the search
* @param hash hash value
* @param num_index_list number of index vector
* @param index_list pointer to the index vector
* @return index or a negative value if the hash value was not found
*/
int GetIndex( DWORD64 hash, int num_index_list=0, int *index_list=(int*)0); // called from LookUpToMod(...);
};
+19 -7
View File
@@ -19,14 +19,23 @@ along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>
#include "uMod_Main.h"
/*
MyTypeHash GetHash(unsigned char *str, int len) // estimate the hash
void GetHash( unsigned char *str, unsigned int len, DWORD64 &hash) // estimate the hash
{
MyTypeHash hash = 0;
for (int i=0; i<len; i++) hash = str[i] + (hash << 6) + (hash << 16) - hash;
return (hash);
DWORD32 hash1 = hash & 0xFFFFFFFF;
DWORD32 hash2 = hash>>32 & 0xFFFFFFFF;
for (int i=0; i<len; i++)
{
hash1 = ((hash1 << 5) + hash1) + *str; // D.J. Bernsteins algorithm (djb2)
hash2 = *str + (hash2<< 6) + (hash2 << 16) - hash2; // SDBM algorithm
str++;
}
hash = hash2;
hash<<=32;
hash |= hash1;
}
*/
@@ -43,10 +52,13 @@ The problem is that it doesn't take the pitch into account and BytesPerPixel may
*/
#define CRC32POLY 0xEDB88320u /* CRC-32 Polynom */
#define ulCrc_in 0xffffffff
unsigned int GetCRC32( char *pcDatabuf, unsigned int ulDatalen)
DWORD32 GetCRC32( char *pcDatabuf, unsigned int ulDatalen)
{
unsigned int crc = ulCrc_in;
for (unsigned int idx = 0u; idx<ulDatalen; idx++)
+33 -1
View File
@@ -19,11 +19,43 @@ along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>
#define uMod_TEXTUREFUNCTION_H_
unsigned int GetCRC32( char *pcDatabuf, unsigned int ulDatalen);
// this value is simply the init value for the D.J. Bernsteins algorithm (djb2)
#define HASH_INIT_VALUE 5381
/**
* This hash function combines the djb2 and sdbm algorithm. Both are designed for hashing strings,
* but compared to many others they don't include a Hash*data[i] operation, which would reset the hash
* if data[i]==0. This is never the case while hashing text, but it is very often the case when hashing
* textures. Therefore many good algorithm cannot be used at this point.
*
* Here are two algorithm used to reduce the number of collision (collision == two different textures have
* the same hash value)
*
* @param[in] data pointer to the buffer
* @param[in] len length of buffer in bytes
* @param[in,out] hash in = initial value of the hash; out = returned hash
*/
void GetHash( unsigned char *str, unsigned int len, DWORD64 &hash); // estimate the hash
/**
* Caluclate the CRC32 value over a buffer. This function is used in texmod. Thanks to RS for given me this information!
* @param[in] data pointer to the buffer
* @param[in] len length of buffer in bytes
* @return CRC32 value
*/
DWORD32 GetCRC32( char *data, unsigned int len);
/*
case D3DFMT_MULTI2_ARGB8:
case D3DFMT_VERTEXDATA:
*/
/**
* Returns the number of bits used per pixel.
* @param[in] format DX format.
* @return
*/
inline int GetBitsFromFormat(D3DFORMAT format)
{
switch(format) //switch trough the formats to calculate the size of the raw data
+237 -77
View File
@@ -31,6 +31,9 @@ uMod_TextureServer::uMod_TextureServer(wchar_t *game)
LenghtOfClients = 0;
BoolSaveAllTextures = false;
BoolSaveSingleTexture = false;
BoolShowTextureString = false;
BoolSupportTPF = false;
SavePath[0] = 0;
int len=0;
@@ -54,8 +57,16 @@ uMod_TextureServer::uMod_TextureServer(wchar_t *game)
KeySave = 0;
KeyNext = 0;
FontColour = 0u;
TextureColour = 0u;
WidthFilter = 0u;
HeightFilter = 0u;
DepthFilter = 0u;
FormatFilter = 0u;
FileFormat = uMod_D3DXIFF_DDS;
FontColour = D3DCOLOR_ARGB(255,255,0,0);
TextureColour = D3DCOLOR_ARGB(255,0,255,0);
Pipe.In = INVALID_HANDLE_VALUE;
Pipe.Out = INVALID_HANDLE_VALUE;
@@ -94,27 +105,24 @@ int uMod_TextureServer::AddClient(uMod_TextureClient *client, TextureFileStruct*
client->SetGameName(GameName);
client->SaveAllTextures(BoolSaveAllTextures);
client->SaveSingleTexture(BoolSaveSingleTexture);
client->ShowTextureString(BoolShowTextureString);
client->SupportTPF(BoolSupportTPF);
client->SetSaveDirectory(SavePath);
if (KeyBack > 0) client->SetKeyBack(KeyBack);
if (KeySave > 0) client->SetKeySave(KeySave);
if (KeyNext > 0) client->SetKeyNext(KeyNext);
client->SetKeyBack(KeyBack);
client->SetKeySave(KeySave);
client->SetKeyNext(KeyNext);
if (FontColour>0u)
{
DWORD r = (FontColour>>16)&0xFF;
DWORD g = (FontColour>>8)&0xFF;
DWORD b = (FontColour)&0xFF;
client->SetFontColour( r, g, b);
}
if (TextureColour>0u)
{
DWORD r = (TextureColour>>16)&0xFF;
DWORD g = (TextureColour>>8)&0xFF;
DWORD b = (TextureColour)&0xFF;
client->SetTextureColour( r, g, b);
}
client->SetFontColour( FontColour);
client->SetTextureColour( TextureColour);
client->SetWidthFilter( WidthFilter);
client->SetHeightFilter( HeightFilter);
client->SetDepthFilter( DepthFilter);
client->SetFormatFilter(FormatFilter);
client->SetFileFormat(FileFormat);
if (int ret = PrepareUpdate( update, number)) return (ret); // get a copy of all texture to be modded
@@ -161,14 +169,17 @@ int uMod_TextureServer::RemoveClient(uMod_TextureClient *client, const int versi
return (ret);
}
bool hit = false;
for (int i = 0; i < NumberOfClients; i++) if (client == Clients[i])
{
hit = true;
NumberOfClients--;
Clients[i] = Clients[NumberOfClients];
break;
}
int ret = UnlockMutex();
if (!hit) return ret;
if (ret!=RETURN_OK) return (ret);
@@ -187,9 +198,9 @@ int uMod_TextureServer::RemoveClient(uMod_TextureClient *client, const int versi
return (RETURN_OK);
}
int uMod_TextureServer::AddFile( char* buffer, unsigned int size, MyTypeHash hash, bool force) // called from Mainloop()
int uMod_TextureServer::AddFile( char* buffer, DWORD64 size, DWORD64 hash, bool force) // called from Mainloop()
{
Message("uMod_TextureServer::AddFile( %lu %lu, %#lX, %d): %lu\n", buffer, size, hash, force, this);
Message("uMod_TextureServer::AddFile( %p %llu, %#llX, %d): %lu\n", buffer, size, hash, force, this);
TextureFileStruct* temp = NULL;
@@ -236,23 +247,9 @@ int uMod_TextureServer::AddFile( char* buffer, unsigned int size, MyTypeHash ha
temp->pData = buffer;
/*
try
{
temp->pData = new char[size];
}
catch (...)
{
if (!new_file) CurrentMod.Remove( temp); // if this is a not a new file it is in the list of the CurrentMod
delete temp;
gl_ErrorState |= uMod_ERROR_MEMORY | uMod_ERROR_SERVER;
return (RETURN_NO_MEMORY);
}
*/
for (unsigned int i=0; i<size; i++) temp->pData[i] = buffer[i];
temp->Size = size;
temp->Size = (unsigned int) size;
temp->NumberOfTextures = 0;
temp->Textures = NULL;
temp->Hash = hash;
@@ -261,7 +258,7 @@ int uMod_TextureServer::AddFile( char* buffer, unsigned int size, MyTypeHash ha
//else
temp->ForceReload = force;
Message("End AddFile(%#lX)\n", hash);
Message("uMod_TextureServer::End AddFile(%#lX)\n", hash);
if (new_file) return (CurrentMod.Add(temp)); // new files must be added to the list of the CurrentMod
else return (RETURN_OK);
}
@@ -352,7 +349,7 @@ int uMod_TextureServer::AddFile(wchar_t* file_name, MyTypeHash hash, bool force)
}
*/
int uMod_TextureServer::RemoveFile(MyTypeHash hash) // called from Mainloop()
int uMod_TextureServer::RemoveFile(DWORD64 hash) // called from Mainloop()
{
Message("RemoveFile( %lu): %lu\n", hash, this);
@@ -400,6 +397,40 @@ int uMod_TextureServer::SaveSingleTexture(bool val) // called from Mainloop()
return (UnlockMutex());
}
int uMod_TextureServer::ShowTextureString(bool val) // called from Mainloop()
{
if (BoolShowTextureString == val) return (RETURN_OK);
BoolShowTextureString = val;
if (int ret = LockMutex())
{
gl_ErrorState |= uMod_ERROR_SERVER;
return (ret);
}
for (int i = 0; i < NumberOfClients; i++)
{
Clients[i]->ShowTextureString(BoolShowTextureString);
}
return (UnlockMutex());
}
int uMod_TextureServer::SupportTPF(bool val) // called from Mainloop()
{
if (BoolSupportTPF == val) return (RETURN_OK);
BoolSupportTPF = val;
if (int ret = LockMutex())
{
gl_ErrorState |= uMod_ERROR_SERVER;
return (ret);
}
for (int i = 0; i < NumberOfClients; i++)
{
Clients[i]->SupportTPF(BoolSupportTPF);
}
return (UnlockMutex());
}
int uMod_TextureServer::SetSaveDirectory(wchar_t *dir) // called from Mainloop()
{
Message("uMod_TextureServer::SetSaveDirectory( %ls): %lu\n", dir, this);
@@ -472,7 +503,7 @@ int uMod_TextureServer::SetKeyNext(int key) // called from Mainloop()
return (UnlockMutex());
}
int uMod_TextureServer::SetFontColour(DWORD colour) // called from Mainloop()
int uMod_TextureServer::SetFontColour(DWORD64 colour) // called from Mainloop()
{
if (colour==0u) return (RETURN_OK);
if (int ret = LockMutex())
@@ -481,18 +512,15 @@ int uMod_TextureServer::SetFontColour(DWORD colour) // called from Mainloop()
return (ret);
}
FontColour = colour;
DWORD r = (FontColour>>16)&0xFF;
DWORD g = (FontColour>>8)&0xFF;
DWORD b = (FontColour)&0xFF;
Message("uMod_TextureServer::SetFontColour( %u %u %u): %lu\n", r ,g ,b, this);
Message("uMod_TextureServer::SetFontColour( %#lX): %lu\n",colour, this);
for (int i = 0; i < NumberOfClients; i++)
{
Clients[i]->SetFontColour( r, g, b);
Clients[i]->SetFontColour( colour);
}
return (UnlockMutex());
}
int uMod_TextureServer::SetTextureColour(DWORD colour) // called from Mainloop()
int uMod_TextureServer::SetTextureColour(DWORD64 colour) // called from Mainloop()
{
if (colour==0u) return (RETURN_OK);
if (int ret = LockMutex())
@@ -501,13 +529,90 @@ int uMod_TextureServer::SetTextureColour(DWORD colour) // called from Mainloop()
return (ret);
}
TextureColour = colour;
DWORD r = (TextureColour>>16)&0xFF;
DWORD g = (TextureColour>>8)&0xFF;
DWORD b = (TextureColour)&0xFF;
Message("uMod_TextureServer::SetTextureColour( %u %u %u): %lu\n", r ,g ,b, this);
Message("uMod_TextureServer::SetTextureColour( %#lX): %lu\n", colour, this);
for (int i = 0; i < NumberOfClients; i++)
{
Clients[i]->SetTextureColour( r, g, b);
Clients[i]->SetTextureColour( colour);
}
return (UnlockMutex());
}
int uMod_TextureServer::SetFileFormat(DWORD64 format) // called from Mainloop()
{
if (int ret = LockMutex())
{
gl_ErrorState |= uMod_ERROR_SERVER;
return (ret);
}
FileFormat = format;
Message("uMod_TextureServer::SetFileFormat( %lu): %lu\n", format, this);
for (int i = 0; i < NumberOfClients; i++)
{
Clients[i]->SetFileFormat( format);
}
return (UnlockMutex());
}
int uMod_TextureServer::SetFormatFilter(DWORD64 format) // called from Mainloop()
{
if (int ret = LockMutex())
{
gl_ErrorState |= uMod_ERROR_SERVER;
return (ret);
}
FormatFilter = format;
Message("uMod_TextureServer::SetFormatFilter( %lu): %lu\n", format, this);
for (int i = 0; i < NumberOfClients; i++)
{
Clients[i]->SetFormatFilter( format);
}
return (UnlockMutex());
}
int uMod_TextureServer::SetWidthFilter(DWORD64 size) // called from Mainloop()
{
if (int ret = LockMutex())
{
gl_ErrorState |= uMod_ERROR_SERVER;
return (ret);
}
WidthFilter = size;
Message("uMod_TextureServer::SetWidthFilter( %lu): %lu\n", size, this);
for (int i = 0; i < NumberOfClients; i++)
{
Clients[i]->SetWidthFilter( size);
}
return (UnlockMutex());
}
int uMod_TextureServer::SetHeightFilter(DWORD64 size) // called from Mainloop()
{
if (int ret = LockMutex())
{
gl_ErrorState |= uMod_ERROR_SERVER;
return (ret);
}
HeightFilter = size;
Message("uMod_TextureServer::SetHeightFilter( %lu): %lu\n", size, this);
for (int i = 0; i < NumberOfClients; i++)
{
Clients[i]->SetHeightFilter( size);
}
return (UnlockMutex());
}
int uMod_TextureServer::SetDepthFilter(DWORD64 size) // called from Mainloop()
{
if (int ret = LockMutex())
{
gl_ErrorState |= uMod_ERROR_SERVER;
return (ret);
}
DepthFilter = size;
Message("uMod_TextureServer::SetDepthFilter( %lu): %lu\n", size, this);
for (int i = 0; i < NumberOfClients; i++)
{
Clients[i]->SetDepthFilter( size);
}
return (UnlockMutex());
}
@@ -610,11 +715,11 @@ int uMod_TextureServer::MainLoop(void) // run as a separated thread
unsigned long num = 0u;
bool update_textures = false;
unsigned int texture_size = 0u;
unsigned int texture_received = 0u;
DWORD64 texture_size = 0u;
DWORD64 texture_received = 0u;
char *texture_data = (char*)0;
bool texture_force = false;
MyTypeHash texture_hash = 0u;
DWORD64 texture_hash = 0u;
Message("MainLoop: started\n");
while (1)
@@ -629,9 +734,9 @@ int uMod_TextureServer::MainLoop(void) // run as a separated thread
Message("MainLoop: read something (%lu)\n", num);
if (ret || GetLastError() == ERROR_MORE_DATA)
{
unsigned int pos = 0;
DWORD64 pos = 0;
MsgStruct *commands;
unsigned int size=0u;
DWORD64 size=0u;
while (pos < num)
{
if (texture_received<texture_size)
@@ -653,7 +758,7 @@ int uMod_TextureServer::MainLoop(void) // run as a separated thread
{
case CONTROL_END_TEXTURES:
{
Message("MainLoop: CONTROL_END_TEXTURES (): %lu\n", this);
Message("MainLoop: CONTROL_END_TEXTURES (): %p\n", this);
update_textures=true;
break;
}
@@ -677,7 +782,7 @@ int uMod_TextureServer::MainLoop(void) // run as a separated thread
texture_force=true;
try
{
texture_data = new char[texture_size];
texture_data = new char[(unsigned int) texture_size];
}
catch (...)
{
@@ -685,7 +790,7 @@ int uMod_TextureServer::MainLoop(void) // run as a separated thread
texture_data = (char*)0;
gl_ErrorState |= uMod_ERROR_MEMORY | uMod_ERROR_SERVER;
}
Message("MainLoop: CONTROL_FORCE_RELOAD_TEXTURE_DATA (%#lX %u, %u): %lu\n", texture_hash, texture_size, texture_data, this);
Message("MainLoop: CONTROL_FORCE_RELOAD_TEXTURE_DATA (%#llX %llu, %p): %p\n", texture_hash, texture_size, texture_data, this);
break;
}
case CONTROL_ADD_TEXTURE_DATA:
@@ -696,7 +801,7 @@ int uMod_TextureServer::MainLoop(void) // run as a separated thread
texture_force=true;
try
{
texture_data = new char[texture_size];
texture_data = new char[(unsigned int) texture_size];
}
catch (...)
{
@@ -704,29 +809,43 @@ int uMod_TextureServer::MainLoop(void) // run as a separated thread
texture_data = (char*)0;
gl_ErrorState |= uMod_ERROR_MEMORY | uMod_ERROR_SERVER;
}
Message("MainLoop: CONTROL_ADD_TEXTURE_DATA (%#lX %u, %u): %lu\n", texture_hash, texture_size, texture_data, this);
Message("MainLoop: CONTROL_ADD_TEXTURE_DATA (%#llX %llu, %p): %p\n", texture_hash, texture_size, texture_data, this);
break;
}
case CONTROL_REMOVE_TEXTURE:
{
Message("MainLoop: CONTROL_REMOVE_TEXTURE (%#lX): %lu\n", commands->Hash, this);
Message("MainLoop: CONTROL_REMOVE_TEXTURE (%#llX): %p\n", commands->Hash, this);
RemoveFile(commands->Hash);
//update_textures = true;
break;
}
case CONTROL_SAVE_ALL:
{
Message("MainLoop: CONTROL_SAVE_ALL (%#llX): %p\n", commands->Value, this);
if (commands->Value == 0) SaveAllTextures(false);
else SaveAllTextures(true);
break;
}
case CONTROL_SAVE_SINGLE:
{
Message("MainLoop: CONTROL_SAVE_SINGLE (%d): %lu\n", commands->Value, this);
Message("MainLoop: CONTROL_SAVE_SINGLE (%#llX): %p\n", commands->Value, this);
if (commands->Value == 0) SaveSingleTexture(false);
else SaveSingleTexture(true);
break;
}
case CONTROL_SAVE_ALL:
case CONTROL_SHOW_STRING:
{
Message("MainLoop: CONTROL_SAVE_ALL (%d): %lu\n", commands->Value, this);
if (commands->Value == 0) SaveAllTextures(false);
else SaveAllTextures(true);
Message("MainLoop: CONTROL_SHOW_STRING (%#llX): %p\n", commands->Value, this);
if (commands->Value == 0) ShowTextureString(false);
else ShowTextureString(true);
break;
}
case CONTROL_SUPPORT_TPF:
{
Message("MainLoop: CONTROL_SUPPORT_TPF (%#llX): %p\n", commands->Value, this);
if (commands->Value == 0) SupportTPF(false);
else SupportTPF(true);
break;
}
case CONTROL_SET_DIR:
@@ -738,37 +857,68 @@ int uMod_TextureServer::MainLoop(void) // run as a separated thread
case CONTROL_KEY_BACK:
{
Message("MainLoop: CONTROL_KEY_BACK (%#X): %lu\n", commands->Value, this);
SetKeyBack(commands->Value);
Message("MainLoop: CONTROL_KEY_BACK (%#llX): %p\n", commands->Value, this);
SetKeyBack((int) commands->Value);
break;
}
case CONTROL_KEY_SAVE:
{
Message("MainLoop: CONTROL_KEY_SAVE (%#X): %lu\n", commands->Value, this);
SetKeySave(commands->Value);
Message("MainLoop: CONTROL_KEY_SAVE (%#llX): %p\n", commands->Value, this);
SetKeySave((int) commands->Value);
break;
}
case CONTROL_KEY_NEXT:
{
Message("MainLoop: CONTROL_KEY_NEXT (%#X): %lu\n", commands->Value, this);
SetKeyNext(commands->Value);
Message("MainLoop: CONTROL_KEY_NEXT (%#llX): %p\n", commands->Value, this);
SetKeyNext((int) commands->Value);
break;
}
case CONTROL_FONT_COLOUR:
{
Message("MainLoop: CONTROL_FONT_COLOUR (%#X): %lu\n", commands->Value, this);
Message("MainLoop: CONTROL_FONT_COLOUR (%#llX): %p\n", commands->Value, this);
SetFontColour(commands->Value);
break;
}
case CONTROL_TEXTURE_COLOUR:
{
Message("MainLoop: CONTROL_TEXTURE_COLOUR (%#X): %lu\n", commands->Value, this);
Message("MainLoop: CONTROL_TEXTURE_COLOUR (%#llX): %p\n", commands->Value, this);
SetTextureColour(commands->Value);
break;
}
case CONTROL_WIDTH_FILTER:
{
Message("MainLoop: CONTROL_WIDTH_FILTER (%#llX): %p\n", commands->Value, this);
SetWidthFilter(commands->Value);
break;
}
case CONTROL_HEIGHT_FILTER:
{
Message("MainLoop: CONTROL_HEIGHT_FILTER (%#llX): %p\n", commands->Value, this);
SetHeightFilter(commands->Value);
break;
}
case CONTROL_DEPTH_FILTER:
{
Message("MainLoop: CONTROL_DEPTH_FILTER (%#llX): %p\n", commands->Value, this);
SetDepthFilter(commands->Value);
break;
}
case CONTROL_FORMAT_FILTER:
{
Message("MainLoop: CONTROL_FORMAT_FILTER (%#llX): %p\n", commands->Value, this);
SetFormatFilter(commands->Value);
break;
}
case CONTROL_SAVE_FORMAT:
{
Message("MainLoop: CONTROL_SAVE_FORMAT (%#llX): %p\n", commands->Value, this);
SetFileFormat(commands->Value);
break;
}
default:
{
Message("MainLoop: DEFAULT: %lu %lu %#lX\n", commands->Control, commands->Value, commands->Hash, this);
Message("MainLoop: DEFAULT: %lu %#llX %#llX\n", commands->Control, commands->Value, commands->Hash, this);
break;
}
}
@@ -790,7 +940,7 @@ int uMod_TextureServer::MainLoop(void) // run as a separated thread
return (RETURN_OK);
}
int uMod_TextureServer::OpenPipe(wchar_t *game) // called from InitInstance()
int uMod_TextureServer::OpenPipe(wchar_t *game, int injection_method) // called from InitInstance()
{
Message("OpenPipe: Out\n")
// open first outgoing pipe !!
@@ -810,7 +960,17 @@ int uMod_TextureServer::OpenPipe(wchar_t *game) // called from InitInstance()
len++; //to send also the zero
unsigned long num;
//send name of this game to uMod_GUI
WriteFile(Pipe.Out, (const void*) game, len * sizeof(wchar_t), &num, NULL);
char *buffer=(char*)0;
GetMemory(buffer, sizeof(int) + len * sizeof(wchar_t));
*((int*) buffer) = injection_method;
char *p_game = (char*) game;
for (unsigned int i=0; i<len*sizeof(wchar_t); i++) buffer[i+sizeof(int)] = p_game[i];
//WriteFile(Pipe.Out, (const void*) &injection_method, sizeof(int), &num, NULL);
//WriteFile(Pipe.Out, (const void*) game, len * sizeof(wchar_t), &num, NULL);
WriteFile(Pipe.Out, (const void*) buffer, len * sizeof(wchar_t) + sizeof(int), &num, NULL);
delete [] buffer;
// now we can open the pipe for reading
Message("OpenPipe: In\n");
+112 -47
View File
@@ -24,7 +24,7 @@ along with Universal Modding Engine. If not, see <http://www.gnu.org/licenses/>
#include "uMod_ArrayHandler.h"
/*
/**
* An object of this class is created only once.
* The Mainloop functions is executed by a server thread,
* which listen on a pipe.
@@ -41,34 +41,36 @@ class uMod_TextureServer
public:
/**
* The server is created from the dll entry routine.
* @param name Name of the game executable (without the extension)
* @param[in] name Name of the game executable (without the extension)
*/
uMod_TextureServer(wchar_t *name);
~uMod_TextureServer(void);
/**
* 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.
* @param[in] client This-pointer of the client
* @param[out] update Current texture to be modded
* @param[out] number Number of modded textures
* @param[in] version The device version (DX9, DX9EX, DX10, or DX101)
* @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
* @param[in] client This-pointer of the client
* @param[in] version The device version (DX9, DX9EX, DX10, or DX101)
* @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
* @param[in] name Name of the game
* @param[in] injection_method global hook=1, direct injection=2, no injection=3
* @return RETURN_OK on success
*/
int OpenPipe(wchar_t *name); // called on initialization of our d3d9 fake dll
int OpenPipe(wchar_t *name, int injection_method); // 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)
@@ -87,121 +89,184 @@ public:
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
* @param[in] buffer hold the file content of the texture
* @param[in] size size of the file content
* @param[in] hash hash of the texture to be replaced
* @param[in] 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
int AddFile( char* buffer, DWORD64 size, DWORD64 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
* Add a file to the list of texture to be modded (called from the mainloop). Not supported anymore!
* @param[in] file_name Name and path to the file to be loaded.
* @param[in] hash hash of the texture to be replaced
* @param[in] 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
int AddFile( wchar_t* file_name, DWORD64 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.
* @param[in] hash Hash of the target texture.
* @return RETURN_OK on success
*/
int RemoveFile( MyTypeHash hash); // called from Mainloop()
int RemoveFile( DWORD64 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.
* @param[in] val Set TRUE to enable the mode.
* @return
*/
int SaveAllTextures(bool val); // called from Mainloop()
/**
* (called from the mainloop).
* @param val
* Enable/Disable the save single texture mode (called from the mainloop).
* @param[in] val
* @return
*/
int SaveSingleTexture(bool val); // called from Mainloop()
/**
* (called from the mainloop).
* @param dir
* Enable/Disable the string in the left upper corner during save single texture mode (called from the mainloop).
* @param[in] val
* @return
*/
int ShowTextureString(bool val); // called from Mainloop()
/**
* Enable/Disable the hashing with CRC32, which is needed to support tpf mods (called from the mainloop).
* @param[in] val
* @return
*/
int SupportTPF(bool val); // called from Mainloop()
/**
* Set saving directory (called from the mainloop).
* @param[in] dir
* @return
*/
int SetSaveDirectory( wchar_t *dir); // called from Mainloop()
/**
* (called from the mainloop).
* @param key
* @param[in] key
* @return
*/
int SetKeyBack( int key); // called from Mainloop()
/**
* (called from the mainloop).
* @param key
* @param[in] key
* @return
*/
int SetKeySave( int key); // called from Mainloop()
/**
* (called from the mainloop).
* @param key
* @param[in] key
* @return
*/
int SetKeyNext( int key); // called from Mainloop()
/**
* (called from the mainloop).
* @param colour
* @param[in] colour
* @return
*/
int SetFontColour(DWORD colour); // called from Mainloop()
int SetFontColour(DWORD64 colour); // called from Mainloop()
/**
* (called from the mainloop).
* @param colour
* @param[in] colour
* @return
*/
int SetTextureColour(DWORD colour); // called from Mainloop()
int SetTextureColour(DWORD64 colour); // called from Mainloop()
bool BoolSaveAllTextures;
bool BoolSaveSingleTexture;
wchar_t SavePath[MAX_PATH];
wchar_t GameName[MAX_PATH];
/**
* (called from the mainloop).
* @param[in] format
* @return
*/
int SetFileFormat(DWORD64 format);
/**
* (called from the mainloop).
* @param[in] format
* @return
*/
int SetFormatFilter(DWORD64 format);
/**
* (called from the mainloop).
* @param[in] size
* @return
*/
int SetWidthFilter(DWORD64 size);
/**
* (called from the mainloop).
* @param[in] size
* @return
*/
int SetHeightFilter(DWORD64 size);
/**
* (called from the mainloop).
* @param[in] size
* @return
*/
int SetDepthFilter(DWORD64 size);
/**
* 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)
* @param[in] 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
/**
* 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
* @param[out] update
* @param[out] 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
int PrepareUpdate(TextureFileStruct* &update, int &number);
/**
* Locks the mutex.
* @return
*/
int LockMutex();
/**
* Locks the mutex.
* @return
*/
int UnlockMutex();
HANDLE Mutex;
HANDLE Mutex; //!< Mutex protects the simultaneously add or remove of multiple clients.
bool BoolSaveAllTextures;
bool BoolSaveSingleTexture;
bool BoolShowTextureString;
bool BoolSupportTPF;
wchar_t SavePath[MAX_PATH];
wchar_t GameName[MAX_PATH];
int KeyBack;
int KeySave;
int KeyNext;
DWORD FontColour;
DWORD TextureColour;
DWORD64 FontColour;
DWORD64 TextureColour;
DWORD64 FileFormat;
DWORD64 FormatFilter;
DWORD64 WidthFilter;
DWORD64 HeightFilter;
DWORD64 DepthFilter;
PipeStruct Pipe;