mirror of
https://github.com/DxWnd/DxWnd.reloaded
synced 2024-12-30 09:25:35 +01:00
v2_02_53_src
Former-commit-id: dcbedb5a0c1c7f2fac7f9113c04ca113d67f128f
This commit is contained in:
parent
a526fd2091
commit
a17992ec84
@ -257,3 +257,9 @@ typedef enum {
|
|||||||
DXW_LIMIT_1024x768,
|
DXW_LIMIT_1024x768,
|
||||||
DXW_LIMIT_1280x960
|
DXW_LIMIT_1280x960
|
||||||
} ResolutionLimits_Types;
|
} ResolutionLimits_Types;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
TIMER_TYPE_NONE = 0,
|
||||||
|
TIMER_TYPE_USER32,
|
||||||
|
TIMER_TYPE_WINMM
|
||||||
|
} Timer_Types;
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:c24abb81ba8ba231b637a91ce227ef7f0ec20bccc36f9e8bea78f3e76d5ac2a2
|
oid sha256:03271f56101f397e9d6ffc4c966d04af5ae7a94e2dfd2df958d185363586a74a
|
||||||
size 445440
|
size 446976
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:663ef886bb9f08ed3fea88ec675f0f213b8c60490183f2ad44984e5c7b6ef08d
|
oid sha256:8621dc8cebb19d5e945aeba4932dff40115f73c88209fe39e4388bef4822f621
|
||||||
size 535040
|
size 535040
|
||||||
|
1438
build/dxwnd.ini
1438
build/dxwnd.ini
File diff suppressed because it is too large
Load Diff
26
build/exports/Dungeon Odyssey (Demo).dxw
Normal file
26
build/exports/Dungeon Odyssey (Demo).dxw
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
[target]
|
||||||
|
title0=Dungeon Odyssey (Demo)
|
||||||
|
path0=D:\Games\Dungeon Odyssey Demo\DungOdy.exe
|
||||||
|
module0=
|
||||||
|
opengllib0=
|
||||||
|
ver0=7
|
||||||
|
coord0=0
|
||||||
|
flag0=134234146
|
||||||
|
flagg0=1207959568
|
||||||
|
flagh0=20
|
||||||
|
flagi0=4
|
||||||
|
tflag0=64
|
||||||
|
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=4
|
26
build/exports/Heart of Darkness.dxw
Normal file
26
build/exports/Heart of Darkness.dxw
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
[target]
|
||||||
|
title0=Heart of Darkness
|
||||||
|
path0=D:\Games\Heart of Darkness\HODWin32.exe
|
||||||
|
module0=
|
||||||
|
opengllib0=
|
||||||
|
ver0=0
|
||||||
|
coord0=0
|
||||||
|
flag0=134217762
|
||||||
|
flagg0=1207959552
|
||||||
|
flagh0=2068
|
||||||
|
flagi0=4
|
||||||
|
tflag0=64
|
||||||
|
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
|
26
build/exports/Heroes of Might and Magic 4 Complete.dxw
Normal file
26
build/exports/Heroes of Might and Magic 4 Complete.dxw
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
[target]
|
||||||
|
title0=Heroes of Might and Magic 4 Complete
|
||||||
|
path0=D:\Games\Heroes of Might and Magic 4 Complete\heroes4.exe
|
||||||
|
module0=
|
||||||
|
opengllib0=
|
||||||
|
ver0=0
|
||||||
|
coord0=0
|
||||||
|
flag0=671350818
|
||||||
|
flagg0=1207959552
|
||||||
|
flagh0=65556
|
||||||
|
flagi0=5
|
||||||
|
tflag0=64
|
||||||
|
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
|
26
build/exports/Hesperian Wars.dxw
Normal file
26
build/exports/Hesperian Wars.dxw
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
[target]
|
||||||
|
title0=Hesperian Wars
|
||||||
|
path0=D:\Games\Hesperian_Wars\HW.EXE
|
||||||
|
module0=
|
||||||
|
opengllib0=
|
||||||
|
ver0=0
|
||||||
|
coord0=0
|
||||||
|
flag0=136314914
|
||||||
|
flagg0=1207959552
|
||||||
|
flagh0=-2147483628
|
||||||
|
flagi0=4
|
||||||
|
tflag0=6227
|
||||||
|
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
|
26
build/exports/Homeworld.dxw
Normal file
26
build/exports/Homeworld.dxw
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
[target]
|
||||||
|
title0=Homeworld
|
||||||
|
path0=D:\Games\Homeworld\Homeworld.exe
|
||||||
|
module0=
|
||||||
|
opengllib0=
|
||||||
|
ver0=0
|
||||||
|
coord0=0
|
||||||
|
flag0=704667680
|
||||||
|
flagg0=1208090896
|
||||||
|
flagh0=20
|
||||||
|
flagi0=4
|
||||||
|
tflag0=64
|
||||||
|
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
|
26
build/exports/Horde 2 the Citadel.dxw
Normal file
26
build/exports/Horde 2 the Citadel.dxw
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
[target]
|
||||||
|
title0=Horde 2 the Citadel
|
||||||
|
path0=D:\Games\Horde2\HORDE\horde2.exe
|
||||||
|
module0=
|
||||||
|
opengllib0=
|
||||||
|
ver0=0
|
||||||
|
coord0=0
|
||||||
|
flag0=134217766
|
||||||
|
flagg0=134217728
|
||||||
|
flagh0=20
|
||||||
|
flagi0=4
|
||||||
|
tflag0=64
|
||||||
|
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
|
26
build/exports/Horde.dxw
Normal file
26
build/exports/Horde.dxw
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
[target]
|
||||||
|
title0=Horde
|
||||||
|
path0=D:\Games\HORDE\horde.exe
|
||||||
|
module0=
|
||||||
|
opengllib0=
|
||||||
|
ver0=0
|
||||||
|
coord0=0
|
||||||
|
flag0=134217766
|
||||||
|
flagg0=134217728
|
||||||
|
flagh0=20
|
||||||
|
flagi0=4
|
||||||
|
tflag0=64
|
||||||
|
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
|
@ -6,8 +6,8 @@ opengllib0=
|
|||||||
ver0=0
|
ver0=0
|
||||||
coord0=0
|
coord0=0
|
||||||
flag0=679485474
|
flag0=679485474
|
||||||
flagg0=1209008128
|
flagg0=1207959552
|
||||||
flagh0=20
|
flagh0=32788
|
||||||
flagi0=4
|
flagi0=4
|
||||||
tflag0=0
|
tflag0=0
|
||||||
initx0=0
|
initx0=0
|
||||||
@ -22,3 +22,5 @@ sizx0=800
|
|||||||
sizy0=600
|
sizy0=600
|
||||||
maxfps0=0
|
maxfps0=0
|
||||||
initts0=0
|
initts0=0
|
||||||
|
winver0=0
|
||||||
|
maxres0=0
|
||||||
|
26
build/exports/Metal Knight.dxw
Normal file
26
build/exports/Metal Knight.dxw
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
[target]
|
||||||
|
title0=Metal Knight RIP
|
||||||
|
path0=D:\Games\Metal Knight RIP\mk.exe
|
||||||
|
module0=
|
||||||
|
opengllib0=
|
||||||
|
ver0=0
|
||||||
|
coord0=0
|
||||||
|
flag0=134217762
|
||||||
|
flagg0=134217728
|
||||||
|
flagh0=20
|
||||||
|
flagi0=4
|
||||||
|
tflag0=64
|
||||||
|
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
|
26
build/exports/Settlers 3, the.dxw
Normal file
26
build/exports/Settlers 3, the.dxw
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
[target]
|
||||||
|
title0=Settlers 3, the
|
||||||
|
path0=D:\Games\Settlers3\S3.EXE
|
||||||
|
module0=
|
||||||
|
opengllib0=
|
||||||
|
ver0=0
|
||||||
|
coord0=0
|
||||||
|
flag0=-1476394974
|
||||||
|
flagg0=1207959618
|
||||||
|
flagh0=20
|
||||||
|
flagi0=4
|
||||||
|
tflag0=64
|
||||||
|
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
|
@ -5,11 +5,11 @@ module0=jgl
|
|||||||
opengllib0=
|
opengllib0=
|
||||||
ver0=0
|
ver0=0
|
||||||
coord0=0
|
coord0=0
|
||||||
flag0=-1174405087
|
flag0=973352994
|
||||||
flagg0=1213333504
|
flagg0=136462360
|
||||||
flagh0=65556
|
flagh0=2162708
|
||||||
flagi0=4100
|
flagi0=4100
|
||||||
tflag0=6483
|
tflag0=64
|
||||||
initx0=0
|
initx0=0
|
||||||
inity0=0
|
inity0=0
|
||||||
minx0=0
|
minx0=0
|
||||||
@ -18,8 +18,8 @@ maxx0=0
|
|||||||
maxy0=0
|
maxy0=0
|
||||||
posx0=50
|
posx0=50
|
||||||
posy0=50
|
posy0=50
|
||||||
sizx0=1024
|
sizx0=800
|
||||||
sizy0=768
|
sizy0=600
|
||||||
maxfps0=0
|
maxfps0=0
|
||||||
initts0=6
|
initts0=6
|
||||||
winver0=0
|
winver0=0
|
||||||
|
26
build/exports/Still Life (GOG).dxw
Normal file
26
build/exports/Still Life (GOG).dxw
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
[target]
|
||||||
|
title0=Still Life (GOG)
|
||||||
|
path0=D:\Games\Still Life (GOG)\StillLife.exe
|
||||||
|
module0=
|
||||||
|
opengllib0=
|
||||||
|
ver0=0
|
||||||
|
coord0=0
|
||||||
|
flag0=671105058
|
||||||
|
flagg0=1207959568
|
||||||
|
flagh0=20
|
||||||
|
flagi0=4
|
||||||
|
tflag0=1088
|
||||||
|
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
|
26
build/exports/Warhammer 40K Chaos Gate.dxw
Normal file
26
build/exports/Warhammer 40K Chaos Gate.dxw
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
[target]
|
||||||
|
title0=Warhammer 40K Chaos Gate
|
||||||
|
path0=D:\Games\Warhammer 40K Chaos Gate\game\WH40K.exe
|
||||||
|
module0=
|
||||||
|
opengllib0=
|
||||||
|
ver0=0
|
||||||
|
coord0=0
|
||||||
|
flag0=679493667
|
||||||
|
flagg0=1207959552
|
||||||
|
flagh0=20
|
||||||
|
flagi0=4
|
||||||
|
tflag0=64
|
||||||
|
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
|
@ -356,3 +356,13 @@ fixed log message for TextOut parameters
|
|||||||
hooked DisableD3DSpy (invoked by The Bard's Tale)
|
hooked DisableD3DSpy (invoked by The Bard's Tale)
|
||||||
fixed extglViewport coordinate remapping when invoked with CW_USEDEFAULT values (Civ III)
|
fixed extglViewport coordinate remapping when invoked with CW_USEDEFAULT values (Civ III)
|
||||||
fixed bug in DirectDarawCreate/Ex hooking with wrong module handle
|
fixed bug in DirectDarawCreate/Ex hooking with wrong module handle
|
||||||
|
|
||||||
|
v2.02.53
|
||||||
|
Handling of ddraw screen color depth 15BPP - in "Hesperian Wars"
|
||||||
|
fixed IAT scanning: now function addresses for remapping are searched in possibly multiple instances of dll text segment - in "Aaron Hall's Dungeon Odissey"
|
||||||
|
hooked SystemParametersInfo call
|
||||||
|
fixed window size logic to check for window menu bar, considering also the WS_CHILD case.
|
||||||
|
fixed window move/resize when message processing is enabled: coordinates outside the child area or within ENTER/EXITSIZEMOVE must NOT be altered.
|
||||||
|
expanded timer processing to include user32 Set/KillTimer - in "Aaron Hall's Dungeon Odissey"
|
||||||
|
fixed possible recursion while hooking child window procedure identical to parent's one
|
||||||
|
fixed gdi emulation on top of ddraw surface, enough to play "Sid Meyer's Civilization III".
|
||||||
|
19
d3d9proxy/proxydll.sln
Normal file
19
d3d9proxy/proxydll.sln
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||||
|
# Visual Studio 2008
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "proxydll", "proxydll.vcproj", "{02EB97D5-B1C5-411E-8274-83A95985DE6F}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{02EB97D5-B1C5-411E-8274-83A95985DE6F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{02EB97D5-B1C5-411E-8274-83A95985DE6F}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{02EB97D5-B1C5-411E-8274-83A95985DE6F}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{02EB97D5-B1C5-411E-8274-83A95985DE6F}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
BIN
dll/Thumbs.db
BIN
dll/Thumbs.db
Binary file not shown.
@ -562,6 +562,7 @@ void FixPixelFormat(int ColorDepth, DDPIXELFORMAT *pf)
|
|||||||
pf->dwBBitMask = 0;
|
pf->dwBBitMask = 0;
|
||||||
pf->dwRGBAlphaBitMask = 0x0000;
|
pf->dwRGBAlphaBitMask = 0x0000;
|
||||||
break;
|
break;
|
||||||
|
case 15: // v2.02.53: Hesperian Wars - so far the only game setting color depth to 15 BPP!
|
||||||
case 16:
|
case 16:
|
||||||
pf->dwRGBBitCount = 16;
|
pf->dwRGBBitCount = 16;
|
||||||
if (dxw.dwFlags1 & USERGB565){
|
if (dxw.dwFlags1 & USERGB565){
|
||||||
@ -571,7 +572,7 @@ void FixPixelFormat(int ColorDepth, DDPIXELFORMAT *pf)
|
|||||||
pf->dwRGBAlphaBitMask = 0x0000;
|
pf->dwRGBAlphaBitMask = 0x0000;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!(dxw.dwFlags4 & NOALPHACHANNEL)) pf->dwFlags |= DDPF_ALPHAPIXELS; // v2.02.33,40
|
if(!(dxw.dwFlags4 & NOALPHACHANNEL) && (ColorDepth == 16)) pf->dwFlags |= DDPF_ALPHAPIXELS; // v2.02.33,40,53
|
||||||
pf->dwRBitMask = 0x7c00;
|
pf->dwRBitMask = 0x7c00;
|
||||||
pf->dwGBitMask = 0x03e0;
|
pf->dwGBitMask = 0x03e0;
|
||||||
pf->dwBBitMask = 0x001f;
|
pf->dwBBitMask = 0x001f;
|
||||||
@ -799,6 +800,7 @@ static void SetPixFmt(LPDDSURFACEDESC2 lpdd)
|
|||||||
switch (dxw.VirtualPixelFormat.dwRGBBitCount)
|
switch (dxw.VirtualPixelFormat.dwRGBBitCount)
|
||||||
{
|
{
|
||||||
case 8:
|
case 8:
|
||||||
|
case 15:
|
||||||
case 16:
|
case 16:
|
||||||
case 24:
|
case 24:
|
||||||
case 32:
|
case 32:
|
||||||
|
@ -15,6 +15,7 @@ typedef HRESULT (WINAPI *GetDeviceData_Type)(LPDIRECTINPUTDEVICE, DWORD, LPVOID,
|
|||||||
typedef HRESULT (WINAPI *GetDeviceState_Type)(LPDIRECTINPUTDEVICE, DWORD, LPDIMOUSESTATE);
|
typedef HRESULT (WINAPI *GetDeviceState_Type)(LPDIRECTINPUTDEVICE, DWORD, LPDIMOUSESTATE);
|
||||||
typedef HRESULT (WINAPI *DISetCooperativeLevel_Type)(LPDIRECTINPUTDEVICE, HWND, DWORD);
|
typedef HRESULT (WINAPI *DISetCooperativeLevel_Type)(LPDIRECTINPUTDEVICE, HWND, DWORD);
|
||||||
typedef HRESULT (WINAPI *SetDataFormat_Type)(LPDIRECTINPUTDEVICE, LPCDIDATAFORMAT);
|
typedef HRESULT (WINAPI *SetDataFormat_Type)(LPDIRECTINPUTDEVICE, LPCDIDATAFORMAT);
|
||||||
|
typedef HRESULT (WINAPI *DIEnumDevices_Type)(void *, DWORD, LPDIENUMDEVICESCALLBACK, LPVOID, DWORD);
|
||||||
|
|
||||||
HRESULT WINAPI extDirectInputCreate(HINSTANCE, DWORD, LPDIRECTINPUT *, LPUNKNOWN);
|
HRESULT WINAPI extDirectInputCreate(HINSTANCE, DWORD, LPDIRECTINPUT *, LPUNKNOWN);
|
||||||
HRESULT WINAPI extDirectInputCreateEx(HINSTANCE, DWORD, REFIID, LPVOID *, LPUNKNOWN);
|
HRESULT WINAPI extDirectInputCreateEx(HINSTANCE, DWORD, REFIID, LPVOID *, LPUNKNOWN);
|
||||||
@ -26,6 +27,7 @@ HRESULT WINAPI extGetDeviceState(LPDIRECTINPUTDEVICE, DWORD, LPDIMOUSESTATE);
|
|||||||
HRESULT WINAPI extDISetCooperativeLevel(LPDIRECTINPUTDEVICE, HWND, DWORD);
|
HRESULT WINAPI extDISetCooperativeLevel(LPDIRECTINPUTDEVICE, HWND, DWORD);
|
||||||
HRESULT WINAPI extSetDataFormat(LPDIRECTINPUTDEVICE, LPCDIDATAFORMAT);
|
HRESULT WINAPI extSetDataFormat(LPDIRECTINPUTDEVICE, LPCDIDATAFORMAT);
|
||||||
HRESULT WINAPI extQueryInterfaceI(void *, REFIID, LPVOID *);
|
HRESULT WINAPI extQueryInterfaceI(void *, REFIID, LPVOID *);
|
||||||
|
HRESULT WINAPI extDIEnumDevices(void *, DWORD, LPDIENUMDEVICESCALLBACK, LPVOID, DWORD);
|
||||||
void GetMousePosition(int *, int *);
|
void GetMousePosition(int *, int *);
|
||||||
void InitPosition(int, int, int, int, int, int);
|
void InitPosition(int, int, int, int, int, int);
|
||||||
|
|
||||||
@ -38,6 +40,7 @@ GetDeviceState_Type pGetDeviceState;
|
|||||||
DISetCooperativeLevel_Type pDISetCooperativeLevel;
|
DISetCooperativeLevel_Type pDISetCooperativeLevel;
|
||||||
SetDataFormat_Type pSetDataFormat;
|
SetDataFormat_Type pSetDataFormat;
|
||||||
QueryInterface_Type pQueryInterfaceI;
|
QueryInterface_Type pQueryInterfaceI;
|
||||||
|
DIEnumDevices_Type pDIEnumDevices;
|
||||||
|
|
||||||
int iCursorX;
|
int iCursorX;
|
||||||
int iCursorY;
|
int iCursorY;
|
||||||
@ -103,7 +106,7 @@ HRESULT WINAPI extDirectInputCreate(HINSTANCE hinst,
|
|||||||
if(res) return res;
|
if(res) return res;
|
||||||
SetHook((void *)(**(DWORD **)lplpdi), extQueryInterfaceI, (void **)&pQueryInterfaceI, "QueryInterface(I)");
|
SetHook((void *)(**(DWORD **)lplpdi), extQueryInterfaceI, (void **)&pQueryInterfaceI, "QueryInterface(I)");
|
||||||
SetHook((void *)(**(DWORD **)lplpdi + 12), extDICreateDevice, (void **)&pDICreateDevice, "CreateDevice(I)");
|
SetHook((void *)(**(DWORD **)lplpdi + 12), extDICreateDevice, (void **)&pDICreateDevice, "CreateDevice(I)");
|
||||||
//SetHook((void *)(**(DWORD **)lplpdi + 16), extDIEnumDevices, (void **)&pDIEnumDevices, "EnumDevices(I)");
|
SetHook((void *)(**(DWORD **)lplpdi + 16), extDIEnumDevices, (void **)&pDIEnumDevices, "EnumDevices(I)");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +121,7 @@ HRESULT WINAPI extDirectInputCreateEx(HINSTANCE hinst,
|
|||||||
res = (*pDirectInputCreateEx)(hinst, dwversion, riidltf, ppvout, pu);
|
res = (*pDirectInputCreateEx)(hinst, dwversion, riidltf, ppvout, pu);
|
||||||
if(res) return res;
|
if(res) return res;
|
||||||
SetHook((void *)(**(DWORD **)ppvout + 12), extDICreateDevice, (void **)&pDICreateDevice, "CreateDevice(I)");
|
SetHook((void *)(**(DWORD **)ppvout + 12), extDICreateDevice, (void **)&pDICreateDevice, "CreateDevice(I)");
|
||||||
//SetHook((void *)(**(DWORD **)lplpdi + 16), extDIEnumDevices, (void **)&pDIEnumDevices, "EnumDevices(I)");
|
SetHook((void *)(**(DWORD **)ppvout + 16), extDIEnumDevices, (void **)&pDIEnumDevices, "EnumDevices(I)");
|
||||||
SetHook((void *)(**(DWORD **)ppvout + 36), extDICreateDeviceEx, (void **)pDICreateDeviceEx, "DICreateDeviceEx(I)");
|
SetHook((void *)(**(DWORD **)ppvout + 36), extDICreateDeviceEx, (void **)pDICreateDeviceEx, "DICreateDeviceEx(I)");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -137,6 +140,7 @@ HRESULT WINAPI extQueryInterfaceI(void * lpdi, REFIID riid, LPVOID *obp)
|
|||||||
case 0x5944E662: //DirectInput2A
|
case 0x5944E662: //DirectInput2A
|
||||||
case 0x5944E663: //DirectInput2W
|
case 0x5944E663: //DirectInput2W
|
||||||
SetHook((void *)(**(DWORD **)obp + 12), extDICreateDevice, (void **)pDICreateDevice, "CreateDevice(I)");
|
SetHook((void *)(**(DWORD **)obp + 12), extDICreateDevice, (void **)pDICreateDevice, "CreateDevice(I)");
|
||||||
|
SetHook((void *)(**(DWORD **)obp + 16), extDIEnumDevices, (void **)&pDIEnumDevices, "EnumDevices(I)");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -317,12 +321,56 @@ void InitPosition(int x, int y, int minx, int miny, int maxx, int maxy)
|
|||||||
iCurMaxY = maxy;
|
iCurMaxY = maxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
//HRESULT WINAPI extEnumDevices(void *lpdi, DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags)
|
typedef struct {
|
||||||
//{
|
LPDIENUMDEVICESCALLBACK cb;
|
||||||
// HRESULT res;
|
LPVOID arg;
|
||||||
// OutTraceDW("EnumDevices(I): di=%x DevType=%x CallBack=%x Ref=%x Flags=%x\n", lpdi, dwDevType, lpCallback, pvRef, dwFlags);
|
} CallbackArg;
|
||||||
// res=(*pEnumDevices)( lpdi, dwDevType, lpCallback, pvRef, dwFlags);
|
|
||||||
// OutTraceDW("EnumDevices(I): res=%x\n", res);
|
HRESULT WINAPI extDeviceProxy(LPCDIDEVICEINSTANCE dev, LPVOID arg)
|
||||||
// return res;
|
{
|
||||||
//}
|
HRESULT res;
|
||||||
|
char *p;
|
||||||
|
switch (dev->dwSize) {
|
||||||
|
case sizeof(DIDEVICEINSTANCEA): p="ASCII"; break;
|
||||||
|
case sizeof(DIDEVICEINSTANCEW): p="WIDECHAR"; break;
|
||||||
|
default: p="UNKNOWN"; break;
|
||||||
|
}
|
||||||
|
OutTraceDW("EnumDevices(I): CALLBACK size=%d(%s) GUID=(%x.%x.%x.%x) type=%x InstanceName=\"%s\", ProductName=\"%s\"\n",
|
||||||
|
dev->dwSize, p, dev->guidInstance.Data1, dev->guidInstance.Data2, dev->guidInstance.Data3, dev->guidInstance.Data4,
|
||||||
|
dev->dwDevType, dev->tszInstanceName, dev->tszProductName);
|
||||||
|
|
||||||
|
if(0){
|
||||||
|
DIDEVICEINSTANCEW fixdev;
|
||||||
|
fixdev.dwSize=sizeof(DIDEVICEINSTANCEW);
|
||||||
|
fixdev.dwDevType=dev->dwDevType;
|
||||||
|
fixdev.guidInstance=dev->guidInstance;
|
||||||
|
fixdev.guidProduct=dev->guidProduct;
|
||||||
|
mbstowcs(fixdev.tszInstanceName, dev->tszInstanceName, strlen(dev->tszInstanceName));
|
||||||
|
mbstowcs(fixdev.tszProductName, dev->tszProductName, strlen(dev->tszProductName));
|
||||||
|
res = ((LPDIENUMDEVICESCALLBACKW)(((CallbackArg *)arg)->cb))(&fixdev, ((CallbackArg *)arg)->arg);
|
||||||
|
OutTraceDW("EnumDevices: CALLBACK ret=%x\n", res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
__try{
|
||||||
|
res = ((((CallbackArg *)arg)->cb))(dev, ((CallbackArg *)arg)->arg);
|
||||||
|
}
|
||||||
|
__except(EXCEPTION_EXECUTE_HANDLER){
|
||||||
|
res=TRUE;
|
||||||
|
}
|
||||||
|
OutTraceDW("EnumDevices: CALLBACK ret=%x\n", res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI extDIEnumDevices(void *lpdi, DWORD dwDevType, LPDIENUMDEVICESCALLBACK lpCallback, LPVOID pvRef, DWORD dwFlags)
|
||||||
|
{
|
||||||
|
HRESULT res;
|
||||||
|
CallbackArg Arg;
|
||||||
|
OutTraceDW("EnumDevices(I): di=%x DevType=%x CallBack=%x Ref=%x Flags=%x\n", lpdi, dwDevType, lpCallback, pvRef, dwFlags);
|
||||||
|
Arg.cb= lpCallback;
|
||||||
|
Arg.arg=pvRef;
|
||||||
|
res=(*pDIEnumDevices)( lpdi, dwDevType, (LPDIENUMDEVICESCALLBACK)extDeviceProxy, pvRef, dwFlags);
|
||||||
|
OutTraceDW("EnumDevices(I): res=%x\n", res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
285
dll/dxhook.cpp
285
dll/dxhook.cpp
@ -337,143 +337,9 @@ void SetHook(void *target, void *hookproc, void **hookedproc, char *hookname)
|
|||||||
*hookedproc = tmp;
|
*hookedproc = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HOOKBYIAT
|
// v2.02.53: thorough scan - the IAT is scanned considering the possibility to have each dll module
|
||||||
PIMAGE_SECTION_HEADER ImageRVA2Section(PIMAGE_NT_HEADERS pimage_nt_headers,DWORD dwRVA)
|
// replicated also many times. It may depend upon the compiling environment?
|
||||||
{
|
// So far, it makes the difference for Dungeon Odissey
|
||||||
int i;
|
|
||||||
PIMAGE_SECTION_HEADER pimage_section_header=(PIMAGE_SECTION_HEADER)((PCHAR(pimage_nt_headers)) + sizeof(IMAGE_NT_HEADERS));
|
|
||||||
for(i=0;i<pimage_nt_headers->FileHeader.NumberOfSections;i++)
|
|
||||||
{
|
|
||||||
if((pimage_section_header->VirtualAddress) && (dwRVA<=(pimage_section_header->VirtualAddress+pimage_section_header->SizeOfRawData)))
|
|
||||||
{
|
|
||||||
return ((PIMAGE_SECTION_HEADER)pimage_section_header);
|
|
||||||
}
|
|
||||||
pimage_section_header++;
|
|
||||||
}
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD RVA2Offset(PCHAR pImageBase,DWORD dwRVA)
|
|
||||||
{
|
|
||||||
DWORD _offset;
|
|
||||||
PIMAGE_SECTION_HEADER section;
|
|
||||||
PIMAGE_DOS_HEADER pimage_dos_header;
|
|
||||||
PIMAGE_NT_HEADERS pimage_nt_headers;
|
|
||||||
pimage_dos_header = PIMAGE_DOS_HEADER(pImageBase);
|
|
||||||
pimage_nt_headers = (PIMAGE_NT_HEADERS)(pImageBase+pimage_dos_header->e_lfanew);
|
|
||||||
section=ImageRVA2Section(pimage_nt_headers,dwRVA);
|
|
||||||
if(section==NULL)
|
|
||||||
{
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
_offset=dwRVA+section->PointerToRawData-section->VirtualAddress;
|
|
||||||
return(_offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *HookAPI(HMODULE module, char *dll, void *apiproc, const char *apiname, void *hookproc)
|
|
||||||
{
|
|
||||||
PIMAGE_NT_HEADERS pnth;
|
|
||||||
PIMAGE_IMPORT_DESCRIPTOR pidesc;
|
|
||||||
DWORD base, rva;
|
|
||||||
PSTR impmodule;
|
|
||||||
PIMAGE_THUNK_DATA ptaddr;
|
|
||||||
PIMAGE_THUNK_DATA ptname;
|
|
||||||
PIMAGE_IMPORT_BY_NAME piname;
|
|
||||||
DWORD oldprotect;
|
|
||||||
void *org;
|
|
||||||
PCHAR pThunk;
|
|
||||||
DWORD dwThunk;
|
|
||||||
PCHAR pDllName;
|
|
||||||
|
|
||||||
OutTraceB("HookAPI: module=%x dll=%s apiproc=%x apiname=%s hookproc=%x\n",
|
|
||||||
module, dll, apiproc, apiname, hookproc);
|
|
||||||
|
|
||||||
if(!*apiname) { // check
|
|
||||||
char *sMsg="HookAPI: NULL api name\n";
|
|
||||||
OutTraceE(sMsg);
|
|
||||||
if (IsAssertEnabled) MessageBox(0, sMsg, "HookAPI", MB_OK | MB_ICONEXCLAMATION);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
base = (DWORD)module;
|
|
||||||
__try{
|
|
||||||
pnth = PIMAGE_NT_HEADERS(PBYTE(base) + PIMAGE_DOS_HEADER(base)->e_lfanew);
|
|
||||||
if(!pnth) {
|
|
||||||
OutTraceE("HookAPI: ERROR no PNTH at %d\n", __LINE__);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
rva = pnth->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress;
|
|
||||||
if(!rva) {
|
|
||||||
OutTraceE("HookAPI: ERROR no IAT at %d\n", __LINE__);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
pidesc = (PIMAGE_IMPORT_DESCRIPTOR)(base + rva);
|
|
||||||
OutTraceDW("HookAPI: pidesc=%x\n", pidesc);
|
|
||||||
|
|
||||||
while(pidesc->Name){
|
|
||||||
pThunk=(PCHAR)base+pidesc->FirstThunk;
|
|
||||||
dwThunk = pidesc->FirstThunk;
|
|
||||||
pDllName=(PSTR)base+pidesc->Name;
|
|
||||||
OutTraceDW("HookAPI: pDllName=%s Name=%s\n", pDllName, pidesc->Name);
|
|
||||||
//impmodule = (PSTR)(base + pidesc->Name);
|
|
||||||
//if(!lstrcmpi(dll, impmodule)) break;
|
|
||||||
pidesc ++;
|
|
||||||
}
|
|
||||||
if(!pidesc->FirstThunk) {
|
|
||||||
OutTraceB("HookAPI: PE unreferenced dll=%s\n", dll);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ptaddr = (PIMAGE_THUNK_DATA)(base + (DWORD)pidesc->FirstThunk);
|
|
||||||
ptname = (pidesc->OriginalFirstThunk) ? (PIMAGE_THUNK_DATA)(base + (DWORD)pidesc->OriginalFirstThunk) : NULL;
|
|
||||||
|
|
||||||
if((apiproc==NULL) && (ptname==NULL)){
|
|
||||||
if (IsDebug) OutTraceDW("HookAPI: unreacheable api=%s dll=%s\n", apiname, dll);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(ptaddr->u1.Function){
|
|
||||||
if (ptname){
|
|
||||||
if(!IMAGE_SNAP_BY_ORDINAL(ptname->u1.Ordinal)){
|
|
||||||
piname = (PIMAGE_IMPORT_BY_NAME)(base + (DWORD)ptname->u1.AddressOfData);
|
|
||||||
if(!lstrcmpi(apiname, (char *)piname->Name)) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (apiproc){
|
|
||||||
if(ptaddr->u1.Function == (DWORD)apiproc) break;
|
|
||||||
}
|
|
||||||
ptaddr ++;
|
|
||||||
if (ptname) ptname ++;
|
|
||||||
}
|
|
||||||
if(!ptaddr->u1.Function) return 0;
|
|
||||||
|
|
||||||
org = (void *)ptaddr->u1.Function;
|
|
||||||
if(org == hookproc) return 0; // already hooked
|
|
||||||
|
|
||||||
if(!VirtualProtect(&ptaddr->u1.Function, 4, PAGE_EXECUTE_READWRITE, &oldprotect)) {
|
|
||||||
OutTraceDW("HookAPI: VirtualProtect error %d at %d\n", GetLastError(), __LINE__);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
ptaddr->u1.Function = (DWORD)hookproc;
|
|
||||||
if(!VirtualProtect(&ptaddr->u1.Function, 4, oldprotect, &oldprotect)) {
|
|
||||||
OutTraceDW("HookAPI: VirtualProtect error %d at %d\n", GetLastError(), __LINE__);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!FlushInstructionCache(GetCurrentProcess(), &ptaddr->u1.Function, 4)) {
|
|
||||||
OutTraceDW("HookAPI: FlushInstructionCache error %d at %d\n", GetLastError(), __LINE__);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if(IsDebug) OutTrace("HookAPI hook=%s address=%x->%x\n", apiname, org, hookproc);
|
|
||||||
}
|
|
||||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
|
||||||
{
|
|
||||||
OutTraceDW("HookAPI: EXCEPTION hook=%s:%s Hook Failed.\n", dll, apiname);
|
|
||||||
org = 0;
|
|
||||||
}
|
|
||||||
return org;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
void *HookAPI(HMODULE module, char *dll, void *apiproc, const char *apiname, void *hookproc)
|
void *HookAPI(HMODULE module, char *dll, void *apiproc, const char *apiname, void *hookproc)
|
||||||
{
|
{
|
||||||
@ -498,6 +364,8 @@ void *HookAPI(HMODULE module, char *dll, void *apiproc, const char *apiname, voi
|
|||||||
}
|
}
|
||||||
|
|
||||||
base = (DWORD)module;
|
base = (DWORD)module;
|
||||||
|
org = 0; // by default, ret = 0 => API not found
|
||||||
|
|
||||||
__try{
|
__try{
|
||||||
pnth = PIMAGE_NT_HEADERS(PBYTE(base) + PIMAGE_DOS_HEADER(base)->e_lfanew);
|
pnth = PIMAGE_NT_HEADERS(PBYTE(base) + PIMAGE_DOS_HEADER(base)->e_lfanew);
|
||||||
if(!pnth) {
|
if(!pnth) {
|
||||||
@ -513,65 +381,71 @@ void *HookAPI(HMODULE module, char *dll, void *apiproc, const char *apiname, voi
|
|||||||
|
|
||||||
while(pidesc->FirstThunk){
|
while(pidesc->FirstThunk){
|
||||||
impmodule = (PSTR)(base + pidesc->Name);
|
impmodule = (PSTR)(base + pidesc->Name);
|
||||||
if(!lstrcmpi(dll, impmodule)) break;
|
if(!lstrcmpi(dll, impmodule)) {
|
||||||
|
//OutTraceH("HookAPI: dll=%s found at %x\n", dll, impmodule);
|
||||||
|
|
||||||
|
ptaddr = (PIMAGE_THUNK_DATA)(base + (DWORD)pidesc->FirstThunk);
|
||||||
|
ptname = (pidesc->OriginalFirstThunk) ? (PIMAGE_THUNK_DATA)(base + (DWORD)pidesc->OriginalFirstThunk) : NULL;
|
||||||
|
|
||||||
|
//if((apiproc==NULL) && (ptname==NULL)){
|
||||||
|
// OutTraceH("HookAPI: unreacheable api=%s dll=%s\n", apiname, dll);
|
||||||
|
// return 0;
|
||||||
|
//}
|
||||||
|
|
||||||
|
while(ptaddr->u1.Function){
|
||||||
|
if (ptname){
|
||||||
|
if(!IMAGE_SNAP_BY_ORDINAL(ptname->u1.Ordinal)){
|
||||||
|
piname = (PIMAGE_IMPORT_BY_NAME)(base + (DWORD)ptname->u1.AddressOfData);
|
||||||
|
//OutTrace("examining by ptname name=%s\n", (char *)piname->Name);
|
||||||
|
if(!lstrcmpi(apiname, (char *)piname->Name)) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (apiproc){
|
||||||
|
// log not working !!!
|
||||||
|
//piname = (PIMAGE_IMPORT_BY_NAME)(base + (DWORD)ptaddr->u1.AddressOfData);
|
||||||
|
//OutTrace("examining by addr name=%s\n", (char *)piname->Name);
|
||||||
|
if(ptaddr->u1.Function == (DWORD)apiproc) break;
|
||||||
|
}
|
||||||
|
ptaddr ++;
|
||||||
|
if (ptname) ptname ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ptaddr->u1.Function) {
|
||||||
|
org = (void *)ptaddr->u1.Function;
|
||||||
|
if(org == hookproc) return 0; // already hooked
|
||||||
|
|
||||||
|
if(!VirtualProtect(&ptaddr->u1.Function, 4, PAGE_EXECUTE_READWRITE, &oldprotect)) {
|
||||||
|
OutTraceDW("HookAPI: VirtualProtect error %d at %d\n", GetLastError(), __LINE__);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ptaddr->u1.Function = (DWORD)hookproc;
|
||||||
|
if(!VirtualProtect(&ptaddr->u1.Function, 4, oldprotect, &oldprotect)) {
|
||||||
|
OutTraceDW("HookAPI: VirtualProtect error %d at %d\n", GetLastError(), __LINE__);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!FlushInstructionCache(GetCurrentProcess(), &ptaddr->u1.Function, 4)) {
|
||||||
|
OutTraceDW("HookAPI: FlushInstructionCache error %d at %d\n", GetLastError(), __LINE__);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
OutTraceH("HookAPI hook=%s address=%x->%x\n", apiname, org, hookproc);
|
||||||
|
|
||||||
|
return org;
|
||||||
|
}
|
||||||
|
}
|
||||||
pidesc ++;
|
pidesc ++;
|
||||||
}
|
}
|
||||||
if(!pidesc->FirstThunk) {
|
if(!pidesc->FirstThunk) {
|
||||||
OutTraceH("HookAPI: PE unreferenced dll=%s\n", dll);
|
OutTraceH("HookAPI: PE unreferenced function %s:%s\n", dll, apiname);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptaddr = (PIMAGE_THUNK_DATA)(base + (DWORD)pidesc->FirstThunk);
|
|
||||||
ptname = (pidesc->OriginalFirstThunk) ? (PIMAGE_THUNK_DATA)(base + (DWORD)pidesc->OriginalFirstThunk) : NULL;
|
|
||||||
|
|
||||||
if((apiproc==NULL) && (ptname==NULL)){
|
|
||||||
OutTraceH("HookAPI: unreacheable api=%s dll=%s\n", apiname, dll);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(ptaddr->u1.Function){
|
|
||||||
if (ptname){
|
|
||||||
if(!IMAGE_SNAP_BY_ORDINAL(ptname->u1.Ordinal)){
|
|
||||||
piname = (PIMAGE_IMPORT_BY_NAME)(base + (DWORD)ptname->u1.AddressOfData);
|
|
||||||
if(!lstrcmpi(apiname, (char *)piname->Name)) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (apiproc){
|
|
||||||
if(ptaddr->u1.Function == (DWORD)apiproc) break;
|
|
||||||
}
|
|
||||||
ptaddr ++;
|
|
||||||
if (ptname) ptname ++;
|
|
||||||
}
|
|
||||||
if(!ptaddr->u1.Function) return 0;
|
|
||||||
|
|
||||||
org = (void *)ptaddr->u1.Function;
|
|
||||||
if(org == hookproc) return 0; // already hooked
|
|
||||||
|
|
||||||
if(!VirtualProtect(&ptaddr->u1.Function, 4, PAGE_EXECUTE_READWRITE, &oldprotect)) {
|
|
||||||
OutTraceDW("HookAPI: VirtualProtect error %d at %d\n", GetLastError(), __LINE__);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
ptaddr->u1.Function = (DWORD)hookproc;
|
|
||||||
if(!VirtualProtect(&ptaddr->u1.Function, 4, oldprotect, &oldprotect)) {
|
|
||||||
OutTraceDW("HookAPI: VirtualProtect error %d at %d\n", GetLastError(), __LINE__);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!FlushInstructionCache(GetCurrentProcess(), &ptaddr->u1.Function, 4)) {
|
|
||||||
OutTraceDW("HookAPI: FlushInstructionCache error %d at %d\n", GetLastError(), __LINE__);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
OutTraceH("HookAPI hook=%s address=%x->%x\n", apiname, org, hookproc);
|
|
||||||
}
|
}
|
||||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
OutTraceDW("HookAPI: EXCEPTION hook=%s:%s Hook Failed.\n", dll, apiname);
|
OutTraceDW("HookAPI: EXCEPTION hook=%s:%s Hook Failed.\n", dll, apiname);
|
||||||
org = 0;
|
|
||||||
}
|
}
|
||||||
return org;
|
return org;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// v.2.1.80: unified positioning logic into CalculateWindowPos routine
|
// v.2.1.80: unified positioning logic into CalculateWindowPos routine
|
||||||
// now taking in account for window menus (see "Alien Cabal")
|
// now taking in account for window menus (see "Alien Cabal")
|
||||||
|
|
||||||
@ -596,7 +470,7 @@ void CalculateWindowPos(HWND hwnd, DWORD width, DWORD height, LPWINDOWPOS wp)
|
|||||||
rect.bottom = rect.top + MaxY; //v2.02.09
|
rect.bottom = rect.top + MaxY; //v2.02.09
|
||||||
break;
|
break;
|
||||||
case DXW_DESKTOP_WORKAREA:
|
case DXW_DESKTOP_WORKAREA:
|
||||||
SystemParametersInfo(SPI_GETWORKAREA, NULL, &workarea, 0);
|
(*pSystemParametersInfoA)(SPI_GETWORKAREA, NULL, &workarea, 0);
|
||||||
rect = workarea;
|
rect = workarea;
|
||||||
break;
|
break;
|
||||||
case DXW_DESKTOP_FULL:
|
case DXW_DESKTOP_FULL:
|
||||||
@ -620,7 +494,8 @@ void CalculateWindowPos(HWND hwnd, DWORD width, DWORD height, LPWINDOWPOS wp)
|
|||||||
UnmappedRect=rect;
|
UnmappedRect=rect;
|
||||||
dwStyle=(*pGetWindowLong)(hwnd, GWL_STYLE);
|
dwStyle=(*pGetWindowLong)(hwnd, GWL_STYLE);
|
||||||
dwExStyle=(*pGetWindowLong)(hwnd, GWL_EXSTYLE);
|
dwExStyle=(*pGetWindowLong)(hwnd, GWL_EXSTYLE);
|
||||||
hMenu = GetMenu(hwnd);
|
// BEWARE: from MSDN - If the window is a child window, the return value is undefined.
|
||||||
|
hMenu = (dwStyle & WS_CHILD) ? NULL : GetMenu(hwnd);
|
||||||
AdjustWindowRectEx(&rect, dwStyle, (hMenu!=NULL), dwExStyle);
|
AdjustWindowRectEx(&rect, dwStyle, (hMenu!=NULL), dwExStyle);
|
||||||
if (hMenu) CloseHandle(hMenu);
|
if (hMenu) CloseHandle(hMenu);
|
||||||
switch(dxw.Coordinates){
|
switch(dxw.Coordinates){
|
||||||
@ -1466,18 +1341,42 @@ extern HHOOK hMouseHook;
|
|||||||
|
|
||||||
LRESULT CALLBACK MessageHook(int code, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK MessageHook(int code, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
static BOOL SizeMoving = FALSE;
|
||||||
|
|
||||||
if(code == HC_ACTION){
|
if(code == HC_ACTION){
|
||||||
if(dxw.IsFullScreen()){
|
if(dxw.IsFullScreen()){
|
||||||
MSG *msg;
|
MSG *msg;
|
||||||
msg = (MSG *)lParam;
|
msg = (MSG *)lParam;
|
||||||
OutTraceC("MessageHook: message=%d(%s) remove=%d pt=(%d,%d)\n",
|
OutTraceC("MessageHook: hwnd=%x message=%d(%s) remove=%d pt=(%d,%d)\n",
|
||||||
msg->message, ExplainWinMessage(msg->message), msg->wParam, msg->pt.x, msg->pt.y);
|
msg->hwnd, msg->message, ExplainWinMessage(msg->message), msg->wParam, msg->pt.x, msg->pt.y);
|
||||||
msg->pt=dxw.FixMessagePt(dxw.GethWnd(), msg->pt);
|
|
||||||
// beware: needs fix for mousewheel?
|
switch(msg->message){
|
||||||
if((msg->message <= WM_MOUSELAST) && (msg->message >= WM_MOUSEFIRST)) msg->lParam = MAKELPARAM(msg->pt.x, msg->pt.y);
|
case WM_ENTERSIZEMOVE: SizeMoving = TRUE; break;
|
||||||
OutTraceC("MessageHook: fixed lparam/pt=(%d,%d)\n", msg->pt.x, msg->pt.y);
|
case WM_EXITSIZEMOVE: SizeMoving = FALSE; break;
|
||||||
GetHookInfo()->CursorX=(short)msg->pt.x;
|
}
|
||||||
GetHookInfo()->CursorY=(short)msg->pt.y;
|
|
||||||
|
// 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
|
||||||
|
msg->pt=dxw.FixMessagePt(dxw.GethWnd(), msg->pt);
|
||||||
|
//msg->pt=dxw.FixMessagePt(msg->hwnd, 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);
|
return CallNextHookEx(hMouseHook, code, wParam, lParam);
|
||||||
|
113
dll/dxwcore.cpp
113
dll/dxwcore.cpp
@ -27,7 +27,7 @@ dxwCore::dxwCore()
|
|||||||
memset(PrimSurfaces, 0, sizeof(PrimSurfaces));
|
memset(PrimSurfaces, 0, sizeof(PrimSurfaces));
|
||||||
ResetEmulatedDC();
|
ResetEmulatedDC();
|
||||||
MustShowOverlay=FALSE;
|
MustShowOverlay=FALSE;
|
||||||
TimerEvent.uTimerId = 0;
|
TimerEvent.dwTimerType = TIMER_TYPE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
dxwCore::~dxwCore()
|
dxwCore::~dxwCore()
|
||||||
@ -244,6 +244,21 @@ RECT dxwCore::GetScreenRect()
|
|||||||
return Screen;
|
return Screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RECT dxwCore::GetUnmappedScreenRect()
|
||||||
|
{
|
||||||
|
static RECT Screen;
|
||||||
|
POINT upleft = {0, 0};
|
||||||
|
memset(&Screen, 0, sizeof(RECT));
|
||||||
|
(*pGetClientRect)(hWnd, &Screen);
|
||||||
|
(*pClientToScreen)(hWnd, &upleft);
|
||||||
|
Screen.top += upleft.x;
|
||||||
|
Screen.bottom += upleft.x;
|
||||||
|
Screen.left += upleft.y;
|
||||||
|
Screen.right += upleft.y;
|
||||||
|
return Screen;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL dxwCore::IsDesktop(HWND hwnd)
|
BOOL dxwCore::IsDesktop(HWND hwnd)
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
@ -1326,6 +1341,7 @@ BOOL dxwCore::ReleaseEmulatedDC(HWND hwnd)
|
|||||||
(*pGetClientRect)(hwnd, &client);
|
(*pGetClientRect)(hwnd, &client);
|
||||||
if(!(wdc=(*pGDIGetDC)(hwnd)))
|
if(!(wdc=(*pGDIGetDC)(hwnd)))
|
||||||
OutTraceE("GetDC: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
|
OutTraceE("GetDC: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
|
||||||
|
//OutTrace("StretchBlt: destdc=%x destrect=(0,0)-(%d,%d) srcdc=%x srcrect=(0,0)-(%d,%d)\n", wdc, client.right, client.bottom, VirtualHDC, dxw.GetScreenWidth(), dxw.GetScreenHeight());
|
||||||
if(!(*pGDIStretchBlt)(wdc, 0, 0, client.right, client.bottom, VirtualHDC, 0, 0, dxw.GetScreenWidth(), dxw.GetScreenHeight(), SRCCOPY))
|
if(!(*pGDIStretchBlt)(wdc, 0, 0, client.right, client.bottom, VirtualHDC, 0, 0, dxw.GetScreenWidth(), dxw.GetScreenHeight(), SRCCOPY))
|
||||||
OutTraceE("StretchBlt: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
|
OutTraceE("StretchBlt: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
|
||||||
//(*pInvalidateRect)(hwnd, NULL, 0);
|
//(*pInvalidateRect)(hwnd, NULL, 0);
|
||||||
@ -1349,40 +1365,91 @@ BOOL dxwCore::IsVirtual(HDC hdc)
|
|||||||
void dxwCore::PushTimer(UINT uTimerId, UINT uDelay, UINT uResolution, LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT fuEvent)
|
void dxwCore::PushTimer(UINT uTimerId, UINT uDelay, UINT uResolution, LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT fuEvent)
|
||||||
{
|
{
|
||||||
// save current timer
|
// save current timer
|
||||||
TimerEvent.uTimerId = uTimerId;
|
TimerEvent.dwTimerType = TIMER_TYPE_WINMM;
|
||||||
TimerEvent.uDelay = uDelay;
|
TimerEvent.t.uTimerId = uTimerId;
|
||||||
TimerEvent.uResolution = uResolution;
|
TimerEvent.t.uDelay = uDelay;
|
||||||
TimerEvent.lpTimeProc = lpTimeProc;
|
TimerEvent.t.uResolution = uResolution;
|
||||||
TimerEvent.dwUser = dwUser;
|
TimerEvent.t.lpTimeProc = lpTimeProc;
|
||||||
TimerEvent.fuEvent = fuEvent;
|
TimerEvent.t.dwUser = dwUser;
|
||||||
|
TimerEvent.t.fuEvent = fuEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dxwCore::PushTimer(HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc)
|
||||||
|
{
|
||||||
|
// save current timer
|
||||||
|
TimerEvent.dwTimerType = TIMER_TYPE_USER32;
|
||||||
|
TimerEvent.t.hWnd = hWnd;
|
||||||
|
TimerEvent.t.nIDEvent = nIDEvent;
|
||||||
|
TimerEvent.t.uElapse = uElapse;
|
||||||
|
TimerEvent.t.lpTimerFunc = lpTimerFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dxwCore::PopTimer(UINT uTimerId)
|
void dxwCore::PopTimer(UINT uTimerId)
|
||||||
{
|
{
|
||||||
// clear current timer
|
// clear current timer
|
||||||
if(uTimerId != TimerEvent.uTimerId){
|
if(TimerEvent.dwTimerType != TIMER_TYPE_WINMM) {
|
||||||
// this should never happen, unless there are more than 1 timer!
|
// this should never happen, unless there are more than 1 timer!
|
||||||
char msg[256];
|
char msg[256];
|
||||||
sprintf(msg,"PopTimer: TimerId=%x last=%x\n", uTimerId, TimerEvent.uTimerId);
|
sprintf(msg,"PopTimer: TimerType=%x last=%x\n", TIMER_TYPE_WINMM, TimerEvent.dwTimerType);
|
||||||
MessageBox(0, msg, "PopTimer", MB_OK | MB_ICONEXCLAMATION);
|
MessageBox(0, msg, "PopTimer", MB_OK | MB_ICONEXCLAMATION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TimerEvent.uTimerId = 0;
|
if(uTimerId != TimerEvent.t.uTimerId){
|
||||||
TimerEvent.uDelay = 0;
|
// this should never happen, unless there are more than 1 timer!
|
||||||
TimerEvent.uResolution = 0;
|
char msg[256];
|
||||||
TimerEvent.lpTimeProc = NULL;
|
sprintf(msg,"PopTimer: TimerId=%x last=%x\n", uTimerId, TimerEvent.t.uTimerId);
|
||||||
TimerEvent.dwUser = 0;
|
MessageBox(0, msg, "PopTimer", MB_OK | MB_ICONEXCLAMATION);
|
||||||
TimerEvent.fuEvent = 0;
|
return;
|
||||||
|
}
|
||||||
|
TimerEvent.dwTimerType = TIMER_TYPE_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dxwCore::PopTimer(HWND hWnd, UINT_PTR nIDEvent)
|
||||||
|
{
|
||||||
|
// clear current timer
|
||||||
|
if(TimerEvent.dwTimerType != TIMER_TYPE_USER32) {
|
||||||
|
// this should never happen, unless there are more than 1 timer!
|
||||||
|
char msg[256];
|
||||||
|
sprintf(msg,"PopTimer: TimerType=%x last=%x\n", TIMER_TYPE_WINMM, TimerEvent.dwTimerType);
|
||||||
|
MessageBox(0, msg, "PopTimer", MB_OK | MB_ICONEXCLAMATION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(nIDEvent != TimerEvent.t.nIDEvent){
|
||||||
|
// this should never happen, unless there are more than 1 timer!
|
||||||
|
char msg[256];
|
||||||
|
sprintf(msg,"PopTimer: TimerId=%x last=%x\n", nIDEvent, TimerEvent.t.nIDEvent);
|
||||||
|
MessageBox(0, msg, "PopTimer", MB_OK | MB_ICONEXCLAMATION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TimerEvent.dwTimerType = TIMER_TYPE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dxwCore::RenewTimers()
|
void dxwCore::RenewTimers()
|
||||||
{
|
{
|
||||||
if(ptimeKillEvent && ptimeSetEvent && TimerEvent.uTimerId){
|
switch(TimerEvent.dwTimerType){
|
||||||
UINT NewDelay;
|
case TIMER_TYPE_NONE:
|
||||||
MMRESULT res;
|
break;
|
||||||
(*ptimeKillEvent)(TimerEvent.uTimerId);
|
case TIMER_TYPE_USER32:
|
||||||
NewDelay = dxw.StretchTime(TimerEvent.uDelay);
|
if(pSetTimer && pKillTimer){
|
||||||
res=(*ptimeSetEvent)(NewDelay, TimerEvent.uResolution, TimerEvent.lpTimeProc, TimerEvent.dwUser, TimerEvent.fuEvent);
|
UINT uElapse;
|
||||||
TimerEvent.uTimerId = res;
|
UINT_PTR res;
|
||||||
|
(*pKillTimer)(TimerEvent.t.hWnd, TimerEvent.t.nIDEvent);
|
||||||
|
uElapse = dxw.StretchTime(TimerEvent.t.uElapse);
|
||||||
|
res=(*pSetTimer)(TimerEvent.t.hWnd, TimerEvent.t.nIDEvent, uElapse, TimerEvent.t.lpTimerFunc);
|
||||||
|
TimerEvent.t.nIDEvent = res;
|
||||||
|
OutTraceDW("DXWND: RenewTimers type=USER32 Elsapse=%d IDEvent=%x\n", uElapse, res);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TIMER_TYPE_WINMM:
|
||||||
|
if(ptimeKillEvent && ptimeSetEvent){
|
||||||
|
UINT NewDelay;
|
||||||
|
MMRESULT res;
|
||||||
|
(*ptimeKillEvent)(TimerEvent.t.uTimerId);
|
||||||
|
NewDelay = dxw.StretchTime(TimerEvent.t.uDelay);
|
||||||
|
res=(*ptimeSetEvent)(NewDelay, TimerEvent.t.uResolution, TimerEvent.t.lpTimeProc, TimerEvent.t.dwUser, TimerEvent.t.fuEvent);
|
||||||
|
TimerEvent.t.uTimerId = res;
|
||||||
|
OutTraceDW("DXWND: RenewTimers type=WINMM Delay=%d TimerId=%x\n", NewDelay, res);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,23 @@
|
|||||||
#define DDSQLEN 0x10
|
#define DDSQLEN 0x10
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UINT uTimerId;
|
DWORD dwTimerType;
|
||||||
UINT uDelay;
|
union{
|
||||||
UINT uResolution;
|
struct {
|
||||||
LPTIMECALLBACK lpTimeProc;
|
UINT uTimerId;
|
||||||
DWORD_PTR dwUser;
|
UINT uDelay;
|
||||||
UINT fuEvent;
|
UINT uResolution;
|
||||||
|
LPTIMECALLBACK lpTimeProc;
|
||||||
|
DWORD_PTR dwUser;
|
||||||
|
UINT fuEvent;
|
||||||
|
};
|
||||||
|
struct {
|
||||||
|
HWND hWnd;
|
||||||
|
UINT_PTR nIDEvent;
|
||||||
|
UINT uElapse;
|
||||||
|
TIMERPROC lpTimerFunc;
|
||||||
|
};
|
||||||
|
} t;
|
||||||
} TimerEvent_Type;
|
} TimerEvent_Type;
|
||||||
|
|
||||||
class dxwCore
|
class dxwCore
|
||||||
@ -53,6 +64,7 @@ public: // methods
|
|||||||
void FixWorkarea(LPRECT);
|
void FixWorkarea(LPRECT);
|
||||||
POINT FixMessagePt(HWND, POINT);
|
POINT FixMessagePt(HWND, POINT);
|
||||||
RECT GetScreenRect(void);
|
RECT GetScreenRect(void);
|
||||||
|
RECT GetUnmappedScreenRect();
|
||||||
RECT GetWindowRect(RECT);
|
RECT GetWindowRect(RECT);
|
||||||
RECT GetClientRect(RECT);
|
RECT GetClientRect(RECT);
|
||||||
POINT AddCoordinates(POINT, POINT);
|
POINT AddCoordinates(POINT, POINT);
|
||||||
@ -94,7 +106,9 @@ public: // methods
|
|||||||
int VirtualOffsetX, VirtualOffsetY;
|
int VirtualOffsetX, VirtualOffsetY;
|
||||||
void DumpPalette(DWORD, LPPALETTEENTRY);
|
void DumpPalette(DWORD, LPPALETTEENTRY);
|
||||||
void PushTimer(UINT, UINT, UINT, LPTIMECALLBACK, DWORD_PTR, UINT);
|
void PushTimer(UINT, UINT, UINT, LPTIMECALLBACK, DWORD_PTR, UINT);
|
||||||
|
void PushTimer(HWND, UINT_PTR, UINT, TIMERPROC);
|
||||||
void PopTimer(UINT);
|
void PopTimer(UINT);
|
||||||
|
void PopTimer(HWND, UINT_PTR);
|
||||||
void RenewTimers();
|
void RenewTimers();
|
||||||
|
|
||||||
public: // simple data variables
|
public: // simple data variables
|
||||||
|
@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "dxwnd.h"
|
#include "dxwnd.h"
|
||||||
#include "dxwcore.hpp"
|
#include "dxwcore.hpp"
|
||||||
|
|
||||||
#define VERSION "2.02.52"
|
#define VERSION "2.02.53"
|
||||||
|
|
||||||
#define DDTHREADLOCK 1
|
#define DDTHREADLOCK 1
|
||||||
|
|
||||||
|
BIN
dll/dxwnd.suo
BIN
dll/dxwnd.suo
Binary file not shown.
Binary file not shown.
@ -78,11 +78,12 @@ static HookEntry_Type ScaledHooks[]={
|
|||||||
{"Ellipse", (FARPROC)NULL, (FARPROC *)&pEllipse, (FARPROC)extEllipse},
|
{"Ellipse", (FARPROC)NULL, (FARPROC *)&pEllipse, (FARPROC)extEllipse},
|
||||||
{"Polygon", (FARPROC)NULL, (FARPROC *)&pPolygon, (FARPROC)extPolygon},
|
{"Polygon", (FARPROC)NULL, (FARPROC *)&pPolygon, (FARPROC)extPolygon},
|
||||||
{"Arc", (FARPROC)NULL, (FARPROC *)&pArc, (FARPROC)extArc},
|
{"Arc", (FARPROC)NULL, (FARPROC *)&pArc, (FARPROC)extArc},
|
||||||
{"CreateEllipticRgn", (FARPROC)NULL, (FARPROC *)&pCreateEllipticRgn, (FARPROC)extCreateEllipticRgn},
|
// commented out since they alter text on screen...... (see Imperialism II difficulty level menu)
|
||||||
{"CreateEllipticRgnIndirect", (FARPROC)NULL, (FARPROC *)&pCreateEllipticRgnIndirect, (FARPROC)extCreateEllipticRgnIndirect},
|
//{"CreateEllipticRgn", (FARPROC)NULL, (FARPROC *)&pCreateEllipticRgn, (FARPROC)extCreateEllipticRgn},
|
||||||
{"CreateRectRgn", (FARPROC)NULL, (FARPROC *)&pCreateRectRgn, (FARPROC)extCreateRectRgn},
|
//{"CreateEllipticRgnIndirect", (FARPROC)NULL, (FARPROC *)&pCreateEllipticRgnIndirect, (FARPROC)extCreateEllipticRgnIndirect},
|
||||||
{"CreateRectRgnIndirect", (FARPROC)NULL, (FARPROC *)&pCreateRectRgnIndirect, (FARPROC)extCreateRectRgnIndirect},
|
//{"CreateRectRgn", (FARPROC)NULL, (FARPROC *)&pCreateRectRgn, (FARPROC)extCreateRectRgn},
|
||||||
{"CreatePolygonRgn", (FARPROC)NULL, (FARPROC *)&pCreatePolygonRgn, (FARPROC)extCreatePolygonRgn},
|
//{"CreateRectRgnIndirect", (FARPROC)NULL, (FARPROC *)&pCreateRectRgnIndirect, (FARPROC)extCreateRectRgnIndirect},
|
||||||
|
//{"CreatePolygonRgn", (FARPROC)NULL, (FARPROC *)&pCreatePolygonRgn, (FARPROC)extCreatePolygonRgn},
|
||||||
{"DrawTextA", (FARPROC)NULL, (FARPROC *)&pDrawText, (FARPROC)extDrawText},
|
{"DrawTextA", (FARPROC)NULL, (FARPROC *)&pDrawText, (FARPROC)extDrawText},
|
||||||
{"DrawTextExA", (FARPROC)NULL, (FARPROC *)&pDrawTextEx, (FARPROC)extDrawTextEx},
|
{"DrawTextExA", (FARPROC)NULL, (FARPROC *)&pDrawTextEx, (FARPROC)extDrawTextEx},
|
||||||
|
|
||||||
@ -123,11 +124,9 @@ static HookEntry_Type DDHooks[]={
|
|||||||
{"CreateDCA", (FARPROC)CreateDCA, (FARPROC *)&pGDICreateDC, (FARPROC)extDDCreateDC},
|
{"CreateDCA", (FARPROC)CreateDCA, (FARPROC *)&pGDICreateDC, (FARPROC)extDDCreateDC},
|
||||||
{"BitBlt", (FARPROC)BitBlt, (FARPROC *)&pGDIBitBlt, (FARPROC)extDDBitBlt},
|
{"BitBlt", (FARPROC)BitBlt, (FARPROC *)&pGDIBitBlt, (FARPROC)extDDBitBlt},
|
||||||
{"StretchBlt", (FARPROC)StretchBlt, (FARPROC *)&pGDIStretchBlt, (FARPROC)extDDStretchBlt},
|
{"StretchBlt", (FARPROC)StretchBlt, (FARPROC *)&pGDIStretchBlt, (FARPROC)extDDStretchBlt},
|
||||||
// {"PatBlt", (FARPROC)PatBlt, (FARPROC *)&pGDIPatBlt, (FARPROC)extDDPatBlt}, // missing one ...
|
|
||||||
// {"MaskBlt", (FARPROC)NULL, (FARPROC *)&pMaskBlt, (FARPROC)extMaskBlt},
|
|
||||||
|
|
||||||
{"GetClipBox", (FARPROC)NULL, (FARPROC *)&pGDIGetClipBox, (FARPROC)extGetClipBox},
|
{"GetClipBox", (FARPROC)NULL, (FARPROC *)&pGDIGetClipBox, (FARPROC)extGetClipBox},
|
||||||
|
// {"PatBlt", (FARPROC)PatBlt, (FARPROC *)&pGDIPatBlt, (FARPROC)extDDPatBlt}, // missing one ...
|
||||||
|
// {"MaskBlt", (FARPROC)NULL, (FARPROC *)&pMaskBlt, (FARPROC)extDDMaskBlt}, // missing one ...
|
||||||
{0, NULL, 0, 0} // terminator
|
{0, NULL, 0, 0} // terminator
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -315,7 +314,6 @@ int WINAPI extGetDeviceCaps(HDC hdc, int nindex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// if you have a bypassed setting, use it first!
|
// if you have a bypassed setting, use it first!
|
||||||
if(pSetDevMode){
|
if(pSetDevMode){
|
||||||
switch(nindex){
|
switch(nindex){
|
||||||
@ -618,18 +616,22 @@ extern HDC PrimHDC;
|
|||||||
|
|
||||||
HDC WINAPI extDDCreateCompatibleDC(HDC hdc)
|
HDC WINAPI extDDCreateCompatibleDC(HDC hdc)
|
||||||
{
|
{
|
||||||
HDC RetHdc, SrcHdc;
|
HDC RetHdc;
|
||||||
extern GetDC_Type pGetDC;
|
extern GetDC_Type pGetDC;
|
||||||
|
|
||||||
OutTraceDW("GDI.CreateCompatibleDC: hdc=%x\n", hdc);
|
OutTraceDW("GDI.CreateCompatibleDC: hdc=%x\n", hdc);
|
||||||
|
|
||||||
if(hdc==0 && pGetDC && dxw.IsFullScreen()){
|
if(dxw.IsDesktop(WindowFromDC(hdc)) && dxw.IsFullScreen()) {
|
||||||
dxw.SetPrimarySurface();
|
dxw.SetPrimarySurface();
|
||||||
(*pGetDC)(dxw.lpDDSPrimHDC,&SrcHdc);
|
if(!PrimHDC && dxw.lpDDSPrimHDC){
|
||||||
OutTraceDW("GDI.CreateCompatibleDC: duplicating screen HDC lpDDSPrimHDC=%x\n", dxw.lpDDSPrimHDC);
|
HRESULT res;
|
||||||
RetHdc=(*pGDICreateCompatibleDC)(SrcHdc);
|
STOPPER("null PrimHDC");
|
||||||
(*pReleaseDC)(dxw.lpDDSPrimHDC,SrcHdc);
|
res=(*pGetDC)(dxw.lpDDSPrimHDC, &PrimHDC);
|
||||||
}
|
if(res) OutTraceE("GDI.CreateCompatibleDC ERROR: GetDC lpdds=%x err=%d(%s) at %d\n", dxw.lpDDSPrimHDC, res, ExplainDDError(res), __LINE__);
|
||||||
|
}
|
||||||
|
OutTraceDW("GDI.CreateCompatibleDC: duplicating screen HDC lpDDSPrimHDC=%x SrcHdc=%x\n", dxw.lpDDSPrimHDC, PrimHDC);
|
||||||
|
RetHdc=(*pGDICreateCompatibleDC)(PrimHDC);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
RetHdc=(*pGDICreateCompatibleDC)(hdc);
|
RetHdc=(*pGDICreateCompatibleDC)(hdc);
|
||||||
|
|
||||||
@ -774,7 +776,6 @@ HDC WINAPI extDDGetWindowDC(HWND hwnd)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
|
||||||
int WINAPI extDDReleaseDC(HWND hwnd, HDC hDC)
|
int WINAPI extDDReleaseDC(HWND hwnd, HDC hDC)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
@ -796,27 +797,6 @@ int WINAPI extDDReleaseDC(HWND hwnd, HDC hDC)
|
|||||||
}
|
}
|
||||||
return(res);
|
return(res);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
int WINAPI extDDReleaseDC(HWND hwnd, HDC hDC)
|
|
||||||
{
|
|
||||||
int res;
|
|
||||||
extern HRESULT WINAPI extReleaseDC(LPDIRECTDRAWSURFACE, HDC);
|
|
||||||
|
|
||||||
OutTraceDW("GDI.ReleaseDC: hwnd=%x hdc=%x\n", hwnd, hDC);
|
|
||||||
res=0;
|
|
||||||
if (hDC == hPrimaryDC){
|
|
||||||
OutTraceDW("GDI.ReleaseDC: refreshing primary surface lpdds=%x\n",dxw.lpDDSPrimHDC);
|
|
||||||
//extReleaseDC(dxw.lpDDSPrimHDC, hDC);
|
|
||||||
hPrimaryDC=NULL;
|
|
||||||
res=1; // 1 = OK
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
res=(*pGDIReleaseDC)(hwnd, hDC);
|
|
||||||
if (!res) OutTraceE("GDI.ReleaseDC: ERROR err=%d at %d\n", GetLastError(), __LINE__);
|
|
||||||
}
|
|
||||||
return(res);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BOOL WINAPI extDDBitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, DWORD dwRop)
|
BOOL WINAPI extDDBitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, DWORD dwRop)
|
||||||
{
|
{
|
||||||
@ -829,19 +809,26 @@ BOOL WINAPI extDDBitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHe
|
|||||||
|
|
||||||
ret=1; // OK
|
ret=1; // OK
|
||||||
|
|
||||||
if(hdcDest==0) {
|
//if(hdcDest==0) {
|
||||||
|
if(dxw.IsDesktop(WindowFromDC(hdcDest))) {
|
||||||
|
OutTrace("hdcDest=%x PrimHDC=%x\n", hdcDest, PrimHDC);
|
||||||
hdcDest=PrimHDC;
|
hdcDest=PrimHDC;
|
||||||
if(hdcDest==0) {
|
if(hdcDest==0) {
|
||||||
dxw.ResetPrimarySurface();
|
dxw.ResetPrimarySurface();
|
||||||
dxw.SetPrimarySurface();
|
dxw.SetPrimarySurface();
|
||||||
res=extGetDC(dxw.lpDDSPrimHDC, &PrimHDC);
|
extGetDC(dxw.lpDDSPrimHDC, &PrimHDC);
|
||||||
hdcDest=PrimHDC;
|
hdcDest=PrimHDC;
|
||||||
}
|
}
|
||||||
|
res=(*pGDIBitBlt)(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
|
||||||
|
if(!res) OutTraceE("GDI.BitBlt: ERROR err=%d at %d\n", GetLastError(), __LINE__);
|
||||||
|
dxw.ScreenRefresh();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res=(*pGDIBitBlt)(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
|
res=(*pGDIBitBlt)(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
|
||||||
if(!res) OutTraceE("GDI.BitBlt: ERROR err=%d at %d\n", GetLastError(), __LINE__);
|
if(!res) OutTraceE("GDI.BitBlt: ERROR err=%d at %d\n", GetLastError(), __LINE__);
|
||||||
|
|
||||||
|
|
||||||
//dxw.SetPrimarySurface();
|
//dxw.SetPrimarySurface();
|
||||||
//OutTraceDW("GDI.StretchBlt: refreshing primary surface lpdds=%x\n",dxw.lpDDSPrimHDC);
|
//OutTraceDW("GDI.StretchBlt: refreshing primary surface lpdds=%x\n",dxw.lpDDSPrimHDC);
|
||||||
//sBlt("GDI.BitBlt", dxw.lpDDSPrimHDC, NULL, dxw.lpDDSPrimHDC, NULL, 0, NULL, 0);
|
//sBlt("GDI.BitBlt", dxw.lpDDSPrimHDC, NULL, dxw.lpDDSPrimHDC, NULL, 0, NULL, 0);
|
||||||
@ -857,10 +844,21 @@ BOOL WINAPI extDDStretchBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int
|
|||||||
{
|
{
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
RECT ClientRect;
|
RECT ClientRect;
|
||||||
|
extern HRESULT WINAPI extGetDC(LPDIRECTDRAWSURFACE, HDC FAR *);
|
||||||
|
|
||||||
OutTraceDW("GDI.StretchBlt: HDC=%x nXDest=%d nYDest=%d nWidth=%d nHeight=%d hdcSrc=%x nXSrc=%d nYSrc=%d nWSrc=%x nHSrc=%x dwRop=%x\n",
|
OutTraceDW("GDI.StretchBlt: HDC=%x nXDest=%d nYDest=%d nWidth=%d nHeight=%d hdcSrc=%x nXSrc=%d nYSrc=%d nWSrc=%x nHSrc=%x dwRop=%x\n",
|
||||||
hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, nWSrc, nHSrc, dwRop);
|
hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, nWSrc, nHSrc, dwRop);
|
||||||
|
|
||||||
|
//if(dxw.IsDesktop(WindowFromDC(hdcDest))) {
|
||||||
|
// hdcDest=PrimHDC;
|
||||||
|
// if(hdcDest==0) {
|
||||||
|
// dxw.ResetPrimarySurface();
|
||||||
|
// dxw.SetPrimarySurface();
|
||||||
|
// extGetDC(dxw.lpDDSPrimHDC, &PrimHDC);
|
||||||
|
// hdcDest=PrimHDC;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
if(hdcDest != hdcSrc){
|
if(hdcDest != hdcSrc){
|
||||||
(*pGetClientRect)(dxw.GethWnd(),&ClientRect);
|
(*pGetClientRect)(dxw.GethWnd(),&ClientRect);
|
||||||
ret=(*pGDIStretchBlt)(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, nWidth, nHeight, dwRop);
|
ret=(*pGDIStretchBlt)(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, nWidth, nHeight, dwRop);
|
||||||
@ -1936,6 +1934,13 @@ DWORD WINAPI extGetObjectType(HGDIOBJ h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
HBITMAP WINAPI extCreateDIBitmap(HDC hdc, const BITMAPINFOHEADER *lpbmih, DWORD fdwInit, const VOID *lpbInit, const BITMAPINFO *lpbmi, UINT fuUsage)
|
||||||
|
{
|
||||||
|
OutTrace("CreateDIBitmap: hdc=x dwInit=%x bInit=%x Usage=%x\n", hdc, fdwInit, lpbInit, fuUsage);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int WINAPI extSetMapMode(HDC hdc, int fnMapMode)
|
int WINAPI extSetMapMode(HDC hdc, int fnMapMode)
|
||||||
{
|
{
|
||||||
OutTraceDW("SetMapMode: hdc=%x MapMode=%d\n", hdc, fnMapMode);
|
OutTraceDW("SetMapMode: hdc=%x MapMode=%d\n", hdc, fnMapMode);
|
||||||
|
287
dll/kernel32.cpp
287
dll/kernel32.cpp
@ -6,6 +6,9 @@
|
|||||||
#include "hddraw.h"
|
#include "hddraw.h"
|
||||||
#include "ddproxy.h"
|
#include "ddproxy.h"
|
||||||
|
|
||||||
|
//#undef IsTraceDW
|
||||||
|
//#define IsTraceDW TRUE
|
||||||
|
|
||||||
static HookEntry_Type Hooks[]={
|
static HookEntry_Type Hooks[]={
|
||||||
{"IsDebuggerPresent", (FARPROC)NULL, (FARPROC *)NULL, (FARPROC)extIsDebuggerPresent},
|
{"IsDebuggerPresent", (FARPROC)NULL, (FARPROC *)NULL, (FARPROC)extIsDebuggerPresent},
|
||||||
{"GetProcAddress", (FARPROC)GetProcAddress, (FARPROC *)&pGetProcAddress, (FARPROC)extGetProcAddress},
|
{"GetProcAddress", (FARPROC)GetProcAddress, (FARPROC *)&pGetProcAddress, (FARPROC)extGetProcAddress},
|
||||||
@ -38,7 +41,6 @@ static HookEntry_Type TimeHooks[]={
|
|||||||
{"GetSystemTimeAsFileTime", (FARPROC)GetSystemTimeAsFileTime, (FARPROC *)&pGetSystemTimeAsFileTime, (FARPROC)extGetSystemTimeAsFileTime},
|
{"GetSystemTimeAsFileTime", (FARPROC)GetSystemTimeAsFileTime, (FARPROC *)&pGetSystemTimeAsFileTime, (FARPROC)extGetSystemTimeAsFileTime},
|
||||||
{"Sleep", (FARPROC)Sleep, (FARPROC *)&pSleep, (FARPROC)extSleep},
|
{"Sleep", (FARPROC)Sleep, (FARPROC *)&pSleep, (FARPROC)extSleep},
|
||||||
{"SleepEx", (FARPROC)SleepEx, (FARPROC *)&pSleepEx, (FARPROC)extSleepEx},
|
{"SleepEx", (FARPROC)SleepEx, (FARPROC *)&pSleepEx, (FARPROC)extSleepEx},
|
||||||
{"SetTimer", (FARPROC)SetTimer, (FARPROC *)&pSetTimer, (FARPROC)extSetTimer},
|
|
||||||
{"QueryPerformanceCounter", (FARPROC)NULL, (FARPROC *)&pQueryPerformanceCounter, (FARPROC)extQueryPerformanceCounter},
|
{"QueryPerformanceCounter", (FARPROC)NULL, (FARPROC *)&pQueryPerformanceCounter, (FARPROC)extQueryPerformanceCounter},
|
||||||
{"QueryPerformanceFrequency", (FARPROC)NULL, (FARPROC *)&pQueryPerformanceFrequency, (FARPROC)extQueryPerformanceFrequency},
|
{"QueryPerformanceFrequency", (FARPROC)NULL, (FARPROC *)&pQueryPerformanceFrequency, (FARPROC)extQueryPerformanceFrequency},
|
||||||
{0, NULL, 0, 0} // terminator
|
{0, NULL, 0, 0} // terminator
|
||||||
@ -46,7 +48,8 @@ static HookEntry_Type TimeHooks[]={
|
|||||||
|
|
||||||
static HookEntry_Type VersionHooks[]={
|
static HookEntry_Type VersionHooks[]={
|
||||||
{"GetVersion", (FARPROC)GetVersion, (FARPROC *)&pGetVersion, (FARPROC)extGetVersion},
|
{"GetVersion", (FARPROC)GetVersion, (FARPROC *)&pGetVersion, (FARPROC)extGetVersion},
|
||||||
{"GetVersionEx", (FARPROC)GetVersionEx, (FARPROC *)&pGetVersionEx, (FARPROC)extGetVersionEx},
|
{"GetVersionExA", (FARPROC)GetVersionExA, (FARPROC *)&pGetVersionExA, (FARPROC)extGetVersionExA},
|
||||||
|
{"GetVersionExW", (FARPROC)GetVersionExW, (FARPROC *)&pGetVersionExW, (FARPROC)extGetVersionExW},
|
||||||
{0, NULL, 0, 0} // terminator
|
{0, NULL, 0, 0} // terminator
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -199,11 +202,11 @@ static struct {char bMajor; char bMinor; char *sName;} WinVersions[9]=
|
|||||||
{6, 2, "Windows 8"}
|
{6, 2, "Windows 8"}
|
||||||
};
|
};
|
||||||
|
|
||||||
BOOL WINAPI extGetVersionEx(LPOSVERSIONINFO lpVersionInfo)
|
BOOL WINAPI extGetVersionExA(LPOSVERSIONINFOA lpVersionInfo)
|
||||||
{
|
{
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
ret=(*pGetVersionEx)(lpVersionInfo);
|
ret=(*pGetVersionExA)(lpVersionInfo);
|
||||||
if(!ret) {
|
if(!ret) {
|
||||||
OutTraceE("GetVersionEx: ERROR err=%d\n", GetLastError());
|
OutTraceE("GetVersionEx: ERROR err=%d\n", GetLastError());
|
||||||
return ret;
|
return ret;
|
||||||
@ -224,6 +227,31 @@ BOOL WINAPI extGetVersionEx(LPOSVERSIONINFO lpVersionInfo)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI extGetVersionExW(LPOSVERSIONINFOW lpVersionInfo)
|
||||||
|
{
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
ret=(*pGetVersionExW)(lpVersionInfo);
|
||||||
|
if(!ret) {
|
||||||
|
OutTraceE("GetVersionEx: ERROR err=%d\n", GetLastError());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
OutTraceDW("GetVersionEx: version=%d.%d build=(%d)\n",
|
||||||
|
lpVersionInfo->dwMajorVersion, lpVersionInfo->dwMinorVersion, lpVersionInfo->dwBuildNumber);
|
||||||
|
|
||||||
|
if(dxw.dwFlags2 & FAKEVERSION) {
|
||||||
|
// fake Win XP build 0
|
||||||
|
lpVersionInfo->dwMajorVersion = WinVersions[dxw.FakeVersionId].bMajor;
|
||||||
|
lpVersionInfo->dwMinorVersion = WinVersions[dxw.FakeVersionId].bMinor;
|
||||||
|
lpVersionInfo->dwBuildNumber = 0;
|
||||||
|
OutTraceDW("GetVersionEx: FIXED version=%d.%d build=(%d) os=\"%ls\"\n",
|
||||||
|
lpVersionInfo->dwMajorVersion, lpVersionInfo->dwMinorVersion, lpVersionInfo->dwBuildNumber,
|
||||||
|
WinVersions[dxw.FakeVersionId].sName);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
DWORD WINAPI extGetVersion(void)
|
DWORD WINAPI extGetVersion(void)
|
||||||
{
|
{
|
||||||
DWORD dwVersion;
|
DWORD dwVersion;
|
||||||
@ -284,17 +312,6 @@ void WINAPI extGetLocalTime(LPSYSTEMTIME lpLocalTime)
|
|||||||
lpLocalTime->wHour, lpLocalTime->wMinute, lpLocalTime->wSecond, lpLocalTime->wMilliseconds);
|
lpLocalTime->wHour, lpLocalTime->wMinute, lpLocalTime->wSecond, lpLocalTime->wMilliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT_PTR WINAPI extSetTimer(HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc)
|
|
||||||
{
|
|
||||||
UINT uShiftedElapse;
|
|
||||||
// beware: the quicker the time flows, the more the time clicks are incremented,
|
|
||||||
// and the lesser the pauses must be lasting! Shift operations are reverted in
|
|
||||||
// GetSystemTime vs. Sleep or SetTimer
|
|
||||||
uShiftedElapse = dxw.StretchTime(uElapse);
|
|
||||||
if (IsDebug) OutTrace("SetTimer: elapse=%d->%d timeshift=%d\n", uElapse, uShiftedElapse, dxw.TimeShift);
|
|
||||||
return (*pSetTimer)(hWnd, nIDEvent, uShiftedElapse, lpTimerFunc);
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID WINAPI extSleep(DWORD dwMilliseconds)
|
VOID WINAPI extSleep(DWORD dwMilliseconds)
|
||||||
{
|
{
|
||||||
DWORD dwNewDelay;
|
DWORD dwNewDelay;
|
||||||
@ -331,6 +348,45 @@ void WINAPI extGetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime)
|
|||||||
dxw.GetSystemTimeAsFileTime(lpSystemTimeAsFileTime);
|
dxw.GetSystemTimeAsFileTime(lpSystemTimeAsFileTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI extQueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount)
|
||||||
|
{
|
||||||
|
BOOL ret;
|
||||||
|
LARGE_INTEGER myPerfCount;
|
||||||
|
if(dxw.dwFlags4 & NOPERFCOUNTER){
|
||||||
|
ret=0;
|
||||||
|
myPerfCount.QuadPart = 0;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
ret=(*pQueryPerformanceCounter)(&myPerfCount);
|
||||||
|
myPerfCount = dxw.StretchCounter(myPerfCount);
|
||||||
|
}
|
||||||
|
*lpPerformanceCount = myPerfCount;
|
||||||
|
OutTraceB("QueryPerformanceCounter: ret=%x Count=%x-%x\n", ret, lpPerformanceCount->HighPart, lpPerformanceCount->LowPart);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI extQueryPerformanceFrequency(LARGE_INTEGER *lpPerformanceFrequency)
|
||||||
|
{
|
||||||
|
BOOL ret;
|
||||||
|
if(dxw.dwFlags4 & NOPERFCOUNTER){
|
||||||
|
LARGE_INTEGER myPerfFrequency;
|
||||||
|
myPerfFrequency.LowPart = 0L;
|
||||||
|
myPerfFrequency.HighPart = 0L;
|
||||||
|
*lpPerformanceFrequency=myPerfFrequency;
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret=(*pQueryPerformanceFrequency)(lpPerformanceFrequency);
|
||||||
|
OutTraceDW("QueryPerformanceFrequency: ret=%x Frequency=%x-%x\n", ret, lpPerformanceFrequency->HighPart, lpPerformanceFrequency->LowPart);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
LoadLibrary (hooking) related APIs
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
HMODULE SysLibs[SYSLIBIDX_MAX];
|
HMODULE SysLibs[SYSLIBIDX_MAX];
|
||||||
|
|
||||||
HMODULE WINAPI LoadLibraryExWrapper(LPCTSTR lpFileName, HANDLE hFile, DWORD dwFlags, char *api)
|
HMODULE WINAPI LoadLibraryExWrapper(LPCTSTR lpFileName, HANDLE hFile, DWORD dwFlags, char *api)
|
||||||
@ -536,6 +592,12 @@ FARPROC WINAPI extGetProcAddress(HMODULE hModule, LPCSTR proc)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
I/O related APIs
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
UINT WINAPI extGetDriveType(LPCTSTR lpRootPathName)
|
UINT WINAPI extGetDriveType(LPCTSTR lpRootPathName)
|
||||||
{
|
{
|
||||||
OutTraceDW("GetDriveType: path=\"%s\"\n", lpRootPathName);
|
OutTraceDW("GetDriveType: path=\"%s\"\n", lpRootPathName);
|
||||||
@ -543,91 +605,30 @@ UINT WINAPI extGetDriveType(LPCTSTR lpRootPathName)
|
|||||||
return (*pGetDriveType)(lpRootPathName);
|
return (*pGetDriveType)(lpRootPathName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HANDLE LastFile=NULL;
|
|
||||||
static int Where=0;
|
|
||||||
static DWORD FileLength;
|
|
||||||
static DWORD IOHeapSize;
|
|
||||||
static HANDLE IOHeap;
|
|
||||||
|
|
||||||
BOOL WINAPI extReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
|
BOOL WINAPI extReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
|
||||||
{
|
{
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
static char *IOBuffer=NULL;
|
static char *IOBuffer=NULL;
|
||||||
DWORD BytesRead;
|
|
||||||
DWORD Cursor;
|
|
||||||
//HANDLE hFileRead;
|
|
||||||
|
|
||||||
OutTrace("ReadFile: hFile=%x Buffer=%x BytesToRead=%d\n", hFile, lpBuffer, nNumberOfBytesToRead);
|
|
||||||
|
|
||||||
#define SECTOR_SIZE 4096
|
if(IsTraceDW){
|
||||||
//#define LEGACY_SIZE 1024
|
OutTrace("ReadFile: hFile=%x Buffer=%x BytesToRead=%d Overlapped=%x", hFile, lpBuffer, nNumberOfBytesToRead, lpOverlapped);
|
||||||
#define LEGACY_SIZE 1024
|
if(lpOverlapped) OutTrace("->(Offset=0x%x OffsetHigh=0x%x)", lpOverlapped->Offset, lpOverlapped->OffsetHigh);
|
||||||
|
|
||||||
if(!IOBuffer) { // initial allocation
|
|
||||||
IOHeap=HeapCreate(0, 0, 0);
|
|
||||||
IOHeapSize = SECTOR_SIZE*200;
|
|
||||||
if(IOHeap==NULL) OutTraceE("HeapCreate ERROR: err=%d at %d\n", GetLastError(), __LINE__);
|
|
||||||
IOBuffer=(char *)HeapAlloc(IOHeap, 0, IOHeapSize);
|
|
||||||
if(IOBuffer==0) OutTraceE("HeapAlloc ERROR: err=%d at %d\n", GetLastError(), __LINE__);
|
|
||||||
OutTrace("ReadFile: Heap=%x Buffer=%x\n", IOHeap, IOBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if reading current cached file ....
|
|
||||||
if(hFile==LastFile){
|
|
||||||
OutTrace("ReadFile: BUFFERED BEFORE BytesRequested=%d FileSize=%d where=%d\n",
|
|
||||||
nNumberOfBytesToRead, FileLength, Where);
|
|
||||||
if((Where+nNumberOfBytesToRead)<=FileLength)
|
|
||||||
*lpNumberOfBytesRead=nNumberOfBytesToRead;
|
|
||||||
else
|
|
||||||
*lpNumberOfBytesRead=FileLength-Where;
|
|
||||||
if (*lpNumberOfBytesRead < 0) *lpNumberOfBytesRead=0;
|
|
||||||
memcpy((char *)lpBuffer, IOBuffer+Where, *lpNumberOfBytesRead);
|
|
||||||
OutTrace("ReadFile: ");
|
|
||||||
for(unsigned int i=0; i<*lpNumberOfBytesRead; i++) OutTrace("%02X,", *((unsigned char *)lpBuffer+i));
|
|
||||||
OutTrace("\n");
|
OutTrace("\n");
|
||||||
OutTrace("ReadFile: BUFFERED READ BytesRequested=%d BytesRead=%d where=%d\n",
|
|
||||||
nNumberOfBytesToRead, *lpNumberOfBytesRead, Where);
|
|
||||||
Where += (*lpNumberOfBytesRead);
|
|
||||||
//Where = ((Where+(LEGACY_SIZE-1)) / LEGACY_SIZE) * LEGACY_SIZE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LastFile=hFile;
|
|
||||||
Where=Cursor=0;
|
|
||||||
// get the whole file
|
|
||||||
Where=(*pSetFilePointer)(hFile, 0, 0, FILE_CURRENT);
|
|
||||||
if(Where==INVALID_SET_FILE_POINTER){
|
|
||||||
OutTraceE("SetFilePointer ERROR: err=%d at %d\n", GetLastError(), __LINE__);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
if((*pSetFilePointer)(hFile, 0, 0, FILE_BEGIN)==INVALID_SET_FILE_POINTER){
|
|
||||||
OutTraceE("SetFilePointer ERROR: err=%d at %d\n", GetLastError(), __LINE__);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
OutTrace("SetFilePointer: current pos=%d\n", Where);
|
|
||||||
//hFileRead=ReOpenFile(hFile, 0, 0, 0);
|
|
||||||
do {// try to read it all
|
|
||||||
// when space is not enough, let's grow!
|
|
||||||
if((DWORD)(Cursor+SECTOR_SIZE) > (DWORD)IOHeapSize){
|
|
||||||
OutTrace("HeapReAlloc: about to add another chunk... current size=%d\n", IOHeapSize);
|
|
||||||
IOHeapSize += (200*SECTOR_SIZE);
|
|
||||||
IOBuffer=(char *)HeapReAlloc(IOHeap, 0, IOBuffer, IOHeapSize);
|
|
||||||
if(IOBuffer==0) OutTraceE("HeapReAlloc ERROR: err=%d at %d\n", GetLastError(), __LINE__);
|
|
||||||
}
|
|
||||||
ret=(*pReadFile)(hFile, IOBuffer+Cursor, SECTOR_SIZE, &BytesRead, NULL); // read one block
|
|
||||||
if(!ret)
|
|
||||||
OutTrace("ReadFIle ERROR: err=%d at %d\n", GetLastError(), __LINE__);
|
|
||||||
else
|
|
||||||
OutTrace("ReadFIle: BytesRead=%d\n", BytesRead);
|
|
||||||
Cursor+=BytesRead;
|
|
||||||
if (ret && BytesRead == 0) ret=FALSE; // eof
|
|
||||||
} while(ret);
|
|
||||||
//CloseHandle(hFileRead);
|
|
||||||
OutTrace("ReadFIle: BUFFERED FileSize=%d\n", Cursor);
|
|
||||||
FileLength=Cursor;
|
|
||||||
|
|
||||||
// recurse ...
|
ret = (*pReadFile)(hFile, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped);
|
||||||
return extReadFile(hFile, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped);
|
if(IsTraceDW){
|
||||||
|
if(ret){
|
||||||
|
OutTrace("ReadFile: NumberOfBytesRead=%d\n", *lpNumberOfBytesRead);
|
||||||
|
OutTrace("ReadFile: ");
|
||||||
|
for(unsigned int i=0; i<*lpNumberOfBytesRead; i++) OutTrace("%02X,", *((unsigned char *)lpBuffer+i));
|
||||||
|
OutTrace("\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
OutTrace("ReadFile: ERROR err=%d\n", GetLastError());
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE WINAPI extCreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
HANDLE WINAPI extCreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
||||||
@ -635,76 +636,41 @@ HANDLE WINAPI extCreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwS
|
|||||||
DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
|
DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
|
||||||
{
|
{
|
||||||
HANDLE ret;
|
HANDLE ret;
|
||||||
OutTrace("CreateFile: FileName=%s DesiredAccess=%x SharedMode=%x Disposition=%x Flags=%x\n",
|
OutTraceDW("CreateFile: FileName=%s DesiredAccess=%x SharedMode=%x Disposition=%x Flags=%x\n",
|
||||||
lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, dwFlagsAndAttributes);
|
lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, dwFlagsAndAttributes);
|
||||||
|
|
||||||
//dwFlagsAndAttributes &= ~FILE_FLAG_NO_BUFFERING;
|
// just proxy
|
||||||
|
if(!(dxw.dwFlags3 & BUFFEREDIOFIX))
|
||||||
|
return (*pCreateFile)(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
|
||||||
|
|
||||||
|
if((dxw.dwFlags3 & BUFFEREDIOFIX) && (dwFlagsAndAttributes & FILE_FLAG_NO_BUFFERING)){
|
||||||
|
OutTraceDW("CreateFile: suppress FILE_FLAG_NO_BUFFERING\n");
|
||||||
|
dwFlagsAndAttributes &= ~FILE_FLAG_NO_BUFFERING;
|
||||||
|
}
|
||||||
|
|
||||||
ret=(*pCreateFile)(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
|
ret=(*pCreateFile)(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
|
||||||
if(ret && (ret != (HANDLE)INVALID_SET_FILE_POINTER))
|
if(IsTraceDW){
|
||||||
OutTrace("CreateFile: ret=%x\n", ret);
|
if(ret && (ret != (HANDLE)INVALID_SET_FILE_POINTER))
|
||||||
else
|
OutTrace("CreateFile: ret=%x\n", ret);
|
||||||
OutTraceE("CreateFile ERROR: err=%d\n", GetLastError());
|
else
|
||||||
|
OutTrace("CreateFile ERROR: err=%d\n", GetLastError());
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI extCloseHandle(HANDLE hObject)
|
BOOL WINAPI extCloseHandle(HANDLE hObject)
|
||||||
{
|
{
|
||||||
if (hObject==LastFile) {
|
OutTrace("CloseHandle: hFile=%x\n", hObject);
|
||||||
LastFile=0; // invalidate cache
|
|
||||||
OutTrace("CloseHandle: INVALIDATE CACHE hFile=%x\n", hObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (*pCloseHandle)(hObject);
|
return (*pCloseHandle)(hObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD WINAPI extSetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
|
DWORD WINAPI extSetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
|
||||||
{
|
{
|
||||||
DWORD ret;
|
OutTrace("SetFilePointer: hFile=%x DistanceToMove=0x%lx DistanceToMoveHigh=0x%x MoveMethod=%x\n",
|
||||||
OutTrace("SetFilePointer: hFile=%x DistanceToMove=%ld DistanceToMoveHigh=%x MoveMethod=%x\n",
|
|
||||||
hFile, lDistanceToMove, lpDistanceToMoveHigh, dwMoveMethod);
|
hFile, lDistanceToMove, lpDistanceToMoveHigh, dwMoveMethod);
|
||||||
|
|
||||||
// if cached file ...
|
return (*pSetFilePointer)(hFile, lDistanceToMove, lpDistanceToMoveHigh, dwMoveMethod);
|
||||||
if(LastFile==hFile){
|
|
||||||
int LastPos=Where;
|
|
||||||
if(!lpDistanceToMoveHigh){
|
|
||||||
OutTrace("SetFilePointer: buffered move\n");
|
|
||||||
switch(dwMoveMethod){
|
|
||||||
case FILE_BEGIN: Where=lDistanceToMove; break;
|
|
||||||
case FILE_CURRENT: Where+=lDistanceToMove; break;
|
|
||||||
case FILE_END: Where=FileLength-lDistanceToMove; break;
|
|
||||||
}
|
|
||||||
//if(Where % LEGACY_SIZE){
|
|
||||||
// Where=LastPos;
|
|
||||||
// SetLastError(ERROR_INVALID_PARAMETER);
|
|
||||||
// OutTrace("SetFilePointer: ret=INVALID_SET_FILE_POINTER pos=%d\n", Where);
|
|
||||||
// return INVALID_SET_FILE_POINTER;
|
|
||||||
//}
|
|
||||||
|
|
||||||
// Where = ((Where + LEGACY_SIZE-1) / LEGACY_SIZE) * LEGACY_SIZE;
|
|
||||||
|
|
||||||
Where = (Where / LEGACY_SIZE) * LEGACY_SIZE;
|
|
||||||
|
|
||||||
OutTrace("SetFilePointer: ret=0x%x(#%d)\n", Where, Where);
|
|
||||||
return Where;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// proxy
|
|
||||||
ret=(*pSetFilePointer)(hFile, lDistanceToMove, lpDistanceToMoveHigh, dwMoveMethod);
|
|
||||||
if(lpDistanceToMoveHigh){
|
|
||||||
if(ret)
|
|
||||||
OutTrace("SetFilePointer: DistanceToMoveHigh=%x\n", *lpDistanceToMoveHigh);
|
|
||||||
else
|
|
||||||
OutTraceE("SetFilePointer ERROR: err=%d\n", GetLastError());
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(ret==INVALID_SET_FILE_POINTER)
|
|
||||||
OutTraceE("SetFilePointer ERROR: err=%d\n", GetLastError());
|
|
||||||
else
|
|
||||||
OutTrace("SetFilePointer: ret=%x\n", ret);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI extCreateProcessA(
|
BOOL WINAPI extCreateProcessA(
|
||||||
@ -723,36 +689,3 @@ BOOL WINAPI extCreateProcessA(
|
|||||||
OutTraceDW("CreateProcess: SUPPRESS ApplicationName=%s CommandLine=\"%s\"\n", lpApplicationName, lpCommandLine);
|
OutTraceDW("CreateProcess: SUPPRESS ApplicationName=%s CommandLine=\"%s\"\n", lpApplicationName, lpCommandLine);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI extQueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount)
|
|
||||||
{
|
|
||||||
BOOL ret;
|
|
||||||
LARGE_INTEGER myPerfCount;
|
|
||||||
if(dxw.dwFlags4 & NOPERFCOUNTER){
|
|
||||||
ret=0;
|
|
||||||
myPerfCount.QuadPart = 0;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
ret=(*pQueryPerformanceCounter)(&myPerfCount);
|
|
||||||
myPerfCount = dxw.StretchCounter(myPerfCount);
|
|
||||||
}
|
|
||||||
*lpPerformanceCount = myPerfCount;
|
|
||||||
OutTraceB("QueryPerformanceCounter: ret=%x Count=%x-%x\n", ret, lpPerformanceCount->HighPart, lpPerformanceCount->LowPart);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL WINAPI extQueryPerformanceFrequency(LARGE_INTEGER *lpPerformanceFrequency)
|
|
||||||
{
|
|
||||||
BOOL ret;
|
|
||||||
if(dxw.dwFlags4 & NOPERFCOUNTER){
|
|
||||||
LARGE_INTEGER myPerfFrequency;
|
|
||||||
myPerfFrequency.LowPart = 0L;
|
|
||||||
myPerfFrequency.HighPart = 0L;
|
|
||||||
*lpPerformanceFrequency=myPerfFrequency;
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ret=(*pQueryPerformanceFrequency)(lpPerformanceFrequency);
|
|
||||||
OutTraceDW("QueryPerformanceFrequency: ret=%x Frequency=%x-%x\n", ret, lpPerformanceFrequency->HighPart, lpPerformanceFrequency->LowPart);
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1,179 +0,0 @@
|
|||||||
#include <dxdiag.h>
|
|
||||||
#include "dxwnd.h"
|
|
||||||
#include "dxwcore.hpp"
|
|
||||||
#include "syslibs.h"
|
|
||||||
#include "dxhook.h"
|
|
||||||
#include "dxhelper.h"
|
|
||||||
|
|
||||||
extern void HookModule(HMODULE, int);
|
|
||||||
|
|
||||||
static HookEntry_Type Hooks[]={
|
|
||||||
{"CoCreateInstance", NULL, (FARPROC *)&pCoCreateInstance, (FARPROC)extCoCreateInstance},
|
|
||||||
{"CoCreateInstanceEx", NULL, (FARPROC *)&pCoCreateInstanceEx, (FARPROC)extCoCreateInstanceEx},
|
|
||||||
{"CoInitialize", NULL, (FARPROC *)&pCoInitialize, (FARPROC)extCoInitialize},
|
|
||||||
{0, NULL, 0, 0} // terminator
|
|
||||||
};
|
|
||||||
|
|
||||||
extern HRESULT WINAPI extDirectDrawCreate(GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *);
|
|
||||||
extern HRESULT WINAPI extDirectDrawCreateEx(GUID FAR *, LPDIRECTDRAW FAR *, REFIID, IUnknown FAR *);
|
|
||||||
|
|
||||||
void HookOle32(HMODULE module)
|
|
||||||
{
|
|
||||||
HookLibrary(module, Hooks, "ole32.dll");
|
|
||||||
}
|
|
||||||
|
|
||||||
FARPROC Remap_ole32_ProcAddress(LPCSTR proc, HMODULE hModule)
|
|
||||||
{
|
|
||||||
FARPROC addr;
|
|
||||||
if (addr=RemapLibrary(proc, hModule, Hooks)) return addr;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// so far, there are 4 additional libraries that could be loaded by meand of a CoCreateInstance call....
|
|
||||||
|
|
||||||
#define ADDITIONAL_MODULE_COUNT 4
|
|
||||||
struct {
|
|
||||||
BOOL Hooked;
|
|
||||||
char *ModuleName;
|
|
||||||
} AddedModules[ADDITIONAL_MODULE_COUNT]=
|
|
||||||
{
|
|
||||||
{FALSE, "quartz"},
|
|
||||||
{FALSE, "ddrawex"},
|
|
||||||
{FALSE, "amstream"},
|
|
||||||
{FALSE, "dplayx"}
|
|
||||||
};
|
|
||||||
|
|
||||||
static void HookAdditionalModules()
|
|
||||||
{
|
|
||||||
for(int i=0; i<ADDITIONAL_MODULE_COUNT; i++){
|
|
||||||
if(!AddedModules[i].Hooked){ // if the module is not hooked yet...
|
|
||||||
HMODULE hModule;
|
|
||||||
hModule=GetModuleHandle(AddedModules[i].ModuleName);
|
|
||||||
if(hModule){ // --- and now it exists ...
|
|
||||||
HookModule(hModule, 0); // ... then hook it and ..
|
|
||||||
AddedModules[i].Hooked=TRUE; // .. mark it as already hooked
|
|
||||||
OutTraceDW("CoCreateInstance: hooked module=%s hmodule=%x\n", AddedModules[i].ModuleName, hModule);
|
|
||||||
//CloseHandle(hModule); // do NOT close this handle
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
// Ole32 CoCreateInstance handling: you can create DirectDraw objects through it!
|
|
||||||
// utilized so far in a single game: Axiz & Allies
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void HookDDSession(LPDIRECTDRAW *, int);
|
|
||||||
|
|
||||||
HRESULT STDAPICALLTYPE extCoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID FAR* ppv)
|
|
||||||
{
|
|
||||||
HRESULT res;
|
|
||||||
OutTraceDW("CoCreateInstance: rclsid=%x UnkOuter=%x ClsContext=%x refiid=%x(%s)\n",
|
|
||||||
rclsid, pUnkOuter, dwClsContext, riid.Data1, ExplainGUID((GUID *)&riid));
|
|
||||||
|
|
||||||
res=(*pCoCreateInstance)(rclsid, pUnkOuter, dwClsContext, riid, ppv);
|
|
||||||
if(res)
|
|
||||||
OutTraceE("CoCreateInstance: ERROR res=%x\n", res);
|
|
||||||
else
|
|
||||||
OutTraceDW("CoCreateInstance: ppv=%x->%x\n", *ppv, *(DWORD *)*ppv);
|
|
||||||
|
|
||||||
if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DirectDraw){
|
|
||||||
OutTraceDW("CoCreateInstance: CLSID_DirectDraw object\n");
|
|
||||||
switch (*(DWORD *)&riid){
|
|
||||||
case 0x6C14DB80:
|
|
||||||
OutTraceDW("CoCreateInstance: IID_DirectDraw RIID lpdd=%x\n", *ppv);
|
|
||||||
HookDDSession((LPDIRECTDRAW *)ppv, 1);
|
|
||||||
break;
|
|
||||||
case 0xB3A6F3E0:
|
|
||||||
OutTraceDW("CoCreateInstance: IID_DirectDraw2 RIID lpdd=%x\n", *ppv);
|
|
||||||
HookDDSession((LPDIRECTDRAW *)ppv, 2);
|
|
||||||
break;
|
|
||||||
case 0x9c59509a:
|
|
||||||
OutTraceDW("CoCreateInstance: IID_DirectDraw4 RIID lpdd=%x\n", *ppv);
|
|
||||||
HookDDSession((LPDIRECTDRAW *)ppv, 4);
|
|
||||||
case 0x15e65ec0:
|
|
||||||
OutTraceDW("CoCreateInstance: IID_DirectDraw7 RIID lpdd=%x\n", *ppv);
|
|
||||||
HookDDSession((LPDIRECTDRAW *)ppv, 7);
|
|
||||||
break;
|
|
||||||
case 0xe436ebb3:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DxDiagProvider) res=HookDxDiag(riid, ppv);
|
|
||||||
|
|
||||||
HookAdditionalModules();
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT STDAPICALLTYPE extCoCreateInstanceEx(REFCLSID rclsid, IUnknown *punkOuter, DWORD dwClsCtx, COSERVERINFO *pServerInfo, DWORD dwCount, MULTI_QI *pResults)
|
|
||||||
{
|
|
||||||
HRESULT res;
|
|
||||||
DWORD i;
|
|
||||||
|
|
||||||
OutTraceDW("CoCreateInstanceEx: rclsid=%x UnkOuter=%x ClsContext=%x Count=%d\n",
|
|
||||||
rclsid, punkOuter, dwClsCtx, dwCount);
|
|
||||||
|
|
||||||
res=(*pCoCreateInstanceEx)(rclsid, punkOuter, dwClsCtx, pServerInfo, dwCount, pResults);
|
|
||||||
if(res) {
|
|
||||||
OutTraceE("CoCreateInstanceEx: ERROR res=%x\n", res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i=0; i<dwCount; i++){
|
|
||||||
LPVOID FAR* ppv;
|
|
||||||
IID riid;
|
|
||||||
|
|
||||||
if(pResults[i].hr) continue;
|
|
||||||
|
|
||||||
riid=*pResults[i].pIID;
|
|
||||||
ppv=(LPVOID *)pResults[i].pItf;
|
|
||||||
|
|
||||||
// CLSID e436ebb3 implies loading quartz.dll to play movies through dshow:
|
|
||||||
// quartz.dll must be hooked.
|
|
||||||
if (*(DWORD *)&rclsid==0xe436ebb3){
|
|
||||||
HMODULE qlib;
|
|
||||||
OutTraceDW("CoCreateInstanceEx: CLSID_FilterGraph RIID=%x\n", *(DWORD *)&riid);
|
|
||||||
qlib=(*pLoadLibraryA)("quartz.dll");
|
|
||||||
OutTraceDW("CoCreateInstanceEx: quartz lib handle=%x\n", qlib);
|
|
||||||
HookModule(qlib, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DirectDraw){
|
|
||||||
OutTraceDW("CoCreateInstanceEx: CLSID_DirectDraw object\n");
|
|
||||||
switch (*(DWORD *)&riid){
|
|
||||||
case 0x6C14DB80:
|
|
||||||
OutTraceDW("CoCreateInstanceEx: IID_DirectDraw RIID lpdd=%x\n", *ppv);
|
|
||||||
HookDDSession((LPDIRECTDRAW *)ppv, 1);
|
|
||||||
break;
|
|
||||||
case 0xB3A6F3E0:
|
|
||||||
OutTraceDW("CoCreateInstanceEx: IID_DirectDraw2 RIID lpdd=%x\n", *ppv);
|
|
||||||
HookDDSession((LPDIRECTDRAW *)ppv, 2);
|
|
||||||
break;
|
|
||||||
case 0x9c59509a:
|
|
||||||
OutTraceDW("CoCreateInstanceEx: IID_DirectDraw4 RIID lpdd=%x\n", *ppv);
|
|
||||||
HookDDSession((LPDIRECTDRAW *)ppv, 4);
|
|
||||||
case 0x15e65ec0:
|
|
||||||
OutTraceDW("CoCreateInstanceEx: IID_DirectDraw7 RIID lpdd=%x\n", *ppv);
|
|
||||||
HookDDSession((LPDIRECTDRAW *)ppv, 7);
|
|
||||||
break;
|
|
||||||
case 0xe436ebb3:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DxDiagProvider) res=HookDxDiag(riid, ppv);
|
|
||||||
}
|
|
||||||
|
|
||||||
HookAdditionalModules();
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT WINAPI extCoInitialize(LPVOID pvReserved)
|
|
||||||
{
|
|
||||||
HRESULT res;
|
|
||||||
OutTraceDW("CoInitialize: Reserved=%x\n", pvReserved);
|
|
||||||
res=(*pCoInitialize)(pvReserved);
|
|
||||||
return res;
|
|
||||||
}
|
|
@ -1,228 +0,0 @@
|
|||||||
#include <dxdiag.h>
|
|
||||||
#include "dxwnd.h"
|
|
||||||
#include "dxwcore.hpp"
|
|
||||||
#include "syslibs.h"
|
|
||||||
#include "dxhook.h"
|
|
||||||
#include "dxhelper.h"
|
|
||||||
|
|
||||||
extern void HookModule(HMODULE, int);
|
|
||||||
|
|
||||||
static HookEntry_Type Hooks[]={
|
|
||||||
{"CoCreateInstance", NULL, (FARPROC *)&pCoCreateInstance, (FARPROC)extCoCreateInstance},
|
|
||||||
{"CoCreateInstanceEx", NULL, (FARPROC *)&pCoCreateInstanceEx, (FARPROC)extCoCreateInstanceEx},
|
|
||||||
{"CoInitialize", NULL, (FARPROC *)&pCoInitialize, (FARPROC)extCoInitialize},
|
|
||||||
{0, NULL, 0, 0} // terminator
|
|
||||||
};
|
|
||||||
|
|
||||||
extern HRESULT WINAPI extDirectDrawCreate(GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *);
|
|
||||||
extern HRESULT WINAPI extDirectDrawCreateEx(GUID FAR *, LPDIRECTDRAW FAR *, REFIID, IUnknown FAR *);
|
|
||||||
|
|
||||||
void HookOle32(HMODULE module)
|
|
||||||
{
|
|
||||||
HookLibrary(module, Hooks, "ole32.dll");
|
|
||||||
}
|
|
||||||
|
|
||||||
FARPROC Remap_ole32_ProcAddress(LPCSTR proc, HMODULE hModule)
|
|
||||||
{
|
|
||||||
FARPROC addr;
|
|
||||||
if (addr=RemapLibrary(proc, hModule, Hooks)) return addr;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// so far, there are 4 additional libraries that could be loaded by meand of a CoCreateInstance call....
|
|
||||||
|
|
||||||
#define ADDITIONAL_MODULE_COUNT 4
|
|
||||||
struct {
|
|
||||||
BOOL Hooked;
|
|
||||||
char *ModuleName;
|
|
||||||
} AddedModules[ADDITIONAL_MODULE_COUNT]=
|
|
||||||
{
|
|
||||||
{FALSE, "quartz"},
|
|
||||||
{FALSE, "ddrawex"},
|
|
||||||
{FALSE, "amstream"},
|
|
||||||
{FALSE, "dplayx"}
|
|
||||||
};
|
|
||||||
|
|
||||||
static void HookAdditionalModules()
|
|
||||||
{
|
|
||||||
for(int i=0; i<ADDITIONAL_MODULE_COUNT; i++){
|
|
||||||
if(!AddedModules[i].Hooked){ // if the module is not hooked yet...
|
|
||||||
HMODULE hModule;
|
|
||||||
hModule=GetModuleHandle(AddedModules[i].ModuleName);
|
|
||||||
if(hModule){ // --- and now it exists ...
|
|
||||||
HookModule(hModule, 0); // ... then hook it and ..
|
|
||||||
AddedModules[i].Hooked=TRUE; // .. mark it as already hooked
|
|
||||||
OutTraceDW("CoCreateInstance: hooked module=%s hmodule=%x\n", AddedModules[i].ModuleName, hModule);
|
|
||||||
//CloseHandle(hModule); // do NOT close this handle
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
// Ole32 CoCreateInstance handling: you can create DirectDraw objects through it!
|
|
||||||
// utilized so far in a single game: Axiz & Allies
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void HookDDSession(LPDIRECTDRAW *, int);
|
|
||||||
static HRESULT STDAPICALLTYPE myCoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID FAR* ppv)
|
|
||||||
{
|
|
||||||
HRESULT res;
|
|
||||||
|
|
||||||
res=(*pCoCreateInstance)(rclsid, pUnkOuter, dwClsContext, riid, ppv);
|
|
||||||
if(res)
|
|
||||||
OutTraceE("CoCreateInstance: ERROR res=%x\n", res);
|
|
||||||
else
|
|
||||||
OutTraceDW("CoCreateInstance: ppv=%x->%x\n", *ppv, *(DWORD *)*ppv);
|
|
||||||
|
|
||||||
if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DirectDraw){
|
|
||||||
LPDIRECTDRAW lpOldDDraw;
|
|
||||||
OutTraceDW("CoCreateInstance: CLSID_DirectDraw object\n");
|
|
||||||
switch (*(DWORD *)&riid){
|
|
||||||
case 0x6C14DB80:
|
|
||||||
OutTraceDW("DirectDrawCreate: IID_DirectDraw RIID\n");
|
|
||||||
res=extDirectDrawCreate(NULL, (LPDIRECTDRAW *)&ppv, 0);
|
|
||||||
if(res)OutTraceDW("DirectDrawCreate: res=%x(%s)\n", res, ExplainDDError(res));
|
|
||||||
break;
|
|
||||||
case 0xB3A6F3E0:
|
|
||||||
OutTraceDW("DirectDrawCreate: IID_DirectDraw2 RIID\n");
|
|
||||||
res=extDirectDrawCreate(NULL, &lpOldDDraw, 0);
|
|
||||||
if(res)OutTraceDW("DirectDrawCreate: res=%x(%s)\n", res, ExplainDDError(res));
|
|
||||||
res=lpOldDDraw->QueryInterface(IID_IDirectDraw2, (LPVOID *)&ppv);
|
|
||||||
if(res)OutTraceDW("QueryInterface: res=%x(%s)\n", res, ExplainDDError(res));
|
|
||||||
lpOldDDraw->Release();
|
|
||||||
break;
|
|
||||||
case 0x9c59509a:
|
|
||||||
OutTraceDW("DirectDrawCreate: IID_DirectDraw4 RIID\n");
|
|
||||||
res=extDirectDrawCreate(NULL, &lpOldDDraw, 0);
|
|
||||||
if(res)OutTraceDW("DirectDrawCreate: res=%x(%s)\n", res, ExplainDDError(res));
|
|
||||||
res=lpOldDDraw->QueryInterface(IID_IDirectDraw4, (LPVOID *)&ppv);
|
|
||||||
if(res)OutTraceDW("QueryInterface: res=%x(%s)\n", res, ExplainDDError(res));
|
|
||||||
lpOldDDraw->Release();
|
|
||||||
case 0x15e65ec0:
|
|
||||||
OutTraceDW("CoCreateInstance: IID_DirectDraw7 RIID\n");
|
|
||||||
res=extDirectDrawCreateEx(NULL, (LPDIRECTDRAW *)&ppv, IID_IDirectDraw7, 0);
|
|
||||||
if(res)OutTraceDW("DirectDrawCreateEx: res=%x(%s)\n", res, ExplainDDError(res));
|
|
||||||
break;
|
|
||||||
case 0xe436ebb3:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DxDiagProvider) res=HookDxDiag(riid, ppv);
|
|
||||||
|
|
||||||
HookAdditionalModules();
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT STDAPICALLTYPE extCoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID FAR* ppv)
|
|
||||||
{
|
|
||||||
HRESULT res;
|
|
||||||
OutTraceDW("CoCreateInstance: rclsid=%x UnkOuter=%x ClsContext=%x refiid=%x(%s)\n",
|
|
||||||
rclsid, pUnkOuter, dwClsContext, riid.Data1, ExplainGUID((GUID *)&riid));
|
|
||||||
|
|
||||||
res=(*pCoCreateInstance)(rclsid, pUnkOuter, dwClsContext, riid, ppv);
|
|
||||||
if(res)
|
|
||||||
OutTraceE("CoCreateInstance: ERROR res=%x\n", res);
|
|
||||||
else
|
|
||||||
OutTraceDW("CoCreateInstance: ppv=%x->%x\n", *ppv, *(DWORD *)*ppv);
|
|
||||||
|
|
||||||
if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DirectDraw){
|
|
||||||
OutTraceDW("CoCreateInstance: CLSID_DirectDraw object\n");
|
|
||||||
switch (*(DWORD *)&riid){
|
|
||||||
case 0x6C14DB80:
|
|
||||||
OutTraceDW("CoCreateInstance: IID_DirectDraw RIID lpdd=%x\n", *ppv);
|
|
||||||
HookDDSession((LPDIRECTDRAW *)ppv, 1);
|
|
||||||
break;
|
|
||||||
case 0xB3A6F3E0:
|
|
||||||
OutTraceDW("CoCreateInstance: IID_DirectDraw2 RIID lpdd=%x\n", *ppv);
|
|
||||||
HookDDSession((LPDIRECTDRAW *)ppv, 2);
|
|
||||||
break;
|
|
||||||
case 0x9c59509a:
|
|
||||||
OutTraceDW("CoCreateInstance: IID_DirectDraw4 RIID lpdd=%x\n", *ppv);
|
|
||||||
HookDDSession((LPDIRECTDRAW *)ppv, 4);
|
|
||||||
case 0x15e65ec0:
|
|
||||||
OutTraceDW("CoCreateInstance: IID_DirectDraw7 RIID lpdd=%x\n", *ppv);
|
|
||||||
HookDDSession((LPDIRECTDRAW *)ppv, 7);
|
|
||||||
break;
|
|
||||||
case 0xe436ebb3:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DxDiagProvider) res=HookDxDiag(riid, ppv);
|
|
||||||
|
|
||||||
HookAdditionalModules();
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT STDAPICALLTYPE extCoCreateInstanceEx(REFCLSID rclsid, IUnknown *punkOuter, DWORD dwClsCtx, COSERVERINFO *pServerInfo, DWORD dwCount, MULTI_QI *pResults)
|
|
||||||
{
|
|
||||||
HRESULT res;
|
|
||||||
DWORD i;
|
|
||||||
|
|
||||||
OutTraceDW("CoCreateInstanceEx: rclsid=%x UnkOuter=%x ClsContext=%x Count=%d\n",
|
|
||||||
rclsid, punkOuter, dwClsCtx, dwCount);
|
|
||||||
|
|
||||||
res=(*pCoCreateInstanceEx)(rclsid, punkOuter, dwClsCtx, pServerInfo, dwCount, pResults);
|
|
||||||
if(res) {
|
|
||||||
OutTraceE("CoCreateInstanceEx: ERROR res=%x\n", res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i=0; i<dwCount; i++){
|
|
||||||
LPVOID FAR* ppv;
|
|
||||||
IID riid;
|
|
||||||
|
|
||||||
if(pResults[i].hr) continue;
|
|
||||||
|
|
||||||
riid=*pResults[i].pIID;
|
|
||||||
ppv=(LPVOID *)pResults[i].pItf;
|
|
||||||
|
|
||||||
// CLSID e436ebb3 implies loading quartz.dll to play movies through dshow:
|
|
||||||
// quartz.dll must be hooked.
|
|
||||||
if (*(DWORD *)&rclsid==0xe436ebb3){
|
|
||||||
HMODULE qlib;
|
|
||||||
OutTraceDW("CoCreateInstanceEx: CLSID_FilterGraph RIID=%x\n", *(DWORD *)&riid);
|
|
||||||
qlib=(*pLoadLibraryA)("quartz.dll");
|
|
||||||
OutTraceDW("CoCreateInstanceEx: quartz lib handle=%x\n", qlib);
|
|
||||||
HookModule(qlib, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DirectDraw){
|
|
||||||
OutTraceDW("CoCreateInstanceEx: CLSID_DirectDraw object\n");
|
|
||||||
switch (*(DWORD *)&riid){
|
|
||||||
case 0x6C14DB80:
|
|
||||||
OutTraceDW("CoCreateInstanceEx: IID_DirectDraw RIID lpdd=%x\n", *ppv);
|
|
||||||
HookDDSession((LPDIRECTDRAW *)ppv, 1);
|
|
||||||
break;
|
|
||||||
case 0xB3A6F3E0:
|
|
||||||
OutTraceDW("CoCreateInstanceEx: IID_DirectDraw2 RIID lpdd=%x\n", *ppv);
|
|
||||||
HookDDSession((LPDIRECTDRAW *)ppv, 2);
|
|
||||||
break;
|
|
||||||
case 0x9c59509a:
|
|
||||||
OutTraceDW("CoCreateInstanceEx: IID_DirectDraw4 RIID lpdd=%x\n", *ppv);
|
|
||||||
HookDDSession((LPDIRECTDRAW *)ppv, 4);
|
|
||||||
case 0x15e65ec0:
|
|
||||||
OutTraceDW("CoCreateInstanceEx: IID_DirectDraw7 RIID lpdd=%x\n", *ppv);
|
|
||||||
HookDDSession((LPDIRECTDRAW *)ppv, 7);
|
|
||||||
break;
|
|
||||||
case 0xe436ebb3:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (*(DWORD *)&rclsid==*(DWORD *)&CLSID_DxDiagProvider) res=HookDxDiag(riid, ppv);
|
|
||||||
}
|
|
||||||
|
|
||||||
HookAdditionalModules();
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT WINAPI extCoInitialize(LPVOID pvReserved)
|
|
||||||
{
|
|
||||||
HRESULT res;
|
|
||||||
OutTraceDW("CoInitialize: Reserved=%x\n", pvReserved);
|
|
||||||
res=(*pCoInitialize)(pvReserved);
|
|
||||||
return res;
|
|
||||||
}
|
|
@ -107,7 +107,8 @@ typedef void (WINAPI *GetSystemTime_Type)(LPSYSTEMTIME);
|
|||||||
typedef void (WINAPI *GetSystemTimeAsFileTime_Type)(LPFILETIME);
|
typedef void (WINAPI *GetSystemTimeAsFileTime_Type)(LPFILETIME);
|
||||||
typedef DWORD (WINAPI *GetTickCount_Type)(void);
|
typedef DWORD (WINAPI *GetTickCount_Type)(void);
|
||||||
typedef DWORD (WINAPI *GetVersion_Type)(void);
|
typedef DWORD (WINAPI *GetVersion_Type)(void);
|
||||||
typedef BOOL (WINAPI *GetVersionEx_Type)(LPOSVERSIONINFO);
|
typedef BOOL (WINAPI *GetVersionExA_Type)(LPOSVERSIONINFOA);
|
||||||
|
typedef BOOL (WINAPI *GetVersionExW_Type)(LPOSVERSIONINFOW);
|
||||||
typedef void (WINAPI *GlobalMemoryStatus_Type)(LPMEMORYSTATUS);
|
typedef void (WINAPI *GlobalMemoryStatus_Type)(LPMEMORYSTATUS);
|
||||||
typedef HMODULE (WINAPI *LoadLibraryA_Type)(LPCTSTR);
|
typedef HMODULE (WINAPI *LoadLibraryA_Type)(LPCTSTR);
|
||||||
typedef HMODULE (WINAPI *LoadLibraryExA_Type)(LPCTSTR, HANDLE, DWORD);
|
typedef HMODULE (WINAPI *LoadLibraryExA_Type)(LPCTSTR, HANDLE, DWORD);
|
||||||
@ -189,6 +190,8 @@ typedef HWND (WINAPI *SetCapture_Type)(HWND);
|
|||||||
typedef HWND (WINAPI *GetForegroundWindow_Type)(void);
|
typedef HWND (WINAPI *GetForegroundWindow_Type)(void);
|
||||||
typedef HWND (WINAPI *GetActiveWindow_Type)(void);
|
typedef HWND (WINAPI *GetActiveWindow_Type)(void);
|
||||||
typedef BOOL (WINAPI *IsWindowVisible_Type)(HWND);
|
typedef BOOL (WINAPI *IsWindowVisible_Type)(HWND);
|
||||||
|
typedef BOOL (WINAPI *SystemParametersInfo_Type)(UINT, UINT, PVOID, UINT);
|
||||||
|
typedef BOOL (WINAPI *KillTimer_Type)(HWND, UINT_PTR);
|
||||||
|
|
||||||
// Winmm.dll:
|
// Winmm.dll:
|
||||||
typedef MCIERROR(WINAPI *mciSendCommand_Type)(MCIDEVICEID, UINT, DWORD_PTR, DWORD_PTR);
|
typedef MCIERROR(WINAPI *mciSendCommand_Type)(MCIDEVICEID, UINT, DWORD_PTR, DWORD_PTR);
|
||||||
@ -307,7 +310,8 @@ DXWEXTERN GetSystemTime_Type pGetSystemTime DXWINITIALIZED;
|
|||||||
DXWEXTERN GetSystemTimeAsFileTime_Type pGetSystemTimeAsFileTime DXWINITIALIZED;
|
DXWEXTERN GetSystemTimeAsFileTime_Type pGetSystemTimeAsFileTime DXWINITIALIZED;
|
||||||
DXWEXTERN GetTickCount_Type pGetTickCount DXWINITIALIZED;
|
DXWEXTERN GetTickCount_Type pGetTickCount DXWINITIALIZED;
|
||||||
DXWEXTERN GetVersion_Type pGetVersion DXWINITIALIZED;
|
DXWEXTERN GetVersion_Type pGetVersion DXWINITIALIZED;
|
||||||
DXWEXTERN GetVersionEx_Type pGetVersionEx DXWINITIALIZED;
|
DXWEXTERN GetVersionExA_Type pGetVersionExA DXWINITIALIZED;
|
||||||
|
DXWEXTERN GetVersionExW_Type pGetVersionExW DXWINITIALIZED;
|
||||||
DXWEXTERN GlobalMemoryStatus_Type pGlobalMemoryStatus DXWINITIALIZED;
|
DXWEXTERN GlobalMemoryStatus_Type pGlobalMemoryStatus DXWINITIALIZED;
|
||||||
DXWEXTERN LoadLibraryA_Type pLoadLibraryA DXWINITIALIZED;
|
DXWEXTERN LoadLibraryA_Type pLoadLibraryA DXWINITIALIZED;
|
||||||
DXWEXTERN LoadLibraryExA_Type pLoadLibraryExA DXWINITIALIZED;
|
DXWEXTERN LoadLibraryExA_Type pLoadLibraryExA DXWINITIALIZED;
|
||||||
@ -384,6 +388,8 @@ DXWEXTERN SetCapture_Type pSetCapture DXWINITIALIZED;
|
|||||||
DXWEXTERN GetForegroundWindow_Type pGetForegroundWindow DXWINITIALIZED;
|
DXWEXTERN GetForegroundWindow_Type pGetForegroundWindow DXWINITIALIZED;
|
||||||
DXWEXTERN GetActiveWindow_Type pGetActiveWindow DXWINITIALIZED;
|
DXWEXTERN GetActiveWindow_Type pGetActiveWindow DXWINITIALIZED;
|
||||||
DXWEXTERN IsWindowVisible_Type pIsWindowVisible DXWINITIALIZED;
|
DXWEXTERN IsWindowVisible_Type pIsWindowVisible DXWINITIALIZED;
|
||||||
|
DXWEXTERN SystemParametersInfo_Type pSystemParametersInfoA DXWINITIALIZED;
|
||||||
|
DXWEXTERN KillTimer_Type pKillTimer DXWINITIALIZED;
|
||||||
|
|
||||||
// Winmm.dll:
|
// Winmm.dll:
|
||||||
DXWEXTERN mciSendCommand_Type pmciSendCommand DXWINITIALIZED;
|
DXWEXTERN mciSendCommand_Type pmciSendCommand DXWINITIALIZED;
|
||||||
@ -496,7 +502,8 @@ extern void WINAPI extGetSystemTime(LPSYSTEMTIME);
|
|||||||
extern void WINAPI extGetSystemTimeAsFileTime(LPFILETIME);
|
extern void WINAPI extGetSystemTimeAsFileTime(LPFILETIME);
|
||||||
extern DWORD WINAPI extGetTickCount(void);
|
extern DWORD WINAPI extGetTickCount(void);
|
||||||
extern DWORD WINAPI extGetVersion(void);
|
extern DWORD WINAPI extGetVersion(void);
|
||||||
extern BOOL WINAPI extGetVersionEx(LPOSVERSIONINFO);
|
extern BOOL WINAPI extGetVersionExA(LPOSVERSIONINFOA);
|
||||||
|
extern BOOL WINAPI extGetVersionExW(LPOSVERSIONINFOW);
|
||||||
extern void WINAPI extGlobalMemoryStatus(LPMEMORYSTATUS);
|
extern void WINAPI extGlobalMemoryStatus(LPMEMORYSTATUS);
|
||||||
extern int WINAPI extIsDebuggerPresent(void);
|
extern int WINAPI extIsDebuggerPresent(void);
|
||||||
extern HMODULE WINAPI extLoadLibraryA(LPCTSTR);
|
extern HMODULE WINAPI extLoadLibraryA(LPCTSTR);
|
||||||
@ -521,6 +528,7 @@ extern HRESULT STDAPICALLTYPE extCoInitialize(LPVOID);
|
|||||||
|
|
||||||
// user32.dll:
|
// user32.dll:
|
||||||
extern HDC WINAPI extBeginPaint(HWND, LPPAINTSTRUCT);
|
extern HDC WINAPI extBeginPaint(HWND, LPPAINTSTRUCT);
|
||||||
|
extern HDC WINAPI extDDBeginPaint(HWND, LPPAINTSTRUCT);
|
||||||
extern LRESULT WINAPI extCallWindowProc(WNDPROC, HWND, UINT, WPARAM, LPARAM);
|
extern LRESULT WINAPI extCallWindowProc(WNDPROC, HWND, UINT, WPARAM, LPARAM);
|
||||||
extern LONG WINAPI extChangeDisplaySettingsA(DEVMODEA *, DWORD);
|
extern LONG WINAPI extChangeDisplaySettingsA(DEVMODEA *, DWORD);
|
||||||
extern LONG WINAPI extChangeDisplaySettingsExA(LPCTSTR, DEVMODEA *, HWND, DWORD, LPVOID);
|
extern LONG WINAPI extChangeDisplaySettingsExA(LPCTSTR, DEVMODEA *, HWND, DWORD, LPVOID);
|
||||||
@ -534,6 +542,7 @@ extern HWND WINAPI extCreateWindowExA(DWORD, LPCTSTR, LPCTSTR, DWORD, int, int,
|
|||||||
extern HWND WINAPI extCreateWindowExW(DWORD, LPCWSTR, LPCWSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID);
|
extern HWND WINAPI extCreateWindowExW(DWORD, LPCWSTR, LPCWSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID);
|
||||||
extern LRESULT WINAPI extDefWindowProc(HWND, UINT, WPARAM, LPARAM);
|
extern LRESULT WINAPI extDefWindowProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
extern BOOL WINAPI extEndPaint(HWND, const PAINTSTRUCT *);
|
extern BOOL WINAPI extEndPaint(HWND, const PAINTSTRUCT *);
|
||||||
|
extern BOOL WINAPI extDDEndPaint(HWND, const PAINTSTRUCT *);
|
||||||
extern LONG WINAPI extEnumDisplaySettings(LPCTSTR, DWORD, DEVMODE *);
|
extern LONG WINAPI extEnumDisplaySettings(LPCTSTR, DWORD, DEVMODE *);
|
||||||
extern int WINAPI extFillRect(HDC, const RECT *, HBRUSH);
|
extern int WINAPI extFillRect(HDC, const RECT *, HBRUSH);
|
||||||
extern int WINAPI extFrameRect(HDC, const RECT *, HBRUSH);
|
extern int WINAPI extFrameRect(HDC, const RECT *, HBRUSH);
|
||||||
@ -578,6 +587,8 @@ extern HWND WINAPI extSetCapture(HWND);
|
|||||||
extern HWND WINAPI extGetForegroundWindow(void);
|
extern HWND WINAPI extGetForegroundWindow(void);
|
||||||
extern HWND WINAPI extGetActiveWindow(void);
|
extern HWND WINAPI extGetActiveWindow(void);
|
||||||
extern BOOL WINAPI extIsWindowVisible(HWND);
|
extern BOOL WINAPI extIsWindowVisible(HWND);
|
||||||
|
extern BOOL WINAPI extSystemParametersInfoA(UINT, UINT, PVOID, UINT);
|
||||||
|
extern BOOL WINAPI extKillTimer(HWND, UINT_PTR);
|
||||||
|
|
||||||
// Winmm.dll:
|
// Winmm.dll:
|
||||||
extern MCIERROR WINAPI extmciSendCommand(MCIDEVICEID, UINT, DWORD_PTR, DWORD_PTR);
|
extern MCIERROR WINAPI extmciSendCommand(MCIDEVICEID, UINT, DWORD_PTR, DWORD_PTR);
|
||||||
|
296
dll/user32.cpp
296
dll/user32.cpp
@ -19,8 +19,6 @@ static HookEntry_Type Hooks[]={
|
|||||||
{"ChangeDisplaySettingsExA", (FARPROC)NULL, (FARPROC *)&pChangeDisplaySettingsExA, (FARPROC)extChangeDisplaySettingsExA},
|
{"ChangeDisplaySettingsExA", (FARPROC)NULL, (FARPROC *)&pChangeDisplaySettingsExA, (FARPROC)extChangeDisplaySettingsExA},
|
||||||
{"ChangeDisplaySettingsW", (FARPROC)NULL, (FARPROC *)&pChangeDisplaySettingsW, (FARPROC)extChangeDisplaySettingsW}, // ref. by Knights of Honor
|
{"ChangeDisplaySettingsW", (FARPROC)NULL, (FARPROC *)&pChangeDisplaySettingsW, (FARPROC)extChangeDisplaySettingsW}, // ref. by Knights of Honor
|
||||||
{"ChangeDisplaySettingsExW", (FARPROC)NULL, (FARPROC *)&pChangeDisplaySettingsExW, (FARPROC)extChangeDisplaySettingsExW},
|
{"ChangeDisplaySettingsExW", (FARPROC)NULL, (FARPROC *)&pChangeDisplaySettingsExW, (FARPROC)extChangeDisplaySettingsExW},
|
||||||
{"BeginPaint", (FARPROC)BeginPaint, (FARPROC *)&pBeginPaint, (FARPROC)extBeginPaint},
|
|
||||||
{"EndPaint", (FARPROC)EndPaint, (FARPROC *)&pEndPaint, (FARPROC)extEndPaint},
|
|
||||||
{"ShowCursor", (FARPROC)ShowCursor, (FARPROC *)&pShowCursor, (FARPROC)extShowCursor},
|
{"ShowCursor", (FARPROC)ShowCursor, (FARPROC *)&pShowCursor, (FARPROC)extShowCursor},
|
||||||
{"CreateDialogIndirectParamA", (FARPROC)CreateDialogIndirectParamA, (FARPROC *)&pCreateDialogIndirectParam, (FARPROC)extCreateDialogIndirectParam},
|
{"CreateDialogIndirectParamA", (FARPROC)CreateDialogIndirectParamA, (FARPROC *)&pCreateDialogIndirectParam, (FARPROC)extCreateDialogIndirectParam},
|
||||||
{"CreateDialogParamA", (FARPROC)CreateDialogParamA, (FARPROC *)&pCreateDialogParam, (FARPROC)extCreateDialogParam},
|
{"CreateDialogParamA", (FARPROC)CreateDialogParamA, (FARPROC *)&pCreateDialogParam, (FARPROC)extCreateDialogParam},
|
||||||
@ -45,10 +43,19 @@ static HookEntry_Type Hooks[]={
|
|||||||
//{"GetActiveWindow", (FARPROC)NULL, (FARPROC *)&pGetActiveWindow, (FARPROC)extGetActiveWindow},
|
//{"GetActiveWindow", (FARPROC)NULL, (FARPROC *)&pGetActiveWindow, (FARPROC)extGetActiveWindow},
|
||||||
//{"GetForegroundWindow", (FARPROC)NULL, (FARPROC *)&pGetForegroundWindow, (FARPROC)extGetForegroundWindow},
|
//{"GetForegroundWindow", (FARPROC)NULL, (FARPROC *)&pGetForegroundWindow, (FARPROC)extGetForegroundWindow},
|
||||||
{"IsWindowVisible", (FARPROC)NULL, (FARPROC *)&pIsWindowVisible, (FARPROC)extIsWindowVisible},
|
{"IsWindowVisible", (FARPROC)NULL, (FARPROC *)&pIsWindowVisible, (FARPROC)extIsWindowVisible},
|
||||||
|
{"SystemParametersInfoA", (FARPROC)SystemParametersInfoA, (FARPROC *)&pSystemParametersInfoA, (FARPROC)extSystemParametersInfoA},
|
||||||
|
{0, NULL, 0, 0} // terminator
|
||||||
|
};
|
||||||
|
|
||||||
|
static HookEntry_Type NoGDIHooks[]={
|
||||||
|
{"BeginPaint", (FARPROC)BeginPaint, (FARPROC *)&pBeginPaint, (FARPROC)extBeginPaint},
|
||||||
|
{"EndPaint", (FARPROC)EndPaint, (FARPROC *)&pEndPaint, (FARPROC)extEndPaint},
|
||||||
{0, NULL, 0, 0} // terminator
|
{0, NULL, 0, 0} // terminator
|
||||||
};
|
};
|
||||||
|
|
||||||
static HookEntry_Type EmulateHooks[]={
|
static HookEntry_Type EmulateHooks[]={
|
||||||
|
{"BeginPaint", (FARPROC)BeginPaint, (FARPROC *)&pBeginPaint, (FARPROC)extBeginPaint},
|
||||||
|
{"EndPaint", (FARPROC)EndPaint, (FARPROC *)&pEndPaint, (FARPROC)extEndPaint},
|
||||||
{"GetDC", (FARPROC)GetDC, (FARPROC *)&pGDIGetDC, (FARPROC)extGDIGetDC},
|
{"GetDC", (FARPROC)GetDC, (FARPROC *)&pGDIGetDC, (FARPROC)extGDIGetDC},
|
||||||
{"GetWindowDC", (FARPROC)GetWindowDC, (FARPROC *)&pGDIGetWindowDC, (FARPROC)extGDIGetWindowDC},
|
{"GetWindowDC", (FARPROC)GetWindowDC, (FARPROC *)&pGDIGetWindowDC, (FARPROC)extGDIGetWindowDC},
|
||||||
{"ReleaseDC", (FARPROC)ReleaseDC, (FARPROC *)&pGDIReleaseDC, (FARPROC)extGDIReleaseDC},
|
{"ReleaseDC", (FARPROC)ReleaseDC, (FARPROC *)&pGDIReleaseDC, (FARPROC)extGDIReleaseDC},
|
||||||
@ -57,6 +64,8 @@ static HookEntry_Type EmulateHooks[]={
|
|||||||
};
|
};
|
||||||
|
|
||||||
static HookEntry_Type DDHooks[]={
|
static HookEntry_Type DDHooks[]={
|
||||||
|
{"BeginPaint", (FARPROC)BeginPaint, (FARPROC *)&pBeginPaint, (FARPROC)extDDBeginPaint},
|
||||||
|
{"EndPaint", (FARPROC)EndPaint, (FARPROC *)&pEndPaint, (FARPROC)extDDEndPaint},
|
||||||
{"GetDC", (FARPROC)GetDC, (FARPROC *)&pGDIGetDC, (FARPROC)extDDGetDC},
|
{"GetDC", (FARPROC)GetDC, (FARPROC *)&pGDIGetDC, (FARPROC)extDDGetDC},
|
||||||
{"GetWindowDC", (FARPROC)GetWindowDC, (FARPROC *)&pGDIGetWindowDC, (FARPROC)extDDGetDC},
|
{"GetWindowDC", (FARPROC)GetWindowDC, (FARPROC *)&pGDIGetWindowDC, (FARPROC)extDDGetDC},
|
||||||
{"ReleaseDC", (FARPROC)ReleaseDC, (FARPROC *)&pGDIReleaseDC, (FARPROC)extDDReleaseDC},
|
{"ReleaseDC", (FARPROC)ReleaseDC, (FARPROC *)&pGDIReleaseDC, (FARPROC)extDDReleaseDC},
|
||||||
@ -65,6 +74,8 @@ static HookEntry_Type DDHooks[]={
|
|||||||
};
|
};
|
||||||
|
|
||||||
static HookEntry_Type ScaledHooks[]={
|
static HookEntry_Type ScaledHooks[]={
|
||||||
|
{"BeginPaint", (FARPROC)BeginPaint, (FARPROC *)&pBeginPaint, (FARPROC)extBeginPaint},
|
||||||
|
{"EndPaint", (FARPROC)EndPaint, (FARPROC *)&pEndPaint, (FARPROC)extEndPaint},
|
||||||
{"GetDC", (FARPROC)GetDC, (FARPROC *)&pGDIGetDC, (FARPROC)extGDIGetDC},
|
{"GetDC", (FARPROC)GetDC, (FARPROC *)&pGDIGetDC, (FARPROC)extGDIGetDC},
|
||||||
{"GetDCEx", (FARPROC)NULL, (FARPROC *)&pGDIGetDCEx, (FARPROC)extGDIGetDCEx},
|
{"GetDCEx", (FARPROC)NULL, (FARPROC *)&pGDIGetDCEx, (FARPROC)extGDIGetDCEx},
|
||||||
{"GetWindowDC", (FARPROC)GetWindowDC, (FARPROC *)&pGDIGetWindowDC, (FARPROC)extGDIGetWindowDC},
|
{"GetWindowDC", (FARPROC)GetWindowDC, (FARPROC *)&pGDIGetWindowDC, (FARPROC)extGDIGetWindowDC},
|
||||||
@ -112,6 +123,12 @@ static HookEntry_Type MouseHooks2[]={
|
|||||||
{0, NULL, 0, 0} // terminator
|
{0, NULL, 0, 0} // terminator
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static HookEntry_Type TimeHooks[]={
|
||||||
|
{"SetTimer", (FARPROC)SetTimer, (FARPROC *)&pSetTimer, (FARPROC)extSetTimer},
|
||||||
|
{"KillTimer", (FARPROC)KillTimer, (FARPROC *)&pKillTimer, (FARPROC)extKillTimer},
|
||||||
|
{0, NULL, 0, 0} // terminator
|
||||||
|
};
|
||||||
|
|
||||||
FARPROC Remap_user32_ProcAddress(LPCSTR proc, HMODULE hModule)
|
FARPROC Remap_user32_ProcAddress(LPCSTR proc, HMODULE hModule)
|
||||||
{
|
{
|
||||||
FARPROC addr;
|
FARPROC addr;
|
||||||
@ -121,6 +138,8 @@ FARPROC Remap_user32_ProcAddress(LPCSTR proc, HMODULE hModule)
|
|||||||
if (dxw.dwFlags2 & GDISTRETCHED) if (addr=RemapLibrary(proc, hModule, ScaledHooks)) return addr;
|
if (dxw.dwFlags2 & GDISTRETCHED) if (addr=RemapLibrary(proc, hModule, ScaledHooks)) return addr;
|
||||||
if (dxw.dwFlags3 & GDIEMULATEDC) if (addr=RemapLibrary(proc, hModule, EmulateHooks)) return addr;
|
if (dxw.dwFlags3 & GDIEMULATEDC) if (addr=RemapLibrary(proc, hModule, EmulateHooks)) return addr;
|
||||||
if (dxw.dwFlags1 & MAPGDITOPRIMARY) if (addr=RemapLibrary(proc, hModule, DDHooks)) return addr;
|
if (dxw.dwFlags1 & MAPGDITOPRIMARY) if (addr=RemapLibrary(proc, hModule, DDHooks)) return addr;
|
||||||
|
if (!(dxw.dwFlags2 & GDISTRETCHED) && !(dxw.dwFlags3 & GDIEMULATEDC) && !(dxw.dwFlags1 & MAPGDITOPRIMARY))
|
||||||
|
if (addr=RemapLibrary(proc, hModule, NoGDIHooks)) return addr;
|
||||||
|
|
||||||
if (dxw.dwFlags1 & MODIFYMOUSE) if (addr=RemapLibrary(proc, hModule, MouseHooks)) return addr;
|
if (dxw.dwFlags1 & MODIFYMOUSE) if (addr=RemapLibrary(proc, hModule, MouseHooks)) return addr;
|
||||||
if (dxw.dwFlags1 & (PREVENTMAXIMIZE|FIXWINFRAME|LOCKWINPOS|LOCKWINSTYLE))
|
if (dxw.dwFlags1 & (PREVENTMAXIMIZE|FIXWINFRAME|LOCKWINPOS|LOCKWINSTYLE))
|
||||||
@ -129,6 +148,9 @@ FARPROC Remap_user32_ProcAddress(LPCSTR proc, HMODULE hModule)
|
|||||||
if (addr=RemapLibrary(proc, hModule, MouseHooks2)) return addr;
|
if (addr=RemapLibrary(proc, hModule, MouseHooks2)) return addr;
|
||||||
if (dxw.dwFlags3 & PEEKALLMESSAGES)
|
if (dxw.dwFlags3 & PEEKALLMESSAGES)
|
||||||
if (addr=RemapLibrary(proc, hModule, PeekAllHooks)) return addr;
|
if (addr=RemapLibrary(proc, hModule, PeekAllHooks)) return addr;
|
||||||
|
if(dxw.dwFlags2 & TIMESTRETCH)
|
||||||
|
if (addr=RemapLibrary(proc, hModule, TimeHooks)) return addr;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,15 +159,18 @@ static char *libname = "user32.dll";
|
|||||||
void HookUser32(HMODULE hModule)
|
void HookUser32(HMODULE hModule)
|
||||||
{
|
{
|
||||||
HookLibrary(hModule, Hooks, libname);
|
HookLibrary(hModule, Hooks, libname);
|
||||||
|
if (!(dxw.dwFlags2 & GDISTRETCHED) && !(dxw.dwFlags3 & GDIEMULATEDC) && !(dxw.dwFlags1 & MAPGDITOPRIMARY))
|
||||||
|
HookLibrary(hModule, NoGDIHooks, libname);
|
||||||
if (dxw.dwFlags3 & GDIEMULATEDC) HookLibrary(hModule, EmulateHooks, libname);
|
if (dxw.dwFlags3 & GDIEMULATEDC) HookLibrary(hModule, EmulateHooks, libname);
|
||||||
if (dxw.dwFlags2 & GDISTRETCHED) HookLibrary(hModule, ScaledHooks, libname);
|
if (dxw.dwFlags2 & GDISTRETCHED) HookLibrary(hModule, ScaledHooks, libname);
|
||||||
if (dxw.dwFlags1 & MAPGDITOPRIMARY) HookLibrary(hModule, DDHooks, libname);
|
if (dxw.dwFlags1 & MAPGDITOPRIMARY) HookLibrary(hModule, DDHooks, libname);
|
||||||
|
|
||||||
if (dxw.dwFlags1 & CLIENTREMAPPING) HookLibrary(hModule, RemapHooks, libname);
|
if (dxw.dwFlags1 & CLIENTREMAPPING) HookLibrary(hModule, RemapHooks, libname);
|
||||||
if(dxw.dwFlags1 & MODIFYMOUSE) HookLibrary(hModule, MouseHooks, libname);
|
if (dxw.dwFlags1 & MODIFYMOUSE) HookLibrary(hModule, MouseHooks, libname);
|
||||||
if (dxw.dwFlags1 & (PREVENTMAXIMIZE|FIXWINFRAME|LOCKWINPOS|LOCKWINSTYLE)) HookLibrary(hModule, WinHooks, libname);
|
if (dxw.dwFlags1 & (PREVENTMAXIMIZE|FIXWINFRAME|LOCKWINPOS|LOCKWINSTYLE)) HookLibrary(hModule, WinHooks, libname);
|
||||||
if((dxw.dwFlags1 & (MODIFYMOUSE|SLOWDOWN|KEEPCURSORWITHIN)) || (dxw.dwFlags2 & KEEPCURSORFIXED)) HookLibrary(hModule, MouseHooks2, libname);
|
if ((dxw.dwFlags1 & (MODIFYMOUSE|SLOWDOWN|KEEPCURSORWITHIN)) || (dxw.dwFlags2 & KEEPCURSORFIXED)) HookLibrary(hModule, MouseHooks2, libname);
|
||||||
if(dxw.dwFlags3 & PEEKALLMESSAGES) HookLibrary(hModule, PeekAllHooks, libname);
|
if (dxw.dwFlags3 & PEEKALLMESSAGES) HookLibrary(hModule, PeekAllHooks, libname);
|
||||||
|
if (dxw.dwFlags2 & TIMESTRETCH) HookLibrary(hModule, TimeHooks, libname);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -280,15 +305,18 @@ void dxwFixWindowPos(char *ApiName, HWND hwnd, LPARAM lParam)
|
|||||||
static int BorderX=-1;
|
static int BorderX=-1;
|
||||||
static int BorderY=-1;
|
static int BorderY=-1;
|
||||||
int cx, cy;
|
int cx, cy;
|
||||||
|
extern void CalculateWindowPos(HWND, DWORD, DWORD, LPWINDOWPOS);
|
||||||
|
|
||||||
OutTraceDW("%s: GOT hwnd=%x pos=(%d,%d) dim=(%d,%d) Flags=%x(%s)\n",
|
OutTraceDW("%s: GOT hwnd=%x pos=(%d,%d) dim=(%d,%d) Flags=%x(%s)\n",
|
||||||
ApiName, hwnd, wp->x, wp->y, wp->cx, wp->cy, wp->flags, ExplainWPFlags(wp->flags));
|
ApiName, hwnd, wp->x, wp->y, wp->cx, wp->cy, wp->flags, ExplainWPFlags(wp->flags));
|
||||||
|
|
||||||
if (dxw.dwFlags1 & PREVENTMAXIMIZE){
|
if (dxw.dwFlags1 & PREVENTMAXIMIZE){
|
||||||
int UpdFlag = 0;
|
int UpdFlag = 0;
|
||||||
|
WINDOWPOS MaxPos;
|
||||||
|
CalculateWindowPos(hwnd, MaxX, MaxY, &MaxPos);
|
||||||
|
|
||||||
if(wp->cx>MaxX) { wp->cx=MaxX; UpdFlag=1; }
|
if(wp->cx>MaxPos.cx) { wp->cx=MaxPos.cx; UpdFlag=1; }
|
||||||
if(wp->cy>MaxY) { wp->cy=MaxY; UpdFlag=1; }
|
if(wp->cy>MaxPos.cy) { wp->cy=MaxPos.cy; UpdFlag=1; }
|
||||||
if (UpdFlag)
|
if (UpdFlag)
|
||||||
OutTraceDW("%s: SET max dim=(%d,%d)\n", ApiName, wp->cx, wp->cy);
|
OutTraceDW("%s: SET max dim=(%d,%d)\n", ApiName, wp->cx, wp->cy);
|
||||||
}
|
}
|
||||||
@ -296,7 +324,6 @@ void dxwFixWindowPos(char *ApiName, HWND hwnd, LPARAM lParam)
|
|||||||
if ((wp->flags & (SWP_NOMOVE|SWP_NOSIZE))==(SWP_NOMOVE|SWP_NOSIZE)) return; //v2.02.13
|
if ((wp->flags & (SWP_NOMOVE|SWP_NOSIZE))==(SWP_NOMOVE|SWP_NOSIZE)) return; //v2.02.13
|
||||||
|
|
||||||
if ((dxw.dwFlags1 & LOCKWINPOS) && dxw.IsFullScreen() && (hwnd==dxw.GethWnd())){
|
if ((dxw.dwFlags1 & LOCKWINPOS) && dxw.IsFullScreen() && (hwnd==dxw.GethWnd())){
|
||||||
extern void CalculateWindowPos(HWND, DWORD, DWORD, LPWINDOWPOS);
|
|
||||||
CalculateWindowPos(hwnd, MaxX, MaxY, wp);
|
CalculateWindowPos(hwnd, MaxX, MaxY, wp);
|
||||||
OutTraceDW("%s: LOCK pos=(%d,%d) dim=(%d,%d)\n", ApiName, wp->x, wp->y, wp->cx, wp->cy);
|
OutTraceDW("%s: LOCK pos=(%d,%d) dim=(%d,%d)\n", ApiName, wp->x, wp->y, wp->cx, wp->cy);
|
||||||
}
|
}
|
||||||
@ -360,9 +387,15 @@ void dxwFixMinMaxInfo(char *ApiName, HWND hwnd, LPARAM lParam)
|
|||||||
lpmmi->ptMaxSize.x = dxw.GetScreenWidth();
|
lpmmi->ptMaxSize.x = dxw.GetScreenWidth();
|
||||||
lpmmi->ptMaxSize.y = dxw.GetScreenHeight();
|
lpmmi->ptMaxSize.y = dxw.GetScreenHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// allow for initial dimensions ....
|
||||||
|
//if(lpmmi->ptMaxSize.x < dxw.iSizX) lpmmi->ptMaxSize.x = dxw.iSizX;
|
||||||
|
//if(lpmmi->ptMaxSize.y < dxw.iSizY) lpmmi->ptMaxSize.y = dxw.iSizY;
|
||||||
|
|
||||||
OutTraceDW("%s: SET PREVENTMAXIMIZE MaxPosition=(%d,%d) MaxSize=(%d,%d)\n", ApiName,
|
OutTraceDW("%s: SET PREVENTMAXIMIZE MaxPosition=(%d,%d) MaxSize=(%d,%d)\n", ApiName,
|
||||||
lpmmi->ptMaxPosition.x, lpmmi->ptMaxPosition.y, lpmmi->ptMaxSize.x, lpmmi->ptMaxSize.y);
|
lpmmi->ptMaxPosition.x, lpmmi->ptMaxPosition.y, lpmmi->ptMaxSize.x, lpmmi->ptMaxSize.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// v2.1.75: added logic to fix win coordinates to selected ones.
|
// v2.1.75: added logic to fix win coordinates to selected ones.
|
||||||
// fixes the problem with "Achtung Spitfire", that can't be managed through PREVENTMAXIMIZE flag.
|
// fixes the problem with "Achtung Spitfire", that can't be managed through PREVENTMAXIMIZE flag.
|
||||||
if (dxw.dwFlags1 & LOCKWINPOS){
|
if (dxw.dwFlags1 & LOCKWINPOS){
|
||||||
@ -424,37 +457,6 @@ static LRESULT WINAPI FixWindowProc(char *ApiName, HWND hwnd, UINT Msg, WPARAM w
|
|||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static POINT FixMessagePt(HWND hwnd, POINT point)
|
|
||||||
{
|
|
||||||
RECT rect;
|
|
||||||
static POINT curr;
|
|
||||||
curr=point;
|
|
||||||
|
|
||||||
if(!(*pScreenToClient)(hwnd, &curr)){
|
|
||||||
OutTraceE("ScreenToClient ERROR=%d hwnd=%x at %d\n", GetLastError(), hwnd, __LINE__);
|
|
||||||
curr.x = curr.y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(*pGetClientRect)(hwnd, &rect)) {
|
|
||||||
OutTraceE("GetClientRect ERROR=%d hwnd=%x at %d\n", GetLastError(), hwnd, __LINE__);
|
|
||||||
curr.x = curr.y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ISDEBUG
|
|
||||||
if(IsDebug) OutTrace("FixMessagePt point=(%d,%d) hwnd=%x win pos=(%d,%d) size=(%d,%d)\n",
|
|
||||||
point.x, point.y, hwnd, point.x-curr.x, point.y-curr.y, rect.right, rect.bottom);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (curr.x < 0) curr.x=0;
|
|
||||||
if (curr.y < 0) curr.y=0;
|
|
||||||
if (curr.x > rect.right) curr.x=rect.right;
|
|
||||||
if (curr.y > rect.bottom) curr.y=rect.bottom;
|
|
||||||
if (rect.right) curr.x = (curr.x * dxw.GetScreenWidth()) / rect.right;
|
|
||||||
if (rect.bottom) curr.y = (curr.y * dxw.GetScreenHeight()) / rect.bottom;
|
|
||||||
|
|
||||||
return curr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// user32 API hookers
|
// user32 API hookers
|
||||||
@ -471,8 +473,6 @@ BOOL WINAPI extInvalidateRect(HWND hwnd, RECT *lpRect, BOOL bErase)
|
|||||||
OutTraceDW("InvalidateRect: hwnd=%x rect=NULL erase=%x\n",
|
OutTraceDW("InvalidateRect: hwnd=%x rect=NULL erase=%x\n",
|
||||||
hwnd, bErase);
|
hwnd, bErase);
|
||||||
|
|
||||||
//if(dxw.dwFlags3 & GDIEMULATEDC) return TRUE;
|
|
||||||
|
|
||||||
if(dxw.IsFullScreen() && dxw.IsRealDesktop(hwnd)) {
|
if(dxw.IsFullScreen() && dxw.IsRealDesktop(hwnd)) {
|
||||||
hwnd=dxw.GethWnd();
|
hwnd=dxw.GethWnd();
|
||||||
dxw.MapClient(lpRect);
|
dxw.MapClient(lpRect);
|
||||||
@ -646,7 +646,8 @@ BOOL WINAPI extSetWindowPos(HWND hwnd, HWND hWndInsertAfter, int X, int Y, int c
|
|||||||
rect.right=cx; rect.bottom=cy;
|
rect.right=cx; rect.bottom=cy;
|
||||||
dwCurStyle=(*pGetWindowLong)(hwnd, GWL_STYLE);
|
dwCurStyle=(*pGetWindowLong)(hwnd, GWL_STYLE);
|
||||||
dwExStyle=(*pGetWindowLong)(hwnd, GWL_EXSTYLE);
|
dwExStyle=(*pGetWindowLong)(hwnd, GWL_EXSTYLE);
|
||||||
hMenu = GetMenu(hwnd);
|
// BEWARE: from MSDN - If the window is a child window, the return value is undefined.
|
||||||
|
hMenu = (dwCurStyle & WS_CHILD) ? NULL : GetMenu(hwnd);
|
||||||
AdjustWindowRectEx(&rect, dwCurStyle, (hMenu!=NULL), dwExStyle);
|
AdjustWindowRectEx(&rect, dwCurStyle, (hMenu!=NULL), dwExStyle);
|
||||||
if (hMenu) CloseHandle(hMenu);
|
if (hMenu) CloseHandle(hMenu);
|
||||||
cx=rect.right; cy=rect.bottom;
|
cx=rect.right; cy=rect.bottom;
|
||||||
@ -1057,8 +1058,6 @@ static HWND WINAPI extCreateWindowCommon(
|
|||||||
if (dxw.dwFlags1 & PREVENTMAXIMIZE){
|
if (dxw.dwFlags1 & PREVENTMAXIMIZE){
|
||||||
OutTraceDW("%s: handling PREVENTMAXIMIZE mode\n", ApiName);
|
OutTraceDW("%s: handling PREVENTMAXIMIZE mode\n", ApiName);
|
||||||
dwStyle &= ~WS_MAXIMIZE;
|
dwStyle &= ~WS_MAXIMIZE;
|
||||||
//dwStyle &= ~(WS_MAXIMIZE | WS_POPUP);
|
|
||||||
//dwExStyle &= ~WS_EX_TOPMOST;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// v2.1.92: fixes size & position for auxiliary big window, often used
|
// v2.1.92: fixes size & position for auxiliary big window, often used
|
||||||
@ -1074,7 +1073,7 @@ static HWND WINAPI extCreateWindowCommon(
|
|||||||
((x<=0)&&(y<=0)) || ((x==CW_USEDEFAULT)&&(y==CW_USEDEFAULT))
|
((x<=0)&&(y<=0)) || ((x==CW_USEDEFAULT)&&(y==CW_USEDEFAULT))
|
||||||
)
|
)
|
||||||
&&
|
&&
|
||||||
((nWidth>=(int)dxw.GetScreenWidth())&&(nHeight>=(int)dxw.GetScreenHeight()))
|
((nWidth>=(int)dxw.GetScreenWidth())&&(nHeight>=(int)dxw.GetScreenHeight()))
|
||||||
&&
|
&&
|
||||||
!(dwExStyle & WS_EX_CONTROLPARENT) // Diablo fix
|
!(dwExStyle & WS_EX_CONTROLPARENT) // Diablo fix
|
||||||
&&
|
&&
|
||||||
@ -1123,7 +1122,7 @@ static HWND WINAPI extCreateWindowCommon(
|
|||||||
dxw.SetFullScreen(TRUE);
|
dxw.SetFullScreen(TRUE);
|
||||||
if(dxw.Coordinates==DXW_DESKTOP_WORKAREA){
|
if(dxw.Coordinates==DXW_DESKTOP_WORKAREA){
|
||||||
RECT workarea;
|
RECT workarea;
|
||||||
SystemParametersInfo(SPI_GETWORKAREA, NULL, &workarea, 0);
|
(*pSystemParametersInfoA)(SPI_GETWORKAREA, NULL, &workarea, 0);
|
||||||
x=0;
|
x=0;
|
||||||
y=0;
|
y=0;
|
||||||
nWidth=workarea.right;
|
nWidth=workarea.right;
|
||||||
@ -1197,10 +1196,12 @@ static HWND WINAPI extCreateWindowCommon(
|
|||||||
if ((dwStyle & WS_CHILD) && (dxw.dwFlags1 & HOOKCHILDWIN)){
|
if ((dwStyle & WS_CHILD) && (dxw.dwFlags1 & HOOKCHILDWIN)){
|
||||||
long res;
|
long res;
|
||||||
pWindowProc = (WNDPROC)(*pGetWindowLong)(wndh, GWL_WNDPROC);
|
pWindowProc = (WNDPROC)(*pGetWindowLong)(wndh, GWL_WNDPROC);
|
||||||
OutTraceDW("Hooking CHILD wndh=%x WindowProc %x->%x\n", wndh, pWindowProc, extChildWindowProc);
|
if((pWindowProc != extWindowProc) && (pWindowProc != extChildWindowProc)){ // avoid recursions
|
||||||
res=(*pSetWindowLong)(wndh, GWL_WNDPROC, (LONG)extChildWindowProc);
|
OutTraceDW("Hooking CHILD wndh=%x WindowProc %x->%x\n", wndh, pWindowProc, extChildWindowProc);
|
||||||
WhndStackPush(wndh, pWindowProc);
|
res=(*pSetWindowLong)(wndh, GWL_WNDPROC, (LONG)extChildWindowProc);
|
||||||
if(!res) OutTraceE("%s: SetWindowLong ERROR %x\n", ApiName, GetLastError());
|
WhndStackPush(wndh, pWindowProc);
|
||||||
|
if(!res) OutTraceE("%s: SetWindowLong ERROR %x\n", ApiName, GetLastError());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OutTraceDW("%s: ret=%x\n", ApiName, wndh);
|
OutTraceDW("%s: ret=%x\n", ApiName, wndh);
|
||||||
@ -1234,13 +1235,17 @@ HWND WINAPI extCreateWindowExW(
|
|||||||
LPVOID lpParam)
|
LPVOID lpParam)
|
||||||
{
|
{
|
||||||
if(IsTraceDW){
|
if(IsTraceDW){
|
||||||
char xString[20], yString[20];
|
char xString[20], yString[20], wString[20], hString[20];
|
||||||
if (x==CW_USEDEFAULT) strcpy(xString,"CW_USEDEFAULT");
|
if (x==CW_USEDEFAULT) strcpy(xString,"CW_USEDEFAULT");
|
||||||
else sprintf(xString,"%d", x);
|
else sprintf(xString,"%d", x);
|
||||||
if (y==CW_USEDEFAULT) strcpy(yString,"CW_USEDEFAULT");
|
if (y==CW_USEDEFAULT) strcpy(yString,"CW_USEDEFAULT");
|
||||||
else sprintf(yString,"%d", y);
|
else sprintf(yString,"%d", y);
|
||||||
OutTrace("CreateWindowExW: class=\"%ls\" wname=\"%ls\" pos=(%s,%s) size=(%d,%d) Style=%x(%s) ExStyle=%x(%s)\n",
|
if (nWidth==CW_USEDEFAULT) strcpy(wString,"CW_USEDEFAULT");
|
||||||
lpClassName, lpWindowName, xString, yString, nWidth, nHeight,
|
else sprintf(wString,"%d", nWidth);
|
||||||
|
if (nHeight==CW_USEDEFAULT) strcpy(hString,"CW_USEDEFAULT");
|
||||||
|
else sprintf(hString,"%d", nHeight);
|
||||||
|
OutTrace("CreateWindowExW: class=\"%ls\" wname=\"%ls\" pos=(%s,%s) size=(%s,%s) Style=%x(%s) ExStyle=%x(%s)\n",
|
||||||
|
lpClassName, lpWindowName, xString, yString, wString, hString,
|
||||||
dwStyle, ExplainStyle(dwStyle), dwExStyle, ExplainExStyle(dwExStyle));
|
dwStyle, ExplainStyle(dwStyle), dwExStyle, ExplainExStyle(dwExStyle));
|
||||||
}
|
}
|
||||||
if(IsDebug) OutTrace("CreateWindowExW: DEBUG screen=(%d,%d)\n", dxw.GetScreenWidth(), dxw.GetScreenHeight());
|
if(IsDebug) OutTrace("CreateWindowExW: DEBUG screen=(%d,%d)\n", dxw.GetScreenWidth(), dxw.GetScreenHeight());
|
||||||
@ -1264,13 +1269,17 @@ HWND WINAPI extCreateWindowExA(
|
|||||||
LPVOID lpParam)
|
LPVOID lpParam)
|
||||||
{
|
{
|
||||||
if(IsTraceDW){
|
if(IsTraceDW){
|
||||||
char xString[20], yString[20];
|
char xString[20], yString[20], wString[20], hString[20];
|
||||||
if (x==CW_USEDEFAULT) strcpy(xString,"CW_USEDEFAULT");
|
if (x==CW_USEDEFAULT) strcpy(xString,"CW_USEDEFAULT");
|
||||||
else sprintf(xString,"%d", x);
|
else sprintf(xString,"%d", x);
|
||||||
if (y==CW_USEDEFAULT) strcpy(yString,"CW_USEDEFAULT");
|
if (y==CW_USEDEFAULT) strcpy(yString,"CW_USEDEFAULT");
|
||||||
else sprintf(yString,"%d", y);
|
else sprintf(yString,"%d", y);
|
||||||
OutTrace("CreateWindowExA: class=\"%s\" wname=\"%s\" pos=(%s,%s) size=(%d,%d) Style=%x(%s) ExStyle=%x(%s)\n",
|
if (nWidth==CW_USEDEFAULT) strcpy(wString,"CW_USEDEFAULT");
|
||||||
ClassToStr(lpClassName), lpWindowName, xString, yString, nWidth, nHeight,
|
else sprintf(wString,"%d", nWidth);
|
||||||
|
if (nHeight==CW_USEDEFAULT) strcpy(hString,"CW_USEDEFAULT");
|
||||||
|
else sprintf(hString,"%d", nHeight);
|
||||||
|
OutTrace("CreateWindowExA: class=\"%s\" wname=\"%s\" pos=(%s,%s) size=(%s,%s) Style=%x(%s) ExStyle=%x(%s)\n",
|
||||||
|
ClassToStr(lpClassName), lpWindowName, xString, yString, wString, hString,
|
||||||
dwStyle, ExplainStyle(dwStyle), dwExStyle, ExplainExStyle(dwExStyle));
|
dwStyle, ExplainStyle(dwStyle), dwExStyle, ExplainExStyle(dwExStyle));
|
||||||
}
|
}
|
||||||
if(IsDebug) OutTrace("CreateWindowExA: DEBUG screen=(%d,%d)\n", dxw.GetScreenWidth(), dxw.GetScreenHeight());
|
if(IsDebug) OutTrace("CreateWindowExA: DEBUG screen=(%d,%d)\n", dxw.GetScreenWidth(), dxw.GetScreenHeight());
|
||||||
@ -1562,9 +1571,10 @@ HDC WINAPI extGDIGetDC(HWND hwnd)
|
|||||||
|
|
||||||
ret=(*pGDIGetDC)(lochwnd);
|
ret=(*pGDIGetDC)(lochwnd);
|
||||||
|
|
||||||
if((dxw.dwFlags3 & GDIEMULATEDC) && (dxw.IsDesktop(hwnd))){
|
if((dxw.dwFlags3 & GDIEMULATEDC) && (dxw.IsDesktop(hwnd)) && (dxw.VirtualHDC==NULL)){
|
||||||
ret=dxw.AcquireEmulatedDC(lochwnd);
|
ret=dxw.AcquireEmulatedDC(lochwnd);
|
||||||
OutTraceDW("GDI.GetDC(GDIEMULATEDC): remapping hdc=%x->%x\n", (*pGDIGetDC)(hwnd), ret);
|
OutTraceDW("GDI.GetDC(GDIEMULATEDC): remapping hdc=%x->%x\n", (*pGDIGetDC)(hwnd), ret);
|
||||||
|
dxw.VirtualHDC=ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ret){
|
if(ret){
|
||||||
@ -1664,7 +1674,7 @@ int WINAPI extGDIReleaseDC(HWND hwnd, HDC hDC)
|
|||||||
OutTraceDW("GDI.ReleaseDC: hwnd=%x hdc=%x\n", hwnd, hDC);
|
OutTraceDW("GDI.ReleaseDC: hwnd=%x hdc=%x\n", hwnd, hDC);
|
||||||
if (dxw.IsRealDesktop(hwnd)) hwnd=dxw.GethWnd();
|
if (dxw.IsRealDesktop(hwnd)) hwnd=dxw.GethWnd();
|
||||||
|
|
||||||
if(dxw.dwFlags3 & GDIEMULATEDC)
|
if((dxw.dwFlags3 & GDIEMULATEDC) && (hDC == dxw.VirtualHDC)) // v2.02.53 !!!!!
|
||||||
res=dxw.ReleaseEmulatedDC(hwnd);
|
res=dxw.ReleaseEmulatedDC(hwnd);
|
||||||
else
|
else
|
||||||
res=(*pGDIReleaseDC)(hwnd, hDC);
|
res=(*pGDIReleaseDC)(hwnd, hDC);
|
||||||
@ -1673,41 +1683,17 @@ int WINAPI extGDIReleaseDC(HWND hwnd, HDC hDC)
|
|||||||
return(res);
|
return(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
HDC EmuHDC;
|
|
||||||
|
|
||||||
HDC WINAPI extBeginPaint(HWND hwnd, LPPAINTSTRUCT lpPaint)
|
HDC WINAPI extBeginPaint(HWND hwnd, LPPAINTSTRUCT lpPaint)
|
||||||
{
|
{
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
extern HRESULT WINAPI extGetDC(LPDIRECTDRAWSURFACE, HDC FAR *);
|
extern HRESULT WINAPI extGetDC(LPDIRECTDRAWSURFACE, HDC FAR *);
|
||||||
|
|
||||||
// proxy part ...
|
|
||||||
OutTraceDW("GDI.BeginPaint: hwnd=%x lpPaint=%x FullScreen=%x\n", hwnd, lpPaint, dxw.IsFullScreen());
|
OutTraceDW("GDI.BeginPaint: hwnd=%x lpPaint=%x FullScreen=%x\n", hwnd, lpPaint, dxw.IsFullScreen());
|
||||||
hdc=(*pBeginPaint)(hwnd, lpPaint);
|
hdc=(*pBeginPaint)(hwnd, lpPaint);
|
||||||
|
|
||||||
// if not in fullscreen mode, that's all!
|
// if not in fullscreen mode, that's all!
|
||||||
if(!dxw.IsFullScreen()) return hdc;
|
if(!dxw.IsFullScreen()) return hdc;
|
||||||
|
|
||||||
if((dxw.dwFlags3 & GDIEMULATEDC) && dxw.IsFullScreen() && dxw.IsDesktop(hwnd)) {
|
|
||||||
EmuHDC = dxw.AcquireEmulatedDC(hwnd);
|
|
||||||
OutTraceDW("GDI.BeginPaint(GDIEMULATEDC): hdc=%x emulated hdc=%x\n", hdc, EmuHDC);
|
|
||||||
hdc=EmuHDC;
|
|
||||||
lpPaint->hdc=EmuHDC;
|
|
||||||
dxw.MapClient(&lpPaint->rcPaint);
|
|
||||||
return hdc;
|
|
||||||
}
|
|
||||||
|
|
||||||
// on MAPGDITOPRIMARY, return the PrimHDC handle instead of the window DC
|
|
||||||
if(dxw.dwFlags1 & MAPGDITOPRIMARY) {
|
|
||||||
if(pGetDC && dxw.lpDDSPrimHDC){
|
|
||||||
extGetDC(dxw.lpDDSPrimHDC,&PrimHDC);
|
|
||||||
OutTraceDW("GDI.BeginPaint(MAPGDITOPRIMARY): redirect hdc=%x -> PrimHDC=%x\n", hdc, PrimHDC);
|
|
||||||
hdc=PrimHDC;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
OutTraceDW("GDI.BeginPaint(MAPGDITOPRIMARY): hdc=%x\n", hdc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// on CLIENTREMAPPING, resize the paint area to virtual screen size
|
// on CLIENTREMAPPING, resize the paint area to virtual screen size
|
||||||
if(dxw.dwFlags1 & CLIENTREMAPPING){
|
if(dxw.dwFlags1 & CLIENTREMAPPING){
|
||||||
lpPaint->rcPaint.top=0;
|
lpPaint->rcPaint.top=0;
|
||||||
@ -1716,14 +1702,76 @@ HDC WINAPI extBeginPaint(HWND hwnd, LPPAINTSTRUCT lpPaint)
|
|||||||
lpPaint->rcPaint.bottom=dxw.GetScreenHeight();
|
lpPaint->rcPaint.bottom=dxw.GetScreenHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!dxw.IsDesktop(hwnd)) return hdc;
|
||||||
|
|
||||||
|
if(dxw.dwFlags3 & GDIEMULATEDC) {
|
||||||
|
HDC EmuHDC;
|
||||||
|
EmuHDC = dxw.AcquireEmulatedDC(hwnd);
|
||||||
|
lpPaint->hdc=EmuHDC;
|
||||||
|
dxw.MapClient(&lpPaint->rcPaint);
|
||||||
|
OutTraceDW("GDI.BeginPaint(GDIEMULATEDC): hdc=%x -> %x\n", hdc, EmuHDC);
|
||||||
|
return EmuHDC;
|
||||||
|
}
|
||||||
|
|
||||||
OutTraceDW("GDI.BeginPaint: hdc=%x\n", hdc);
|
OutTraceDW("GDI.BeginPaint: hdc=%x\n", hdc);
|
||||||
return hdc;
|
return hdc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HDC WINAPI extDDBeginPaint(HWND hwnd, LPPAINTSTRUCT lpPaint)
|
||||||
|
{
|
||||||
|
HDC hdc;
|
||||||
|
extern HRESULT WINAPI extGetDC(LPDIRECTDRAWSURFACE, HDC FAR *);
|
||||||
|
|
||||||
|
OutTraceDW("GDI.BeginPaint: hwnd=%x lpPaint=%x FullScreen=%x\n", hwnd, lpPaint, dxw.IsFullScreen());
|
||||||
|
hdc=(*pBeginPaint)(hwnd, lpPaint);
|
||||||
|
|
||||||
|
// if not in fullscreen mode, that's all!
|
||||||
|
if(!dxw.IsFullScreen()) return hdc;
|
||||||
|
|
||||||
|
// on CLIENTREMAPPING, resize the paint area to virtual screen size
|
||||||
|
if(dxw.dwFlags1 & CLIENTREMAPPING){
|
||||||
|
lpPaint->rcPaint.top=0;
|
||||||
|
lpPaint->rcPaint.left=0;
|
||||||
|
lpPaint->rcPaint.right=dxw.GetScreenWidth();
|
||||||
|
lpPaint->rcPaint.bottom=dxw.GetScreenHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!dxw.IsDesktop(hwnd)) return hdc;
|
||||||
|
|
||||||
|
// on MAPGDITOPRIMARY, return the PrimHDC handle instead of the window DC
|
||||||
|
// if a primary surface has not been created yet, do it
|
||||||
|
if(!pGetDC || !dxw.lpDDSPrimHDC){
|
||||||
|
extern HRESULT WINAPI extDirectDrawCreate(GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *);
|
||||||
|
HRESULT res;
|
||||||
|
LPDIRECTDRAW lpDD;
|
||||||
|
LPDIRECTDRAWSURFACE lpDDS;
|
||||||
|
DDSURFACEDESC ddsd;
|
||||||
|
res=extDirectDrawCreate(0, &lpDD, NULL);
|
||||||
|
//lpDD->SetDisplayMode(dxw.GetScreenWidth(), dxw.GetScreenHeight(), NULL);
|
||||||
|
lpDD->SetCooperativeLevel(hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
|
||||||
|
memset((void *)&ddsd, 0, sizeof(DDSURFACEDESC));
|
||||||
|
ddsd.dwSize = sizeof(DDSURFACEDESC);
|
||||||
|
ddsd.dwFlags = DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH;
|
||||||
|
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
||||||
|
ddsd.dwHeight = dxw.GetScreenHeight();
|
||||||
|
ddsd.dwWidth = dxw.GetScreenWidth();
|
||||||
|
res=lpDD->CreateSurface(&ddsd, &lpDDS, NULL);
|
||||||
|
dxw.lpDDSPrimHDC = lpDDS;
|
||||||
|
OutTraceDW("GDI.BeginPaint(MAPGDITOPRIMARY): dd=%x ddsPrim=%x\n", lpDD, lpDDS);
|
||||||
|
}
|
||||||
|
extGetDC(dxw.lpDDSPrimHDC,&PrimHDC);
|
||||||
|
lpPaint->hdc=PrimHDC;
|
||||||
|
//dxw.MapClient(&lpPaint->rcPaint);
|
||||||
|
OutTraceDW("GDI.BeginPaint(MAPGDITOPRIMARY): hdc=%x -> %x\n", hdc, PrimHDC);
|
||||||
|
return PrimHDC;
|
||||||
|
}
|
||||||
|
|
||||||
BOOL WINAPI extEndPaint(HWND hwnd, const PAINTSTRUCT *lpPaint)
|
BOOL WINAPI extEndPaint(HWND hwnd, const PAINTSTRUCT *lpPaint)
|
||||||
{
|
{
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
HRESULT WINAPI extReleaseDC(LPDIRECTDRAWSURFACE lpdds, HDC FAR hdc);
|
extern HRESULT WINAPI extReleaseDC(LPDIRECTDRAWSURFACE lpdds, HDC FAR hdc);
|
||||||
|
extern HRESULT WINAPI extGetDC(LPDIRECTDRAWSURFACE, HDC FAR *);
|
||||||
|
extern HRESULT WINAPI extBlt(LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect, LPDIRECTDRAWSURFACE lpddssrc, LPRECT lpsrcrect, DWORD dwflags, LPDDBLTFX lpddbltfx);
|
||||||
|
|
||||||
OutTraceDW("GDI.EndPaint: hwnd=%x lpPaint=%x lpPaint.hdc=%x\n", hwnd, lpPaint, lpPaint->hdc);
|
OutTraceDW("GDI.EndPaint: hwnd=%x lpPaint=%x lpPaint.hdc=%x\n", hwnd, lpPaint, lpPaint->hdc);
|
||||||
|
|
||||||
@ -1735,6 +1783,15 @@ BOOL WINAPI extEndPaint(HWND hwnd, const PAINTSTRUCT *lpPaint)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// v2.02.53 ...
|
||||||
|
if((dxw.dwFlags1 & MAPGDITOPRIMARY) && dxw.IsFullScreen() && dxw.IsDesktop(hwnd)){
|
||||||
|
ret=(*pEndPaint)(hwnd, lpPaint);
|
||||||
|
dxw.lpDDSPrimHDC->Unlock(NULL);
|
||||||
|
//dxw.ScreenRefresh();
|
||||||
|
extBlt(dxw.lpDDSPrimHDC, NULL, dxw.lpDDSPrimHDC, NULL, 0, NULL);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
// proxy part ...
|
// proxy part ...
|
||||||
ret=(*pEndPaint)(hwnd, lpPaint);
|
ret=(*pEndPaint)(hwnd, lpPaint);
|
||||||
OutTraceDW("GDI.EndPaint: hwnd=%x ret=%x\n", hwnd, ret);
|
OutTraceDW("GDI.EndPaint: hwnd=%x ret=%x\n", hwnd, ret);
|
||||||
@ -1748,6 +1805,7 @@ BOOL WINAPI extEndPaint(HWND hwnd, const PAINTSTRUCT *lpPaint)
|
|||||||
// v2.02.09: on MAPGDITOPRIMARY, release the PrimHDC handle
|
// v2.02.09: on MAPGDITOPRIMARY, release the PrimHDC handle
|
||||||
if(dxw.dwFlags1 & MAPGDITOPRIMARY) {
|
if(dxw.dwFlags1 & MAPGDITOPRIMARY) {
|
||||||
if(pReleaseDC && dxw.lpDDSPrimHDC){
|
if(pReleaseDC && dxw.lpDDSPrimHDC){
|
||||||
|
extGetDC(dxw.lpDDSPrimHDC,&PrimHDC);
|
||||||
extReleaseDC(dxw.lpDDSPrimHDC, PrimHDC);
|
extReleaseDC(dxw.lpDDSPrimHDC, PrimHDC);
|
||||||
OutTraceDW("GDI.EndPaint: released hdc=%x\n", PrimHDC);
|
OutTraceDW("GDI.EndPaint: released hdc=%x\n", PrimHDC);
|
||||||
}
|
}
|
||||||
@ -1756,6 +1814,31 @@ BOOL WINAPI extEndPaint(HWND hwnd, const PAINTSTRUCT *lpPaint)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI extDDEndPaint(HWND hwnd, const PAINTSTRUCT *lpPaint)
|
||||||
|
{
|
||||||
|
BOOL ret;
|
||||||
|
extern HRESULT WINAPI extReleaseDC(LPDIRECTDRAWSURFACE lpdds, HDC FAR hdc);
|
||||||
|
extern HRESULT WINAPI extGetDC(LPDIRECTDRAWSURFACE, HDC FAR *);
|
||||||
|
extern HRESULT WINAPI extBlt(LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect, LPDIRECTDRAWSURFACE lpddssrc, LPRECT lpsrcrect, DWORD dwflags, LPDDBLTFX lpddbltfx);
|
||||||
|
|
||||||
|
OutTraceDW("GDI.EndPaint: hwnd=%x lpPaint=%x lpPaint.hdc=%x\n", hwnd, lpPaint, lpPaint->hdc);
|
||||||
|
|
||||||
|
// v2.02.53 ...
|
||||||
|
if(dxw.IsFullScreen() && dxw.IsDesktop(hwnd)){
|
||||||
|
ret=(*pEndPaint)(hwnd, lpPaint);
|
||||||
|
dxw.lpDDSPrimHDC->Unlock(NULL);
|
||||||
|
//dxw.ScreenRefresh();
|
||||||
|
extBlt(dxw.lpDDSPrimHDC, NULL, dxw.lpDDSPrimHDC, NULL, 0, NULL);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// proxy part ...
|
||||||
|
ret=(*pEndPaint)(hwnd, lpPaint);
|
||||||
|
OutTraceDW("GDI.EndPaint: hwnd=%x ret=%x\n", hwnd, ret);
|
||||||
|
if(!ret) OutTraceE("GDI.EndPaint ERROR: err=%d at %d\n", GetLastError(), __LINE__);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
HWND WINAPI extCreateDialogIndirectParam(HINSTANCE hInstance, LPCDLGTEMPLATE lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM lParamInit)
|
HWND WINAPI extCreateDialogIndirectParam(HINSTANCE hInstance, LPCDLGTEMPLATE lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM lParamInit)
|
||||||
{
|
{
|
||||||
HWND RetHWND;
|
HWND RetHWND;
|
||||||
@ -2073,10 +2156,53 @@ BOOL WINAPI extIsWindowVisible(HWND hwnd)
|
|||||||
{
|
{
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
ret=(*pIsWindowVisible)(hwnd);
|
ret=(*pIsWindowVisible)(hwnd);
|
||||||
OutTraceDW("IsWindowVisible: hwnd=%x ret=%x\n", hwnd, ret);
|
OutTraceB("IsWindowVisible: hwnd=%x ret=%x\n", hwnd, ret);
|
||||||
if(dxw.IsDesktop(hwnd)){
|
if(dxw.IsDesktop(hwnd) && !ret){
|
||||||
OutTraceDW("IsWindowVisible: FORCING ret=TRUE\n");
|
OutTraceDW("IsWindowVisible: FORCING ret=TRUE\n");
|
||||||
ret=TRUE;
|
ret=TRUE;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI extSystemParametersInfoA(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni)
|
||||||
|
{
|
||||||
|
BOOL ret;
|
||||||
|
OutTraceDW("SystemParametersInfo: Action=%x Param=%x WinIni=%x\n", uiAction, uiParam, fWinIni);
|
||||||
|
ret=(*pSystemParametersInfoA)(uiAction, uiParam, pvParam, fWinIni);
|
||||||
|
if(uiAction==SPI_GETWORKAREA){
|
||||||
|
LPRECT cli = (LPRECT)pvParam;
|
||||||
|
cli->top = 0;
|
||||||
|
cli->left = 0;
|
||||||
|
cli->bottom = dxw.GetScreenHeight();
|
||||||
|
cli->right = dxw.GetScreenWidth();
|
||||||
|
OutTraceDW("SystemParametersInfo: resized client workarea rect=(%d,%d)-(%d,%d)\n", cli->left, cli->top, cli->right, cli->bottom);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef OutTraceDW
|
||||||
|
#define OutTraceDW OutTrace
|
||||||
|
|
||||||
|
UINT_PTR WINAPI extSetTimer(HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc)
|
||||||
|
{
|
||||||
|
UINT uShiftedElapse;
|
||||||
|
UINT_PTR ret;
|
||||||
|
// beware: the quicker the time flows, the more the time clicks are incremented,
|
||||||
|
// and the lesser the pauses must be lasting! Shift operations are reverted in
|
||||||
|
// GetSystemTime vs. Sleep or SetTimer
|
||||||
|
uShiftedElapse = dxw.StretchTime(uElapse);
|
||||||
|
OutTraceDW("SetTimer: hwnd=%x TimerFunc=%x elapse=%d->%d timeshift=%d\n", hWnd, lpTimerFunc, uElapse, uShiftedElapse, dxw.TimeShift);
|
||||||
|
ret = (*pSetTimer)(hWnd, nIDEvent, uShiftedElapse, lpTimerFunc);
|
||||||
|
if(ret) dxw.PushTimer(hWnd, ret, uElapse, lpTimerFunc);
|
||||||
|
OutTraceDW("SetTimer: IDEvent=%x ret=%x\n", nIDEvent, ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI extKillTimer(HWND hWnd, UINT_PTR uIDEvent)
|
||||||
|
{
|
||||||
|
BOOL ret;
|
||||||
|
OutTraceDW("KillTimer: hwnd=%x IDEvent=%x\n", hWnd, uIDEvent);
|
||||||
|
ret = (*pKillTimer)(hWnd, uIDEvent);
|
||||||
|
OutTraceDW("KillTimer: ret=%x\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user