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

v2_03_41_src

Former-commit-id: 75e42f81096bdea104b7b82ac70a502963c0fe39
This commit is contained in:
gho tik 2015-10-25 12:42:15 -04:00 committed by Refael ACkermann
parent 7ff3fc295d
commit b3937c0e3f
38 changed files with 1098 additions and 668 deletions

View File

@ -138,7 +138,7 @@
#define SUPPORTSVGA 0x00400000 // Supports SVGA standard resolutions #define SUPPORTSVGA 0x00400000 // Supports SVGA standard resolutions
#define SUPPORTHDTV 0x00800000 // Supports HDTV standard resolutions #define SUPPORTHDTV 0x00800000 // Supports HDTV standard resolutions
#define RELEASEMOUSE 0x01000000 // GetCursorPos returns centered coordinates when the mouse cursor is moved outside the window #define RELEASEMOUSE 0x01000000 // GetCursorPos returns centered coordinates when the mouse cursor is moved outside the window
#define FRAMECOMPENSATION 0x02000000 // Compensate for frame border adding x,y displacement of (x) left border and (y) window title bar //#define FRAMECOMPENSATION 0x02000000 // Compensate for frame border adding x,y displacement of (x) left border and (y) window title bar
#define HOTPATCH 0x04000000 // Use hot patching technique to handle obfuscated IAT #define HOTPATCH 0x04000000 // Use hot patching technique to handle obfuscated IAT
#define ENABLEHOTKEYS 0x08000000 // Enables hot keys #define ENABLEHOTKEYS 0x08000000 // Enables hot keys
#define HOTPATCHALWAYS 0x10000000 // Force hot patching to every call #define HOTPATCHALWAYS 0x10000000 // Force hot patching to every call
@ -206,6 +206,8 @@
#define FIXPIXELZOOM 0x00400000 #define FIXPIXELZOOM 0x00400000
#define REUSEEMULATEDDC 0x00800000 #define REUSEEMULATEDDC 0x00800000
#define CREATEDESKTOP 0x01000000 // creates a virtual desktop window to replace the real one #define CREATEDESKTOP 0x01000000 // creates a virtual desktop window to replace the real one
#define NOWINDOWHOOKS 0x02000000 // do not intercept window callback routines
//#define NOMOUSEPROC 0x04000000 // don't process mouse x,y coordinates twice in WindowProc and MessageHook hookers
// logging Tflags DWORD: // logging Tflags DWORD:
#define OUTTRACE 0x00000001 // enables tracing to dxwnd.log in general #define OUTTRACE 0x00000001 // enables tracing to dxwnd.log in general

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:42ec28df67eae0d8fd18218010fd1cf3ad9c182d0b3ee9d828c1d11c925c96e0 oid sha256:d724989d76de31cdefc98848587998e2e3464ea49793397892e068d37db2c730
size 593408 size 593408

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:945f3a67534c63ae2e17d0cb76db3a473149e39b62164fb433f6a4a021d75471 oid sha256:17c20de2bcab09a41568811d8227ff38f2411dd95c133e1252e2852293ab643f
size 545280 size 545280

Binary file not shown.

View File

@ -0,0 +1,32 @@
[target]
title0=688(I) Hunter Killer
path0=D:\Games\688\688I_HK.EXE
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=-2011168734
flagg0=1209008128
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

View File

@ -0,0 +1,32 @@
[target]
title0=Batman Vengeance
path0=D:\Games\Batman Vengeance\Batman\Batman.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

View File

@ -0,0 +1,32 @@
[target]
title0=Cool Pool Eightball Demo
path0=D:\Games\CoolPoolEightballDemo\CoolPool.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=136314914
flagg0=1207959552
flagh0=20
flagi0=134217732
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

View File

@ -0,0 +1,32 @@
[target]
title0=Deathtrap Dungeon
path0=F:\ASYLUM\DD_CD.EXE
launchpath0=D:\Games\Deathtrap Dungeon\DDSTART.EXE
module0=
opengllib0=
notes0=Note:\ninstalled from CD, the game need to be configured with the launcher from the HD \nand the actual game exe from the CD!\n\nNote: \nThe intro movies are interlaced and can be deinterlaced. \nAlso, the game can be rendered with bilinear filtering.
registry0=
ver0=1
coord0=0
flag0=681574434
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=268439680
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

View File

@ -0,0 +1,32 @@
[target]
title0=Dweep Gold
path0=D:\Games\DweepGol\Dweep.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=136314914
flagg0=1207959552
flagh0=20
flagi0=134217732
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

32
build/exports/Fin-Fin.dxw Normal file
View File

@ -0,0 +1,32 @@
[target]
title0=Fin-Fin
path0=D:\Games\Fin-Fin\v90seger\teoboot.exe
launchpath0=D:\Games\Fin-Fin\v90seger\FinFin.exe
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=-1465909214
flagg0=1207959552
flagh0=20
flagi0=205520900
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

View File

@ -5,14 +5,14 @@ launchpath0=
module0= module0=
opengllib0= opengllib0=
notes0= notes0=
ver0=0 ver0=7
coord0=0 coord0=0
flag0=-1476394974 flag0=-1474297822
flagg0=1207959552 flagg0=1207959552
flagh0=20 flagh0=33554448
flagi0=138412036 flagi0=205520900
flagj0=4224 flagj0=4224
flagk0=512 flagk0=66048
tflag0=0 tflag0=0
initx0=0 initx0=0
inity0=0 inity0=0
@ -29,3 +29,4 @@ initts0=0
winver0=0 winver0=0
maxres0=-1 maxres0=-1
swapeffect0=0 swapeffect0=0
registry0=

View File

@ -0,0 +1,32 @@
[target]
title0=PBA Bowling 2 Demo
path0=D:\Games\PBA Bowling 2 Demo\BowlingR.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

View File

@ -1,6 +1,6 @@
[target] [target]
title0=Requiem Avenging Angel (D3D) title0=Requiem Avenging Angel (D3D)
path0=D:\Games\Requiem Avenging Angel\D3D.exe path0=D:\Games\Requiem Avenging Angel\D3D.by Matt.exe
launchpath0= launchpath0=
module0= module0=
opengllib0= opengllib0=
@ -8,8 +8,8 @@ ver0=0
coord0=0 coord0=0
flag0=-1468006366 flag0=-1468006366
flagg0=1207959552 flagg0=1207959552
flagh0=20 flagh0=1044
flagi0=138412036 flagi0=1212153860
tflag0=0 tflag0=0
initx0=0 initx0=0
inity0=0 inity0=0
@ -26,3 +26,7 @@ initts0=0
winver0=0 winver0=0
maxres0=-1 maxres0=-1
flagj0=128 flagj0=128
notes0=
registry0=# Requiem Avenging Angel: DirectX version patch\n\n[HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\DirectX]\n"Version"="4.07.00.0704"\n\n[HKEY_LOCAL_MACHINE\Software\Microsoft\DirectX]\n"Version"="4.07.00.0704"\n\n[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\DirectX]\n"Version"="4.07.00.0704"\n\n[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DirectX]\n"Version"="4.07.00.0704"\n
flagk0=67174400
swapeffect0=0

View File

@ -8,9 +8,9 @@ ver0=0
coord0=0 coord0=0
flag0=-1199570906 flag0=-1199570906
flagg0=1207959552 flagg0=1207959552
flagh0=20 flagh0=1044
flagi0=1212153860 flagi0=1212153860
tflag0=6914 tflag0=0
initx0=0 initx0=0
inity0=0 inity0=0
minx0=0 minx0=0
@ -25,3 +25,8 @@ maxfps0=0
initts0=0 initts0=0
winver0=0 winver0=0
maxres0=-1 maxres0=-1
notes0=
registry0=# Requiem Avenging Angel: DirectX version patch\n\n[HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\DirectX]\n"Version"="4.07.00.0704"\n\n[HKEY_LOCAL_MACHINE\Software\Microsoft\DirectX]\n"Version"="4.07.00.0704"\n
flagj0=128
flagk0=67174400
swapeffect0=0

View File

@ -0,0 +1,32 @@
[target]
title0=Sid Meyer's Gettysburg Demo
path0=D:\Games\Sid Meyer's Gettysburg Demo\lee.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=673185826
flagg0=1207959552
flagh0=20
flagi0=138412036
flagj0=67113088
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

View File

@ -5,10 +5,10 @@ module0=
opengllib0= opengllib0=
ver0=0 ver0=0
coord0=0 coord0=0
flag0=-2147483102 flag0=-2147483614
flagg0=269484064 flagg0=1477443616
flagh0=532 flagh0=532
flagi0=0 flagi0=4194304
tflag0=0 tflag0=0
initx0=0 initx0=0
inity0=0 inity0=0
@ -22,3 +22,11 @@ sizx0=0
sizy0=0 sizy0=0
maxfps0=0 maxfps0=0
initts0=0 initts0=0
launchpath0=
notes0=
registry0=
flagj0=67108992
flagk0=65536
winver0=0
maxres0=0
swapeffect0=0

View File

@ -0,0 +1,32 @@
[target]
title0=X-Files, the
path0=D:\Games\X-Files\XFiles.exe
launchpath0=
module0=
opengllib0=
notes0=
registry0=
ver0=0
coord0=0
flag0=-2011168733
flagg0=1209008128
flagh0=16
flagi0=138412036
flagj0=67113088
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

View File

@ -929,3 +929,13 @@ fix: hooked more GDI calls: CreateICA, GetViewportExtEx, IntersectClipRect, SetR
fix: ChangeDisplaySettings no longer take note of video mode when called with CDS_TEST flag fix: ChangeDisplaySettings no longer take note of video mode when called with CDS_TEST flag
fix: merged user32 FillRect and FrameRect handling fix: merged user32 FillRect and FrameRect handling
fix: fixed bug that was leaving a copy of dxwnd.ini on last visited directory on window close fix: fixed bug that was leaving a copy of dxwnd.ini on last visited directory on window close
v2.03.41
fix: filtering of mouse messages in "Message pump" option. Makes games more responsive to mouse clicks. Improves "X-files".
fix: exclusion of DDSCL_SETDEVICEWINDOW, DDSCL_CREATEDEVICEWINDOW and DDSCL_SETFOCUSWINDOW flags in ddraw SetCooperativeLevel windowed mode
fix: guess PRIMARY surface in ddraw1 when no flags (but BACKBUFFERCOUNT) are set. Necessary for "Star Force Deluxe"
delete: suppressed frame compensation option FRAMECOMPENSATION (unused).
add: added debug flag NOWINDOWHOOKS to avoid WindowProc hook.
fix: GetPaletteEntries hook returns 256 value against hpal=NULL. Let "M.I.B." run, though palette is still not ok.
fix: StretchDIBits hook no longer can return an unassigned value
fix: anti-recursion check in DialogBox WindowProc call

View File

@ -336,6 +336,7 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
while(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)){ while(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)){
OutTraceW("MESSAGEPUMP: msg=%x l-wParam=(%x,%x)\n", msg.message, msg.lParam, msg.wParam); OutTraceW("MESSAGEPUMP: msg=%x l-wParam=(%x,%x)\n", msg.message, msg.lParam, msg.wParam);
if((msg.message >= WM_KEYFIRST) && (msg.message <= WM_KEYLAST)) break; // do not consume keyboard inputs if((msg.message >= WM_KEYFIRST) && (msg.message <= WM_KEYLAST)) break; // do not consume keyboard inputs
if((msg.message >= WM_MOUSEFIRST) && (msg.message <= WM_MOUSELAST)) break; // do not consume mouse inputs
PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);

View File

