1
0
mirror of https://github.com/DxWnd/DxWnd.reloaded synced 2024-12-30 09:25:35 +01:00
Former-commit-id: 4aa4aecda3c03386a0a020debb1cec6d3f877331
This commit is contained in:
gho tik 2013-01-04 10:30:38 -05:00 committed by Refael ACkermann
parent caa3532608
commit 72f5bb48ce
28 changed files with 4130 additions and 1073 deletions

View File

@ -1,4 +1,5 @@
#include <ddraw.h>
//#include "dxwcore.hpp"
#define DXW_IDLE 0
#define DXW_ACTIVE 1
@ -8,7 +9,7 @@
#define DXWACTIVATESINGLETASK 1 // comment to allow multiple task activations
// first flags DWORD dwFlags:
// first flags DWORD dwFlags1:
#define UNNOTIFY 0x00000001
#define EMULATESURFACE 0x00000002
#define CLIPCURSOR 0x00000004 // Force cursor clipping within window
@ -42,7 +43,7 @@
#define HOOKCHILDWIN 0x40000000 // hook CHILD windows to alter placement coordinates (UNUSED)
#define MESSAGEPROC 0x80000000 // process peek/get messages
// second flags DWORD dwFlags2:
// second flags DWORD dxw.dwFlags2:
#define RECOVERSCREENMODE 0x00000001 // actively set screen mode to initial state after hooking
#define REFRESHONRESIZE 0x00000002 // forces a refresh (blitting from backbuffer to primary) upon win resize
#define BACKBUFATTACH 0x00000004 // sets backbuf wxh dim. equal to primary surface so that ZBUFFER is attachable.....
@ -103,16 +104,6 @@ typedef struct
BOOL isLogging;
} DXWNDSTATUS;
typedef struct
{
// (full)screen width & height
DWORD dwWidth, dwHeight;
DDPIXELFORMAT PixelFormat;
DWORD dwPrimarySurfaceCaps;
DWORD dwBackBufferCount;
} ScreenDef_Type;
extern ScreenDef_Type ActualScr, VirtualScr;
extern DXWNDSTATUS DxWndStatus;
int SetTarget(TARGETMAP *);
@ -132,25 +123,24 @@ LRESULT CALLBACK extWindowProc(HWND, UINT, WPARAM, LPARAM);
// defines below to condition debug message handling
#define OutTraceW if(dwTFlags & OUTWINMESSAGES) OutTrace
#define OutTraceX if(dwTFlags & OUTPROXYTRACE) OutTrace
#define OutTraceD if(dwTFlags & OUTDDRAWTRACE) OutTrace
#define OutTraceC if(dwTFlags & OUTCURSORTRACE) OutTrace
#define OutTraceW if(dxw.dwTFlags & OUTWINMESSAGES) OutTrace
#define OutTraceX if(dxw.dwTFlags & OUTPROXYTRACE) OutTrace
#define OutTraceD if(dxw.dwTFlags & OUTDDRAWTRACE) OutTrace
#define OutTraceC if(dxw.dwTFlags & OUTCURSORTRACE) OutTrace
#define OutTraceP OutTrace
#define OutTraceE OutTrace
#define IsTraceW (dwTFlags & OUTWINMESSAGES)
#define IsTraceX (dwTFlags & OUTPROXYTRACE)
#define IsTraceD (dwTFlags & OUTDDRAWTRACE)
#define IsTraceC (dwTFlags & OUTCURSORTRACE)
#define IsTraceW (dxw.dwTFlags & OUTWINMESSAGES)
#define IsTraceX (dxw.dwTFlags & OUTPROXYTRACE)
#define IsTraceD (dxw.dwTFlags & OUTDDRAWTRACE)
#define IsTraceC (dxw.dwTFlags & OUTCURSORTRACE)
#define IsTraceP (TRUE)
#define IsTraceE (TRUE)
#define IsDebug (dwTFlags & OUTDEBUG)
#define IsAssertEnabled (dwTFlags & ASSERTDIALOG)
#define IsDebug (dxw.dwTFlags & OUTDEBUG)
#define IsAssertEnabled (dxw.dwTFlags & ASSERTDIALOG)
#define STEP OutTrace("STEP at %s:%d\n", __MODULE__, __LINE__)
extern void WhndStackPush(HWND, WNDPROC);
extern WNDPROC WhndGetWindowProc(HWND );
extern DWORD dwFlags, dwFlags2, dwTFlags;
#define debugstep OutTrace("STEP at %d\n", __LINE__)

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:45ea0ab9cba93c39da05d08c0c2a8798c647186d5882dfdc679e1ab2bf3b4e25
size 266240
oid sha256:2556cf08b2c38ff21834f13e3202ea976936eefd2b5b2da3ce11fc1d878f633a
size 259072

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2d61f3984a2545612ddb0ea7cb3dca19bbf5cfe4b12acdd6c61de8b85816692a
size 483328
oid sha256:d0ef26bafd26df050cec17c30948cf719a91fd7eb300bdca5a069410c76f5928
size 482816

View File

@ -1,35 +0,0 @@
[target]
title0=The Grinch
path0=D:\Games\The_Grinch\The Grinch\bin\TheGrinch.exe
module0=
ver0=10
flag0=536870914
flagg0=16
tflag0=0
initx0=0
inity0=0
minx0=0
miny0=0
maxx0=0
maxy0=0
posx0=50
posy0=50
sizx0=800
sizy0=600
title1=7th Legion
path1=D:\Games\7th Legion\legion.exe
module1=
ver1=0
flag1=16418
flagg1=2128
tflag1=0
initx1=0
inity1=0
minx1=0
miny1=0
maxx1=0
maxy1=0
posx1=50
posy1=50
sizx1=800
sizy1=600

