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

v2_02_34_src

Former-commit-id: d8d2c00dadd24ffc53cc6d189f0edd44f1abd949
This commit is contained in:
gho tik 2013-09-16 12:38:17 -04:00 committed by Refael ACkermann
parent 0a986911a5
commit 0b52adcc2b
24 changed files with 867 additions and 523 deletions

View File

@ -99,6 +99,7 @@
#define FONTBYPASS 0x00020000 // bypass font unsupported API
#define YUV2RGB 0x00040000 // Simulate YUV to RGB color conversion
#define RGB2YUV 0x00080000 // Simulate RGB to YUV color conversion
#define BUFFEREDIOFIX 0x00100000 // fix buffered IO incompatibilities between pre-Win98 and post-WinNT
// logging Tflags DWORD:
#define OUTTRACE 0x00000001 // enables tracing to dxwnd.log in general
@ -203,6 +204,7 @@ extern WNDPROC WhndGetWindowProc(HWND );
typedef enum {
DXW_SET_COORDINATES = 0,
DXW_DESKTOP_CENTER,
DXW_DESKTOP_WORKAREA,
DXW_DESKTOP_CENTER
DXW_DESKTOP_FULL
} Coordinates_Types;

View File

@ -331,7 +331,7 @@ flag14=402653218
flagg14=134217728
flagh14=1044
flagi14=0
tflag14=2
tflag14=259
initx14=0
inity14=0
minx14=0
@ -1080,8 +1080,54 @@ sizx46=800
sizy46=600
maxfps46=0
initts46=0
title47=age3.exe
path47=D:\Games\Age of Empires III\age3.exe
module47=
opengllib47=
ver47=0
coord47=0
flag47=-394125278
flagg47=134217728
flagh47=20
flagi47=0
tflag47=64
initx47=0
inity47=0
minx47=0
miny47=0
maxx47=0
maxy47=0
posx47=50
posy47=50
sizx47=800
sizy47=600
maxfps47=0
initts47=0
title48=road.exe
path48=D:\Games\Vangers\road.exe
module48=
opengllib48=
ver48=1
coord48=0
flag48=134217762
flagg48=134217728
flagh48=20
flagi48=0
tflag48=323
initx48=0
inity48=0
minx48=0
miny48=0
maxx48=0
maxy48=0
posx48=50
posy48=50
sizx48=800
sizy48=600
maxfps48=0
initts48=0
[window]
posx=908
posy=205
posx=1435
posy=210
sizx=320
sizy=420

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:12040e25e1b8e234164832361e51d6470456a3050a15ae43f29a78b3636d0f70
size 404992
oid sha256:996722440a942e7241f3ee9fc60589c3dee97d84b8487c8c319ebf8962da3105
size 406016

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1fbd3ed5ac2b5db41671b9b4f80688c59abc1d894b408912f5c19c06c4a18063
oid sha256:0ccd2bbf780cc35a20ef2cd852c3b1a5934717b1d477906c67b3d3a9ad156e19
size 524800

View File

@ -241,6 +241,19 @@ GUI
added controls for new core features
defaulted ddraw emulation mode to surface emulation
v2.02.34
CORE:
Much better surface description in log
Completely revised CreateSurface hook: emulated and direct code are merged as much as possible, and reference counter are kept accurate. Now most games can work both in emulated and direct mode.
Fixed surface capabilities for "Vangers", "The Sims" (now working in emulated mode again)
Updated "Fixed aspect ratio" option: now uses the x,y size declared in the configuration instead of the fixed 800 x 600 standard one.
Added virtual fullscreen "Desktop" mode.
Completely revised the Peek/GetMessage handling: now it uses the standard SetWindowHook API instead of the address redirection, making the handling more reliable and accurate: now "Age of Empires III" works at last!
GUI:
Added virtual fullscreen "Desktop" mode.
Added "Fix buffered IO after Win98" flag: this is meant to fix an incompatibility in the ReadFile kernel32 API that must read from block boundaries, where a block was smaller up to Win98 and bigger after it.
As a result, games like "Dylan Dog Horror Luna Park" show IO errors while reading data from the CD. Unfortunately, this is not the only problem of this game, so Dylan Dog fans will have to wait further.
Maybe some other programs suffer of this problem, and I will strongly appreciate if anyone finds some.

File diff suppressed because it is too large Load Diff

View File

