summaryrefslogtreecommitdiffhomepage
path: root/src/dbg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dbg.c')
-rw-r--r--src/dbg.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/dbg.c b/src/dbg.c
index 20f0271..c7af49a 100644
--- a/src/dbg.c
+++ b/src/dbg.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2021 Michael Smith <mikesmiffy128@gmail.com>
+ * Copyright © 2022 Michael Smith <mikesmiffy128@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -14,6 +14,12 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
+#include <Windows.h>
+#endif
+
#include "con_.h"
#include "intdefs.h"
#include "ppmagic.h"
@@ -46,4 +52,17 @@ void dbg_asmdump(char *name, const void *p, int len) {
}
}
+#ifdef _WIN32
+usize dbg_toghidra(void *addr) {
+ void *mod;
+ if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
+ GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (ushort *)addr,
+ (HMODULE *)&mod/*please leave me alone*/)) {
+ con_warn("dbg_toghidra: couldn't get base address\n");
+ return 0;
+ }
+ return (char *)addr - (char *)mod + 0x10000000;
+}
+#endif
+
// vi: sw=4 ts=4 noet tw=80 cc=80