mirror of
https://github.com/DxWnd/DxWnd.reloaded
synced 2024-12-30 09:25:35 +01:00
v2_02_16_src
Former-commit-id: 3d676d8b4e1d202e234cada66f573ba256575653
This commit is contained in:
parent
d57a6abc8e
commit
b0524b2bb5
@ -75,6 +75,7 @@
|
||||
#define LIMITRESOURCES 0x10000000 // Limit resources to fit an old program's expectations
|
||||
#define STARTDEBUG 0x20000000 // Start in DEBUG mode
|
||||
#define SETCOMPATIBILITY 0x40000000 // invoke ddraw SetAppCompatData to set aero compatibility mode
|
||||
#define WIREFRAME 0x80000000 // invoke ddraw SetAppCompatData to set aero compatibility mode
|
||||
|
||||
// logging Tflags DWORD:
|
||||
#define OUTTRACE 0x00000001 // enables tracing to dxwnd.log in general
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f64d856c6fd27bd8942e38438cdf956305709c9f842068013aad3fc9d2bf287b
|
||||
size 302592
|
||||
oid sha256:ccce7b58149566392637a1d72f587445ede44d768a6b88c4e28202b87ad5040c
|
||||
size 304640
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7fba4604764b38eb0dba2a2f669d2dfcb96d179138a6a6214ad3513b5d6eeba2
|
||||
oid sha256:95dbceb4c4ac4c61b5c7f8e3b3a128136c352da735829e51ae0bb713d37458e9
|
||||
size 501248
|
||||
|
4422
build/dxwnd.ini
Normal file
4422
build/dxwnd.ini
Normal file
File diff suppressed because it is too large
Load Diff
BIN
build/manual.pdf
BIN
build/manual.pdf
Binary file not shown.
@ -76,3 +76,9 @@ Fixed directx SetClipper hook to properly handle backbuffer clipping and fix "Wa
|
||||
v2.02.15
|
||||
Fixed clipping handling of primary/backbuffer surfaces
|
||||
Added option to set AERO compatibility for Vista/Win7/Win8 platforms. Need to call a undocumented ddraw API. Thanks to Vovchik that discovered it. Use at your own risk!
|
||||
|
||||
v2.02.16
|
||||
DLL injection finally working! Quake 2 is supported.
|
||||
Added Wireframe option for OpenGL games
|
||||
Improved fix for clipper handling of primary/backbuffer surfaces
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "dxwcore.hpp"
|
||||
#include "dxhook.h"
|
||||
#include "glhook.h"
|
||||
#include "msvfwhook.h"
|
||||
#define DXWDECLARATIONS 1
|
||||
#include "syslibs.h"
|
||||
#undef DXWDECLARATIONS
|
||||
@ -43,7 +44,7 @@ static char *Flag2Names[32]={
|
||||
"TIMESTRETCH", "HOOKOPENGL", "WALLPAPERMODE", "SHOWHWCURSOR",
|
||||
"HOOKGDI", "SHOWFPSOVERLAY", "FAKEVERSION", "FULLRECTBLT",
|
||||
"NOPALETTEUPDATE", "SUPPRESSIME", "NOBANNER", "WINDOWIZE",
|
||||
"", "", "", "",
|
||||
"LIMITRESOURCES", "STARTDEBUG", "SETCOMPATIBILITY", "",
|
||||
};
|
||||
|
||||
static char *TFlagNames[32]={
|
||||
@ -820,6 +821,10 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
|
||||
|
||||
void HookSysLibsInit()
|
||||
{
|
||||
static BOOL DoOnce = FALSE;
|
||||
if(DoOnce) return;
|
||||
DoOnce=TRUE;
|
||||
|
||||
pLoadLibraryA = LoadLibraryA;
|
||||
pLoadLibraryExA = LoadLibraryExA;
|
||||
pLoadLibraryW = LoadLibraryW;
|
||||
@ -1112,8 +1117,6 @@ void HookSysLibs(HMODULE module)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void RecoverScreenMode()
|
||||
{
|
||||
DEVMODE InitDevMode;
|
||||
@ -1201,6 +1204,7 @@ void HookModule(HMODULE base, int dxversion)
|
||||
HookDirect3D(base, dxversion);
|
||||
HookOle32(base, dxversion); // unfinished business
|
||||
if(dxw.dwFlags2 & HOOKOPENGL) HookOpenGLLibs(base, dxw.CustomOpenGLLib);
|
||||
HookMSV4WLibs(base);
|
||||
//ForceHookOpenGL(base);
|
||||
}
|
||||
|
||||
@ -1319,7 +1323,6 @@ int HookInit(TARGETMAP *target, HWND hwnd)
|
||||
if(!res) OutTraceE("MoveWindow ERROR: dxw.hParentWnd=%x err=%d at %d\n", dxw.hParentWnd, GetLastError(), __LINE__);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include "dxwnd.h"
|
||||
#include "dxwcore.hpp"
|
||||
|
||||
#define VERSION "2.02.15"
|
||||
#define VERSION "2.02.16"
|
||||
|
||||
LRESULT CALLBACK HookProc(int ncode, WPARAM wparam, LPARAM lparam);
|
||||
|
||||
@ -40,6 +41,8 @@ int HookStatus=DXW_IDLE;
|
||||
static int TaskIndex=-1;
|
||||
DXWNDSTATUS DxWndStatus;
|
||||
|
||||
void InjectHook();
|
||||
|
||||
BOOL APIENTRY DllMain( HANDLE hmodule,
|
||||
DWORD dwreason,
|
||||
LPVOID preserved
|
||||
@ -63,7 +66,7 @@ BOOL APIENTRY DllMain( HANDLE hmodule,
|
||||
if(!hTraceMutex) hTraceMutex = CreateMutex(0, FALSE, "Trace_Mutex");
|
||||
hLockMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, "Lock_Mutex");
|
||||
if(!hLockMutex) hLockMutex = CreateMutex(0, FALSE, "Lock_Mutex");
|
||||
|
||||
InjectHook();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -191,3 +194,21 @@ LRESULT CALLBACK HookProc(int ncode, WPARAM wparam, LPARAM lparam)
|
||||
}
|
||||
return CallNextHookEx(hHook, ncode, wparam, lparam);
|
||||
}
|
||||
|
||||
void InjectHook()
|
||||
{
|
||||
char name[MAX_PATH];
|
||||
int i;
|
||||
GetModuleFileName(0, name, MAX_PATH);
|
||||
for(i = 0; name[i]; i ++) name[i] = tolower(name[i]);
|
||||
for(i = 0; pMapping[i].path[0]; i ++){
|
||||
if(!strncmp(name, pMapping[i].path, strlen(name))){
|
||||
if (pMapping[i].flags2 & STARTDEBUG){
|
||||
OutTrace("InjectHook: task[%d]=\"%s\" hooked\n", i, pMapping[i].path);
|
||||
dxw.InitTarget(&pMapping[i]);
|
||||
HookInit(&pMapping[i],NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Version="9,00"
|
||||
Name="dxwnd"
|
||||
ProjectGUID="{579E7FE7-2745-4100-A802-23511711FCDE}"
|
||||
RootNamespace="dxwnd"
|
||||
@ -348,6 +348,10 @@
|
||||
RelativePath=".\imelib.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\msvfwhook.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\syslibs.cpp"
|
||||
>
|
||||
@ -393,6 +397,10 @@
|
||||
RelativePath=".\hddraw.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\msvfwhook.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\resource.h"
|
||||
>
|
||||
|
@ -29,7 +29,26 @@ FARPROC Remap_gl_ProcAddress(LPCSTR proc, HMODULE hModule)
|
||||
OutTraceD("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pglDrawBuffer);
|
||||
return (FARPROC)extglDrawBuffer;
|
||||
}
|
||||
|
||||
if (!strcmp(proc,"glPolygonMode")){
|
||||
pglPolygonMode=(glPolygonMode_Type)(*pGetProcAddress)(hModule, proc);
|
||||
OutTraceD("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pglPolygonMode);
|
||||
return (FARPROC)extglPolygonMode;
|
||||
}
|
||||
if (!strcmp(proc,"glGetFloatv")){
|
||||
pglGetFloatv=(glGetFloatv_Type)(*pGetProcAddress)(hModule, proc);
|
||||
OutTraceD("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pglGetFloatv);
|
||||
return (FARPROC)extglGetFloatv;
|
||||
}
|
||||
if (!strcmp(proc,"glClear")){
|
||||
pglClear=(glClear_Type)(*pGetProcAddress)(hModule, proc);
|
||||
OutTraceD("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pglClear);
|
||||
return (FARPROC)extglClear;
|
||||
}
|
||||
if (!strcmp(proc,"wglCreateContext")){
|
||||
pwglCreateContext=(wglCreateContext_Type)(*pGetProcAddress)(hModule, proc);
|
||||
OutTraceD("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pwglCreateContext);
|
||||
return (FARPROC)extwglCreateContext;
|
||||
}
|
||||
// NULL -> keep the original call address
|
||||
return NULL;
|
||||
}
|
||||
@ -53,17 +72,30 @@ void ForceHookOpenGL(HMODULE base) // to do .....
|
||||
pglScissor=(glScissor_Type)GetProcAddress(hGlLib, "glScissor");
|
||||
if(pglScissor) {
|
||||
HookAPI(base, "opengl32", pglScissor, "glScissor", extglScissor);
|
||||
//extglScissor(dxw.iPosX,dxw.iPosY,dxw.iSizX,dxw.iSizY);
|
||||
}
|
||||
pglGetIntegerv=(glGetIntegerv_Type)GetProcAddress(hGlLib, "glGetIntegerv");
|
||||
if(pglGetIntegerv) {
|
||||
HookAPI(base, "opengl32", pglGetIntegerv, "glGetIntegerv", extglGetIntegerv);
|
||||
//extglGetIntegerv(0, NULL);
|
||||
}
|
||||
pglDrawBuffer=(glDrawBuffer_Type)GetProcAddress(hGlLib, "glDrawBuffer");
|
||||
if(pglDrawBuffer) {
|
||||
HookAPI(base, "opengl32", pglDrawBuffer, "glDrawBuffer", extglDrawBuffer);
|
||||
//extglDrawBuffer(0);
|
||||
}
|
||||
pglPolygonMode=(glPolygonMode_Type)GetProcAddress(hGlLib, "glPolygonMode");
|
||||
if(pglPolygonMode) {
|
||||
HookAPI(base, "opengl32", pglPolygonMode, "glPolygonMode", extglPolygonMode);
|
||||
}
|
||||
pglGetFloatv=(glGetFloatv_Type)GetProcAddress(hGlLib, "glGetFloatv");
|
||||
if(pglGetFloatv) {
|
||||
HookAPI(base, "opengl32", pglGetFloatv, "glGetFloatv", extglGetFloatv);
|
||||
}
|
||||
pglClear=(glClear_Type)GetProcAddress(hGlLib, "glClear");
|
||||
if(pglClear) {
|
||||
HookAPI(base, "opengl32", pglClear, "glClear", extglClear);
|
||||
}
|
||||
pwglCreateContext=(wglCreateContext_Type)GetProcAddress(hGlLib, "wglCreateContext");
|
||||
if(pwglCreateContext) {
|
||||
HookAPI(base, "opengl32", pwglCreateContext, "wglCreateContext", extwglCreateContext);
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,6 +118,14 @@ void HookOpenGLLibs(HMODULE module, char *customlib)
|
||||
if(tmp) pglGetIntegerv = (glGetIntegerv_Type)tmp;
|
||||
tmp = HookAPI(module, customlib, NULL, "glDrawBuffer", extglDrawBuffer);
|
||||
if(tmp) pglDrawBuffer = (glDrawBuffer_Type)tmp;
|
||||
tmp = HookAPI(module, customlib, NULL, "glPolygonMode", extglPolygonMode);
|
||||
if(tmp) pglPolygonMode = (glPolygonMode_Type)tmp;
|
||||
tmp = HookAPI(module, customlib, NULL, "glGetFloatv", extglGetFloatv);
|
||||
if(tmp) pglGetFloatv = (glGetFloatv_Type)tmp;
|
||||
tmp = HookAPI(module, customlib, NULL, "glClear", extglClear);
|
||||
if(tmp) pglClear = (glClear_Type)tmp;
|
||||
tmp = HookAPI(module, customlib, NULL, "wglCreateContext", extwglCreateContext);
|
||||
if(tmp) pwglCreateContext = (wglCreateContext_Type)tmp;
|
||||
break;
|
||||
case 1:
|
||||
static int DoOnce=TRUE;
|
||||
@ -95,13 +135,13 @@ void HookOpenGLLibs(HMODULE module, char *customlib)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void WINAPI extglViewport(GLint x, GLint y, GLsizei width, GLsizei height)
|
||||
{
|
||||
RECT client;
|
||||
POINT p={0,0};
|
||||
//if (dxw.dwFlags2 & HANDLEFPS) if(dxw.HandleFPS()) return;
|
||||
(*pGetClientRect)(dxw.GethWnd(), &client);
|
||||
OutTraceD("glViewport: declared pos=(%d,%d) size=(%d,%d)\n", x, y, width, height);
|
||||
@ -118,6 +158,7 @@ void WINAPI extglViewport(GLint x, GLint y, GLsizei width, GLsizei height
|
||||
void WINAPI extglScissor(GLint x, GLint y, GLsizei width, GLsizei height)
|
||||
{
|
||||
RECT client;
|
||||
POINT p={0,0};
|
||||
//if (dxw.dwFlags2 & HANDLEFPS) if(dxw.HandleFPS()) return;
|
||||
(*pGetClientRect)(dxw.GethWnd(), &client);
|
||||
OutTraceD("glScissor: declared pos=(%d,%d) size=(%d,%d)\n", x, y, width, height);
|
||||
@ -138,6 +179,7 @@ void WINAPI extglGetIntegerv(GLenum pname, GLint *params)
|
||||
void WINAPI extglDrawBuffer(GLenum mode)
|
||||
{
|
||||
if (IsDebug) OutTrace("glDrawBuffer: mode=%x\n", mode);
|
||||
if(dxw.dwFlags2 & WIREFRAME) (*pglClear)(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT) ; // clear screen for wireframe mode....
|
||||
// handle FPS only to backbuffer updates (if stereo, on left backbuffer...)
|
||||
// using the frontbuffer seems less reliable: Return to Castle Wolfenstein doesn't use it at all!
|
||||
if (dxw.dwFlags2 & HANDLEFPS){
|
||||
@ -153,3 +195,49 @@ void WINAPI extglDrawBuffer(GLenum mode)
|
||||
}
|
||||
(*pglDrawBuffer)(mode);
|
||||
}
|
||||
|
||||
void WINAPI extglPolygonMode(GLenum face, GLenum mode)
|
||||
{
|
||||
OutTraceD("glPolygonMode: face=%x mode=%x\n", face, mode);
|
||||
if(dxw.dwFlags2 & WIREFRAME) mode = GL_LINE; // trick to set wireframe mode....
|
||||
(*pglPolygonMode)(face, mode);
|
||||
return;
|
||||
}
|
||||
|
||||
void WINAPI extglGetFloatv(GLenum pname, GLboolean *params)
|
||||
{
|
||||
OutTraceD("glGetFloatv: pname=%x\n", pname);
|
||||
(*pglGetFloatv)(pname, params);
|
||||
return;
|
||||
}
|
||||
|
||||
void WINAPI extglClear(GLbitfield mask)
|
||||
{
|
||||
(*pglClear)(mask);
|
||||
return;
|
||||
}
|
||||
|
||||
HGLRC WINAPI extwglCreateContext(HDC hdc)
|
||||
{
|
||||
HGLRC ret;
|
||||
ret=(*pwglCreateContext)(hdc);
|
||||
if(ret!=NULL){
|
||||
HWND hwnd;
|
||||
hwnd=WindowFromDC(hdc);
|
||||
dxw.SethWnd(hwnd);
|
||||
OutTraceD("wglCreateContext: hdc=%x hwnd=%x\n", hdc, hwnd);
|
||||
}
|
||||
else {
|
||||
OutTraceD("wglCreateContext: ERROR hdc=%x err=%x\n", hdc, GetLastError());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// to do:
|
||||
// glutSetWindow - save current window handle
|
||||
// glutInitWindowPosition, glutInitWindowSize
|
||||
// glutInitDisplayMode
|
||||
// glutCreateWindow, glutCreateSubWindow
|
||||
// glutPositionWindow, glutReshapeWindow
|
||||
// glGetFloatv ( GL_SCISSOR_BOX - GL_VIEWPORT )
|
||||
|
||||
|
14
dll/glhook.h
14
dll/glhook.h
@ -9,6 +9,10 @@ typedef void (WINAPI *glGetIntegerv_Type)(GLenum, GLint *);
|
||||
typedef void (WINAPI *glFinish_Type)(void);
|
||||
typedef void (WINAPI *glFlush_Type)(void);
|
||||
typedef void (WINAPI *glDrawBuffer_Type)(GLenum);
|
||||
typedef void (WINAPI *glPolygonMode_Type)(GLenum, GLenum);
|
||||
typedef void (WINAPI *glGetFloatv_Type)(GLenum, GLboolean *);
|
||||
typedef void (WINAPI *glClear_Type)(GLbitfield);
|
||||
typedef HGLRC (WINAPI *wglCreateContext_Type)(HDC);
|
||||
|
||||
extern void WINAPI extglViewport(GLint, GLint, GLsizei, GLsizei);
|
||||
extern void WINAPI extglScissor(GLint, GLint, GLsizei, GLsizei);
|
||||
@ -16,6 +20,10 @@ extern void WINAPI extglGetIntegerv(GLenum, GLint *);
|
||||
extern void WINAPI extglFinish(void);
|
||||
extern void WINAPI extglFlush(void);
|
||||
extern void WINAPI extglDrawBuffer(GLenum);
|
||||
extern void WINAPI extglPolygonMode(GLenum, GLenum);
|
||||
extern void WINAPI extglGetFloatv(GLenum, GLboolean *);
|
||||
extern void WINAPI extglClear(GLbitfield);
|
||||
extern HGLRC WINAPI extwglCreateContext(HDC);
|
||||
|
||||
#ifdef DXWDECLARATIONS
|
||||
#undef DXWEXTERN
|
||||
@ -35,4 +43,8 @@ DXWEXTERN glScissor_Type pglScissor;
|
||||
DXWEXTERN glGetIntegerv_Type pglGetIntegerv;
|
||||
//DXWEXTERN glFinish_Type pglFinish;
|
||||
//DXWEXTERN glFlush_Type pglFlush;
|
||||
DXWEXTERN glDrawBuffer_Type pglDrawBuffer;
|
||||
DXWEXTERN glDrawBuffer_Type pglDrawBuffer;
|
||||
DXWEXTERN glPolygonMode_Type pglPolygonMode;
|
||||
DXWEXTERN glGetFloatv_Type pglGetFloatv;
|
||||
DXWEXTERN glClear_Type pglClear;
|
||||
DXWEXTERN wglCreateContext_Type pwglCreateContext;
|
||||
|
@ -2819,31 +2819,18 @@ HRESULT WINAPI extSetClipper(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWCLIPPER lpdd
|
||||
// clipping ON & OFF affects blitting on primary surface.
|
||||
if(dxw.dwFlags1 & SUPPRESSCLIPPING) return 0;
|
||||
|
||||
#if 1
|
||||
if(dxw.dwFlags1 & (EMULATESURFACE|EMULATEBUFFER)){
|
||||
if (isPrim && lpDDSEmu_Prim) {
|
||||
res=(*pSetClipper)(lpDDSEmu_Prim, lpddc);
|
||||
if(res) OutTraceE("CreateSurface: SetClipper ERROR: res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
lpDDC = lpddc;
|
||||
// n.b. SetHWnd was not wrapped, so pSetHWnd is not usable (NULL) !!!
|
||||
if(lpDDC) res=lpDDC->SetHWnd( 0, dxw.GethWnd());
|
||||
if(res) OutTraceE("CreateSurface: SetHWnd ERROR: res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
}
|
||||
else if ((lpdds == lpDDSBack) && lpDDSEmu_Back) {
|
||||
res=(*pSetClipper)(lpDDSEmu_Back, lpddc);
|
||||
if(res) OutTraceE("CreateSurface: SetClipper ERROR: res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
lpDDC = lpddc;
|
||||
// n.b. SetHWnd was not wrapped, so pSetHWnd is not usable (NULL) !!!
|
||||
if(lpDDC) res=lpDDC->SetHWnd( 0, dxw.GethWnd());
|
||||
if(res) OutTraceE("CreateSurface: SetHWnd ERROR: res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
if ((isPrim && lpDDSEmu_Prim) ||
|
||||
((lpdds == lpDDSBack) && lpDDSEmu_Back)){
|
||||
OutTraceD("SetClipper: skip primary/backbuffer lpdds=%x\n", lpdds);
|
||||
res=0;
|
||||
}
|
||||
else
|
||||
res=(*pSetClipper)(lpdds, lpddc);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
// just proxy ...
|
||||
res=(*pSetClipper)(lpdds, lpddc);
|
||||
res=(*pSetClipper)(lpdds, lpddc);
|
||||
|
||||
if (res)
|
||||
OutTraceE("SetClipper: ERROR res=%x(%s)\n", res, ExplainDDError(res));
|
||||
return res;
|
||||
|
52
dll/msvfwhook.cpp
Normal file
52
dll/msvfwhook.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
#include "dxwnd.h"
|
||||
#include "dxwcore.hpp"
|
||||
#include "syslibs.h"
|
||||
#include "dxhook.h"
|
||||
#include "Vfw.h"
|
||||
|
||||
#define DXWDECLARATIONS TRUE
|
||||
#include "msvfwhook.h"
|
||||
#undef DXWDECLARATIONS
|
||||
|
||||
FARPROC Remap_vfw_ProcAddress(LPCSTR proc, HMODULE hModule)
|
||||
{
|
||||
if (!strcmp(proc,"ICSendMessage")){
|
||||
pICSendMessage=(ICSendMessage_Type)(*pGetProcAddress)(hModule, proc);
|
||||
OutTraceD("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pICSendMessage);
|
||||
return (FARPROC)extICSendMessage;
|
||||
}
|
||||
if (!strcmp(proc,"ICOpen")){
|
||||
pICOpen=(ICOpen_Type)(*pGetProcAddress)(hModule, proc);
|
||||
OutTraceD("GetProcAddress: hooking proc=%s at addr=%x\n", ProcToString(proc), pICOpen);
|
||||
return (FARPROC)extICOpen;
|
||||
}
|
||||
|
||||
// NULL -> keep the original call address
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void HookMSV4WLibs(HMODULE module)
|
||||
{
|
||||
void *tmp;
|
||||
tmp = HookAPI(module, "MSVFW32.dll", NULL, "ICSendMessage", extICSendMessage);
|
||||
if(tmp) pICSendMessage = (ICSendMessage_Type)tmp;
|
||||
tmp = HookAPI(module, "MSVFW32.dll", NULL, "ICOpen", extICOpen);
|
||||
if(tmp) pICOpen = (ICOpen_Type)tmp;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
LRESULT WINAPI extICSendMessage(HIC hic, UINT wMsg, DWORD_PTR dw1, DWORD_PTR dw2)
|
||||
{
|
||||
LRESULT res;
|
||||
OutTraceD("ICSendMessage: hic=%x wMsg=%x dw1=%x dw2=%x\n", hic, wMsg, dw1, dw2);
|
||||
return 0;
|
||||
res=(*pICSendMessage)(hic, wMsg, dw1, dw2);
|
||||
return res;
|
||||
}
|
||||
|
||||
HIC WINAPI extICOpen(DWORD fccType, DWORD fccHandler, UINT wMode)
|
||||
{
|
||||
OutTraceD("ICOpen: fccType=%x fccHandler=%x wMode=%x\n", fccType, fccHandler, wMode);
|
||||
return (HIC)0;
|
||||
}
|
26
dll/msvfwhook.h
Normal file
26
dll/msvfwhook.h
Normal file
@ -0,0 +1,26 @@
|
||||
#include "Vfw.h"
|
||||
|
||||
extern FARPROC Remap_vfw_ProcAddress(LPCSTR, HMODULE);
|
||||
extern void HookMSV4WLibs(HMODULE);
|
||||
|
||||
typedef LRESULT (WINAPI * ICSendMessage_Type)(HIC, UINT, DWORD_PTR, DWORD_PTR);
|
||||
typedef HIC (WINAPI *ICOpen_Type)(DWORD, DWORD, UINT);
|
||||
|
||||
extern LRESULT WINAPI extICSendMessage(HIC, UINT, DWORD_PTR, DWORD_PTR);
|
||||
extern HIC WINAPI extICOpen(DWORD, DWORD, UINT);
|
||||
|
||||
#ifdef DXWDECLARATIONS
|
||||
#undef DXWEXTERN
|
||||
#undef DXWINITIALIZED
|
||||
#define DXWEXTERN
|
||||
#define DXWINITIALIZED = NULL
|
||||
#else
|
||||
#undef DXWEXTERN
|
||||
#undef DXWINITIALIZED
|
||||
#define DXWEXTERN extern
|
||||
#define DXWINITIALIZED
|
||||
#endif
|
||||
|
||||
// MSVFW32.dll:
|
||||
DXWEXTERN ICSendMessage_Type pICSendMessage;
|
||||
DXWEXTERN ICOpen_Type pICOpen;
|
@ -8,6 +8,7 @@
|
||||
#include "dxwcore.hpp"
|
||||
#include "dxhook.h"
|
||||
#include "glhook.h"
|
||||
#include "msvfwhook.h"
|
||||
#include "syslibs.h"
|
||||
#include "dxhelper.h"
|
||||
#include "hddraw.h"
|
||||
@ -1210,7 +1211,7 @@ LONG WINAPI MyChangeDisplaySettings(char *fname, DEVMODE *lpDevMode, DWORD dwfla
|
||||
if(dwflags==CDS_FULLSCREEN) dwflags=0; // no FULLSCREEN
|
||||
res=(*ChangeDisplaySettings)(&TryMode, dwflags);
|
||||
OutTraceD("%s: fixed size=(%d x %d) bpp=%d res=%x(%s)\n",
|
||||
fname, NewMode.dmPelsHeight, NewMode.dmPelsWidth, NewMode.dmBitsPerPel,
|
||||
fname, NewMode.dmPelsWidth, NewMode.dmPelsHeight, NewMode.dmBitsPerPel,
|
||||
res, ExplainDisplaySettingsRetcode(res));
|
||||
return res;
|
||||
}
|
||||
@ -1465,7 +1466,8 @@ BOOL WINAPI extGetMessage(LPMSG lpMsg, HWND hwnd, UINT wMsgFilterMin, UINT wMsgF
|
||||
#define SYSLIBIDX_OLE32 3
|
||||
#define SYSLIBIDX_DIRECTDRAW 4
|
||||
#define SYSLIBIDX_OPENGL 5
|
||||
#define SYSLIBIDX_MAX 6 // array size
|
||||
#define SYSLIBIDX_MSVFW 6
|
||||
#define SYSLIBIDX_MAX 7 // array size
|
||||
HMODULE SysLibs[SYSLIBIDX_MAX];
|
||||
char *SysNames[SYSLIBIDX_MAX]={
|
||||
"kernel32.dll",
|
||||
@ -1473,7 +1475,8 @@ char *SysNames[SYSLIBIDX_MAX]={
|
||||
"GDI32.dll",
|
||||
"ole32.dll",
|
||||
"ddraw.dll",
|
||||
"opengl32.dll"
|
||||
"opengl32.dll",
|
||||
"msvfw32.dll"
|
||||
};
|
||||
char *SysNames2[SYSLIBIDX_MAX]={
|
||||
"kernel32",
|
||||
@ -1481,7 +1484,8 @@ char *SysNames2[SYSLIBIDX_MAX]={
|
||||
"GDI32",
|
||||
"ole32",
|
||||
"ddraw",
|
||||
"opengl32"
|
||||
"opengl32",
|
||||
"msvfw32"
|
||||
};
|
||||
extern void HookModule(HMODULE, int);
|
||||
extern void HookSysLibs(HMODULE);
|
||||
@ -1701,9 +1705,13 @@ FARPROC WINAPI extGetProcAddress(HMODULE hModule, LPCSTR proc)
|
||||
}
|
||||
break;
|
||||
case SYSLIBIDX_OPENGL:
|
||||
//default:
|
||||
if(!(dxw.dwFlags2 & HOOKOPENGL)) break;
|
||||
if (remap=Remap_gl_ProcAddress(proc, hModule)) return remap;
|
||||
break;
|
||||
case SYSLIBIDX_MSVFW:
|
||||
if (remap=Remap_vfw_ProcAddress(proc, hModule)) return remap;
|
||||
break;
|
||||
//default:
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -118,17 +118,13 @@
|
||||
#define IDC_MODALSTYLE 1069
|
||||
#define IDC_KEEPASPECTRATIO 1070
|
||||
#define IDC_LIMITRESOURCES 1071
|
||||
#define IDC_FORCEWINRESIZE 1072
|
||||
#define IDC_LIMITRESOURCES2 1072
|
||||
#define IDC_SUPPRESSIME 1072
|
||||
#define IDC_DISABLEGAMMARAMP 1073
|
||||
#define IDC_SETCOMPATIBILITY 1073
|
||||
#define IDC_FIXNCHITTEST 1074
|
||||
#define IDC_LIMITFPS 1075
|
||||
#define IDC_SKIPFPS 1076
|
||||
#define IDC_SHOWFPS 1077
|
||||
#define IDC_HIDEMULTIMONITOR 1078
|
||||
#define IDC_TIMESLIDER 1078
|
||||
#define IDC_TIMESTRETCH 1079
|
||||
#define IDC_TIMESPEED 1079
|
||||
#define IDC_HOOKOPENGL 1080
|
||||
@ -137,17 +133,18 @@
|
||||
#define IDC_SHOWFPSOVERLAY 1083
|
||||
#define IDC_FAKEVERSION 1084
|
||||
#define IDC_COMBOTS 1085
|
||||
#define IDC_SUPPRESSCLIPPING2 1085
|
||||
#define IDC_FULLRECTBLT 1085
|
||||
#define IDC_NOPALETTEUPDATE 1086
|
||||
#define IDC_LIST2 1088
|
||||
#define IDC_LISTTS 1088
|
||||
#define IDC_LISTFAKE 1089
|
||||
#define IDC_TABPANEL 1090
|
||||
#define IDC_WINDOWIZE 1091
|
||||
#define IDC_NOBANNER 1092
|
||||
#define IDC_NOBANNER2 1093
|
||||
#define IDC_STARTDEBUG 1093
|
||||
#define IDC_WIREFRAME 1094
|
||||
#define IDC_DISABLEGAMMARAMP 1095
|
||||
#define IDC_FORCEWINRESIZE 1096
|
||||
#define IDC_TIMESLIDER 1097
|
||||
#define ID_MODIFY 32771
|
||||
#define ID_DELETE 32772
|
||||
#define ID_ADD 32773
|
||||
|
@ -27,6 +27,7 @@ void CTabOpenGL::DoDataExchange(CDataExchange* pDX)
|
||||
CDialog::DoDataExchange(pDX);
|
||||
CTargetDlg *cTarget = ((CTargetDlg *)(this->GetParent()->GetParent()));
|
||||
DDX_Check(pDX, IDC_HOOKOPENGL, cTarget->m_HookOpenGL);
|
||||
DDX_Check(pDX, IDC_WIREFRAME, cTarget->m_WireFrame);
|
||||
DDX_Text(pDX, IDC_OPENGLLIB, cTarget->m_OpenGLLib);
|
||||
}
|
||||
|
||||
|
@ -90,6 +90,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
|
||||
m_FakeVersion = FALSE;
|
||||
m_FullRectBlt = FALSE;
|
||||
m_NoPaletteUpdate = FALSE;
|
||||
m_WireFrame = FALSE;
|
||||
m_InitX = 0;
|
||||
m_InitY = 0;
|
||||
m_MaxX = 0;
|
||||
|
@ -98,6 +98,7 @@ public:
|
||||
BOOL m_LimitResources;
|
||||
BOOL m_SuppressIME;
|
||||
BOOL m_SetCompatibility;
|
||||
BOOL m_WireFrame;
|
||||
int m_InitX;
|
||||
int m_InitY;
|
||||
int m_MaxX;
|
||||
|
Binary file not shown.
@ -391,10 +391,11 @@ IDD_TAB_OPENGL DIALOGEX 0, 0, 300, 240
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
GROUPBOX "OpenGL",IDC_STATIC,7,3,140,58
|
||||
LTEXT "Custom OpenGL library",IDC_STATIC,15,29,110,9
|
||||
GROUPBOX "OpenGL",IDC_STATIC,7,3,140,72
|
||||
LTEXT "Custom OpenGL library",IDC_STATIC,15,39,110,9
|
||||
CONTROL "Hook OpenGL",IDC_HOOKOPENGL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,15,115,10
|
||||
EDITTEXT IDC_OPENGLLIB,13,41,126,14,ES_AUTOHSCROLL
|
||||
EDITTEXT IDC_OPENGLLIB,13,51,126,14,ES_AUTOHSCROLL
|
||||
CONTROL "Show Wireframe",IDC_WIREFRAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,25,115,10
|
||||
END
|
||||
|
||||
IDD_TAB_COMPAT DIALOGEX 0, 0, 300, 240
|
||||
|
Binary file not shown.
@ -26,6 +26,8 @@ static char THIS_FILE[] = __FILE__;
|
||||
extern UINT m_StartToTray;
|
||||
extern UINT m_InitialState;
|
||||
extern char m_ConfigFileName[20+1];
|
||||
extern BOOL Inject(DWORD, const char *);
|
||||
|
||||
PRIVATEMAP *pTitles; // global ptr: get rid of it!!
|
||||
TARGETMAP *pTargets; // idem.
|
||||
|
||||
@ -438,6 +440,7 @@ void CDxwndhostView::OnModify()
|
||||
dlg.m_ShowFPSOverlay = TargetMaps[i].flags2 & SHOWFPSOVERLAY ? 1 : 0;
|
||||
dlg.m_TimeStretch = TargetMaps[i].flags2 & TIMESTRETCH ? 1 : 0;
|
||||
dlg.m_HookOpenGL = TargetMaps[i].flags2 & HOOKOPENGL ? 1 : 0;
|
||||
dlg.m_WireFrame = TargetMaps[i].flags2 & WIREFRAME ? 1 : 0;
|
||||
dlg.m_FakeVersion = TargetMaps[i].flags2 & FAKEVERSION ? 1 : 0;
|
||||
dlg.m_FullRectBlt = TargetMaps[i].flags2 & FULLRECTBLT ? 1 : 0;
|
||||
dlg.m_NoPaletteUpdate = TargetMaps[i].flags2 & NOPALETTEUPDATE ? 1 : 0;
|
||||
@ -545,6 +548,7 @@ void CDxwndhostView::OnModify()
|
||||
if(dlg.m_ShowFPSOverlay) TargetMaps[i].flags2 |= SHOWFPSOVERLAY;
|
||||
if(dlg.m_TimeStretch) TargetMaps[i].flags2 |= TIMESTRETCH;
|
||||
if(dlg.m_HookOpenGL) TargetMaps[i].flags2 |= HOOKOPENGL;
|
||||
if(dlg.m_WireFrame) TargetMaps[i].flags2 |= WIREFRAME;
|
||||
if(dlg.m_FakeVersion) TargetMaps[i].flags2 |= FAKEVERSION;
|
||||
if(dlg.m_FullRectBlt) TargetMaps[i].flags2 |= FULLRECTBLT;
|
||||
if(dlg.m_NoPaletteUpdate) TargetMaps[i].flags2 |= NOPALETTEUPDATE;
|
||||
@ -845,6 +849,7 @@ void CDxwndhostView::OnAdd()
|
||||
if(dlg.m_ShowFPSOverlay) TargetMaps[i].flags2 |= SHOWFPSOVERLAY;
|
||||
if(dlg.m_TimeStretch) TargetMaps[i].flags2 |= TIMESTRETCH;
|
||||
if(dlg.m_HookOpenGL) TargetMaps[i].flags2 |= HOOKOPENGL;
|
||||
if(dlg.m_WireFrame) TargetMaps[i].flags2 |= WIREFRAME;
|
||||
if(dlg.m_FakeVersion) TargetMaps[i].flags2 |= FAKEVERSION;
|
||||
if(dlg.m_FullRectBlt) TargetMaps[i].flags2 |= FULLRECTBLT;
|
||||
if(dlg.m_NoPaletteUpdate) TargetMaps[i].flags2 |= NOPALETTEUPDATE;
|
||||
@ -1194,18 +1199,10 @@ DWORD WINAPI StartDebug(void *p)
|
||||
res=MessageBoxEx(0, DebugMessage, "Continue stepping?", MB_YESNO | MB_ICONQUESTION, NULL);
|
||||
if(res!=IDYES) step=FALSE;
|
||||
}
|
||||
if(1){
|
||||
// DLL injection:
|
||||
char buf[MAX_PATH] = {0};
|
||||
BOOL Injected;
|
||||
extern BOOL Inject(DWORD, const char *);
|
||||
GetFullPathName("dxinj.dll", MAX_PATH, buf, NULL);
|
||||
Injected=Inject(pinfo.dwProcessId, buf);
|
||||
if(!Injected){
|
||||
sprintf(DebugMessage,"Injection error: pid=%x dll=%s", pinfo.dwProcessId, buf);
|
||||
MessageBoxEx(0, DebugMessage, "Injection", MB_ICONEXCLAMATION, NULL);
|
||||
}
|
||||
// end of DLL injection
|
||||
GetFullPathName("dxwnd.dll", MAX_PATH, path, NULL);
|
||||
if(!Inject(pinfo.dwProcessId, path)){
|
||||
sprintf(DebugMessage,"Injection error: pid=%x dll=%s", pinfo.dwProcessId, path);
|
||||
MessageBoxEx(0, DebugMessage, "Injection", MB_ICONEXCLAMATION, NULL);
|
||||
}
|
||||
break;
|
||||
case CREATE_THREAD_DEBUG_EVENT:
|
||||
|
Loading…
x
Reference in New Issue
Block a user