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

v2_04_06_src_fx4

Former-commit-id: 1f32de7896e503fe164bcea0087d3072e521bcae
This commit is contained in:
gho tik 2017-01-20 11:49:41 -05:00 committed by Refael ACkermann
parent 90f03dc416
commit 6097e08028
20 changed files with 220 additions and 24 deletions

View File

@ -268,6 +268,8 @@
#define MARKWING32 0x00010000 // Marks (highlights with colored frames) all WinG32 operations
#define DYNAMICZCLEAN 0x00020000 // Performs ZBUFFER cleaning also every time the ZBUFFER is activated
#define MARKGDI32 0x00040000 // Marks (highlights with colored frames) the main GDI32 operations
#define DUMPDIBSECTION 0x00080000 // dumps DIBs to BMP files for debugging purposes
#define DUMPDEVCONTEXT 0x00100000 // dumps source HDC to BMP files for debugging purposes
// logging Tflags DWORD:
#define OUTTRACE 0x00000001 // enables tracing to dxwnd.log in general

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c4a337db3a9c5cbb7c06069a437f34c28285dcf2548181622789c594c8750bc1
size 781312
oid sha256:a035cc2206b5dcd8fed40fafdef29abe8b54f47acfbceb0568cd7d09f17be7d8
size 782848

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fb594ca522bdf3bc9956b3e2f18c8582c85728c30a77f6c0879e971bc3417ff2
oid sha256:fdef6f8a6645074858924bffbe81e345ebafda4269521681fcad76f50d14a589
size 673280

View File

@ -1458,10 +1458,14 @@ add: hook for GDI32 GdiAlphaBlend, very rare call that appeared in "RHEM" during
v2.04.06/fx3
GUI:
add: Expert mode
add: experimental dump od DIB sections and blitted dc for debugging purposes
DLL:
fix: corrected condition to print two virtual registry log messages
fix: improved logic to recover surfaces with DDSCAPS_TEXTURE capability - ref. "Dominant Species"
fix: fixed cursor clipping state and toggle key to make it work in all conditions
fix: D3D objects hooking with QueryInterface method. Fixes "Wizardry Chronicle"
fix: add hook for GDI32 GdiGradientFill and GdiTransparentBlt, present in "RHEM"
fix: log messages for CloseHandle wrapper
fix: log messages for CloseHandle wrapper
fix: log messages for GetPixel wrapper
fix: window position in MoveWindow for ANCHORED mode and big windows
fix: DialogBoxParamA wrapper

View File

@ -4224,7 +4224,7 @@ static HRESULT WINAPI extGetDC(int dxversion, GetDC_Type pGetDC, LPDIRECTDRAWSUR
res=(*pGetDC)(lpdds, pHDC);
}
OutTraceDDRAW("GetDC: res=%x hdc=%x\n",res, *pHDC);
OutTraceDDRAW("GetDC: res=%x(%s) hdc=%x\n", res, ExplainDDError(res), *pHDC);
return res;
}

151
dll/dibdump.cpp Normal file
View File