3197
debug/dxwnd.ini Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@
#include <ddraw.h>
#include <stdio.h>
#include "dxwnd.h"
#include "dxwcore.hpp"
#include "hddraw.h"
typedef HRESULT (WINAPI *Lock_Type)(LPDIRECTDRAWSURFACE, LPRECT, LPDIRECTDRAWSURFACE, DWORD, HANDLE);
@ -13,8 +14,6 @@ extern Unlock4_Type pUnlockMethod(LPDIRECTDRAWSURFACE);
extern DWORD PaletteEntries[256];
extern DWORD *Palette16BPP;
extern DWORD dwDDVersion;
extern DWORD dwFlags;
extern char *ExplainDDError(DWORD);
extern int Set_dwSize_From_Surface(LPDIRECTDRAWSURFACE);
@ -156,7 +155,7 @@ static HRESULT WINAPI EmuBlt_16_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdes
if (!Palette16BPP) { // first time through .....
unsigned int pi;
Palette16BPP = (DWORD *)malloc(0x10000 * sizeof(DWORD));
if (dwFlags & USERGB565){
if (dxw.dwFlags1 & USERGB565){
for (pi=0; pi<0x10000; pi++) {
Palette16BPP[pi]=(pi & 0x1F)<<3 | (pi & 0x7E0)<<5 | (pi & 0xF800)<<8; // RGB565
}
@ -285,7 +284,7 @@ static HRESULT WINAPI EmuBlt_32_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdes
memset(&ddsd_dst,0,sizeof(DDSURFACEDESC2));
ddsd_dst.dwSize = Set_dwSize_From_Surface(lpddsdst);
ddsd_dst.dwFlags = DDSD_LPSURFACE | DDSD_PITCH;
ddsd_dst.dxw.dwFlags1 = DDSD_LPSURFACE | DDSD_PITCH;
if(res=(*pLock)(lpddsdst, 0, (LPDIRECTDRAWSURFACE)&ddsd_dst, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY|DDLOCK_WAIT, 0)){
OutTraceE("EmuBlt32_32: Lock ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
return res;
@ -293,7 +292,7 @@ static HRESULT WINAPI EmuBlt_32_to_32(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdes
memset(&ddsd_src,0,sizeof(DDSURFACEDESC2));
ddsd_src.dwSize = Set_dwSize_From_Surface(lpddssrc);
ddsd_src.dwFlags = DDSD_LPSURFACE | DDSD_PITCH;
ddsd_src.dxw.dwFlags1 = DDSD_LPSURFACE | DDSD_PITCH;
if (lpsurface) { // already locked, just get info ....
if(res=lpddssrc->GetSurfaceDesc((LPDDSURFACEDESC)&ddsd_src)) {
OutTraceE("EmuBlt32_32: GetSurfaceDesc ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
@ -846,15 +845,15 @@ static HRESULT WINAPI RevBlt_Null(LPDIRECTDRAWSURFACE lpddsdst, LPRECT lpdestrec
void SetBltTransformations()
{
OutTraceD("SetBltTransformations: color transformation %d->%d\n",
VirtualScr.PixelFormat.dwRGBBitCount, ActualScr.PixelFormat.dwRGBBitCount);
dxw.VirtualPixelFormat.dwRGBBitCount, dxw.ActualPixelFormat.dwRGBBitCount);
/* default (bad) setting */
pRevBlt=RevBlt_Null;
pEmuBlt=EmuBlt_Null;
switch (ActualScr.PixelFormat.dwRGBBitCount){
switch (dxw.ActualPixelFormat.dwRGBBitCount){
case 32:
switch(VirtualScr.PixelFormat.dwRGBBitCount){
switch(dxw.VirtualPixelFormat.dwRGBBitCount){
case 8:
pRevBlt=RevBlt_32_to_8;
pEmuBlt=EmuBlt_8_to_32;
@ -875,12 +874,12 @@ void SetBltTransformations()
OutTraceD("set color transformation 32->32\n");
break;
default:
OutTraceD("unsupported color transformation %d->32\n", VirtualScr.PixelFormat.dwRGBBitCount);
OutTraceD("unsupported color transformation %d->32\n", dxw.VirtualPixelFormat.dwRGBBitCount);
break;
}
break;
case 16:
switch(VirtualScr.PixelFormat.dwRGBBitCount){
switch(dxw.VirtualPixelFormat.dwRGBBitCount){
case 8:
pRevBlt=RevBlt_16_to_8;
pEmuBlt=EmuBlt_8_to_16;
@ -900,14 +899,14 @@ void SetBltTransformations()
pEmuBlt=EmuBlt_32_to_16;
break;
default:
OutTraceD("unsupported color transformation %d->16\n", VirtualScr.PixelFormat.dwRGBBitCount);
OutTraceD("unsupported color transformation %d->16\n", dxw.VirtualPixelFormat.dwRGBBitCount);
break;
}
break;
default:
OutTraceD("unsupported color transformation %d->%d\n",
VirtualScr.PixelFormat.dwRGBBitCount,
ActualScr.PixelFormat.dwRGBBitCount);
dxw.VirtualPixelFormat.dwRGBBitCount,
dxw.ActualPixelFormat.dwRGBBitCount);
break;
}
return;

View File

@ -6,16 +6,17 @@
#include <stdio.h>
#include <stdarg.h>
#include "dxwnd.h"
#include "dxwcore.hpp"
#include "dxhook.h"
#include "glhook.h"
#include "syslibs.h"
#include "dxhelper.h"
dxwCore dxw;
extern BOOL MakeWindowTransparent(HWND, unsigned char);
extern void dx_ScreenRefresh();
extern void InitScreenParameters();
//extern char *ExplainStyle(DWORD);
int WINAPI extGetDeviceCaps(HDC, int);
BOOL WINAPI extGetCursorPos(LPPOINT);
@ -108,16 +109,6 @@ extern BOOL WINAPI extSetDeviceGammaRamp(HDC, LPVOID);
extern BOOL WINAPI extGetDeviceGammaRamp(HDC, LPVOID);
extern LRESULT WINAPI extSendMessage(HWND, UINT, WPARAM, LPARAM);
DWORD dwFlags;
DWORD dwFlags2;
DWORD dwTFlags;
DWORD dwVersion=0;
BOOL bActive = 1;
BOOL Filler = 99;
HWND hWnd = 0;
HWND hParentWnd = 0;
HWND hChildWnd = 0;
extern HANDLE hTraceMutex;
char *gsModules;
@ -234,9 +225,9 @@ static void OutTraceHeader(FILE *fp)
fprintf(fp, "*** DxWnd %s log BEGIN: %02d-%02d-%04d %02d:%02d:%02d ***\n",
Version, Time.wDay, Time.wMonth, Time.wYear, Time.wHour, Time.wMinute, Time.wSecond);
fprintf(fp, "*** Flags= ");
for(i=0, dword=dwFlags; i<32; i++, dword>>=1) if(dword & 0x1) fprintf(fp, "%s ", FlagNames[i]);
for(i=0, dword=dwFlags2; i<32; i++, dword>>=1) if(dword & 0x1) fprintf(fp, "%s ", Flag2Names[i]);
for(i=0, dword=dwTFlags; i<32; i++, dword>>=1) if(dword & 0x1) fprintf(fp, "%s ", TFlagNames[i]);
for(i=0, dword=dxw.dwFlags1; i<32; i++, dword>>=1) if(dword & 0x1) fprintf(fp, "%s ", FlagNames[i]);
for(i=0, dword=dxw.dwFlags2; i<32; i++, dword>>=1) if(dword & 0x1) fprintf(fp, "%s ", Flag2Names[i]);
for(i=0, dword=dxw.dwTFlags; i<32; i++, dword>>=1) if(dword & 0x1) fprintf(fp, "%s ", TFlagNames[i]);
fprintf(fp, "***\n");
}
@ -247,7 +238,7 @@ void OutTrace(const char *format, ...)
static FILE *fp=NULL; // GHO: thread safe???
// check global log flag
if(!(dwTFlags & OUTTRACE)) return;
if(!(dxw.dwTFlags & OUTTRACE)) return;
WaitForSingleObject(hTraceMutex, INFINITE);
if (fp == NULL){
@ -260,7 +251,7 @@ void OutTrace(const char *format, ...)
fp = fopen(path, "a+");
}
if (fp==NULL){ // last chance: do not log...
dwTFlags &= ~OUTTRACE; // turn flag OFF
dxw.dwTFlags &= ~OUTTRACE; // turn flag OFF
return;
}
else
@ -277,15 +268,15 @@ void OutTrace(const char *format, ...)
static void dx_ToggleLogging()
{
// toggle LOGGING
if(dwTFlags & OUTTRACE){
if(dxw.dwTFlags & OUTTRACE){
OutTraceD("Toggle logging OFF\n");
dwTFlags &= ~OUTTRACE;
dxw.dwTFlags &= ~OUTTRACE;
}
else {
dwTFlags |= OUTTRACE;
dxw.dwTFlags |= OUTTRACE;
OutTraceD("Toggle logging ON\n");
}
DxWndStatus.isLogging=(dwTFlags & OUTTRACE);
DxWndStatus.isLogging=(dxw.dwTFlags & OUTTRACE);
SetHookStatus(&DxWndStatus);
}
@ -555,109 +546,6 @@ void SetHook(void *target, void *hookproc, void **hookedproc, char *hookname)
*hookedproc = tmp;
}
// v2.1.93: FixCursorPos completely revised to introduce a clipping tolerance in
// clipping regions as well as in normal operations
#define CLIP_TOLERANCE 4
static POINT FixCursorPos(HWND hwnd, POINT prev)
{
POINT curr;
RECT rect;
extern LPRECT lpClipRegion;
curr=prev;
// scale mouse coordinates
// remember: rect from GetClientRect always start at 0,0!
if(dwFlags & MODIFYMOUSE){
if (!(*pGetClientRect)(hwnd, &rect)) {
OutTraceD("GetClientRect ERROR %d at %d\n", GetLastError(),__LINE__);
curr.x = curr.y = 0;
}
if (rect.right) curr.x = (curr.x * VirtualScr.dwWidth) / rect.right;
if (rect.bottom) curr.y = (curr.y * VirtualScr.dwHeight) / rect.bottom;
}
if((dwFlags & ENABLECLIPPING) && lpClipRegion){
// v2.1.93:
// in clipping mode, avoid the cursor position to lay outside the valid rect
// note 1: the rect follow the convention and valid coord lay between left to righ-1,
// top to bottom-1
// note 2: CLIP_TOLERANCE is meant to handle possible integer divide tolerance errors
// that may prevent reaching the clip rect borders. The smaller you shrink the window,
// the bigger tolerance is required
if (curr.x < lpClipRegion->left+CLIP_TOLERANCE) curr.x=lpClipRegion->left;
if (curr.y < lpClipRegion->top+CLIP_TOLERANCE) curr.y=lpClipRegion->top;
if (curr.x >= lpClipRegion->right-CLIP_TOLERANCE) curr.x=lpClipRegion->right-1;
if (curr.y >= lpClipRegion->bottom-CLIP_TOLERANCE) curr.y=lpClipRegion->bottom-1;
}
else{
if (curr.x < CLIP_TOLERANCE) curr.x=0;
if (curr.y < CLIP_TOLERANCE) curr.y=0;
if (curr.x >= (LONG)VirtualScr.dwWidth-CLIP_TOLERANCE) curr.x=VirtualScr.dwWidth-1;
if (curr.y >= (LONG)VirtualScr.dwHeight-CLIP_TOLERANCE) curr.y=VirtualScr.dwHeight-1;
}
return curr;
}
static void FixNCHITCursorPos(LPPOINT lppoint)
{
RECT rect;
POINT point;
point=*lppoint;
(*pGetClientRect)(hWnd, &rect);
(*pScreenToClient)(hWnd, &point);
if (point.x < 0) return;
if (point.y < 0) return;
if (point.x > rect.right) return;
if (point.y > rect.bottom) return;
*lppoint=point;
lppoint->x = (lppoint->x * VirtualScr.dwWidth) / rect.right;
lppoint->y = (lppoint->y * VirtualScr.dwHeight) / rect.bottom;
if(lppoint->x < CLIP_TOLERANCE) lppoint->x=0;
if(lppoint->y < CLIP_TOLERANCE) lppoint->y=0;
if(lppoint->x > (LONG)VirtualScr.dwWidth-CLIP_TOLERANCE) lppoint->x=VirtualScr.dwWidth-1;
if(lppoint->y > (LONG)VirtualScr.dwHeight-CLIP_TOLERANCE) lppoint->y=VirtualScr.dwHeight-1;
}
void DxWndSetClipCursor()
{
RECT Rect;
POINT UpLeftCorner;
OutTraceD("DxWndSetClipCursor:\n");
if (hWnd==NULL) {
OutTraceD("DxWndSetClipCursor: ASSERT hWnd==NULL\n");
return;
}
(*pGetClientRect)(hWnd, &Rect);
UpLeftCorner.x=UpLeftCorner.y=0;
(*pClientToScreen)(hWnd, &UpLeftCorner);
Rect.left+=UpLeftCorner.x;
Rect.right+=UpLeftCorner.x;
Rect.top+=UpLeftCorner.y;
Rect.bottom+=UpLeftCorner.y;
(*pClipCursor)(NULL);
if(!(*pClipCursor)(&Rect)){
OutTraceE("ClipCursor: ERROR err=%d at %d\n", GetLastError(), __LINE__);
}
OutTraceD("DxWndSetClipCursor: rect=(%d,%d)-(%d,%d)\n",
Rect.left, Rect.top, Rect.right, Rect.bottom);
}
void DxWndEraseClipCursor()
{
OutTraceD("DxWndEraseClipCursor:\n");
(*pClipCursor)(NULL);
}
// v.2.1.80: unified positioning logic into CalculateWindowPos routine
// now taking in account for window menus (see "Alien Cabal")
@ -718,11 +606,10 @@ void AdjustWindowFrame(HWND hwnd, DWORD width, DWORD height)
OutTraceD("AdjustWindowFrame hwnd=%x, wxh=%dx%d\n", hwnd, width, height);
if (width) VirtualScr.dwWidth = width;
if (height) VirtualScr.dwHeight = height;
dxw.SetScreenSize(width, height);
if (hwnd==NULL) return;
(*pSetWindowLong)(hwnd, GWL_STYLE, (dwFlags2 & MODALSTYLE) ? 0 : WS_OVERLAPPEDWINDOW);
(*pSetWindowLong)(hwnd, GWL_STYLE, (dxw.dwFlags2 & MODALSTYLE) ? 0 : WS_OVERLAPPEDWINDOW);
(*pSetWindowLong)(hwnd, GWL_EXSTYLE, 0);
(*pShowWindow)(hwnd, SW_SHOWNORMAL);
OutTraceD("AdjustWindowFrame hwnd=%x, set style=WS_OVERLAPPEDWINDOW extstyle=0\n", hwnd);
@ -749,10 +636,10 @@ void AdjustWindowFrame(HWND hwnd, DWORD width, DWORD height)
// fixing cursor view and clipping region
if (dwFlags & HIDEHWCURSOR) while (ShowCursor(0) >= 0);
if (dwFlags & CLIPCURSOR) {
if (dxw.dwFlags1 & HIDEHWCURSOR) while (ShowCursor(0) >= 0);
if (dxw.dwFlags1 & CLIPCURSOR) {
OutTraceD("AdjustWindowFrame: setting clip region\n");
DxWndSetClipCursor();
dxw.SetClipCursor();
}
(*pInvalidateRect)(hwnd, NULL, TRUE);
@ -792,36 +679,9 @@ LRESULT CALLBACK extChildWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPAR
static int i=0;
static WINDOWPOS *wp;
WNDPROC pWindowProc;
extern BOOL isFullScreen;
OutTraceW("DEBUG: ChildWinMsg [0x%x]%s(%x,%x)\n", message, ExplainWinMessage(message), wparam, lparam);
switch(message){
#if 0
// deleted after interception of MoveWindow API with WS_CHILD special case.
// don't make the same compensation twice!!!
case WM_WINDOWPOSCHANGING:
{
// WINDOWPOS coordinates update for Age of Empires I & II edit controls.
WINDOWPOS *wp;
RECT rect;
wp = (LPWINDOWPOS)lparam;
OutTraceD("ChildWindowProc: WM_WINDOWPOSCHANGING pos=(%d,%d) size=(%d,%d)\n",
wp->x, wp->y, wp->cx, wp->cy);
if(isFullScreen){
// scale coordinates
if (!(*pGetClientRect)(hWnd, &rect)) { // note! hWnd, the main form. Fixed again v70
OutTraceE("GetClientRect ERROR %d at %d\n", GetLastError(),__LINE__);
break;
}
wp->x = (wp->x * rect.right) / VirtualScr.dwWidth;
wp->cx = (wp->cx * rect.right) / VirtualScr.dwWidth;
wp->y = (wp->y * rect.bottom) / VirtualScr.dwHeight;
wp->cy = (wp->cy * rect.bottom) / VirtualScr.dwHeight;
OutTraceD("ChildWindowProc: fixed pos=(%d,%d) size=(%d,%d)\n", wp->x, wp->y, wp->cx, wp->cy);
}
}
break;
#endif
// Cybermercs: it seems that all game menus are conveniently handled by the WindowProc routine,
// while the action screen get messages processed by the ChildWindowProc, that needs some different
@ -839,13 +699,13 @@ LRESULT CALLBACK extChildWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPAR
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_MBUTTONDBLCLK:
if(dwFlags & MODIFYMOUSE){ // mouse processing
if(dxw.dwFlags1 & MODIFYMOUSE){ // mouse processing
POINT prev, curr;
// scale mouse coordinates
prev.x = LOWORD(lparam);
prev.y = HIWORD(lparam);
//OutTraceC("ChildWindowProc: hwnd=%x pos XY prev=(%d,%d)\n", hwnd, prev.x, prev.y);
curr=FixCursorPos(hWnd, prev); // Warn! the correction must refer to the main window hWnd, not the current hwnd one !!!
curr=dxw.FixCursorPos(prev); // Warn! the correction must refer to the main window hWnd, not the current hwnd one !!!
lparam = MAKELPARAM(curr.x, curr.y);
OutTraceC("ChildWindowProc: hwnd=%x pos XY=(%d,%d)->(%d,%d)\n", hwnd, prev.x, prev.y, curr.x, curr.y);
}
@ -862,10 +722,10 @@ LRESULT CALLBACK extChildWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPAR
static void dx_TogglePositionLock(HWND hwnd)
{
// toggle position locking
if(dwFlags & LOCKWINPOS){
if(dxw.dwFlags1 & LOCKWINPOS){
// unlock
OutTraceD("Toggle position lock OFF\n");
dwFlags &= ~LOCKWINPOS;
dxw.dwFlags1 &= ~LOCKWINPOS;
}
else {
// lock and update window position!!!
@ -874,7 +734,7 @@ static void dx_TogglePositionLock(HWND hwnd)
POINT p={0,0};
(*pGetClientRect)(hwnd,&rect);
(*pClientToScreen)(hwnd,&p);
dwFlags |= LOCKWINPOS;
dxw.dwFlags1 |= LOCKWINPOS;
OutTraceD("Toggle position lock ON\n");
iPosX=(short)p.x;
iPosY=(short)p.y;
@ -885,12 +745,12 @@ static void dx_TogglePositionLock(HWND hwnd)
void dx_ToggleDC()
{
if(dwFlags & HANDLEDC){
dwFlags &= ~HANDLEDC;
if(dxw.dwFlags1 & HANDLEDC){
dxw.dwFlags1 &= ~HANDLEDC;
OutTrace("ToggleDC: HANDLEDC mode OFF\n");
}
else {
dwFlags |= HANDLEDC;
dxw.dwFlags1 |= HANDLEDC;
OutTrace("ToggleDC: HANDLEDC mode ON\n");
}
}
@ -913,7 +773,7 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
OutTraceW("WindowProc: WinMsg=[0x%x]%s(%x,%x)\n", message, ExplainWinMessage(message), wparam, lparam);
switch(message){
case WM_NCHITTEST:
if((dwFlags2 & FIXNCHITTEST) && (dwFlags & MODIFYMOUSE)){ // mouse processing
if((dxw.dwFlags2 & FIXNCHITTEST) && (dxw.dwFlags1 & MODIFYMOUSE)){ // mouse processing
POINT cursor;
LRESULT ret;
ret=(*pDefWindowProc)(hwnd, message, wparam, lparam);
@ -921,7 +781,7 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
if (ret==HTCLIENT) {
cursor.x=LOWORD(lparam);
cursor.y=HIWORD(lparam);
FixNCHITCursorPos(&cursor);
dxw.FixNCHITCursorPos(&cursor);
lparam = MAKELPARAM(cursor.x, cursor.y);
}
else
@ -933,8 +793,7 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
return 1; // 1 == OK, erased
break;
case WM_DISPLAYCHANGE:
extern int isFullScreen;
if ((dwFlags & LOCKWINPOS) && isFullScreen){
if ((dxw.dwFlags1 & LOCKWINPOS) && dxw.IsFullScreen()){
OutTraceD("WindowProc: prevent WM_DISPLAYCHANGE depth=%d size=(%d,%d)\n",
wparam, HIWORD(lparam), LOWORD(lparam));
return 0;
@ -948,20 +807,20 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
break;
case WM_ENTERSIZEMOVE:
while(ShowCursor(1) < 0);
if(dwFlags & CLIPCURSOR) DxWndEraseClipCursor();
if(dwFlags & ENABLECLIPPING) (*pClipCursor)(NULL);
if(dxw.dwFlags1 & CLIPCURSOR) dxw.EraseClipCursor();
if(dxw.dwFlags1 & ENABLECLIPPING) (*pClipCursor)(NULL);
break;
case WM_EXITSIZEMOVE:
if (dwFlags & HIDEHWCURSOR) while(ShowCursor(0) >= 0);
if(dwFlags & ENABLECLIPPING) extClipCursor(lpClipRegion);
if(dwFlags2 & REFRESHONRESIZE) dx_ScreenRefresh();
if (dxw.dwFlags1 & HIDEHWCURSOR) while(ShowCursor(0) >= 0);
if(dxw.dwFlags1 & ENABLECLIPPING) extClipCursor(lpClipRegion);
if(dxw.dwFlags2 & REFRESHONRESIZE) dxw.ScreenRefresh();
break;
case WM_ACTIVATE:
bActive = (LOWORD(wparam) == WA_ACTIVE || LOWORD(wparam) == WA_CLICKACTIVE) ? 1 : 0;
dxw.bActive = (LOWORD(wparam) == WA_ACTIVE || LOWORD(wparam) == WA_CLICKACTIVE) ? 1 : 0;
case WM_NCACTIVATE:
if(message == WM_NCACTIVATE) bActive = wparam;
if(message == WM_NCACTIVATE) dxw.bActive = wparam;
(*pSetWindowPos)(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
if(dwFlags & UNNOTIFY){
if(dxw.dwFlags1 & UNNOTIFY){
DefWindowProc(hwnd, message, wparam, lparam);
return false;
}
@ -976,7 +835,7 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
case WM_MOUSEMOVE:
prev.x = LOWORD(lparam);
prev.y = HIWORD(lparam);
if (dwFlags & HIDEHWCURSOR) {
if (dxw.dwFlags1 & HIDEHWCURSOR) {
(*pGetClientRect)(hwnd, &rect);
if(prev.x >= 0 && prev.x < rect.right && prev.y >= 0 && prev.y < rect.bottom)
while(ShowCursor(0) >= 0);
@ -986,9 +845,9 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
else {
while(ShowCursor(1) < 0);
}
if(dwFlags & MODIFYMOUSE){ // mouse processing
if(dxw.dwFlags1 & MODIFYMOUSE){ // mouse processing
// scale mouse coordinates
curr=FixCursorPos(hwnd, prev);
curr=dxw.FixCursorPos(hwnd, prev);
lparam = MAKELPARAM(curr.x, curr.y);
OutTraceC("WindowProc: hwnd=%x pos XY=(%d,%d)->(%d,%d)\n", hwnd, prev.x, prev.y, curr.x, curr.y);
}
@ -1004,26 +863,26 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_MBUTTONDBLCLK:
if((dwFlags & CLIPCURSOR) && ClipCursorToggleState) DxWndSetClipCursor();
if(dwFlags & MODIFYMOUSE){ // mouse processing
if((dxw.dwFlags1 & CLIPCURSOR) && ClipCursorToggleState) dxw.SetClipCursor();
if(dxw.dwFlags1 & MODIFYMOUSE){ // mouse processing
// scale mouse coordinates
prev.x = LOWORD(lparam);
prev.y = HIWORD(lparam);
curr=FixCursorPos(hwnd, prev);
curr=dxw.FixCursorPos(hwnd, prev);
lparam = MAKELPARAM(curr.x, curr.y);
OutTraceC("WindowProc: hwnd=%x pos XY=(%d,%d)->(%d,%d)\n", hwnd, prev.x, prev.y, curr.x, curr.y);
}
break;
case WM_SETFOCUS:
//if (dwFlags & CLIPCURSOR) if (ClipCursorToggleState) DxWndSetClipCursor();
if (dwFlags & ENABLECLIPPING) extClipCursor(lpClipRegion);
//if (dxw.dwFlags1 & CLIPCURSOR) if (ClipCursorToggleState) dxw.SetClipCursor();
if (dxw.dwFlags1 & ENABLECLIPPING) extClipCursor(lpClipRegion);
break;
case WM_KILLFOCUS:
if (dwFlags & CLIPCURSOR) DxWndEraseClipCursor();
if (dwFlags & ENABLECLIPPING) (*pClipCursor)(NULL);
if (dxw.dwFlags1 & CLIPCURSOR) dxw.EraseClipCursor();
if (dxw.dwFlags1 & ENABLECLIPPING) (*pClipCursor)(NULL);
break;
case WM_CLOSE:
//if (dwFlags & HANDLECOSEICON) {
//if (dxw.dwFlags1 & HANDLECOSEICON) {
{
OutTraceD("WindowProc: WM_CLOSE - terminating process\n");
TerminateProcess(GetCurrentProcess(),0);
@ -1033,13 +892,13 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
OutTraceW("event WM_SYSKEYDOWN wparam=%x lparam=%x\n", wparam, lparam);
switch (wparam){
case VK_F12:
if(dwFlags & CLIPCURSOR){
if(dxw.dwFlags1 & CLIPCURSOR){
OutTraceD("WindowProc: WM_SYSKEYDOWN key=%x ToggleState=%x\n",wparam,ClipCursorToggleState);
ClipCursorToggleState = !ClipCursorToggleState;
ClipCursorToggleState ? DxWndSetClipCursor() : DxWndEraseClipCursor();
ClipCursorToggleState ? dxw.SetClipCursor() : dxw.EraseClipCursor();
}
case VK_F11:
dx_ScreenRefresh();
dxw.ScreenRefresh();
break;
case VK_F10:
dx_ToggleLogging();
@ -1051,7 +910,7 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
dx_ToggleDC();
break;
case VK_F4:
if (dwFlags & HANDLEALTF4) {
if (dxw.dwFlags1 & HANDLEALTF4) {
OutTraceD("WindowProc: WM_SYSKEYDOWN(ALT-F4) - terminating process\n");
TerminateProcess(GetCurrentProcess(),0);
}
@ -1062,9 +921,9 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
default:
break;
}
if (dwFlags & AUTOREFRESH)
if (dxw.dwFlags1 & AUTOREFRESH)
{
dx_ScreenRefresh();
dxw.ScreenRefresh();
}
pWindowProc=WhndGetWindowProc(hwnd);
@ -1074,7 +933,7 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
// save last NCHITTEST cursor position for use with KEEPASPECTRATIO scaling
if(message==WM_NCHITTEST) LastCursorPos=ret;
// v2.1.89: if FORCEWINRESIZE add standard processing for the missing WM_NC* messages
if(dwFlags2 & FORCEWINRESIZE){
if(dxw.dwFlags2 & FORCEWINRESIZE){
switch(message){
//case WM_NCHITTEST:
//case WM_NCPAINT:
@ -1189,7 +1048,7 @@ void HookSysLibs(char *module)
if(tmp) pBeginPaint = (BeginPaint_Type)tmp;
tmp = HookAPI("user32.dll", EndPaint, "EndPaint", extEndPaint);
if(tmp) pEndPaint = (EndPaint_Type)tmp;
if(dwFlags & MAPGDITOPRIMARY){
if(dxw.dwFlags1 & MAPGDITOPRIMARY){
tmp = HookAPI("GDI32.dll", CreateCompatibleDC, "CreateCompatibleDC", extDDCreateCompatibleDC);
if(tmp) pCreateCompatibleDC = (CreateCompatibleDC_Type)tmp;
tmp = HookAPI("GDI32.dll", DeleteDC, "DeleteDC", extDDDeleteDC);
@ -1234,7 +1093,7 @@ void HookSysLibs(char *module)
//if(tmp) pInvalidateRgn = (InvalidateRgn_Type)tmp;
}
if (dwFlags & CLIENTREMAPPING){
if (dxw.dwFlags1 & CLIENTREMAPPING){
tmp = HookAPI("user32.dll", ScreenToClient, "ScreenToClient", extScreenToClient);
if(tmp) pScreenToClient = (ScreenToClient_Type)tmp;
tmp = HookAPI("user32.dll", ClientToScreen, "ClientToScreen", extClientToScreen);
@ -1263,7 +1122,7 @@ void HookSysLibs(char *module)
if(tmp) pClipCursor = (ClipCursor_Type)tmp;
tmp = HookAPI("user32.dll", FillRect, "FillRect", extFillRect);
if(tmp) pFillRect = (FillRect_Type)tmp;
if (dwFlags & MESSAGEPROC) {
if (dxw.dwFlags1 & MESSAGEPROC) {
tmp = HookAPI("user32.dll", PeekMessageA, "PeekMessageA", extPeekMessage); // added for GPL
if(tmp) pPeekMessage = (PeekMessage_Type)tmp;
tmp = HookAPI("user32.dll", GetMessageA, "GetMessageA", extGetMessage); // added for GPL
@ -1285,7 +1144,7 @@ void HookSysLibs(char *module)
if(tmp) pRegisterClassExA = (RegisterClassExA_Type)tmp;
tmp = HookAPI("GDI32.dll", Rectangle, "Rectangle", extRectangle);
if(tmp) pRectangle = (Rectangle_Type)tmp;
if (dwFlags & (PREVENTMAXIMIZE|FIXWINFRAME|LOCKWINPOS|LOCKWINSTYLE)){
if (dxw.dwFlags1 & (PREVENTMAXIMIZE|FIXWINFRAME|LOCKWINPOS|LOCKWINSTYLE)){
tmp = HookAPI("user32.dll", ShowWindow, "ShowWindow", extShowWindow);
if(tmp) pShowWindow = (ShowWindow_Type)tmp;
tmp = HookAPI("user32.dll", SetWindowLongA, "SetWindowLongA", extSetWindowLong);
@ -1302,7 +1161,7 @@ void HookSysLibs(char *module)
//tmp = HookAPI("user32.dll", SetWindowPlacement, "SetWindowPlacement", extSetWindowPlacement);
//if(tmp) pSetWindowPlacement = (SetWindowPlacement_Type)tmp;
}
if ((dwFlags & EMULATESURFACE) && (dwFlags & HANDLEDC)){
if ((dxw.dwFlags1 & EMULATESURFACE) && (dxw.dwFlags1 & HANDLEDC)){
tmp = HookAPI("GDI32.dll", SetTextColor, "SetTextColor", extSetTextColor);
if(tmp) pSetTextColor = (SetTextColor_Type)tmp;
tmp = HookAPI("GDI32.dll", SetBkColor, "SetBkColor", extSetBkColor);
@ -1321,7 +1180,7 @@ void HookSysLibs(char *module)
tmp = HookAPI("user32.dll", GetDesktopWindow, "GetDesktopWindow", extGetDesktopWindow);
if(tmp) pGetDesktopWindow = (GetDesktopWindow_Type)tmp;
if(dwFlags & MODIFYMOUSE){
if(dxw.dwFlags1 & MODIFYMOUSE){
tmp = HookAPI("user32.dll", GetCursorPos, "GetCursorPos", extGetCursorPos);
if(tmp) pGetCursorPos = (GetCursorPos_Type)tmp;
//tmp = HookAPI("user32.dll", GetPhysicalCursorPos, "", extGetCursorPos);
@ -1331,7 +1190,7 @@ void HookSysLibs(char *module)
tmp = HookAPI("user32.dll", SendMessageA, "SendMessageA", extSendMessage);
if(tmp) pSendMessage = (SendMessage_Type)tmp;
}
if((dwFlags & (MODIFYMOUSE|SLOWDOWN|KEEPCURSORWITHIN)) || (dwFlags2 & KEEPCURSORFIXED)){
if((dxw.dwFlags1 & (MODIFYMOUSE|SLOWDOWN|KEEPCURSORWITHIN)) || (dxw.dwFlags2 & KEEPCURSORFIXED)){
tmp = HookAPI("user32.dll", SetCursorPos, "SetCursorPos", extSetCursorPos);
if(tmp) pSetCursorPos = (SetCursorPos_Type)tmp;
}
@ -1370,7 +1229,7 @@ void HookSysLibs(char *module)
if(tmp) pMoveWindow = (MoveWindow_Type)tmp;
}
if(dwFlags2 & DISABLEGAMMARAMP){
if(dxw.dwFlags2 & DISABLEGAMMARAMP){
tmp = HookAPI("GDI32.dll", SetDeviceGammaRamp, "SetDeviceGammaRamp", extSetDeviceGammaRamp);
if(tmp) pSetDeviceGammaRamp = (SetDeviceGammaRamp_Type)tmp;
tmp = HookAPI("GDI32.dll", GetDeviceGammaRamp, "GetDeviceGammaRamp", extGetDeviceGammaRamp);
@ -1466,7 +1325,7 @@ void HookExceptionHandler(void)
void HookModule(char *module, int dxversion)
{
HookSysLibs(module);
if(dwFlags & HOOKDI) HookDirectInput(dxversion);
if(dxw.dwFlags1 & HOOKDI) HookDirectInput(dxversion);
HookDirectDraw(dxversion);
HookDirect3D(dxversion);
HookOle32(dxversion); // unfinished business
@ -1483,36 +1342,36 @@ int HookInit(TARGETMAP *target, HWND hwnd)
"DirectX7", "DirectX8", "DirectX9", "None\\OpenGL", "", "", ""
};
dwFlags = target->flags;
dwFlags2 = target->flags2;
dwTFlags = target->tflags;
dxw.dwFlags1 = target->flags;
dxw.dwFlags2 = target->flags2;
dxw.dwTFlags = target->tflags;
gsModules = target->module;
// v2.1.75: is it correct to set hWnd here?
hWnd=hwnd;
hParentWnd=GetParent(hwnd);
hChildWnd=hwnd;
dxw.SethWnd(hwnd);
dxw.hParentWnd=GetParent(hwnd);
dxw.hChildWnd=hwnd;
// bounds control
if(target->dxversion<0) target->dxversion=0;
if(target->dxversion>10) target->dxversion=10;
OutTraceD("HookInit: path=\"%s\" module=\"%s\" dxversion=%s hWnd=%x hParentWnd=%x\n",
target->path, target->module, dxversions[target->dxversion], hwnd, hParentWnd);
OutTraceD("HookInit: path=\"%s\" module=\"%s\" dxversion=%s hWnd=%x dxw.hParentWnd=%x\n",
target->path, target->module, dxversions[target->dxversion], hwnd, dxw.hParentWnd);
if (IsDebug){
DWORD dwStyle, dwExStyle;
dwStyle=GetWindowLong(hWnd, GWL_STYLE);
dwExStyle=GetWindowLong(hWnd, GWL_EXSTYLE);
dwStyle=GetWindowLong(dxw.GethWnd(), GWL_STYLE);
dwExStyle=GetWindowLong(dxw.GethWnd(), GWL_EXSTYLE);
OutTrace("HookInit: hWnd style=%x(%s) exstyle=%x(%s)\n", dwStyle, ExplainStyle(dwStyle), dwExStyle, ExplainExStyle(dwExStyle));
dwStyle=GetWindowLong(hParentWnd, GWL_STYLE);
dwExStyle=GetWindowLong(hParentWnd, GWL_EXSTYLE);
OutTrace("HookInit: hParentWnd style=%x(%s) exstyle=%x(%s)\n", dwStyle, ExplainStyle(dwStyle), dwExStyle, ExplainExStyle(dwExStyle));
dwStyle=GetWindowLong(dxw.hParentWnd, GWL_STYLE);
dwExStyle=GetWindowLong(dxw.hParentWnd, GWL_EXSTYLE);
OutTrace("HookInit: dxw.hParentWnd style=%x(%s) exstyle=%x(%s)\n", dwStyle, ExplainStyle(dwStyle), dwExStyle, ExplainExStyle(dwExStyle));
}
if(dwFlags & HANDLEEXCEPTIONS) HookExceptionHandler();
if(dxw.dwFlags1 & HANDLEEXCEPTIONS) HookExceptionHandler();
if (dwTFlags & OUTIMPORTTABLE) DumpImportTable(NULL);
if (dxw.dwTFlags & OUTIMPORTTABLE) DumpImportTable(NULL);
if (dwTFlags & DXPROXED){
if (dxw.dwTFlags & DXPROXED){
HookDDProxy(target->dxversion);
return 0;
}
@ -1532,16 +1391,16 @@ int HookInit(TARGETMAP *target, HWND hwnd)
sModule=strtok(NULL," ");
}
if(dwFlags2 & RECOVERSCREENMODE) RecoverScreenMode();
if(dxw.dwFlags2 & RECOVERSCREENMODE) RecoverScreenMode();
InitScreenParameters();
if (IsDebug) OutTraceD("MoveWindow: target pos=(%d,%d) size=(%d,%d)\n", iPosX, iPosY, iSizX, iSizY);
if(dwFlags & FIXPARENTWIN){
if(dxw.dwFlags1 & FIXPARENTWIN){
CalculateWindowPos(hwnd, iSizX, iSizY, &wp);
if (IsDebug) OutTraceD("MoveWindow: hParentWnd=%x pos=(%d,%d) size=(%d,%d)\n", hParentWnd, wp.x, wp.y, wp.cx, wp.cy);
res=(*pMoveWindow)(hParentWnd, wp.x, wp.y, wp.cx, wp.cy, FALSE);
if(!res) OutTraceE("MoveWindow ERROR: hParentWnd=%x err=%d at %d\n", hParentWnd, GetLastError(), __LINE__);
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;
@ -1558,13 +1417,13 @@ HRESULT WINAPI extGDIGetDisplayMode(HDC dev, int mode)
OutTraceD("GDIGetDisplayMode, mode=%x\n", mode);
res=(*pGDIGetDisplayMode)(dev, mode);
if((dwFlags & EMULATESURFACE) && (VirtualScr.PixelFormat.dwRGBBitCount == 8)){
if((dxw.dwFlags1 & EMULATESURFACE) && (dxw.VirtualPixelFormat.dwRGBBitCount == 8)){
//lpddsd->ddpfPixelFormat.dwFlags |= DDPF_PALETTEINDEXED8;
//lpddsd->ddpfPixelFormat.dwRGBBitCount = 8;
//lpddsd->ddsCaps.dwCaps |= DDSCAPS_PALETTE;
}
else
if((dwFlags & EMULATESURFACE) && (VirtualScr.PixelFormat.dwRGBBitCount == 16)){
if((dxw.dwFlags1 & EMULATESURFACE) && (dxw.VirtualPixelFormat.dwRGBBitCount == 16)){
//lpddsd->ddpfPixelFormat.dwRGBBitCount = 16;
}
//OutTraceD("GetDisplayMode: returning WxH=(%dx%d), PixelFormat Flags=%x, RGBBitCount=%d, Caps=%x\n",
@ -1578,13 +1437,12 @@ HRESULT WINAPI extGDIGetDisplayMode(HDC dev, int mode)
HWND WINAPI extGetDesktopWindow(void)
{
// V2.1.73: correct ???
extern BOOL isFullScreen;
HWND res;
OutTraceD("GetDesktopWindow: FullScreen=%x\n", isFullScreen);
if (isFullScreen){
OutTraceD("GetDesktopWindow: returning main window hwnd=%x\n", hWnd);
return hWnd;
OutTraceD("GetDesktopWindow: FullScreen=%x\n", dxw.IsFullScreen());
if (dxw.IsFullScreen()){
OutTraceD("GetDesktopWindow: returning main window hwnd=%x\n", dxw.GethWnd());
return dxw.GethWnd();
}
else{
res=(*pGetDesktopWindow)();

View File

@ -1,5 +1,5 @@
#include "dxwnd.h"
//#include "dxwcore.hpp"
#include "dxwcore.hpp"
#include "syslibs.h"
extern GetCursorPos_Type pGetCursorPos;
@ -7,18 +7,42 @@ extern ClientToScreen_Type pClientToScreen;
dxwCore::dxwCore()
{
// initialization stuff ....
FullScreen=FALSE;
SethWnd(NULL);
SetScreenSize();
dwMaxDDVersion=7;
hParentWnd = 0;
hChildWnd = 0;
bActive = TRUE;
bDInputAbs = 0;
}
dxwCore::~dxwCore()
{
}
void dxwCore::SethWnd(HWND hwnd)
RECT dxwCore::GetScreenRect()
{
hWnd=hwnd;
static RECT Screen;
Screen.left=0;
Screen.top=0;
Screen.right=dwScreenWidth;
Screen.bottom=dwScreenHeight;
return Screen;
}
POINT FixCursorPos(POINT prev)
// v2.1.93: FixCursorPos completely revised to introduce a clipping tolerance in
// clipping regions as well as in normal operations
#define CLIP_TOLERANCE 4
POINT dxwCore::FixCursorPos(POINT prev)
{
return FixCursorPos(hWnd, prev);
}
POINT dxwCore::FixCursorPos(HWND hwnd, POINT prev)
{
POINT curr;
RECT rect;
@ -28,17 +52,17 @@ POINT FixCursorPos(POINT prev)
// scale mouse coordinates
// remember: rect from GetClientRect always start at 0,0!
if(dwFlags & MODIFYMOUSE){
if (!(*pGetClientRect)(hWnd, &rect)) {
if(dxw.dwFlags1 & MODIFYMOUSE){
if (!(*pGetClientRect)(hwnd, &rect)) {
OutTraceD("GetClientRect ERROR %d at %d\n", GetLastError(),__LINE__);
curr.x = curr.y = 0;
}
if (rect.right) curr.x = (curr.x * VirtualScr.dwWidth) / rect.right;
if (rect.bottom) curr.y = (curr.y * VirtualScr.dwHeight) / rect.bottom;
if (rect.right) curr.x = (curr.x * dxw.GetScreenWidth()) / rect.right;
if (rect.bottom) curr.y = (curr.y * dxw.GetScreenHeight()) / rect.bottom;
}
if((dwFlags & ENABLECLIPPING) && lpClipRegion){
if((dxw.dwFlags1 & ENABLECLIPPING) && lpClipRegion){
// v2.1.93:
// in clipping mode, avoid the cursor position to lay outside the valid rect
// note 1: the rect follow the convention and valid coord lay between left to righ-1,
@ -54,9 +78,123 @@ POINT FixCursorPos(POINT prev)
else{
if (curr.x < CLIP_TOLERANCE) curr.x=0;
if (curr.y < CLIP_TOLERANCE) curr.y=0;
if (curr.x >= (LONG)VirtualScr.dwWidth-CLIP_TOLERANCE) curr.x=VirtualScr.dwWidth-1;
if (curr.y >= (LONG)VirtualScr.dwHeight-CLIP_TOLERANCE) curr.y=VirtualScr.dwHeight-1;
if (curr.x >= (LONG)dxw.GetScreenWidth()-CLIP_TOLERANCE) curr.x=dxw.GetScreenWidth()-1;
if (curr.y >= (LONG)dxw.GetScreenHeight()-CLIP_TOLERANCE) curr.y=dxw.GetScreenHeight()-1;
}
return curr;
}
void dxwCore::FixNCHITCursorPos(LPPOINT lppoint)
{
RECT rect;
POINT point;
point=*lppoint;
(*pGetClientRect)(dxw.GethWnd(), &rect);
(*pScreenToClient)(dxw.GethWnd(), &point);
if (point.x < 0) return;
if (point.y < 0) return;
if (point.x > rect.right) return;
if (point.y > rect.bottom) return;
*lppoint=point;
lppoint->x = (lppoint->x * dxw.GetScreenWidth()) / rect.right;
lppoint->y = (lppoint->y * dxw.GetScreenHeight()) / rect.bottom;
if(lppoint->x < CLIP_TOLERANCE) lppoint->x=0;
if(lppoint->y < CLIP_TOLERANCE) lppoint->y=0;
if(lppoint->x > (LONG)dxw.GetScreenWidth()-CLIP_TOLERANCE) lppoint->x=dxw.GetScreenWidth()-1;
if(lppoint->y > (LONG)dxw.GetScreenHeight()-CLIP_TOLERANCE) lppoint->y=dxw.GetScreenHeight()-1;
}
void dxwCore::SetClipCursor()
{
RECT Rect;
POINT UpLeftCorner;
OutTraceD("Core::SetClipCursor:\n");
if (hWnd==NULL) {
OutTraceD("Core::SetClipCursor: ASSERT hWnd==NULL\n");
return;
}
(*pGetClientRect)(hWnd, &Rect);
UpLeftCorner.x=UpLeftCorner.y=0;
(*pClientToScreen)(hWnd, &UpLeftCorner);
Rect.left+=UpLeftCorner.x;
Rect.right+=UpLeftCorner.x;
Rect.top+=UpLeftCorner.y;
Rect.bottom+=UpLeftCorner.y;
(*pClipCursor)(NULL);
if(!(*pClipCursor)(&Rect)){
OutTraceE("ClipCursor: ERROR err=%d at %d\n", GetLastError(), __LINE__);
}
OutTraceD("Core::SetClipCursor: rect=(%d,%d)-(%d,%d)\n",
Rect.left, Rect.top, Rect.right, Rect.bottom);
}
void dxwCore::EraseClipCursor()
{
OutTraceD("Core::EraseClipCursor:\n");
(*pClipCursor)(NULL);
}
// MapWindow Rect: returns a rectangle in the real coordinate system from the virtual coordinates
// of an emulated fullscreen window. NULL or void returns the rectangle of the whole client area.
RECT dxwCore::MapWindowRect(void)
{
return MapWindowRect(NULL);
}
RECT dxwCore::MapWindowRect(LPRECT lpRect)
{
POINT UpLeft={0,0};
RECT RetRect;
RECT ClientRect;
if (!(*pGetClientRect)(hWnd, &ClientRect)){
OutTraceE("GetClientRect ERROR: err=%d hwnd=%x at %d\n", GetLastError(), hWnd, __LINE__);
}
if(lpRect){
RetRect.left = lpRect->left * ClientRect.right / dwScreenWidth;
RetRect.right = lpRect->right * ClientRect.right / dwScreenWidth;
RetRect.top = lpRect->top * ClientRect.bottom / dwScreenHeight;
RetRect.bottom = lpRect->bottom * ClientRect.bottom / dwScreenHeight;
}
else {
RetRect=ClientRect;
}
if(!(*pClientToScreen)(hWnd, &UpLeft)){
OutTraceE("ClientToScreen ERROR: err=%d hwnd=%x at %d\n", GetLastError(), hWnd, __LINE__);
}
if(!OffsetRect(&RetRect ,UpLeft.x, UpLeft.y)){
OutTraceE("OffsetRect ERROR: err=%d hwnd=%x at %d\n", GetLastError(), hWnd, __LINE__);
}
return RetRect;
}
void dxwCore::ScreenRefresh(void)
{
// optimization: don't blit too often!
// 20mSec seems a good compromise.
#define DXWREFRESHINTERVAL 20
LPDIRECTDRAWSURFACE lpDDSPrim;
extern LPDIRECTDRAWSURFACE GetPrimarySurface();
extern HRESULT WINAPI extBlt(LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect, LPDIRECTDRAWSURFACE lpddssrc, LPRECT lpsrcrect, DWORD dwflags, LPDDBLTFX lpddbltfx);
static int t = -1;
if (t == -1)
t = GetTickCount()-(DXWREFRESHINTERVAL+1); // V.2.1.69: trick - subtract
int tn = GetTickCount();
if (tn-t < DXWREFRESHINTERVAL) return;
lpDDSPrim=GetPrimarySurface();
// if too early ....
if (lpDDSPrim)
extBlt(lpDDSPrim, NULL, lpDDSPrim, NULL, 0, NULL);
(*pInvalidateRect)(hWnd, NULL, FALSE);
t = tn;
}

View File

@ -1,7 +1,5 @@
#include <windows.h>
#define CLIP_TOLERANCE 4
class dxwCore
{
// Construction/destruction
@ -10,15 +8,46 @@ public:
virtual ~dxwCore();
// Operations
public:
void SethWnd(HWND);
public:
public: // methods
void SethWnd(HWND hwnd) {hWnd=hwnd;}
HWND GethWnd(void) {return hWnd;}
void SetScreenSize(void) {dwScreenWidth=800; dwScreenHeight=600;}
void SetScreenSize(int x, int y) {if(x)dwScreenWidth=x; if(y)dwScreenHeight=y;}
DWORD GetScreenWidth(void) {return dwScreenWidth;}
DWORD GetScreenHeight(void) {return dwScreenHeight;}
RECT GetScreenRect(void);
void SetFullScreen(BOOL fs) {FullScreen=fs;}
BOOL IsFullScreen() {return FullScreen;}
POINT FixCursorPos(POINT);
POINT FixCursorPos(HWND, POINT);
void FixNCHITCursorPos(LPPOINT);
void SetClipCursor(void);
void EraseClipCursor(void);
RECT MapWindowRect(LPRECT lpRect);
RECT MapWindowRect(void);
void ScreenRefresh(void);
public: // simple data variables
DDPIXELFORMAT ActualPixelFormat;
DDPIXELFORMAT VirtualPixelFormat;
DWORD dwPrimarySurfaceCaps;
DWORD dwBackBufferCount;
DWORD dwDDVersion;
DWORD dwMaxDDVersion;
DWORD dwFlags1;
DWORD dwFlags2;
DWORD dwTFlags;
HWND hParentWnd;
HWND hChildWnd;
BOOL bActive;
BOOL bDInputAbs;
// Implementation
protected:
DWORD dwScreenWidth;
DWORD dwScreenHeight;
BOOL FullScreen;
HWND hWnd;
int dwScreenWidth;
int dwScreenHeight;
BOOL IsFullScreen;
};
extern dxwCore dxw;

View File

@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdio.h>
#include "dxwnd.h"
#define VERSION "2.01.100"
#define VERSION "2.02.00"
LRESULT CALLBACK HookProc(int ncode, WPARAM wparam, LPARAM lparam);

20
dll/dxwnd.ws2008.sln Normal file
View File

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dxwnd", "dxwnd.ws2008.vcproj", "{579E7FE7-2745-4100-A802-23511711FCDE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{579E7FE7-2745-4100-A802-23511711FCDE}.Debug|Win32.ActiveCfg = Debug|Win32
{579E7FE7-2745-4100-A802-23511711FCDE}.Debug|Win32.Build.0 = Debug|Win32
{579E7FE7-2745-4100-A802-23511711FCDE}.Release|Win32.ActiveCfg = Release|Win32
{579E7FE7-2745-4100-A802-23511711FCDE}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

BIN
dll/dxwnd.ws2008.suo Normal file

Binary file not shown.

View File

@ -244,6 +244,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\dxwcore.cpp"
>
</File>
<File
RelativePath="dxwnd.cpp"
>
@ -357,6 +361,10 @@
RelativePath="dxhook.h"
>
</File>
<File
RelativePath=".\dxwcore.hpp"
>
</File>
<File
RelativePath="..\Include\dxwnd.h"
>

View File

@ -1,4 +1,5 @@
#include "dxwnd.h"
#include "dxwcore.hpp"
#include "syslibs.h"
#include "dxhook.h"
#include "glhook.h"
@ -14,14 +15,14 @@ extern short iPosX, iPosY, iSizX, iSizY;
void WINAPI extglViewport(GLint x, GLint y, GLsizei width, GLsizei height)
{
RECT client;
(*pGetClientRect)(hWnd, &client);
(*pGetClientRect)(dxw.GethWnd(), &client);
OutTraceD("glViewport: declared pos=(%d,%d) size=(%d,%d)\n", x, y, width, height);
if(IsDebug) OutTrace("glViewport: DEBUG win=(%d,%d) screen=(%d,%d)\n",
client.right, client.bottom, VirtualScr.dwWidth, VirtualScr.dwHeight);
x = (x * (GLint)client.right) / (GLint)VirtualScr.dwWidth;
y = (y * (GLint)client.bottom) / (GLint)VirtualScr.dwHeight;
width = (width * (GLint)client.right) / (GLint)VirtualScr.dwWidth;
height = (height * (GLint)client.bottom) / (GLint)VirtualScr.dwHeight;
client.right, client.bottom, dxw.GetScreenWidth(), dxw.GetScreenHeight());
x = (x * (GLint)client.right) / (GLint)dxw.GetScreenWidth();
y = (y * (GLint)client.bottom) / (GLint)dxw.GetScreenHeight();
width = (width * (GLint)client.right) / (GLint)dxw.GetScreenWidth();
height = (height * (GLint)client.bottom) / (GLint)dxw.GetScreenHeight();
OutTraceD("glViewport: remapped pos=(%d,%d) size=(%d,%d)\n", x, y, width, height);
(*pglViewport)(x, y, width, height);
}
@ -29,12 +30,12 @@ void WINAPI extglViewport(GLint x, GLint y, GLsizei width, GLsizei height
void WINAPI extglScissor(GLint x, GLint y, GLsizei width, GLsizei height)
{
RECT client;
(*pGetClientRect)(hWnd, &client);
(*pGetClientRect)(dxw.GethWnd(), &client);
OutTraceD("glScissor: declared pos=(%d,%d) size=(%d,%d)\n", x, y, width, height);
x = (x * (GLint)client.right) / (GLint)VirtualScr.dwWidth;
y = (y * (GLint)client.bottom) / (GLint)VirtualScr.dwHeight;
width = (width * (GLint)client.right) / (GLint)VirtualScr.dwWidth;
height = (height * (GLint)client.bottom) / (GLint)VirtualScr.dwHeight;
x = (x * (GLint)client.right) / (GLint)dxw.GetScreenWidth();
y = (y * (GLint)client.bottom) / (GLint)dxw.GetScreenHeight();
width = (width * (GLint)client.right) / (GLint)dxw.GetScreenWidth();
height = (height * (GLint)client.bottom) / (GLint)dxw.GetScreenHeight();
OutTraceD("glScissor: remapped pos=(%d,%d) size=(%d,%d)\n", x, y, width, height);
(*pglScissor)(x, y, width, height);
}

View File

@ -1,6 +1,7 @@
#include <windows.h>
#include <d3d9.h>
#include "dxwnd.h"
#include "dxwcore.hpp"
typedef void* (WINAPI *Direct3DCreate8_Type)(UINT);
typedef void* (WINAPI *Direct3DCreate9_Type)(UINT);
@ -18,9 +19,6 @@ HRESULT WINAPI extEnumAdapterModes9(void *, UINT, D3DFORMAT, UINT , D3DDISPLAYMO
HRESULT WINAPI extGetAdapterDisplayMode(void *, UINT, D3DDISPLAYMODE *);
HRESULT WINAPI extGetDisplayMode(void *, D3DDISPLAYMODE *);
extern HWND hWnd;
extern DWORD dwFlags;
extern BOOL bActive;
extern char *ExplainDDError(DWORD);
Direct3DCreate8_Type pDirect3DCreate8 = 0;
@ -115,7 +113,7 @@ HRESULT WINAPI extGetDisplayMode(void *lpd3d, D3DDISPLAYMODE *pMode)
res=(*pGetDisplayMode)(lpd3d, pMode);
OutTraceD("DEBUG: GetDisplayMode: size=(%dx%d) RefreshRate=%d Format=%d\n",
pMode->Width, pMode->Height, pMode->RefreshRate, pMode->Format);
if(dwFlags2 & KEEPASPECTRATIO){
if(dxw.dwFlags2 & KEEPASPECTRATIO){
pMode->Width=iSizX;
pMode->Height=iSizY;
OutTraceD("DEBUG: GetDisplayMode: fixed size=(%dx%d)\n", pMode->Width, pMode->Height);
@ -148,7 +146,7 @@ HRESULT WINAPI extGetAdapterDisplayMode(void *lpd3d, UINT Adapter, D3DDISPLAYMOD
res=(*pGetAdapterDisplayMode)(lpd3d, Adapter, pMode);
OutTraceD("DEBUG: GetAdapterDisplayMode: size=(%dx%d) RefreshRate=%d Format=%d\n",
pMode->Width, pMode->Height, pMode->RefreshRate, pMode->Format);
if(dwFlags2 & KEEPASPECTRATIO){
if(dxw.dwFlags2 & KEEPASPECTRATIO){
pMode->Width=iSizX;
pMode->Height=iSizY;
OutTraceD("DEBUG: GetDisplayMode: fixed size=(%dx%d)\n", pMode->Width, pMode->Height);
@ -163,7 +161,6 @@ HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devicetype,
DWORD param[64], *tmp;
D3DDISPLAYMODE mode;
int Windowed;
extern BOOL isFullScreen;
if(dwD3DVersion == 9){
memcpy(param, ppresentparam, 56);
@ -174,16 +171,9 @@ HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devicetype,
OutTraceD("D3D8::CreateDevice\n");
}
hWnd = hfocuswindow;
VirtualScr.dwWidth = param[0];
VirtualScr.dwHeight = param[1];
// The Fellowship of the Ring: starts with 0,0 size, but this doesn't fully help
//if ((VirtualScr.dwWidth==0) && (VirtualScr.dwHeight==0)){
// OutTraceD("CreateDevice: setting default size 800x600\n");
// VirtualScr.dwWidth=800;
// VirtualScr.dwHeight=600;
//}
AdjustWindowFrame(hWnd, VirtualScr.dwWidth, VirtualScr.dwHeight);
dxw.SethWnd(hfocuswindow);
dxw.SetScreenSize(param[0], param[1]);
AdjustWindowFrame(dxw.GethWnd(), dxw.GetScreenWidth(), dxw.GetScreenHeight());
tmp = param;
OutTraceD(" Adapter = %i\n", adapter);
@ -213,14 +203,14 @@ HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devicetype,
if(dwD3DVersion == 9){
param[7] = 0; //hDeviceWindow
isFullScreen = ~param[8]?TRUE:FALSE;
dxw.SetFullScreen(~param[8]?TRUE:FALSE);
param[8] = 1; //Windowed
param[12] = 0; //FullScreen_RefreshRateInHz;
param[13] = D3DPRESENT_INTERVAL_DEFAULT; //PresentationInterval
}
else{
param[6] = 0; //hDeviceWindow
isFullScreen = ~param[7]?TRUE:FALSE;
dxw.SetFullScreen(~param[7]?TRUE:FALSE);
param[7] = 1; //Windowed
param[11] = 0; //FullScreen_RefreshRateInHz;
param[12] = D3DPRESENT_INTERVAL_DEFAULT; //PresentationInterval
@ -246,11 +236,11 @@ HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devicetype,
SetHook((void *)(**(DWORD **)ppd3dd + 64), extReset, (void **)&pReset, "Reset(D9)");
}
DxWndStatus.IsFullScreen = isFullScreen;
DxWndStatus.IsFullScreen = dxw.IsFullScreen();
DxWndStatus.DXVersion=(short)dwD3DVersion;
DxWndStatus.Height=(short)VirtualScr.dwHeight;
DxWndStatus.Width=(short)VirtualScr.dwWidth;
DxWndStatus.ColorDepth=(short)VirtualScr.PixelFormat.dwRGBBitCount;
DxWndStatus.Height=(short)dxw.GetScreenHeight();
DxWndStatus.Width=(short)dxw.GetScreenWidth();
DxWndStatus.ColorDepth=(short)dxw.VirtualPixelFormat.dwRGBBitCount;
SetHookStatus(&DxWndStatus);
return 0;

View File

@ -13,6 +13,7 @@
#include <stdio.h>
#include <stdarg.h>
#include "dxwnd.h"
#include "dxwcore.hpp"
#include "dxhook.h"
#include "syslibs.h"
#include "dxhelper.h"
@ -280,7 +281,7 @@ int HookDDProxy(int dxVersion)
// LPDIRECTDRAW lpdd;
// BOOL res;
dwFlags |= OUTDDRAWTRACE;
dxw.dwFlags1 |= OUTDDRAWTRACE;
pCreateCompatibleDC=CreateCompatibleDC;
pGDIGetDC=GetDC;
@ -1747,7 +1748,7 @@ static void HookDDSessionProxy(LPDIRECTDRAW *lplpdd, int dxVersion)
HRESULT WINAPI extDirectDrawCreateProxy(GUID FAR *lpguid, LPDIRECTDRAW FAR *lplpdd, IUnknown FAR *pu)
{
HRESULT res;
int dwDDVersion;
int DDVersion;
OutTraceP("DirectDrawCreate: PROXED guid=%x(%s)\n",
lpguid, ExplainGUID(lpguid));
@ -1758,19 +1759,19 @@ HRESULT WINAPI extDirectDrawCreateProxy(GUID FAR *lpguid, LPDIRECTDRAW FAR *lplp
return res;
}
dwDDVersion=1;
DDVersion=1;
if (lpguid) switch (*(DWORD *)lpguid){
case 0x6C14DB80: dwDDVersion=1; break;
case 0xB3A6F3E0: dwDDVersion=2; break;
case 0x9c59509a: dwDDVersion=4; break;
case 0x15e65ec0: dwDDVersion=7; break;
case 0x6C14DB80: DDVersion=1; break;
case 0xB3A6F3E0: DDVersion=2; break;
case 0x9c59509a: DDVersion=4; break;
case 0x15e65ec0: DDVersion=7; break;
}
OutTraceP("DirectDrawCreate: lpdd=%x guid=%x DDVersion=%d\n",
*lplpdd, (lpguid ? *(DWORD *)lpguid:0), dwDDVersion);
*lplpdd, (lpguid ? *(DWORD *)lpguid:0), DDVersion);
#ifdef HOOKDDRAW
HookDDSessionProxy(lplpdd, dwDDVersion);
HookDDSessionProxy(lplpdd, DDVersion);
#endif
return 0;
}
@ -1778,7 +1779,7 @@ HRESULT WINAPI extDirectDrawCreateProxy(GUID FAR *lpguid, LPDIRECTDRAW FAR *lplp
HRESULT WINAPI extDirectDrawCreateExProxy(GUID FAR *lpguid, LPDIRECTDRAW FAR *lplpdd, REFIID RefIid, IUnknown FAR *pu)
{
HRESULT res;
int dwDDVersion;
int DDVersion;
OutTraceP("DirectDrawCreateEx: PROXED guid=%x(%s) refiid=%x\n",
lpguid, ExplainGUID(lpguid), RefIid);
@ -1789,19 +1790,19 @@ HRESULT WINAPI extDirectDrawCreateExProxy(GUID FAR *lpguid, LPDIRECTDRAW FAR *lp
return res;
}
dwDDVersion=1;
DDVersion=1;
if (lpguid) switch (*(DWORD *)lpguid){
case 0x6C14DB80: dwDDVersion=1; break;
case 0xB3A6F3E0: dwDDVersion=2; break;
case 0x9c59509a: dwDDVersion=4; break;
case 0x15e65ec0: dwDDVersion=7; break;
case 0x6C14DB80: DDVersion=1; break;
case 0xB3A6F3E0: DDVersion=2; break;
case 0x9c59509a: DDVersion=4; break;
case 0x15e65ec0: DDVersion=7; break;
}
OutTraceP("DirectDrawCreateEx: lpdd=%x guid=%x DDVersion=%d\n",
*lplpdd, (lpguid ? *(DWORD *)lpguid:0), dwDDVersion);
*lplpdd, (lpguid ? *(DWORD *)lpguid:0), DDVersion);
#ifdef HOOKDDRAW
HookDDSessionProxy(lplpdd, dwDDVersion);
HookDDSessionProxy(lplpdd, DDVersion);
#endif
return 0;
}
@ -1854,7 +1855,7 @@ HRESULT WINAPI extDirectDrawEnumerateExProxy(LPDDENUMCALLBACKEX lpCallback, LPVO
{
HRESULT ret;
OutTraceP("DirectDrawEnumerateEx: PROXED lpCallback=%x lpContext=%x Flags=%x(%s)\n",
lpCallback, lpContext, dwFlags, ExplainDDEnumerateFlags(dwFlags));
lpCallback, lpContext, dxw.dwFlags1, ExplainDDEnumerateFlags(dwFlags));
(*pDirectDrawEnumerateEx)(DDEnumerateCallbackEx, lpContext, dwFlags);
ret=(*pDirectDrawEnumerateEx)(lpCallback, lpContext, dwFlags);
if(ret) OutTraceP("DirectDrawEnumerateEx: ERROR res=%x(%s)\n", ret, ExplainDDError(ret));

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
#include <windows.h>
#include <dinput.h>
#include "dxwnd.h"
#include "dxwcore.hpp"
#include "syslibs.h"
typedef HRESULT (WINAPI *QueryInterface_Type)(void *, REFIID, LPVOID *);
@ -26,12 +27,6 @@ HRESULT WINAPI extQueryInterfaceI(void *, REFIID, LPVOID *);
void GetMousePosition(int *, int *);
void InitPosition(int, int, int, int, int, int);
extern DWORD dwFlags;
extern BOOL bActive;
extern HWND hWnd;
extern DWORD dwWidth;
extern DWORD dwHeight;
DirectInputCreate_Type pDirectInputCreate = 0;
DirectInputCreateEx_Type pDirectInputCreateEx = 0;
DICreateDevice_Type pDICreateDevice = 0;
@ -42,8 +37,6 @@ DISetCooperativeLevel_Type pDISetCooperativeLevel;
SetDataFormat_Type pSetDataFormat;
QueryInterface_Type pQueryInterfaceI;
BOOL bDInputAbs = 0;
int iCursorX;
int iCursorY;
int iCursorXBuf;
@ -205,14 +198,14 @@ HRESULT WINAPI extGetDeviceData(LPDIRECTINPUTDEVICE lpdid, DWORD cbdata, LPVOID
res = (*pGetDeviceData)(lpdid, cbdata, rgdod, pdwinout, dwflags);
if(res) return res;
if(!bActive) *pdwinout = 0;
if(!dxw.bActive) *pdwinout = 0;
GetMousePosition((int *)&p.x, (int *)&p.y);
if(cbdata == 20 || cbdata == 24){
tmp = (BYTE *)rgdod;
for(i = 0; i < *pdwinout; i ++){
if(((LPDIDEVICEOBJECTDATA)tmp)->dwOfs == DIMOFS_X){
((LPDIDEVICEOBJECTDATA)tmp)->dwData = p.x;
if(!bDInputAbs){
if(!dxw.bDInputAbs){
if(p.x < iCurMinX) p.x = iCurMinX;
if(p.x > iCurMaxX) p.x = iCurMaxX;
((LPDIDEVICEOBJECTDATA)tmp)->dwData = p.x - iCursorXBuf;
@ -221,7 +214,7 @@ HRESULT WINAPI extGetDeviceData(LPDIRECTINPUTDEVICE lpdid, DWORD cbdata, LPVOID
}
if(((LPDIDEVICEOBJECTDATA)tmp)->dwOfs == DIMOFS_Y){
((LPDIDEVICEOBJECTDATA)tmp)->dwData = p.y;
if(!bDInputAbs){
if(!dxw.bDInputAbs){
if(p.y < iCurMinY) p.y = iCurMinY;
if(p.y > iCurMaxY) p.y = iCurMaxY;
((LPDIDEVICEOBJECTDATA)tmp)->dwData = p.y - iCursorYBuf;
@ -240,7 +233,7 @@ HRESULT WINAPI extGetDeviceState(LPDIRECTINPUTDEVICE lpdid, DWORD cbdata, LPDIMO
HRESULT res;
POINT p = {0, 0};
OutTraceD("GetDeviceState cbData:%i %i\n", cbdata, bActive);
OutTraceD("GetDeviceState cbData:%i %i\n", cbdata, dxw.bActive);
res = (*pGetDeviceState)(lpdid, cbdata, lpvdata);
if(res) return res;
@ -248,7 +241,7 @@ HRESULT WINAPI extGetDeviceState(LPDIRECTINPUTDEVICE lpdid, DWORD cbdata, LPDIMO
GetMousePosition((int *)&p.x, (int *)&p.y);
lpvdata->lX = p.x;
lpvdata->lY = p.y;
if(!bDInputAbs){
if(!dxw.bDInputAbs){
if(p.x < iCurMinX) p.x = iCurMinX;
if(p.x > iCurMaxX) p.x = iCurMaxX;
if(p.y < iCurMinY) p.y = iCurMinY;
@ -258,14 +251,14 @@ HRESULT WINAPI extGetDeviceState(LPDIRECTINPUTDEVICE lpdid, DWORD cbdata, LPDIMO
iCursorX = p.x;
iCursorY = p.y;
}
if(!bActive){
if(!dxw.bActive){
lpvdata->lZ = 0;
*(DWORD *)lpvdata->rgbButtons = 0;
}
OutTraceD("DEBUG: directinput mousestate=(%d,%d)\n", p.x, p.y);
}
if(cbdata == 256 && !bActive) ZeroMemory(lpvdata, 256);
if(cbdata == 256 && !dxw.bActive) ZeroMemory(lpvdata, 256);
return 0;
}
@ -273,8 +266,8 @@ HRESULT WINAPI extSetDataFormat(LPDIRECTINPUTDEVICE lpdid, LPCDIDATAFORMAT lpdf)
{
OutTraceD("SetDataFormat: flags = 0x%x\n", lpdf->dwFlags);
if(lpdf->dwFlags & DIDF_ABSAXIS) bDInputAbs = 1;
if(lpdf->dwFlags & DIDF_RELAXIS) bDInputAbs = 0;
if(lpdf->dwFlags & DIDF_ABSAXIS) dxw.bDInputAbs = 1;
if(lpdf->dwFlags & DIDF_RELAXIS) dxw.bDInputAbs = 0;
return (*pSetDataFormat)(lpdid, lpdf);
}

File diff suppressed because it is too large Load Diff

View File

@ -89,8 +89,6 @@ typedef BOOL (WINAPI *SetDeviceGammaRamp_Type)(HDC, LPVOID);
typedef BOOL (WINAPI *GetDeviceGammaRamp_Type)(HDC, LPVOID);
typedef LRESULT (WINAPI *SendMessage_Type)(HWND, UINT, WPARAM, LPARAM);
extern DWORD dwFlags, dwFlags2;
extern HWND hWnd;
extern GetCursorPos_Type pGetCursorPos;
extern SetCursorPos_Type pSetCursorPos;
extern ClipCursor_Type pClipCursor;

View File

@ -5,6 +5,7 @@
#include <malloc.h>
#include <ddraw.h>
#include "dxwnd.h"
#include "dxwcore.hpp"
#include "dxhook.h"
#include "syslibs.h"
#include "dxhelper.h"

View File

@ -131,6 +131,7 @@
#define ID_TRAY_RESTORE 32808
#define ID_VIEW_STATUS 32809
#define ID_DXAPP_EXIT 32810
#define ID_SAVEFILE 32810
// Next default values for new objects
//
@ -138,7 +139,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 150
#define _APS_NEXT_COMMAND_VALUE 32809
#define _APS_NEXT_COMMAND_VALUE 32811
#define _APS_NEXT_CONTROL_VALUE 1032
#define _APS_NEXT_SYMED_VALUE 101
#endif

Binary file not shown.

View File

@ -80,6 +80,7 @@ IDR_MAINFRAME MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "Save", ID_FILE_SAVE
MENUITEM "&Sort programs list", ID_FILE_SORTPROGRAMSLIST
MENUITEM "&Clear all logs", ID_FILE_CLEARALLLOGS
POPUP "Hook"
@ -393,7 +394,7 @@ BEGIN
ID_FILE_NEW "Create a new file\nNew File"
ID_FILE_OPEN "Open an existing file\nOpen"
ID_FILE_CLOSE "Close the active file\nClose"
ID_FILE_SAVE "Save overwriting the files in the working directory\nSave"
ID_FILE_SAVE "Save the configuration file\nSave"
ID_FILE_SAVE_AS "Save with a new name\nrename and save"
END

20
host/dxwndhost.vs2008.sln Normal file
View File

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dxwndhost", "dxwndhost.vs2008.vcproj", "{FD0B0234-8EC5-43C0-A384-1B881DD3D925}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FD0B0234-8EC5-43C0-A384-1B881DD3D925}.Debug|Win32.ActiveCfg = Debug|Win32
{FD0B0234-8EC5-43C0-A384-1B881DD3D925}.Debug|Win32.Build.0 = Debug|Win32
{FD0B0234-8EC5-43C0-A384-1B881DD3D925}.Release|Win32.ActiveCfg = Release|Win32
{FD0B0234-8EC5-43C0-A384-1B881DD3D925}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

BIN
host/dxwndhost.vs2008.suo Normal file

Binary file not shown.

View File

@ -45,6 +45,7 @@ BEGIN_MESSAGE_MAP(CDxwndhostView, CListView)
ON_COMMAND(ID_FILE_SORTPROGRAMSLIST, OnSort)
ON_COMMAND(ID_FILE_CLEARALLLOGS, OnClearAllLogs)
ON_COMMAND(ID_FILE_GOTOTRAYICON, OnGoToTrayIcon)
ON_COMMAND(ID_FILE_SAVE, OnSaveFile)
ON_COMMAND(ID_HOOK_START, OnHookStart)
ON_COMMAND(ID_HOOK_STOP, OnHookStop)
ON_COMMAND(ID_DXAPP_EXIT, OnExit)
@ -92,11 +93,100 @@ CDxwndhostView::CDxwndhostView()
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &this->InitDevMode);
}
CDxwndhostView::~CDxwndhostView()
void CDxwndhostView::SaveConfigFile()
{
int i;
char key[32], val[32];
for(i = 0; i < MAXTARGETS; i ++){
if(!TargetMaps[i].path[0]) break;
sprintf_s(key, sizeof(key), "title%i", i);
WritePrivateProfileString("target", key, TitleMaps[i].title, InitPath);
sprintf_s(key, sizeof(key), "path%i", i);
WritePrivateProfileString("target", key, TargetMaps[i].path, InitPath);
sprintf_s(key, sizeof(key), "module%i", i);
WritePrivateProfileString("target", key, TargetMaps[i].module, InitPath);
sprintf_s(key, sizeof(key), "ver%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].dxversion);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "flag%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].flags);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "flagg%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].flags2);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "tflag%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].tflags);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "initx%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].initx);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "inity%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].inity);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "minx%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].minx);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "miny%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].miny);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "maxx%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].maxx);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "maxy%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].maxy);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "posx%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].posx);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "posy%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].posy);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "sizx%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].sizx);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "sizy%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].sizy);
WritePrivateProfileString("target", key, val, InitPath);
}
for(; i < MAXTARGETS; i ++){
sprintf_s(key, sizeof(key), "path%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "ver%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "flag%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "flagg%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "tflag%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "initx%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "inity%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "minx%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "miny%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "maxx%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "maxy%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "posx%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "posy%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "sizx%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "sizy%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
}
this->isUpdated=FALSE;
}
CDxwndhostView::~CDxwndhostView()
{
EndHook();
RevertScreenChanges(&this->InitDevMode);
@ -106,92 +196,7 @@ CDxwndhostView::~CDxwndhostView()
"Task list has changed.\n"
"Do you want to save it?",
"Warning", MB_YESNO | MB_ICONQUESTION, NULL)==IDYES)
{
for(i = 0; i < MAXTARGETS; i ++){
if(!TargetMaps[i].path[0]) break;
sprintf_s(key, sizeof(key), "title%i", i);
WritePrivateProfileString("target", key, TitleMaps[i].title, InitPath);
sprintf_s(key, sizeof(key), "path%i", i);
WritePrivateProfileString("target", key, TargetMaps[i].path, InitPath);
sprintf_s(key, sizeof(key), "module%i", i);
WritePrivateProfileString("target", key, TargetMaps[i].module, InitPath);
sprintf_s(key, sizeof(key), "ver%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].dxversion);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "flag%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].flags);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "flagg%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].flags2);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "tflag%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].tflags);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "initx%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].initx);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "inity%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].inity);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "minx%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].minx);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "miny%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].miny);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "maxx%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].maxx);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "maxy%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].maxy);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "posx%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].posx);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "posy%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].posy);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "sizx%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].sizx);
WritePrivateProfileString("target", key, val, InitPath);
sprintf_s(key, sizeof(key), "sizy%i", i);
sprintf_s(val, sizeof(val), "%i", TargetMaps[i].sizy);
WritePrivateProfileString("target", key, val, InitPath);
}
for(; i < MAXTARGETS; i ++){
sprintf_s(key, sizeof(key), "path%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "ver%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "flag%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "flagg%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "tflag%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "initx%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "inity%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "minx%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "miny%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "maxx%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "maxy%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "posx%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "posy%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "sizx%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "sizy%i", i);
WritePrivateProfileString("target", key, 0, InitPath);
}
}
this->isUpdated=FALSE;
this->SaveConfigFile();
if(this->SystemTray.Enabled()){
this->SystemTray.StopAnimation();
@ -966,6 +971,16 @@ void CDxwndhostView::OnGoToTrayIcon()
this->SystemTray.MinimiseToTray(pParent, FALSE);
}
void CDxwndhostView::OnSaveFile()
{
if (this->isUpdated)
if (MessageBoxEx(0,
"Task list has changed.\n"
"Do you want to save it?",
"Warning", MB_YESNO | MB_ICONQUESTION, NULL)==IDYES)
this->SaveConfigFile();
}
void CDxwndhostView::OnTrayRestore()
{
CWnd *pParent = this->GetParent();

View File

@ -19,6 +19,7 @@ protected: // Create from serialization only features.
private:
void Resize(void);
void SaveConfigFile();
TARGETMAP TargetMaps[MAXTARGETS];
PRIVATEMAP TitleMaps[MAXTARGETS];
char InitPath[MAX_PATH];
@ -69,6 +70,7 @@ protected:
afx_msg void OnRun();
afx_msg void OnClearAllLogs();
afx_msg void OnGoToTrayIcon();
afx_msg void OnSaveFile();
afx_msg void OnHookStart();
afx_msg void OnInitMenu();
afx_msg void OnHookStop();