├── d3dim.rc ├── d3dim700.rc ├── resource.h ├── d3dim.def ├── README.md ├── d3dim700.def ├── d3dim.dsw ├── LICENSE.txt ├── d3dim.c ├── d3dim.dsp ├── d3dim700.dsp ├── d3dim700.c └── .gitignore /d3dim.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UCyborg/LegacyD3DResolutionHack/HEAD/d3dim.rc -------------------------------------------------------------------------------- /d3dim700.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UCyborg/LegacyD3DResolutionHack/HEAD/d3dim700.rc -------------------------------------------------------------------------------- /resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Developer Studio generated include file. 3 | // Used by d3dim.rc 4 | // 5 | 6 | // Next default values for new objects 7 | // 8 | #ifdef APSTUDIO_INVOKED 9 | #ifndef APSTUDIO_READONLY_SYMBOLS 10 | #define _APS_NO_MFC 1 11 | #define _APS_NEXT_RESOURCE_VALUE 101 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1000 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /d3dim.def: -------------------------------------------------------------------------------- 1 | LIBRARY d3dim 2 | 3 | EXPORTS 4 | D3DMalloc = _D3DMalloc @2 5 | D3DRealloc = _D3DRealloc @3 6 | D3DFree = _D3DFree @1 7 | Direct3DCreateDevice = _Direct3DCreateDevice @4 8 | Direct3DCreateTexture = _Direct3DCreateTexture @5 9 | Direct3DCreate = _Direct3DCreate @7 10 | PaletteUpdateNotify = _PaletteUpdateNotify @12 11 | PaletteAssociateNotify = _PaletteAssociateNotify @11 12 | SurfaceFlipNotify = _SurfaceFlipNotify @13 13 | FlushD3DDevices = _FlushD3DDevices @10 14 | FlushD3DDevices2 = _FlushD3DDevices2 @9 15 | Direct3D_HALCleanUp = _Direct3D_HALCleanUp @8 16 | Direct3DGetSWRastZPixFmts = _Direct3DGetSWRastZPixFmts @6 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Legacy Direct3D Resolution Hack 2 | 3 | Simple proxy DLL which removes artificial limitation from legacy Direct3D 7 and below, 4 | allowing older Direct3D applications and games to run at resolution which width/height 5 | exceeds 2048 pixels. 6 | 7 | The application must be able to pick the desired resolution on its own, this 8 | doesn't add new resolutions to applications with hardcoded resolution list, it merely 9 | prevents Direct3D device creation function from returning an error when passed DirectDraw 10 | surface with width/height exceeding 2048 pixels. 11 | 12 | The current implementation doesn't work with all games, need to make ddraw.dll based proxy. 13 | -------------------------------------------------------------------------------- /d3dim700.def: -------------------------------------------------------------------------------- 1 | LIBRARY d3dim700 2 | 3 | EXPORTS 4 | D3DMalloc = _D3DMalloc @2 5 | D3DRealloc = _D3DRealloc @3 6 | D3DFree = _D3DFree @1 7 | Direct3DCreateDevice = _Direct3DCreateDevice @4 8 | CreateTexture = _CreateTexture @5 9 | DestroyTexture = _DestroyTexture @8 10 | SetPriority = _SetPriority @17 11 | GetPriority = _GetPriority @13 12 | SetLOD = _SetLOD @16 13 | GetLOD = _GetLOD @12 14 | Direct3DCreate = _Direct3DCreate @9 15 | FlushD3DDevices = _FlushD3DDevices @11 16 | PaletteUpdateNotify = _PaletteUpdateNotify @15 17 | PaletteAssociateNotify = _PaletteAssociateNotify @14 18 | SurfaceFlipNotify = _SurfaceFlipNotify @18 19 | D3DTextureUpdate = _D3DTextureUpdate @7 20 | D3DBreakVBLock = _D3DBreakVBLock @6 21 | Direct3D_HALCleanUp = _Direct3D_HALCleanUp @10 22 | -------------------------------------------------------------------------------- /d3dim.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "d3dim"=".\d3dim.dsp" - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "d3dim700"=".\d3dim700.dsp" - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | Global: 31 | 32 | Package=<5> 33 | {{{ 34 | }}} 35 | 36 | Package=<3> 37 | {{{ 38 | }}} 39 | 40 | ############################################################################### 41 | 42 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2016 UCyborg 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so. 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 6 | -------------------------------------------------------------------------------- /d3dim.c: -------------------------------------------------------------------------------- 1 | #define WIN32_LEAN_AND_MEAN 2 | #include 3 | 4 | void *memmem(const void *l, size_t l_len, const void *s, size_t s_len) 5 | { 6 | register char *cur, *last; 7 | const char *cl = (const char *)l; 8 | const char *cs = (const char *)s; 9 | 10 | /* we need something to compare */ 11 | if (!l_len || !s_len) 12 | return NULL; 13 | 14 | /* "s" must be smaller or equal to "l" */ 15 | if (l_len < s_len) 16 | return NULL; 17 | 18 | /* special case where s_len == 1 */ 19 | if (s_len == 1) 20 | return memchr(l, (int)*cs, l_len); 21 | 22 | /* the last position where it's possible to find "s" in "l" */ 23 | last = (char *)cl + l_len - s_len; 24 | 25 | for (cur = (char *)cl; cur <= last; cur++) 26 | if (cur[0] == cs[0] && !memcmp(cur, cs, s_len)) 27 | return cur; 28 | 29 | return NULL; 30 | } 31 | 32 | FARPROC D3DMalloc; 33 | FARPROC D3DRealloc; 34 | FARPROC D3DFree; 35 | FARPROC Direct3DCreateDevice; 36 | FARPROC Direct3DCreateTexture; 37 | FARPROC Direct3DCreate; 38 | FARPROC PaletteUpdateNotify; 39 | FARPROC PaletteAssociateNotify; 40 | FARPROC SurfaceFlipNotify; 41 | FARPROC FlushD3DDevices; 42 | FARPROC FlushD3DDevices2; 43 | FARPROC Direct3D_HALCleanUp; 44 | FARPROC Direct3DGetSWRastZPixFmts; 45 | 46 | __declspec(naked) void _D3DMalloc() { __asm { jmp [D3DMalloc] } } 47 | __declspec(naked) void _D3DRealloc() { __asm { jmp [D3DRealloc] } } 48 | __declspec(naked) void _D3DFree() { __asm { jmp [D3DFree] } } 49 | __declspec(naked) void _Direct3DCreateDevice() { __asm { jmp [Direct3DCreateDevice] } } 50 | __declspec(naked) void _Direct3DCreateTexture() { __asm { jmp [Direct3DCreateTexture] } } 51 | __declspec(naked) void _Direct3DCreate() { __asm { jmp [Direct3DCreate] } } 52 | __declspec(naked) void _PaletteUpdateNotify() { __asm { jmp [PaletteUpdateNotify] } } 53 | __declspec(naked) void _PaletteAssociateNotify() { __asm { jmp [PaletteAssociateNotify] } } 54 | __declspec(naked) void _SurfaceFlipNotify() { __asm { jmp [SurfaceFlipNotify] } } 55 | __declspec(naked) void _FlushD3DDevices() { __asm { jmp [FlushD3DDevices] } } 56 | __declspec(naked) void _FlushD3DDevices2() { __asm { jmp [FlushD3DDevices2] } } 57 | __declspec(naked) void _Direct3D_HALCleanUp() { __asm { jmp [Direct3D_HALCleanUp] } } 58 | __declspec(naked) void _Direct3DGetSWRastZPixFmts() { __asm { jmp [Direct3DGetSWRastZPixFmts] } } 59 | 60 | const BYTE wantedBytes[] = { 0xB8, 0x00, 0x08, 0x00, 0x00, 0x39 }; 61 | 62 | BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 63 | { 64 | if (fdwReason) 65 | { 66 | char szPath[MAX_PATH]; 67 | HMODULE hD3DIm; 68 | PIMAGE_DOS_HEADER pDosHeader; 69 | PIMAGE_NT_HEADERS pNtHeader; 70 | DWORD dwCodeBase; 71 | DWORD dwCodeSize; 72 | DWORD dwPatchBase; 73 | DWORD dwOldProtect; 74 | 75 | DisableThreadLibraryCalls(hinstDLL); 76 | 77 | GetSystemDirectory(szPath, MAX_PATH); 78 | strcat(szPath, "\\d3dim.dll"); 79 | hD3DIm = LoadLibrary(szPath); 80 | 81 | pDosHeader = (PIMAGE_DOS_HEADER)hD3DIm; 82 | pNtHeader = (PIMAGE_NT_HEADERS)((char *)pDosHeader + pDosHeader->e_lfanew); 83 | dwCodeBase = (DWORD)hD3DIm + pNtHeader->OptionalHeader.BaseOfCode; 84 | dwCodeSize = pNtHeader->OptionalHeader.SizeOfCode; 85 | 86 | dwPatchBase = (DWORD)memmem((void *)dwCodeBase, dwCodeSize, wantedBytes, sizeof(wantedBytes)); 87 | if (dwPatchBase) 88 | { 89 | dwPatchBase++; 90 | VirtualProtect((LPVOID)dwPatchBase, 4, PAGE_EXECUTE_READWRITE, &dwOldProtect); 91 | *(DWORD *)dwPatchBase = -1; 92 | VirtualProtect((LPVOID)dwPatchBase, 4, dwOldProtect, &dwOldProtect); 93 | } 94 | 95 | D3DMalloc = GetProcAddress(hD3DIm, "D3DMalloc"); 96 | D3DRealloc = GetProcAddress(hD3DIm, "D3DRealloc"); 97 | D3DFree = GetProcAddress(hD3DIm, "D3DFree"); 98 | Direct3DCreateDevice = GetProcAddress(hD3DIm, "Direct3DCreateDevice"); 99 | Direct3DCreateTexture = GetProcAddress(hD3DIm, "Direct3DCreateTexture"); 100 | Direct3DCreate = GetProcAddress(hD3DIm, "Direct3DCreate"); 101 | PaletteUpdateNotify = GetProcAddress(hD3DIm, "PaletteUpdateNotify"); 102 | PaletteAssociateNotify = GetProcAddress(hD3DIm, "PaletteAssociateNotify"); 103 | SurfaceFlipNotify = GetProcAddress(hD3DIm, "SurfaceFlipNotify"); 104 | FlushD3DDevices = GetProcAddress(hD3DIm, "FlushD3DDevices"); 105 | FlushD3DDevices2 = GetProcAddress(hD3DIm, "FlushD3DDevices2"); 106 | Direct3D_HALCleanUp = GetProcAddress(hD3DIm, "Direct3D_HALCleanUp"); 107 | Direct3DGetSWRastZPixFmts = GetProcAddress(hD3DIm, "Direct3DGetSWRastZPixFmts"); 108 | } 109 | return TRUE; 110 | } 111 | -------------------------------------------------------------------------------- /d3dim.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="d3dim" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 6 | 7 | CFG=d3dim - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "d3dim.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "d3dim.mak" CFG="d3dim - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "d3dim - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") 21 | !MESSAGE "d3dim - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "d3dim - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 0 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "Release" 42 | # PROP Intermediate_Dir "Release" 43 | # PROP Ignore_Export_Lib 1 44 | # PROP Target_Dir "" 45 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "d3dim_EXPORTS" /YX /FD /c 46 | # ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "d3dim_EXPORTS" /FR /FD /c 47 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 48 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 49 | # ADD BASE RSC /l 0x424 /d "NDEBUG" 50 | # ADD RSC /l 0x424 /d "NDEBUG" 51 | BSC32=bscmake.exe 52 | # ADD BASE BSC32 /nologo 53 | # ADD BSC32 /nologo 54 | LINK32=link.exe 55 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 56 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /def:"d3dim.def" /opt:nowin98 57 | # SUBTRACT LINK32 /pdb:none /debug 58 | 59 | !ELSEIF "$(CFG)" == "d3dim - Win32 Debug" 60 | 61 | # PROP BASE Use_MFC 0 62 | # PROP BASE Use_Debug_Libraries 1 63 | # PROP BASE Output_Dir "Debug" 64 | # PROP BASE Intermediate_Dir "Debug" 65 | # PROP BASE Target_Dir "" 66 | # PROP Use_MFC 0 67 | # PROP Use_Debug_Libraries 1 68 | # PROP Output_Dir "Debug" 69 | # PROP Intermediate_Dir "Debug" 70 | # PROP Ignore_Export_Lib 1 71 | # PROP Target_Dir "" 72 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "d3dim_EXPORTS" /YX /FD /GZ /c 73 | # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "d3dim_EXPORTS" /FR /FD /GZ /c 74 | # SUBTRACT CPP /YX 75 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 76 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 77 | # ADD BASE RSC /l 0x424 /d "_DEBUG" 78 | # ADD RSC /l 0x424 /d "_DEBUG" 79 | BSC32=bscmake.exe 80 | # ADD BASE BSC32 /nologo 81 | # ADD BSC32 /nologo 82 | LINK32=link.exe 83 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept 84 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /def:"d3dim.def" /pdbtype:sept /opt:nowin98 85 | # SUBTRACT LINK32 /pdb:none 86 | 87 | !ENDIF 88 | 89 | # Begin Target 90 | 91 | # Name "d3dim - Win32 Release" 92 | # Name "d3dim - Win32 Debug" 93 | # Begin Group "Source Files" 94 | 95 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 96 | # Begin Source File 97 | 98 | SOURCE=.\d3dim.c 99 | # End Source File 100 | # End Group 101 | # Begin Group "Header Files" 102 | 103 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 104 | # End Group 105 | # Begin Group "Resource Files" 106 | 107 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 108 | # Begin Source File 109 | 110 | SOURCE=.\d3dim.rc 111 | # End Source File 112 | # End Group 113 | # End Target 114 | # End Project 115 | -------------------------------------------------------------------------------- /d3dim700.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="d3dim700" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 6 | 7 | CFG=d3dim700 - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "d3dim700.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "d3dim700.mak" CFG="d3dim700 - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "d3dim700 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") 21 | !MESSAGE "d3dim700 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "d3dim700 - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 0 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "Release" 42 | # PROP Intermediate_Dir "Release" 43 | # PROP Ignore_Export_Lib 1 44 | # PROP Target_Dir "" 45 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "d3dim700_EXPORTS" /YX /FD /c 46 | # ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "d3dim700_EXPORTS" /FR /FD /c 47 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 48 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 49 | # ADD BASE RSC /l 0x424 /d "NDEBUG" 50 | # ADD RSC /l 0x424 /d "NDEBUG" 51 | BSC32=bscmake.exe 52 | # ADD BASE BSC32 /nologo 53 | # ADD BSC32 /nologo 54 | LINK32=link.exe 55 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 56 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /def:"d3dim700.def" /opt:nowin98 57 | # SUBTRACT LINK32 /pdb:none /debug 58 | 59 | !ELSEIF "$(CFG)" == "d3dim700 - Win32 Debug" 60 | 61 | # PROP BASE Use_MFC 0 62 | # PROP BASE Use_Debug_Libraries 1 63 | # PROP BASE Output_Dir "Debug" 64 | # PROP BASE Intermediate_Dir "Debug" 65 | # PROP BASE Target_Dir "" 66 | # PROP Use_MFC 0 67 | # PROP Use_Debug_Libraries 1 68 | # PROP Output_Dir "Debug" 69 | # PROP Intermediate_Dir "Debug" 70 | # PROP Ignore_Export_Lib 1 71 | # PROP Target_Dir "" 72 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "d3dim700_EXPORTS" /YX /FD /GZ /c 73 | # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "d3dim700_EXPORTS" /FR /FD /GZ /c 74 | # SUBTRACT CPP /YX 75 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 76 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 77 | # ADD BASE RSC /l 0x424 /d "_DEBUG" 78 | # ADD RSC /l 0x424 /d "_DEBUG" 79 | BSC32=bscmake.exe 80 | # ADD BASE BSC32 /nologo 81 | # ADD BSC32 /nologo 82 | LINK32=link.exe 83 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept 84 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /def:"d3dim700.def" /pdbtype:sept /opt:nowin98 85 | # SUBTRACT LINK32 /pdb:none 86 | 87 | !ENDIF 88 | 89 | # Begin Target 90 | 91 | # Name "d3dim700 - Win32 Release" 92 | # Name "d3dim700 - Win32 Debug" 93 | # Begin Group "Source Files" 94 | 95 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 96 | # Begin Source File 97 | 98 | SOURCE=.\d3dim700.c 99 | # End Source File 100 | # End Group 101 | # Begin Group "Header Files" 102 | 103 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 104 | # End Group 105 | # Begin Group "Resource Files" 106 | 107 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 108 | # Begin Source File 109 | 110 | SOURCE=.\d3dim700.rc 111 | # End Source File 112 | # End Group 113 | # End Target 114 | # End Project 115 | -------------------------------------------------------------------------------- /d3dim700.c: -------------------------------------------------------------------------------- 1 | #define WIN32_LEAN_AND_MEAN 2 | #include 3 | 4 | void *memmem(const void *l, size_t l_len, const void *s, size_t s_len) 5 | { 6 | register char *cur, *last; 7 | const char *cl = (const char *)l; 8 | const char *cs = (const char *)s; 9 | 10 | /* we need something to compare */ 11 | if (!l_len || !s_len) 12 | return NULL; 13 | 14 | /* "s" must be smaller or equal to "l" */ 15 | if (l_len < s_len) 16 | return NULL; 17 | 18 | /* special case where s_len == 1 */ 19 | if (s_len == 1) 20 | return memchr(l, (int)*cs, l_len); 21 | 22 | /* the last position where it's possible to find "s" in "l" */ 23 | last = (char *)cl + l_len - s_len; 24 | 25 | for (cur = (char *)cl; cur <= last; cur++) 26 | if (cur[0] == cs[0] && !memcmp(cur, cs, s_len)) 27 | return cur; 28 | 29 | return NULL; 30 | } 31 | 32 | FARPROC D3DMalloc; 33 | FARPROC D3DRealloc; 34 | FARPROC D3DFree; 35 | FARPROC Direct3DCreateDevice; 36 | FARPROC CreateTexture; 37 | FARPROC DestroyTexture; 38 | FARPROC SetPriority; 39 | FARPROC GetPriority; 40 | FARPROC SetLOD; 41 | FARPROC GetLOD; 42 | FARPROC Direct3DCreate; 43 | FARPROC FlushD3DDevices; 44 | FARPROC PaletteUpdateNotify; 45 | FARPROC PaletteAssociateNotify; 46 | FARPROC SurfaceFlipNotify; 47 | FARPROC D3DTextureUpdate; 48 | FARPROC D3DBreakVBLock; 49 | FARPROC Direct3D_HALCleanUp; 50 | 51 | __declspec(naked) void _D3DMalloc() { __asm { jmp [D3DMalloc] } } 52 | __declspec(naked) void _D3DRealloc() { __asm { jmp [D3DRealloc] } } 53 | __declspec(naked) void _D3DFree() { __asm { jmp [D3DFree] } } 54 | __declspec(naked) void _Direct3DCreateDevice() { __asm { jmp [Direct3DCreateDevice] } } 55 | __declspec(naked) void _CreateTexture() { __asm { jmp [CreateTexture] } } 56 | __declspec(naked) void _DestroyTexture() { __asm { jmp [DestroyTexture] } } 57 | __declspec(naked) void _SetPriority() { __asm { jmp [SetPriority] } } 58 | __declspec(naked) void _GetPriority() { __asm { jmp [GetPriority] } } 59 | __declspec(naked) void _SetLOD() { __asm { jmp [SetLOD] } } 60 | __declspec(naked) void _GetLOD() { __asm { jmp [GetLOD] } } 61 | __declspec(naked) void _Direct3DCreate() { __asm { jmp [Direct3DCreate] } } 62 | __declspec(naked) void _FlushD3DDevices() { __asm { jmp [FlushD3DDevices] } } 63 | __declspec(naked) void _PaletteUpdateNotify() { __asm { jmp [PaletteUpdateNotify] } } 64 | __declspec(naked) void _PaletteAssociateNotify() { __asm { jmp [PaletteAssociateNotify] } } 65 | __declspec(naked) void _SurfaceFlipNotify() { __asm { jmp [SurfaceFlipNotify] } } 66 | __declspec(naked) void _D3DTextureUpdate() { __asm { jmp [D3DTextureUpdate] } } 67 | __declspec(naked) void _D3DBreakVBLock() { __asm { jmp [D3DBreakVBLock] } } 68 | __declspec(naked) void _Direct3D_HALCleanUp() { __asm { jmp [Direct3D_HALCleanUp] } } 69 | 70 | const BYTE wantedBytes[] = { 0xB8, 0x00, 0x08, 0x00, 0x00, 0x39 }; 71 | 72 | BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 73 | { 74 | if (fdwReason) 75 | { 76 | char szPath[MAX_PATH]; 77 | HMODULE hD3DIm; 78 | PIMAGE_DOS_HEADER pDosHeader; 79 | PIMAGE_NT_HEADERS pNtHeader; 80 | DWORD dwCodeBase; 81 | DWORD dwCodeSize; 82 | DWORD dwPatchBase; 83 | DWORD dwOldProtect; 84 | 85 | DisableThreadLibraryCalls(hinstDLL); 86 | 87 | GetSystemDirectory(szPath, MAX_PATH); 88 | strcat(szPath, "\\d3dim700.dll"); 89 | hD3DIm = LoadLibrary(szPath); 90 | 91 | pDosHeader = (PIMAGE_DOS_HEADER)hD3DIm; 92 | pNtHeader = (PIMAGE_NT_HEADERS)((char *)pDosHeader + pDosHeader->e_lfanew); 93 | dwCodeBase = (DWORD)hD3DIm + pNtHeader->OptionalHeader.BaseOfCode; 94 | dwCodeSize = pNtHeader->OptionalHeader.SizeOfCode; 95 | 96 | dwPatchBase = (DWORD)memmem((void *)dwCodeBase, dwCodeSize, wantedBytes, sizeof(wantedBytes)); 97 | if (dwPatchBase) 98 | { 99 | dwPatchBase++; 100 | VirtualProtect((LPVOID)dwPatchBase, 4, PAGE_EXECUTE_READWRITE, &dwOldProtect); 101 | *(DWORD *)dwPatchBase = -1; 102 | VirtualProtect((LPVOID)dwPatchBase, 4, dwOldProtect, &dwOldProtect); 103 | } 104 | 105 | D3DMalloc = GetProcAddress(hD3DIm, "D3DMalloc"); 106 | D3DRealloc = GetProcAddress(hD3DIm, "D3DRealloc"); 107 | D3DFree = GetProcAddress(hD3DIm, "D3DFree"); 108 | Direct3DCreateDevice = GetProcAddress(hD3DIm, "Direct3DCreateDevice"); 109 | CreateTexture = GetProcAddress(hD3DIm, "CreateTexture"); 110 | DestroyTexture = GetProcAddress(hD3DIm, "DestroyTexture"); 111 | SetPriority = GetProcAddress(hD3DIm, "SetPriority"); 112 | GetPriority = GetProcAddress(hD3DIm, "GetPriority"); 113 | SetLOD = GetProcAddress(hD3DIm, "SetLOD"); 114 | GetLOD = GetProcAddress(hD3DIm, "GetLOD"); 115 | Direct3DCreate = GetProcAddress(hD3DIm, "Direct3DCreate"); 116 | FlushD3DDevices = GetProcAddress(hD3DIm, "FlushD3DDevices"); 117 | PaletteUpdateNotify = GetProcAddress(hD3DIm, "PaletteUpdateNotify"); 118 | PaletteAssociateNotify = GetProcAddress(hD3DIm, "PaletteAssociateNotify"); 119 | SurfaceFlipNotify = GetProcAddress(hD3DIm, "SurfaceFlipNotify"); 120 | D3DTextureUpdate = GetProcAddress(hD3DIm, "D3DTextureUpdate"); 121 | D3DBreakVBLock = GetProcAddress(hD3DIm, "D3DBreakVBLock"); 122 | Direct3D_HALCleanUp = GetProcAddress(hD3DIm, "Direct3D_HALCleanUp"); 123 | } 124 | return TRUE; 125 | } 126 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/windows,codeblocks,linux,c,visualstudio 2 | 3 | ### Windows ### 4 | # Windows image file caches 5 | Thumbs.db 6 | ehthumbs.db 7 | 8 | # Folder config file 9 | Desktop.ini 10 | 11 | # Recycle Bin used on file shares 12 | $RECYCLE.BIN/ 13 | 14 | # Windows Installer files 15 | *.cab 16 | *.msi 17 | *.msm 18 | *.msp 19 | 20 | # Windows shortcuts 21 | *.lnk 22 | 23 | 24 | ### CodeBlocks ### 25 | # specific to CodeBlocks IDE 26 | *.cbp 27 | *.layout 28 | *.depend 29 | 30 | # generated directories 31 | bin/ 32 | obj/ 33 | 34 | 35 | ### Linux ### 36 | *~ 37 | 38 | # temporary files which can be created if a process still has a handle open of a deleted file 39 | .fuse_hidden* 40 | 41 | # KDE directory preferences 42 | .directory 43 | 44 | # Linux trash folder which might appear on any partition or disk 45 | .Trash-* 46 | 47 | 48 | ### C ### 49 | # Object files 50 | *.o 51 | *.ko 52 | *.obj 53 | *.elf 54 | 55 | # Precompiled Headers 56 | *.gch 57 | *.pch 58 | 59 | # Libraries 60 | *.lib 61 | *.a 62 | *.la 63 | *.lo 64 | 65 | # Shared objects (inc. Windows DLLs) 66 | *.dll 67 | *.so 68 | *.so.* 69 | *.dylib 70 | 71 | # Executables 72 | *.exe 73 | *.out 74 | *.app 75 | *.i*86 76 | *.x86_64 77 | *.hex 78 | 79 | # Debug files 80 | *.dSYM/ 81 | 82 | 83 | ### VisualStudio ### 84 | ## Ignore Visual Studio temporary files, build results, and 85 | ## files generated by popular Visual Studio add-ons. 86 | 87 | # Database files 88 | *.db 89 | *.opendb 90 | 91 | # User-specific files 92 | *.suo 93 | *.user 94 | *.userosscache 95 | *.sln.docstates 96 | 97 | # User-specific files (MonoDevelop/Xamarin Studio) 98 | *.userprefs 99 | 100 | # Build results 101 | [Dd]ebug/ 102 | [Dd]ebugPublic/ 103 | [Rr]elease/ 104 | [Rr]eleases/ 105 | x64/ 106 | x86/ 107 | bld/ 108 | [Bb]in/ 109 | [Oo]bj/ 110 | [Ll]og/ 111 | 112 | # Visual Studio 2015 cache/options directory 113 | .vs/ 114 | # Uncomment if you have tasks that create the project's static files in wwwroot 115 | #wwwroot/ 116 | 117 | # MSTest test Results 118 | [Tt]est[Rr]esult*/ 119 | [Bb]uild[Ll]og.* 120 | 121 | # NUNIT 122 | *.VisualState.xml 123 | TestResult.xml 124 | 125 | # Build Results of an ATL Project 126 | [Dd]ebugPS/ 127 | [Rr]eleasePS/ 128 | dlldata.c 129 | 130 | # DNX 131 | project.lock.json 132 | artifacts/ 133 | 134 | *_i.c 135 | *_p.c 136 | *_i.h 137 | *.ilk 138 | *.meta 139 | *.obj 140 | *.pch 141 | *.pdb 142 | *.pgc 143 | *.pgd 144 | *.rsp 145 | *.sbr 146 | *.tlb 147 | *.tli 148 | *.tlh 149 | *.tmp 150 | *.tmp_proj 151 | *.log 152 | *.vspscc 153 | *.vssscc 154 | .builds 155 | *.pidb 156 | *.svclog 157 | *.scc 158 | 159 | # Chutzpah Test files 160 | _Chutzpah* 161 | 162 | # Visual C++ cache files 163 | ipch/ 164 | *.aps 165 | *.ncb 166 | *.opendb 167 | *.opensdf 168 | *.sdf 169 | *.cachefile 170 | 171 | # Visual Studio profiler 172 | *.psess 173 | *.vsp 174 | *.vspx 175 | *.sap 176 | 177 | # TFS 2012 Local Workspace 178 | $tf/ 179 | 180 | # Guidance Automation Toolkit 181 | *.gpState 182 | 183 | # ReSharper is a .NET coding add-in 184 | _ReSharper*/ 185 | *.[Rr]e[Ss]harper 186 | *.DotSettings.user 187 | 188 | # JustCode is a .NET coding add-in 189 | .JustCode 190 | 191 | # TeamCity is a build add-in 192 | _TeamCity* 193 | 194 | # DotCover is a Code Coverage Tool 195 | *.dotCover 196 | 197 | # NCrunch 198 | _NCrunch_* 199 | .*crunch*.local.xml 200 | nCrunchTemp_* 201 | 202 | # MightyMoose 203 | *.mm.* 204 | AutoTest.Net/ 205 | 206 | # Web workbench (sass) 207 | .sass-cache/ 208 | 209 | # Installshield output folder 210 | [Ee]xpress/ 211 | 212 | # DocProject is a documentation generator add-in 213 | DocProject/buildhelp/ 214 | DocProject/Help/*.HxT 215 | DocProject/Help/*.HxC 216 | DocProject/Help/*.hhc 217 | DocProject/Help/*.hhk 218 | DocProject/Help/*.hhp 219 | DocProject/Help/Html2 220 | DocProject/Help/html 221 | 222 | # Click-Once directory 223 | publish/ 224 | 225 | # Publish Web Output 226 | *.[Pp]ublish.xml 227 | *.azurePubxml 228 | # TODO: Comment the next line if you want to checkin your web deploy settings 229 | # but database connection strings (with potential passwords) will be unencrypted 230 | *.pubxml 231 | *.publishproj 232 | 233 | # NuGet Packages 234 | *.nupkg 235 | # The packages folder can be ignored because of Package Restore 236 | **/packages/* 237 | # except build/, which is used as an MSBuild target. 238 | !**/packages/build/ 239 | # Uncomment if necessary however generally it will be regenerated when needed 240 | #!**/packages/repositories.config 241 | # NuGet v3's project.json files produces more ignoreable files 242 | *.nuget.props 243 | *.nuget.targets 244 | 245 | # Microsoft Azure Build Output 246 | csx/ 247 | *.build.csdef 248 | 249 | # Microsoft Azure Emulator 250 | ecf/ 251 | rcf/ 252 | 253 | # Windows Store app package directories and files 254 | AppPackages/ 255 | BundleArtifacts/ 256 | Package.StoreAssociation.xml 257 | _pkginfo.txt 258 | 259 | # Visual Studio cache files 260 | # files ending in .cache can be ignored 261 | *.[Cc]ache 262 | # but keep track of directories ending in .cache 263 | !*.[Cc]ache/ 264 | 265 | # Others 266 | ClientBin/ 267 | ~$* 268 | *~ 269 | *.dbmdl 270 | *.dbproj.schemaview 271 | *.pfx 272 | *.publishsettings 273 | node_modules/ 274 | orleans.codegen.cs 275 | 276 | # Since there are multiple workflows, uncomment next line to ignore bower_components 277 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 278 | #bower_components/ 279 | 280 | # RIA/Silverlight projects 281 | Generated_Code/ 282 | 283 | # Backup & report files from converting an old project file 284 | # to a newer Visual Studio version. Backup files are not needed, 285 | # because we have git ;-) 286 | _UpgradeReport_Files/ 287 | Backup*/ 288 | UpgradeLog*.XML 289 | UpgradeLog*.htm 290 | 291 | # SQL Server files 292 | *.mdf 293 | *.ldf 294 | 295 | # Business Intelligence projects 296 | *.rdl.data 297 | *.bim.layout 298 | *.bim_*.settings 299 | 300 | # Microsoft Fakes 301 | FakesAssemblies/ 302 | 303 | # GhostDoc plugin setting file 304 | *.GhostDoc.xml 305 | 306 | # Node.js Tools for Visual Studio 307 | .ntvs_analysis.dat 308 | 309 | # Visual Studio 6 build log 310 | *.plg 311 | 312 | # Visual Studio 6 workspace options file 313 | *.opt 314 | 315 | # Visual Studio LightSwitch build output 316 | **/*.HTMLClient/GeneratedArtifacts 317 | **/*.DesktopClient/GeneratedArtifacts 318 | **/*.DesktopClient/ModelManifest.xml 319 | **/*.Server/GeneratedArtifacts 320 | **/*.Server/ModelManifest.xml 321 | _Pvt_Extensions 322 | 323 | # Paket dependency manager 324 | .paket/paket.exe 325 | paket-files/ 326 | 327 | # FAKE - F# Make 328 | .fake/ 329 | 330 | # JetBrains Rider 331 | .idea/ 332 | *.sln.iml 333 | --------------------------------------------------------------------------------