@ -0,0 +1,151 @@
#define _CRT_SECURE_NO_WARNINGS
#include "dxwnd.h"
#include "dxwcore.hpp"
#include "syslibs.h"
#include "hddraw.h"
#include "dxhook.h"
#include "dxhelper.h"
#include "shareddc.hpp"
#include "stdio.h"
void DumpDibSection(const BITMAPINFO *pbmi, UINT iUsage, VOID *pvBits)
{
static int prog=0;
FILE *fdump;
char path[81];
BITMAPFILEHEADER hdr; // bitmap file-header
BITMAPV4HEADER pbi; // bitmap info-header
int iScanLineSize;
if(iUsage != DIB_RGB_COLORS) return;
if(prog==0) CreateDirectory(".\\bmp.out", NULL);
sprintf(path,".\\bmp.out\\dib.%08.8d.bmp", prog);
fdump=fopen(path, "wb");
if(!fdump) return;
memset((void *)&pbi, 0, sizeof(BITMAPV4HEADER));
pbi.bV4Size = sizeof(BITMAPV4HEADER);
pbi.bV4Width = pbmi->bmiHeader.biWidth;
pbi.bV4Height = pbmi->bmiHeader.biHeight;
pbi.bV4BitCount = pbmi->bmiHeader.biBitCount;
pbi.bV4SizeImage = ((pbi.bV4Width * pbi.bV4BitCount + 0x1F) & ~0x1F)/8 * pbi.bV4Height;
pbi.bV4Height = - pbi.bV4Height;
pbi.bV4Planes = pbmi->bmiHeader.biPlanes;
pbi.bV4V4Compression = pbmi->bmiHeader.biCompression;
pbi.bV4XPelsPerMeter = 1;
pbi.bV4YPelsPerMeter = 1;
pbi.bV4ClrUsed = pbmi->bmiHeader.biClrUsed;
if(!pbi.bV4ClrUsed) pbi.bV4ClrUsed = 1 << pbi.bV4BitCount;
pbi.bV4ClrImportant = pbmi->bmiHeader.biClrImportant;
pbi.bV4RedMask = 0;
pbi.bV4RedMask = 0;
pbi.bV4GreenMask = 0;
pbi.bV4BlueMask = 0;
pbi.bV4AlphaMask = 0;
pbi.bV4CSType = LCS_CALIBRATED_RGB;
iScanLineSize = ((pbi.bV4Width * pbi.bV4BitCount + 0x1F) & ~0x1F)/8;
OutTrace("DumpDibSection: prog=%d size=%d wxh=(%dx%d) bc=%d sizeimg=%d planes=%d comp=%x ppm=(%dx%d) colors=%d imp=%d\n",
prog,
pbi.bV4Size, pbi.bV4Width, pbi.bV4Height, pbi.bV4BitCount, pbi.bV4SizeImage,
pbi.bV4Planes, pbi.bV4V4Compression, pbi.bV4XPelsPerMeter, pbi.bV4YPelsPerMeter,
pbi.bV4ClrUsed, pbi.bV4ClrImportant);
prog++;
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, fdump);
// Copy the BITMAPINFOHEADER array into the file.
fwrite((LPVOID)&pbi, sizeof(BITMAPV4HEADER), 1, fdump);
// Copy the RGBQUAD array into the file.
if(pbi.bV4ClrUsed) fwrite(&pbmi->bmiColors[0], pbi.bV4ClrUsed * sizeof (RGBQUAD), 1, fdump);
// 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, fdump);
fwrite((BYTE *)pvBits, pbi.bV4SizeImage, 1, fdump);
// Close the .BMP file.
fclose(fdump);
}
void DumpHDC(HDC hdc, int x0, int y0, int w, int h)
{
FILE *fdump;
static int prog = 0;
char path[81];
BITMAPFILEHEADER hdr;
BITMAPV4HEADER pbi; // bitmap info-header
if (w<0) w = -w;
if (h<0) h = -h;
if(prog==0) CreateDirectory(".\\bmp.out", NULL);
sprintf(path,".\\bmp.out\\hdc.%08.8d.bmp", prog);
fdump=fopen(path, "wb");
if(!fdump) {
OutTrace("DumpHDC: err=%d\n", GetLastError());
return;
}
// this bitmap is not created in the same format of the original HDC: using the GetPixel call to read the pixels
// means that the resulting image will be 32bpp color depth
memset((void *)&pbi, 0, sizeof(BITMAPV4HEADER));
pbi.bV4Size = sizeof(BITMAPV4HEADER);
pbi.bV4Width = w;
pbi.bV4Height = h;
pbi.bV4BitCount = 32;
pbi.bV4SizeImage = ((pbi.bV4Width * pbi.bV4BitCount + 0x1F) & ~0x1F)/8 * pbi.bV4Height;
pbi.bV4Height = -pbi.bV4Height;
pbi.bV4Planes = 1;
pbi.bV4V4Compression = BI_BITFIELDS;
pbi.bV4XPelsPerMeter = 1;
pbi.bV4YPelsPerMeter = 1;
pbi.bV4ClrUsed = 0;
pbi.bV4ClrImportant = 0;
pbi.bV4RedMask = 0x000000FF;
pbi.bV4GreenMask = 0x0000FF00;
pbi.bV4BlueMask = 0x00FF0000;
pbi.bV4AlphaMask = 0x00000000;
pbi.bV4CSType = LCS_CALIBRATED_RGB;
int iScanLineSize = ((pbi.bV4Width * pbi.bV4BitCount + 0x1F) & ~0x1F)/8;
OutTrace("DumpDevContext: prog=%08.8d size=%d wxh=(%dx%d) bc=%d sizeimg=%d planes=%d comp=%x ppm=(%dx%d) colors=%d imp=%d\n",
prog,
pbi.bV4Size, pbi.bV4Width, pbi.bV4Height, pbi.bV4BitCount, pbi.bV4SizeImage,
pbi.bV4Planes, pbi.bV4V4Compression, pbi.bV4XPelsPerMeter, pbi.bV4YPelsPerMeter,
pbi.bV4ClrUsed, pbi.bV4ClrImportant);
prog++;
// Fill in the fields of the file header
hdr.bfType = ((WORD) ('M' << 8) | 'B'); // is always "BM"
hdr.bfSize = (w * h) + sizeof( hdr );
hdr.bfReserved1 = 0;
hdr.bfReserved2 = 0;
hdr.bfOffBits = (DWORD)(sizeof(hdr) + sizeof(pbi));
// Write the file header
fwrite( &hdr, sizeof(hdr), 1, fdump);
// Write the DIB header
fwrite( &pbi, sizeof(pbi), 1, fdump );
// Write the bits
for(int y=y0; y<y0+h; y++)
for(int x=x0; x<x0+w; x++){
DWORD pixel=GetPixel(hdc, x, y);
fwrite(&pixel, sizeof(DWORD), 1, fdump);
}
fclose(fdump);
}
// eof

