1
0
mirror of https://github.com/DxWnd/DxWnd.reloaded synced 2024-12-30 09:25:35 +01:00

v2_02_79_src

Former-commit-id: 60203413bf00a880af7de48467fe44a4341a4ac3
This commit is contained in:
gho tik 2014-06-14 12:39:22 -04:00 committed by Refael ACkermann
parent a60b480840
commit afbcaf5324
24 changed files with 239 additions and 119 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3bb7913ecbd4bf5117c4858a94e0f9e1d5606d8dc8165258118f0a2b4e05c6ef
size 485888
oid sha256:0552e42ae11b81672959e1b316db09614269737d6e12393f0bd473b140ce6d50
size 487424

View File

@ -5,10 +5,10 @@ module0=
opengllib0=
ver0=0
coord0=0
flag0=671088674
flag0=939524146
flagg0=1207959552
flagh0=20
flagi0=4
flagh0=16
flagi0=138412036
tflag0=0
initx0=0
inity0=0
@ -22,3 +22,6 @@ sizx0=800
sizy0=600
maxfps0=0
initts0=0
launchpath0=
winver0=0
maxres0=0

View File

@ -0,0 +1,27 @@
[target]
title0=Battle Realms
path0=D:\Games\Battle Realms\Battle_Realms_F.exe
launchpath0=
module0=
opengllib0=
ver0=0
coord0=0
flag0=150994976
flagg0=1207959552
flagh0=20
flagi0=138412036
tflag0=0
initx0=0
inity0=0
minx0=0
miny0=0
maxx0=0
maxy0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
maxfps0=0
initts0=0
winver0=0
maxres0=-1

View File

@ -8,7 +8,7 @@ coord0=0
flag0=679493664
flagg0=1207959552
flagh0=65556
flagi0=4
flagi0=69206020
tflag0=0
initx0=0
inity0=0
@ -24,3 +24,4 @@ maxfps0=0
initts0=0
winver0=0
maxres0=-1
launchpath0=

View File

@ -6,9 +6,9 @@ opengllib0=
ver0=1
coord0=0
flag0=138428450
flagg0=1108344848
flagg0=1242562576
flagh0=20
flagi0=0
flagi0=4194304
tflag0=0
initx0=0
inity0=0
@ -22,3 +22,6 @@ sizx0=640
sizy0=480
maxfps0=0
initts0=0
launchpath0=
winver0=0
maxres0=0

View File

@ -6,9 +6,9 @@ opengllib0=
ver0=0
coord0=0
flag0=16418
flagg0=574619648
flagg0=708837376
flagh0=20
flagi0=0
flagi0=4194304
tflag0=263
initx0=0
inity0=0
@ -22,3 +22,6 @@ sizx0=800
sizy0=600
maxfps0=0
initts0=0
launchpath0=
winver0=0
maxres0=0

View File

@ -8,7 +8,7 @@ coord0=0
flag0=134217762
flagg0=1209008384
flagh0=20
flagi0=4
flagi0=4194308
tflag0=64
initx0=0
inity0=0
@ -24,3 +24,4 @@ maxfps0=0
initts0=0
winver0=0
maxres0=-1
launchpath0=

View File

@ -8,7 +8,7 @@ coord0=0
flag0=150994976
flagg0=1207959552
flagh0=20
flagi0=4
flagi0=4194308
tflag0=259
initx0=0
inity0=0
@ -22,3 +22,6 @@ sizx0=800
sizy0=600
maxfps0=0
initts0=0
launchpath0=D:\Games\International Football 2000\MSIF2000.EXE
winver0=0
maxres0=0

View File

@ -8,8 +8,8 @@ coord0=0
flag0=134217762
flagg0=1207959552
flagh0=20
flagi0=1028
tflag0=6163
flagi0=4194308
tflag0=0
initx0=0
inity0=0
minx0=0
@ -22,3 +22,6 @@ sizx0=800
sizy0=600
maxfps0=0
initts0=0
launchpath0=
winver0=0
maxres0=0

View File