@ -120,7 +120,7 @@ char *ExplainDDSCaps2(DWORD c)
if (c & DDSCAPS2_EXTENDEDFORMATPRIMARY) strcat(eb, "EXTENDEDFORMATPRIMARY+");
if (c & DDSCAPS2_ADDITIONALPRIMARY) strcat(eb, "ADDITIONALPRIMARY+");
l=strlen(eb);
if (l>strlen("DDCAPS2_")) eb[l-1]=0; // delete last '+' if any
if (l>strlen("DDSCAPS2_")) eb[l-1]=0; // delete last '+' if any
else eb[0]=0;
return(eb);
}
@ -144,7 +144,7 @@ char *ExplainDDSCaps3(DWORD c)
strcat(eb, sQuality);
}
l=strlen(eb);
if (l>strlen("DDCAPS3_")) eb[l-1]=0; // delete last '+' if any
if (l>strlen("DDSCAPS3_")) eb[l-1]=0; // delete last '+' if any
else eb[0]=0;
return(eb);
}

View File

@ -59,7 +59,7 @@ static char *Flag3Names[32]={
"SAVECAPS", "SINGLEPROCAFFINITY", "EMULATEREGISTRY", "CDROMDRIVETYPE",
"NOWINDOWMOVE", "DISABLEHAL", "LOCKSYSCOLORS", "EMULATEDC",
"FULLSCREENONLY", "FONTBYPASS", "YUV2RGB", "RGB2YUV",
"Flags3:21", "Flags3:22", "Flags3:23", "Flags3:24",
"BUFFEREDIOFIX", "Flags3:22", "Flags3:23", "Flags3:24",
"Flags3:25", "Flags3:26", "Flags3:27", "Flags3:28",
"Flags3:29", "Flags3:30", "Flags3:31", "Flags3:32",
};
@ -569,21 +569,10 @@ void CalculateWindowPos(HWND hwnd, DWORD width, DWORD height, LPWINDOWPOS wp)
case DXW_DESKTOP_WORKAREA:
SystemParametersInfo(SPI_GETWORKAREA, NULL, &workarea, 0);
rect = workarea;
if ((dxw.dwFlags2 & KEEPASPECTRATIO) && !(dxw.dwFlags3 & FIXD3DFRAME)) {
int w, h, b; // width, height and border
w = workarea.right - workarea.left;
h = workarea.bottom - workarea.top;
if ((w * 600) > (h * 800)){
b = (w - (h * 800 / 600))/2;
rect.left = workarea.left + b;
rect.right = workarea.right - b;
}
else {
b = (h - (w * 600 / 800))/2;
rect.top = workarea.top + b;
rect.bottom = workarea.bottom - b;
}
}
break;
case DXW_DESKTOP_FULL:
(*pGetClientRect)((*pGetDesktopWindow)(), &workarea);
rect = workarea;
break;
case DXW_SET_COORDINATES:
default:
@ -648,7 +637,17 @@ void AdjustWindowFrame(HWND hwnd, DWORD width, DWORD height)
dxw.SetScreenSize(width, height);
if (hwnd==NULL) return;
style = ((dxw.dwFlags2 & MODALSTYLE) || (dxw.Coordinates == DXW_DESKTOP_WORKAREA)) ? 0 : WS_OVERLAPPEDWINDOW;
switch(dxw.Coordinates){
case DXW_SET_COORDINATES:
case DXW_DESKTOP_CENTER:
style = (dxw.dwFlags2 & MODALSTYLE) ? 0 : WS_OVERLAPPEDWINDOW;
break;
case DXW_DESKTOP_WORKAREA:
case DXW_DESKTOP_FULL:
style = 0;
break;
}
(*pSetWindowLong)(hwnd, GWL_STYLE, style);
(*pSetWindowLong)(hwnd, GWL_EXSTYLE, 0);
(*pShowWindow)(hwnd, SW_SHOWNORMAL);
@ -1324,6 +1323,27 @@ void SetSingleProcessAffinity(void)
OutTraceE("SetProcessAffinityMask: ERROR err=%d\n", GetLastError());
}
extern HHOOK hMouseHook;
LRESULT CALLBACK MessageHook(int code, WPARAM wParam, LPARAM lParam)
{
if(code == HC_ACTION){
if(dxw.IsFullScreen()){
MSG *msg;
msg = (MSG *)lParam;
OutTraceC("MessageHook: message=%d(%s) remove=%d pt=(%d,%d)\n",
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?
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);
}
void HookInit(TARGETMAP *target, HWND hwnd)
{
HMODULE base;
@ -1404,17 +1424,15 @@ void HookInit(TARGETMAP *target, HWND hwnd)
if(dxw.dwFlags2 & RECOVERSCREENMODE) RecoverScreenMode();
if(dxw.dwFlags3 & FORCE16BPP) SwitchTo16BPP();
if (dxw.dwFlags1 & MESSAGEPROC){
extern HINSTANCE hInst;
hMouseHook=SetWindowsHookEx(WH_GETMESSAGE, MessageHook, hInst, GetCurrentThreadId());
if(hMouseHook==NULL) OutTraceE("SetWindowsHookEx WH_GETMESSAGE failed: error=%d\n", GetLastError());
}
InitScreenParameters();
if (IsDebug) OutTraceD("MoveWindow: target pos=(%d,%d) size=(%d,%d)\n", dxw.iPosX, dxw.iPosY, dxw.iSizX, dxw.iSizY); //v2.02.09
//if(dxw.dwFlags1 & FIXPARENTWIN){
// CalculateWindowPos(hwnd, dxw.iSizX, dxw.iSizY, &wp);
// if (IsDebug) OutTraceD("MoveWindow: dxw.hParentWnd=%x pos=(%d,%d) size=(%d,%d)\n", dxw.hParentWnd, wp.x, wp.y, wp.cx, wp.cy);
// res=(*pMoveWindow)(dxw.hParentWnd, wp.x, wp.y, wp.cx, wp.cy, FALSE);
// if(!res) OutTraceE("MoveWindow ERROR: dxw.hParentWnd=%x err=%d at %d\n", dxw.hParentWnd, GetLastError(), __LINE__);
//}
//return 0;
}
LPCSTR ProcToString(LPCSTR proc)

View File

@ -209,14 +209,14 @@ POINT dxwCore::FixCursorPos(POINT prev)
w = rect.right - rect.left;
h = rect.bottom - rect.top;
if ((dxw.Coordinates == DXW_DESKTOP_WORKAREA) && (dxw.dwFlags2 & KEEPASPECTRATIO)) {
if ((w * 600) > (h * 800)){
b = (w - (h * 800 / 600))/2;
if (dxw.dwFlags2 & KEEPASPECTRATIO) {
if ((w * iSizY) > (h * iSizX)){
b = (w - (h * iSizX / iSizY))/2;
curr.x -= b;
w -= 2*b;
}
else {
b = (h - (w * 600 / 800))/2;
b = (h - (w * iSizY / iSizX))/2;
curr.y -= b;
h -= 2*b;
}
@ -326,6 +326,23 @@ void dxwCore::SethWnd(HWND hwnd)
hWndFPS=hwnd;
}
void dxwCore::FixWorkarea(LPRECT workarea)
{
int w, h, b; // width, height and border
w = workarea->right - workarea->left;
h = workarea->bottom - workarea->top;
if ((w * iSizY) > (h * iSizX)){
b = (w - (h * iSizX / iSizY))/2;
workarea->left += b;
workarea->right -= b;
}
else {
b = (h - (w * iSizY / iSizX))/2;
workarea->top += b;
workarea->bottom -= b;
}
}
RECT dxwCore::MapWindowRect(LPRECT lpRect)
{
POINT UpLeft={0,0};
@ -341,14 +358,14 @@ RECT dxwCore::MapWindowRect(LPRECT lpRect)
}
RetRect=ClientRect;
bx = by = 0;
if ((dxw.Coordinates == DXW_DESKTOP_WORKAREA) && (dwFlags2 & KEEPASPECTRATIO)){
if (dwFlags2 & KEEPASPECTRATIO){
w = RetRect.right - RetRect.left;
h = RetRect.bottom - RetRect.top;
if ((w * 600) > (h * 800)){
bx = (w - (h * 800 / 600))/2;
if ((w * iSizY) > (h * iSizX)){
bx = (w - (h * iSizX / iSizY))/2;
}
else {
by = (h - (w * 600 / 800))/2;
by = (h - (w * iSizY / iSizX))/2;
}
OutTraceB("bx=%d by=%d\n", bx, by);
}
@ -375,6 +392,37 @@ RECT dxwCore::MapWindowRect(LPRECT lpRect)
return RetRect;
}
POINT dxwCore::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;
}
void dxwCore::MapClient(LPRECT rect)
{
RECT client;

View File

@ -41,6 +41,8 @@ public: // methods
void MapWindow(LPPOINT);
void MapWindow(LPRECT);
void MapWindow(int *, int *, int *, int *);
void FixWorkarea(LPRECT);
POINT FixMessagePt(HWND, POINT);
RECT GetScreenRect(void);
RECT GetWindowRect(RECT);
RECT GetClientRect(RECT);

View File

@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dxwnd.h"
#include "dxwcore.hpp"
#define VERSION "2.02.33"
#define VERSION "2.02.34"
#define DDTHREADLOCK 1
@ -32,6 +32,7 @@ LRESULT CALLBACK HookProc(int ncode, WPARAM wparam, LPARAM lparam);
HINSTANCE hInst;
HHOOK hHook;
HHOOK hMouseHook;
HANDLE hMapping;
TARGETMAP *pMapping;
DXWNDSTATUS *pStatus;
@ -111,6 +112,7 @@ int StartHook(void)
int EndHook(void)
{
UnhookWindowsHookEx(hHook);
UnhookWindowsHookEx(hMouseHook);
HookStatus=DXW_IDLE;
return 0;
}

Binary file not shown.

View File

@ -627,21 +627,7 @@ HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devicetype,
RECT workarea;
GetClassName(dxw.GethWnd(), ClassName, 80);
(*pGetClientRect)(dxw.GethWnd(), &workarea);
if ((dxw.dwFlags2 & KEEPASPECTRATIO) && (dxw.Coordinates == DXW_DESKTOP_WORKAREA)) {
int w, h, b; // width, height and border
w = workarea.right - workarea.left;
h = workarea.bottom - workarea.top;
if ((w * 600) > (h * 800)){
b = (w - (h * 800 / 600))/2;
workarea.left += b;
workarea.right -= b;
}
else {
b = (h - (w * 600 / 800))/2;
workarea.top += b;
workarea.bottom -= b;
}
}
if (dxw.dwFlags2 & KEEPASPECTRATIO) dxw.FixWorkarea(&workarea);
hfocuswindow=(*pCreateWindowExA)(
0, ClassName, "child",
WS_CHILD|WS_VISIBLE,

View File

@ -17,6 +17,14 @@ static HookEntry_Type Hooks[]={
{0, NULL, 0, 0} // terminator
};
static HookEntry_Type FixIOHooks[]={
{"ReadFile", (FARPROC)NULL, (FARPROC *)&pReadFile, (FARPROC)extReadFile},
{"CreateFileA", (FARPROC)NULL, (FARPROC *)&pCreateFile, (FARPROC)extCreateFile},
{"SetFilePointer", (FARPROC)NULL, (FARPROC *)&pSetFilePointer, (FARPROC)extSetFilePointer},
{"CloseHandle", (FARPROC)NULL, (FARPROC *)&pCloseHandle, (FARPROC)extCloseHandle},
{0, NULL, 0, 0} // terminator
};
static HookEntry_Type LimitHooks[]={
{"GetDiskFreeSpaceA", (FARPROC)GetDiskFreeSpaceA, (FARPROC *)&pGetDiskFreeSpaceA, (FARPROC)extGetDiskFreeSpaceA},
{"GlobalMemoryStatus", (FARPROC)GlobalMemoryStatus, (FARPROC *)&pGlobalMemoryStatus, (FARPROC)extGlobalMemoryStatus},
@ -45,6 +53,7 @@ static char *libname = "kernel32.dll";
void HookKernel32(HMODULE module)
{
HookLibrary(module, Hooks, libname);
if(dxw.dwFlags3 & BUFFEREDIOFIX) HookLibrary(module, FixIOHooks, libname);
if(dxw.dwFlags2 & LIMITRESOURCES) HookLibrary(module, LimitHooks, libname);
if(dxw.dwFlags2 & TIMESTRETCH) HookLibrary(module, TimeHooks, libname);
if(dxw.dwFlags2 & FAKEVERSION) HookLibrary(module, VersionHooks, libname);
@ -64,6 +73,9 @@ FARPROC Remap_kernel32_ProcAddress(LPCSTR proc, HMODULE hModule)
if (addr=RemapLibrary(proc, hModule, Hooks)) return addr;
if(dxw.dwFlags3 & BUFFEREDIOFIX)
if (addr=RemapLibrary(proc, hModule, FixIOHooks)) return addr;
if(dxw.dwFlags2 & LIMITRESOURCES)
if (addr=RemapLibrary(proc, hModule, LimitHooks)) return addr;
@ -494,4 +506,135 @@ UINT WINAPI extGetDriveType(LPCTSTR lpRootPathName)
OutTraceD("GetDriveType: path=\"%s\"\n", lpRootPathName);
if (dxw.dwFlags3 & CDROMDRIVETYPE) return DRIVE_CDROM;
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 ret;
static char *IOBuffer=NULL;
DWORD BytesRead;
DWORD Cursor;
OutTrace("ReadFile: hFile=%x Buffer=%x BytesToRead=%d\n", hFile, lpBuffer, nNumberOfBytesToRead);
#define SECTOR_SIZE 4096
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(lpBuffer, IOBuffer+Where, nNumberOfBytesToRead);
OutTrace("ReadFile: BUFFERED READ BytesRequested=%d BytesRead=%d where=%d\n",
nNumberOfBytesToRead, *lpNumberOfBytesRead, Where);
Where += (*lpNumberOfBytesRead);
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;
}
do {// try to read it all
// when space is not enough, let's grow!
if((DWORD)(IOBuffer+Cursor+SECTOR_SIZE) > (DWORD)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, lpOverlapped); // read one block
Cursor+=BytesRead;
if (ret && BytesRead == 0) ret=FALSE; // eof
} while(ret);
OutTrace("ReadFIle: BUFFERED FileSize=%d\n", Cursor);
FileLength=Cursor;
// recurse ...
return extReadFile(hFile, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped);
}
HANDLE WINAPI extCreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
HANDLE ret;
OutTrace("CreateFile: FileName=%s DesiredAccess=%x SharedMode=%x Disposition=%x Flags=%x\n",
lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, dwFlagsAndAttributes);
ret=(*pCreateFile)(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
if(ret && (ret != (HANDLE)INVALID_SET_FILE_POINTER))
OutTrace("CreateFile: ret=%x\n", ret);
else
OutTraceE("CreateFile ERROR: err=%d\n", GetLastError());
return ret;
}
BOOL WINAPI extCloseHandle(HANDLE hObject)
{
if (hObject==LastFile) LastFile=0; // invalidate cache
return (*pCloseHandle)(hObject);
}
DWORD WINAPI extSetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
{
DWORD ret;
OutTrace("SetFilePointer: hFile=%x DistanceToMove=%ld DistanceToMoveHigh=%x MoveMethod=%x\n",
hFile, lDistanceToMove, lpDistanceToMoveHigh, dwMoveMethod);
// if cached file ...
if(LastFile==hFile){
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;
}
OutTrace("SetFilePointer: ret=%x\n", 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;
}

View File

@ -104,6 +104,7 @@ typedef HMODULE (WINAPI *LoadLibraryA_Type)(LPCTSTR);
typedef HMODULE (WINAPI *LoadLibraryExA_Type)(LPCTSTR, HANDLE, DWORD);
typedef HMODULE (WINAPI *LoadLibraryW_Type)(LPCWSTR);
typedef HMODULE (WINAPI *LoadLibraryExW_Type)(LPCWSTR, HANDLE, DWORD);
typedef BOOL (WINAPI *ReadFile_Type)(HANDLE, LPVOID, DWORD, LPDWORD, LPOVERLAPPED);
typedef LPTOP_LEVEL_EXCEPTION_FILTER
(WINAPI *SetUnhandledExceptionFilter_Type)(LPTOP_LEVEL_EXCEPTION_FILTER);
typedef void (WINAPI *Sleep_Type)(DWORD);
@ -112,6 +113,9 @@ typedef BOOL (WINAPI *CreateScalableFontResourceA_Type)(DWORD, LPCTSTR, LPCTSTR,
typedef int (WINAPI *AddFontResourceA_Type)(LPCTSTR);
typedef BOOL (WINAPI *CreateScalableFontResourceW_Type)(DWORD, LPCWSTR, LPCWSTR, LPCWSTR);
typedef int (WINAPI *AddFontResourceW_Type)(LPCWSTR);
typedef HANDLE (WINAPI *CreateFile_Type)(LPCTSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
typedef DWORD (WINAPI *SetFilePointer_Type)(HANDLE, LONG, PLONG, DWORD);
typedef BOOL (WINAPI *CloseHandle_Type)(HANDLE);
// ole32.dll:
typedef HRESULT (STDAPICALLTYPE *CoCreateInstance_Type)(REFCLSID, LPUNKNOWN, DWORD, REFIID, LPVOID FAR*);
@ -281,9 +285,13 @@ DXWEXTERN LoadLibraryA_Type pLoadLibraryA DXWINITIALIZED;
DXWEXTERN LoadLibraryExA_Type pLoadLibraryExA DXWINITIALIZED;
DXWEXTERN LoadLibraryW_Type pLoadLibraryW DXWINITIALIZED;
DXWEXTERN LoadLibraryExW_Type pLoadLibraryExW DXWINITIALIZED;
DXWEXTERN ReadFile_Type pReadFile DXWINITIALIZED;
DXWEXTERN SetUnhandledExceptionFilter_Type pSetUnhandledExceptionFilter DXWINITIALIZED;
DXWEXTERN Sleep_Type pSleep DXWINITIALIZED;
DXWEXTERN SleepEx_Type pSleepEx DXWINITIALIZED;
DXWEXTERN CreateFile_Type pCreateFile DXWINITIALIZED;
DXWEXTERN SetFilePointer_Type pSetFilePointer DXWINITIALIZED;
DXWEXTERN CloseHandle_Type pCloseHandle DXWINITIALIZED;
// ole32.dll:
DXWEXTERN CoCreateInstance_Type pCoCreateInstance DXWINITIALIZED;
@ -449,9 +457,13 @@ extern HMODULE WINAPI extLoadLibraryA(LPCTSTR);
extern HMODULE WINAPI extLoadLibraryExA(LPCTSTR, HANDLE, DWORD);
extern HMODULE WINAPI extLoadLibraryW(LPCWSTR);
extern HMODULE WINAPI extLoadLibraryExW(LPCWSTR, HANDLE, DWORD);
extern BOOL WINAPI extReadFile(HANDLE, LPVOID, DWORD, LPDWORD, LPOVERLAPPED);
extern LPTOP_LEVEL_EXCEPTION_FILTER WINAPI extSetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER);
extern void WINAPI extSleep(DWORD);
extern DWORD WINAPI extSleepEx(DWORD, BOOL);
extern HANDLE WINAPI extCreateFile(LPCTSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
extern DWORD WINAPI extSetFilePointer(HANDLE, LONG, PLONG, DWORD);
extern BOOL WINAPI extCloseHandle(HANDLE);
// ole32.dll:
extern HRESULT STDAPICALLTYPE extCoCreateInstance(REFCLSID, LPUNKNOWN, DWORD, REFIID, LPVOID FAR*);
@ -491,6 +503,7 @@ extern BOOL WINAPI extDDInvalidateRect(HWND, RECT *, BOOL);
extern int WINAPI extMapWindowPoints(HWND, HWND, LPPOINT, UINT);
extern BOOL WINAPI extMoveWindow(HWND, int, int, int, int, BOOL);
extern BOOL WINAPI extPeekMessage(LPMSG, HWND, UINT, UINT, UINT);
extern BOOL WINAPI extPeekAnyMessage(LPMSG, HWND, UINT, UINT, UINT);
extern ATOM WINAPI extRegisterClassExA(WNDCLASSEXA *);
extern int WINAPI extDDReleaseDC(HWND, HDC);
extern int WINAPI extGDIReleaseDC(HWND, HDC);

View File

@ -74,8 +74,14 @@ static HookEntry_Type RemapHooks[]={
};
static HookEntry_Type MessageHooks[]={
{"PeekMessageA", (FARPROC)PeekMessageA, (FARPROC *)&pPeekMessage, (FARPROC)extPeekMessage},
{"GetMessageA", (FARPROC)GetMessageA, (FARPROC *)&pGetMessage, (FARPROC)extGetMessage},
//{"PeekMessageA", (FARPROC)PeekMessageA, (FARPROC *)&pPeekMessage, (FARPROC)extPeekMessage},
//{"GetMessageA", (FARPROC)GetMessageA, (FARPROC *)&pGetMessage, (FARPROC)extGetMessage},
{0, NULL, 0, 0} // terminator
};
static HookEntry_Type PeekAllHooks[]={
{"PeekMessageA", (FARPROC)NULL, (FARPROC *)&pPeekMessage, (FARPROC)extPeekAnyMessage},
{"PeekMessageW", (FARPROC)NULL, (FARPROC *)&pPeekMessage, (FARPROC)extPeekAnyMessage},
{0, NULL, 0, 0} // terminator
};
@ -112,14 +118,17 @@ FARPROC Remap_user32_ProcAddress(LPCSTR proc, HMODULE hModule)
if (addr=RemapLibrary(proc, hModule, (dxw.dwFlags1 & MAPGDITOPRIMARY) ? DDHooks : GDIHooks)) return addr;
if (dxw.dwFlags1 & CLIENTREMAPPING)
if (addr=RemapLibrary(proc, hModule, RemapHooks)) return addr;
if (dxw.dwFlags1 & MESSAGEPROC)
if (addr=RemapLibrary(proc, hModule, MessageHooks)) return addr;
// commented out since message processing was given to SetWindowHook callback
// if (dxw.dwFlags1 & MESSAGEPROC)
// if (addr=RemapLibrary(proc, hModule, MessageHooks)) return addr;
if(dxw.dwFlags1 & MODIFYMOUSE)
if (addr=RemapLibrary(proc, hModule, MouseHooks)) return addr;
if (dxw.dwFlags1 & (PREVENTMAXIMIZE|FIXWINFRAME|LOCKWINPOS|LOCKWINSTYLE))
if (addr=RemapLibrary(proc, hModule, WinHooks)) return addr;
if((dxw.dwFlags1 & (MODIFYMOUSE|SLOWDOWN|KEEPCURSORWITHIN)) || (dxw.dwFlags2 & KEEPCURSORFIXED))
if (addr=RemapLibrary(proc, hModule, MouseHooks2)) return addr;
if(FALSE)
if (addr=RemapLibrary(proc, hModule, PeekAllHooks)) return addr;
return NULL;
}
@ -132,10 +141,11 @@ void HookUser32(HMODULE hModule)
HookLibrary(hModule, EmulateHooks, libname);
HookLibrary(hModule, (dxw.dwFlags1 & MAPGDITOPRIMARY) ? DDHooks : GDIHooks, libname);
if (dxw.dwFlags1 & CLIENTREMAPPING) HookLibrary(hModule, RemapHooks, libname);
if (dxw.dwFlags1 & MESSAGEPROC) HookLibrary(hModule, MessageHooks, libname);
//if (dxw.dwFlags1 & MESSAGEPROC) HookLibrary(hModule, MessageHooks, libname);
if(dxw.dwFlags1 & MODIFYMOUSE)HookLibrary(hModule, MouseHooks, 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(FALSE) HookLibrary(hModule, PeekAllHooks, libname);
return;
}
@ -770,6 +780,28 @@ BOOL WINAPI extSetCursorPos(int x, int y)
return res;
}
BOOL WINAPI extPeekAnyMessage(LPMSG lpMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg)
{
BOOL res;
if(wMsgFilterMin || wMsgFilterMax){
while (TRUE){
res=(*pPeekMessage)(lpMsg, hwnd, 0, 0, wRemoveMsg);
if((lpMsg->message >= wMsgFilterMin) && (lpMsg->message <= wMsgFilterMax)) break;
if(!wRemoveMsg)(*pPeekMessage)(lpMsg, hwnd, 0, 0, TRUE);
}
}
else
res=(*pPeekMessage)(lpMsg, hwnd, 0, 0, wRemoveMsg);
OutTraceW("PeekMessage: lpmsg=%x hwnd=%x filter=(%x-%x) remove=%x msg=%x(%s) wparam=%x, lparam=%x pt=(%d,%d) res=%x\n",
lpMsg, lpMsg->hwnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg,
lpMsg->message, ExplainWinMessage(lpMsg->message & 0xFFFF),
lpMsg->wParam, lpMsg->lParam, lpMsg->pt.x, lpMsg->pt.y, res);
return res;
}
BOOL WINAPI extPeekMessage(LPMSG lpMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg)
{
BOOL res;
@ -791,7 +823,7 @@ BOOL WINAPI extPeekMessage(LPMSG lpMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsg
// fix to avoid crash in Warhammer Final Liberation, that evidently intercepts mouse position by
// peeking & removing messages from window queue and considering the lParam parameter.
// v2.1.100 - never alter the mlMsg, otherwise the message is duplicated in the queue! Work on a copy of it.
// v2.1.100 - never alter the lpMsg, otherwise the message is duplicated in the queue! Work on a copy of it.
if(wRemoveMsg){
static MSG MsgCopy;
MsgCopy=*lpMsg;
@ -1127,9 +1159,19 @@ static HWND WINAPI extCreateWindowCommon(
y=0;
nWidth=workarea.right;
nHeight=workarea.bottom;
dwStyle=(dxw.dwFlags2 & MODALSTYLE) ? 0 : WS_OVERLAPPEDWINDOW;
dwStyle=0;
OutTraceD("%s: WORKAREA win pos=(%d,%d) size=(%d,%d)\n", ApiName, x, y, nWidth, nHeight);
}
else if(dxw.Coordinates==DXW_DESKTOP_FULL){
RECT workarea;
(*pGetClientRect)((*pGetDesktopWindow)(), &workarea);
x=0;
y=0;
nWidth=workarea.right;
nHeight=workarea.bottom;
dwStyle=0;
OutTraceD("%s: FULLDESKTOP win pos=(%d,%d) size=(%d,%d)\n", ApiName, x, y, nWidth, nHeight);
}
}
if(!dxw.IsFullScreen()){ // v2.1.63: needed for "Monster Truck Madness"

View File

@ -147,7 +147,7 @@
#define IDC_HOOKDLLS 1104
#define IDC_HOOKENABLED 1105
#define IDC_DESKTOPWORKAREA 1106
#define IDC_FIXD3DFRAME 1107
#define IDC_DESKTOPFULL 1107
#define IDC_TIMESLIDER 1108
#define IDC_BLACKWHITE 1109
#define IDC_SAVECAPS 1110
@ -167,6 +167,8 @@
#define IDC_FONTBYPASS 1124
#define IDC_YUV2RGB 1125
#define IDC_RGB2YUV 1126
#define IDC_FIXD3DFRAME 1127
#define IDC_BUFFEREDIOFIX 1128
#define ID_MODIFY 32771
#define ID_DELETE 32772
#define ID_ADD 32773

View File

@ -36,6 +36,7 @@ void CTabCompat::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_SUPPRESSD3DEXT, cTarget->m_SuppressD3DExt);
DDX_Check(pDX, IDC_CDROMDRIVETYPE, cTarget->m_CDROMDriveType);
DDX_Check(pDX, IDC_FONTBYPASS, cTarget->m_FontBypass);
DDX_Check(pDX, IDC_BUFFEREDIOFIX, cTarget->m_BufferedIOFix);
}
BEGIN_MESSAGE_MAP(CTabCompat, CDialog)

View File

@ -34,7 +34,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
m_HandleExceptions = FALSE;
m_SuppressIME = FALSE;
m_SuppressD3DExt = FALSE;
m_SetCompatibility = FALSE;
m_SetCompatibility = TRUE;
m_DisableHAL = FALSE;
m_LockSysColors = FALSE;
m_ForceYUVtoRGB = FALSE;
@ -44,6 +44,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
m_LimitResources = FALSE;
m_CDROMDriveType = FALSE;
m_FontBypass = FALSE;
m_BufferedIOFix = FALSE;
m_UnNotify = FALSE;
m_Windowize = TRUE; // default true !!
m_HookDLLs = TRUE; // default true !!

View File

@ -105,6 +105,7 @@ public:
BOOL m_LimitResources;
BOOL m_CDROMDriveType;
BOOL m_FontBypass;
BOOL m_BufferedIOFix;
BOOL m_SuppressIME;
BOOL m_SetCompatibility;
BOOL m_DisableHAL;

Binary file not shown.

View File

@ -263,15 +263,16 @@ BEGIN
CONTROL "Optimize CPU (DirectX1 - 7)",IDC_SAVELOAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,160,109,10
CONTROL "Intercept Alt-F4 key",IDC_HANDLEALTF4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,136,109,10
CONTROL "Run in Window",IDC_WINDOWIZE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,148,124,10
GROUPBOX "Generic",IDC_STATIC,7,103,286,88
GROUPBOX "Generic",IDC_STATIC,7,103,286,84
CONTROL "No banner",IDC_NOBANNER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,124,108,10
CONTROL "use DLL Injection",IDC_STARTDEBUG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,136,100,10
CONTROL "Remap Client Rect",IDC_CLIENTREMAPPING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,112,115,10
CONTROL "Hook all DLLs",IDC_HOOKDLLS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,160,124,10
CONTROL "Hook enabled",IDC_HOOKENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,112,124,10
CONTROL "X,Y coordinates",IDC_COORDINATES,"Button",BS_AUTORADIOBUTTON | WS_GROUP,170,198,95,10
CONTROL "Desktop work area",IDC_DESKTOPWORKAREA,"Button",BS_AUTORADIOBUTTON,170,208,95,10
CONTROL "Desktop center",IDC_DESKTOPCENTER,"Button",BS_AUTORADIOBUTTON,170,218,95,10
CONTROL "X,Y coordinates",IDC_COORDINATES,"Button",BS_AUTORADIOBUTTON | WS_GROUP,170,190,95,10
CONTROL "Desktop center",IDC_DESKTOPCENTER,"Button",BS_AUTORADIOBUTTON,170,200,95,10
CONTROL "Desktop work area",IDC_DESKTOPWORKAREA,"Button",BS_AUTORADIOBUTTON,170,210,95,10
CONTROL "Desktop",IDC_DESKTOPFULL,"Button",BS_AUTORADIOBUTTON,170,220,95,10
CONTROL "Hook child WindowProc",IDC_HOOKCHILDWIN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,148,114,10
CONTROL "Emulate Registry",IDC_EMULATEREGISTRY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,172,124,10
CONTROL "Fullscreen only",IDC_FULLSCREENONLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,172,114,10
@ -434,6 +435,7 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,164,109,12
CONTROL "Set CDROM Drive Type",IDC_CDROMDRIVETYPE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,152,109,12
CONTROL "Bypass font unsupported api",IDC_FONTBYPASS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,140,109,12
CONTROL "Fix buffered IO after Win98",IDC_BUFFEREDIOFIX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,128,109,12
END
IDD_TAB_GDI DIALOGEX 0, 0, 300, 240

Binary file not shown.

View File

@ -148,6 +148,7 @@ static void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg)
if(dlg->m_LimitResources) t->flags2 |= LIMITRESOURCES;
if(dlg->m_CDROMDriveType) t->flags3 |= CDROMDRIVETYPE;
if(dlg->m_FontBypass) t->flags3 |= FONTBYPASS;
if(dlg->m_BufferedIOFix) t->flags3 |= BUFFEREDIOFIX;
if(dlg->m_SuppressIME) t->flags2 |= SUPPRESSIME;
if(dlg->m_SuppressD3DExt) t->flags3 |= SUPPRESSD3DEXT;
if(dlg->m_SetCompatibility) t->flags2 |= SETCOMPATIBILITY;
@ -279,6 +280,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg)
dlg->m_LimitResources = t->flags2 & LIMITRESOURCES ? 1 : 0;
dlg->m_CDROMDriveType = t->flags3 & CDROMDRIVETYPE ? 1 : 0;
dlg->m_FontBypass = t->flags3 & FONTBYPASS ? 1 : 0;
dlg->m_BufferedIOFix = t->flags3 & BUFFEREDIOFIX ? 1 : 0;
dlg->m_SaveLoad = t->flags & SAVELOAD ? 1 : 0;
dlg->m_SlowDown = t->flags & SLOWDOWN ? 1 : 0;
dlg->m_BlitFromBackBuffer = t->flags & BLITFROMBACKBUFFER ? 1 : 0;