View File

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

Binary file not shown.

View File

@ -293,6 +293,10 @@
RelativePath=".\ddtexture.cpp"
>
</File>
<File
RelativePath=".\dibdump.cpp"
>
</File>
<File
RelativePath=".\dinput.cpp"
>

View File

@ -10,6 +10,8 @@
#include "stdio.h"
extern void DumpDibSection(const BITMAPINFO *, UINT, VOID *);
extern void DumpHDC(HDC, int, int, int, int);
static BOOL bGDIRecursionFlag = FALSE;
static void Stopper(char *s, int line)
@ -963,6 +965,8 @@ BOOL WINAPI extGDIBitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nH
Flux = (IsToScreen ? 1 : 0) + (IsFromScreen ? 2 : 0);
if (IsToScreen && (dxw.dwFlags3 & NOGDIBLT)) return TRUE;
if(IsToScreen && (dxw.dwFlags8 & DUMPDEVCONTEXT)) DumpHDC(hdcSrc, nXSrc, nYSrc, nWidth, nHeight);
if(dxw.IsFullScreen()){
//int nWSrc, nHSrc,
int nWDest, nHDest;
@ -2930,7 +2934,12 @@ COLORREF WINAPI extGetPixel(HDC hdc, int nXPos, int nYPos)
}
ret=(*pGetPixel)(hdc, nXPos, nYPos);
if(!ret) OutTraceE("GetPixel ERROR: err=%d\n", GetLastError());
if(ret==CLR_INVALID) {
OutTraceE("GetPixel ERROR: err=%d\n", GetLastError());
}
else {
OutTraceDW("GetPixel: color=0x%x\n", ret);
}
return ret;}
BOOL WINAPI extPlgBlt(HDC hdcDest, const POINT *lpPoint, HDC hdcSrc, int nXSrc, int nYSrc, int nWidth, int nHeight, HBITMAP hbmMask, int xMask, int yMask)
@ -3011,7 +3020,9 @@ HBITMAP WINAPI extCreateDIBSection(HDC hdc, const BITMAPINFO *pbmi, UINT iUsage,
}
else {
OutTraceDW("CreateDIBSection: ret=%x\n", ret);
if(dxw.dwFlags8 & DUMPDIBSECTION) DumpDibSection(pbmi, iUsage, *ppvBits);
}
return ret;
}

View File

