-
Notifications
You must be signed in to change notification settings - Fork 1
/
Widget.h
160 lines (123 loc) · 5.2 KB
/
Widget.h
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#pragma once
#define WINDOW_TITLE_MAX_LEN 256
#define WINDOW_CLASS_MAX_LEN 256
#define WINDOWID_FLSERVER_MENUIDSUMVIEW 0x800c
#define WINDOWID_FLSERVER_STATUSFRAME 0xe900
#define WIDGET_WM_INIT_WIDGETS 0xeeff
#include <string>
#include <memory>
#include "../flhookplugin_sdk/headers/FLHook.h"
using namespace std;
namespace raincious
{
namespace FLHookPlugin
{
namespace Revelation
{
namespace Widget
{
class WidgetBase
{
public:
WidgetBase();
virtual ~WidgetBase();
virtual void create(HWND parent, uint top, uint left, uint width, uint height);
// Automatically call in every second for reloading data
virtual void tick();
// Self event proc
virtual LRESULT CALLBACK proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
// Automatically call when window event been fired (You need to check if thats your event)
virtual void onCreate(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
virtual void onClose(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
virtual void onDestory(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
virtual void onSize(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, uint top, uint left, uint width, uint height);
virtual void onMove(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, uint top, uint left, uint width, uint height);
virtual void onCommand(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
virtual void onUpdate(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
virtual void onEvent(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
virtual void onPaint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, HDC windowClientArea);
virtual void onDisable();
virtual void onRemove();
// Status set & get
void setDisable(bool dis);
bool isDisabled();
void setPause(bool pus);
bool isPaused();
protected:
typedef struct WidgetSubClassInfo
{
WidgetBase* Instance = NULL;
WNDPROC OldProc = NULL;
};
bool disabled = false;
bool paused = false;
HWND widget = NULL;
static UINT_PTR SubClassIDs;
static map <UINT_PTR, WidgetSubClassInfo> InstanceSubClassIDMap;
static LRESULT CALLBACK WidgetProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
static WidgetBase* GetInstanceBySubClassID(UINT_PTR uIdSubclass);
static bool SetWidgetSubClassProc(WidgetBase* instance);
static bool RemoveWidgetSubClass(WidgetBase* instance);
static LRESULT WINAPI CallWidgetDefaultProc(UINT_PTR uIdSubclass, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
};
// Mounted widgets
typedef map <const char*, unique_ptr<WidgetBase>> MountedWidgetList;
// Window weights for searching FLServer window
typedef map <HWND, uint> WindowWeights;
// Information for window searching and binding
typedef struct ProcessSearchInfo
{
DWORD processID = 0;
WindowWeights rootWindows;
} processSearchInfo;
class Main
{
public:
static uint Width;
static uint Height;
static Main* Get();
static void Free();
// Mount and unmount a widget
bool mount(const char* name, unique_ptr<WidgetBase> widget);
bool demount(const char* name);
void run();
protected:
static Main* Instance;
bool paused = false;
MountedWidgetList list;
RECT windowOriginalRect, windowExpectingRect, widgetTargetOriginalRect;
uint windowExpectingWidth = 0, windowExpectingHeight = 0, windowOriginalWidth = 0, windowOriginalHeight = 0;
uint widgetTargetOriginalWidth = 0, widgetTargetOriginalHeight = 0;
uint widgetCurrentTop = 0, widgetCurrentLeft = 0, widgetCurrentWidth = 0, widgetCurrentHeight = 0;
HANDLE tickThreadHandle = NULL, uiThreadHandle = NULL;
HWND window = NULL, widgetWindow = NULL;
HHOOK windowEventHook = NULL;
WNDPROC oldWindowProc = NULL;
bool threadStopSignal = false, tickThreadRunning = false, uiThreadRunning = false;
static BOOL CALLBACK EnumServerWindow(HWND hwnd, LPARAM lParam);
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static void UIDataUpdateThread();
static void UIMessagingThread();
Main();
~Main();
// Call when adding widgets to the widget area
void create();
void tick();
// Total windows event hooks
void onCreate(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void onDestory(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void onClose(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void onSize(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void onMove(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void onCommand(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void onUpdate(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void onPaint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, HDC windowClientArea);
void onEvent(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
// Window size related functions
void fixWindowSize();
void fixWidgetSize();
};
}
}
}
}