diff --git a/build/ICCVID.DLL b/build/ICCVID.DLL deleted file mode 100644 index ae34f20..0000000 Binary files a/build/ICCVID.DLL and /dev/null differ diff --git a/build/dxwnd.0.ini b/build/dxwnd.0.ini index bb365c8..6300aff 100644 --- a/build/dxwnd.0.ini +++ b/build/dxwnd.0.ini @@ -22,3 +22,5 @@ refresh= logtoggle= plocktoggle= fpstoggle= +printscreen=0x7B + diff --git a/build/dxwnd.dll b/build/dxwnd.dll index 3f7c827..a7537a0 100644 --- a/build/dxwnd.dll +++ b/build/dxwnd.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5005c1da2c65a47e47378d41ed67cb908a2fd475ced015bddebe715c7f1d71d7 -size 570368 +oid sha256:a309ebf6376c46e11161cf10c80cfaec09dc6bb88fa7ac4d8bbd0cf92e243eb8 +size 571904 diff --git a/build/dxwnd.exe b/build/dxwnd.exe index 9b429dc..99fd109 100644 --- a/build/dxwnd.exe +++ b/build/dxwnd.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2e73542e5cc2b9a1fa1d6429230b756694eb361b63fe55b812cb1c31c118e938 +oid sha256:e7bef752b0ed1dd25215248cadaae676418c24c88518b878d1328e2e34abb6ef size 538112 diff --git a/build/exports/Croc - Legend of the Gobbos.dxw b/build/exports/Croc - Legend of the Gobbos.dxw index 752e1bd..84dde12 100644 --- a/build/exports/Croc - Legend of the Gobbos.dxw +++ b/build/exports/Croc - Legend of the Gobbos.dxw @@ -6,7 +6,7 @@ module0= opengllib0= ver0=0 coord0=0 -flag0=134218272 +flag0=134217762 flagg0=1207959552 flagh0=20 flagi0=138412036 @@ -25,3 +25,5 @@ maxfps0=0 initts0=0 winver0=0 maxres0=-1 +notes0= +flagj0=128 diff --git a/build/exports/Dark Fall - The Journal (GOG 2.0.0.6).dxw b/build/exports/Dark Fall - The Journal (GOG 2.0.0.6).dxw new file mode 100644 index 0000000..ce01f15 --- /dev/null +++ b/build/exports/Dark Fall - The Journal (GOG 2.0.0.6).dxw @@ -0,0 +1,29 @@ +[target] +title0=Dark Fall - The Journal (GOG 2.0.0.6) +path0=D:\Games\Dark Fall - The Journal 2_0_0_6\DarkFall.exe +launchpath0= +module0= +opengllib0= +notes0= +ver0=0 +coord0=0 +flag0=713031682 +flagg0=1242562560 +flagh0=20 +flagi0=205520900 +flagj0=4224 +tflag0=0 +initx0=0 +inity0=0 +minx0=0 +miny0=0 +maxx0=0 +maxy0=0 +posx0=50 +posy0=50 +sizx0=640 +sizy0=480 +maxfps0=0 +initts0=0 +winver0=0 +maxres0=-1 diff --git a/build/exports/Diablo.dxw b/build/exports/Diablo.dxw index 9fb8c95..1e7c9cd 100644 --- a/build/exports/Diablo.dxw +++ b/build/exports/Diablo.dxw @@ -5,7 +5,7 @@ module0= opengllib0= ver0=1 coord0=0 -flag0=138428450 +flag0=138428448 flagg0=1242562576 flagh0=20 flagi0=4194304 @@ -26,4 +26,4 @@ launchpath0= winver0=0 maxres0=0 notes0= -flagj0=129 +flagj0=8388737 diff --git a/build/exports/Dink Smallwood.dxw b/build/exports/Dink Smallwood.dxw new file mode 100644 index 0000000..863911c --- /dev/null +++ b/build/exports/Dink Smallwood.dxw @@ -0,0 +1,29 @@ +[target] +title0=Dink Smallwood +path0=D:\Games\Dink Smallwood\dink.exe +launchpath0= +module0= +opengllib0= +notes0= +ver0=0 +coord0=0 +flag0=134217762 +flagg0=1207959552 +flagh0=20 +flagi0=138412038 +flagj0=4224 +tflag0=536870912 +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 diff --git a/build/exports/KKND Xtreme.dxw b/build/exports/KKND Xtreme.dxw index a9c842f..385b289 100644 --- a/build/exports/KKND Xtreme.dxw +++ b/build/exports/KKND Xtreme.dxw @@ -5,10 +5,10 @@ module0= opengllib0= ver0=0 coord0=0 -flag0=134234146 +flag0=402669600 flagg0=1207959552 flagh0=20 -flagi0=4 +flagi0=4194308 tflag0=0 initx0=0 inity0=0 @@ -24,3 +24,6 @@ maxfps0=0 initts0=0 winver0=0 maxres0=-1 +launchpath0= +notes0= +flagj0=8388736 diff --git a/build/exports/Road Rash.dxw b/build/exports/Road Rash.dxw new file mode 100644 index 0000000..0b72fd0 --- /dev/null +++ b/build/exports/Road Rash.dxw @@ -0,0 +1,29 @@ +[target] +title0=Road Rash +path0=D:\Games\road rash\ROADRASH.EXE +launchpath0= +module0= +opengllib0= +notes0= +ver0=0 +coord0=0 +flag0=134217762 +flagg0=1744830464 +flagh0=1044 +flagi0=1212153860 +flagj0=4224 +tflag0=0 +initx0=0 +inity0=0 +minx0=0 +miny0=0 +maxx0=0 +maxy0=0 +posx0=50 +posy0=50 +sizx0=800 +sizy0=600 +maxfps0=0 +initts0=0 +winver0=0 +maxres0=-1 diff --git a/build/exports/dxwnd.ini b/build/exports/dxwnd.ini index 385ef5b..8e8544a 100644 --- a/build/exports/dxwnd.ini +++ b/build/exports/dxwnd.ini @@ -1,5 +1,5 @@ [window] -posx=1292 -posy=131 +posx=541 +posy=525 sizx=320 -sizy=787 +sizy=406 diff --git a/build/readme-relnotes.txt b/build/readme-relnotes.txt index 3a25de5..dbbbd96 100644 --- a/build/readme-relnotes.txt +++ b/build/readme-relnotes.txt @@ -751,4 +751,11 @@ fix: dinput GetDeviceData add: implemented "Release mouse outside window" functionality in dinput calls fix: now "Release mouse outside window" leaves the mouse close to where it left the window fix: in GUI, keeps memory of last used paths -fix: several log messages \ No newline at end of file +fix: several log messages + +v2.03.13 +add: integrated printscreen facility with 8BPP paletized dump, activated by "printscreen" special key (default Alt-F12) +fix: recovery for lost surfaces (i.e. after a Ctrl+Alt+Del command) +fix: palette display form showing active entries +fix: EnumDisplayModes hook in emulate surface mode +fix: several log improvements diff --git a/build/registry/dxwnd.road rash.reg b/build/registry/dxwnd.road rash.reg new file mode 100644 index 0000000..03f7ff3 --- /dev/null +++ b/build/registry/dxwnd.road rash.reg @@ -0,0 +1,13 @@ +[HKEY_LOCAL_MACHINE\SOFTWARE] + +; Road Rash + +[HKEY_LOCAL_MACHINE\SOFTWARE\Electronic Arts] +[HKEY_LOCAL_MACHINE\SOFTWARE\Electronic Arts\RoadRash 95] +""="" +"Path"="." +"CheckDialup"=hex:00 +"ChatState"=hex:02 +"MiniDash"=hex:00 +"OpponentList"=hex:01 + diff --git a/dll/ddblit.cpp b/dll/ddblit.cpp index a0f0234..3da3af8 100644 --- a/dll/ddblit.cpp +++ b/dll/ddblit.cpp @@ -240,6 +240,7 @@ static HRESULT sBltToPrimary(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdest if (lpdds != lpddssrc){ if (IsDebug) BlitTrace("SRC2EMU", &emurect, &destrect, __LINE__); if(destrect.top == -32000) return DD_OK; // happens when window is minimized & do not notify on task switch ... + if(lpdds->IsLost()) lpdds->Restore(); // lpDDSEmu_Back could get lost ..... res=(*pBlt)(lpdds, &emurect, lpddssrc, lpsrcrect, dwflags, lpddbltfx); } @@ -282,6 +283,8 @@ static HRESULT sBltToPrimary(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdest return res; } + if(lpDDSEmu_Prim->IsLost()) lpDDSEmu_Prim->Restore(); + dxw.ShowOverlay(lpDDSSource); if (IsDebug) BlitTrace("BACK2PRIM", &emurect, &destrect, __LINE__); res=(*pPrimaryBlt)(lpDDSEmu_Prim, &destrect, lpDDSSource, &emurect); diff --git a/dll/ddraw.cpp b/dll/ddraw.cpp index db04307..2e86bb1 100644 --- a/dll/ddraw.cpp +++ b/dll/ddraw.cpp @@ -501,10 +501,6 @@ void mySetPalette(int dwstart, int dwcount, LPPALETTEENTRY lpentries, BOOL Has25 int i; extern DXWNDSTATUS *pStatus; - // copy the palette entries on the current system palette - for(int idx=0; idxPalette[dwstart+idx]= lpentries[idx]; - // if has reserved palette entries, recover them if(!Has256ColorsPalette){ int nStatCols, nPalEntries; @@ -531,6 +527,10 @@ void mySetPalette(int dwstart, int dwcount, LPPALETTEENTRY lpentries, BOOL Has25 } } + // copy the palette entries on the current system palette + for(int idx=0; idxPalette[dwstart+idx]= lpentries[idx]; + for(i = 0; i < dwcount; i ++){ PALETTEENTRY PalColor; PalColor = lpentries[i]; @@ -883,6 +883,29 @@ int SurfaceDescrSize(LPDIRECTDRAWSURFACE lpdds) return sizeof(DDSURFACEDESC); } +int SurfaceDescrSizeD(LPDIRECTDRAW lpdd) +{ + char sMsg[81]; + void *extCreateSurface = NULL; + + if(lpdd){ + __try{ + extCreateSurface=(void *)*(DWORD *)(*(DWORD *)lpdd + 24); + } + __except (EXCEPTION_EXECUTE_HANDLER){ + return sizeof(DDSURFACEDESC); + }; + if(extCreateSurface==(void *)extCreateSurface7) return sizeof(DDSURFACEDESC2); + if(extCreateSurface==(void *)extCreateSurface4) return sizeof(DDSURFACEDESC2); + if(extCreateSurface==(void *)extCreateSurface2) return sizeof(DDSURFACEDESC); + if(extCreateSurface==(void *)extCreateSurface1) return sizeof(DDSURFACEDESC); + } + sprintf_s(sMsg, 80, "SurfaceDescrSizeD(%x) can't match %x\n", lpdd, extCreateSurface); + OutTraceDW(sMsg); + if (IsAssertEnabled) MessageBox(0, sMsg, "SurfaceDescrSizeD", MB_OK | MB_ICONEXCLAMATION); + return sizeof(DDSURFACEDESC); +} + int lpddsHookedVersion(LPDIRECTDRAWSURFACE lpdds) { char sMsg[81]; @@ -3150,7 +3173,6 @@ HRESULT WINAPI ColorConversionGDI(LPDIRECTDRAWSURFACE lpdds, RECT emurect, LPDIR { // GDICOLORCONV: use GDI capabilities to convert color depth by BitBlt-ting between different hdc HRESULT res; - OutTrace("STEP: GDI Color Conversion\n"); do { HDC hdc_source, hdc_dest; res=(*pGetDC)(lpdds, &hdc_source); @@ -3425,6 +3447,7 @@ HRESULT WINAPI extCreatePalette(LPDIRECTDRAW lpdd, DWORD dwflags, LPPALETTEENTRY //if (dwflags & ~(DDPCAPS_PRIMARYSURFACE|DDPCAPS_8BIT|DDPCAPS_ALLOW256|DDPCAPS_INITIALIZE_LEGACY)) STOPPER("Palette flags"); if(dwflags & DDPCAPS_ALLOW256) Has256ColorsPalette = TRUE; + if(!(dwflags & DDPCAPS_PRIMARYSURFACE)) Has256ColorsPalette = TRUE; if(dxw.dwFlags1 & EMULATESURFACE) dwflags &= ~DDPCAPS_PRIMARYSURFACE; res = (*pCreatePalette)(lpdd, dwflags, lpddpa, lplpddp, pu); @@ -3584,7 +3607,12 @@ HRESULT WINAPI extLock(LPDIRECTDRAWSURFACE lpdds, LPRECT lprect, LPDDSURFACEDESC res = (*pLock)(lpdds, lprect, lpDDSurfaceDesc, flags, hEvent); OutTraceDW("Lock RETRY: ret=%x(%s)\n", res, ExplainDDError(res)); } - if(res) OutTraceE("Lock ERROR: ret=%x(%s)\n", res, ExplainDDError(res)); + if(res==DDERR_SURFACELOST){ + lpdds->Restore(); + res = (*pLock)(lpdds, lprect, lpDDSurfaceDesc, flags, hEvent); + OutTraceDW("Lock RETRY: ret=%x(%s)\n", res, ExplainDDError(res)); + } + if(res) OutTraceE("Lock ERROR: ret=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__); OutTraceB("Lock: lPitch=%d lpSurface=%x %s\n", lpDDSurfaceDesc->lPitch, lpDDSurfaceDesc->lpSurface, LogSurfaceAttributes(lpDDSurfaceDesc, "[Locked]", __LINE__)); if(dxw.dwFlags1 & SUPPRESSDXERRORS) res=DD_OK; @@ -3664,7 +3692,7 @@ HRESULT WINAPI extLockDir(LPDIRECTDRAWSURFACE lpdds, LPRECT lprect, LPDDSURFACED res=(*pLock)(lpdds, lprect, lpDDSurfaceDesc, flags, hEvent); - if(res) OutTraceE("Lock ERROR: ret=%x(%s)\n", res, ExplainDDError(res)); + if(res) OutTraceE("Lock ERROR: ret=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__); OutTraceB("Lock: %s\n", LogSurfaceAttributes((LPDDSURFACEDESC)lpDDSurfaceDesc, "[Locked]" , __LINE__)); if(dxw.dwFlags1 & SUPPRESSDXERRORS) res=DD_OK; @@ -4041,8 +4069,7 @@ HRESULT WINAPI extEnumDisplayModes(EnumDisplayModes1_Type pEnumDisplayModes, LPD EmuDesc.dwRefreshRate = 0; EmuDesc.ddpfPixelFormat.dwFlags = DDPF_RGB; if (lpddsd) dwSize=lpddsd->dwSize; // sizeof either DDSURFACEDESC or DDSURFACEDESC2 !!! - else dwSize = sizeof(DDSURFACEDESC2); - if(dwSize > sizeof(DDSURFACEDESC2)) dwSize=sizeof(DDSURFACEDESC2); + else dwSize=SurfaceDescrSizeD(lpdd); memset(&EmuDesc, 0, dwSize); EmuDesc.dwSize=dwSize; EmuDesc.dwFlags=DDSD_PIXELFORMAT|DDSD_REFRESHRATE|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PITCH; diff --git a/dll/ddshot.cpp b/dll/ddshot.cpp new file mode 100644 index 0000000..99bc908 --- /dev/null +++ b/dll/ddshot.cpp @@ -0,0 +1,132 @@ +#define _CRT_SECURE_NO_WARNINGS + +#include +#include +#include "dxwnd.h" +#include "dxwcore.hpp" +#include "dxhelper.h" + +extern char *ExplainDDError(DWORD); + +typedef HRESULT (WINAPI *Lock_Type)(LPDIRECTDRAWSURFACE, LPRECT, LPDDSURFACEDESC, DWORD, HANDLE); +typedef HRESULT (WINAPI *Unlock4_Type)(LPDIRECTDRAWSURFACE, LPRECT); +typedef HRESULT (WINAPI *Unlock1_Type)(LPDIRECTDRAWSURFACE, LPVOID); + +extern Lock_Type pLock; +extern Unlock4_Type pUnlockMethod(LPDIRECTDRAWSURFACE); +extern int Set_dwSize_From_Surface(LPDIRECTDRAWSURFACE); + +void DDrawScreenShot() +{ + LPDIRECTDRAWSURFACE s; + DDSURFACEDESC2 ddsd; + int w, h, iSurfaceSize, iScanLineSize; + HRESULT res; + static int MinTexX, MinTexY, MaxTexX, MaxTexY; + static BOOL DoOnce = TRUE; + char pszFile[MAX_PATH]; + static int hash = 0; + + if(DoOnce){ + sprintf_s(pszFile, MAX_PATH, "%s\\screenshot.out", GetDxWndPath()); + CreateDirectory(pszFile, NULL); + while(TRUE){ + sprintf_s(pszFile, MAX_PATH, "%s\\screenshot.out\\shot.%08d.bmp", GetDxWndPath(), hash); + if(GetFileAttributes(pszFile) == INVALID_FILE_ATTRIBUTES) break; + hash++; + } + DoOnce = FALSE; + } + + if(dxw.dwFlags5 & GDIMODE){ + extern LPDIRECTDRAWSURFACE lpDDSBack; + s = lpDDSBack; + } + else{ + s = dxw.GetPrimarySurface(); + } + if(!s) return; + + memset(&ddsd,0,sizeof(DDSURFACEDESC2)); + ddsd.dwSize = Set_dwSize_From_Surface(s); + ddsd.dwFlags = DDSD_LPSURFACE | DDSD_PITCH; + if(res=(*pLock)(s, 0, (LPDDSURFACEDESC)&ddsd, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY|DDLOCK_WAIT, 0)){ + OutTraceE("ScreenShot: Lock ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__); + return; + } + + while (TRUE) { // fake loop + OutTrace("ScreenShot: lpdds=%x BitCount=%d size=(%dx%d)\n", + s, ddsd.ddpfPixelFormat.dwRGBBitCount, ddsd.dwWidth, ddsd.dwHeight); + w = ddsd.dwWidth; + h = ddsd.dwHeight; + if(ddsd.ddpfPixelFormat.dwRGBBitCount == 0) { + OutTrace("ScreenShot: SKIP 0BPP texture\n"); + break; + } + + iSurfaceSize = ddsd.dwHeight * ddsd.lPitch; + + FILE *hf; + BITMAPFILEHEADER hdr; // bitmap file-header + BITMAPV4HEADER pbi; // bitmap info-header + + memset((void *)&pbi, 0, sizeof(BITMAPV4HEADER)); + pbi.bV4Size = sizeof(BITMAPV4HEADER); + pbi.bV4Width = ddsd.dwWidth; + pbi.bV4Height = ddsd.dwHeight; + pbi.bV4BitCount = (WORD)ddsd.ddpfPixelFormat.dwRGBBitCount; + pbi.bV4SizeImage = ((pbi.bV4Width * pbi.bV4BitCount + 0x1F) & ~0x1F)/8 * pbi.bV4Height; + pbi.bV4Height = - pbi.bV4Height; + pbi.bV4Planes = 1; + pbi.bV4V4Compression = BI_BITFIELDS; + if(pbi.bV4BitCount == 8) pbi.bV4V4Compression = BI_RGB; + pbi.bV4XPelsPerMeter = 1; + pbi.bV4YPelsPerMeter = 1; + pbi.bV4ClrUsed = 0; + if(pbi.bV4BitCount == 8) pbi.bV4ClrUsed = 256; + pbi.bV4ClrImportant = 0; + pbi.bV4RedMask = ddsd.ddpfPixelFormat.dwRBitMask; + pbi.bV4GreenMask = ddsd.ddpfPixelFormat.dwGBitMask; + pbi.bV4BlueMask = ddsd.ddpfPixelFormat.dwBBitMask; + pbi.bV4AlphaMask = ddsd.ddpfPixelFormat.dwRGBAlphaBitMask; + pbi.bV4CSType = LCS_CALIBRATED_RGB; + iScanLineSize = ((pbi.bV4Width * pbi.bV4BitCount + 0x1F) & ~0x1F)/8; + + // Create the .BMP file. + sprintf_s(pszFile, MAX_PATH, "%s\\screenshot.out\\shot.%08d.bmp", GetDxWndPath(), hash++); + hf = fopen(pszFile, "wb"); + if(!hf) break; + + hdr.bfType = 0x4d42; // 0x42 = "B" 0x4d = "M" + // Compute the size of the entire file. + hdr.bfSize = (DWORD) (sizeof(BITMAPFILEHEADER) + pbi.bV4Size + pbi.bV4ClrUsed * sizeof(RGBQUAD) + pbi.bV4SizeImage); + hdr.bfReserved1 = 0; + hdr.bfReserved2 = 0; + + // Compute the offset to the array of color indices. + hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) + pbi.bV4Size + pbi.bV4ClrUsed * sizeof (RGBQUAD); + + // Copy the BITMAPFILEHEADER into the .BMP file. + fwrite((LPVOID)&hdr, sizeof(BITMAPFILEHEADER), 1, hf); + + // Copy the BITMAPINFOHEADER array into the file. + fwrite((LPVOID)&pbi, sizeof(BITMAPV4HEADER), 1, hf); + + // Copy the RGBQUAD array into the file. + if(pbi.bV4ClrUsed){ + extern DWORD PaletteEntries[256]; + fwrite((LPVOID)PaletteEntries, pbi.bV4ClrUsed * sizeof (RGBQUAD), 1, hf); + } + + // Copy the array of color indices into the .BMP file. + for(int y=0; y<(int)ddsd.dwHeight; y++) + fwrite((BYTE *)ddsd.lpSurface + (y*ddsd.lPitch), iScanLineSize, 1, hf); + + // Close the .BMP file. + fclose(hf); + break; + } + res=(*pUnlockMethod(s))(s, NULL); + if (res) OutTraceE("ScreenShot: Unlock ERROR lpdds=%x res=%x(%s) at %d\n", s, res, ExplainDDError(res), __LINE__); +} diff --git a/dll/dxhook.cpp b/dll/dxhook.cpp index 463096e..9340591 100644 --- a/dll/dxhook.cpp +++ b/dll/dxhook.cpp @@ -778,6 +778,7 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp static int LastTimeShift; static int SaveTimeShift; static BOOL TimeShiftToggle=TRUE; + extern void DDrawScreenShot(); if(DoOnce){ DoOnce=FALSE; @@ -1093,6 +1094,9 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp TerminateProcess(GetCurrentProcess(),0); } break; + case DXVK_PRINTSCREEN: + DDrawScreenShot(); + break; default: break; } diff --git a/dll/dxwcore.cpp b/dll/dxwcore.cpp index c6474e8..6b44620 100644 --- a/dll/dxwcore.cpp +++ b/dll/dxwcore.cpp @@ -1903,7 +1903,8 @@ static char *VKeyLabels[DXVK_SIZE]={ "timefast", "timeslow", "timetoggle", - "altf4" + "altf4", + "printscreen" }; void dxwCore::MapKeysInit() diff --git a/dll/dxwcore.hpp b/dll/dxwcore.hpp index 6a36e70..aa357a3 100644 --- a/dll/dxwcore.hpp +++ b/dll/dxwcore.hpp @@ -240,6 +240,7 @@ typedef enum { DXVK_TIMESLOW, DXVK_TIMETOGGLE, DXVK_ALTF4, + DXVK_PRINTSCREEN, DXVK_SIZE }; diff --git a/dll/dxwnd.cpp b/dll/dxwnd.cpp index 9930e02..97fdb5c 100644 --- a/dll/dxwnd.cpp +++ b/dll/dxwnd.cpp @@ -27,7 +27,7 @@ along with this program. If not, see . #include "TlHelp32.h" -#define VERSION "2.03.12" +#define VERSION "2.03.13" #define DDTHREADLOCK 1 //#define LOCKTHREADS diff --git a/dll/dxwnd.vs2008.suo b/dll/dxwnd.vs2008.suo index dee1184..baa2238 100644 Binary files a/dll/dxwnd.vs2008.suo and b/dll/dxwnd.vs2008.suo differ diff --git a/dll/dxwnd.vs2008.vcproj b/dll/dxwnd.vs2008.vcproj index a93b330..54e5136 100644 --- a/dll/dxwnd.vs2008.vcproj +++ b/dll/dxwnd.vs2008.vcproj @@ -261,6 +261,10 @@ /> + + diff --git a/dll/gdi32.cpp b/dll/gdi32.cpp index 0ea3fd9..51d29f7 100644 --- a/dll/gdi32.cpp +++ b/dll/gdi32.cpp @@ -51,6 +51,13 @@ COLORREF WINAPI extSetTextColor(HDC hdc, COLORREF crColor); int WINAPI extSetBkMode(HDC, int); */ +typedef UINT (WINAPI *GetPaletteEntries_Type)(HPALETTE, UINT, UINT, LPPALETTEENTRY); +typedef UINT (WINAPI *GetSystemPaletteUse_Type)(HDC); +GetPaletteEntries_Type pGetPaletteEntries = NULL; +GetSystemPaletteUse_Type pGetSystemPaletteUse = NULL; +UINT WINAPI extGetPaletteEntries(HPALETTE, UINT, UINT, LPPALETTEENTRY); +UINT WINAPI extGetSystemPaletteUse(HDC); + static HookEntry_Type Hooks[]={ {HOOK_IAT_CANDIDATE, "GetDeviceCaps", (FARPROC)GetDeviceCaps, (FARPROC *)&pGDIGetDeviceCaps, (FARPROC)extGetDeviceCaps}, @@ -71,6 +78,11 @@ static HookEntry_Type Hooks[]={ {HOOK_IAT_CANDIDATE, "GetPixelFormat", (FARPROC)NULL, (FARPROC *)&pGDIGetPixelFormat, (FARPROC)extGDIGetPixelFormat}, {HOOK_IAT_CANDIDATE, "ChoosePixelFormat", (FARPROC)NULL, (FARPROC *)&pChoosePixelFormat, (FARPROC)extChoosePixelFormat}, {HOOK_IAT_CANDIDATE, "DescribePixelFormat", (FARPROC)NULL, (FARPROC *)&pDescribePixelFormat, (FARPROC)extDescribePixelFormat}, + + {HOOK_HOT_CANDIDATE, "GetPaletteEntries", (FARPROC)GetPaletteEntries, (FARPROC *)&pGetPaletteEntries, (FARPROC)extGetPaletteEntries}, + {HOOK_HOT_CANDIDATE, "GetSystemPaletteUse", (FARPROC)GetSystemPaletteUse, (FARPROC *)&pGetSystemPaletteUse, (FARPROC)extGetSystemPaletteUse}, + + {HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator }; @@ -479,15 +491,10 @@ BOOL WINAPI extGDIRestoreDC(HDC hdc, int nSavedDC) HPALETTE WINAPI extGDICreatePalette(CONST LOGPALETTE *plpal) { HPALETTE ret; - int idx; - OutTraceDW("GDI.CreatePalette: plpal=%x version=%x NumEntries=%x\n", plpal, plpal->palVersion, plpal->palNumEntries); + OutTraceDW("GDI.CreatePalette: plpal=%x version=%x NumEntries=%d\n", plpal, plpal->palVersion, plpal->palNumEntries); + if(IsDebug) dxw.DumpPalette(plpal->palNumEntries, (LPPALETTEENTRY)plpal->palPalEntry); ret=(*pGDICreatePalette)(plpal); - if(IsDebug){ - OutTraceDW("PalEntry[%x]= ", plpal->palNumEntries); - for(idx=0; idxpalNumEntries; idx++) OutTraceDW("(%x)", plpal->palPalEntry[idx]); - OutTraceDW("\n"); - } OutTraceDW("GDI.CreatePalette: hPalette=%x\n", ret); return ret; } @@ -525,7 +532,7 @@ UINT WINAPI extRealizePalette(HDC hdc) if((OBJ_DC == GetObjectType(hdc)) && (dxw.dwFlags1 & EMULATESURFACE)){ PALETTEENTRY PalEntries[256]; UINT nEntries; - nEntries=GetPaletteEntries(hDesktopPalette, 0, 256, PalEntries); + nEntries=(*pGetPaletteEntries)(hDesktopPalette, 0, 256, PalEntries); mySetPalette(0, nEntries, PalEntries, TRUE); // ?? if(IsDebug) dxw.DumpPalette(nEntries, PalEntries); ret=DD_OK; @@ -1751,10 +1758,27 @@ int WINAPI extAddFontResourceW(LPCWSTR lpszFontFile) UINT WINAPI extSetSystemPaletteUse(HDC hdc, UINT uUsage) { //BOOL res; - OutTraceDW("SetSystemPaletteUse: hdc=%x Usage=%x(%s)\n", hdc, uUsage, ExplainPaletteUse(uUsage)); + OutTraceDW("GDI.SetSystemPaletteUse: hdc=%x Usage=%x(%s)\n", hdc, uUsage, ExplainPaletteUse(uUsage)); return SYSPAL_NOSTATIC256; } +UINT WINAPI extGetPaletteEntries(HPALETTE hpal, UINT iStartIndex, UINT nEntries, LPPALETTEENTRY lppe) +{ + UINT res; + OutTraceDW("GDI.GetPaletteEntries: hpal=%x iStartIndex=%d nEntries=%d\n", hpal, iStartIndex, nEntries); + res=(*pGetPaletteEntries)(hpal, iStartIndex, nEntries, lppe); + return res; +} + +UINT WINAPI extGetSystemPaletteUse(HDC hdc) +{ + UINT res; + OutTraceDW("GDI.GetSystemPaletteUse: hdc=%x\n", hdc); + res=(*pGetSystemPaletteUse)(hdc); + OutTraceDW("GetSystemPaletteUse: res=%x(%s)\n", res, ExplainPaletteUse(res)); + return res; +} + //BEWARE: SetPixelFormat must be issued on the same hdc used by OpenGL wglCreateContext, otherwise // a failure err=2000 ERROR INVALID PIXEL FORMAT occurs!! diff --git a/dll/user32.cpp b/dll/user32.cpp index 98742b7..dcb8b12 100644 --- a/dll/user32.cpp +++ b/dll/user32.cpp @@ -20,6 +20,11 @@ BOOL IsChangeDisplaySettingsHotPatched = FALSE; //BOOL WINAPI extValidateRect(HWND, const RECT *); //ValidateRect_Type pValidateRect = NULL; +//typedef BOOL (WINAPI *EnumDisplayMonitors_Type)(HDC, LPCRECT, MONITORENUMPROC, LPARAM); +//EnumDisplayMonitors_Type pEnumDisplayMonitors = NULL; +//BOOL WINAPI extEnumDisplayMonitors(HDC, LPCRECT, MONITORENUMPROC, LPARAM); + + static HookEntry_Type Hooks[]={ {HOOK_IAT_CANDIDATE, "UpdateWindow", (FARPROC)NULL, (FARPROC *)&pUpdateWindow, (FARPROC)extUpdateWindow}, //{HOOK_IAT_CANDIDATE, "GetWindowPlacement", (FARPROC)NULL, (FARPROC *)&pGetWindowPlacement, (FARPROC)extGetWindowPlacement}, @@ -44,7 +49,7 @@ static HookEntry_Type Hooks[]={ {HOOK_IAT_CANDIDATE, "RegisterClassExA", (FARPROC)RegisterClassExA, (FARPROC *)&pRegisterClassExA, (FARPROC)extRegisterClassExA}, {HOOK_IAT_CANDIDATE, "RegisterClassA", (FARPROC)RegisterClassA, (FARPROC *)&pRegisterClassA, (FARPROC)extRegisterClassA}, {HOOK_HOT_CANDIDATE, "GetSystemMetrics", (FARPROC)GetSystemMetrics, (FARPROC *)&pGetSystemMetrics, (FARPROC)extGetSystemMetrics}, - {HOOK_IAT_CANDIDATE, "GetDesktopWindow", (FARPROC)GetDesktopWindow, (FARPROC *)&pGetDesktopWindow, (FARPROC)extGetDesktopWindow}, + {HOOK_HOT_CANDIDATE, "GetDesktopWindow", (FARPROC)GetDesktopWindow, (FARPROC *)&pGetDesktopWindow, (FARPROC)extGetDesktopWindow}, {HOOK_IAT_CANDIDATE, "CloseWindow", (FARPROC)NULL, (FARPROC *)&pCloseWindow, (FARPROC)extCloseWindow}, {HOOK_IAT_CANDIDATE, "DestroyWindow", (FARPROC)NULL, (FARPROC *)&pDestroyWindow, (FARPROC)extDestroyWindow}, {HOOK_IAT_CANDIDATE, "SetSysColors", (FARPROC)NULL, (FARPROC *)&pSetSysColors, (FARPROC)extSetSysColors}, @@ -60,6 +65,8 @@ static HookEntry_Type Hooks[]={ //{HOOK_HOT_CANDIDATE, "GetActiveWindow", (FARPROC)NULL, (FARPROC *)&pGetActiveWindow, (FARPROC)extGetActiveWindow}, //{HOOK_HOT_CANDIDATE, "GetForegroundWindow", (FARPROC)GetForegroundWindow, (FARPROC *)&pGetForegroundWindow, (FARPROC)extGetForegroundWindow}, //{HOOK_IAT_CANDIDATE, "GetWindowTextA", (FARPROC)GetWindowTextA, (FARPROC *)&pGetWindowTextA, (FARPROC)extGetWindowTextA}, + //{HOOK_HOT_CANDIDATE, "EnumDisplayMonitors", (FARPROC)EnumDisplayMonitors, (FARPROC *)&pEnumDisplayMonitors, (FARPROC)extEnumDisplayMonitors}, + {HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator }; @@ -2756,7 +2763,7 @@ HWND WINAPI extChildWindowFromPointEx(HWND hWndParent, POINT Point, UINT uFlags) BOOL extGetMonitorInfo(HMONITOR hMonitor, LPMONITORINFO lpmi, GetMonitorInfo_Type pGetMonitorInfo) { BOOL res; - OutTrace("GetMonitorInfo: hMonitor=%x mi=MONITORINFO%s\n", hMonitor, lpmi->cbSize==sizeof(MONITORINFO)?"":"EX"); + OutTraceDW("GetMonitorInfo: hMonitor=%x mi=MONITORINFO%s\n", hMonitor, lpmi->cbSize==sizeof(MONITORINFO)?"":"EX"); res=(*pGetMonitorInfo)(hMonitor, lpmi); if(res && dxw.Windowize){ OutTraceDW("GetMonitorInfo: FIX Work=(%d,%d)-(%d,%d) Monitor=(%d,%d)-(%d,%d) -> (%d,%d)-(%d,%d)\n", @@ -2766,6 +2773,9 @@ BOOL extGetMonitorInfo(HMONITOR hMonitor, LPMONITORINFO lpmi, GetMonitorInfo_Typ lpmi->rcWork = dxw.GetScreenRect(); lpmi->rcMonitor = dxw.GetScreenRect(); } + else + OutTraceE("GetMonitorInfo: ERROR err=%d\n", GetLastError()); + return res; } diff --git a/host/TabProgram.cpp b/host/TabProgram.cpp index 17e1de6..7641c29 100644 --- a/host/TabProgram.cpp +++ b/host/TabProgram.cpp @@ -72,7 +72,7 @@ void CTabProgram::OnOpen() extern char *gInitFilePath; CTargetDlg *cTarget = ((CTargetDlg *)(this->GetParent()->GetParent())); cTarget->m_File.GetWindowText(path, MAX_PATH); - GetPrivateProfileString("window", "exepath", ".", path, MAX_PATH, gInitFilePath); + GetPrivateProfileString("window", "exepath", NULL, path, MAX_PATH, gInitFilePath); CFileDialog dlg( TRUE, "*.*", path, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Program (*.exe)|*.exe|All Files (*.*)|*.*||", this); if( dlg.DoModal() == IDOK) { diff --git a/host/dxwndhost.vs2008.suo b/host/dxwndhost.vs2008.suo index 1261f5c..3485163 100644 Binary files a/host/dxwndhost.vs2008.suo and b/host/dxwndhost.vs2008.suo differ