forked from Ilyaki/ProtoInput
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAdjustWindowRectHook.cpp
More file actions
57 lines (46 loc) · 1.63 KB
/
Copy pathAdjustWindowRectHook.cpp
File metadata and controls
57 lines (46 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "AdjustWindowRectHook.h"
#include <imgui.h>
namespace Proto
{
int AdjustWindowRectHook::width = 0;
int AdjustWindowRectHook::height = 0;
int AdjustWindowRectHook::posx = 0;
int AdjustWindowRectHook::posy = 0;
BOOL WINAPI Hook_AdjustWindowRect(LPRECT lpRect, DWORD dwStyle, BOOL bMenu)
{
lpRect->top = AdjustWindowRectHook::posy;
lpRect->left = AdjustWindowRectHook::posx;
lpRect->bottom = AdjustWindowRectHook::height + AdjustWindowRectHook::posy;
lpRect->right = AdjustWindowRectHook::width + AdjustWindowRectHook::posx;
return AdjustWindowRect(lpRect, dwStyle, false);;
}
BOOL WINAPI Hook_AdjustWindowRectEx(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle)
{
lpRect->top = AdjustWindowRectHook::posy;
lpRect->left = AdjustWindowRectHook::posx;
lpRect->bottom = AdjustWindowRectHook::height + AdjustWindowRectHook::posy;
lpRect->right = AdjustWindowRectHook::width + AdjustWindowRectHook::posx;
return AdjustWindowRectEx(lpRect, dwStyle, false, dwExStyle);;
}
void AdjustWindowRectHook::ShowGuiStatus()
{
int pos[2] = { posx, posy };
ImGui::InputInt2("Position", &pos[0]);
posx = pos[0];
posy = pos[1];
int size[2] = { width, height };
ImGui::InputInt2("Size", &size[0]);
width = size[0];
height = size[1];
}
void AdjustWindowRectHook::InstallImpl()
{
hookInfoRect = std::get<1>(InstallNamedHook(L"user32", "AdjustWindowRect", Hook_AdjustWindowRect));
hookInfoRectEx = std::get<1>(InstallNamedHook(L"user32", "AdjustWindowRectEx", Hook_AdjustWindowRectEx));
}
void AdjustWindowRectHook::UninstallImpl()
{
UninstallHook(&hookInfoRect);
UninstallHook(&hookInfoRectEx);
}
}