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

64 lines
1.7 KiB
C++
Raw Normal View History

#define _WIN32_WINNT 0x0600
#define WIN32_LEAN_AND_MEAN
#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <stdio.h>
#include <malloc.h>
#include <ddraw.h>
#include "dxwnd.h"
#include "dxwcore.hpp"
#include "dxhook.h"
#include "syslibs.h"
#include "dxhelper.h"
typedef struct {
HWND hwnd;
WNDPROC wndproc;
} wndstack_entry;
#define MAXWNDHSTACK 256
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 ....
// v2.02.36 using CallWindowProc you can pass WinProc handles, so you don't need to eliminate them!
//if (((DWORD)wndproc & 0xFFFF0000) == 0xFFFF0000) return;
//OutTraceDW("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.
if(WhndTOS>=MAXWNDHSTACK) {
char sMsg[80];
sprintf(sMsg, "Table overflow: %d entries used", MAXWNDHSTACK);
MessageBox(0, sMsg, "WhndStackPush", MB_OK | MB_ICONEXCLAMATION);
return;
}
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) {
//OutTraceDW("DEBUG: WNDPROC STACK pop hwnd=%x, wndproc=%x\n", hwnd, WhndStack[StackIdx].wndproc);
return WhndStack[StackIdx].wndproc;
}
//OutTraceDW("DEBUG: WNDPROC STACK pop hwnd=%x, wndproc=NULL\n", hwnd);
return NULL;
}