fix: #64 Size of MSG is different on Win32 and Win64

This commit is contained in:
yuanyuanxiang
2025-04-01 03:57:38 +08:00
parent 2dbdc1860f
commit 1492ef4bd2
4 changed files with 102 additions and 14 deletions

View File

@@ -241,3 +241,86 @@ inline bool WriteBitmap(LPBITMAPINFO bmpInfo, const void* bmpData, const std::st
}
return false;
}
#ifdef _WIN32
#ifdef _WINDOWS
#include <afxwin.h>
#else
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
class MSG32 { // <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ(32λ)
public:
uint32_t hwnd;
uint32_t message;
uint32_t wParam;
uint32_t lParam;
uint32_t time;
POINT pt;
MSG32(const void* buffer, int size) {
if (size == sizeof(MSG32)) {
memcpy(this, buffer, sizeof(MSG32));
}
else {
memset(this, 0, sizeof(MSG32));
}
}
MSG32() {
memset(this, 0, sizeof(MSG32));
}
MSG32* Create(const void* buffer, int size) {
if (size == sizeof(MSG32)) {
memcpy(this, buffer, sizeof(MSG32));
}
else {
memset(this, 0, sizeof(MSG32));
}
return this;
}
};
// Windows <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϢMSG<53><47>32λ<32><CEBB>64λϵͳ<CFB5>´<EFBFBD>С<EFBFBD><D0A1>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>¿<EFBFBD>ƽ̨<C6BD>ܹ<EFBFBD>Զ<EFBFBD>̿<EFBFBD><CCBF><EFBFBD><EFBFBD>
// <20><>Ҫʹ<D2AA><CAB9><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ(ͳһ<CDB3><D2BB><EFBFBD><EFBFBD>64λwindows <20><>MSG<53><47><EFBFBD><EFBFBD>)
class MSG64 { // <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ(64λ)
public:
uint64_t hwnd;
uint64_t message;
uint64_t wParam;
uint64_t lParam;
uint64_t time;
POINT pt;
MSG64(const MSG& msg) :hwnd((uint64_t)msg.hwnd), message(msg.message), wParam(msg.wParam),
lParam(msg.lParam), time(msg.time), pt(msg.pt) {}
MSG64(const MSG32& msg) :hwnd((uint64_t)msg.hwnd), message(msg.message), wParam(msg.wParam),
lParam(msg.lParam), time(msg.time), pt(msg.pt) {}
MSG64(const void* buffer, int size) {
if (size == sizeof(MSG64)) {
memcpy(this, buffer, sizeof(MSG64));
}
else {
memset(this, 0, sizeof(MSG64));
}
}
MSG64() {
memset(this, 0, sizeof(MSG64));
}
MSG64* Create(const MSG32* msg32) {
hwnd = msg32->hwnd;
message = msg32->message;
wParam = msg32->wParam;
lParam = msg32->lParam;
time = msg32->time;
pt = msg32->pt;
return this;
}
};
#endif