2013-05-02 12:17:06 -04:00
|
|
|
#define _WIN32_WINNT 0x0600
|
2012-12-24 10:20:23 -05:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <ddraw.h>
|
|
|
|
#include "dxwnd.h"
|
2013-01-04 10:30:38 -05:00
|
|
|
#include "dxwcore.hpp"
|
2012-12-24 10:20:23 -05:00
|
|
|
#include "dxhook.h"
|
|
|
|
#include "syslibs.h"
|
|
|
|
#include "dxhelper.h"
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
HWND hwnd;
|
|
|
|
WNDPROC wndproc;
|
|
|
|
} wndstack_entry;
|
|
|
|
|
2013-07-21 12:38:09 -04:00
|
|
|
#define MAXWNDHSTACK 256
|
2012-12-24 10:20:23 -05:00
|
|
|
|
|
|
|
wndstack_entry WhndStack[MAXWNDHSTACK];
|
|
|
|
static int WhndTOS = 0;
|
|
|
|
|
|
|
|
void WhndStackInit()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void WhndStackPush(HWND hwnd, WNDPROC wndproc)
|
|
|
|
{
|
|
|
|
int StackIdx;
|
|
|
|
// wndproc values of 0xFFFFxxxx type seems to be error codes rather than valid callback addresses ....
|
|
|
|
if (((DWORD)wndproc & 0xFFFF0000) == 0xFFFF0000) return;
|
|
|
|
//OutTraceD("DEBUG: WNDPROC STACK push hwnd=%x, wndproc=%x\n", hwnd, wndproc);
|
|
|
|
// try update first...
|
|
|
|
for(StackIdx=0; StackIdx<WhndTOS; StackIdx++)
|
|
|
|
if (WhndStack[StackIdx].hwnd==hwnd) {
|
|
|
|
WhndStack[StackIdx].wndproc=wndproc;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// push if not already there.
|
2013-07-21 12:38:09 -04:00
|
|
|
if(WhndTOS>=MAXWNDHSTACK) {
|
|
|
|
char sMsg[80];
|
|
|
|
sprintf(sMsg, "Table overflow: %d entries used", MAXWNDHSTACK);
|
|
|
|
MessageBox(0, sMsg, "WhndStackPush", MB_OK | MB_ICONEXCLAMATION);
|
|
|
|
return;
|
|
|
|
}
|
2012-12-24 10:20:23 -05:00
|
|
|
WhndStack[WhndTOS].hwnd=hwnd;
|
|
|
|
WhndStack[WhndTOS].wndproc=wndproc;
|
|
|
|
WhndTOS++;
|
|
|
|
}
|
|
|
|
|
|
|
|
WNDPROC WhndGetWindowProc(HWND hwnd)
|
|
|
|
{
|
|
|
|
int StackIdx;
|
|
|
|
for(StackIdx=0; StackIdx<MAXWNDHSTACK; StackIdx++) if (WhndStack[StackIdx].hwnd==hwnd) {
|
|
|
|
//OutTraceD("DEBUG: WNDPROC STACK pop hwnd=%x, wndproc=%x\n", hwnd, WhndStack[StackIdx].wndproc);
|
|
|
|
return WhndStack[StackIdx].wndproc;
|
|
|
|
}
|
|
|
|
//OutTraceD("DEBUG: WNDPROC STACK pop hwnd=%x, wndproc=NULL\n", hwnd);
|
|
|
|
return NULL;
|
|
|
|
}
|