diff --git a/build/dxwnd.dll b/build/dxwnd.dll index 6ec58cd..9a87d37 100644 --- a/build/dxwnd.dll +++ b/build/dxwnd.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:58d53ae35a2c6ed0abd1628c80eebf170d591eb9b2a840f79b3a0507813048c9 -size 619520 +oid sha256:4ba9b297fe64848f5b2fc2ec464edf523c15537cec300708587e072b69b6d175 +size 622080 diff --git a/build/dxwnd.exe b/build/dxwnd.exe index aef5581..89e6f9f 100644 --- a/build/dxwnd.exe +++ b/build/dxwnd.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bfcf831bd510bb48aaef99c2469d1627a11d73ea4c4c50c765e257ab30b38f7e +oid sha256:bd5ee4d4d589d7580de254177665f34b2c8ead891982d3700123f29cecc90cc3 size 546304 diff --git a/build/dxwnd.ini b/build/dxwnd.ini new file mode 100644 index 0000000..5d59aee --- /dev/null +++ b/build/dxwnd.ini @@ -0,0 +1,64 @@ +[window] +posx=1313 +posy=581 +sizx=320 +sizy=200 +lang=default +exepath=D:\Games\Kasbrik\ +;lang=automatic +;updatepaths=1 +;debug=1 +;multiprocesshook=0 +;checkadmin=0 +[texture] +MinTexX=16 +MaxTexX=0 +MinTexY=16 +MaxTexY=0 +[keymapping] +timetoggle=0x72 +altf4=0x73 +timeslow=0x74 +timefast=0x75 +cliptoggle= +refresh= +logtoggle= +plocktoggle= +fpstoggle= +printscreen=0x7B +corner=0x7A +freezetime=0x79 + + +[target] +title0=Kasbrik 3D +path0=D:\Games\Kasbrik\Kasbrik.exe +launchpath0= +module0= +opengllib0= +notes0= +registry0= +ver0=8 +coord0=0 +flag0=136314914 +flagg0=1207959552 +flagh0=20 +flagi0=138412036 +flagj0=4224 +flagk0=327680 +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 +swapeffect0=0 diff --git a/build/exports/688(I) Hunter Killer.dxw b/build/exports/688(I) Hunter Killer.dxw index 2a4f44d..48711eb 100644 --- a/build/exports/688(I) Hunter Killer.dxw +++ b/build/exports/688(I) Hunter Killer.dxw @@ -13,7 +13,7 @@ flagg0=1209008128 flagh0=20 flagi0=138412036 flagj0=4224 -flagk0=327680 +flagk0=344064 tflag0=0 initx0=0 inity0=0 diff --git a/build/exports/Kasbrik 3D.dxw b/build/exports/Kasbrik 3D.dxw new file mode 100644 index 0000000..7edec24 --- /dev/null +++ b/build/exports/Kasbrik 3D.dxw @@ -0,0 +1,32 @@ +[target] +title0=Kasbrik 3D +path0=D:\Games\Kasbrik\Kasbrik.exe +launchpath0= +module0= +opengllib0= +notes0= +registry0= +ver0=8 +coord0=0 +flag0=136315426 +flagg0=1275068416 +flagh0=20 +flagi0=138412036 +flagj0=4224 +flagk0=268763136 +tflag0=0 +initx0=0 +inity0=0 +minx0=0 +miny0=0 +maxx0=800 +maxy0=600 +posx0=50 +posy0=50 +sizx0=800 +sizy0=600 +maxfps0=0 +initts0=0 +winver0=0 +maxres0=-1 +swapeffect0=0 diff --git a/build/exports/Les adventures de Robby le Robot - Mission Code de la route.dxw b/build/exports/Les adventures de Robby le Robot - Mission Code de la route.dxw new file mode 100644 index 0000000..704db29 --- /dev/null +++ b/build/exports/Les adventures de Robby le Robot - Mission Code de la route.dxw @@ -0,0 +1,32 @@ +[target] +title0=Les adventures de Robby le Robot - Mission Code de la route +path0=D:\Games\Robby Robot\VISION.EXE +launchpath0= +module0= +opengllib0= +notes0= +registry0= +ver0=0 +coord0=0 +flag0=136314914 +flagg0=1207959552 +flagh0=20 +flagi0=138412036 +flagj0=4224 +flagk0=327680 +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 +swapeffect0=0 diff --git a/build/exports/Snowmobile Racing.dxw b/build/exports/Snowmobile Racing.dxw new file mode 100644 index 0000000..1472661 --- /dev/null +++ b/build/exports/Snowmobile Racing.dxw @@ -0,0 +1,32 @@ +[target] +title0=Snowmobile Racing +path0=D:\Games\Snowmobile Racing\snow.exe +launchpath0= +module0= +opengllib0= +notes0= +registry0= +ver0=0 +coord0=0 +flag0=681574434 +flagg0=1207959552 +flagh0=20 +flagi0=138412036 +flagj0=4224 +flagk0=327680 +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 +swapeffect0=0 diff --git a/build/exports/Space Hulk.dxw b/build/exports/Space Hulk.dxw new file mode 100644 index 0000000..b62e9be --- /dev/null +++ b/build/exports/Space Hulk.dxw @@ -0,0 +1,32 @@ +[target] +title0=Space Hulk +path0=D:\Games\Space Hulk\HULKDATA\BIN\HULKW95.EXE +launchpath0= +module0= +opengllib0= +notes0=Beware: this game requirestheat the executable HULKW95.EXE, \nlocated in the HULKDATA\BIN subfolder, is run from the root directory.\nTo do so, it is necessary to create a task shortcut and ru the game from there,\nrunning the game from DxWnd is not working. +registry0= +ver0=0 +coord0=0 +flag0=140509218 +flagg0=1207959552 +flagh0=20 +flagi0=138412036 +flagj0=5248 +flagk0=327680 +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 +swapeffect0=0 diff --git a/build/exports/Star Wars X-Wing Alliance (GOG).dxw b/build/exports/Star Wars X-Wing Alliance (GOG).dxw new file mode 100644 index 0000000..7a46790 --- /dev/null +++ b/build/exports/Star Wars X-Wing Alliance (GOG).dxw @@ -0,0 +1,32 @@ +[target] +title0=Star Wars X-Wing Alliance (GOG) +path0=D:\Games\Star Wars - X-Wing Alliance (GOG)\XWINGALLIANCE.EXE +launchpath0= +module0= +opengllib0= +notes0= +registry0= +ver0=0 +coord0=0 +flag0=136314930 +flagg0=1207959552 +flagh0=20 +flagi0=138412036 +flagj0=4224 +flagk0=1476722688 +tflag0=0 +initx0=0 +inity0=0 +minx0=0 +miny0=0 +maxx0=800 +maxy0=600 +posx0=50 +posy0=50 +sizx0=800 +sizy0=600 +maxfps0=0 +initts0=0 +winver0=0 +maxres0=-1 +swapeffect0=0 diff --git a/build/exports/Star Wars X-Wing Alliance.dxw b/build/exports/Star Wars X-Wing Alliance.dxw index aa57e39..e8be10e 100644 --- a/build/exports/Star Wars X-Wing Alliance.dxw +++ b/build/exports/Star Wars X-Wing Alliance.dxw @@ -12,7 +12,7 @@ flag0=136314930 flagg0=1207959552 flagh0=20 flagi0=138412036 -flagj0=1073746048 +flagj0=1074794624 flagk0=402980864 tflag0=0 initx0=0 diff --git a/build/exports/Star Wars X-Wing vs. Tie-Fighter (GOG).dxw b/build/exports/Star Wars X-Wing vs. Tie-Fighter (GOG).dxw new file mode 100644 index 0000000..f7da9cb --- /dev/null +++ b/build/exports/Star Wars X-Wing vs. Tie-Fighter (GOG).dxw @@ -0,0 +1,32 @@ +[target] +title0=Star Wars X-Wing vs. Tie-Fighter (GOG) +path0=D:\Games\Star Wars - XvT\Z_XVT__.EXE +launchpath0= +module0= +opengllib0= +notes0= +registry0= +ver0=0 +coord0=0 +flag0=136314930 +flagg0=1207959552 +flagh0=20 +flagi0=138412036 +flagj0=67113088 +flagk0=939589632 +tflag0=0 +initx0=0 +inity0=0 +minx0=0 +miny0=0 +maxx0=800 +maxy0=600 +posx0=50 +posy0=50 +sizx0=800 +sizy0=600 +maxfps0=0 +initts0=0 +winver0=0 +maxres0=-1 +swapeffect0=0 diff --git a/build/exports/Ultim@te Race Pro.dxw b/build/exports/Ultim@te Race Pro.dxw new file mode 100644 index 0000000..12efb3b --- /dev/null +++ b/build/exports/Ultim@te Race Pro.dxw @@ -0,0 +1,32 @@ +[target] +title0=Ultim@te Race Pro +path0=D:\Games\Ultim@te Race Pro\ULTIM@TE RACE PRO.EXE +launchpath0= +module0= +opengllib0= +notes0= +registry0= +ver0=0 +coord0=0 +flag0=681574434 +flagg0=1207959552 +flagh0=20 +flagi0=138412036 +flagj0=4736 +flagk0=327680 +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 +swapeffect0=0 diff --git a/build/readme-relnotes.txt b/build/readme-relnotes.txt index 3fa406b..539309d 100644 --- a/build/readme-relnotes.txt +++ b/build/readme-relnotes.txt @@ -974,3 +974,10 @@ add: added compatibility options "Hook GOG libs" and "Byass GOG libs" to manage add: added "Enable Time Freeze" timing option and the virtual key "freezetime" add: command line option /E to terminate exixting DxWnd session fix: relocation of WS_POPUP windows. Fixes "Riven" menu window. + +v2.03.47 +add: added handling of DirectInput8 dinput8.dll +fix: completely revised directinput hooking to manage multiple devices acquire/unacquire +fix: added some dinput error codes to log messages +fix: increased time freeze toggle key hysteresis time to 1 sec to avoid multiple activations + diff --git a/dll/dinput.cpp b/dll/dinput.cpp index 76881ac..43cf6d9 100644 --- a/dll/dinput.cpp +++ b/dll/dinput.cpp @@ -9,6 +9,13 @@ #include "syslibs.h" #include "dxhelper.h" +#ifndef DIDEVTYPE_MOUSE +#define DIDEVTYPE_DEVICE 1 +#define DIDEVTYPE_MOUSE 2 +#define DIDEVTYPE_KEYBOARD 3 +#define DIDEVTYPE_JOYSTICK 4 +#endif + typedef HRESULT (WINAPI *QueryInterface_Type)(void *, REFIID, LPVOID *); typedef HRESULT (WINAPI *DirectInputCreate_Type)(HINSTANCE, DWORD, LPDIRECTINPUT *, LPUNKNOWN); typedef HRESULT (WINAPI *DirectInputCreateEx_Type)(HINSTANCE, DWORD, REFIID, LPVOID *, LPUNKNOWN); @@ -78,7 +85,11 @@ int iCurMinY; int iCurMaxX; int iCurMaxY; -void HookDirectInput(HMODULE module, int version) +LPDIRECTINPUTDEVICE lpDIDKeyboard = NULL; +LPDIRECTINPUTDEVICE lpDIDSysMouse = NULL; +LPDIRECTINPUTDEVICE lpDIDJoystick = NULL; + +void HookDirectInput(HMODULE module) { const GUID di7 = {0x9A4CB684,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE}; HINSTANCE hinst; @@ -98,7 +109,7 @@ void HookDirectInput(HMODULE module, int version) } } -void HookDirectInput8(HMODULE module, int version) +void HookDirectInput8(HMODULE module) { const GUID di8 = {0xBF798030,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00}; HINSTANCE hinst; @@ -114,51 +125,6 @@ void HookDirectInput8(HMODULE module, int version) } } -#if 0 -int HookDirectInput(HMODULE module, int version) -{ - HINSTANCE hinst; - void *tmp; - LPDIRECTINPUT lpdi; - 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", 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(!pDirectInputCreateA && !pDirectInputCreateW && !pDirectInputCreateEx){ - if(version < 8){ - hinst = LoadLibrary("dinput.dll"); - pDirectInputCreateA = - (DirectInputCreate_Type)GetProcAddress(hinst, "DirectInputCreateA"); - if(pDirectInputCreateA) - if(!extDirectInputCreateA(GetModuleHandle(0), DIRECTINPUT_VERSION, - &lpdi, 0)) lpdi->Release(); - pDirectInputCreateEx = - (DirectInputCreateEx_Type)GetProcAddress(hinst, "DirectInputCreateEx"); - if(pDirectInputCreateEx) - if(!extDirectInputCreateEx(GetModuleHandle(0), DIRECTINPUT_VERSION, - di7, (void **)&lpdi, 0)) lpdi->Release(); - } - else{ - hinst = LoadLibrary("dinput8.dll"); - pDirectInputCreateEx = - (DirectInputCreateEx_Type)GetProcAddress(hinst, "DirectInput8Create"); - if(pDirectInputCreateEx) - if(!extDirectInputCreateEx(GetModuleHandle(0), DIRECTINPUT_VERSION, - di8, (void **)&lpdi, 0)) lpdi->Release(); - } - } - if(pDirectInputCreateA || pDirectInputCreateW || pDirectInputCreateEx) return 1; - return 0; -} -#endif - FARPROC Remap_DInput_ProcAddress(LPCSTR proc, HMODULE hModule) { FARPROC addr; @@ -173,7 +139,6 @@ FARPROC Remap_DInput8_ProcAddress(LPCSTR proc, HMODULE hModule) return NULL; } -static char *libname = "dsound.dll"; HRESULT WINAPI extDirectInputCreate(HINSTANCE hinst, DWORD dwversion, LPDIRECTINPUT *lplpdi, LPUNKNOWN pu, DirectInputCreate_Type pDirectInputCreate, char *apiname) { @@ -256,14 +221,13 @@ HRESULT WINAPI extDirectInput8Create(HINSTANCE hinst, DWORD dwversion, REFIID ri } OutTraceDW("DirectInput8Create: di=%x\n", *ppvout); SetHook((void *)(**(DWORD **)ppvout + 12), extDICreateDevice, (void **)&pDICreateDevice, "CreateDevice(I8)"); + SetHook((void *)(**(DWORD **)ppvout + 16), extDIEnumDevices, (void **)&pDIEnumDevices, "EnumDevices(I8)"); return 0; } -HRESULT WINAPI extDICreateDevice(LPDIRECTINPUT lpdi, REFGUID rguid, LPDIRECTINPUTDEVICE *lplpdid, LPUNKNOWN pu) +static char *sDeviceType(REFGUID rguid) { - HRESULT res; char *devtype; - switch(rguid.Data1){ case 0x6F1D2B60: devtype = "SysMouse"; break; case 0x6F1D2B61: devtype = "SysKeyboard"; break; @@ -274,7 +238,26 @@ HRESULT WINAPI extDICreateDevice(LPDIRECTINPUT lpdi, REFGUID rguid, LPDIRECTINPU case 0x6F1D2B83: devtype = "SysKeyboardEm2"; break; default: devtype = "Unknown"; break; } - OutTraceDW("CreateDevice(I): REFGUID=%x(%s)\n", rguid.Data1, devtype); + return devtype; +} + +static int iDeviceType(REFGUID rguid) +{ + int devtype; + switch(rguid.Data1){ + case 0x6F1D2B60: devtype = DIDEVTYPE_MOUSE; break; + case 0x6F1D2B61: devtype = DIDEVTYPE_KEYBOARD; break; + case 0x6F1D2B70: devtype = DIDEVTYPE_JOYSTICK; break; + default: devtype = 0; break; + } + return devtype; +} + +HRESULT WINAPI extDICreateDevice(LPDIRECTINPUT lpdi, REFGUID rguid, LPDIRECTINPUTDEVICE *lplpdid, LPUNKNOWN pu) +{ + HRESULT res; + + OutTraceDW("CreateDevice(I): REFGUID=%x(%s)\n", rguid.Data1, sDeviceType(rguid)); res = (*pDICreateDevice)(lpdi, rguid, lplpdid, pu); if(res) { @@ -288,7 +271,13 @@ HRESULT WINAPI extDICreateDevice(LPDIRECTINPUT lpdi, REFGUID rguid, LPDIRECTINPU SetHook((void *)(**(DWORD **)lplpdid + 40), extGetDeviceData, (void **)&pGetDeviceData, "GetDeviceData(I)"); SetHook((void *)(**(DWORD **)lplpdid + 44), extSetDataFormat, (void **)&pSetDataFormat, "SetDataFormat(I)"); SetHook((void *)(**(DWORD **)lplpdid + 52), extDISetCooperativeLevel, (void **)&pDISetCooperativeLevel, "SetCooperativeLevel(I)"); - return 0; + + switch(iDeviceType(rguid)){ + case DIDEVTYPE_MOUSE: lpDIDSysMouse = *lplpdid; break; + case DIDEVTYPE_KEYBOARD: lpDIDKeyboard = *lplpdid; break; + case DIDEVTYPE_JOYSTICK: lpDIDJoystick = *lplpdid; break; + } + return DI_OK; } HRESULT WINAPI extDICreateDeviceEx(LPDIRECTINPUT lpdi, REFGUID rguid, @@ -296,7 +285,7 @@ HRESULT WINAPI extDICreateDeviceEx(LPDIRECTINPUT lpdi, REFGUID rguid, { HRESULT res; - OutTraceDW("CreateDeviceEx(I): GUID=%x REFIID=%x\n", rguid.Data1, riid.Data1); + OutTraceDW("CreateDeviceEx(I): GUID=%x(%s) REFIID=%x\n", rguid.Data1, sDeviceType(rguid), riid.Data1); res = (*pDICreateDeviceEx)(lpdi, rguid, riid, pvout, pu); if(res) { @@ -310,7 +299,13 @@ HRESULT WINAPI extDICreateDeviceEx(LPDIRECTINPUT lpdi, REFGUID rguid, SetHook((void *)(**(DWORD **)pvout + 40), extGetDeviceData, (void **)&pGetDeviceData, "GetDeviceData(I)"); SetHook((void *)(**(DWORD **)pvout + 44), extSetDataFormat, (void **)&pSetDataFormat, "SetDataFormat(I)"); SetHook((void *)(**(DWORD **)pvout + 52), extDISetCooperativeLevel, (void **)&pDISetCooperativeLevel, "SetCooperativeLevel(I)"); - return 0; + + switch(iDeviceType(rguid)){ + case DIDEVTYPE_MOUSE: lpDIDSysMouse = *(LPDIRECTINPUTDEVICE *)pvout; break; + case DIDEVTYPE_KEYBOARD: lpDIDKeyboard = *(LPDIRECTINPUTDEVICE *)pvout; break; + case DIDEVTYPE_JOYSTICK: lpDIDJoystick = *(LPDIRECTINPUTDEVICE *)pvout; break; + } + return DI_OK; } /* from MSDN: @@ -343,9 +338,18 @@ HRESULT WINAPI extGetDeviceData(LPDIRECTINPUTDEVICE lpdid, DWORD cbdata, LPVOID lpdid, cbdata, rgdod, *pdwinout, dwflags); res = (*pGetDeviceData)(lpdid, cbdata, rgdod, pdwinout, dwflags); - if(res) { - OutTraceE("GetDeviceData(I) ERROR: err=%x(%s)\n", res, ExplainDDError(res)); - return res; + switch(res){ + case DI_OK: + break; + case DIERR_NOTACQUIRED: + case DIERR_INPUTLOST: + OutTraceB("GetDeviceData(I): handling err=%s\n", ExplainDDError(res)); + *pdwinout = 0; // to avoid crashes + break; + default: + OutTraceE("GetDeviceData(I) ERROR: err=%x(%s)\n", res, ExplainDDError(res)); + return res; + break; } if(!dxw.bActive) { @@ -399,9 +403,17 @@ HRESULT WINAPI extGetDeviceState(LPDIRECTINPUTDEVICE lpdid, DWORD cbdata, LPDIMO OutTraceDW("GetDeviceState(I): did=%x cbData=%i,%i\n", lpdid, cbdata, dxw.bActive); res = (*pGetDeviceState)(lpdid, cbdata, lpvdata); - if(res) { - OutTraceE("GetDeviceState(I) ERROR: err=%x(%s)\n", res, ExplainDDError(res)); - return res; + switch(res){ + case DI_OK: + break; + case DIERR_NOTACQUIRED: + case DIERR_INPUTLOST: + OutTraceB("GetDeviceState(I): handling err=%s\n", ExplainDDError(res)); + break; + default: + OutTraceE("GetDeviceState(I) ERROR: err=%x(%s)\n", res, ExplainDDError(res)); + return res; + break; } if( cbdata == sizeof(DIMOUSESTATE) || cbdata == sizeof(DIMOUSESTATE2) @@ -424,23 +436,17 @@ HRESULT WINAPI extGetDeviceState(LPDIRECTINPUTDEVICE lpdid, DWORD cbdata, LPDIMO lpvdata->lZ = 0; *(DWORD *)lpvdata->rgbButtons = 0; } - OutTraceB("GetDeviceState(I): DEBUG mousestate=(%d,%d)\n", p.x, p.y); + OutTraceB("GetDeviceState(I): DEBUG cleared mousestate=(%d,%d)\n", p.x, p.y); } - if(cbdata == 256 && !dxw.bActive) ZeroMemory(lpvdata, 256); + // SysKeybd device + if(cbdata == 256 && !dxw.bActive) { + ZeroMemory(lpvdata, 256); + OutTraceB("GetDeviceState(I): DEBUG cleared syskeybdstate\n"); + } return DI_OK; } -//static char *dftype(LPCDIDATAFORMAT lpdf) -//{ -// if(lpdf == &c_dfDIMouse) return "mouse"; -// if(lpdf == &c_dfDIKeyboard) return "keyboard"; -// if(lpdf == &c_dfDIMouse2) return "mouse2"; -// if(lpdf == &c_dfDIJoystick) return "joy"; -// if(lpdf == &c_dfDIJoystick2) return "joy2"; -// return "custom"; -//} - static char *didftype(DWORD c) { static char eb[256]; @@ -508,6 +514,7 @@ HRESULT WINAPI extDISetCooperativeLevel(LPDIRECTINPUTDEVICE lpdid, HWND hwnd, DW if(dxw.IsRealDesktop(hwnd)) hwnd=dxw.GethWnd(); //dwflags = DISCL_NONEXCLUSIVE | DISCL_BACKGROUND; + dwflags = DISCL_NONEXCLUSIVE | DISCL_FOREGROUND; hwnd=dxw.GethWnd(); res = (*pDISetCooperativeLevel)(lpdid, hwnd, dwflags); @@ -578,29 +585,32 @@ HRESULT WINAPI extDIEnumDevices(void *lpdi, DWORD dwDevType, LPDIENUMDEVICESCALL return res; } -LPDIRECTINPUTDEVICE lpDID = NULL; - HRESULT WINAPI extAcquire(LPDIRECTINPUTDEVICE lpdid) { HRESULT res; - lpDID = lpdid; res = (*pAcquire)(lpdid); - OutTrace("Acquire(I): lpdid=%x res=%x\n", lpdid, res); + OutTrace("Acquire(I): lpdid=%x res=%x(%s)\n", lpdid, res, ExplainDDError(res)); return res; } HRESULT WINAPI extUnacquire(LPDIRECTINPUTDEVICE lpdid) { HRESULT res; - lpDID = lpdid; res = (*pUnacquire)(lpdid); - OutTrace("Unacquire(I): lpdid=%x res=%x\n", lpdid, res); + OutTrace("Unacquire(I): lpdid=%x res=%x(%s)\n", lpdid, res, ExplainDDError(res)); return res; } void ToggleAcquiredDevices(BOOL flag) { - if (!lpDID) return; - if(flag && pAcquire)(*pAcquire)(lpDID); - if(!flag && pUnacquire)(*pUnacquire)(lpDID); -} \ No newline at end of file + if(flag && pAcquire){ + if(lpDIDSysMouse) (*pAcquire)(lpDIDSysMouse); + if(lpDIDKeyboard) (*pAcquire)(lpDIDKeyboard); + if(lpDIDJoystick) (*pAcquire)(lpDIDJoystick); + } + if(!flag && pUnacquire){ + if(lpDIDSysMouse) (*pUnacquire)(lpDIDSysMouse); + if(lpDIDKeyboard) (*pUnacquire)(lpDIDKeyboard); + if(lpDIDJoystick) (*pUnacquire)(lpDIDJoystick); + } +} diff --git a/dll/dxhelper.cpp b/dll/dxhelper.cpp index c85aeed..9b7dcac 100644 --- a/dll/dxhelper.cpp +++ b/dll/dxhelper.cpp @@ -1814,6 +1814,12 @@ char *ExplainDDError(DWORD c) case D3DERR_CANNOTPROTECTCONTENT: eb="D3DERR_CANNOTPROTECTCONTENT"; break; case D3DERR_UNSUPPORTEDCRYPTO: eb="D3DERR_UNSUPPORTEDCRYPTO"; break; case D3DERR_PRESENT_STATISTICS_DISJOINT:eb="D3DERR_PRESENT_STATISTICS_DISJOINT"; break; + // DINPUT errors + case DIERR_INPUTLOST: eb="DIERR_INPUTLOST"; break; + //case DIERR_INVALIDPARAM: eb="DIERR_INVALIDPARAM"; break; + case DIERR_NOTACQUIRED: eb="DIERR_NOTACQUIRED"; break; + case DIERR_NOTINITIALIZED: eb="DIERR_NOTINITIALIZED"; break; + case E_PENDING: eb="E_PENDING"; break; default: eb="unknown"; break; } diff --git a/dll/dxhook.cpp b/dll/dxhook.cpp index b79f877..4a90362 100644 --- a/dll/dxhook.cpp +++ b/dll/dxhook.cpp @@ -852,7 +852,8 @@ void HookModule(HMODULE base, int dxversion) if(dxw.dwFlags6 & HOOKGOGLIBS) HookWinMM(base, "win32.dll"); //if(dxw.dwFlags2 & SUPPRESSIME) HookImeLib(module); HookGDI32(base); - if(dxw.dwFlags1 & HOOKDI) HookDirectInput(base, dxversion); + if(dxw.dwFlags1 & HOOKDI) HookDirectInput(base); + if(dxw.dwFlags1 & HOOKDI8) HookDirectInput8(base); if(dxw.dwTargetDDVersion != HOOKDDRAWNONE) HookDirectDraw(base, dxversion); HookDirect3D(base, dxversion); HookDirect3D7(base, dxversion); diff --git a/dll/dxhook.h b/dll/dxhook.h index 773467c..67860f6 100644 --- a/dll/dxhook.h +++ b/dll/dxhook.h @@ -4,8 +4,8 @@ extern int HookDirect3D(HMODULE, int); extern int HookDirect3D7(HMODULE, int); extern void HookOle32(HMODULE); extern void HookGDI32(HMODULE); -extern void HookDirectInput(HMODULE, int); -extern void HookDirectInput8(HMODULE, int); +extern void HookDirectInput(HMODULE); +extern void HookDirectInput8(HMODULE); extern void HookDirectSound(HMODULE); extern void HookImeLib(HMODULE); extern void HookKernel32(HMODULE); diff --git a/dll/dxwcore.cpp b/dll/dxwcore.cpp index 1087e13..a98ff3d 100644 --- a/dll/dxwcore.cpp +++ b/dll/dxwcore.cpp @@ -1214,7 +1214,7 @@ void dxwCore::GetSystemTime(LPSYSTEMTIME lpSystemTime) dwTick=(dwCurrentTick-dwStartTick); TimeShift=GetHookInfo()->TimeShift; dwTick = (*pTimeShifter)(dwTick, TimeShift); - if(dxw.TimeFreeze) dwTick=0; + if(TimeFreeze) dwTick=0; // From MSDN: Contains a 64-bit value representing the number of // 100-nanosecond intervals since January 1, 1601 (UTC). // So, since 1mSec = 10.000 * 100nSec, you still have to multiply by 10.000. @@ -1871,7 +1871,7 @@ UINT dxwCore::MapKeysConfig(UINT message, LPARAM lparam, WPARAM wparam) void dxwCore::ToggleFreezedTime() { static DWORD dwLastTime = 0; - if(((*pGetTickCount)() - dwLastTime) < 100) return; + if(((*pGetTickCount)() - dwLastTime) < 1000) return; TimeFreeze = !TimeFreeze; dwLastTime = (*pGetTickCount)(); OutTraceDW("DxWnd: time is %s\n", dxw.TimeFreeze ? "freezed" : "unfreezed"); diff --git a/dll/dxwnd.cpp b/dll/dxwnd.cpp index c3191d5..ed97561 100644 --- a/dll/dxwnd.cpp +++ b/dll/dxwnd.cpp @@ -27,7 +27,7 @@ along with this program. If not, see . #include "TlHelp32.h" -#define VERSION "2.03.46" +#define VERSION "2.03.47" #define DDTHREADLOCK 1 //#define LOCKTHREADS diff --git a/dll/dxwnd.vs2008.suo b/dll/dxwnd.vs2008.suo index a4bbf46..10a43ca 100644 Binary files a/dll/dxwnd.vs2008.suo and b/dll/dxwnd.vs2008.suo differ diff --git a/dll/gdi32.cpp b/dll/gdi32.cpp index 24d7c4c..e48a5b2 100644 --- a/dll/gdi32.cpp +++ b/dll/gdi32.cpp @@ -107,8 +107,9 @@ static HookEntry_Type ScaledHooks[]={ {HOOK_IAT_CANDIDATE, "Polygon", (FARPROC)NULL, (FARPROC *)&pPolygon, (FARPROC)extPolygon}, {HOOK_IAT_CANDIDATE, "Arc", (FARPROC)NULL, (FARPROC *)&pArc, (FARPROC)extArc}, // commented out since they alter text on screen...... (see Imperialism II difficulty level menu) - //{HOOK_IAT_CANDIDATE, "CreateEllipticRgn", (FARPROC)NULL, (FARPROC *)&pCreateEllipticRgn, (FARPROC)extCreateEllipticRgn}, - //{HOOK_IAT_CANDIDATE, "CreateEllipticRgnIndirect", (FARPROC)NULL, (FARPROC *)&pCreateEllipticRgnIndirect, (FARPROC)extCreateEllipticRgnIndirect}, + // v2.03.47 - restored: needed for "688(I) Hunter Killer" periscope .... + {HOOK_IAT_CANDIDATE, "CreateEllipticRgn", (FARPROC)NULL, (FARPROC *)&pCreateEllipticRgn, (FARPROC)extCreateEllipticRgn}, + {HOOK_IAT_CANDIDATE, "CreateEllipticRgnIndirect", (FARPROC)NULL, (FARPROC *)&pCreateEllipticRgnIndirect, (FARPROC)extCreateEllipticRgnIndirect}, // CreateRectRgn must be hooked in scaled mode to let Avernum work correctly! {HOOK_IAT_CANDIDATE, "CreateRectRgn", (FARPROC)NULL, (FARPROC *)&pCreateRectRgn, (FARPROC)extCreateRectRgn}, {HOOK_IAT_CANDIDATE, "CreateRectRgnIndirect", (FARPROC)NULL, (FARPROC *)&pCreateRectRgnIndirect, (FARPROC)extCreateRectRgnIndirect}, diff --git a/dll/kernel32.cpp b/dll/kernel32.cpp index 4cd2c7a..1095595 100644 --- a/dll/kernel32.cpp +++ b/dll/kernel32.cpp @@ -13,13 +13,16 @@ BOOL WINAPI extCheckRemoteDebuggerPresent(HANDLE, PBOOL); LPVOID WINAPI extVirtualAlloc(LPVOID, SIZE_T, DWORD, DWORD); +UINT WINAPI extWinExec(LPCSTR, UINT); typedef LPVOID (WINAPI *VirtualAlloc_Type)(LPVOID, SIZE_T, DWORD, DWORD); typedef BOOL (WINAPI *CreateProcessA_Type)(LPCTSTR, LPTSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, LPVOID, LPCTSTR, LPSTARTUPINFO, LPPROCESS_INFORMATION); +typedef UINT (WINAPI *WinExec_Type)(LPCSTR, UINT); CreateProcessA_Type pCreateProcessA = NULL; VirtualAlloc_Type pVirtualAlloc = NULL; +WinExec_Type pWinExec = NULL; #ifdef NOFREELIBRARY typedef BOOL (WINAPI *FreeLibrary_Type)(HMODULE); @@ -47,6 +50,7 @@ static HookEntry_Type Hooks[]={ {HOOK_IAT_CANDIDATE, "GetLogicalDrives", (FARPROC)NULL, (FARPROC *)&pGetLogicalDrives, (FARPROC)extGetLogicalDrives}, {HOOK_IAT_CANDIDATE, "GetTempFileNameA", (FARPROC)GetTempFileNameA, (FARPROC *)&pGetTempFileName, (FARPROC)extGetTempFileName}, {HOOK_IAT_CANDIDATE, "CreateProcessA", (FARPROC)NULL, (FARPROC *)&pCreateProcessA, (FARPROC)extCreateProcessA}, + //{HOOK_IAT_CANDIDATE, "WinExec", (FARPROC)NULL, (FARPROC *)&pWinExec, (FARPROC)extWinExec}, #ifdef NOFREELIBRARY {HOOK_HOT_CANDIDATE, "FreeLibrary", (FARPROC)FreeLibrary, (FARPROC *)&pFreeLibrary, (FARPROC)extFreeLibrary}, #endif @@ -1093,4 +1097,15 @@ LPVOID WINAPI extVirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocatio } OutTrace("VirtualAlloc: ret=%x\n", ret); return ret; -} \ No newline at end of file +} + +// WinExec: used by "Star Wars X-Wings Alliance" frontend, but fortunately it's not essential to hook it.... +UINT WINAPI extWinExec(LPCSTR lpCmdLine, UINT uCmdShow) +{ + UINT ret; + OutTraceDW("WinExec: lpCmdLine=%s CmdShow=%x\n", lpCmdLine, uCmdShow); + ret=(*pWinExec)(lpCmdLine, uCmdShow); + if(ret<31) + OutTraceE("WinExec: ERROR ret=%x\n", ret); + return ret; +} diff --git a/dll/winmm.cpp b/dll/winmm.cpp index a5d7122..0593f6b 100644 --- a/dll/winmm.cpp +++ b/dll/winmm.cpp @@ -88,7 +88,7 @@ DWORD WINAPI exttimeGetTime(void) { DWORD ret; ret = dxw.GetTickCount(); - if (IsDebug) OutTrace("timeGetTime: time=%x\n", ret); + //OutTraceB("timeGetTime: time=%x\n", ret); return ret; } diff --git a/host/TabInput.cpp b/host/TabInput.cpp index f6342d9..721361c 100644 --- a/host/TabInput.cpp +++ b/host/TabInput.cpp @@ -44,6 +44,7 @@ void CTabInput::DoDataExchange(CDataExchange* pDX) //DDX_Check(pDX, IDC_FRAMECOMPENSATION, cTarget->m_FrameCompensation); // DirectInput DDX_Check(pDX, IDC_HOOKDI, cTarget->m_HookDI); + DDX_Check(pDX, IDC_HOOKDI8, cTarget->m_HookDI8); DDX_Check(pDX, IDC_UNACQUIRE, cTarget->m_Unacquire); DDX_Text(pDX, IDC_INITX, cTarget->m_InitX); DDX_Text(pDX, IDC_INITY, cTarget->m_InitY); diff --git a/host/TargetDlg.cpp b/host/TargetDlg.cpp index 7bc263f..e0f2a19 100644 --- a/host/TargetDlg.cpp +++ b/host/TargetDlg.cpp @@ -28,6 +28,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/) m_MouseVisibility = 0; m_TextureHandling = 0; m_HookDI = FALSE; + m_HookDI8 = FALSE; m_ModifyMouse = TRUE; // default true !! m_VirtualJoystick = FALSE; m_Unacquire = FALSE; diff --git a/host/TargetDlg.h b/host/TargetDlg.h index 9a2378e..fffb53f 100644 --- a/host/TargetDlg.h +++ b/host/TargetDlg.h @@ -33,6 +33,7 @@ public: int m_TextureHandling; int m_SonProcessMode; BOOL m_HookDI; + BOOL m_HookDI8; BOOL m_ModifyMouse; BOOL m_VirtualJoystick; BOOL m_Unacquire; diff --git a/host/dxwndhost.aps b/host/dxwndhost.aps index f8b2f04..629abd5 100644 Binary files a/host/dxwndhost.aps and b/host/dxwndhost.aps differ diff --git a/host/dxwndhost.rc b/host/dxwndhost.rc index 358eda2..9979cdb 100644 Binary files a/host/dxwndhost.rc and b/host/dxwndhost.rc differ diff --git a/host/dxwndhost.vs2008.suo b/host/dxwndhost.vs2008.suo index beec9fa..bb42508 100644 Binary files a/host/dxwndhost.vs2008.suo and b/host/dxwndhost.vs2008.suo differ diff --git a/host/dxwndhostView.cpp b/host/dxwndhostView.cpp index d79e1b5..2983e35 100644 --- a/host/dxwndhostView.cpp +++ b/host/dxwndhostView.cpp @@ -247,6 +247,7 @@ static void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg) } if(dlg->m_HookDI) t->flags |= HOOKDI; + if(dlg->m_HookDI8) t->flags |= HOOKDI8; if(dlg->m_ModifyMouse) t->flags |= MODIFYMOUSE; if(dlg->m_VirtualJoystick) t->flags6 |= VIRTUALJOYSTICK; if(dlg->m_Unacquire) t->flags6 |= UNACQUIRE; @@ -491,6 +492,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg) if(t->flags5 & INJECTSON) dlg->m_SonProcessMode = 3; dlg->m_HookDI = t->flags & HOOKDI ? 1 : 0; + dlg->m_HookDI8 = t->flags & HOOKDI8 ? 1 : 0; dlg->m_ModifyMouse = t->flags & MODIFYMOUSE ? 1 : 0; dlg->m_VirtualJoystick = t->flags6 & VIRTUALJOYSTICK ? 1 : 0; dlg->m_Unacquire = t->flags6 & UNACQUIRE ? 1 : 0; diff --git a/host/resource b/host/resource index fefdb32..e023a09 100644 Binary files a/host/resource and b/host/resource differ