From 63934645ab4acfd67328c91ab32e5f9d6d466714 Mon Sep 17 00:00:00 2001 From: gho tik Date: Sun, 13 Jul 2014 12:39:33 -0400 Subject: [PATCH] v2_02_85_src Former-commit-id: 130f1fb64eb2e2fef8397ccc53f4845431fa17f1 --- Include/dxwnd.h | 7 ++- build/dxwnd.dll | 4 +- build/dxwnd.ini | 57 ++++++++++++++++++++++- build/readme-relnotes.txt | 6 ++- dll/dxhook.cpp | 8 ++-- dll/dxwcore.cpp | 4 +- dll/dxwnd.cpp | 2 +- dll/dxwnd.vs2008.suo | Bin 175616 -> 178176 bytes dll/dxwnd.vs2008.vcproj | 4 ++ dll/hd3d.cpp | 61 ++++++++++++++++++++++--- dll/hd3d.doc.hpp | 41 +++++++++++++++++ dll/user32.cpp | 34 ++++++++++---- dll/wndproc.cpp | 94 +++++++++++++++++++++++++++++++++++--- 13 files changed, 287 insertions(+), 35 deletions(-) create mode 100644 dll/hd3d.doc.hpp diff --git a/Include/dxwnd.h b/Include/dxwnd.h index 54565fd..44f23fe 100644 --- a/Include/dxwnd.h +++ b/Include/dxwnd.h @@ -258,8 +258,11 @@ LRESULT CALLBACK extDialogWindowProc(HWND, UINT, WPARAM, LPARAM); #define IsAssertEnabled (dxw.dwTFlags & ASSERTDIALOG) #define STEP OutTrace("STEP at %s:%d\n", __FILE__, __LINE__) -extern void WhndStackPush(HWND, WNDPROC); -extern WNDPROC WhndGetWindowProc(HWND ); +extern void WinDBPut(HWND, WNDPROC, int, int); +extern BOOL WinDBGetSize(HWND, int *, int *); +extern WNDPROC WinDBGetProc(HWND); +extern void WinDBPutProc(HWND, WNDPROC); +extern void WinDBPutSize(HWND, int, int); typedef enum { DXW_SET_COORDINATES = 0, diff --git a/build/dxwnd.dll b/build/dxwnd.dll index 430192f..9f9b368 100644 --- a/build/dxwnd.dll +++ b/build/dxwnd.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9acf0133674a5d1ffcc309d75c08587768cf3442b0df972f25fae2e030364053 -size 492544 +oid sha256:44bc7151507fb71f758117713d02a61e84ee848a109920a5e8c6820e4cfe79a2 +size 493568 diff --git a/build/dxwnd.ini b/build/dxwnd.ini index ae1493c..4df1801 100644 --- a/build/dxwnd.ini +++ b/build/dxwnd.ini @@ -1,6 +1,59 @@ [window] -posx=929 -posy=550 +posx=1074 +posy=334 sizx=320 sizy=200 lang=automatic +[target] +title0=MetroLL.exe +path0=D:\Games\Metro Last Light\MetroLL.exe +launchpath0= +module0= +opengllib0= +ver0=10 +coord0=0 +flag0=679477792 +flagg0=1207959552 +flagh0=20 +flagi0=205520900 +tflag0=6147 +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 +title1=MC.EXE +path1=D:\Games\Moonchld\MC.EXE +launchpath1= +module1= +opengllib1= +ver1=0 +coord1=0 +flag1=134218336 +flagg1=1207959552 +flagh1=2068 +flagi1=-2009071612 +tflag1=6147 +initx1=0 +inity1=0 +minx1=0 +miny1=0 +maxx1=0 +maxy1=0 +posx1=50 +posy1=50 +sizx1=800 +sizy1=600 +maxfps1=0 +initts1=0 +winver1=0 +maxres1=-1 diff --git a/build/readme-relnotes.txt b/build/readme-relnotes.txt index 02de050..91a90c1 100644 --- a/build/readme-relnotes.txt +++ b/build/readme-relnotes.txt @@ -548,4 +548,8 @@ fix: supppressed BackBuffer release within D3D7:CreateDevice: this makes "Tetris add: build-in check for compatibility modes set! v2.02.84 -fix: removed extra reference to ddraw session causing window movements on fullscreen game exit: fixes another "Wind Fantasy SP" reported bug \ No newline at end of file +fix: removed extra reference to ddraw session causing window movements on fullscreen game exit: fixes another "Wind Fantasy SP" reported bug + +v2.02.85 +fix: revised handling of d3d D3DFORMAT field: fixes "Call of Cthulhu DCotE" color problems +fix: added recovery for rounded child win coordinates: fixes blitting problems in Diablo when win size is not an exact multiple of native resolution. \ No newline at end of file diff --git a/dll/dxhook.cpp b/dll/dxhook.cpp index 91d3ae9..38b7f79 100644 --- a/dll/dxhook.cpp +++ b/dll/dxhook.cpp @@ -528,7 +528,7 @@ void HookWindowProc(HWND hwnd) } else {// don't hook twice .... long lres; - WhndStackPush(hwnd, pWindowProc); + WinDBPutProc(hwnd, pWindowProc); lres=(*pSetWindowLongA)(hwnd, GWL_WNDPROC, (LONG)extWindowProc); OutTraceDW("SetWindowLong: hwnd=%x HOOK WindowProc=%x->%x\n", hwnd, lres, (LONG)extWindowProc); } @@ -597,7 +597,7 @@ LRESULT CALLBACK extDialogWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPA t=tn; } - pWindowProc=WhndGetWindowProc(hwnd); + pWindowProc=WinDBGetProc(hwnd); if(pWindowProc) return(*pCallWindowProc)(pWindowProc, hwnd, message, wparam, lparam); char *sMsg="ASSERT: DialogWinMsg pWindowProc=NULL !!!\n"; OutTraceDW(sMsg); @@ -653,7 +653,7 @@ LRESULT CALLBACK extChildWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPAR } } - pWindowProc=WhndGetWindowProc(hwnd); + pWindowProc=WinDBGetProc(hwnd); // v2.02.82: use CallWindowProc that handles WinProc handles if(pWindowProc) return(*pCallWindowProc)(pWindowProc, hwnd, message, wparam, lparam); @@ -1016,7 +1016,7 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp } if (dxw.dwFlags1 & AUTOREFRESH) dxw.ScreenRefresh(); - pWindowProc=WhndGetWindowProc(hwnd); + pWindowProc=WinDBGetProc(hwnd); //OutTraceB("WindowProc: pWindowProc=%x extWindowProc=%x message=%x(%s) wparam=%x lparam=%x\n", // (*pWindowProc), extWindowProc, message, ExplainWinMessage(message), wparam, lparam); if(pWindowProc) { diff --git a/dll/dxwcore.cpp b/dll/dxwcore.cpp index 4e61dc8..157f238 100644 --- a/dll/dxwcore.cpp +++ b/dll/dxwcore.cpp @@ -29,7 +29,7 @@ static LARGE_INTEGER TimeShifter64Coarse(LARGE_INTEGER, int); dxwCore::dxwCore() { // initialization stuff .... - extern void WhndStackInit(); + extern void WinDBInit(); FullScreen=FALSE; SethWnd(NULL); SetScreenSize(); @@ -44,7 +44,7 @@ dxwCore::dxwCore() ResetEmulatedDC(); MustShowOverlay=FALSE; TimerEvent.dwTimerType = TIMER_TYPE_NONE; - WhndStackInit(); + WinDBInit(); } dxwCore::~dxwCore() diff --git a/dll/dxwnd.cpp b/dll/dxwnd.cpp index 27bb17d..d0635d9 100644 --- a/dll/dxwnd.cpp +++ b/dll/dxwnd.cpp @@ -24,7 +24,7 @@ along with this program. If not, see . #include "dxwnd.h" #include "dxwcore.hpp" -#define VERSION "2.02.84" +#define VERSION "2.02.85" #define DDTHREADLOCK 1 diff --git a/dll/dxwnd.vs2008.suo b/dll/dxwnd.vs2008.suo index 6fb3b4232a62fee5fff74403e4cf568e129869fc..61209d371e59f189670b07c3574567ac6b806f1b 100644 GIT binary patch delta 9255 zcma)?33wGnx`w+tCkr7!2qA=kA&{_z#juA>0tq1dDndlou&7~&k^O`nH$)m!j4YvYI51~uIr<_$2!J1P6Be9L9}zvc1*fj`F$1nYMlQRyZ`=6ZLerGZJhpa- zdENe(Yj(MvjNKGvrpH&J5>?OvCr}w>R%e!ObyL%hxDHAUTJDN`+*rsmmgn1p``zcg ziigtki<~*mRHv;o)0vBZ%kgiSlk43!Ooqwzu1u}#l@zB3(wCZwIt^wzMQEWSwA;_y z&vBO8C*CqmL-+IcUN1q>=n-aLN&E#bI4ZAQD1^J+8C$=}VVcI`RS#GA6QwOL?~ zUP4dYy~HHjZkN&hTAVfO51u!PcK&cvFL36pDKqTYiyHBrGK<-9y9e-!TrkHgOis1b za~N#SLvKSDpm(4jA$#YyW`FW6c>jPZp(@B>1-~<{oqWJew=2(?)wbYo;R3tDWD{uGr}g#7mrI2R!ADZjK)5l*GOq6_3)Y{%N>C@i4v~h5Ovu zfs&gTZ~~JqnXM*tzfEjwvoP@AmrX6S!d#OWNc`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2_$Htl}(a=YK@NI-ZhY02Hzx|;({QZh+v{SF?iQEjDOm2~QVU6=0Fx2_9+d=v8% z9PYGDwm3`~ds!>TT-L< + + diff --git a/dll/hd3d.cpp b/dll/hd3d.cpp index 6995efb..d28f4fe 100644 --- a/dll/hd3d.cpp +++ b/dll/hd3d.cpp @@ -9,6 +9,7 @@ #include "dxhook.h" #include "dxhelper.h" #include "syslibs.h" +#include "hd3d.doc.hpp" // fake include to hold documentation #define HOOKD3D10ANDLATER 1 #define TRACEALLMETHODS 1 @@ -668,7 +669,6 @@ HRESULT WINAPI extReset(void *pd3dd, D3DPRESENT_PARAMETERS* pPresParam) OutTraceD3D("GetAdapterDisplayMode FAILED! %x\n", res); return(DD_OK); } - param[2] = mode.Format; param[7] = 0; //hDeviceWindow dxw.SetFullScreen(~param[8]?TRUE:FALSE); param[8] = 1; //Windowed @@ -688,7 +688,6 @@ HRESULT WINAPI extReset(void *pd3dd, D3DPRESENT_PARAMETERS* pPresParam) OutTraceD3D("GetAdapterDisplayMode FAILED! %x\n", res); return(DD_OK); } - param[2] = mode.Format; param[6] = 0; //hDeviceWindow dxw.SetFullScreen(~param[7]?TRUE:FALSE); param[7] = 1; //Windowed @@ -700,6 +699,16 @@ HRESULT WINAPI extReset(void *pd3dd, D3DPRESENT_PARAMETERS* pPresParam) if(!(dxw.dwFlags4 & NOD3DRESET)){ res = (*pReset)(pd3dd, (D3DPRESENT_PARAMETERS *)param); + if(res){ + OutTraceD3D("switching to mode=%x\n", mode.Format); + param[2] = mode.Format; // first attempt: current screen mode + res = (*pReset)(pd3dd, (D3DPRESENT_PARAMETERS *)param); + } + if(res){ + OutTraceD3D("switching to mode=D3DFMT_UNKNOWN\n"); + param[2] = D3DFMT_UNKNOWN; // second attempt: unknown, good for windowed mode + res = (*pReset)(pd3dd, (D3DPRESENT_PARAMETERS *)param); + } if(res == D3DERR_INVALIDCALL){ OutTraceD3D("FAILED! D3DERR_INVALIDCALL\n", res); return D3DERR_INVALIDCALL; @@ -898,7 +907,6 @@ HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devicetype, (*pGetAdapterDisplayMode9)(lpd3d, 0, &mode); else (*pGetAdapterDisplayMode8)(lpd3d, 0, &mode); - param[2] = mode.Format; OutTraceD3D(" Current Format = 0x%x\n", mode.Format); OutTraceD3D(" Current ScreenSize = (%dx%d)\n", mode.Width, mode.Height); OutTraceD3D(" Current Refresh Rate = %d\n", mode.RefreshRate); @@ -913,6 +921,16 @@ HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devicetype, param[13] = D3DPRESENT_INTERVAL_DEFAULT; //PresentationInterval } res = (*pCreateDevice9)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, ppd3dd); + if(res){ + OutTraceD3D("switching to mode=%x\n", mode.Format); + param[2] = mode.Format; // first attempt: current screen mode + res = (*pCreateDevice9)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, ppd3dd); + } + if(res){ + OutTraceD3D("switching to mode=D3DFMT_UNKNOWN\n"); + param[2] = D3DFMT_UNKNOWN; // second attempt: unknown, good for windowed mode + res = (*pCreateDevice9)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, ppd3dd); + } } else{ if(dxw.Windowize){ @@ -924,6 +942,16 @@ HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devicetype, param[12] = D3DPRESENT_INTERVAL_DEFAULT; //PresentationInterval } res = (*pCreateDevice8)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, ppd3dd); + if(res){ + OutTraceD3D("switching to mode=%x\n", mode.Format); + param[2] = mode.Format; // first attempt: current screen mode + res = (*pCreateDevice8)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, ppd3dd); + } + if(res){ + OutTraceD3D("switching to mode=D3DFMT_UNKNOWN\n"); + param[2] = D3DFMT_UNKNOWN; // second attempt: unknown, good for windowed mode + res = (*pCreateDevice8)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, ppd3dd); + } } if(res){ @@ -989,7 +1017,6 @@ HRESULT WINAPI extCreateDeviceEx(void *lpd3d, UINT adapter, D3DDEVTYPE devicetyp //((LPDIRECT3D9)lpd3d)->GetAdapterDisplayMode(0, &mode); (*pGetAdapterDisplayMode9)(lpd3d, 0, &mode); - param[2] = mode.Format; OutTraceD3D(" Current Format = 0x%x\n", mode.Format); OutTraceD3D(" Current ScreenSize = (%dx%d)\n", mode.Width, mode.Height); OutTraceD3D(" Current Refresh Rate = %d\n", mode.RefreshRate); @@ -1004,6 +1031,16 @@ HRESULT WINAPI extCreateDeviceEx(void *lpd3d, UINT adapter, D3DDEVTYPE devicetyp } res = (*pCreateDeviceEx)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, pFullscreenDisplayMode, ppd3dd); + if(res){ + OutTraceD3D("switching to mode=%x\n", mode.Format); + param[2] = mode.Format; // first attempt: current screen mode + res = (*pCreateDeviceEx)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, pFullscreenDisplayMode, ppd3dd); + } + if(res){ + OutTraceD3D("switching to mode=D3DFMT_UNKNOWN\n"); + param[2] = D3DFMT_UNKNOWN; // second attempt: unknown, good for windowed mode + res = (*pCreateDeviceEx)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, pFullscreenDisplayMode, ppd3dd); + } if(res){ OutTraceD3D("FAILED! %x\n", res); return res; @@ -1109,7 +1146,6 @@ HRESULT WINAPI extCreateAdditionalSwapChain(void *lpd3dd, D3DPRESENT_PARAMETERS (*pGetAdapterDisplayMode9)(lpd3dd, 0, &mode); else (*pGetAdapterDisplayMode8)(lpd3dd, 0, &mode); - param[2] = mode.Format; OutTraceD3D(" Current Format = 0x%x\n", mode.Format); OutTraceD3D(" Current ScreenSize = (%dx%d)\n", mode.Width, mode.Height); OutTraceD3D(" Current Refresh Rate = %d\n", mode.RefreshRate); @@ -1131,7 +1167,20 @@ HRESULT WINAPI extCreateAdditionalSwapChain(void *lpd3dd, D3DPRESENT_PARAMETERS } } res=(*pCreateAdditionalSwapChain)(lpd3dd, (D3DPRESENT_PARAMETERS *)param, ppSwapChain); - if(res) OutTraceE("CreateAdditionalSwapChain ERROR: res=%x\n", res); + if(res){ + OutTraceD3D("switching to mode=%x\n", mode.Format); + param[2] = mode.Format; // first attempt: current screen mode + res=(*pCreateAdditionalSwapChain)(lpd3dd, (D3DPRESENT_PARAMETERS *)param, ppSwapChain); + } + if(res){ + OutTraceD3D("switching to mode=D3DFMT_UNKNOWN\n"); + param[2] = D3DFMT_UNKNOWN; // second attempt: unknown, good for windowed mode + res=(*pCreateAdditionalSwapChain)(lpd3dd, (D3DPRESENT_PARAMETERS *)param, ppSwapChain); + } + if(res) { + OutTraceE("CreateAdditionalSwapChain ERROR: res=%x\n", res); + } + (dwD3DVersion == 9) ? HookD3DDevice9(&lpd3dd) : HookD3DDevice8(&lpd3dd); return res; } diff --git a/dll/hd3d.doc.hpp b/dll/hd3d.doc.hpp new file mode 100644 index 0000000..38ccad0 --- /dev/null +++ b/dll/hd3d.doc.hpp @@ -0,0 +1,41 @@ +#if 0 +from http://msdn.microsoft.com/en-us/library/windows/desktop/bb172588%28v=vs.85%29.aspx + +D3DPRESENT_PARAMETERS structure + +Describes the presentation parameters. +Syntax +C++ + +typedef struct D3DPRESENT_PARAMETERS { + UINT BackBufferWidth; + UINT BackBufferHeight; + D3DFORMAT BackBufferFormat; + UINT BackBufferCount; + D3DMULTISAMPLE_TYPE MultiSampleType; + DWORD MultiSampleQuality; + D3DSWAPEFFECT SwapEffect; + HWND hDeviceWindow; + BOOL Windowed; + BOOL EnableAutoDepthStencil; + D3DFORMAT AutoDepthStencilFormat; + DWORD Flags; + UINT FullScreen_RefreshRateInHz; + UINT PresentationInterval; +} D3DPRESENT_PARAMETERS, *LPD3DPRESENT_PARAMETERS; + +BackBufferFormat + Type: D3DFORMAT + The back buffer format. For more information about formats, see D3DFORMAT. + This value must be one of the render-target formats as validated by CheckDeviceType. + You can use GetDisplayMode to obtain the current format. + In fact, D3DFMT_UNKNOWN can be specified for the BackBufferFormat while in windowed mode. + This tells the runtime to use the current display-mode format and eliminates the need to call GetDisplayMode. + For windowed applications, the back buffer format no longer needs to match the display-mode format because + color conversion can now be done by the hardware (if the hardware supports color conversion). + The set of possible back buffer formats is constrained, but the runtime will allow any valid back buffer format + to be presented to any desktop format. (There is the additional requirement that the device be operable in the + desktop; devices typically do not operate in 8 bits per pixel modes.) + + Full-screen applications cannot do color conversion. +#endif \ No newline at end of file diff --git a/dll/user32.cpp b/dll/user32.cpp index 0a23fc6..b97a21d 100644 --- a/dll/user32.cpp +++ b/dll/user32.cpp @@ -12,6 +12,8 @@ #include "hddraw.h" #include "dxhelper.h" +#define FIXCHILDSIZE TRUE + BOOL IsChangeDisplaySettingsHotPatched = FALSE; static HookEntry_Type Hooks[]={ @@ -543,7 +545,7 @@ LONG WINAPI extGetWindowLong(HWND hwnd, int nIndex, GetWindowLong_Type pGetWindo if((nIndex==GWL_WNDPROC)||(nIndex==DWL_DLGPROC)){ WNDPROC wp; - wp=WhndGetWindowProc(hwnd); + wp=WinDBGetProc(hwnd); OutTraceDW("GetWindowLong: remapping WindowProc res=%x -> %x\n", res, (LONG)wp); if(wp) res=(LONG)wp; // if not found, don't alter the value. } @@ -623,8 +625,8 @@ LONG WINAPI extSetWindowLong(HWND hwnd, int nIndex, LONG dwNewLong, SetWindowLon if((OldProc==extWindowProc) || (OldProc==extChildWindowProc)|| (OldProc==extDialogWindowProc)) - OldProc=WhndGetWindowProc(hwnd); - WhndStackPush(hwnd, (WNDPROC)dwNewLong); + OldProc=WinDBGetProc(hwnd); + WinDBPutProc(hwnd, (WNDPROC)dwNewLong); res=(LONG)OldProc; SetLastError(0); lres=(WNDPROC)(*pSetWindowLongA)(hwnd, nIndex, (LONG)extWindowProc); @@ -973,6 +975,16 @@ BOOL WINAPI extGetClientRect(HWND hwnd, LPRECT lpRect) } else if (dxw.IsFullScreen()){ + int w, h; + if(FIXCHILDSIZE){ + if(WinDBGetSize(hwnd, &w, &h)){ + lpRect->top=lpRect->left=0; + lpRect->right=w; + lpRect->bottom=h; + OutTraceB("GetClientRect: fixed rect=(%d,%d)-(%d,%d)\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); + return TRUE; + } + } *lpRect=dxw.GetClientRect(*lpRect); OutTraceB("GetClientRect: fixed rect=(%d,%d)-(%d,%d)\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); } @@ -1127,7 +1139,7 @@ static void HookChildWndProc(HWND hwnd, DWORD dwStyle, LPCTSTR ApiName) { // child window inherit the father's windproc, so if it's redirected to // a hooker (either extWindowProc or extChildWindowProc) you have to retrieve - // the correct value (WhndGetWindowProc) before saving it (WhndStackPush). + // the correct value (WinDBGetProc) before saving it (WinDBPutProc). long res; WNDPROC pWindowProc; @@ -1138,13 +1150,13 @@ static void HookChildWndProc(HWND hwnd, DWORD dwStyle, LPCTSTR ApiName) HWND Father; WNDPROC pFatherProc; Father=GetParent(hwnd); - pFatherProc=WhndGetWindowProc(Father); + pFatherProc=WinDBGetProc(Father); OutTraceDW("%s: WndProc=%s father=%x WndProc=%x\n", ApiName, (pWindowProc == extWindowProc) ? "extWindowProc" : ((pWindowProc == extChildWindowProc) ? "extChildWindowProc" : "extDialogWindowProc"), Father, pFatherProc); pWindowProc = pFatherProc; } - WhndStackPush(hwnd, pWindowProc); + WinDBPutProc(hwnd, pWindowProc); if(dwStyle & WS_CHILD){ OutTraceDW("%s: Hooking CHILD hwnd=%x father WindowProc %x->%x\n", ApiName, hwnd, pWindowProc, extChildWindowProc); res=(*pSetWindowLongA)(hwnd, GWL_WNDPROC, (LONG)extChildWindowProc); @@ -1174,7 +1186,10 @@ static HWND WINAPI extCreateWindowCommon( { HWND hwnd; BOOL isValidHandle=TRUE; + int iOrigW, iOrigH; + iOrigW=nWidth; + iOrigH=nHeight; if(!dxw.Windowize){ if(WideChar) hwnd= (*pCreateWindowExW)(dwExStyle, (LPCWSTR)lpClassName, (LPCWSTR)lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam); @@ -1336,6 +1351,9 @@ static HWND WINAPI extCreateWindowCommon( if ((dxw.dwFlags1 & HOOKCHILDWIN) && (dwStyle & (WS_CHILD|WS_DLGFRAME))) HookChildWndProc(hwnd, dwStyle, ApiName); + if ((FIXCHILDSIZE) && (dwStyle & (WS_CHILD|WS_DLGFRAME))) + WinDBPutSize(hwnd, iOrigW, iOrigH); + OutTraceDW("%s: ret=%x\n", ApiName, hwnd); return hwnd; } @@ -2123,7 +2141,7 @@ HWND WINAPI extCreateDialogIndirectParam(HINSTANCE hInstance, LPCDLGTEMPLATE lpT // v2.02.73: redirect lpDialogFunc only when it is nor NULL if(lpDialogFunc) { - WhndStackPush(RetHWND, (WNDPROC)lpDialogFunc); + WinDBPutProc(RetHWND, (WNDPROC)lpDialogFunc); if(!(*pSetWindowLongA)(RetHWND, DWL_DLGPROC, (LONG)extDialogWindowProc)) OutTraceE("SetWindowLong: ERROR err=%d at %d\n", GetLastError(), __LINE__); } @@ -2145,7 +2163,7 @@ HWND WINAPI extCreateDialogParam(HINSTANCE hInstance, LPCTSTR lpTemplateName, HW // v2.02.73: redirect lpDialogFunc only when it is nor NULL: fix for "LEGO Stunt Rally" if(lpDialogFunc) { - WhndStackPush(RetHWND, (WNDPROC)lpDialogFunc); + WinDBPutProc(RetHWND, (WNDPROC)lpDialogFunc); if(!(*pSetWindowLongA)(RetHWND, DWL_DLGPROC, (LONG)extDialogWindowProc)) OutTraceE("SetWindowLong: ERROR err=%d at %d\n", GetLastError(), __LINE__); } diff --git a/dll/wndproc.cpp b/dll/wndproc.cpp index 1da6c7d..6cb0271 100644 --- a/dll/wndproc.cpp +++ b/dll/wndproc.cpp @@ -15,6 +15,8 @@ typedef struct { HWND hwnd; WNDPROC wndproc; + int w; + int h; } wndstack_entry; #define MAXWNDHSTACK 256 @@ -23,16 +25,17 @@ wndstack_entry *WhndStack; static int WhndTOS = 0; static int WhndSize = 0; -void WhndStackInit() +void WinDBInit() { WhndSize = MAXWNDHSTACK; WhndStack = (wndstack_entry *)malloc(WhndSize * sizeof(wndstack_entry)); } -void WhndStackPush(HWND hwnd, WNDPROC wndproc) +void WinDBPut(HWND hwnd, WNDPROC wndproc, int w, int h) { int StackIdx; + // add extra space when necessary, in chunks of MAXWNDHSTACK entries if(WhndTOS == WhndSize){ WhndSize += MAXWNDHSTACK; WhndStack = (wndstack_entry *)realloc(WhndStack, WhndSize * sizeof(wndstack_entry)); @@ -44,21 +47,98 @@ void WhndStackPush(HWND hwnd, WNDPROC wndproc) // try update first... for(StackIdx=0; StackIdx