#include "common.h" #include "user32.h" typedef int (WINAPI *MessageBoxAPtr)(HWND hwnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType); typedef int (WINAPI *MessageBoxWPtr)(HWND hwnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType); DLL_EXPORT WINAPI int MessageBoxA(HWND hwnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType) { MessageBoxAPtr proc = (MessageBoxAPtr) getFunction("_user32.dll", "MessageBoxA"); LPSTR buffer = malloc(strlen(lpText) + 1 + 26); strcpy(buffer, "MessageBoxA gruesst Sie!\n"), strcat(buffer, lpText); int result = proc(hwnd, buffer, lpCaption, uType); free(buffer); return result; } DLL_EXPORT WINAPI int MessageBoxW(HWND hwnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType) { MessageBoxWPtr proc = (MessageBoxWPtr) getFunction("_user32.dll", "MessageBoxW"); LPWSTR buffer = malloc(wcslen(lpText) + 1 + 26); wcscpy(buffer, L"MessageBoxW gruesst Sie!\n"); wcscat(buffer, lpText); int result = proc(hwnd, buffer, lpCaption, uType); free(buffer); return result; } DLL_EXPORT WINAPI HMONITOR MonitorFromWindow(HWND hwnd, DWORD dwFlags) { logDebug("MonitorFromWindow: Called"); return (HMONITOR) 1; } DLL_EXPORT WINAPI BOOL GetMonitorInfoA(HMONITOR hMonitor, LPMONITORINFO lpmi) { logDebug("GetMonitorInfo: Called"); if (hMonitor != (HMONITOR) 1) { logWarn("GetMonitorInfoA: Called with invalid hMonitor"); return FALSE; } if (lpmi->cbSize != sizeof(MONITORINFO)) { logWarn("GetMonitorInfoA: Called with invalid lpmi->cbSize"); return FALSE; } lpmi->rcMonitor.left = 0; lpmi->rcMonitor.top = 0; lpmi->rcMonitor.right = GetSystemMetrics(SM_CXSCREEN); lpmi->rcMonitor.bottom = GetSystemMetrics(SM_CYSCREEN); RECT workArea = { 0 }; if (!SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0)) { logError("GetMonitorInfoA: GetSystemParametersInfo failed"); } lpmi->rcWork = workArea; lpmi->dwFlags = MONITORINFOF_PRIMARY; return TRUE; } DLL_EXPORT WINAPI BOOL GetMonitorInfoW(HMONITOR hMonitor, LPMONITORINFO lpmi) { return GetMonitorInfoA(hMonitor, lpmi); }