@ -6,9 +6,9 @@ opengllib0=
ver0=0
coord0=0
flag0=138428450
flagg0=1275068416
flagh0=8388628
flagi0=0
flagg0=201326592
flagh0=20
flagi0=4194304
tflag0=259
initx0=0
inity0=0
@ -22,3 +22,6 @@ sizx0=800
sizy0=600
maxfps0=0
initts0=0
launchpath0=
winver0=0
maxres0=0

View File

@ -4,11 +4,11 @@ path0=D:\Games\O.R.B\orb.exe
module0=
opengllib0=
ver0=0
coord0=2
coord0=0
flag0=134234144
flagg0=1207959568
flagg0=1207959552
flagh0=20
flagi0=4
flagi0=4194308
tflag0=6163
initx0=0
inity0=0
@ -24,3 +24,4 @@ maxfps0=0
initts0=0
winver0=0
maxres0=-1
launchpath0=

View File

@ -5,10 +5,10 @@ module0=
opengllib0=
ver0=0
coord0=0
flag0=2082
flagg0=143654912
flag0=134219810
flagg0=135266304
flagh0=16
flagi0=0
flagi0=4194304
tflag0=0
initx0=0
inity0=0
@ -22,3 +22,6 @@ sizx0=800
sizy0=600
maxfps0=0
initts0=0
launchpath0=
winver0=0
maxres0=0

View File

@ -10,7 +10,7 @@ flag0=134217760
flagg0=134217728
flagh0=20
flagi0=138412036
tflag0=6147
tflag0=0
initx0=0
inity0=0
minx0=0

View File

@ -5,10 +5,10 @@ module0=
opengllib0=
ver0=0
coord0=0
flag0=134234146
flagg0=1073741840
flag0=671105058
flagg0=1207959568
flagh0=16
flagi0=0
flagi0=4194304
tflag0=0
initx0=0
inity0=0
@ -22,3 +22,6 @@ sizx0=800
sizy0=600
maxfps0=0
initts0=0
launchpath0=
winver0=0
maxres0=0

View File

@ -1,5 +1,5 @@
[window]
posx=1289
posy=149
sizx=465
sizy=382
posx=1393
posy=159
sizx=455
sizy=708

View File

@ -521,4 +521,7 @@ fix: hot patch handling of loaded modules
log: fixed some messages with no line ending for GetObjectType()
d3d begin of code reorganization and cleaning
ole32, user32 API hot patched
handling of DWL_DLGPROC message
handling of DWL_DLGPROC message
v2.02.79
fix: recovered capability to "pin" ddraw and d3d calls

View File