@ -579,7 +579,8 @@ void dxwFixWindowPos(char *ApiName, HWND hwnd, LPARAM lParam)
wp->x = MaxPos.x;
wp->y = MaxPos.y;
OutTraceDW("%s: SET anchored pos=(%d,%d) size=(%dx%d)\n", ApiName, wp->x, wp->y, wp->cx, wp->cy);
} }
}
}
if ((dxw.dwFlags2 & KEEPASPECTRATIO) && dxw.IsFullScreen() && (hwnd==dxw.GethWnd())){
// note: while keeping aspect ration, resizing from one corner doesn't tell
@ -2615,17 +2616,15 @@ BOOL WINAPI extEndPaint(HWND hwnd, const PAINTSTRUCT *lpPaint)
HWND WINAPI extCreateDialogIndirectParam(HINSTANCE hInstance, LPCDLGTEMPLATE lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM lParamInit)
{
HWND RetHWND;
BOOL FullScreen;
FullScreen = dxw.IsFullScreen();
OutTraceDW("CreateDialogIndirectParam: hInstance=%x lpTemplate=(style=%x extstyle=%x items=%d pos=(%d,%d) size=(%dx%d)) hWndParent=%x lpDialogFunc=%x lParamInit=%x\n",
hInstance,
lpTemplate->style, lpTemplate->dwExtendedStyle, lpTemplate->cdit, lpTemplate->x, lpTemplate->y, lpTemplate->cx, lpTemplate->cy,
hWndParent, lpDialogFunc, lParamInit);
if(dxw.IsFullScreen() && hWndParent==NULL) hWndParent=dxw.GethWnd();
// v2.03.98: commented out the temporary return to windowed mode to make Red Alert 2 dialog work again!
//dxw.SetFullScreen(FALSE);
//InMainWinCreation++;
RetHWND=(*pCreateDialogIndirectParam)(hInstance, lpTemplate, hWndParent, lpDialogFunc, lParamInit);
//dxw.SetFullScreen(FullScreen);
//InMainWinCreation--;
// v2.02.73: redirect lpDialogFunc only when it is nor NULL
if( lpDialogFunc &&
@ -2642,14 +2641,12 @@ HWND WINAPI extCreateDialogIndirectParam(HINSTANCE hInstance, LPCDLGTEMPLATE lpT
HWND WINAPI extCreateDialogParam(HINSTANCE hInstance, LPCTSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM lParamInit)
{
HWND RetHWND;
BOOL FullScreen;
FullScreen = dxw.IsFullScreen();
OutTraceDW("CreateDialogParam: hInstance=%x lpTemplateName=%s hWndParent=%x lpDialogFunc=%x lParamInit=%x\n",
hInstance, sTemplateName(lpTemplateName), hWndParent, lpDialogFunc, lParamInit);
if(hWndParent==NULL) hWndParent=dxw.GethWnd();
//dxw.SetFullScreen(FALSE);
//InMainWinCreation++;
RetHWND=(*pCreateDialogParam)(hInstance, lpTemplateName, hWndParent, lpDialogFunc, lParamInit);
//dxw.SetFullScreen(FullScreen);
//InMainWinCreation--;
// v2.02.73: redirect lpDialogFunc only when it is nor NULL: fix for "LEGO Stunt Rally"
if( lpDialogFunc &&
@ -2715,20 +2712,31 @@ BOOL WINAPI extMoveWindow(HWND hwnd, int X, int Y, int nWidth, int nHeight, BOOL
RECT screen;
DWORD dwStyle;
POINT upleft = {0,0};
char *sStyle;
(*pGetClientRect)(dxw.GethWnd(),&screen);
(*pClientToScreen)(dxw.GethWnd(),&upleft);
if((dwStyle=(*pGetWindowLong)(hwnd, GWL_STYLE)) && WS_CHILDWINDOW){
// Big main child window: see "Reah"
X=Y=0;
sStyle="(child) ";
}
else{
// Regular big main window, usual case.
X=upleft.x;
Y=upleft.y;
X=upleft.x;
Y=upleft.y;
sStyle="";
}
nWidth=screen.right;
nHeight=screen.bottom;
OutTraceDW("MoveWindow: fixed BIG win pos=(%d,%d) size=(%d,%d)\n", X, Y, nWidth, nHeight);
if (dxw.dwFlags7 & ANCHORED){
WINDOWPOS MaxPos;
dxw.CalculateWindowPos(hwnd, dxw.iSizX, dxw.iSizY, &MaxPos);
nWidth = MaxPos.cx;
nHeight = MaxPos.cy;
X = MaxPos.x;
Y = MaxPos.y;
}
OutTraceDW("MoveWindow: fixed BIG %swin pos=(%d,%d) size=(%d,%d)\n", sStyle, X, Y, nWidth, nHeight);
}
}
}
@ -3838,18 +3846,17 @@ BOOL WINAPI extCloseDesktop(HDESK hDesktop)
INT_PTR WINAPI extDialogBoxParamA(HINSTANCE hInstance, LPCTSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam)
{
BOOL ret, FullScreen;
FullScreen = dxw.IsFullScreen();
BOOL ret;
OutTraceDW("DialogBoxParamA: FullScreen=%x TemplateName=\"%s\" WndParent=%x\n",
FullScreen, sTemplateName(lpTemplateName), hWndParent);
dxw.IsFullScreen(), sTemplateName(lpTemplateName), hWndParent);
// attempt to fix "Colonial Project 2" dialog. Doesn't work, but it could be ok.....
//if(FullScreen && dxw.IsRealDesktop(hWndParent)){
// OutTraceDW("DialogBoxParamA: remap WndParent=%x->%x\n", hWndParent, dxw.GethWnd());
// hWndParent = dxw.GethWnd();
//}
dxw.SetFullScreen(FALSE);
//InMainWinCreation++;
ret = (*pDialogBoxParamA)(hInstance, lpTemplateName, hWndParent, lpDialogFunc, dwInitParam);
dxw.SetFullScreen(FullScreen);
//InMainWinCreation--;
OutTraceDW("DialogBoxParamA: ret=%x\n", ret);
return ret;
}

View File

@ -343,6 +343,13 @@ MCIERROR WINAPI extmciSendCommand(BOOL isAnsi, mciSendCommand_Type pmciSendComma
pw->hWnd = dxw.GethWnd();
OutTraceB("mciSendCommand: REDIRECT hwnd=%x\n", pw->hWnd);
}
// attempt to stretch "Wizardry Chronicle" intro movie, but it doesn't work ...
//if(1){
// fdwCommand &= ~MCI_OVLY_WINDOW_DISABLE_STRETCH;
// fdwCommand |= MCI_OVLY_WINDOW_ENABLE_STRETCH;
// fdwCommand |= MCI_ANIM_WINDOW_HWND;
// OutTraceB("mciSendCommand: STRETCH flags=%x hwnd=%x\n", fdwCommand, pw->hWnd);
//}
break;
case MCI_PUT:
RECT client;

View File

@ -32,6 +32,8 @@ void CTabDebug::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_MARKLOCK, cTarget->m_MarkLock);
DDX_Check(pDX, IDC_MARKWING32, cTarget->m_MarkWinG32);
DDX_Check(pDX, IDC_MARKGDI32, cTarget->m_MarkGDI32);
DDX_Check(pDX, IDC_DUMPDIBSECTION, cTarget->m_DumpDIBSection);
DDX_Check(pDX, IDC_DUMPDEVCONTEXT, cTarget->m_DumpDevContext);
DDX_Check(pDX, IDC_NOBLT, cTarget->m_NoBlt);
DDX_Check(pDX, IDC_FASTBLT, cTarget->m_FastBlt);
DDX_Check(pDX, IDC_GDICOLORCONV, cTarget->m_GDIColorConv);

View File

@ -181,6 +181,8 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
m_MarkLock = FALSE;
m_MarkWinG32 = FALSE;
m_MarkGDI32 = FALSE;
m_DumpDIBSection = FALSE;
m_DumpDevContext = FALSE;
m_NoSysMemPrimary = FALSE;
m_NoSysMemBackBuf = FALSE;
m_NoBlt = FALSE;

View File

@ -135,6 +135,8 @@ public:
BOOL m_MarkLock;
BOOL m_MarkWinG32;
BOOL m_MarkGDI32;
BOOL m_DumpDIBSection;
BOOL m_DumpDevContext;
BOOL m_NoSysMemPrimary;
BOOL m_NoSysMemBackBuf;
BOOL m_NoBlt;

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -458,6 +458,8 @@ void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg)
if(dlg->m_MarkLock) t->flags3 |= MARKLOCK;
if(dlg->m_MarkWinG32) t->flags8 |= MARKWING32;
if(dlg->m_MarkGDI32) t->flags8 |= MARKGDI32;
if(dlg->m_DumpDIBSection) t->flags8 |= DUMPDIBSECTION;
if(dlg->m_DumpDevContext) t->flags8 |= DUMPDEVCONTEXT;
if(dlg->m_NoSysMemPrimary) t->flags6 |= NOSYSMEMPRIMARY;
if(dlg->m_NoSysMemBackBuf) t->flags6 |= NOSYSMEMBACKBUF;
if(dlg->m_NoBlt) t->flags5 |= NOBLT;
@ -780,6 +782,8 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg)
dlg->m_MarkLock = t->flags3 & MARKLOCK ? 1 : 0;
dlg->m_MarkWinG32 = t->flags8 & MARKWING32 ? 1 : 0;
dlg->m_MarkGDI32 = t->flags8 & MARKGDI32 ? 1 : 0;
dlg->m_DumpDIBSection = t->flags8 & DUMPDIBSECTION ? 1 : 0;
dlg->m_DumpDevContext = t->flags8 & DUMPDEVCONTEXT ? 1 : 0;
dlg->m_NoSysMemPrimary = t->flags6 & NOSYSMEMPRIMARY ? 1 : 0;
dlg->m_NoSysMemBackBuf = t->flags6 & NOSYSMEMBACKBUF ? 1 : 0;
dlg->m_NoBlt = t->flags5 & NOBLT ? 1 : 0;

Binary file not shown.