diff --git a/Include/dxwnd.h b/Include/dxwnd.h
index c3eb578..26d76bd 100644
--- a/Include/dxwnd.h
+++ b/Include/dxwnd.h
@@ -27,7 +27,7 @@
#define FIXWINFRAME 0x00002000
#define HIDEHWCURSOR 0x00004000
#define SLOWDOWN 0x00008000
-#define ENABLECLIPPING 0x00010000
+#define DISABLECLIPPING 0x00010000
#define LOCKWINSTYLE 0x00020000
#define MAPGDITOPRIMARY 0x00040000
#define FIXTEXTOUT 0x00080000
@@ -254,6 +254,9 @@
#define FORCEVSYNC 0x00000004 // Forces hardware VSync
#define FORCENOVSYNC 0x00000008 // Forces NO hardware VSync
#define VSYNCSCANLINE 0x00000010 // Activates WaitForVerticalBlank algorythm based on reaching a given scan line
+#define TRIMTEXTUREFORMATS 0x00000020 // Emulates "DirectXTrimTextureFormats" shim to fix textures in Heavy Gear II
+#define NOHALDEVICE 0x00000040 // Simulates a situation of lack of 3D hardware support, like in presence of remote desktop
+#define CLIPLOCKED 0x00000080 // never destroy cursor clipper on window move events ....
// logging Tflags DWORD:
#define OUTTRACE 0x00000001 // enables tracing to dxwnd.log in general
@@ -354,6 +357,7 @@ void OutTraceHex(BYTE *, int);
void *HookAPI(HMODULE, char *, void *, const char *, void *);
void AdjustWindowFrame(HWND, DWORD, DWORD);
char *hexdump(unsigned char *, int);
+void HexTrace(unsigned char *, int);
LRESULT CALLBACK extWindowProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK extChildWindowProc(HWND, UINT, WPARAM, LPARAM);
diff --git a/build/dxwnd.dll b/build/dxwnd.dll
index a6d21ec..a4b7974 100644
--- a/build/dxwnd.dll
+++ b/build/dxwnd.dll
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:c17fbc2f441f7355d88a7b189dfbba0ab31f0295b6900c1343849006fcce9f68
-size 706560
+oid sha256:bb1649c75e814ca6706d0e6951fb34ade18b013d75a1c8d2afce83c6c8143042
+size 709632
diff --git a/build/dxwnd.exe b/build/dxwnd.exe
index 6e6fa7e..a06d146 100644
--- a/build/dxwnd.exe
+++ b/build/dxwnd.exe
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:4c369251987e49585a3cb5776a808fafe262ccf2d6b0ef0265275ba2080189ac
-size 667136
+oid sha256:ef6bb4b84f380a5e3e519d08ce9fca17bb67783b32655728f48197f403477976
+size 668160
diff --git a/build/readme-relnotes.txt b/build/readme-relnotes.txt
index 0a79872..8c5109f 100644
--- a/build/readme-relnotes.txt
+++ b/build/readme-relnotes.txt
@@ -1371,3 +1371,11 @@ fix: fixed CreateDialogIndirectParam and CreateDialogParam wrappers to make inne
fix: recovered DEFAULTMESSAGES option
fix: normalized output for ddraw GetScanLine() method
fix: fixed the policy for redrecting the WindowProc routine. Fixes "Ultimate Spiderman" clipping problems, and possibly much more
+
+v2.03.99
+fix: unwanted hook to directsound when passing by CoCreateInstance()
+fix: transient mode, now checks for both the target and the launcher to be dead before terminating
+add: Direct3D TRIMTEXTUREFORMAT flag, to mimic MS "DirectXTrimTextureFormat" shim. Fixes problems in "Heavy Gear 2" and "Star Wars: Rogue Squardon 3D".
+add: D3DDevice GetCaps hooking and full dump of D3DDevice capabilities
+add: "No HAL Device" flag, making it unavailable the IID_Direct3DHALDevice device. Fixes "Grand Prix World" when the 3D car models are invisible.
+add: reorganization of mouse clipper fields, with the addition of LOCK mode (useful for Tribal Rage)
diff --git a/dll/ddraw.cpp b/dll/ddraw.cpp
index 0e02daf..7b3749f 100644
--- a/dll/ddraw.cpp
+++ b/dll/ddraw.cpp
@@ -1555,6 +1555,7 @@ static void HandleCapsD(char *sLabel, LPDDCAPS c)
sLabel, c->dwVidMemTotal, c->dwVidMemFree, c->dwZBufferBitDepths, ExplainZBufferBitDepths(c->dwZBufferBitDepths));
OutTraceDDRAW("GetCaps(%s): MaxVisibleOverlays=%x CurrVisibleOverlays=%x\n",
sLabel, c->dwMaxVisibleOverlays, c->dwCurrVisibleOverlays);
+ if(IsDebug) HexTrace((unsigned char *)c, c->dwSize);
if(dxw.bHintActive){
if(c->dwVidMemTotal > dwMaxMem) ShowHint(HINT_LIMITMEM);
@@ -1591,13 +1592,14 @@ static HRESULT WINAPI extGetCapsD(int dxversion, GetCapsD_Type pGetCapsD, LPDIRE
HRESULT res;
OutTraceDDRAW("GetCaps(D%d): lpdd=%x %s %s\n", dxversion, lpdd, c1?"c1":"NULL", c2?"c2":"NULL");
res=(*pGetCapsD)(lpdd, c1, c2);
- if(res)
+ if(res) {
OutTraceE("GetCaps(D): ERROR res=%x(%s)\n", res, ExplainDDError(res));
- else {
- if (c1) HandleCapsD("D-HW", c1);
- if (c2) HandleCapsD("D-SW", c2);
+ return res;
}
+ if (c1) HandleCapsD("D-HW", c1);
+ if (c2) HandleCapsD("D-SW", c2);
+
if((dxw.dwFlags3 & FORCESHEL) && c1) {
DDCAPS_DX7 swcaps; // DDCAPS_DX7 because it is the bigger in size
int size;
@@ -1619,6 +1621,20 @@ static HRESULT WINAPI extGetCapsD(int dxversion, GetCapsD_Type pGetCapsD, LPDIRE
if (c2) HandleCapsD("D-SW(fixed)", c2);
}
+ if((dxw.dwFlags8 & NOHALDEVICE) && c1) {
+ OutTraceDW("GetCaps(D): NOHALDEVICE\n");
+ c1->ddsCaps.dwCaps = DDCAPS_NOHARDWARE;
+ c1->ddsCaps.dwCaps2 = DDCAPS2_CANRENDERWINDOWED;
+ c1->dwPalCaps = 0;
+ c1->dwFXCaps = 0;
+ c1->dwFXAlphaCaps = 0;
+ c1->dwCKeyCaps = 0;
+ c1->dwVidMemTotal = c1->dwVidMemFree = 0;
+ c1->dwZBufferBitDepths = 0;
+ c1->dwMaxVisibleOverlays = c1->dwCurrVisibleOverlays = 0;
+ HandleCapsD("D-HW(NoHAL)", c1);
+ }
+
if((dxw.dwFlags3 & MINIMALCAPS)) SetMinimalCaps(c1, c2);
if(dxw.dwFlags3 & CAPMASK) MaskCapsD(c1, c2);
@@ -2602,6 +2618,13 @@ HRESULT WINAPI extGetAttachedSurface(int dxversion, GetAttachedSurface_Type pGet
return DDERR_NOTFOUND;
}
}
+
+ if((dxw.dwFlags8 & NOHALDEVICE) && (lpddsc->dwCaps & DDSCAPS_ZBUFFER)){
+ // tested with "Grand Prix World": if a ZBUFFER is returned, CreateDevice fails!
+ *lplpddas = NULL;
+ OutTraceDW("GetAttachedSurface(%d): NOHALDEVICE no attached ZBUFFER\n", dxversion);
+ return DDERR_NOTFOUND;
+ }
}
else {
// Virtual primary surfaces are created with no DDSCAPS_3DDEVICE caps, so don't look for it ....
@@ -4797,6 +4820,7 @@ static HRESULT WINAPI extGetCapsS(int dxInterface, GetCapsS_Type pGetCapsS, LPDI
caps->dwCaps |= (DDSCAPS_BACKBUFFER|DDSCAPS_VIDEOMEMORY|DDSCAPS_FLIP|DDSCAPS_LOCALVIDMEM); // you never know....
caps->dwCaps &= ~(DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN); // backbuffer surfaces can't be this way
if(caps->dwCaps & DDSCAPS_3DDEVICE) caps->dwCaps |= DDSCAPS_LOCALVIDMEM;
+ //if(caps->dwCaps & DDSCAPS_3DDEVICE) caps->dwCaps |= (DDSCAPS_LOCALVIDMEM | DDSCAPS_COMPLEX);
}
// v2.03.82: fixed logic for ZBUFFER capabilities: "The Creed" may have two, in SYSTEMMEMORY or in VIDEOMEMORY ...
diff --git a/dll/dsound.cpp b/dll/dsound.cpp
index 4d12981..250905c 100644
--- a/dll/dsound.cpp
+++ b/dll/dsound.cpp
@@ -73,6 +73,8 @@ void HookDirectSoundInit()
void HookDirectSoundObj(LPDIRECTSOUND *lpds)
{
+ // v2.03.99: check or DirectSound could be hooked through CoCreateInstance !!
+ if(!(dxw.dwFlags7 & HOOKDIRECTSOUND)) return;
// IDIrectSound::SetCooperativeLevel
SetHook((void *)(**(DWORD **)lpds + 12), extCreateSoundBuffer, (void **)&pCreateSoundBuffer, "CreateSoundBuffer");
SetHook((void *)(**(DWORD **)lpds + 24), extDSSetCooperativeLevel, (void **)&pDSSetCooperativeLevel, "SetCooperativeLevel(DSound)");
diff --git a/dll/dxhook.cpp b/dll/dxhook.cpp
index fcdbbe7..4343855 100644
--- a/dll/dxhook.cpp
+++ b/dll/dxhook.cpp
@@ -67,7 +67,7 @@ static char *FlagNames[32]={
"HOOKDI", "MODIFYMOUSE", "HANDLEEXCEPTIONS", "SAVELOAD",
"EMULATEBUFFER", "HOOKDI8", "BLITFROMBACKBUFFER", "SUPPRESSCLIPPING",
"AUTOREFRESH", "FIXWINFRAME", "HIDEHWCURSOR", "SLOWDOWN",
- "ENABLECLIPPING", "LOCKWINSTYLE", "MAPGDITOPRIMARY", "FIXTEXTOUT",
+ "DISABLECLIPPING", "LOCKWINSTYLE", "MAPGDITOPRIMARY", "FIXTEXTOUT",
"KEEPCURSORWITHIN", "USERGB565", "SUPPRESSDXERRORS", "PREVENTMAXIMIZE",
"LOCKEDSURFACE", "FIXPARENTWIN", "SWITCHVIDEOMEMORY", "CLIENTREMAPPING",
"HANDLEALTF4", "LOCKWINPOS", "HOOKCHILDWIN", "MESSAGEPROC"
@@ -141,7 +141,7 @@ static char *Flag7Names[32]={
static char *Flag8Names[32]={
"FORCEWAIT", "FORCENOWAIT", "FORCEVSYNC", "FORCENOVSYNC",
- "VSYNCSCANLINES", "", "", "",
+ "VSYNCSCANLINES", "TRIMTEXTUREFORMATS", "NOHALDEVICE", "CLIPLOCK",
"", "", "", "",
"", "", "", "",
"", "", "", "",
@@ -277,6 +277,23 @@ void OutTrace(const char *format, ...)
dxw.dwTFlags = tFlags; // restore settings
}
+void HexTrace(unsigned char *buf, int len)
+{
+ char line[3*32 + 40];
+ char hex[6];
+ int count=0;
+ while(len){
+ sprintf(line,"%04X: ", count);
+ for(int i=32; i && len; i--, len--, buf++){
+ sprintf(hex, "%02X.", *buf);
+ strcat(line, hex);
+ }
+ strcat(line, "\n");
+ OutTrace(line);
+ count += 32;
+ }
+}
+
// from MSDN:
// GetVersionEx may be altered or unavailable for releases after Windows 8.1. Instead, use the Version Helper functions
//
diff --git a/dll/dxwcore.cpp b/dll/dxwcore.cpp
index ba33cf4..24f3577 100644
--- a/dll/dxwcore.cpp
+++ b/dll/dxwcore.cpp
@@ -363,7 +363,7 @@ POINT dxwCore::FixCursorPos(POINT prev)
if (h) curr.y = (curr.y * dxw.GetScreenHeight()) / h;
}
- if((dxw.dwFlags1 & ENABLECLIPPING) && lpClipRegion){
+ if((dxw.dwFlags1 & DISABLECLIPPING) && lpClipRegion){
// v2.1.93:
// in clipping mode, avoid the cursor position to lay outside the valid rect
// note 1: the rect follow the convention and valid coord lay between left to righ-1,
diff --git a/dll/dxwnd.cpp b/dll/dxwnd.cpp
index 0a14a98..c04fd2d 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.98.fx1"
+#define VERSION "2.03.99"
#define DDTHREADLOCK 1
//#define LOCKTHREADS
diff --git a/dll/dxwnd.vs2008.suo b/dll/dxwnd.vs2008.suo
index 885bb2a..836f07c 100644
Binary files a/dll/dxwnd.vs2008.suo and b/dll/dxwnd.vs2008.suo differ
diff --git a/dll/hd3d7.cpp b/dll/hd3d7.cpp
index e305f38..63ddece 100644
--- a/dll/hd3d7.cpp
+++ b/dll/hd3d7.cpp
@@ -45,6 +45,7 @@ typedef HRESULT (WINAPI *CreateDevice2_Type)(void *, REFCLSID, LPDIRECTDRAWSURFA
typedef HRESULT (WINAPI *CreateDevice3_Type)(void *, REFCLSID, LPDIRECTDRAWSURFACE4, LPDIRECT3DDEVICE3 *, LPUNKNOWN);
typedef HRESULT (WINAPI *CreateDevice7_Type)(void *, REFCLSID, LPDIRECTDRAWSURFACE7, LPDIRECT3DDEVICE7 *);
typedef HRESULT (WINAPI *EnumZBufferFormats_Type)(void *, REFCLSID, LPD3DENUMPIXELFORMATSCALLBACK, LPVOID);
+typedef HRESULT (WINAPI *EnumTextureFormats_Type)(void *, LPD3DENUMPIXELFORMATSCALLBACK, LPVOID);
QueryInterfaceD3_Type pQueryInterfaceD31 = NULL;
QueryInterfaceD3_Type pQueryInterfaceD32 = NULL;
@@ -73,6 +74,8 @@ CreateDevice7_Type pCreateDevice7 = NULL;
EnumZBufferFormats_Type pEnumZBufferFormats3 = NULL;
EnumZBufferFormats_Type pEnumZBufferFormats7 = NULL;
+EnumTextureFormats_Type pEnumTextureFormats1, pEnumTextureFormats2, pEnumTextureFormats3, pEnumTextureFormats7;
+
HRESULT WINAPI extQueryInterfaceD31(void *, REFIID, LPVOID *);
HRESULT WINAPI extQueryInterfaceD32(void *, REFIID, LPVOID *);
HRESULT WINAPI extQueryInterfaceD33(void *, REFIID, LPVOID *);
@@ -88,13 +91,18 @@ HRESULT WINAPI extCreateLight3(void *, LPDIRECT3DLIGHT *, IUnknown *);
HRESULT WINAPI extEnumZBufferFormats3(void *, REFCLSID, LPD3DENUMPIXELFORMATSCALLBACK, LPVOID);
HRESULT WINAPI extEnumZBufferFormats7(void *, REFCLSID, LPD3DENUMPIXELFORMATSCALLBACK, LPVOID);
+HRESULT WINAPI extEnumTextureFormats1(void *, LPD3DENUMPIXELFORMATSCALLBACK, LPVOID);
+HRESULT WINAPI extEnumTextureFormats2(void *, LPD3DENUMPIXELFORMATSCALLBACK, LPVOID);
+HRESULT WINAPI extEnumTextureFormats3(void *, LPD3DENUMPIXELFORMATSCALLBACK, LPVOID);
+HRESULT WINAPI extEnumTextureFormats7(void *, LPD3DENUMPIXELFORMATSCALLBACK, LPVOID);
+
// Direct3DDevice-n interfaces
typedef ULONG (WINAPI *ReleaseD3D_Type)(LPDIRECT3DDEVICE);
typedef HRESULT (WINAPI *QueryInterfaceD3D_Type)(void *, REFIID, LPVOID *);
typedef HRESULT (WINAPI *D3DInitialize_Type)(void *, LPDIRECT3D , LPGUID, LPD3DDEVICEDESC);
typedef HRESULT (WINAPI *D3DGetCaps_Type)(void *, LPD3DDEVICEDESC ,LPD3DDEVICEDESC);
-typedef HRESULT (WINAPI *D3DGetCaps3_Type)(void *, LPD3DDEVICEDESC, LPD3DDEVICEDESC);
+typedef HRESULT (WINAPI *D3DGetCaps7_Type)(void *, LPD3DDEVICEDESC7);
typedef HRESULT (WINAPI *AddViewport1_Type)(void *, LPDIRECT3DVIEWPORT);
typedef HRESULT (WINAPI *AddViewport2_Type)(void *, LPDIRECT3DVIEWPORT2);
typedef HRESULT (WINAPI *AddViewport3_Type)(void *, LPDIRECT3DVIEWPORT3);
@@ -115,8 +123,8 @@ typedef HRESULT (WINAPI *SwapTextureHandles2_Type)(void *, LPDIRECT3DTEXTURE2, L
QueryInterfaceD3_Type pQueryInterfaceD3D = NULL;
ReleaseD3D_Type pReleaseD3D1, pReleaseD3D2, pReleaseD3D3, pReleaseD3D7;
D3DInitialize_Type pD3DInitialize = NULL;
-D3DGetCaps_Type pD3DGetCaps = NULL;
-D3DGetCaps3_Type pGetCaps3 = NULL;
+D3DGetCaps_Type pD3DGetCaps1, pD3DGetCaps2, pD3DGetCaps3;
+D3DGetCaps7_Type pD3DGetCaps7;
AddViewport1_Type pAddViewport1 = NULL;
AddViewport2_Type pAddViewport2 = NULL;
AddViewport3_Type pAddViewport3 = NULL;
@@ -225,7 +233,6 @@ HRESULT WINAPI extQueryInterfaceD3(void *, REFIID, LPVOID *);
HRESULT WINAPI extQueryInterfaceD3D(void *, REFIID, LPVOID *);
HRESULT WINAPI extD3DInitialize(void *, LPDIRECT3D , LPGUID, LPD3DDEVICEDESC);
-HRESULT WINAPI extD3DGetCaps(void *, LPD3DDEVICEDESC ,LPD3DDEVICEDESC);
ULONG WINAPI extReleaseD3D1(LPDIRECT3DDEVICE);
ULONG WINAPI extReleaseD3D2(LPDIRECT3DDEVICE);
@@ -242,7 +249,10 @@ HRESULT WINAPI extEndScene7(void *);
HRESULT WINAPI extSetRenderState2(void *, D3DRENDERSTATETYPE, DWORD);
HRESULT WINAPI extSetRenderState3(void *, D3DRENDERSTATETYPE, DWORD);
HRESULT WINAPI extSetRenderState7(void *, D3DRENDERSTATETYPE, DWORD);
-HRESULT WINAPI extGetCaps3(void *, LPD3DDEVICEDESC, LPD3DDEVICEDESC);
+HRESULT WINAPI extD3DGetCaps1(void *, LPD3DDEVICEDESC, LPD3DDEVICEDESC);
+HRESULT WINAPI extD3DGetCaps2(void *, LPD3DDEVICEDESC, LPD3DDEVICEDESC);
+HRESULT WINAPI extD3DGetCaps3(void *, LPD3DDEVICEDESC, LPD3DDEVICEDESC);
+HRESULT WINAPI extD3DGetCaps7(void *, LPD3DDEVICEDESC7);
HRESULT WINAPI extSetLightState3(void *d3dd, D3DLIGHTSTATETYPE d3dls, DWORD t);
HRESULT WINAPI extSetViewport3(void *, LPD3DVIEWPORT);
HRESULT WINAPI extGetViewport3(void *, LPD3DVIEWPORT);
@@ -494,24 +504,26 @@ void HookDirect3DDevice(void **lpd3ddev, int d3dversion)
case 1:
SetHook((void *)(**(DWORD **)lpd3ddev + 0), extQueryInterfaceD3D, (void **)&pQueryInterfaceD3D, "QueryInterface(D3D)");
SetHook((void *)(**(DWORD **)lpd3ddev + 8), extReleaseD3D1, (void **)&pReleaseD3D1, "ReleaseD3D(1)");
- //SetHook((void *)(**(DWORD **)lpd3ddev + 16), extGetCaps1, (void **)&pGetCaps1, "GetCaps(1)");
+ SetHook((void *)(**(DWORD **)lpd3ddev + 16), extD3DGetCaps1, (void **)&pD3DGetCaps1, "GetCaps(1)");
SetHook((void *)(**(DWORD **)lpd3ddev + 20), extSwapTextureHandles, (void **)&pSwapTextureHandles, "SwapTextureHandles(1)");
SetHook((void *)(**(DWORD **)lpd3ddev + 32), extExecute, (void **)&pExecute, "Execute(1)");
//SetHook((void *)(**(DWORD **)lpd3ddev + 32), extExecute, NULL, "Execute(1)");
SetHook((void *)(**(DWORD **)lpd3ddev + 36), extAddViewport1, (void **)&pAddViewport1, "AddViewport(1)");
SetHook((void *)(**(DWORD **)lpd3ddev + 40), extDeleteViewport1, (void **)&pDeleteViewport1, "DeleteViewport(1)");
SetHook((void *)(**(DWORD **)lpd3ddev + 44), extNextViewport1, (void **)&pNextViewport1, "NextViewport(1)");
+ SetHook((void *)(**(DWORD **)lpd3ddev + 56), extEnumTextureFormats1, (void **)&pEnumTextureFormats1, "EnumTextureFormats(1)");
SetHook((void *)(**(DWORD **)lpd3ddev + 76), extBeginScene1, (void **)&pBeginScene1, "BeginScene(1)");
SetHook((void *)(**(DWORD **)lpd3ddev + 80), extEndScene1, (void **)&pEndScene1, "EndScene(1)");
break;
case 2:
SetHook((void *)(**(DWORD **)lpd3ddev + 0), extQueryInterfaceD3D, (void **)&pQueryInterfaceD3D, "QueryInterface(D3D)");
SetHook((void *)(**(DWORD **)lpd3ddev + 8), extReleaseD3D2, (void **)&pReleaseD3D2, "ReleaseD3D(2)");
- //SetHook((void *)(**(DWORD **)lpd3ddev + 12), extGetCaps2, (void **)&pGetCaps2, "GetCaps(2)");
- SetHook((void *)(**(DWORD **)lpd3ddev + 16), extSwapTextureHandles, (void **)&pSwapTextureHandles, "SwapTextureHandles(1)");
+ SetHook((void *)(**(DWORD **)lpd3ddev + 12), extD3DGetCaps2, (void **)&pD3DGetCaps2, "GetCaps(2)");
+ SetHook((void *)(**(DWORD **)lpd3ddev + 16), extSwapTextureHandles, (void **)&pSwapTextureHandles, "SwapTextureHandles(2)");
SetHook((void *)(**(DWORD **)lpd3ddev + 24), extAddViewport2, (void **)&pAddViewport2, "AddViewport(2)");
SetHook((void *)(**(DWORD **)lpd3ddev + 28), extDeleteViewport2, (void **)&pDeleteViewport2, "DeleteViewport(2)");
SetHook((void *)(**(DWORD **)lpd3ddev + 32), extNextViewport2, (void **)&pNextViewport2, "NextViewport(2)");
+ SetHook((void *)(**(DWORD **)lpd3ddev + 36), extEnumTextureFormats2, (void **)&pEnumTextureFormats2, "EnumTextureFormats(2)");
SetHook((void *)(**(DWORD **)lpd3ddev + 40), extBeginScene2, (void **)&pBeginScene2, "BeginScene(2)");
SetHook((void *)(**(DWORD **)lpd3ddev + 44), extEndScene2, (void **)&pEndScene2, "EndScene(2)");
SetHook((void *)(**(DWORD **)lpd3ddev + 52), extSetCurrentViewport2, (void **)&pSetCurrentViewport2, "SetCurrentViewport(2)");
@@ -526,8 +538,9 @@ void HookDirect3DDevice(void **lpd3ddev, int d3dversion)
case 3:
SetHook((void *)(**(DWORD **)lpd3ddev + 0), extQueryInterfaceD3D, (void **)&pQueryInterfaceD3D, "QueryInterface(D3D)");
SetHook((void *)(**(DWORD **)lpd3ddev + 8), extReleaseD3D3, (void **)&pReleaseD3D3, "ReleaseD3D(3)");
- SetHook((void *)(**(DWORD **)lpd3ddev + 12), extGetCaps3, (void **)&pGetCaps3, "GetCaps(3)");
+ SetHook((void *)(**(DWORD **)lpd3ddev + 12), extD3DGetCaps3, (void **)&pD3DGetCaps3, "GetCaps(3)");
SetHook((void *)(**(DWORD **)lpd3ddev + 20), extAddViewport3, (void **)&pAddViewport3, "AddViewport(3)");
+ SetHook((void *)(**(DWORD **)lpd3ddev + 32), extEnumTextureFormats3, (void **)&pEnumTextureFormats3, "EnumTextureFormats(3)");
SetHook((void *)(**(DWORD **)lpd3ddev + 36), extBeginScene3, (void **)&pBeginScene3, "BeginScene(3)");
SetHook((void *)(**(DWORD **)lpd3ddev + 40), extEndScene3, (void **)&pEndScene3, "EndScene(3)");
SetHook((void *)(**(DWORD **)lpd3ddev + 48), extSetCurrentViewport3, (void **)&pSetCurrentViewport3, "SetCurrentViewport(3)");
@@ -544,6 +557,8 @@ void HookDirect3DDevice(void **lpd3ddev, int d3dversion)
case 7:
//SetHook((void *)(**(DWORD **)lpd3ddev + 0), extQueryInterfaceD3D, (void **)&pQueryInterfaceD3D, "QueryInterface(D3D)");
SetHook((void *)(**(DWORD **)lpd3ddev + 8), extReleaseD3D7, (void **)&pReleaseD3D7, "ReleaseD3D(7)");
+ SetHook((void *)(**(DWORD **)lpd3ddev + 12), extD3DGetCaps7, (void **)&pD3DGetCaps7, "GetCaps(7)");
+ SetHook((void *)(**(DWORD **)lpd3ddev + 16), extEnumTextureFormats7, (void **)&pEnumTextureFormats7, "EnumTextureFormats(7)");
SetHook((void *)(**(DWORD **)lpd3ddev + 20), extBeginScene7, (void **)&pBeginScene7, "BeginScene(7)");
SetHook((void *)(**(DWORD **)lpd3ddev + 24), extEndScene7, (void **)&pEndScene7, "EndScene(7)");
//SetHook((void *)(**(DWORD **)lpd3ddev + 52), extSetViewport7, (void **)&pSetViewport7, "SetViewport(7)");
@@ -785,7 +800,7 @@ typedef struct {
LPVOID arg;
} CallbackArg7;
-static void DumpD3DDevideDesc(LPD3DDEVICEDESC d3, char *label)
+static void DumpD3DDeviceDesc(LPD3DDEVICEDESC d3, char *label)
{
if(IsTraceD3D){
if(d3){
@@ -802,7 +817,34 @@ static void DumpD3DDevideDesc(LPD3DDEVICEDESC d3, char *label)
if(d3->dwFlags & D3DDD_MAXBUFFERSIZE) OutTrace("MaxBufferSize=%d ", d3->dwMaxBufferSize);
if(d3->dwFlags & D3DDD_MAXVERTEXCOUNT) OutTrace("MaxVertexCount=%d ", d3->dwMaxVertexCount);
OutTrace("Texture min=(%dx%d) max=(%dx%d)\n", d3->dwMinTextureWidth, d3->dwMinTextureHeight, d3->dwMaxTextureWidth, d3->dwMaxTextureHeight);
+ HexTrace((unsigned char *)d3, d3->dwSize);
+ }
+ else
+ OutTrace("EnumDevices: CALLBACK dev=%s ddesc=NULL\n", label);
+ }
+}
+
+static void DumpD3DPrimCaps(char *label, D3DPRIMCAPS *pc)
+{
+ OutTrace("%s={siz=%d Misc=%x Raster=%x ZCmp=%x SrcBlend=%x DestBlend=%x AlphaCmp=%x Shade=%x Tex=%x TexFil=%x TexBlend=%x TexAddr=%x Stipple=(%dx%d)} ",
+ label,
+ pc->dwSize, pc->dwMiscCaps, pc->dwRasterCaps, pc->dwZCmpCaps, pc->dwSrcBlendCaps, pc->dwDestBlendCaps, pc->dwAlphaCmpCaps,
+ pc->dwShadeCaps, pc->dwTextureCaps, pc->dwTextureFilterCaps, pc->dwTextureBlendCaps, pc->dwTextureAddressCaps,
+ pc->dwStippleWidth, pc->dwStippleHeight);
+}
+
+static void DumpD3DDeviceDesc7(LPD3DDEVICEDESC7 d3, char *label)
+{
+ if(IsTraceD3D){
+ if(d3){
+ OutTrace("EnumDevices: CALLBACK dev=%s DevCaps=%x ", label, d3->dwDevCaps);
+ DumpD3DPrimCaps("LineCaps", &d3->dpcLineCaps);
+ DumpD3DPrimCaps("TriCaps", &d3->dpcLineCaps);
+ OutTrace("RenderBitDepth=%d ZBufferBitDepth", d3->dwDeviceRenderBitDepth, d3->dwDeviceZBufferBitDepth);
+ OutTrace("Texture min=(%dx%d) max=(%dx%d)\n", d3->dwMinTextureWidth, d3->dwMinTextureHeight, d3->dwMaxTextureWidth, d3->dwMaxTextureHeight);
+ // to be completed ....
//OutTrace("\n");
+ HexTrace((unsigned char *)d3, sizeof(D3DDEVICEDESC7));
}
else
OutTrace("EnumDevices: CALLBACK dev=%s ddesc=NULL\n", label);
@@ -813,8 +855,16 @@ HRESULT WINAPI extDeviceProxy(GUID FAR *lpGuid, LPSTR lpDeviceDescription, LPSTR
{
HRESULT res;
OutTraceD3D("EnumDevices: CALLBACK GUID=%x(%s) DeviceDescription=\"%s\", DeviceName=\"%s\", arg=%x\n", lpGuid->Data1, ExplainGUID(lpGuid), lpDeviceDescription, lpDeviceName, ((CallbackArg *)arg)->arg);
- DumpD3DDevideDesc(lpd3ddd1, "HWDEV");
- DumpD3DDevideDesc(lpd3ddd2, "SWDEV");
+ DumpD3DDeviceDesc(lpd3ddd1, "HWDEV");
+ DumpD3DDeviceDesc(lpd3ddd2, "SWDEV");
+
+ // IID_IDirect3DHALDevice = 0x84e63de0....
+ if((dxw.dwFlags8 & NOHALDEVICE) && (lpGuid->Data1 == 0x84e63de0))
+ {
+ OutTraceDW("EnumDevices: D3DHALDEVICE SKIP\n");
+ return TRUE;
+ }
+
if(dxw.dwFlags4 & NOPOWER2FIX){
D3DDEVICEDESC lpd3ddd1fix, lpd3ddd2fix;
if(lpd3ddd1) memcpy(&lpd3ddd1fix, lpd3ddd1, sizeof(D3DDEVICEDESC));
@@ -836,7 +886,10 @@ HRESULT WINAPI extDeviceProxy7(LPSTR lpDeviceDescription, LPSTR lpDeviceName, LP
{
HRESULT res;
OutTraceD3D("EnumDevices(D3D7): CALLBACK DeviceDescription=\"%s\", DeviceName=\"%s\", arg=%x\n", lpDeviceDescription, lpDeviceName, ((CallbackArg *)arg)->arg);
- DumpD3DDevideDesc((LPD3DDEVICEDESC)lpd3ddd, "DEV");
+ DumpD3DDeviceDesc((LPD3DDEVICEDESC)lpd3ddd, "DEV");
+
+ // to do: NOHALDEVICE handling, we have no GUID here!
+
if(dxw.dwFlags4 & NOPOWER2FIX){
D3DDEVICEDESC7 lpd3dddfix;
if(lpd3ddd) memcpy(&lpd3dddfix, lpd3ddd, sizeof(D3DDEVICEDESC7));
@@ -1000,8 +1053,8 @@ static HRESULT WINAPI extFindDevice(int d3dversion, FindDevice_Type pFindDevice,
if(res) OutTraceE("FindDevice ERROR: err=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
else {
OutTraceD3D("FindDevice: GUID=%x.%x.%x.%x\n", p2->guid.Data1, p2->guid.Data2, p2->guid.Data3, p2->guid.Data4);
- DumpD3DDevideDesc(&(p2->ddHwDesc), "HWDEV");
- DumpD3DDevideDesc(&(p2->ddSwDesc), "SWDEV");
+ DumpD3DDeviceDesc(&(p2->ddHwDesc), "HWDEV");
+ DumpD3DDeviceDesc(&(p2->ddSwDesc), "SWDEV");
}
return res;
}
@@ -1071,6 +1124,12 @@ HRESULT WINAPI extInitializeVP(void *lpvp, LPDIRECT3D lpd3d)
return res;
}
+#ifndef D3DERR_NOTAVAILABLE
+#define _FACD3D 0x876
+#define D3DERR_NOTAVAILABLE MAKE_HRESULT(1, _FACD3D, 2154)
+#endif
+
+
HRESULT WINAPI extCreateDevice2(void *lpd3d, REFCLSID Guid, LPDIRECTDRAWSURFACE lpdds, LPDIRECT3DDEVICE2 *lplpd3dd)
{
HRESULT res;
@@ -1078,6 +1137,11 @@ HRESULT WINAPI extCreateDevice2(void *lpd3d, REFCLSID Guid, LPDIRECTDRAWSURFACE
OutTraceD3D("CreateDevice(D3D2): d3d=%x GUID=%x(%s) lpdds=%x%s\n",
lpd3d, Guid.Data1, ExplainGUID((GUID *)&Guid), lpdds, dxwss.ExplainSurfaceRole((LPDIRECTDRAWSURFACE)lpdds));
+ if((dxw.dwFlags8 & NOHALDEVICE) && (Guid.Data1 == 0x84e63de0)) {
+ OutTraceDW("CreateDevice(D3D2): D3DHALDEVICE SKIP\n");
+ return D3DERR_NOTAVAILABLE;
+ }
+
res=(*pCreateDevice2)(lpd3d, Guid, lpdds, lplpd3dd);
if(res!=DD_OK) {
OutTraceE("CreateDevice(D3D2) ERROR: err=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
@@ -1097,6 +1161,11 @@ HRESULT WINAPI extCreateDevice3(void *lpd3d, REFCLSID Guid, LPDIRECTDRAWSURFACE4
OutTraceD3D("CreateDevice(D3D3): d3d=%x GUID=%x(%s) lpdds=%x%s\n",
lpd3d, Guid.Data1, ExplainGUID((GUID *)&Guid), lpdds, dxwss.ExplainSurfaceRole((LPDIRECTDRAWSURFACE)lpdds));
+ if((dxw.dwFlags8 & NOHALDEVICE) && (Guid.Data1 == 0x84e63de0)) {
+ OutTraceDW("CreateDevice(D3D3): D3DHALDEVICE SKIP\n");
+ return D3DERR_NOTAVAILABLE;
+ }
+
res=(*pCreateDevice3)(lpd3d, Guid, lpdds, lplpd3dd, unk);
if(res!=DD_OK) {
OutTraceE("CreateDevice(D3D3) ERROR: err=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
@@ -1137,18 +1206,7 @@ HRESULT WINAPI extD3DInitialize(void *d3dd, LPDIRECT3D lpd3d, LPGUID lpGuid, LPD
OutTraceD3D("Initialize: d3dd=%x lpd3d=%x GUID=%x lpd3ddd=%x\n", d3dd, lpd3d, lpGuid->Data1, lpd3dd);
res=(*pD3DInitialize)(d3dd, lpd3d, lpGuid, lpd3dd);
if(res) OutTraceE("Initialize ERROR: err=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
- DumpD3DDevideDesc(lpd3dd, "INIT");
- return res;
-}
-
-HRESULT WINAPI extD3DGetCaps(void *d3dd, LPD3DDEVICEDESC lpd3dd ,LPD3DDEVICEDESC lpd3dd2)
-{
- HRESULT res;
- OutTraceD3D("GetCaps(D3D): d3dd=%x lpd3dd=%x lpd3dd2=%x \n", d3dd, lpd3dd, lpd3dd2);
- res=(*pD3DGetCaps)(d3dd, lpd3dd, lpd3dd2);
- if(res) OutTraceE("GetCaps(D3D) ERROR: err=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
- DumpD3DDevideDesc(lpd3dd, "HWDEV");
- DumpD3DDevideDesc(lpd3dd2, "SWDEV");
+ DumpD3DDeviceDesc(lpd3dd, "INIT");
return res;
}
@@ -1368,21 +1426,27 @@ HRESULT WINAPI extEndScene7(void *d3dd)
return res;
}
-HRESULT WINAPI extGetCaps3(void *d3dd, LPD3DDEVICEDESC hd, LPD3DDEVICEDESC sd)
+HRESULT WINAPI extD3DGetCaps(int d3dversion, D3DGetCaps_Type pD3DGetCaps, void *d3dd, LPD3DDEVICEDESC hd, LPD3DDEVICEDESC sd)
{
HRESULT res;
- OutTraceD3D("GetCaps(3): d3dd=%x hd=%x sd=%x\n", d3dd, hd, sd);
- res=(*pGetCaps3)(d3dd, hd, sd);
+ OutTraceD3D("GetCaps(D3D%d): d3dd=%x hd=%x sd=%x\n", d3dversion, d3dd, hd, sd);
+ res=(*pD3DGetCaps)(d3dd, hd, sd);
if(res) {
- OutTraceE("GetCaps(3): res=%x(%s)\n", res, ExplainDDError(res));
+ OutTraceE("GetCaps(D3D): ERROR res=%x(%s)\n", res, ExplainDDError(res));
return res;
}
+
+ DumpD3DDeviceDesc(hd, "HWDEV");
+ DumpD3DDeviceDesc(sd, "SWDEV");
+
if(dxw.dwFlags4 & NOPOWER2FIX){
if(hd) {
+ OutTraceDW("GetCaps(D3D): Fixing NOPOWER2FIX hw caps\n");
hd->dpcLineCaps.dwTextureCaps|=D3DPTEXTURECAPS_NONPOW2CONDITIONAL|D3DPTEXTURECAPS_POW2;
hd->dpcTriCaps.dwTextureCaps|=D3DPTEXTURECAPS_NONPOW2CONDITIONAL|D3DPTEXTURECAPS_POW2;
}
if(sd) {
+ OutTraceDW("GetCaps(D3D): Fixing NOPOWER2FIX sw caps\n");
sd->dpcLineCaps.dwTextureCaps|=D3DPTEXTURECAPS_NONPOW2CONDITIONAL|D3DPTEXTURECAPS_POW2;
sd->dpcTriCaps.dwTextureCaps|=D3DPTEXTURECAPS_NONPOW2CONDITIONAL|D3DPTEXTURECAPS_POW2;
}
@@ -1390,6 +1454,35 @@ HRESULT WINAPI extGetCaps3(void *d3dd, LPD3DDEVICEDESC hd, LPD3DDEVICEDESC sd)
return res;
}
+HRESULT WINAPI extD3DGetCaps1(void *d3dd, LPD3DDEVICEDESC hd, LPD3DDEVICEDESC sd)
+{ return extD3DGetCaps(1, pD3DGetCaps1, d3dd, hd, sd); }
+HRESULT WINAPI extD3DGetCaps2(void *d3dd, LPD3DDEVICEDESC hd, LPD3DDEVICEDESC sd)
+{ return extD3DGetCaps(2, pD3DGetCaps2, d3dd, hd, sd); }
+HRESULT WINAPI extD3DGetCaps3(void *d3dd, LPD3DDEVICEDESC hd, LPD3DDEVICEDESC sd)
+{ return extD3DGetCaps(3, pD3DGetCaps3, d3dd, hd, sd); }
+
+HRESULT WINAPI extD3DGetCaps7(void *d3dd, LPD3DDEVICEDESC7 lpd3ddd)
+{
+ HRESULT res;
+ OutTraceD3D("GetCaps(D3D7): d3dd=%x lpd3ddd=%x\n", d3dd, lpd3ddd);
+ res=(*pD3DGetCaps7)(d3dd, lpd3ddd);
+ if(res) {
+ OutTraceE("GetCaps(D3D): ERROR res=%x(%s)\n", res, ExplainDDError(res));
+ return res;
+ }
+
+ DumpD3DDeviceDesc7(lpd3ddd, "DEV7");
+
+ if(dxw.dwFlags4 & NOPOWER2FIX){
+ if(lpd3ddd) {
+ OutTraceDW("GetCaps(D3D): Fixing NOPOWER2FIX hw caps\n");
+ lpd3ddd->dpcLineCaps.dwTextureCaps|=D3DPTEXTURECAPS_NONPOW2CONDITIONAL|D3DPTEXTURECAPS_POW2;
+ lpd3ddd->dpcTriCaps.dwTextureCaps|=D3DPTEXTURECAPS_NONPOW2CONDITIONAL|D3DPTEXTURECAPS_POW2;
+ }
+ }
+ return res;
+}
+
HRESULT WINAPI extSetLightState3(void *d3dd, D3DLIGHTSTATETYPE d3dls, DWORD t)
{
HRESULT res;
@@ -1787,33 +1880,90 @@ HRESULT WINAPI extTexUnload(void *t)
typedef struct {
LPD3DENUMPIXELFORMATSCALLBACK *cb;
LPVOID arg;
-} CallbackZBufArg;
+} CallbackPixFmtArg;
HRESULT WINAPI extZBufferProxy(LPDDPIXELFORMAT lpDDPixFmt, LPVOID lpContext)
{
HRESULT res;
- OutTraceD3D("EnumZBufferFormats: CALLBACK context=%x %s \n", ((CallbackZBufArg *)lpContext)->arg, ExplainPixelFormat(lpDDPixFmt));
- res = (*(((CallbackZBufArg *)lpContext)->cb))(lpDDPixFmt, ((CallbackZBufArg *)lpContext)->arg);
+ OutTraceD3D("EnumZBufferFormats: CALLBACK context=%x %s \n", ((CallbackPixFmtArg *)lpContext)->arg, ExplainPixelFormat(lpDDPixFmt));
+ res = (*(((CallbackPixFmtArg *)lpContext)->cb))(lpDDPixFmt, ((CallbackPixFmtArg *)lpContext)->arg);
OutTraceD3D("EnumZBufferFormats: CALLBACK ret=%x\n", res);
return res;
}
-static HRESULT WINAPI extEnumZBufferFormats(EnumZBufferFormats_Type pEnumZBufferFormats, void *lpd3d, REFCLSID riidDevice, LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback, LPVOID lpContext)
+#define MAXPFTABLESIZE 50
+#define MAXTRIMMEDENTRIES 3
+
+typedef struct {
+ int nEntries;
+// LPDDPIXELFORMAT lpPixelFormatEntries;
+ DDPIXELFORMAT lpPixelFormatEntries[MAXPFTABLESIZE];
+} PixelFormatTable_Type;
+
+HRESULT WINAPI FillPixelFormatTable(LPDDPIXELFORMAT lpDDPixFmt, LPVOID Arg)
+{
+ PixelFormatTable_Type *lpPixelFormatTable = (PixelFormatTable_Type *)Arg;
+ OutTraceD3D("EnumZBufferFormats: FILL CALLBACK entry=%d %s\n", lpPixelFormatTable->nEntries, ExplainPixelFormat(lpDDPixFmt));
+ if(lpPixelFormatTable->nEntries >= MAXPFTABLESIZE) return FALSE;
+ memcpy((LPVOID)&(lpPixelFormatTable->lpPixelFormatEntries[lpPixelFormatTable->nEntries]), (LPVOID)lpDDPixFmt, sizeof(DDPIXELFORMAT));
+ lpPixelFormatTable->nEntries ++;
+ //lpPixelFormatTable->lpPixelFormatEntries = (LPDDPIXELFORMAT)realloc((LPVOID)(lpPixelFormatTable->lpPixelFormatEntries), lpPixelFormatTable->nEntries * sizeof(DDPIXELFORMAT));
+ //OutTrace("lp=%x err=%s\n", lpPixelFormatTable->lpPixelFormatEntries, GetLastError());
+ return TRUE;
+}
+
+static HRESULT WINAPI extEnumZBufferFormats(int d3dversion, EnumZBufferFormats_Type pEnumZBufferFormats, void *lpd3d, REFCLSID riidDevice, LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback, LPVOID lpContext)
{
HRESULT ret;
- CallbackZBufArg Arg;
- OutTraceD3D("Direct3D::EnumZBufferFormats d3d=%x clsid=%x context=%x\n", lpd3d, riidDevice.Data1, lpContext);
- Arg.cb= &lpEnumCallback;
- Arg.arg=lpContext;
- ret = (*pEnumZBufferFormats)(lpd3d, riidDevice, (LPD3DENUMPIXELFORMATSCALLBACK)extZBufferProxy, (LPVOID)&Arg);
+ OutTraceD3D("Direct3D::EnumZBufferFormats(%d) d3d=%x clsid=%x context=%x\n", d3dversion, lpd3d, riidDevice.Data1, lpContext);
+
+ if(dxw.dwFlags8 & TRIMTEXTUREFORMATS){
+ int iIndex;
+ int iEnumerated;
+ PixelFormatTable_Type PixelFormatTable;
+ PixelFormatTable.nEntries = 0;
+ //PixelFormatTable.lpPixelFormatEntries = (LPDDPIXELFORMAT)malloc(sizeof(DDPIXELFORMAT));
+ ret = (*pEnumZBufferFormats)(lpd3d, riidDevice, (LPD3DENUMPIXELFORMATSCALLBACK)FillPixelFormatTable, (LPVOID)&PixelFormatTable);
+ OutTraceD3D("EnumZBufferFormats: collected entries=%d\n", PixelFormatTable.nEntries);
+ // bubble sorting;
+ while(TRUE){
+ BOOL bSorted = FALSE;
+ for(iIndex=0; iIndex PixelFormatTable.lpPixelFormatEntries[iIndex+1].dwRGBBitCount){
+ DDPIXELFORMAT tmp;
+ tmp = PixelFormatTable.lpPixelFormatEntries[iIndex];
+ PixelFormatTable.lpPixelFormatEntries[iIndex] = PixelFormatTable.lpPixelFormatEntries[iIndex+1];
+ PixelFormatTable.lpPixelFormatEntries[iIndex+1] = tmp;
+ bSorted = TRUE;
+ }
+ }
+ if(!bSorted) break;
+ }
+ for(iIndex=0, iEnumerated=0; (iIndex < PixelFormatTable.nEntries) && (iEnumerated < MAXTRIMMEDENTRIES); iIndex++){
+ if(PixelFormatTable.lpPixelFormatEntries[iIndex].dwRGBBitCount >= 32) break;
+ if((dxw.dwFlags7 & CLEARTEXTUREFOURCC) && (PixelFormatTable.lpPixelFormatEntries[iIndex].dwFlags & DDPF_FOURCC)) continue;
+ ret = (*lpEnumCallback)(&(PixelFormatTable.lpPixelFormatEntries[iIndex]), lpContext);
+ OutTraceD3D("EnumZBufferFormats: CALLBACK entry=%d ret=%x %s\n", iIndex, ret, ExplainPixelFormat(&PixelFormatTable.lpPixelFormatEntries[iIndex]));
+ if(!ret) break;
+ iEnumerated++;
+ }
+ //free((LPVOID)(PixelFormatTable.lpPixelFormatEntries));
+ ret = DD_OK;
+ }
+ else {
+ CallbackPixFmtArg Arg;
+ Arg.cb= &lpEnumCallback;
+ Arg.arg=lpContext;
+ ret = (*pEnumZBufferFormats)(lpd3d, riidDevice, (LPD3DENUMPIXELFORMATSCALLBACK)extZBufferProxy, (LPVOID)&Arg);
+ }
OutTraceE("Direct3D::EnumZBufferFormats res=%x(%s)\n", ret, ExplainDDError(ret));
return ret;
}
HRESULT WINAPI extEnumZBufferFormats3(void *lpd3d, REFCLSID riidDevice, LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback, LPVOID lpContext)
-{ return extEnumZBufferFormats(pEnumZBufferFormats3, lpd3d, riidDevice, lpEnumCallback, lpContext); }
+{ return extEnumZBufferFormats(3, pEnumZBufferFormats3, lpd3d, riidDevice, lpEnumCallback, lpContext); }
HRESULT WINAPI extEnumZBufferFormats7(void *lpd3d, REFCLSID riidDevice, LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback, LPVOID lpContext)
-{ return extEnumZBufferFormats(pEnumZBufferFormats7, lpd3d, riidDevice, lpEnumCallback, lpContext); }
+{ return extEnumZBufferFormats(7, pEnumZBufferFormats7, lpd3d, riidDevice, lpEnumCallback, lpContext); }
// Beware: using service surfaces with DDSCAPS_SYSTEMMEMORY capability may lead to crashes in D3D operations
// like Vievport::Clear() in "Forsaken" set in emulation AERO-friendly mode. To avoid the problem, you can
@@ -1844,4 +1994,49 @@ HRESULT WINAPI extExecute(void *lpd3d, LPDIRECT3DEXECUTEBUFFER eb, LPDIRECT3DVIE
ret=(*pExecute)(lpd3d, eb, vp, dw);
if (ret) OutTraceE("Direct3DDevice::Execute res=%x(%s)\n", ret, ExplainDDError(ret));
return DD_OK;
-}
\ No newline at end of file
+}
+
+static HRESULT CALLBACK lpTextureTrimmer(LPDDPIXELFORMAT lpDDPixFmt, LPVOID lpContext)
+{
+ HRESULT res;
+ OutTraceD3D("EnumTextureFormats: CALLBACK context=%x %s \n", lpContext, ExplainPixelFormat(lpDDPixFmt));
+ if(lpDDPixFmt->dwFlags & DDPF_FOURCC)
+ res = DD_OK;
+ else
+ res = (*(((CallbackPixFmtArg *)lpContext)->cb))(lpDDPixFmt, ((CallbackPixFmtArg *)lpContext)->arg);
+ return res;
+}
+
+static HRESULT CALLBACK lpTextureDumper(LPDDPIXELFORMAT lpDDPixFmt, LPVOID lpContext)
+{
+ OutTraceD3D("EnumTextureFormats: CALLBACK context=%x %s \n", lpContext, ExplainPixelFormat(lpDDPixFmt));
+ return TRUE;
+}
+
+HRESULT WINAPI extEnumTextureFormats(int d3dversion, EnumTextureFormats_Type pEnumTextureFormats, void *lpd3dd, LPD3DENUMPIXELFORMATSCALLBACK lptfcallback, LPVOID arg)
+{
+ HRESULT res;
+ OutTrace("EnumTextureFormats(%d): lpd3dd=%x cb=%x arg=%x\n", d3dversion, lpd3dd, lptfcallback, arg);
+ if(IsDebug) (*pEnumTextureFormats)(lpd3dd, lpTextureDumper, arg);
+
+ if(dxw.dwFlags7 & CLEARTEXTUREFOURCC){
+ CallbackPixFmtArg Arg;
+ Arg.cb= &lptfcallback;
+ Arg.arg=arg;
+ res = (*pEnumTextureFormats)(lpd3dd, lpTextureTrimmer, (LPVOID)&Arg);
+ }
+ else{
+ res = (*pEnumTextureFormats)(lpd3dd, lptfcallback, arg);
+ }
+ if(res) OutTrace("EnumTextureFormats: res=%x(%s)\n", res, ExplainDDError(res));
+ return res;
+}
+
+HRESULT WINAPI extEnumTextureFormats1(void *lpd3dd, LPD3DENUMPIXELFORMATSCALLBACK lptfcallback, LPVOID arg)
+{ return extEnumTextureFormats(1, pEnumTextureFormats1, lpd3dd, lptfcallback, arg); }
+HRESULT WINAPI extEnumTextureFormats2(void *lpd3dd, LPD3DENUMPIXELFORMATSCALLBACK lptfcallback, LPVOID arg)
+{ return extEnumTextureFormats(2, pEnumTextureFormats2, lpd3dd, lptfcallback, arg); }
+HRESULT WINAPI extEnumTextureFormats3(void *lpd3dd, LPD3DENUMPIXELFORMATSCALLBACK lptfcallback, LPVOID arg)
+{ return extEnumTextureFormats(3, pEnumTextureFormats3, lpd3dd, lptfcallback, arg); }
+HRESULT WINAPI extEnumTextureFormats7(void *lpd3dd, LPD3DENUMPIXELFORMATSCALLBACK lptfcallback, LPVOID arg)
+{ return extEnumTextureFormats(7, pEnumTextureFormats7, lpd3dd, lptfcallback, arg); }
diff --git a/dll/ole32.cpp b/dll/ole32.cpp
index 99f84f1..b6f92a0 100644
--- a/dll/ole32.cpp
+++ b/dll/ole32.cpp
@@ -153,7 +153,7 @@ HRESULT STDAPICALLTYPE extCoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter,
break;
case 0x47d4d946: // CLSID_DirectSound
OutTraceDW("CoCreateInstance: CLSID_DirectSound object\n");
- HookDirectSoundObj((LPDIRECTSOUND *)ppv);
+ HookDirectSoundObj((LPDIRECTSOUND *)ppv);
break;
case 0x4fd2a832: // CLSID_DirectDrawFactory
if ((rclsid.Data2==0x86c8) && (rclsid.Data3 == 0x11d0)){
diff --git a/dll/user32.cpp b/dll/user32.cpp
index 31b505a..7e2184a 100644
--- a/dll/user32.cpp
+++ b/dll/user32.cpp
@@ -2121,7 +2121,8 @@ BOOL WINAPI extClipCursor(RECT *lpRectArg)
OutTrace("ClipCursor: rect=(NULL)\n");
}
- if (!(dxw.dwFlags1 & ENABLECLIPPING)) return 1;
+ if (!(dxw.dwFlags1 & DISABLECLIPPING)) return TRUE;
+ if ((dxw.dwFlags8 & CLIPLOCKED) && (lpRectArg == NULL)) return TRUE;
if(lpRectArg){
Rect=*lpRectArg;
@@ -2150,12 +2151,12 @@ BOOL WINAPI extClipCursor(RECT *lpRectArg)
BOOL WINAPI extGetClipCursor(LPRECT lpRect)
{
- // v2.1.93: if ENABLECLIPPING, return the saved clip rect coordinates
+ // v2.1.93: if DISABLECLIPPING, return the saved clip rect coordinates
BOOL ret;
// proxy....
- if (!(dxw.dwFlags1 & ENABLECLIPPING)) {
+ if (!(dxw.dwFlags1 & DISABLECLIPPING)) {
ret=(*pGetClipCursor)(lpRect);
// v2.03.11: fix for "SubCulture" mouse movement
if(lpRect && dxw.Windowize) *lpRect = dxw.GetScreenRect();
diff --git a/dll/winproc.cpp b/dll/winproc.cpp
index 7a76d33..5d8b08f 100644
--- a/dll/winproc.cpp
+++ b/dll/winproc.cpp
@@ -384,8 +384,8 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
dxw.dwFlags1 &= ~LOCKWINPOS;
}
while((*pShowCursor)(1) < 0);
- if(dxw.dwFlags1 & CLIPCURSOR) dxw.EraseClipCursor();
- if(dxw.dwFlags1 & ENABLECLIPPING) (*pClipCursor)(NULL);
+ if((dxw.dwFlags1 & CLIPCURSOR) && !(dxw.dwFlags8 & CLIPLOCKED)) dxw.EraseClipCursor();
+ if(dxw.dwFlags1 & DISABLECLIPPING) dxw.EraseClipCursor();
break;
case WM_EXITSIZEMOVE:
if(IsToBeLocked){
@@ -394,7 +394,7 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
}
if((dxw.dwFlags1 & HIDEHWCURSOR) && dxw.IsFullScreen()) while((*pShowCursor)(0) >= 0);
if(dxw.dwFlags2 & SHOWHWCURSOR) while((*pShowCursor)(1) < 0);
- if(dxw.dwFlags1 & ENABLECLIPPING) extClipCursor(lpClipRegion);
+ if(dxw.dwFlags1 & DISABLECLIPPING) extClipCursor(lpClipRegion);
if(dxw.dwFlags2 & REFRESHONRESIZE) dxw.ScreenRefresh();
if(dxw.dwFlags4 & HIDEDESKTOP) dxw.HideDesktop(dxw.GethWnd());
if(dxw.dwFlags5 & CENTERTOWIN) {
@@ -489,12 +489,12 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
case WM_SETFOCUS:
OutTraceDW("WindowProc: hwnd=%x GOT FOCUS\n", hwnd);
if(dxw.dwFlags1 & CLIPCURSOR) dxw.SetClipCursor();
- if (dxw.dwFlags1 & ENABLECLIPPING) extClipCursor(lpClipRegion);
+ if (dxw.dwFlags1 & DISABLECLIPPING) extClipCursor(lpClipRegion);
break;
case WM_KILLFOCUS:
OutTraceDW("WindowProc: hwnd=%x LOST FOCUS\n", hwnd);
- if (dxw.dwFlags1 & CLIPCURSOR) dxw.EraseClipCursor();
- if (dxw.dwFlags1 & ENABLECLIPPING) (*pClipCursor)(NULL);
+ if((dxw.dwFlags1 & CLIPCURSOR) && !(dxw.dwFlags8 & CLIPLOCKED)) dxw.EraseClipCursor();
+ if (dxw.dwFlags1 & DISABLECLIPPING) dxw.EraseClipCursor();
break;
case WM_SYSCOMMAND:
// v2.03.56.fix1 by FunkyFr3sh: ensure that "C&C Red Alert 2" receives the WM_SYSCOMMAND / SC_CLOSE message
diff --git a/host/TabDirect3D.cpp b/host/TabDirect3D.cpp
index 3bbf77a..8f3e2a1 100644
--- a/host/TabDirect3D.cpp
+++ b/host/TabDirect3D.cpp
@@ -34,6 +34,7 @@ void CTabDirect3D::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_NOD3DRESET, cTarget->m_NoD3DReset);
DDX_Check(pDX, IDC_SUPPRESSD3DEXT, cTarget->m_SuppressD3DExt);
DDX_Check(pDX, IDC_ENUM16BITMODES, cTarget->m_Enum16bitModes);
+ DDX_Check(pDX, IDC_TRIMTEXTUREFORMATS, cTarget->m_TrimTextureFormats);
// Direct3D window tweaks
DDX_Check(pDX, IDC_FIXD3DFRAME, cTarget->m_FixD3DFrame);
diff --git a/host/TabDirectX2.cpp b/host/TabDirectX2.cpp
index 2e38076..b25ce6e 100644
--- a/host/TabDirectX2.cpp
+++ b/host/TabDirectX2.cpp
@@ -35,6 +35,7 @@ void CTabDirectX2::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_FIXREFCOUNTER, cTarget->m_FixRefCounter);
DDX_Check(pDX, IDC_RETURNNULLREF, cTarget->m_ReturnNullRef);
DDX_Check(pDX, IDC_FORCESHEL, cTarget->m_ForcesHEL);
+ DDX_Check(pDX, IDC_NOHALDEVICE, cTarget->m_NoHALDevice);
DDX_Check(pDX, IDC_MINIMALCAPS, cTarget->m_MinimalCaps);
DDX_Check(pDX, IDC_SETZBUFFERBITDEPTHS, cTarget->m_SetZBufferBitDepths);
DDX_Check(pDX, IDC_DEINTERLACE, cTarget->m_Deinterlace);
diff --git a/host/TabInput.cpp b/host/TabInput.cpp
index 13fbac0..9bc5602 100644
--- a/host/TabInput.cpp
+++ b/host/TabInput.cpp
@@ -31,8 +31,8 @@ void CTabInput::DoDataExchange(CDataExchange* pDX)
DDX_Radio(pDX, IDC_CURSORAUTOMATIC, cTarget->m_MouseVisibility);
// Cursor Handling
DDX_Check(pDX, IDC_MODIFYMOUSE, cTarget->m_ModifyMouse);
- DDX_Check(pDX, IDC_ENABLECLIPPING, cTarget->m_EnableClipping);
- DDX_Check(pDX, IDC_CLIPCURSOR, cTarget->m_CursorClipping);
+ //DDX_Check(pDX, IDC_DISABLECLIPPING, cTarget->m_EnableClipping);
+ //DDX_Check(pDX, IDC_CLIPCURSOR, cTarget->m_CursorClipping);
DDX_Check(pDX, IDC_KEEPCURSORWITHIN, cTarget->m_KeepCursorWithin);
DDX_Check(pDX, IDC_KEEPCURSORFIXED, cTarget->m_KeepCursorFixed);
DDX_Check(pDX, IDC_MESSAGEPROC, cTarget->m_MessageProc);
@@ -41,7 +41,8 @@ void CTabInput::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_SLOW, cTarget->m_SlowDown);
DDX_Check(pDX, IDC_RELEASEMOUSE, cTarget->m_ReleaseMouse);
DDX_Check(pDX, IDC_VIRTUALJOYSTICK, cTarget->m_VirtualJoystick);
- //DDX_Check(pDX, IDC_FRAMECOMPENSATION, cTarget->m_FrameCompensation);
+ // Cursor Clipper
+ DDX_Radio(pDX, IDC_CLIPPERAUTO, cTarget->m_MouseClipper);
// DirectInput
DDX_Check(pDX, IDC_HOOKDI, cTarget->m_HookDI);
DDX_Check(pDX, IDC_HOOKDI8, cTarget->m_HookDI8);
diff --git a/host/TargetDlg.cpp b/host/TargetDlg.cpp
index c949468..ff06fff 100644
--- a/host/TargetDlg.cpp
+++ b/host/TargetDlg.cpp
@@ -31,6 +31,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
m_DxFilterMode = 0; // default: ddraw filtering
m_DCEmulationMode = 0; // default: no emulation
m_MouseVisibility = 0;
+ m_MouseClipper = 0;
m_OffendingMessages = 0;
m_TextureHandling = 0;
m_HookDI = FALSE;
@@ -58,6 +59,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
m_SuppressIME = FALSE;
m_SuppressD3DExt = FALSE;
m_Enum16bitModes = FALSE;
+ m_TrimTextureFormats = FALSE;
m_SetCompatibility = TRUE; // default true !!
m_AEROBoost = TRUE; // default true !!
m_DiabloTweak = FALSE;
@@ -148,8 +150,8 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
m_IndependentRefresh = FALSE;
m_TextureFormat = FALSE;
m_FixWinFrame = FALSE;
- m_EnableClipping = FALSE;
- m_CursorClipping = FALSE;
+ //m_EnableClipping = FALSE;
+ //m_CursorClipping = FALSE;
m_VideoToSystemMem = FALSE;
m_FixTextOut = FALSE;
m_SharedDC = FALSE;
diff --git a/host/TargetDlg.h b/host/TargetDlg.h
index 66784fa..036c5b1 100644
--- a/host/TargetDlg.h
+++ b/host/TargetDlg.h
@@ -33,6 +33,7 @@ public:
int m_DxFilterMode;
int m_DCEmulationMode;
int m_MouseVisibility;
+ int m_MouseClipper;
int m_OffendingMessages;
int m_TextureHandling;
int m_SonProcessMode;
@@ -110,8 +111,8 @@ public:
BOOL m_IndependentRefresh;
BOOL m_TextureFormat;
BOOL m_FixWinFrame;
- BOOL m_EnableClipping;
- BOOL m_CursorClipping;
+ //BOOL m_EnableClipping;
+ //BOOL m_CursorClipping;
BOOL m_VideoToSystemMem;
BOOL m_FixTextOut;
BOOL m_SharedDC;
@@ -234,6 +235,7 @@ public:
BOOL m_DisableDisableAltTab;
BOOL m_NoImagehlp;
BOOL m_ForcesHEL;
+ BOOL m_NoHALDevice;
BOOL m_MinimalCaps;
BOOL m_SetZBufferBitDepths;
BOOL m_ForcesSwapEffect;
@@ -259,7 +261,7 @@ public:
BOOL m_BlackWhite;
BOOL m_SuppressD3DExt;
BOOL m_Enum16bitModes;
- //BOOL m_Force16BPP;
+ BOOL m_TrimTextureFormats;
BOOL m_LimitScreenRes;
BOOL m_InitialRes;
BOOL m_MaximumRes;
diff --git a/host/dxwndhost.aps b/host/dxwndhost.aps
index 3604fb6..aebc35a 100644
Binary files a/host/dxwndhost.aps and b/host/dxwndhost.aps differ
diff --git a/host/dxwndhost.cpp b/host/dxwndhost.cpp
index fb39960..a30a06d 100644
--- a/host/dxwndhost.cpp
+++ b/host/dxwndhost.cpp
@@ -39,6 +39,7 @@ BOOL gWarnOnExit = FALSE;
BOOL gTransientMode = FALSE;
BOOL gAutoHideMode = FALSE;
BOOL gQuietMode = FALSE;
+BOOL gMustDie = FALSE;
int iProgIndex;
extern char m_ConfigFileName[20+1] = "dxwnd.ini";
diff --git a/host/dxwndhost.rc b/host/dxwndhost.rc
index 4482799..ad32bd7 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 5e993d3..e34e54d 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 dd74b5a..6c52cdf 100644
--- a/host/dxwndhostView.cpp
+++ b/host/dxwndhostView.cpp
@@ -36,6 +36,7 @@ extern int KillProcByName(char *, BOOL);
extern BOOL gTransientMode;
extern BOOL gAutoHideMode;
extern BOOL gbDebug;
+extern BOOL gMustDie;
extern int iProgIndex;
PRIVATEMAP *pTitles; // global ptr: get rid of it!!
@@ -276,6 +277,13 @@ void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg)
case 2: t->flags2 |= SHOWHWCURSOR; break;
}
+ switch(dlg->m_MouseClipper){
+ case 0: break;
+ case 1: t->flags |= DISABLECLIPPING; break;
+ case 2: t->flags |= CLIPCURSOR; break;
+ case 3: t->flags |= CLIPCURSOR; t->flags8 |= CLIPLOCKED; break;
+ }
+
switch(dlg->m_OffendingMessages){
case 0: break;
case 1: t->flags3 |= FILTERMESSAGES; break;
@@ -379,6 +387,7 @@ void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg)
if(dlg->m_SuppressIME) t->flags2 |= SUPPRESSIME;
if(dlg->m_SuppressD3DExt) t->flags3 |= SUPPRESSD3DEXT;
if(dlg->m_Enum16bitModes) t->flags7 |= ENUM16BITMODES;
+ if(dlg->m_TrimTextureFormats) t->flags8 |= TRIMTEXTUREFORMATS;
if(dlg->m_SetCompatibility) t->flags2 |= SETCOMPATIBILITY;
if(dlg->m_AEROBoost) t->flags5 |= AEROBOOST;
if(dlg->m_DiabloTweak) t->flags5 |= DIABLOTWEAK;
@@ -392,6 +401,7 @@ void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg)
if(dlg->m_DisableDisableAltTab) t->flags7 |= DISABLEDISABLEALTTAB;
if(dlg->m_NoImagehlp) t->flags5 |= NOIMAGEHLP;
if(dlg->m_ForcesHEL) t->flags3 |= FORCESHEL;
+ if(dlg->m_NoHALDevice) t->flags8 |= NOHALDEVICE;
if(dlg->m_MinimalCaps) t->flags3 |= MINIMALCAPS;
if(dlg->m_SetZBufferBitDepths) t->flags6 |= SETZBUFFERBITDEPTHS;
if(dlg->m_ForcesSwapEffect) t->flags6 |= FORCESWAPEFFECT;
@@ -425,8 +435,8 @@ void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg)
if(dlg->m_IndependentRefresh) t->flags2 |= INDEPENDENTREFRESH;
if(dlg->m_TextureFormat) t->flags5 |= TEXTUREFORMAT;
if(dlg->m_FixWinFrame) t->flags |= FIXWINFRAME;
- if(dlg->m_EnableClipping) t->flags |= ENABLECLIPPING;
- if(dlg->m_CursorClipping) t->flags |= CLIPCURSOR;
+ //if(dlg->m_EnableClipping) t->flags |= DISABLECLIPPING;
+ //if(dlg->m_CursorClipping) t->flags |= CLIPCURSOR;
if(dlg->m_VideoToSystemMem) t->flags |= SWITCHVIDEOMEMORY;
if(dlg->m_FixTextOut) t->flags |= FIXTEXTOUT;
if(dlg->m_HookGlide) t->flags4 |= HOOKGLIDE;
@@ -601,6 +611,11 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg)
if(t->flags & HIDEHWCURSOR) dlg->m_MouseVisibility = 1;
if(t->flags2 & SHOWHWCURSOR) dlg->m_MouseVisibility = 2;
+ dlg->m_MouseClipper = 0;
+ if(t->flags & DISABLECLIPPING) dlg->m_MouseClipper = 1;
+ if(t->flags & CLIPCURSOR) dlg->m_MouseClipper = 2;
+ if(t->flags8 & CLIPLOCKED) dlg->m_MouseClipper = 3;
+
dlg->m_OffendingMessages = 0;
if(t->flags3 & FILTERMESSAGES) dlg->m_OffendingMessages = 1;
if(t->flags3 & DEFAULTMESSAGES) dlg->m_OffendingMessages = 2;
@@ -673,6 +688,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg)
dlg->m_SuppressIME = t->flags2 & SUPPRESSIME ? 1 : 0;
dlg->m_SuppressD3DExt = t->flags3 & SUPPRESSD3DEXT ? 1 : 0;
dlg->m_Enum16bitModes = t->flags7 & ENUM16BITMODES ? 1 : 0;
+ dlg->m_TrimTextureFormats = t->flags8 & TRIMTEXTUREFORMATS ? 1 : 0;
dlg->m_SetCompatibility = t->flags2 & SETCOMPATIBILITY ? 1 : 0;
dlg->m_AEROBoost = t->flags5 & AEROBOOST ? 1 : 0;
dlg->m_DiabloTweak = t->flags5 & DIABLOTWEAK ? 1 : 0;
@@ -686,6 +702,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg)
dlg->m_DisableDisableAltTab = t->flags7 & DISABLEDISABLEALTTAB ? 1 : 0;
dlg->m_NoImagehlp = t->flags5 & NOIMAGEHLP ? 1 : 0;
dlg->m_ForcesHEL = t->flags3 & FORCESHEL ? 1 : 0;
+ dlg->m_NoHALDevice = t->flags8 & NOHALDEVICE ? 1 : 0;
dlg->m_MinimalCaps = t->flags3 & MINIMALCAPS ? 1 : 0;
dlg->m_SetZBufferBitDepths = t->flags6 & SETZBUFFERBITDEPTHS ? 1 : 0;
dlg->m_ForcesSwapEffect = t->flags6 & FORCESWAPEFFECT ? 1 : 0;
@@ -738,8 +755,8 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg)
dlg->m_IndependentRefresh = t->flags2 & INDEPENDENTREFRESH ? 1 : 0;
dlg->m_TextureFormat = t->flags5 & TEXTUREFORMAT ? 1 : 0;
dlg->m_FixWinFrame = t->flags & FIXWINFRAME ? 1 : 0;
- dlg->m_EnableClipping = t->flags & ENABLECLIPPING ? 1 : 0;
- dlg->m_CursorClipping = t->flags & CLIPCURSOR ? 1 : 0;
+ //dlg->m_EnableClipping = t->flags & DISABLECLIPPING ? 1 : 0;
+ //dlg->m_CursorClipping = t->flags & CLIPCURSOR ? 1 : 0;
dlg->m_VideoToSystemMem = t->flags & SWITCHVIDEOMEMORY ? 1 : 0;
dlg->m_FixTextOut = t->flags & FIXTEXTOUT ? 1 : 0;
dlg->m_SharedDC = t->flags6 & SHAREDDC ? 1 : 0;
@@ -1375,14 +1392,6 @@ void CDxwndhostView::OnInitialUpdate()
pTitles = &PrivateMaps[0];
pTargets= &TargetMaps[0];
- // Hot Keys
- //DWORD dwKey;
- //extern Key_Type HKeys[];
- //extern KeyCombo_Type HKeyCombo[];
- //for(int i=0; HKeys[i].iLabelResourceId; i++){
- // dwKey = GetPrivateProfileInt("keymapping", HKeys[i].sIniLabel, 0, gInitPath);
- // if(dwKey) if(!RegisterHotKey(this->GetSafeHwnd(), i, MOD_ALT+MOD_SHIFT+MOD_CONTROL, dwKey)) VKeyError(HKeys[i].sIniLabel);
- //}
UpdateHotKeys();
// Transient mode
@@ -2337,23 +2346,10 @@ void CDxwndhostView::OnClearAllLogs()
_unlink(FilePath);
}
-DWORD WINAPI SilentUpdate(CSystemTray *Tray)
+DWORD WINAPI WaitForDeath(LPVOID arg)
{
- int DxStatus;
- int IdleCount;
- IdleCount=0;
- while (TRUE) {
- // once a second ...
- Sleep(1000);
- DxStatus=GetHookStatus(NULL);
- if (DxStatus != DXW_RUNNING){
- IdleCount++;
- if(IdleCount >= 2) exit(0);
- }
- else {
- IdleCount=0;
- }
- }
+ while(!gMustDie) Sleep(1000);
+ exit(0);
}
DWORD WINAPI TrayIconUpdate(CSystemTray *Tray)
@@ -2370,6 +2366,11 @@ DWORD WINAPI TrayIconUpdate(CSystemTray *Tray)
while (TRUE) {
// once a second ...
Sleep(1000);
+ if(gTransientMode && gMustDie) {
+ Tray->HideIcon();
+ delete(Tray->GetAncestor(GA_ROOTOWNER));
+ exit(0);
+ }
DxStatus=GetHookStatus(NULL);
switch (DxStatus){
case DXW_IDLE: IconId=IDI_DXIDLE; Status="DISABLED"; break;
@@ -2383,11 +2384,6 @@ DWORD WINAPI TrayIconUpdate(CSystemTray *Tray)
Tray->SetIcon(IconId);
IdleCount++;
if(IdleCount == 2) {
- if(gTransientMode) {
- Tray->HideIcon();
- delete(Tray->GetAncestor(GA_ROOTOWNER));
- exit(0);
- }
if(gAutoHideMode) {
Tray->MaximiseFromTray(pParent, FALSE); }
}
@@ -2444,7 +2440,7 @@ void CDxwndhostView::OnGoToTrayIcon()
NIIF_INFO, 10)){
MessageBoxLang(DXW_STRING_TRAYFAIL, DXW_STRING_ERROR, MB_OK);
// error path: if can't create a system tray icon, transient logic must be silently placed here
- if (gTransientMode) StatusThread= CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)SilentUpdate, (LPVOID)NULL, 0, &dwThrdId);
+ if(gTransientMode) StatusThread= CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)WaitForDeath, (LPVOID)NULL, 0, &dwThrdId);
return;
}
IconId=(menu->GetMenuState(ID_HOOK_START, MF_BYCOMMAND)==MF_CHECKED)?IDI_DXWAIT:IDI_DXIDLE;
@@ -2636,6 +2632,56 @@ void CDxwndhostView::OnRButtonDown(UINT nFlags, CPoint point)
CListView::OnRButtonDown(nFlags, point);
}
+typedef struct {
+ char *path;
+ char *launch;
+} PROCESSMAP;
+
+static DWORD WINAPI TransientWaitForChildDeath(void *p)
+{
+ PROCESSMAP *ProcessMap = (PROCESSMAP *)p;
+ BOOL bIsSomeoneAlive;
+ int ret;
+ char sPath[MAX_PATH];
+ char sLaunch[MAX_PATH];
+ char sTemp[MAX_PATH];
+ char *lpProcName, *lpNext;
+
+ // strip full pathname and keep executable name only
+ strcpy(sPath, "");
+ if(ProcessMap->path[0]){
+ strncpy(sTemp, ProcessMap->path, MAX_PATH);
+ lpProcName=sTemp;
+ while (lpNext=strchr(lpProcName,'\\')) lpProcName=lpNext+1;
+ strncpy(sPath, lpProcName, MAX_PATH);
+ }
+ strcpy(sLaunch, "");
+ if(ProcessMap->launch[0]){
+ strncpy(sTemp, ProcessMap->launch, MAX_PATH);
+ lpProcName=sTemp;
+ while (lpNext=strchr(lpProcName,'\\')) lpProcName=lpNext+1;
+ strncpy(sLaunch, lpProcName, MAX_PATH);
+ }
+
+ Sleep(3000); // Wait for process creation - necessary?
+
+ while(TRUE){
+ Sleep(2000);
+ bIsSomeoneAlive = FALSE;
+ if(sPath[0]) {
+ if (!(ret=KillProcByName(sPath, FALSE))) bIsSomeoneAlive = TRUE;
+ }
+ if(sLaunch[0]) {
+ if (!(ret=KillProcByName(sLaunch, FALSE))) bIsSomeoneAlive = TRUE;
+ }
+ if(!bIsSomeoneAlive) {
+ break;
+ }
+ }
+ gMustDie = TRUE;
+ return 0;
+}
+
static char *ExceptionCaption(DWORD ec)
{
char *c;
@@ -3186,6 +3232,8 @@ static void MakeHiddenFile(char *sTargetPath)
CloseHandle(hTempFile);
}
+PROCESSMAP pm;
+
void CDxwndhostView::OnRun()
{
CListCtrl& listctrl = GetListCtrl();
@@ -3286,6 +3334,12 @@ void CDxwndhostView::OnRun()
CloseHandle(pinfo.hThread); // no longer needed, avoid handle leakage
}
+ if(gTransientMode){
+ pm.launch = &(PrivateMaps[i].launchpath[0]);
+ pm.path = &(TargetMaps[i].path[0]);
+ CreateThread( NULL, 0, TransientWaitForChildDeath, &pm, 0, NULL);
+ }
+
// wait & recover
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)RecoverTargetMaps, (LPVOID)TargetMaps, 0, NULL);
if(gAutoHideMode) this->OnGoToTrayIcon();
diff --git a/host/host.aps b/host/host.aps
index 6a498d0..caebb64 100644
Binary files a/host/host.aps and b/host/host.aps differ
diff --git a/host/resource b/host/resource
index 9f5dff1..1fca39a 100644
Binary files a/host/resource and b/host/resource differ