summaryrefslogtreecommitdiff
path: root/csrc/window_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'csrc/window_util.c')
-rw-r--r--csrc/window_util.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/csrc/window_util.c b/csrc/window_util.c
new file mode 100644
index 0000000..41c857a
--- /dev/null
+++ b/csrc/window_util.c
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2018 Iru Cai <mytbk920423@gmail.com>
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include "window_util.h"
+
+wProc windowCallbacks[100]; // 48a010
+int cb_top = 0; // 0x46cad8
+
+extern HWND gwindowHandle;
+
+int register_wait_callback(wProc a1, int a2)
+{
+ cb_top++;
+ windowCallbacks[cb_top] = a1;
+ PostMessageA(gwindowHandle, 0x401, 0, a2);
+ while (1) {
+ MSG msg;
+ if (PeekMessageA(&msg, 0, 0, 0, 1) == 0)
+ continue;
+ if (msg.message == 0x402) {
+ cb_top--;
+ return msg.lParam;
+ }
+ TranslateMessage(&msg);
+ DispatchMessageA(&msg);
+ }
+}
+
+void Post_0402_Message(LPARAM lp)
+{
+ PostMessageA(gwindowHandle, 0x402, 0, lp);
+}