@ -662,23 +662,19 @@ int HookDirectDraw(HMODULE module, int version)
{
if(dxw.dwFlags2 & SETCOMPATIBILITY) ddSetCompatibility();
if(dxw.dwFlags4 & HOTPATCH) {
// hot-patch all APIs and that's all folks!
HookLibrary(module, ddHooks, "ddraw.dll");
return TRUE;
}
#if 0
//void *tmp;
//const GUID dd7 = {0x15e65ec0,0x3b9c,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b};
const GUID dd7 = {0x15e65ec0,0x3b9c,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b};
HMODULE hinst;
OutTraceB("HookDirectDraw version=%d\n", version); //GHO
switch(version){
case 0: // automatic
HookLibrary(module, ddHooks, "ddraw.dll");
//tmp = HookAPI(module, "ddraw.dll", NULL, "DirectDrawCreate", extDirectDrawCreate);
//if(tmp) pDirectDrawCreate = (DirectDrawCreate_Type)tmp;
//tmp = HookAPI(module, "ddraw.dll", NULL, "DirectDrawCreateEx", extDirectDrawCreateEx);
//if(tmp) pDirectDrawCreateEx = (DirectDrawCreateEx_Type)tmp;
//tmp = HookAPI(module, "ddraw.dll", NULL, "DirectDrawEnumerateA", extDirectDrawEnumerate);
//if(tmp) pDirectDrawEnumerate = (DirectDrawEnumerate_Type)tmp;
//tmp = HookAPI(module, "ddraw.dll", NULL, "DirectDrawEnumerateExA", extDirectDrawEnumerateEx);
//if(tmp) pDirectDrawEnumerateEx = (DirectDrawEnumerateEx_Type)tmp;
break;
case 1:
case 2:
@ -686,55 +682,43 @@ int HookDirectDraw(HMODULE module, int version)
case 5:
case 6:
HookLibrary(module, ddHooks, "ddraw.dll");
//hinst = LoadLibrary("ddraw.dll");
//pDirectDrawEnumerate =
// (DirectDrawEnumerate_Type)GetProcAddress(hinst, "DirectDrawEnumerateA");
//pDirectDrawCreate =
// (DirectDrawCreate_Type)GetProcAddress(hinst, "DirectDrawCreate");
//if(dxw.dwFlags4 & HOTPATCH){
// extern void *HotPatch(void *, const char *, void *);
// pDirectDrawEnumerate = (DirectDrawEnumerate_Type)HotPatch(pDirectDrawEnumerate, "DirectDrawEnumerate", extDirectDrawEnumerate);
// pDirectDrawCreate = (DirectDrawCreate_Type)HotPatch(pDirectDrawCreate, "DirectDrawCreate", extDirectDrawCreate);
//}
//else {
// if(pDirectDrawCreate){
// LPDIRECTDRAW lpdd;
// BOOL res;
// HookAPI(module, "ddraw.dll", pDirectDrawCreate, "DirectDrawCreate", extDirectDrawCreate);
// HookAPI(module, "ddraw.dll", pDirectDrawEnumerate, "DirectDrawEnumerateA", extDirectDrawEnumerate);
// res=extDirectDrawCreate(0, &lpdd, 0);
// if (res){
// OutTraceE("DirectDrawCreate: ERROR res=%x(%s)\n", res, ExplainDDError(res));
// }
// lpdd->Release();
// }
//}
//break;
if(!pDirectDrawCreate){ // required for IAT patching
hinst = LoadLibrary("ddraw.dll");
pDirectDrawCreate = (DirectDrawCreate_Type)GetProcAddress(hinst, "DirectDrawCreate");
pDirectDrawEnumerate = (DirectDrawEnumerate_Type)GetProcAddress(hinst, "DirectDrawEnumerateA");
}
if(pDirectDrawCreate){
LPDIRECTDRAW lpdd;
BOOL res;
HookLibrary(module, ddHooks, "ddraw.dll");
res=extDirectDrawCreate(0, &lpdd, 0);
if (res){
OutTraceE("DirectDrawCreate: ERROR res=%x(%s)\n", res, ExplainDDError(res));
}
lpdd->Release();
}
break;
case 7:
HookLibrary(module, ddHooks, "ddraw.dll");
//hinst = LoadLibrary("ddraw.dll");
//pDirectDrawEnumerate =
// (DirectDrawEnumerate_Type)GetProcAddress(hinst, "DirectDrawEnumerateA");
//pDirectDrawEnumerateEx =
// (DirectDrawEnumerateEx_Type)GetProcAddress(hinst, "DirectDrawEnumerateExA");
//pDirectDrawCreate =
// (DirectDrawCreate_Type)GetProcAddress(hinst, "DirectDrawCreate");
//if(pDirectDrawCreate){
// LPDIRECTDRAW lpdd;
// BOOL res;
// HookAPI(module, "ddraw.dll", pDirectDrawCreate, "DirectDrawCreate", extDirectDrawCreate);
// HookAPI(module, "ddraw.dll", pDirectDrawEnumerate, "DirectDrawEnumerateA", extDirectDrawEnumerate);
// HookAPI(module, "ddraw.dll", pDirectDrawEnumerateEx, "DirectDrawEnumerateExA", extDirectDrawEnumerateEx);
// res=extDirectDrawCreate(0, &lpdd, 0);
// if (res) OutTraceE("DirectDrawCreate: ERROR res=%x(%s)\n", res, ExplainDDError(res));
// lpdd->Release();
//}
//pDirectDrawCreateEx =
// (DirectDrawCreateEx_Type)GetProcAddress(hinst, "DirectDrawCreateEx");
HookLibrary(module, ddHooks, "ddraw.dll");
if(!pDirectDrawCreate){ // required for IAT patching in "Crimson skies"
hinst = LoadLibrary("ddraw.dll");
pDirectDrawEnumerate = (DirectDrawEnumerate_Type)GetProcAddress(hinst, "DirectDrawEnumerateA");
pDirectDrawEnumerateEx = (DirectDrawEnumerateEx_Type)GetProcAddress(hinst, "DirectDrawEnumerateExA");
pDirectDrawCreate = (DirectDrawCreate_Type)GetProcAddress(hinst, "DirectDrawCreate");
pDirectDrawCreateEx = (DirectDrawCreateEx_Type)GetProcAddress(hinst, "DirectDrawCreateEx");
}
if(pDirectDrawCreate){
LPDIRECTDRAW lpdd;
BOOL res;
res=extDirectDrawCreate(0, &lpdd, 0);
if (res) OutTraceE("DirectDrawCreate: ERROR res=%x(%s)\n", res, ExplainDDError(res));
lpdd->Release();
}
//if(pDirectDrawCreateEx){
// LPDIRECTDRAW lpdd;
// BOOL res;
// HookAPI(module, "ddraw.dll", pDirectDrawCreateEx, "DirectDrawCreateEx", extDirectDrawCreateEx);
// HookLibrary(module, ddHooks, "ddraw.dll");
// res=extDirectDrawCreateEx(0, &lpdd, dd7, 0);
// if (res) OutTraceE("DirectDrawCreateEx: ERROR res=%x(%s)\n", res, ExplainDDError(res));
// lpdd->Release();
@ -743,9 +727,6 @@ int HookDirectDraw(HMODULE module, int version)
}
if(pDirectDrawCreate || pDirectDrawCreateEx) return 1;
#else
HookLibrary(module, ddHooks, "ddraw.dll");
#endif
return 0;
}