@ -2088,7 +2088,8 @@ HRESULT WINAPI extSetCooperativeLevel(void *lpdd, HWND hwnd, DWORD dwflags)
dxw.SethWnd(hwnd); dxw.SethWnd(hwnd);
} }
dxw.SetFullScreen(TRUE); dxw.SetFullScreen(TRUE);
dwflags &= ~(DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWMODEX); // v2.03.41: added suppression of DDSCL_SETDEVICEWINDOW DDSCL_CREATEDEVICEWINDOW DDSCL_SETFOCUSWINDOW used by "PBA Bowling 2"
dwflags &= ~(DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWMODEX | DDSCL_SETDEVICEWINDOW | DDSCL_CREATEDEVICEWINDOW | DDSCL_SETFOCUSWINDOW);
dwflags |= DDSCL_NORMAL; dwflags |= DDSCL_NORMAL;
bFixFrame = TRUE; bFixFrame = TRUE;
} }
@ -2844,15 +2845,15 @@ static HRESULT WINAPI extCreateSurface(int dxversion, CreateSurface_Type pCreate
//GHO workaround (needed for WarWind, Rogue Spear): //GHO workaround (needed for WarWind, Rogue Spear):
if (lpddsd->dwFlags && !(lpddsd->dwFlags & 0x1)){ if (lpddsd->dwFlags && !(lpddsd->dwFlags & 0x1)){
OutTraceDW("CreateSurface: fixing illegal dwFlags value: %x -> %x\n", OutTraceDW("CreateSurface: fixing illegal dwFlags value: %x -> %x\n",
lpddsd->dwFlags, lpddsd->dwFlags+1); lpddsd->dwFlags, (lpddsd->dwFlags | DDSD_CAPS));
lpddsd->dwFlags++; lpddsd->dwFlags |= DDSD_CAPS;
} }
memcpy(&ddsd, lpddsd, lpddsd->dwSize); // Copy memcpy(&ddsd, lpddsd, lpddsd->dwSize); // Copy
// v2.02.38: this is odd: in "Star Force Deluxe" there is no PRIMARY surface, but a surface with // v2.02.38: this is odd: in "Star Force Deluxe" there is no PRIMARY surface, but a surface with
// 0 flags and 0 capabilities serves for this purpose. Is it a side-effect of old ddraw releases? // 0 flags and 0 capabilities serves for this purpose. Is it a side-effect of old ddraw releases?
if((dxversion == 1) && (ddsd.dwFlags == 0)){ // Star Force Deluxe if((dxversion == 1) && ((ddsd.dwFlags & ~DDSD_BACKBUFFERCOUNT) == 0)){ // Star Force Deluxe
ddsd.dwFlags = DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH; ddsd.dwFlags = DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
//if(dxw.VirtualPixelFormat.dwRGBBitCount == 8) ddsd.ddsCaps.dwCaps |= DDSCAPS_PALETTE; //if(dxw.VirtualPixelFormat.dwRGBBitCount == 8) ddsd.ddsCaps.dwCaps |= DDSCAPS_PALETTE;

View File

@ -28,6 +28,8 @@ dxwCore dxw;
dxwSStack dxwss; dxwSStack dxwss;
dxwWStack dxwws; dxwWStack dxwws;
extern LRESULT CALLBACK MessageHook(int, WPARAM, LPARAM);
typedef char *(*Geterrwarnmessage_Type)(unsigned long, unsigned long); typedef char *(*Geterrwarnmessage_Type)(unsigned long, unsigned long);
typedef int (*Preparedisasm_Type)(void); typedef int (*Preparedisasm_Type)(void);
typedef void (*Finishdisasm_Type)(void); typedef void (*Finishdisasm_Type)(void);
@ -42,7 +44,7 @@ extern void InitScreenParameters();
extern void *HotPatch(void *, const char *, void *); extern void *HotPatch(void *, const char *, void *);
extern void *IATPatch(HMODULE, char *, void *, const char *, void *); extern void *IATPatch(HMODULE, char *, void *, const char *, void *);
void HookModule(HMODULE, int); void HookModule(HMODULE, int);
static void RecoverScreenMode(); void RecoverScreenMode();
static void LockScreenMode(DWORD, DWORD, DWORD); static void LockScreenMode(DWORD, DWORD, DWORD);
extern HANDLE hTraceMutex; extern HANDLE hTraceMutex;
@ -89,7 +91,7 @@ static char *Flag4Names[32]={
"LIMITSCREENRES", "NOFILLRECT", "HOOKGLIDE", "HIDEDESKTOP", "LIMITSCREENRES", "NOFILLRECT", "HOOKGLIDE", "HIDEDESKTOP",
"STRETCHTIMERS", "NOFLIPEMULATION", "NOTEXTURES", "RETURNNULLREF", "STRETCHTIMERS", "NOFLIPEMULATION", "NOTEXTURES", "RETURNNULLREF",
"FINETIMING", "NATIVERES", "SUPPORTSVGA", "SUPPORTHDTV", "FINETIMING", "NATIVERES", "SUPPORTSVGA", "SUPPORTHDTV",
"RELEASEMOUSE", "FRAMECOMPENSATION", "HOTPATCH", "ENABLEHOTKEYS", "RELEASEMOUSE", "--FRAMECOMPENSATION--", "HOTPATCH", "ENABLEHOTKEYS",
"HOTPATCHALWAYS", "NOD3DRESET", "OVERRIDEREGISTRY", "HIDECDROMEMPTY", "HOTPATCHALWAYS", "NOD3DRESET", "OVERRIDEREGISTRY", "HIDECDROMEMPTY",
}; };
@ -111,7 +113,7 @@ static char *Flag6Names[32]={
"NOSYSMEMPRIMARY", "NOSYSMEMBACKBUF", "CONFIRMONCLOSE", "TERMINATEONCLOSE", "NOSYSMEMPRIMARY", "NOSYSMEMBACKBUF", "CONFIRMONCLOSE", "TERMINATEONCLOSE",
"FLIPEMULATION", "SETZBUFFERBITDEPTHS", "SHAREDDC", "WOW32REGISTRY", "FLIPEMULATION", "SETZBUFFERBITDEPTHS", "SHAREDDC", "WOW32REGISTRY",
"STRETCHMOVIES", "BYPASSMCI", "FIXPIXELZOOM", "REUSEEMULATEDDC", "STRETCHMOVIES", "BYPASSMCI", "FIXPIXELZOOM", "REUSEEMULATEDDC",
"", "", "", "", "CREATEDESKTOP", "NOWINDOWHOOKS", "--NOMOUSEPROC--", "",
"", "", "", "", "", "", "", "",
}; };
@ -265,21 +267,7 @@ void OutTraceHex(BYTE *bBuf, int iLen)
OutTrace("\n"); OutTrace("\n");
} }
static void dx_ToggleLogging() void SuppressIMEWindow()
{
// toggle LOGGING
if(dxw.dwTFlags & OUTTRACE){
OutTraceDW("Toggle logging OFF\n");
dxw.dwTFlags &= ~OUTTRACE;
}
else {
dxw.dwTFlags |= OUTTRACE;
OutTraceDW("Toggle logging ON\n");
}
GetHookInfo()->isLogging=(dxw.dwTFlags & OUTTRACE);
}
static void SuppressIMEWindow()
{ {
OutTraceDW("WindowProc: SUPPRESS IME\n"); OutTraceDW("WindowProc: SUPPRESS IME\n");
typedef BOOL (WINAPI *ImmDisableIME_Type)(DWORD); typedef BOOL (WINAPI *ImmDisableIME_Type)(DWORD);
@ -595,6 +583,9 @@ void AdjustWindowPos(HWND hwnd, DWORD width, DWORD height)
void HookWindowProc(HWND hwnd) void HookWindowProc(HWND hwnd)
{ {
WNDPROC pWindowProc; WNDPROC pWindowProc;
if(dxw.dwFlags6 & NOWINDOWHOOKS) return;
pWindowProc = (WNDPROC)(*pGetWindowLongA)(hwnd, GWL_WNDPROC); pWindowProc = (WNDPROC)(*pGetWindowLongA)(hwnd, GWL_WNDPROC);
// don't hook twice .... // don't hook twice ....
if ((pWindowProc == extWindowProc) || if ((pWindowProc == extWindowProc) ||
@ -660,549 +651,6 @@ void AdjustWindowFrame(HWND hwnd, DWORD width, DWORD height)
(*pInvalidateRect)(hwnd, NULL, TRUE); (*pInvalidateRect)(hwnd, NULL, TRUE);
} }
LRESULT CALLBACK extDialogWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
static int i=0;
static WINDOWPOS *wp;
WNDPROC pWindowProc;
static int t = -1;
if (t == -1)
t = (*pGetTickCount)();
int tn = (*pGetTickCount)();
OutTraceW("DEBUG: DialogWinMsg hwnd=%x msg=[0x%x]%s(%x,%x)\n", hwnd, message, ExplainWinMessage(message), wparam, lparam);
// optimization: don't invalidate too often!
// 200mSec seems a good compromise.
if (tn-t > 200) {
(*pInvalidateRect)(hwnd, NULL, TRUE);
t=tn;
}
pWindowProc=dxwws.GetProc(hwnd);
if(pWindowProc) return(*pCallWindowProcA)(pWindowProc, hwnd, message, wparam, lparam);
char *sMsg="ASSERT: DialogWinMsg pWindowProc=NULL !!!\n";
OutTraceDW(sMsg);
if (IsAssertEnabled) MessageBox(0, sMsg, "WindowProc", MB_OK | MB_ICONEXCLAMATION);
return NULL;
}
LRESULT CALLBACK extChildWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
static int i=0;
static WINDOWPOS *wp;
WNDPROC pWindowProc;
OutTraceW("DEBUG: ChildWinMsg hwnd=%x msg=[0x%x]%s(%x,%x)\n", hwnd, message, ExplainWinMessage(message), wparam, lparam);
if(dxw.Windowize){
switch(message){
// Cybermercs: it seems that all game menus are conveniently handled by the WindowProc routine,
// while the action screen get messages processed by the ChildWindowProc, that needs some different
// setting ..........
// Beware: Cybermercs handles some static info about cursor position handling, so that if you resize
// a menu it doesn't work correctly until you don't change screen.
case WM_MOUSEMOVE:
case WM_MOUSEWHEEL:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_RBUTTONDBLCLK:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_MBUTTONDBLCLK:
if(dxw.dwFlags1 & MODIFYMOUSE){ // mouse processing
POINT prev, curr;
// scale mouse coordinates
prev.x = LOWORD(lparam);
prev.y = HIWORD(lparam);
curr = prev;
if(message == WM_MOUSEWHEEL){ // v2.02.33 mousewheel fix
POINT upleft={0,0};
(*pClientToScreen)(dxw.GethWnd(), &upleft);
curr = dxw.SubCoordinates(curr, upleft);
}
//OutTraceC("ChildWindowProc: hwnd=%x pos XY prev=(%d,%d)\n", hwnd, prev.x, prev.y);
curr=dxw.FixCursorPos(curr); // Warn! the correction must refer to the main window hWnd, not the current hwnd one !!!
lparam = MAKELPARAM(curr.x, curr.y);
OutTraceC("ChildWindowProc: hwnd=%x pos XY=(%d,%d)->(%d,%d)\n", hwnd, prev.x, prev.y, curr.x, curr.y);
}
break;
default:
break;
}
}
pWindowProc=dxwws.GetProc(hwnd);
// v2.02.82: use CallWindowProc that handles WinProc handles
if(pWindowProc) return(*pCallWindowProcA)(pWindowProc, hwnd, message, wparam, lparam);
// should never get here ....
OutTraceDW("ChildWindowProc: no WndProc for CHILD hwnd=%x\n", hwnd);
return DefWindowProc(hwnd, message, wparam, lparam);
}
static void dx_UpdatePositionLock(HWND hwnd)
{
RECT rect;
POINT p={0,0};
(*pGetClientRect)(hwnd,&rect);
(*pClientToScreen)(hwnd,&p);
dxw.dwFlags1 |= LOCKWINPOS;
OutTraceDW("Toggle position lock ON\n");
dxw.InitWindowPos(p.x, p.y, rect.right-rect.left, rect.bottom-rect.top);
}
static void dx_TogglePositionLock(HWND hwnd)
{
// toggle position locking
if(dxw.dwFlags1 & LOCKWINPOS){
// unlock
OutTraceDW("Toggle position lock OFF\n");
dxw.dwFlags1 &= ~LOCKWINPOS;
}
else {
OutTraceDW("Toggle position lock ON\n");
dxw.dwFlags1 |= LOCKWINPOS;
dx_UpdatePositionLock(hwnd);
}
}
static void dx_ToggleFPS()
{
if(dxw.dwFlags2 & SHOWFPS){
dxw.dwFlags2 &= ~SHOWFPS;
OutTrace("ToggleFPS: SHOWFPS mode OFF\n");
}
else {
dxw.dwFlags2 |= SHOWFPS;
OutTrace("ToggleFPS: SHOWFPS mode ON\n");
}
}
static void dx_Cornerize(HWND hwnd)
{
static RECT WinRect = {0, 0, 0, 0};
static DWORD OldStyle, OldExtStyle;
// toggle ....
if (WinRect.right == 0){
OutTraceDW("DxWnd: entering corner mode\n");
(*pGetWindowRect)(hwnd, &WinRect);
OldStyle = (*pGetWindowLongA)(hwnd, GWL_STYLE);
OldExtStyle = (*pGetWindowLongA)(hwnd, GWL_EXSTYLE);
(*pSetWindowLongA)(hwnd, GWL_STYLE, WS_VISIBLE|WS_CLIPSIBLINGS|WS_OVERLAPPED);
(*pSetWindowLongA)(hwnd, GWL_EXSTYLE, 0);
(*pMoveWindow)(hwnd, 0, 0, dxw.GetScreenWidth(), dxw.GetScreenHeight(), TRUE);
}
else {
OutTraceDW("DxWnd: exiting corner mode\n");
(*pSetWindowLongA)(hwnd, GWL_STYLE, OldStyle);
(*pSetWindowLongA)(hwnd, GWL_EXSTYLE, OldExtStyle);
(*pMoveWindow)(hwnd, WinRect.left, WinRect.top, WinRect.right, WinRect.bottom, TRUE);
memset(&WinRect, 0, sizeof(WinRect));
}
dxw.ScreenRefresh();
}
LRESULT LastCursorPos;
LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
POINT prev, curr;
RECT rect;
static int i=0;
static int ClipCursorToggleState = 1;
WNDPROC pWindowProc;
extern void dxwFixWindowPos(char *, HWND, LPARAM);
extern LPRECT lpClipRegion;
static BOOL DoOnce = TRUE;
static BOOL IsToBeLocked;
static int LastTimeShift;
static int SaveTimeShift;
static BOOL TimeShiftToggle=TRUE;
extern void DDrawScreenShot();
if(DoOnce){
DoOnce=FALSE;
IsToBeLocked=(dxw.dwFlags1 & LOCKWINPOS);
LastTimeShift=SaveTimeShift=dxw.TimeShift;
}
// v2.1.93: adjust clipping region
if(IsTraceW){
char sPos[161];
sPos[160]=0;
sPos[0]=0;
switch(message){
case WM_WINDOWPOSCHANGING:
case WM_WINDOWPOSCHANGED:
LPWINDOWPOS wp;
wp = (LPWINDOWPOS)lparam;
sprintf_s(sPos, 160, " pos=(%d,%d) size=(%dx%d) flags=%x(%s)", wp->x, wp->y, wp->cx, wp->cy, wp->flags, ExplainWPFlags(wp->flags));
break;
case WM_MOVE:
sprintf_s(sPos, 160, " pos=(%d,%d)", HIWORD(lparam), LOWORD(lparam));
break;
case WM_SIZE:
static char *modes[5]={"RESTORED", "MINIMIZED", "MAXIMIZED", "MAXSHOW", "MAXHIDE"};
sprintf_s(sPos, 160, " mode=SIZE_%s size=(%dx%d)", modes[wparam % 5], HIWORD(lparam), LOWORD(lparam));
break;
}
OutTrace("WindowProc[%x]: WinMsg=[0x%x]%s(%x,%x) %s\n", hwnd, message, ExplainWinMessage(message), wparam, lparam, sPos);
}
if(dxw.dwFlags3 & FILTERMESSAGES){
switch(message){
case WM_NCMOUSEMOVE:
case WM_NCLBUTTONDOWN:
case WM_NCLBUTTONUP:
case WM_NCLBUTTONDBLCLK:
case WM_NCRBUTTONDOWN:
case WM_NCRBUTTONUP:
case WM_NCRBUTTONDBLCLK:
case WM_NCMBUTTONDOWN:
case WM_NCMBUTTONUP:
case WM_NCMBUTTONDBLCLK:
OutTraceDW("WindowProc[%x]: SUPPRESS WinMsg=[0x%x]%s(%x,%x)\n", hwnd, message, ExplainWinMessage(message), wparam, lparam);
return 0;
}
}
if(LastTimeShift != dxw.TimeShift){
extern void SetVSyncDelays(LPDIRECTDRAW);
extern LPDIRECTDRAW lpPrimaryDD;
if(dxw.dwFlags4 & STRETCHTIMERS) dxw.RenewTimers();
if(lpPrimaryDD) SetVSyncDelays(lpPrimaryDD);
LastTimeShift=dxw.TimeShift;
}
switch(message){
// v2.02.13: added WM_GETMINMAXINFO/WM_NCCALCSIZE interception - (see Actua Soccer 3 problems...)
//case WM_NCDESTROY:
// return 0;
case WM_GETMINMAXINFO:
if(dxw.dwFlags1 & LOCKWINPOS){
extern void dxwFixMinMaxInfo(char *, HWND, LPARAM);
dxwFixMinMaxInfo("WindowProc", hwnd, lparam);
return 0;
}
break;
case WM_NCCALCSIZE:
case WM_NCPAINT:
if((dxw.dwFlags1 & LOCKWINPOS) && (hwnd == dxw.GethWnd()) && dxw.IsFullScreen()){ // v2.02.30: don't alter child and other windows....
OutTraceDW("WindowProc: %s wparam=%x\n", ExplainWinMessage(message), wparam);
return (*pDefWindowProcA)(hwnd, message, wparam, lparam);
}
break;
case WM_NCCREATE:
if(dxw.dwFlags2 & SUPPRESSIME) SuppressIMEWindow();
break;
case WM_IME_SETCONTEXT:
case WM_IME_NOTIFY:
case WM_IME_CONTROL:
case WM_IME_COMPOSITIONFULL:
case WM_IME_SELECT:
case WM_IME_CHAR:
case WM_IME_REQUEST:
case WM_IME_KEYDOWN:
case WM_IME_KEYUP:
if(dxw.dwFlags2 & SUPPRESSIME){
OutTraceDW("WindowProc[%x]: SUPPRESS IME WinMsg=[0x%x]%s(%x,%x)\n", hwnd, message, ExplainWinMessage(message), wparam, lparam);
return 0;
}
break;
case WM_NCHITTEST:
if((dxw.dwFlags2 & FIXNCHITTEST) && (dxw.dwFlags1 & MODIFYMOUSE)){ // mouse processing
POINT cursor;
LRESULT ret;
ret=(*pDefWindowProcA)(hwnd, message, wparam, lparam);
if (ret==HTCLIENT) {
cursor.x=LOWORD(lparam);
cursor.y=HIWORD(lparam);
dxw.FixNCHITCursorPos(&cursor);
lparam = MAKELPARAM(cursor.x, cursor.y);
}
else
return ret;
}
break;
case WM_ERASEBKGND:
if(dxw.Windowize && dxw.IsDesktop(hwnd)){
OutTraceDW("WindowProc: WM_ERASEBKGND(%x,%x) - suppressed\n", wparam, lparam);
return 1; // 1 == OK, erased
}
break;
case WM_DISPLAYCHANGE:
if (dxw.Windowize && (dxw.dwFlags1 & LOCKWINPOS) && dxw.IsFullScreen()){
OutTraceDW("WindowProc: prevent WM_DISPLAYCHANGE depth=%d size=(%d,%d)\n",
wparam, LOWORD(lparam), HIWORD(lparam));
// v2.02.43: unless EMULATESURFACE is set, lock the screen resolution only, but not the color depth!
if(dxw.dwFlags1 & EMULATESURFACE) return 0;
// let rparam (color depth) change, but override lparam (screen width & height.)
lparam = MAKELPARAM((LONG)dxw.GetScreenWidth(), (LONG)dxw.GetScreenHeight());
//return 0;
}
break;
case WM_WINDOWPOSCHANGING:
case WM_WINDOWPOSCHANGED:
if(dxw.Windowize && dxw.IsFullScreen()){
if(dxw.dwFlags5 & NOWINPOSCHANGES){
OutTraceDW("WindowProc: %s - suppressed\n", message==WM_WINDOWPOSCHANGED ? "WM_WINDOWPOSCHANGED" : "WM_WINDOWPOSCHANGING");
return 0;
}
extern HWND hControlParentWnd;
LPWINDOWPOS wp;
wp = (LPWINDOWPOS)lparam;
dxwFixWindowPos("WindowProc", hwnd, lparam);
OutTraceDW("WindowProc: %s fixed size=(%d,%d)\n",
(message == WM_WINDOWPOSCHANGED) ? "WM_WINDOWPOSCHANGED" : "WM_WINDOWPOSCHANGING", wp->cx, wp->cy);
// try to lock main wind & control parent together
if((message==WM_WINDOWPOSCHANGED) && hControlParentWnd){
if(dxw.IsDesktop(hwnd)) {
POINT fo = dxw.GetFrameOffset();
(*pMoveWindow)(hControlParentWnd, wp->x+fo.x, wp->y+fo.y, wp->cx, wp->cy, TRUE);
}
}
// v2.03.30: in window mode, it seems that the WM_ACTIVATEAPP message is not sent to the main win.
// this PostMessage call recovers "Thorgal" block at the end of intro movie and "Championship Manager 03 04" cursor
if((message==WM_WINDOWPOSCHANGED) && (dxw.dwFlags6 & ACTIVATEAPP)){
PostMessage(hwnd, WM_ACTIVATEAPP, 1, 0);
}
}
break;
case WM_ENTERSIZEMOVE:
if(IsToBeLocked){
dxw.dwFlags1 &= ~LOCKWINPOS;
}
while((*pShowCursor)(1) < 0);
if(dxw.dwFlags1 & CLIPCURSOR) dxw.EraseClipCursor();
if(dxw.dwFlags1 & ENABLECLIPPING) (*pClipCursor)(NULL);
break;
case WM_EXITSIZEMOVE:
if(IsToBeLocked){
dxw.dwFlags1 |= LOCKWINPOS;
dx_UpdatePositionLock(hwnd);
}
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.dwFlags2 & REFRESHONRESIZE) dxw.ScreenRefresh();
if(dxw.dwFlags4 & HIDEDESKTOP) dxw.HideDesktop(dxw.GethWnd());
if(dxw.dwFlags5 & CENTERTOWIN) {
HDC thdc;
HWND w = dxw.GethWnd();
RECT client;
(*pGetClientRect)(w, &client);
thdc=(*pGDIGetDC)(w);
if(thdc) (*pGDIBitBlt)(thdc, client.left, client.top, client.right, client.bottom, 0, 0, 0, BLACKNESS);
}
break;
case WM_ACTIVATE:
// turn DirectInput bActive flag on & off .....
dxw.bActive = (LOWORD(wparam) == WA_ACTIVE || LOWORD(wparam) == WA_CLICKACTIVE) ? 1 : 0;
case WM_NCACTIVATE:
// turn DirectInput bActive flag on & off .....
if(message == WM_NCACTIVATE) dxw.bActive = wparam;
if(dxw.bActive) (*pSetWindowPos)(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
if(dxw.dwFlags1 & UNNOTIFY){
DefWindowProc(hwnd, message, wparam, lparam);
return false;
}
break;
case WM_NCMOUSEMOVE:
// Posted to a window when the cursor is moved within the nonclient area of the window.
// This message is posted to the window that contains the cursor.
// If a window has captured the mouse, this message is not posted.
// V2.1.90: on nonclient areas the cursor is always shown.
while((*pShowCursor)(1) < 0);
break;
case WM_MOUSEMOVE:
if(dxw.Windowize){
prev.x = LOWORD(lparam);
prev.y = HIWORD(lparam);
if ((dxw.dwFlags1 & HIDEHWCURSOR) && dxw.IsFullScreen()){
(*pGetClientRect)(hwnd, &rect);
if(prev.x >= 0 && prev.x < rect.right && prev.y >= 0 && prev.y < rect.bottom)
while((*pShowCursor)(0) >= 0);
else
while((*pShowCursor)(1) < 0);
}
else {
while((*pShowCursor)(1) < 0);
}
if(dxw.dwFlags1 & MODIFYMOUSE){ // mouse processing
// scale mouse coordinates
curr=dxw.FixCursorPos(prev); //v2.02.30
lparam = MAKELPARAM(curr.x, curr.y);
OutTraceC("WindowProc: hwnd=%x pos XY=(%d,%d)->(%d,%d)\n", hwnd, prev.x, prev.y, curr.x, curr.y);
}
GetHookInfo()->CursorX=LOWORD(lparam);
GetHookInfo()->CursorY=HIWORD(lparam);
}
break;
// fall through cases:
case WM_MOUSEWHEEL:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_RBUTTONDBLCLK:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_MBUTTONDBLCLK:
if(dxw.Windowize){
if((dxw.dwFlags1 & CLIPCURSOR) && ClipCursorToggleState) dxw.SetClipCursor();
if(dxw.dwFlags1 & MODIFYMOUSE){ // mouse processing
// scale mouse coordinates
prev.x = LOWORD(lparam);
prev.y = HIWORD(lparam);
curr = prev;
if(message == WM_MOUSEWHEEL){ // v2.02.33 mousewheel fix
POINT upleft={0,0};
(*pClientToScreen)(dxw.GethWnd(), &upleft);
curr = dxw.SubCoordinates(curr, upleft);
}
curr=dxw.FixCursorPos(curr); //v2.02.30
lparam = MAKELPARAM(curr.x, curr.y);
OutTraceC("WindowProc: hwnd=%x pos XY=(%d,%d)->(%d,%d)\n", hwnd, prev.x, prev.y, curr.x, curr.y);
}
GetHookInfo()->CursorX=LOWORD(lparam);
GetHookInfo()->CursorY=HIWORD(lparam);
}
break;
case WM_SETFOCUS:
OutTraceDW("WindowProc: hwnd=%x GOT FOCUS\n", hwnd);
if (dxw.dwFlags1 & ENABLECLIPPING) 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);
break;
case WM_CLOSE:
// Beware: closing main window does not always mean that the program is about to terminate!!!
extern void gShowHideTaskBar(BOOL);
if(dxw.dwFlags6 & CONFIRMONCLOSE){
OutTraceDW("WindowProc: WM_CLOSE - terminating process?\n");
if (MessageBoxA(NULL, "Do you really want to exit the game?", "DxWnd", MB_YESNO | MB_TASKMODAL) != IDYES) return FALSE;
}
if(dxw.dwFlags6 & HIDETASKBAR) gShowHideTaskBar(FALSE);
if(dxw.dwFlags3 & FORCE16BPP) RecoverScreenMode();
if(dxw.dwFlags6 & TERMINATEONCLOSE) TerminateProcess(GetCurrentProcess(),0);
break;
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
if(!(dxw.dwFlags4 & ENABLEHOTKEYS)) break;
OutTraceW("event %s wparam=%x lparam=%x\n", (message==WM_SYSKEYDOWN)?"WM_SYSKEYDOWN":"WM_KEYDOWN", wparam, lparam);
UINT DxWndKey;
DxWndKey=dxw.MapKeysConfig(message, lparam, wparam);
switch (DxWndKey){
case DXVK_CLIPTOGGLE:
if(dxw.dwFlags1 & CLIPCURSOR){
OutTraceDW("WindowProc: WM_SYSKEYDOWN key=%x ToggleState=%x\n",wparam,ClipCursorToggleState);
ClipCursorToggleState = !ClipCursorToggleState;
ClipCursorToggleState ? dxw.SetClipCursor() : dxw.EraseClipCursor();
}
break;
case DXVK_REFRESH:
dxw.ScreenRefresh();
break;
case DXVK_LOGTOGGLE:
dx_ToggleLogging();
break;
case DXVK_PLOCKTOGGLE:
dx_TogglePositionLock(hwnd);
break;
case DXVK_FPSTOGGLE:
dx_ToggleFPS();
break;
case DXVK_CORNERIZE:
dx_Cornerize(hwnd);
break;
case DXVK_TIMEFAST:
case DXVK_TIMESLOW:
if (dxw.dwFlags2 & TIMESTRETCH) {
if (DxWndKey == DXVK_TIMESLOW && (dxw.TimeShift < 8)) dxw.TimeShift++;
if (DxWndKey == DXVK_TIMEFAST && (dxw.TimeShift > -8)) dxw.TimeShift--;
GetHookInfo()->TimeShift=dxw.TimeShift;
OutTrace("Time Stretch: shift=%d speed=%s\n", dxw.TimeShift, dxw.GetTSCaption());
}
break;
case DXVK_TIMETOGGLE:
if (dxw.dwFlags2 & TIMESTRETCH) {
if(TimeShiftToggle){
SaveTimeShift=dxw.TimeShift;
dxw.TimeShift=0;
}
else{
dxw.TimeShift=SaveTimeShift;
}
TimeShiftToggle = !TimeShiftToggle;
GetHookInfo()->TimeShift=dxw.TimeShift;
}
break;
case DXVK_ALTF4:
if (dxw.dwFlags1 & HANDLEALTF4) {
OutTraceDW("WindowProc: WM_SYSKEYDOWN(ALT-F4) - terminating process\n");
TerminateProcess(GetCurrentProcess(),0);
}
break;
case DXVK_PRINTSCREEN:
DDrawScreenShot();
break;
default:
break;
}
default:
break;
}
if (dxw.dwFlags1 & AUTOREFRESH) dxw.ScreenRefresh();
pWindowProc=dxwws.GetProc(hwnd);
//OutTraceB("WindowProc: pWindowProc=%x extWindowProc=%x message=%x(%s) wparam=%x lparam=%x\n",
// (*pWindowProc), extWindowProc, message, ExplainWinMessage(message), wparam, lparam);
if(pWindowProc) {
LRESULT ret;
// v2.02.36: use CallWindowProc that handles WinProc handles
ret=(*pCallWindowProcA)(pWindowProc, hwnd, message, wparam, lparam);
// save last NCHITTEST cursor position for use with KEEPASPECTRATIO scaling
if(message==WM_NCHITTEST) LastCursorPos=ret;
// v2.1.89: if FORCEWINRESIZE add standard processing for the missing WM_NC* messages
if(dxw.dwFlags2 & FORCEWINRESIZE){
switch(message){
//case WM_NCHITTEST:
//case WM_NCPAINT:
//case WM_NCMOUSEMOVE:
//case WM_NCCALCSIZE:
//case WM_NCACTIVATE:
case WM_SETCURSOR: // shows a different cursor when moving on borders
case WM_NCLBUTTONDOWN: // intercepts mouse down on borders
case WM_NCLBUTTONUP: // intercepts mouse up on borders
ret=(*pDefWindowProcA)(hwnd, message, wparam, lparam);
break;
}
}
return ret;
}
//OutTraceDW("ASSERT: WindowProc mismatch hwnd=%x\n", hwnd);
// ??? maybe it's a normal condition, whenever you don't have a WindowProc routine
// like in Commandos 2. Flag it?
char sMsg[81];
sprintf(sMsg,"ASSERT: WindowProc mismatch hwnd=%x\n", hwnd);
OutTraceDW(sMsg);
if (IsAssertEnabled) MessageBox(0, sMsg, "WindowProc", MB_OK | MB_ICONEXCLAMATION);
return (*pDefWindowProcA)(hwnd, message, wparam, lparam);
}
void HookSysLibsInit() void HookSysLibsInit()
{ {
static BOOL DoOnce = FALSE; static BOOL DoOnce = FALSE;
@ -1227,7 +675,7 @@ static void SaveScreenMode()
InitDevMode.dmPelsWidth, InitDevMode.dmPelsHeight, InitDevMode.dmBitsPerPel); InitDevMode.dmPelsWidth, InitDevMode.dmPelsHeight, InitDevMode.dmBitsPerPel);
} }
static void RecoverScreenMode() void RecoverScreenMode()
{ {
DEVMODE CurrentDevMode; DEVMODE CurrentDevMode;
BOOL res; BOOL res;
@ -1480,54 +928,6 @@ void SetSingleProcessAffinity(void)
OutTraceE("SetProcessAffinityMask: ERROR err=%d\n", GetLastError()); OutTraceE("SetProcessAffinityMask: ERROR err=%d\n", GetLastError());
} }
extern HHOOK hMouseHook;
LRESULT CALLBACK MessageHook(int code, WPARAM wParam, LPARAM lParam)
{
static BOOL SizeMoving = FALSE;
if(code == HC_ACTION){
if(dxw.IsFullScreen()){
MSG *msg;
msg = (MSG *)lParam;
OutTraceC("MessageHook: hwnd=%x message=%d(%s) remove=%d pt=(%d,%d)\n",
msg->hwnd, msg->message, ExplainWinMessage(msg->message), msg->wParam, msg->pt.x, msg->pt.y);
switch(msg->message){
case WM_ENTERSIZEMOVE: SizeMoving = TRUE; break;
case WM_EXITSIZEMOVE: SizeMoving = FALSE; break;
}
// do not try to fix coordinates for points outside the client area!!
// in theory, that should primarily depend on the message type, but this is the way it works ...
// do not do the fixing also when in sizemove mode
RECT client;
client=dxw.GetUnmappedScreenRect();
if ((SizeMoving) ||
(msg->pt.x < client.left) ||
(msg->pt.y < client.top) ||
(msg->pt.x > client.right) ||
(msg->pt.y > client.bottom)){
// do nothing
}
else {
// fix the message point coordinates
POINT upleft={0,0};
// v2.03.36: offset to be calculated from target window
(*pClientToScreen)(msg->hwnd, &upleft);
msg->pt = dxw.SubCoordinates(msg->pt, upleft);
msg->pt=dxw.FixCursorPos(msg->pt);
// beware: needs fix for mousewheel?
if((msg->message <= WM_MOUSELAST) && (msg->message >= WM_MOUSEFIRST)) msg->lParam = MAKELPARAM(msg->pt.x, msg->pt.y);
OutTraceC("MessageHook: fixed lparam/pt=(%d,%d)\n", msg->pt.x, msg->pt.y);
GetHookInfo()->CursorX=(short)msg->pt.x;
GetHookInfo()->CursorY=(short)msg->pt.y;
}
}
}
return CallNextHookEx(hMouseHook, code, wParam, lParam);
}
static void ReplaceRDTSC() static void ReplaceRDTSC()
{ {
typedef BOOL (WINAPI *GetModuleInformation_Type)(HANDLE, HMODULE, LPMODULEINFO, DWORD); typedef BOOL (WINAPI *GetModuleInformation_Type)(HANDLE, HMODULE, LPMODULEINFO, DWORD);
@ -1734,6 +1134,8 @@ HWND CreateVirtualDesktop(LPRECT TargetPos)
} }
} }
extern HHOOK hMouseHook;
void HookInit(TARGETMAP *target, HWND hwnd) void HookInit(TARGETMAP *target, HWND hwnd)
{ {
HMODULE base; HMODULE base;

View File

@ -327,15 +327,6 @@ POINT dxwCore::FixCursorPos(POINT prev)
} }
if(dxw.dwFlags4 & RELEASEMOUSE){ if(dxw.dwFlags4 & RELEASEMOUSE){
#if 0
if ((curr.x < 0) ||
(curr.y < 0) ||
(curr.x > w) ||
(curr.y > h)){
curr.x = w / 2;
curr.y = h / 2;
}
#else
if ((curr.x < 0) || (curr.y < 0) || (curr.x > w) || (curr.y > h)){ if ((curr.x < 0) || (curr.y < 0) || (curr.x > w) || (curr.y > h)){
if(IsWithin){ if(IsWithin){
int RestX, RestY; int RestX, RestY;
@ -356,7 +347,6 @@ POINT dxwCore::FixCursorPos(POINT prev)
IsWithin = TRUE; IsWithin = TRUE;
LastPos = curr; LastPos = curr;
} }
#endif
} }
else { else {
if (curr.x < 0) curr.x = 0; if (curr.x < 0) curr.x = 0;
@ -369,18 +359,18 @@ POINT dxwCore::FixCursorPos(POINT prev)
if (h) curr.y = (curr.y * dxw.GetScreenHeight()) / h; if (h) curr.y = (curr.y * dxw.GetScreenHeight()) / h;
} }
if(dxw.dwFlags4 & FRAMECOMPENSATION){ //if(dxw.dwFlags4 & FRAMECOMPENSATION){
static int dx, dy, todo=TRUE; // static int dx, dy, todo=TRUE;
if (todo){ // if (todo){
POINT FrameOffset = dxw.GetFrameOffset(); // POINT FrameOffset = dxw.GetFrameOffset();
dx=FrameOffset.x; // dx=FrameOffset.x;
dy=FrameOffset.y; // dy=FrameOffset.y;
OutTraceC("GetCursorPos: frame compensation=(%d,%d)\n", dx, dy); // OutTraceC("GetCursorPos: frame compensation=(%d,%d)\n", dx, dy);
todo=FALSE; // todo=FALSE;
} // }
curr.x += dx; // curr.x += dx;
curr.y += dy; // curr.y += dy;
} //}
if((dxw.dwFlags1 & ENABLECLIPPING) && lpClipRegion){ if((dxw.dwFlags1 & ENABLECLIPPING) && lpClipRegion){
// v2.1.93: // v2.1.93:

View File

@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "TlHelp32.h" #include "TlHelp32.h"
#define VERSION "2.03.40" #define VERSION "2.03.41"
#define DDTHREADLOCK 1 #define DDTHREADLOCK 1
//#define LOCKTHREADS //#define LOCKTHREADS

Binary file not shown.

View File

@ -445,6 +445,10 @@
RelativePath=".\kernel32.cpp" RelativePath=".\kernel32.cpp"
> >
</File> </File>
<File
RelativePath=".\msghook.cpp"
>
</File>
<File <File
RelativePath=".\msvfw.cpp" RelativePath=".\msvfw.cpp"
> >
@ -469,6 +473,10 @@
RelativePath=".\winmm.cpp" RelativePath=".\winmm.cpp"
> >
</File> </File>
<File
RelativePath=".\winproc.cpp"
>
</File>
<File <File
RelativePath=".\wintrust.cpp" RelativePath=".\wintrust.cpp"
> >

View File

@ -42,6 +42,9 @@ COLORREF WINAPI extSetBkColor(HDC, COLORREF);
COLORREF WINAPI extSetTextColor(HDC hdc, COLORREF crColor); COLORREF WINAPI extSetTextColor(HDC hdc, COLORREF crColor);
int WINAPI extSetBkMode(HDC, int); int WINAPI extSetBkMode(HDC, int);
*/ */
typedef int (WINAPI *SetDIBits_Type)(HDC, HBITMAP, UINT, UINT, const VOID *, const BITMAPINFO *, UINT);
int WINAPI extSetDIBits(HDC, HBITMAP, UINT, UINT, const VOID *, const BITMAPINFO *, UINT);
SetDIBits_Type pSetDIBits = NULL;
static HookEntry_Type Hooks[]={ static HookEntry_Type Hooks[]={
@ -56,14 +59,12 @@ static HookEntry_Type Hooks[]={
{HOOK_HOT_CANDIDATE, "GetSystemPaletteEntries", (FARPROC)GetSystemPaletteEntries, (FARPROC *)&pGDIGetSystemPaletteEntries, (FARPROC)extGetSystemPaletteEntries}, {HOOK_HOT_CANDIDATE, "GetSystemPaletteEntries", (FARPROC)GetSystemPaletteEntries, (FARPROC *)&pGDIGetSystemPaletteEntries, (FARPROC)extGetSystemPaletteEntries},
{HOOK_HOT_CANDIDATE, "SetSystemPaletteUse", (FARPROC)SetSystemPaletteUse, (FARPROC *)&pSetSystemPaletteUse, (FARPROC)extSetSystemPaletteUse}, {HOOK_HOT_CANDIDATE, "SetSystemPaletteUse", (FARPROC)SetSystemPaletteUse, (FARPROC *)&pSetSystemPaletteUse, (FARPROC)extSetSystemPaletteUse},
{HOOK_IAT_CANDIDATE, "StretchDIBits", (FARPROC)StretchDIBits, (FARPROC *)&pStretchDIBits, (FARPROC)extStretchDIBits}, {HOOK_IAT_CANDIDATE, "StretchDIBits", (FARPROC)StretchDIBits, (FARPROC *)&pStretchDIBits, (FARPROC)extStretchDIBits},
//{HOOK_IAT_CANDIDATE, "SetDIBitsToDevice", (FARPROC)NULL, (FARPROC *)&pSetDIBitsToDevice, (FARPROC)extSetDIBitsToDevice},
//{HOOK_IAT_CANDIDATE, "CreateCompatibleBitmap", (FARPROC)NULL, (FARPROC *)&pCreateCompatibleBitmap, (FARPROC)extCreateCompatibleBitmap}, //{HOOK_IAT_CANDIDATE, "CreateCompatibleBitmap", (FARPROC)NULL, (FARPROC *)&pCreateCompatibleBitmap, (FARPROC)extCreateCompatibleBitmap},
//{HOOK_IAT_CANDIDATE, "SetMapMode", (FARPROC)NULL, (FARPROC *)NULL, (FARPROC)extSetMapMode}, //{HOOK_IAT_CANDIDATE, "SetMapMode", (FARPROC)NULL, (FARPROC *)NULL, (FARPROC)extSetMapMode},
{HOOK_IAT_CANDIDATE, "SetPixelFormat", (FARPROC)NULL, (FARPROC *)&pGDISetPixelFormat, (FARPROC)extGDISetPixelFormat}, {HOOK_IAT_CANDIDATE, "SetPixelFormat", (FARPROC)NULL, (FARPROC *)&pGDISetPixelFormat, (FARPROC)extGDISetPixelFormat},
{HOOK_IAT_CANDIDATE, "GetPixelFormat", (FARPROC)NULL, (FARPROC *)&pGDIGetPixelFormat, (FARPROC)extGDIGetPixelFormat}, {HOOK_IAT_CANDIDATE, "GetPixelFormat", (FARPROC)NULL, (FARPROC *)&pGDIGetPixelFormat, (FARPROC)extGDIGetPixelFormat},
{HOOK_IAT_CANDIDATE, "ChoosePixelFormat", (FARPROC)NULL, (FARPROC *)&pChoosePixelFormat, (FARPROC)extChoosePixelFormat}, {HOOK_IAT_CANDIDATE, "ChoosePixelFormat", (FARPROC)NULL, (FARPROC *)&pChoosePixelFormat, (FARPROC)extChoosePixelFormat},
{HOOK_IAT_CANDIDATE, "DescribePixelFormat", (FARPROC)NULL, (FARPROC *)&pDescribePixelFormat, (FARPROC)extDescribePixelFormat}, {HOOK_IAT_CANDIDATE, "DescribePixelFormat", (FARPROC)NULL, (FARPROC *)&pDescribePixelFormat, (FARPROC)extDescribePixelFormat},
{HOOK_HOT_CANDIDATE, "GetPaletteEntries", (FARPROC)GetPaletteEntries, (FARPROC *)&pGetPaletteEntries, (FARPROC)extGetPaletteEntries}, {HOOK_HOT_CANDIDATE, "GetPaletteEntries", (FARPROC)GetPaletteEntries, (FARPROC *)&pGetPaletteEntries, (FARPROC)extGetPaletteEntries},
{HOOK_HOT_CANDIDATE, "GetSystemPaletteUse", (FARPROC)GetSystemPaletteUse, (FARPROC *)&pGetSystemPaletteUse, (FARPROC)extGetSystemPaletteUse}, {HOOK_HOT_CANDIDATE, "GetSystemPaletteUse", (FARPROC)GetSystemPaletteUse, (FARPROC *)&pGetSystemPaletteUse, (FARPROC)extGetSystemPaletteUse},
#ifdef TRACEPALETTE #ifdef TRACEPALETTE
@ -84,6 +85,7 @@ static HookEntry_Type RemapHooks[]={
{HOOK_IAT_CANDIDATE, "SetDIBitsToDevice", (FARPROC)NULL, (FARPROC *)&pSetDIBitsToDevice, (FARPROC)extSetDIBitsToDevice}, // does the stretching {HOOK_IAT_CANDIDATE, "SetDIBitsToDevice", (FARPROC)NULL, (FARPROC *)&pSetDIBitsToDevice, (FARPROC)extSetDIBitsToDevice}, // does the stretching
{HOOK_IAT_CANDIDATE, "GetRgnBox", (FARPROC)NULL, (FARPROC *)&pGetRgnBox, (FARPROC)extGetRgnBox}, {HOOK_IAT_CANDIDATE, "GetRgnBox", (FARPROC)NULL, (FARPROC *)&pGetRgnBox, (FARPROC)extGetRgnBox},
//{HOOK_IAT_CANDIDATE, "GetRegionData", (FARPROC)NULL, (FARPROC *)&pGetRegionData, (FARPROC)extGetRegionData}, //{HOOK_IAT_CANDIDATE, "GetRegionData", (FARPROC)NULL, (FARPROC *)&pGetRegionData, (FARPROC)extGetRegionData},
//{HOOK_HOT_CANDIDATE, "SetDIBits", (FARPROC)SetDIBits, (FARPROC *)&pSetDIBits, (FARPROC)extSetDIBits},
{HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator {HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator
}; };
@ -644,6 +646,13 @@ UINT WINAPI extGetPaletteEntries(HPALETTE hpal, UINT iStartIndex, UINT nEntries,
OutTraceDW("GDI.GetPaletteEntries: hpal=%x iStartIndex=%d nEntries=%d\n", hpal, iStartIndex, nEntries); OutTraceDW("GDI.GetPaletteEntries: hpal=%x iStartIndex=%d nEntries=%d\n", hpal, iStartIndex, nEntries);
res=(*pGetPaletteEntries)(hpal, iStartIndex, nEntries, lppe); res=(*pGetPaletteEntries)(hpal, iStartIndex, nEntries, lppe);
OutTraceDW("GDI.GetPaletteEntries: res-nEntries=%d\n", res); OutTraceDW("GDI.GetPaletteEntries: res-nEntries=%d\n", res);
if(hpal==0) {
if((res == 0) && (dxw.dwFlags1 & EMULATESURFACE)) {
res = extGetSystemPaletteEntries(0, iStartIndex, nEntries, lppe);
mySetPalette(iStartIndex, nEntries, lppe);
}
res=(nEntries > 256) ? nEntries : 256; // "M.I.B." patch ....
}
if(IsDebug && res) dxw.DumpPalette(res, &lppe[iStartIndex]); if(IsDebug && res) dxw.DumpPalette(res, &lppe[iStartIndex]);
//mySetPalette(0, nEntries, lppe); //mySetPalette(0, nEntries, lppe);
return res; return res;
@ -1159,6 +1168,23 @@ int WINAPI extStretchDIBits(HDC hdc, int XDest, int YDest, int nDestWidth, int n
return ret; return ret;
} }
int WINAPI extSetDIBits(HDC hdc, HBITMAP hbmp, UINT uStartScan, UINT cScanLines, const VOID *lpvBits, const BITMAPINFO *lpbmi, UINT fuColorUse)
{
int ret;
BITMAPINFOHEADER *bmi;
OutTraceDW("SetDIBits: hdc=%x hbmp=%x lines=(%d,%d) ColorUse=%x\n", hdc, hbmp, uStartScan, cScanLines, fuColorUse);
bmi=(BITMAPINFOHEADER *)&(lpbmi->bmiHeader);
OutTraceDW("SetDIBits: BitmapInfo dim=(%dx%d) Planes=%d BPP=%d Compression=%x SizeImage=%x\n",
bmi->biWidth, bmi->biHeight, bmi->biPlanes, bmi->biBitCount, bmi->biCompression, bmi->biSizeImage);
ret = (*pSetDIBits)(hdc, hbmp, uStartScan, cScanLines, lpvBits, lpbmi, fuColorUse);
OutTraceDW("SetDIBits: ret=%d\n", ret);
return ret;
//return cScanLines;
//return (*pSetDIBits)(hdc, hbmp, uStartScan, cScanLines, lpvBits, lpbmi, DIB_PAL_COLORS);
//return (*pSetDIBits)(hdc, hbmp, uStartScan, cScanLines, lpvBits, lpbmi, DIB_RGB_COLORS);
}
int WINAPI extSetDIBitsToDevice(HDC hdc, int XDest, int YDest, DWORD dwWidth, DWORD dwHeight, int XSrc, int YSrc, UINT uStartScan, UINT cScanLines, int WINAPI extSetDIBitsToDevice(HDC hdc, int XDest, int YDest, DWORD dwWidth, DWORD dwHeight, int XSrc, int YSrc, UINT uStartScan, UINT cScanLines,
const VOID *lpvBits, const BITMAPINFO *lpbmi, UINT fuColorUse) const VOID *lpvBits, const BITMAPINFO *lpbmi, UINT fuColorUse)
{ {

64
dll/msghook.cpp Normal file
View File

@ -0,0 +1,64 @@
#define _WIN32_WINNT 0x0600
#define WIN32_LEAN_AND_MEAN
#define _CRT_SECURE_NO_DEPRECATE 1
#include <windows.h>
#include <stdio.h>
#include <stdarg.h>
#include "dxwnd.h"
#include "dxwcore.hpp"
#include "dxhelper.h"
extern HHOOK hMouseHook;
LRESULT CALLBACK MessageHook(int code, WPARAM wParam, LPARAM lParam)
{
static BOOL SizeMoving = FALSE;
if(code == HC_ACTION){
if(dxw.IsFullScreen()){
MSG *msg;
msg = (MSG *)lParam;
OutTraceC("MessageHook: hwnd=%x message=%d(%s) remove=%d pt=(%d,%d)\n",
msg->hwnd, msg->message, ExplainWinMessage(msg->message), msg->wParam, msg->pt.x, msg->pt.y);
switch(msg->message){
case WM_ENTERSIZEMOVE: SizeMoving = TRUE; break;
case WM_EXITSIZEMOVE: SizeMoving = FALSE; break;
}
// do not try to fix coordinates for points outside the client area!!
// in theory, that should primarily depend on the message type, but this is the way it works ...
// do not do the fixing also when in sizemove mode
RECT client;
client=dxw.GetUnmappedScreenRect();
if ((SizeMoving) ||
(msg->pt.x < client.left) ||
(msg->pt.y < client.top) ||
(msg->pt.x > client.right) ||
(msg->pt.y > client.bottom)){
// do nothing
}
else {
// fix the message point coordinates
POINT upleft={0,0};
POINT pt;
// v2.03.36: offset to be calculated from target window
(*pClientToScreen)(msg->hwnd, &upleft);
pt = msg->pt;
pt = dxw.SubCoordinates(pt, upleft);
pt=dxw.FixCursorPos(pt);
msg->pt = pt;
// beware: needs fix for mousewheel?
// if NOMOUSEPROC fix point x,y coordinates only to NON MOUSE messages that won't be fixed by WindowProc hooker
// NOMOUSEPROC is required by "X-Files", must be off for "Star Trek Armada" !!!
// if((msg->message <= WM_MOUSELAST) && (msg->message >= WM_MOUSEFIRST) && !(dxw.dwFlags6 & NOMOUSEPROC)) msg->lParam = MAKELPARAM(pt.x, pt.y);
if((msg->message <= WM_MOUSELAST) && (msg->message >= WM_MOUSEFIRST)) msg->lParam = MAKELPARAM(pt.x, pt.y);
OutTraceC("MessageHook: fixed hwnd=%x lparam/pt=(%d,%d)\n", msg->hwnd, pt.x, pt.y);
GetHookInfo()->CursorX=(short)pt.x;
GetHookInfo()->CursorY=(short)pt.y;
}
}
}
return CallNextHookEx(hMouseHook, code, wParam, lParam);
}

View File

@ -664,7 +664,7 @@ LONG WINAPI extGetWindowLong(GetWindowLong_Type pGetWindowLong, char *ApiName, H
res=(*pGetWindowLong)(hwnd, nIndex); res=(*pGetWindowLong)(hwnd, nIndex);
OutTraceDW("%s: hwnd=%x, Index=%x(%s) res=%x\n", ApiName, hwnd, nIndex, ExplainSetWindowIndex(nIndex), res); OutTraceB("%s: hwnd=%x, Index=%x(%s) res=%x\n", ApiName, hwnd, nIndex, ExplainSetWindowIndex(nIndex), res);
if((nIndex==GWL_WNDPROC)||(nIndex==DWL_DLGPROC)){ if((nIndex==GWL_WNDPROC)||(nIndex==DWL_DLGPROC)){
WNDPROC wp; WNDPROC wp;
@ -731,7 +731,9 @@ LONG WINAPI extSetWindowLong(HWND hwnd, int nIndex, LONG dwNewLong, SetWindowLon
} }
} }
if (((nIndex==GWL_WNDPROC)||(nIndex==DWL_DLGPROC)) && dxw.IsFullScreen()){ // v2.02.51 - see A10 Cuba.... if (((nIndex==GWL_WNDPROC)||(nIndex==DWL_DLGPROC)) &&
dxw.IsFullScreen() && // v2.02.51 - see A10 Cuba....
!(dxw.dwFlags6 & NOWINDOWHOOKS)){ // v2.03.41 - debug flag
WNDPROC lres; WNDPROC lres;
WNDPROC OldProc; WNDPROC OldProc;
// GPL fix // GPL fix
@ -990,6 +992,7 @@ BOOL WINAPI extSetCursorPos(int x, int y)
} }
if(dxw.dwFlags1 & MODIFYMOUSE){ if(dxw.dwFlags1 & MODIFYMOUSE){
#if 0
POINT cur; POINT cur;
RECT rect; RECT rect;
@ -1018,6 +1021,15 @@ BOOL WINAPI extSetCursorPos(int x, int y)
} }
x = cur.x; x = cur.x;
y = cur.y; y = cur.y;
#else
// v2.03.41
POINT cur;
cur.x = x;
cur.y = y;
dxw.MapWindow(&cur);
x = cur.x;
y = cur.y;
#endif
} }
res=0; res=0;
@ -1319,6 +1331,8 @@ static void HookChildWndProc(HWND hwnd, DWORD dwStyle, LPCTSTR ApiName)
long res; long res;
WNDPROC pWindowProc; WNDPROC pWindowProc;
if(dxw.dwFlags6 & NOWINDOWHOOKS) return;
pWindowProc = (WNDPROC)(*pGetWindowLongA)(hwnd, GWL_WNDPROC); pWindowProc = (WNDPROC)(*pGetWindowLongA)(hwnd, GWL_WNDPROC);
if((pWindowProc == extWindowProc) || if((pWindowProc == extWindowProc) ||
(pWindowProc == extChildWindowProc) || (pWindowProc == extChildWindowProc) ||
@ -2138,7 +2152,8 @@ HWND WINAPI extCreateDialogIndirectParam(HINSTANCE hInstance, LPCDLGTEMPLATE lpT
dxw.SetFullScreen(FullScreen); dxw.SetFullScreen(FullScreen);
// v2.02.73: redirect lpDialogFunc only when it is nor NULL // v2.02.73: redirect lpDialogFunc only when it is nor NULL
if(lpDialogFunc) { if( lpDialogFunc &&
!(dxw.dwFlags6 & NOWINDOWHOOKS)){ // v2.03.41 - debug option
dxwws.PutProc(RetHWND, (WNDPROC)lpDialogFunc); dxwws.PutProc(RetHWND, (WNDPROC)lpDialogFunc);
if(!(*pSetWindowLongA)(RetHWND, DWL_DLGPROC, (LONG)extDialogWindowProc)) if(!(*pSetWindowLongA)(RetHWND, DWL_DLGPROC, (LONG)extDialogWindowProc))
OutTraceE("SetWindowLong: ERROR err=%d at %d\n", GetLastError(), __LINE__); OutTraceE("SetWindowLong: ERROR err=%d at %d\n", GetLastError(), __LINE__);
@ -2161,7 +2176,8 @@ HWND WINAPI extCreateDialogParam(HINSTANCE hInstance, LPCTSTR lpTemplateName, HW
dxw.SetFullScreen(FullScreen); dxw.SetFullScreen(FullScreen);
// v2.02.73: redirect lpDialogFunc only when it is nor NULL: fix for "LEGO Stunt Rally" // v2.02.73: redirect lpDialogFunc only when it is nor NULL: fix for "LEGO Stunt Rally"
if(lpDialogFunc) { if( lpDialogFunc &&
!(dxw.dwFlags6 & NOWINDOWHOOKS)){ // v2.03.41 - debug option
dxwws.PutProc(RetHWND, (WNDPROC)lpDialogFunc); dxwws.PutProc(RetHWND, (WNDPROC)lpDialogFunc);
if(!(*pSetWindowLongA)(RetHWND, DWL_DLGPROC, (LONG)extDialogWindowProc)) if(!(*pSetWindowLongA)(RetHWND, DWL_DLGPROC, (LONG)extDialogWindowProc))
OutTraceE("SetWindowLong: ERROR err=%d at %d\n", GetLastError(), __LINE__); OutTraceE("SetWindowLong: ERROR err=%d at %d\n", GetLastError(), __LINE__);
@ -2916,9 +2932,8 @@ BOOL WINAPI extSetForegroundWindow(HWND hwnd)
return res; return res;
} }
HOOKPROC glpMouseHookProcessFunction;
HOOKPROC glpMessageHookProcessFunction;
/* /*
HOOKPROC glpMouseHookProcessFunction;
LRESULT CALLBACK extMouseHookProc(int code, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK extMouseHookProc(int code, WPARAM wParam, LPARAM lParam)
{ {
LRESULT ret; LRESULT ret;
@ -2932,6 +2947,8 @@ LRESULT CALLBACK extMouseHookProc(int code, WPARAM wParam, LPARAM lParam)
} }
*/ */
HOOKPROC glpMessageHookProcessFunction;
LRESULT CALLBACK extMessageHookProc(int code, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK extMessageHookProc(int code, WPARAM wParam, LPARAM lParam)
{ {
LRESULT ret; LRESULT ret;
@ -2941,7 +2958,9 @@ LRESULT CALLBACK extMessageHookProc(int code, WPARAM wParam, LPARAM lParam)
if(pMessage){ if(pMessage){
UINT message = pMessage->message; UINT message = pMessage->message;
if ((message >= 0x600) || // custom messages if ((message >= 0x600) || // custom messages
((message >= WM_KEYFIRST) && (message <= WM_KEYLAST))) // keyboard messages ((message >= WM_KEYFIRST) && (message <= WM_KEYLAST)) || // keyboard messages
((message >= WM_MOUSEFIRST) && (message <= WM_MOUSELAST)) // mouse messages
)
ret = (*glpMessageHookProcessFunction)(code, wParam, lParam); ret = (*glpMessageHookProcessFunction)(code, wParam, lParam);
} }
return ret; return ret;

591
dll/winproc.cpp Normal file
View File

@ -0,0 +1,591 @@
#define _WIN32_WINNT 0x0600
#define WIN32_LEAN_AND_MEAN
#define _CRT_SECURE_NO_DEPRECATE 1
#include <windows.h>
#include <stdio.h>
#include <stdarg.h>
#include "dxwnd.h"
#include "dxwcore.hpp"
#include "dxhelper.h"
extern void SuppressIMEWindow();
extern void RecoverScreenMode();
static void dx_ToggleLogging()
{
// toggle LOGGING
if(dxw.dwTFlags & OUTTRACE){
OutTraceDW("Toggle logging OFF\n");
dxw.dwTFlags &= ~OUTTRACE;
}
else {
dxw.dwTFlags |= OUTTRACE;
OutTraceDW("Toggle logging ON\n");
}
GetHookInfo()->isLogging=(dxw.dwTFlags & OUTTRACE);
}
LRESULT CALLBACK extDialogWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
static int i=0;
static WINDOWPOS *wp;
WNDPROC pWindowProc;
LRESULT res;
static int t = -1;
static int iRecursion = 0;
if(iRecursion) {
iRecursion=0;
return NULL;
}
iRecursion++;
if (t == -1)
t = (*pGetTickCount)();
int tn = (*pGetTickCount)();
OutTraceW("DEBUG: DialogWinMsg hwnd=%x msg=[0x%x]%s(%x,%x)\n", hwnd, message, ExplainWinMessage(message), wparam, lparam);
// optimization: don't invalidate too often!
// 200mSec seems a good compromise.
if (tn-t > 200) {
(*pInvalidateRect)(hwnd, NULL, TRUE);
t=tn;
}
pWindowProc=dxwws.GetProc(hwnd);
if(pWindowProc) {
res =(*pCallWindowProcA)(pWindowProc, hwnd, message, wparam, lparam);
}
else {
char *sMsg="ASSERT: DialogWinMsg pWindowProc=NULL !!!\n";
OutTraceDW(sMsg);
if (IsAssertEnabled) MessageBox(0, sMsg, "WindowProc", MB_OK | MB_ICONEXCLAMATION);
res = NULL;
}
iRecursion=0;
return res;
}
LRESULT CALLBACK extChildWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
static int i=0;
static WINDOWPOS *wp;
WNDPROC pWindowProc;
OutTraceW("DEBUG: ChildWinMsg hwnd=%x msg=[0x%x]%s(%x,%x)\n", hwnd, message, ExplainWinMessage(message), wparam, lparam);
if(dxw.Windowize){
switch(message){
// Cybermercs: it seems that all game menus are conveniently handled by the WindowProc routine,
// while the action screen get messages processed by the ChildWindowProc, that needs some different
// setting ..........
// Beware: Cybermercs handles some static info about cursor position handling, so that if you resize
// a menu it doesn't work correctly until you don't change screen.
case WM_MOUSEMOVE:
case WM_MOUSEWHEEL:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_RBUTTONDBLCLK:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_MBUTTONDBLCLK:
// if(dxw.dwFlags1 & MODIFYMOUSE){ // mouse processing
//if((dxw.dwFlags1 & MODIFYMOUSE) && !(dxw.dwFlags6 & NOMOUSEPROC)){ // mouse processing
if((dxw.dwFlags1 & MODIFYMOUSE) && !(dxw.dwFlags1 & MESSAGEPROC)){ // mouse processing
POINT prev, curr;
// scale mouse coordinates
prev.x = LOWORD(lparam);
prev.y = HIWORD(lparam);
curr = prev;
if(message == WM_MOUSEWHEEL){ // v2.02.33 mousewheel fix
POINT upleft={0,0};
(*pClientToScreen)(dxw.GethWnd(), &upleft);
curr = dxw.SubCoordinates(curr, upleft);
}
//OutTraceC("ChildWindowProc: hwnd=%x pos XY prev=(%d,%d)\n", hwnd, prev.x, prev.y);
curr=dxw.FixCursorPos(curr); // Warn! the correction must refer to the main window hWnd, not the current hwnd one !!!
lparam = MAKELPARAM(curr.x, curr.y);
OutTraceC("ChildWindowProc: hwnd=%x pos XY=(%d,%d)->(%d,%d)\n", hwnd, prev.x, prev.y, curr.x, curr.y);
}
break;
default:
break;
}
}
pWindowProc=dxwws.GetProc(hwnd);
// v2.02.82: use CallWindowProc that handles WinProc handles
if(pWindowProc) return(*pCallWindowProcA)(pWindowProc, hwnd, message, wparam, lparam);
// should never get here ....
OutTraceDW("ChildWindowProc: no WndProc for CHILD hwnd=%x\n", hwnd);
return DefWindowProc(hwnd, message, wparam, lparam);
}
static void dx_UpdatePositionLock(HWND hwnd)
{
RECT rect;
POINT p={0,0};
(*pGetClientRect)(hwnd,&rect);
(*pClientToScreen)(hwnd,&p);
dxw.dwFlags1 |= LOCKWINPOS;
OutTraceDW("Toggle position lock ON\n");
dxw.InitWindowPos(p.x, p.y, rect.right-rect.left, rect.bottom-rect.top);
}
static void dx_TogglePositionLock(HWND hwnd)
{
// toggle position locking
if(dxw.dwFlags1 & LOCKWINPOS){
// unlock
OutTraceDW("Toggle position lock OFF\n");
dxw.dwFlags1 &= ~LOCKWINPOS;
}
else {
OutTraceDW("Toggle position lock ON\n");
dxw.dwFlags1 |= LOCKWINPOS;
dx_UpdatePositionLock(hwnd);
}
}
static void dx_ToggleFPS()
{
if(dxw.dwFlags2 & SHOWFPS){
dxw.dwFlags2 &= ~SHOWFPS;
OutTrace("ToggleFPS: SHOWFPS mode OFF\n");
}
else {
dxw.dwFlags2 |= SHOWFPS;
OutTrace("ToggleFPS: SHOWFPS mode ON\n");
}
}
static void dx_Cornerize(HWND hwnd)
{
static RECT WinRect = {0, 0, 0, 0};
static DWORD OldStyle, OldExtStyle;
// toggle ....
if (WinRect.right == 0){
OutTraceDW("DxWnd: entering corner mode\n");
(*pGetWindowRect)(hwnd, &WinRect);
OldStyle = (*pGetWindowLongA)(hwnd, GWL_STYLE);
OldExtStyle = (*pGetWindowLongA)(hwnd, GWL_EXSTYLE);
(*pSetWindowLongA)(hwnd, GWL_STYLE, WS_VISIBLE|WS_CLIPSIBLINGS|WS_OVERLAPPED);
(*pSetWindowLongA)(hwnd, GWL_EXSTYLE, 0);
(*pMoveWindow)(hwnd, 0, 0, dxw.GetScreenWidth(), dxw.GetScreenHeight(), TRUE);
}
else {
OutTraceDW("DxWnd: exiting corner mode\n");
(*pSetWindowLongA)(hwnd, GWL_STYLE, OldStyle);
(*pSetWindowLongA)(hwnd, GWL_EXSTYLE, OldExtStyle);
(*pMoveWindow)(hwnd, WinRect.left, WinRect.top, WinRect.right, WinRect.bottom, TRUE);
memset(&WinRect, 0, sizeof(WinRect));
}
(*pUpdateWindow)(hwnd);
dxw.ScreenRefresh();
}
LRESULT LastCursorPos;
LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
POINT prev, curr;
RECT rect;
static int i=0;
static int ClipCursorToggleState = 1;
WNDPROC pWindowProc;
extern void dxwFixWindowPos(char *, HWND, LPARAM);
extern LPRECT lpClipRegion;
static BOOL DoOnce = TRUE;
static BOOL IsToBeLocked;
static int LastTimeShift;
static int SaveTimeShift;
static BOOL TimeShiftToggle=TRUE;
extern void DDrawScreenShot();
if(DoOnce){
DoOnce=FALSE;
IsToBeLocked=(dxw.dwFlags1 & LOCKWINPOS);
LastTimeShift=SaveTimeShift=dxw.TimeShift;
}
// v2.1.93: adjust clipping region
if(IsTraceW){
char sPos[161];
sPos[160]=0;
sPos[0]=0;
switch(message){
case WM_WINDOWPOSCHANGING:
case WM_WINDOWPOSCHANGED:
LPWINDOWPOS wp;
wp = (LPWINDOWPOS)lparam;
sprintf_s(sPos, 160, " pos=(%d,%d) size=(%dx%d) flags=%x(%s)", wp->x, wp->y, wp->cx, wp->cy, wp->flags, ExplainWPFlags(wp->flags));
break;
case WM_MOVE:
sprintf_s(sPos, 160, " pos=(%d,%d)", HIWORD(lparam), LOWORD(lparam));
break;
case WM_SIZE:
static char *modes[5]={"RESTORED", "MINIMIZED", "MAXIMIZED", "MAXSHOW", "MAXHIDE"};
sprintf_s(sPos, 160, " mode=SIZE_%s size=(%dx%d)", modes[wparam % 5], HIWORD(lparam), LOWORD(lparam));
break;
}
OutTrace("WindowProc[%x]: WinMsg=[0x%x]%s(%x,%x) %s\n", hwnd, message, ExplainWinMessage(message), wparam, lparam, sPos);
}
if(dxw.dwFlags3 & FILTERMESSAGES){
switch(message){
case WM_NCMOUSEMOVE:
case WM_NCLBUTTONDOWN:
case WM_NCLBUTTONUP:
case WM_NCLBUTTONDBLCLK:
case WM_NCRBUTTONDOWN:
case WM_NCRBUTTONUP:
case WM_NCRBUTTONDBLCLK:
case WM_NCMBUTTONDOWN:
case WM_NCMBUTTONUP:
case WM_NCMBUTTONDBLCLK:
OutTraceDW("WindowProc[%x]: SUPPRESS WinMsg=[0x%x]%s(%x,%x)\n", hwnd, message, ExplainWinMessage(message), wparam, lparam);
return 0;
}
}
if(LastTimeShift != dxw.TimeShift){
extern void SetVSyncDelays(LPDIRECTDRAW);
extern LPDIRECTDRAW lpPrimaryDD;
if(dxw.dwFlags4 & STRETCHTIMERS) dxw.RenewTimers();
if(lpPrimaryDD) SetVSyncDelays(lpPrimaryDD);
LastTimeShift=dxw.TimeShift;
}
switch(message){
// v2.02.13: added WM_GETMINMAXINFO/WM_NCCALCSIZE interception - (see Actua Soccer 3 problems...)
//case WM_NCDESTROY:
// return 0;
case WM_GETMINMAXINFO:
if(dxw.dwFlags1 & LOCKWINPOS){
extern void dxwFixMinMaxInfo(char *, HWND, LPARAM);
dxwFixMinMaxInfo("WindowProc", hwnd, lparam);
return 0;
}
break;
case WM_NCCALCSIZE:
case WM_NCPAINT:
if((dxw.dwFlags1 & LOCKWINPOS) && (hwnd == dxw.GethWnd()) && dxw.IsFullScreen()){ // v2.02.30: don't alter child and other windows....
OutTraceDW("WindowProc: %s wparam=%x\n", ExplainWinMessage(message), wparam);
return (*pDefWindowProcA)(hwnd, message, wparam, lparam);
}
break;
case WM_NCCREATE:
if(dxw.dwFlags2 & SUPPRESSIME) SuppressIMEWindow();
break;
case WM_IME_SETCONTEXT:
case WM_IME_NOTIFY:
case WM_IME_CONTROL:
case WM_IME_COMPOSITIONFULL:
case WM_IME_SELECT:
case WM_IME_CHAR:
case WM_IME_REQUEST:
case WM_IME_KEYDOWN:
case WM_IME_KEYUP:
if(dxw.dwFlags2 & SUPPRESSIME){
OutTraceDW("WindowProc[%x]: SUPPRESS IME WinMsg=[0x%x]%s(%x,%x)\n", hwnd, message, ExplainWinMessage(message), wparam, lparam);
return 0;
}
break;
case WM_NCHITTEST:
if((dxw.dwFlags2 & FIXNCHITTEST) && (dxw.dwFlags1 & MODIFYMOUSE)){ // mouse processing
POINT cursor;
LRESULT ret;
ret=(*pDefWindowProcA)(hwnd, message, wparam, lparam);
if (ret==HTCLIENT) {
cursor.x=LOWORD(lparam);
cursor.y=HIWORD(lparam);
dxw.FixNCHITCursorPos(&cursor);
lparam = MAKELPARAM(cursor.x, cursor.y);
}
else
return ret;
}
break;
case WM_ERASEBKGND:
if(dxw.Windowize && dxw.IsDesktop(hwnd)){
OutTraceDW("WindowProc: WM_ERASEBKGND(%x,%x) - suppressed\n", wparam, lparam);
return 1; // 1 == OK, erased
}
break;
case WM_DISPLAYCHANGE:
if (dxw.Windowize && (dxw.dwFlags1 & LOCKWINPOS) && dxw.IsFullScreen()){
OutTraceDW("WindowProc: prevent WM_DISPLAYCHANGE depth=%d size=(%d,%d)\n",
wparam, LOWORD(lparam), HIWORD(lparam));
// v2.02.43: unless EMULATESURFACE is set, lock the screen resolution only, but not the color depth!
if(dxw.dwFlags1 & EMULATESURFACE) return 0;
// let rparam (color depth) change, but override lparam (screen width & height.)
lparam = MAKELPARAM((LONG)dxw.GetScreenWidth(), (LONG)dxw.GetScreenHeight());
//return 0;
}
break;
case WM_WINDOWPOSCHANGING:
case WM_WINDOWPOSCHANGED:
if(dxw.Windowize && dxw.IsFullScreen()){
if(dxw.dwFlags5 & NOWINPOSCHANGES){
OutTraceDW("WindowProc: %s - suppressed\n", message==WM_WINDOWPOSCHANGED ? "WM_WINDOWPOSCHANGED" : "WM_WINDOWPOSCHANGING");
return 0;
}
extern HWND hControlParentWnd;
LPWINDOWPOS wp;
wp = (LPWINDOWPOS)lparam;
dxwFixWindowPos("WindowProc", hwnd, lparam);
OutTraceDW("WindowProc: %s fixed size=(%d,%d)\n",
(message == WM_WINDOWPOSCHANGED) ? "WM_WINDOWPOSCHANGED" : "WM_WINDOWPOSCHANGING", wp->cx, wp->cy);
// try to lock main wind & control parent together
if((message==WM_WINDOWPOSCHANGED) && hControlParentWnd){
if(dxw.IsDesktop(hwnd)) {
POINT fo = dxw.GetFrameOffset();
(*pMoveWindow)(hControlParentWnd, wp->x+fo.x, wp->y+fo.y, wp->cx, wp->cy, TRUE);
}
}
// v2.03.30: in window mode, it seems that the WM_ACTIVATEAPP message is not sent to the main win.
// this PostMessage call recovers "Thorgal" block at the end of intro movie and "Championship Manager 03 04" cursor
if((message==WM_WINDOWPOSCHANGED) && (dxw.dwFlags6 & ACTIVATEAPP)){
PostMessage(hwnd, WM_ACTIVATEAPP, 1, 0);
}
}
break;
case WM_ENTERSIZEMOVE:
if(IsToBeLocked){
dxw.dwFlags1 &= ~LOCKWINPOS;
}
while((*pShowCursor)(1) < 0);
if(dxw.dwFlags1 & CLIPCURSOR) dxw.EraseClipCursor();
if(dxw.dwFlags1 & ENABLECLIPPING) (*pClipCursor)(NULL);
break;
case WM_EXITSIZEMOVE:
if(IsToBeLocked){
dxw.dwFlags1 |= LOCKWINPOS;
dx_UpdatePositionLock(hwnd);
}
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.dwFlags2 & REFRESHONRESIZE) dxw.ScreenRefresh();
if(dxw.dwFlags4 & HIDEDESKTOP) dxw.HideDesktop(dxw.GethWnd());
if(dxw.dwFlags5 & CENTERTOWIN) {
HDC thdc;
HWND w = dxw.GethWnd();
RECT client;
(*pGetClientRect)(w, &client);
thdc=(*pGDIGetDC)(w);
if(thdc) (*pGDIBitBlt)(thdc, client.left, client.top, client.right, client.bottom, 0, 0, 0, BLACKNESS);
}
break;
case WM_ACTIVATE:
// turn DirectInput bActive flag on & off .....
dxw.bActive = (LOWORD(wparam) == WA_ACTIVE || LOWORD(wparam) == WA_CLICKACTIVE) ? 1 : 0;
case WM_NCACTIVATE:
// turn DirectInput bActive flag on & off .....
if(message == WM_NCACTIVATE) dxw.bActive = wparam;
if(dxw.bActive) (*pSetWindowPos)(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
if(dxw.dwFlags1 & UNNOTIFY){
DefWindowProc(hwnd, message, wparam, lparam);
return false;
}
break;
case WM_NCMOUSEMOVE:
// Posted to a window when the cursor is moved within the nonclient area of the window.
// This message is posted to the window that contains the cursor.
// If a window has captured the mouse, this message is not posted.
// V2.1.90: on nonclient areas the cursor is always shown.
while((*pShowCursor)(1) < 0);
break;
case WM_MOUSEMOVE:
if(dxw.Windowize){
prev.x = LOWORD(lparam);
prev.y = HIWORD(lparam);
if ((dxw.dwFlags1 & HIDEHWCURSOR) && dxw.IsFullScreen()){
(*pGetClientRect)(hwnd, &rect);
if(prev.x >= 0 && prev.x < rect.right && prev.y >= 0 && prev.y < rect.bottom)
while((*pShowCursor)(0) >= 0);
else
while((*pShowCursor)(1) < 0);
}
else {
while((*pShowCursor)(1) < 0);
}
//if(dxw.dwFlags1 & MODIFYMOUSE){ // mouse processing
//if((dxw.dwFlags1 & MODIFYMOUSE) && !(dxw.dwFlags6 & NOMOUSEPROC)){ // mouse processing
if((dxw.dwFlags1 & MODIFYMOUSE) && !(dxw.dwFlags1 & MESSAGEPROC)){ // mouse processing
// scale mouse coordinates
curr=dxw.FixCursorPos(prev); //v2.02.30
lparam = MAKELPARAM(curr.x, curr.y);
OutTraceC("WindowProc: hwnd=%x pos XY=(%d,%d)->(%d,%d)\n", hwnd, prev.x, prev.y, curr.x, curr.y);
}
GetHookInfo()->CursorX=LOWORD(lparam);
GetHookInfo()->CursorY=HIWORD(lparam);
}
break;
// fall through cases:
case WM_MOUSEWHEEL:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_RBUTTONDBLCLK:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_MBUTTONDBLCLK:
if(dxw.Windowize){
if((dxw.dwFlags1 & CLIPCURSOR) && ClipCursorToggleState) dxw.SetClipCursor();
//if(dxw.dwFlags1 & MODIFYMOUSE){ // mouse processing
//if((dxw.dwFlags1 & MODIFYMOUSE) && !(dxw.dwFlags6 & NOMOUSEPROC)){ // mouse processing
if((dxw.dwFlags1 & MODIFYMOUSE) && !(dxw.dwFlags1 & MESSAGEPROC)){ // mouse processing
// scale mouse coordinates
prev.x = LOWORD(lparam);
prev.y = HIWORD(lparam);
curr = prev;
if(message == WM_MOUSEWHEEL){ // v2.02.33 mousewheel fix
POINT upleft={0,0};
(*pClientToScreen)(dxw.GethWnd(), &upleft);
curr = dxw.SubCoordinates(curr, upleft);
}
curr=dxw.FixCursorPos(curr); //v2.02.30
lparam = MAKELPARAM(curr.x, curr.y);
OutTraceC("WindowProc: hwnd=%x pos XY=(%d,%d)->(%d,%d)\n", hwnd, prev.x, prev.y, curr.x, curr.y);
}
GetHookInfo()->CursorX=LOWORD(lparam);
GetHookInfo()->CursorY=HIWORD(lparam);
}
break;
case WM_SETFOCUS:
OutTraceDW("WindowProc: hwnd=%x GOT FOCUS\n", hwnd);
if (dxw.dwFlags1 & ENABLECLIPPING) 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);
break;
case WM_CLOSE:
// Beware: closing main window does not always mean that the program is about to terminate!!!
extern void gShowHideTaskBar(BOOL);
if(dxw.dwFlags6 & CONFIRMONCLOSE){
OutTraceDW("WindowProc: WM_CLOSE - terminating process?\n");
if (MessageBoxA(NULL, "Do you really want to exit the game?", "DxWnd", MB_YESNO | MB_TASKMODAL) != IDYES) return FALSE;
}
if(dxw.dwFlags6 & HIDETASKBAR) gShowHideTaskBar(FALSE);
if(dxw.dwFlags3 & FORCE16BPP) RecoverScreenMode();
if(dxw.dwFlags6 & TERMINATEONCLOSE) TerminateProcess(GetCurrentProcess(),0);
break;
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
if(!(dxw.dwFlags4 & ENABLEHOTKEYS)) break;
OutTraceW("event %s wparam=%x lparam=%x\n", (message==WM_SYSKEYDOWN)?"WM_SYSKEYDOWN":"WM_KEYDOWN", wparam, lparam);
UINT DxWndKey;
DxWndKey=dxw.MapKeysConfig(message, lparam, wparam);
switch (DxWndKey){
case DXVK_CLIPTOGGLE:
if(dxw.dwFlags1 & CLIPCURSOR){
OutTraceDW("WindowProc: WM_SYSKEYDOWN key=%x ToggleState=%x\n",wparam,ClipCursorToggleState);
ClipCursorToggleState = !ClipCursorToggleState;
ClipCursorToggleState ? dxw.SetClipCursor() : dxw.EraseClipCursor();
}
break;
case DXVK_REFRESH:
dxw.ScreenRefresh();
break;
case DXVK_LOGTOGGLE:
dx_ToggleLogging();
break;
case DXVK_PLOCKTOGGLE:
dx_TogglePositionLock(hwnd);
break;
case DXVK_FPSTOGGLE:
dx_ToggleFPS();
break;
case DXVK_CORNERIZE:
dx_Cornerize(hwnd);
break;
case DXVK_TIMEFAST:
case DXVK_TIMESLOW:
if (dxw.dwFlags2 & TIMESTRETCH) {
if (DxWndKey == DXVK_TIMESLOW && (dxw.TimeShift < 8)) dxw.TimeShift++;
if (DxWndKey == DXVK_TIMEFAST && (dxw.TimeShift > -8)) dxw.TimeShift--;
GetHookInfo()->TimeShift=dxw.TimeShift;
OutTrace("Time Stretch: shift=%d speed=%s\n", dxw.TimeShift, dxw.GetTSCaption());
}
break;
case DXVK_TIMETOGGLE:
if (dxw.dwFlags2 & TIMESTRETCH) {
if(TimeShiftToggle){
SaveTimeShift=dxw.TimeShift;
dxw.TimeShift=0;
}
else{
dxw.TimeShift=SaveTimeShift;
}
TimeShiftToggle = !TimeShiftToggle;
GetHookInfo()->TimeShift=dxw.TimeShift;
}
break;
case DXVK_ALTF4:
if (dxw.dwFlags1 & HANDLEALTF4) {
OutTraceDW("WindowProc: WM_SYSKEYDOWN(ALT-F4) - terminating process\n");
TerminateProcess(GetCurrentProcess(),0);
}
break;
case DXVK_PRINTSCREEN:
DDrawScreenShot();
break;
default:
break;
}
default:
break;
}
if (dxw.dwFlags1 & AUTOREFRESH) dxw.ScreenRefresh();
pWindowProc=dxwws.GetProc(hwnd);
//OutTraceB("WindowProc: pWindowProc=%x extWindowProc=%x message=%x(%s) wparam=%x lparam=%x\n",
// (*pWindowProc), extWindowProc, message, ExplainWinMessage(message), wparam, lparam);
if(pWindowProc) {
LRESULT ret;
// v2.02.36: use CallWindowProc that handles WinProc handles
ret=(*pCallWindowProcA)(pWindowProc, hwnd, message, wparam, lparam);
// save last NCHITTEST cursor position for use with KEEPASPECTRATIO scaling
if(message==WM_NCHITTEST) LastCursorPos=ret;
// v2.1.89: if FORCEWINRESIZE add standard processing for the missing WM_NC* messages
if(dxw.dwFlags2 & FORCEWINRESIZE){
switch(message){
//case WM_NCHITTEST:
//case WM_NCPAINT:
//case WM_NCMOUSEMOVE:
//case WM_NCCALCSIZE:
//case WM_NCACTIVATE:
case WM_SETCURSOR: // shows a different cursor when moving on borders
case WM_NCLBUTTONDOWN: // intercepts mouse down on borders
case WM_NCLBUTTONUP: // intercepts mouse up on borders
ret=(*pDefWindowProcA)(hwnd, message, wparam, lparam);
break;
}
}
return ret;
}
//OutTraceDW("ASSERT: WindowProc mismatch hwnd=%x\n", hwnd);
// ??? maybe it's a normal condition, whenever you don't have a WindowProc routine
// like in Commandos 2. Flag it?
char sMsg[81];
sprintf(sMsg,"ASSERT: WindowProc mismatch hwnd=%x\n", hwnd);
OutTraceDW(sMsg);
if (IsAssertEnabled) MessageBox(0, sMsg, "WindowProc", MB_OK | MB_ICONEXCLAMATION);
return (*pDefWindowProcA)(hwnd, message, wparam, lparam);
}

View File

@ -39,6 +39,7 @@ void CTabDebug::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_ANALYTICMODE, cTarget->m_AnalyticMode); DDX_Check(pDX, IDC_ANALYTICMODE, cTarget->m_AnalyticMode);
DDX_Check(pDX, IDC_SURFACEWARN, cTarget->m_SurfaceWarn); DDX_Check(pDX, IDC_SURFACEWARN, cTarget->m_SurfaceWarn);
DDX_Check(pDX, IDC_CAPMASK, cTarget->m_CapMask); DDX_Check(pDX, IDC_CAPMASK, cTarget->m_CapMask);
DDX_Check(pDX, IDC_NOWINDOWHOOKS, cTarget->m_NoWindowHooks);
DDX_Check(pDX, IDC_NODDRAWBLT, cTarget->m_NoDDRAWBlt); DDX_Check(pDX, IDC_NODDRAWBLT, cTarget->m_NoDDRAWBlt);
DDX_Check(pDX, IDC_NODDRAWFLIP, cTarget->m_NoDDRAWFlip); DDX_Check(pDX, IDC_NODDRAWFLIP, cTarget->m_NoDDRAWFlip);
DDX_Check(pDX, IDC_NOGDIBLT, cTarget->m_NoGDIBlt); DDX_Check(pDX, IDC_NOGDIBLT, cTarget->m_NoGDIBlt);

View File

@ -36,10 +36,11 @@ void CTabInput::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_KEEPCURSORWITHIN, cTarget->m_KeepCursorWithin); DDX_Check(pDX, IDC_KEEPCURSORWITHIN, cTarget->m_KeepCursorWithin);
DDX_Check(pDX, IDC_KEEPCURSORFIXED, cTarget->m_KeepCursorFixed); DDX_Check(pDX, IDC_KEEPCURSORFIXED, cTarget->m_KeepCursorFixed);
DDX_Check(pDX, IDC_MESSAGEPROC, cTarget->m_MessageProc); DDX_Check(pDX, IDC_MESSAGEPROC, cTarget->m_MessageProc);
//DDX_Check(pDX, IDC_NOMOUSEPROC, cTarget->m_NoMouseProc);
DDX_Check(pDX, IDC_FIXNCHITTEST, cTarget->m_FixNCHITTEST); DDX_Check(pDX, IDC_FIXNCHITTEST, cTarget->m_FixNCHITTEST);
DDX_Check(pDX, IDC_SLOW, cTarget->m_SlowDown); DDX_Check(pDX, IDC_SLOW, cTarget->m_SlowDown);
DDX_Check(pDX, IDC_RELEASEMOUSE, cTarget->m_ReleaseMouse); DDX_Check(pDX, IDC_RELEASEMOUSE, cTarget->m_ReleaseMouse);
DDX_Check(pDX, IDC_FRAMECOMPENSATION, cTarget->m_FrameCompensation); //DDX_Check(pDX, IDC_FRAMECOMPENSATION, cTarget->m_FrameCompensation);
// DirectInput // DirectInput
DDX_Check(pDX, IDC_HOOKDI, cTarget->m_HookDI); DDX_Check(pDX, IDC_HOOKDI, cTarget->m_HookDI);
DDX_Text(pDX, IDC_INITX, cTarget->m_InitX); DDX_Text(pDX, IDC_INITX, cTarget->m_InitX);

View File

@ -159,6 +159,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
m_Force16BPP = FALSE; m_Force16BPP = FALSE;
m_HookChildWin = FALSE; m_HookChildWin = FALSE;
m_MessageProc = FALSE; m_MessageProc = FALSE;
//m_NoMouseProc = FALSE;
m_FixNCHITTEST = FALSE; m_FixNCHITTEST = FALSE;
m_RecoverScreenMode = FALSE; m_RecoverScreenMode = FALSE;
m_RefreshOnResize = FALSE; m_RefreshOnResize = FALSE;
@ -177,7 +178,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
m_QuarterBlt = FALSE; m_QuarterBlt = FALSE;
m_FineTiming = FALSE; m_FineTiming = FALSE;
m_ReleaseMouse = FALSE; m_ReleaseMouse = FALSE;
m_FrameCompensation = FALSE; //m_FrameCompensation = FALSE;
m_EnableHotKeys = TRUE; // default true !! m_EnableHotKeys = TRUE; // default true !!
m_InterceptRDTSC = FALSE; m_InterceptRDTSC = FALSE;
m_HookOpenGL = FALSE; m_HookOpenGL = FALSE;
@ -189,6 +190,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
m_Deinterlace = FALSE; m_Deinterlace = FALSE;
m_SurfaceWarn = FALSE; m_SurfaceWarn = FALSE;
m_CapMask = FALSE; m_CapMask = FALSE;
m_NoWindowHooks = FALSE;
m_NoDDRAWBlt = FALSE; m_NoDDRAWBlt = FALSE;
m_NoDDRAWFlip = FALSE; m_NoDDRAWFlip = FALSE;
m_NoGDIBlt = FALSE; m_NoGDIBlt = FALSE;

View File

@ -124,6 +124,7 @@ public:
BOOL m_NoWindowMove; BOOL m_NoWindowMove;
BOOL m_HookChildWin; BOOL m_HookChildWin;
BOOL m_MessageProc; BOOL m_MessageProc;
//BOOL m_NoMouseProc;
BOOL m_FixNCHITTEST; BOOL m_FixNCHITTEST;
BOOL m_RecoverScreenMode; BOOL m_RecoverScreenMode;
BOOL m_RefreshOnResize; BOOL m_RefreshOnResize;
@ -143,7 +144,7 @@ public:
BOOL m_QuarterBlt; BOOL m_QuarterBlt;
BOOL m_FineTiming; BOOL m_FineTiming;
BOOL m_ReleaseMouse; BOOL m_ReleaseMouse;
BOOL m_FrameCompensation; // BOOL m_FrameCompensation;
BOOL m_EnableHotKeys; BOOL m_EnableHotKeys;
BOOL m_InterceptRDTSC; BOOL m_InterceptRDTSC;
BOOL m_HookOpenGL; BOOL m_HookOpenGL;
@ -155,6 +156,7 @@ public:
BOOL m_Deinterlace; BOOL m_Deinterlace;
BOOL m_SurfaceWarn; BOOL m_SurfaceWarn;
BOOL m_CapMask; BOOL m_CapMask;
BOOL m_NoWindowHooks;
BOOL m_NoDDRAWBlt; BOOL m_NoDDRAWBlt;
BOOL m_NoDDRAWFlip; BOOL m_NoDDRAWFlip;
BOOL m_NoGDIBlt; BOOL m_NoGDIBlt;

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -359,6 +359,7 @@ static void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg)
if(dlg->m_Force16BPP) t->flags3 |= FORCE16BPP; if(dlg->m_Force16BPP) t->flags3 |= FORCE16BPP;
if(dlg->m_HookChildWin) t->flags |= HOOKCHILDWIN; if(dlg->m_HookChildWin) t->flags |= HOOKCHILDWIN;
if(dlg->m_MessageProc) t->flags |= MESSAGEPROC; if(dlg->m_MessageProc) t->flags |= MESSAGEPROC;
//if(dlg->m_NoMouseProc) t->flags6 |= NOMOUSEPROC;
if(dlg->m_FixNCHITTEST) t->flags2 |= FIXNCHITTEST; if(dlg->m_FixNCHITTEST) t->flags2 |= FIXNCHITTEST;
if(dlg->m_RecoverScreenMode) t->flags2 |= RECOVERSCREENMODE; if(dlg->m_RecoverScreenMode) t->flags2 |= RECOVERSCREENMODE;
if(dlg->m_RefreshOnResize) t->flags2 |= REFRESHONRESIZE; if(dlg->m_RefreshOnResize) t->flags2 |= REFRESHONRESIZE;
@ -377,7 +378,7 @@ static void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg)
if(dlg->m_QuarterBlt) t->flags5 |= QUARTERBLT; if(dlg->m_QuarterBlt) t->flags5 |= QUARTERBLT;
if(dlg->m_FineTiming) t->flags4 |= FINETIMING; if(dlg->m_FineTiming) t->flags4 |= FINETIMING;
if(dlg->m_ReleaseMouse) t->flags4 |= RELEASEMOUSE; if(dlg->m_ReleaseMouse) t->flags4 |= RELEASEMOUSE;
if(dlg->m_FrameCompensation) t->flags4 |= FRAMECOMPENSATION; // if(dlg->m_FrameCompensation) t->flags4 |= FRAMECOMPENSATION;
if(dlg->m_EnableHotKeys) t->flags4 |= ENABLEHOTKEYS; if(dlg->m_EnableHotKeys) t->flags4 |= ENABLEHOTKEYS;
if(dlg->m_InterceptRDTSC) t->flags4 |= INTERCEPTRDTSC; if(dlg->m_InterceptRDTSC) t->flags4 |= INTERCEPTRDTSC;
if(dlg->m_HookOpenGL) t->flags2 |= HOOKOPENGL; if(dlg->m_HookOpenGL) t->flags2 |= HOOKOPENGL;
@ -393,6 +394,7 @@ static void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg)
if(dlg->m_NoPaletteUpdate) t->flags2 |= NOPALETTEUPDATE; if(dlg->m_NoPaletteUpdate) t->flags2 |= NOPALETTEUPDATE;
if(dlg->m_SurfaceWarn) t->flags3 |= SURFACEWARN; if(dlg->m_SurfaceWarn) t->flags3 |= SURFACEWARN;
if(dlg->m_CapMask) t->flags3 |= CAPMASK; if(dlg->m_CapMask) t->flags3 |= CAPMASK;
if(dlg->m_NoWindowHooks) t->flags6 |= NOWINDOWHOOKS;
if(dlg->m_NoDDRAWBlt) t->flags3 |= NODDRAWBLT; if(dlg->m_NoDDRAWBlt) t->flags3 |= NODDRAWBLT;
if(dlg->m_NoDDRAWFlip) t->flags3 |= NODDRAWFLIP; if(dlg->m_NoDDRAWFlip) t->flags3 |= NODDRAWFLIP;
if(dlg->m_NoGDIBlt) t->flags3 |= NOGDIBLT; if(dlg->m_NoGDIBlt) t->flags3 |= NOGDIBLT;
@ -597,6 +599,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg)
dlg->m_Force16BPP = t->flags3 & FORCE16BPP ? 1 : 0; dlg->m_Force16BPP = t->flags3 & FORCE16BPP ? 1 : 0;
dlg->m_HookChildWin = t->flags & HOOKCHILDWIN ? 1 : 0; dlg->m_HookChildWin = t->flags & HOOKCHILDWIN ? 1 : 0;
dlg->m_MessageProc = t->flags & MESSAGEPROC ? 1 : 0; dlg->m_MessageProc = t->flags & MESSAGEPROC ? 1 : 0;
//dlg->m_NoMouseProc = t->flags6 & NOMOUSEPROC ? 1 : 0;
dlg->m_FixNCHITTEST = t->flags2 & FIXNCHITTEST ? 1 : 0; dlg->m_FixNCHITTEST = t->flags2 & FIXNCHITTEST ? 1 : 0;
dlg->m_RecoverScreenMode = t->flags2 & RECOVERSCREENMODE ? 1 : 0; dlg->m_RecoverScreenMode = t->flags2 & RECOVERSCREENMODE ? 1 : 0;
dlg->m_RefreshOnResize = t->flags2 & REFRESHONRESIZE ? 1 : 0; dlg->m_RefreshOnResize = t->flags2 & REFRESHONRESIZE ? 1 : 0;
@ -615,7 +618,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg)
dlg->m_QuarterBlt = t->flags5 & QUARTERBLT ? 1 : 0; dlg->m_QuarterBlt = t->flags5 & QUARTERBLT ? 1 : 0;
dlg->m_FineTiming = t->flags4 & FINETIMING ? 1 : 0; dlg->m_FineTiming = t->flags4 & FINETIMING ? 1 : 0;
dlg->m_ReleaseMouse = t->flags4 & RELEASEMOUSE ? 1 : 0; dlg->m_ReleaseMouse = t->flags4 & RELEASEMOUSE ? 1 : 0;
dlg->m_FrameCompensation = t->flags4 & FRAMECOMPENSATION ? 1 : 0; // dlg->m_FrameCompensation = t->flags4 & FRAMECOMPENSATION ? 1 : 0;
dlg->m_EnableHotKeys = t->flags4 & ENABLEHOTKEYS ? 1 : 0; dlg->m_EnableHotKeys = t->flags4 & ENABLEHOTKEYS ? 1 : 0;
dlg->m_InterceptRDTSC = t->flags4 & INTERCEPTRDTSC ? 1 : 0; dlg->m_InterceptRDTSC = t->flags4 & INTERCEPTRDTSC ? 1 : 0;
dlg->m_HookOpenGL = t->flags2 & HOOKOPENGL ? 1 : 0; dlg->m_HookOpenGL = t->flags2 & HOOKOPENGL ? 1 : 0;
@ -631,6 +634,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg)
dlg->m_NoPaletteUpdate = t->flags2 & NOPALETTEUPDATE ? 1 : 0; dlg->m_NoPaletteUpdate = t->flags2 & NOPALETTEUPDATE ? 1 : 0;
dlg->m_SurfaceWarn = t->flags3 & SURFACEWARN ? 1 : 0; dlg->m_SurfaceWarn = t->flags3 & SURFACEWARN ? 1 : 0;
dlg->m_CapMask = t->flags3 & CAPMASK ? 1 : 0; dlg->m_CapMask = t->flags3 & CAPMASK ? 1 : 0;
dlg->m_NoWindowHooks = t->flags6 & NOWINDOWHOOKS ? 1 : 0;
dlg->m_NoDDRAWBlt = t->flags3 & NODDRAWBLT ? 1 : 0; dlg->m_NoDDRAWBlt = t->flags3 & NODDRAWBLT ? 1 : 0;
dlg->m_NoDDRAWFlip = t->flags3 & NODDRAWFLIP ? 1 : 0; dlg->m_NoDDRAWFlip = t->flags3 & NODDRAWFLIP ? 1 : 0;
dlg->m_NoGDIBlt = t->flags3 & NOGDIBLT ? 1 : 0; dlg->m_NoGDIBlt = t->flags3 & NOGDIBLT ? 1 : 0;

Binary file not shown.