View File

@ -4,6 +4,7 @@
#include <windows.h>
#include <dinput.h>
#include "dxwnd.h"
#include "dxhook.h"
#include "dxwcore.hpp"
#include "syslibs.h"
#include "dxhelper.h"
@ -19,7 +20,8 @@ typedef HRESULT (WINAPI *DISetCooperativeLevel_Type)(LPDIRECTINPUTDEVICE, HWND,
typedef HRESULT (WINAPI *SetDataFormat_Type)(LPDIRECTINPUTDEVICE, LPCDIDATAFORMAT);
typedef HRESULT (WINAPI *DIEnumDevices_Type)(void *, DWORD, LPDIENUMDEVICESCALLBACK, LPVOID, DWORD);
HRESULT WINAPI extDirectInputCreate(HINSTANCE, DWORD, LPDIRECTINPUT *, LPUNKNOWN);
HRESULT WINAPI extDirectInputCreateA(HINSTANCE, DWORD, LPDIRECTINPUT *, LPUNKNOWN);
HRESULT WINAPI extDirectInputCreateW(HINSTANCE, DWORD, LPDIRECTINPUT *, LPUNKNOWN);
HRESULT WINAPI extDirectInputCreateEx(HINSTANCE, DWORD, REFIID, LPVOID *, LPUNKNOWN);
HRESULT WINAPI extDirectInput8Create(HINSTANCE, DWORD, REFIID, LPVOID *, LPUNKNOWN);
HRESULT WINAPI extDICreateDevice(LPDIRECTINPUT, REFGUID, LPDIRECTINPUTDEVICE *, LPUNKNOWN);
@ -28,21 +30,32 @@ HRESULT WINAPI extGetDeviceData(LPDIRECTINPUTDEVICE, DWORD, LPVOID, LPDWORD, DWO
HRESULT WINAPI extGetDeviceState(LPDIRECTINPUTDEVICE, DWORD, LPDIMOUSESTATE);
HRESULT WINAPI extDISetCooperativeLevel(LPDIRECTINPUTDEVICE, HWND, DWORD);
HRESULT WINAPI extSetDataFormat(LPDIRECTINPUTDEVICE, LPCDIDATAFORMAT);
HRESULT WINAPI extQueryInterfaceI(void *, REFIID, LPVOID *);
HRESULT WINAPI extDIQueryInterface(void *, REFIID, LPVOID *);
HRESULT WINAPI extDIEnumDevices(void *, DWORD, LPDIENUMDEVICESCALLBACK, LPVOID, DWORD);
void GetMousePosition(int *, int *);
void InitPosition(int, int, int, int, int, int);
DirectInputCreate_Type pDirectInputCreate = 0;
DirectInputCreate_Type pDirectInputCreateA = 0;
DirectInputCreate_Type pDirectInputCreateW = 0;
DirectInputCreateEx_Type pDirectInputCreateEx = 0;
DICreateDevice_Type pDICreateDevice = 0;
DICreateDeviceEx_Type pDICreateDeviceEx = 0;
GetDeviceData_Type pGetDeviceData;
GetDeviceState_Type pGetDeviceState;
DISetCooperativeLevel_Type pDISetCooperativeLevel;
SetDataFormat_Type pSetDataFormat;
QueryInterface_Type pQueryInterfaceI;
DIEnumDevices_Type pDIEnumDevices;
GetDeviceData_Type pGetDeviceData = 0;
GetDeviceState_Type pGetDeviceState = 0;
DISetCooperativeLevel_Type pDISetCooperativeLevel = 0;
SetDataFormat_Type pSetDataFormat = 0;
QueryInterface_Type pDIQueryInterface = 0;
DIEnumDevices_Type pDIEnumDevices = 0;
//static HookEntry_Type diHooks[]={
// {HOOK_HOT_CANDIDATE, "DirectInputCreateA", (FARPROC)NULL, (FARPROC *)&pDirectInputCreateA, (FARPROC)extDirectInputCreateA},
// {HOOK_HOT_CANDIDATE, "DirectInputCreateW", (FARPROC)NULL, (FARPROC *)&pDirectInputCreateW, (FARPROC)extDirectInputCreateW},
// {HOOK_HOT_CANDIDATE, "DirectInputCreateEx", (FARPROC)NULL, (FARPROC *)&pDirectInputCreateEx, (FARPROC)extDirectInputCreateEx},
// {HOOK_HOT_CANDIDATE, "DirectInput8Create", (FARPROC)NULL, (FARPROC *)&pDirectInput8Create, (FARPROC)extDirectInput8Create},
// {HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator
//};
void GetMousePosition(int *, int *);
void InitPosition(int, int, int, int, int, int);
int iCursorX;
int iCursorY;
@ -61,21 +74,21 @@ int HookDirectInput(HMODULE module, int version)
const GUID di7 = {0x9A4CB684,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE};
const GUID di8 = {0xBF798030,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00};
tmp = HookAPI(module, "dinput.dll", NULL, "DirectInputCreateA", extDirectInputCreate);
if(tmp) pDirectInputCreate = (DirectInputCreate_Type)tmp;
tmp = HookAPI(module, "dinput.dll", NULL, "DirectInputCreateW", extDirectInputCreate);
if(tmp) pDirectInputCreate = (DirectInputCreate_Type)tmp;
tmp = HookAPI(module, "dinput.dll", NULL, "DirectInputCreateA", extDirectInputCreateA);
if(tmp) pDirectInputCreateA = (DirectInputCreate_Type)tmp;
tmp = HookAPI(module, "dinput.dll", NULL, "DirectInputCreateW", extDirectInputCreateW);
if(tmp) pDirectInputCreateW = (DirectInputCreate_Type)tmp;
tmp = HookAPI(module, "dinput.dll", NULL, "DirectInputCreateEx", extDirectInputCreateEx);
if(tmp) pDirectInputCreateEx = (DirectInputCreateEx_Type)tmp;
tmp = HookAPI(module, "dinput8.dll", NULL, "DirectInput8Create", extDirectInput8Create);
if(tmp) pDirectInputCreateEx = (DirectInputCreateEx_Type)tmp;
if(!pDirectInputCreate && !pDirectInputCreateEx){
if(!pDirectInputCreateA && !pDirectInputCreateW && !pDirectInputCreateEx){
if(version < 8){
hinst = LoadLibrary("dinput.dll");
pDirectInputCreate =
pDirectInputCreateA =
(DirectInputCreate_Type)GetProcAddress(hinst, "DirectInputCreateA");
if(pDirectInputCreate)
if(!extDirectInputCreate(GetModuleHandle(0), DIRECTINPUT_VERSION,
if(pDirectInputCreateA)
if(!extDirectInputCreateA(GetModuleHandle(0), DIRECTINPUT_VERSION,
&lpdi, 0)) lpdi->Release();
pDirectInputCreateEx =
(DirectInputCreateEx_Type)GetProcAddress(hinst, "DirectInputCreateEx");
@ -92,29 +105,38 @@ int HookDirectInput(HMODULE module, int version)
di8, (void **)&lpdi, 0)) lpdi->Release();
}
}
if(pDirectInputCreate || pDirectInputCreateEx) return 1;
if(pDirectInputCreateA || pDirectInputCreateW || pDirectInputCreateEx) return 1;
return 0;
}
HRESULT WINAPI extDirectInputCreate(HINSTANCE hinst,
DWORD dwversion, LPDIRECTINPUT *lplpdi, LPUNKNOWN pu)
DWORD dwversion, LPDIRECTINPUT *lplpdi, LPUNKNOWN pu, DirectInputCreate_Type pDirectInputCreate, char *apiname)
{
HRESULT res;
OutTraceDW("DirectInputCreate: dwVersion=%x\n",
dwversion);
OutTraceDW("%s: dwVersion=%x\n", apiname, dwversion);
res = (*pDirectInputCreate)(hinst, dwversion, lplpdi, pu);
if(res) {
OutTraceE("DirectInputCreate: ERROR err=%x(%s)\n", res, ExplainDDError(res));
OutTraceE("%s: ERROR err=%x(%s)\n", apiname, res, ExplainDDError(res));
return res;
}
SetHook((void *)(**(DWORD **)lplpdi), extQueryInterfaceI, (void **)&pQueryInterfaceI, "QueryInterface(I)");
SetHook((void *)(**(DWORD **)lplpdi), extDIQueryInterface, (void **)&pDIQueryInterface, "QueryInterface(I)");
SetHook((void *)(**(DWORD **)lplpdi + 12), extDICreateDevice, (void **)&pDICreateDevice, "CreateDevice(I)");
SetHook((void *)(**(DWORD **)lplpdi + 16), extDIEnumDevices, (void **)&pDIEnumDevices, "EnumDevices(I)");
return 0;
}
HRESULT WINAPI extDirectInputCreateA(HINSTANCE hinst, DWORD dwversion, LPDIRECTINPUT *lplpdi, LPUNKNOWN pu)
{
return extDirectInputCreate(hinst, dwversion, lplpdi, pu, pDirectInputCreateA, "DirectInputCreateA");
}
HRESULT WINAPI extDirectInputCreateW(HINSTANCE hinst, DWORD dwversion, LPDIRECTINPUT *lplpdi, LPUNKNOWN pu)
{
return extDirectInputCreate(hinst, dwversion, lplpdi, pu, pDirectInputCreateW, "DirectInputCreateW");
}
HRESULT WINAPI extDirectInputCreateEx(HINSTANCE hinst,
DWORD dwversion, REFIID riidltf, LPVOID *ppvout, LPUNKNOWN pu)
{
@ -135,14 +157,14 @@ HRESULT WINAPI extDirectInputCreateEx(HINSTANCE hinst,
return 0;
}
HRESULT WINAPI extQueryInterfaceI(void * lpdi, REFIID riid, LPVOID *obp)
HRESULT WINAPI extDIQueryInterface(void * lpdi, REFIID riid, LPVOID *obp)
{
HRESULT res;
OutTraceDW("QueryInterface(I): REFIID=%x\n",
riid.Data1);
res = (*pQueryInterfaceI)(lpdi, riid, obp);
res = (*pDIQueryInterface)(lpdi, riid, obp);
if(res) return res;
switch(riid.Data1){
@ -380,6 +402,7 @@ HRESULT WINAPI extDIEnumDevices(void *lpdi, DWORD dwDevType, LPDIENUMDEVICESCALL
Arg.cb= lpCallback;
Arg.arg=pvRef;
res=(*pDIEnumDevices)( lpdi, dwDevType, (LPDIENUMDEVICESCALLBACK)extDeviceProxy, pvRef, dwFlags);
//res=(*pDIEnumDevices)( lpdi, dwDevType, lpCallback, pvRef, dwFlags);
OutTraceDW("EnumDevices(I): res=%x\n", res);
return res;
}

View File

@ -1642,6 +1642,19 @@ void HookLibrary(HMODULE hModule, HookEntry_Type *Hooks, char *DLLName)
}
}
void PinLibrary(HookEntry_Type *Hooks, char *DLLName)
{
HMODULE hModule = NULL;
hModule = (*pLoadLibraryA)(DLLName);
if(!hModule) {
OutTrace("PinLibrary: LoadLibrary failed on DLL=%s err=%x\n", DLLName, GetLastError());
return;
}
for(; Hooks->APIName; Hooks++){
if (Hooks->StoreAddress) *(Hooks->StoreAddress) = (*pGetProcAddress)(hModule, Hooks->APIName);
}
}
BOOL IsHotPatched(HookEntry_Type *Hooks, char *ApiName)
{
for(; Hooks->APIName; Hooks++){

View File

@ -53,5 +53,6 @@ typedef struct {
extern FARPROC RemapLibrary(LPCSTR, HMODULE, HookEntry_Type *);
extern void HookLibrary(HMODULE, HookEntry_Type *, char *);
extern void PinLibrary(HookEntry_Type *, char *);
extern void HookLibInit(HookEntry_Type *);
extern BOOL IsHotPatched(HookEntry_Type *, char *);

View File

@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dxwnd.h"
#include "dxwcore.hpp"
#define VERSION "2.02.78"
#define VERSION "2.02.79"
#define DDTHREADLOCK 1

Binary file not shown.

View File

@ -326,6 +326,12 @@ FARPROC Remap_d3d11_ProcAddress(LPCSTR proc, HMODULE hModule)
}
int HookDirect3D(HMODULE module, int version){
LPDIRECT3D9 lpd3d;
ID3D10Device *lpd3d10;
ID3D11Device *lpd3d11;
HRESULT res;
OutTrace("HookDirect3D: module=%x version=%d\n", module, version);
switch(version){
case 0:
HookLibrary(module, d3d8Hooks, "d3d8.dll");
@ -337,18 +343,57 @@ int HookDirect3D(HMODULE module, int version){
#endif
break;
case 8:
PinLibrary(d3d8Hooks, "d3d8.dll"); // pin for "Port Royale 2"
HookLibrary(module, d3d8Hooks, "d3d8.dll");
if(pDirect3DCreate8){
lpd3d = (LPDIRECT3D9)extDirect3DCreate8(220);
if(lpd3d) lpd3d->Release();
}
break;
case 9:
PinLibrary(d3d9Hooks, "d3d9.dll");// pin for "Affari tuoi"
HookLibrary(module, d3d9Hooks, "d3d9.dll");
if(pDirect3DCreate9){
lpd3d = (LPDIRECT3D9)extDirect3DCreate9(31);
if(lpd3d) lpd3d->Release();
}
break;
#ifdef HOOKD3D10ANDLATER
case 10:
PinLibrary(d3d10Hooks, "d3d10.dll");
PinLibrary(d3d10_1Hooks, "d3d10_1.dll");
HookLibrary(module, d3d10Hooks, "d3d10.dll");
HookLibrary(module, d3d10_1Hooks, "d3d10_1.dll");
if(pD3D10CreateDevice){
res = extD3D10CreateDevice(
NULL,
D3D10_DRIVER_TYPE_HARDWARE,
NULL,
0,
D3D10_SDK_VERSION,
&lpd3d10);
if(res==DD_OK) lpd3d10->Release();
}
break;
case 11:
PinLibrary(d3d11Hooks, "d3d11.dll");
HookLibrary(module, d3d11Hooks, "d3d11.dll");
if(pD3D11CreateDevice){
D3D_FEATURE_LEVEL FeatureLevel;
ID3D11DeviceContext *pImmediateContext;
res = extD3D11CreateDevice(
NULL,
D3D_DRIVER_TYPE_HARDWARE,
NULL,
0, // flags
NULL, // FeatureLevels
0,
D3D11_SDK_VERSION,
&lpd3d11,
&FeatureLevel,
&pImmediateContext);
if(res==DD_OK) lpd3d11->Release();
}
#endif
}
if(pDirect3DCreate8 || pDirect3DCreate9) return 1;

Binary file not shown.