diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/events.h | 19 | ||||
| -rw-r--r-- | include/hashmap.h | 26 | ||||
| -rw-r--r-- | include/module.h | 41 | ||||
| -rw-r--r-- | include/parser.h | 4 | ||||
| -rw-r--r-- | include/pdb.h | 5 | ||||
| -rw-r--r-- | include/stack_walk.h | 3 | ||||
| -rw-r--r-- | include/types.h | 2 | ||||
| -rw-r--r-- | include/utils.h | 23 |
8 files changed, 123 insertions, 0 deletions
diff --git a/include/events.h b/include/events.h new file mode 100644 index 0000000..65131c6 --- /dev/null +++ b/include/events.h @@ -0,0 +1,19 @@ +#pragma once + +extern void handle_create_process(); + +extern void handle_create_thread(); + +extern void handle_exception(); + +extern void handle_exit_process(); + +extern void handle_exit_thread(); + +extern void handle_load_dll(); + +extern void handle_unload_dll(); + +extern void handle_output_debug_string(); + +extern void handle_rip(); diff --git a/include/hashmap.h b/include/hashmap.h new file mode 100644 index 0000000..88490e7 --- /dev/null +++ b/include/hashmap.h @@ -0,0 +1,26 @@ +#pragma once + +#include "types.h" + +struct element { + u64 name; + u32 start; + u32 end; + u32 unwind_offset; + u32 psl; +}; + +struct hashmap { + u32 capacity; + u32 size; + + struct element* arr; +}; + +extern struct hashmap create_unordered_flat(); + +extern struct element* insert_elem(struct hashmap* map, u32 start, u32 end, u64 name); + +extern struct element* find_elem(struct hashmap* map, u32 start); + +extern void iterate(struct hashmap* map); diff --git a/include/module.h b/include/module.h new file mode 100644 index 0000000..e94e156 --- /dev/null +++ b/include/module.h @@ -0,0 +1,41 @@ +#pragma once + +#include <Windows.h> + +#include "types.h" +#include "hashmap.h" + +struct module { + void* base_addr; + u8** functions_name; + u32* functions_start; + u32* functions_end; + u32* functions_unwind; + u32 functions_count; + u32 functions_capacity; + // u32 functions_name_capacity; + // u32 function_start_capacity; + // u32 function_end_capacity; + // u32 function_unwind_capacity; + + IMAGE_DOS_HEADER dos_header; + IMAGE_NT_HEADERS64 nt_header; +#ifdef HASHMAP + struct hashmap symbols; +#endif + u8 name[256U]; +}; + + +extern struct module modules[64U]; +extern u64 modules_list; + +extern u8 add_module(); + +extern void remove_module(u8 index); + +#ifdef HASHMAP +extern struct element* find_function(struct module* module, u32 rip_offset); +#else +extern u32 find_function(struct module* module, u64 rip_offset); +#endif // HASHMAP diff --git a/include/parser.h b/include/parser.h new file mode 100644 index 0000000..1f93aac --- /dev/null +++ b/include/parser.h @@ -0,0 +1,4 @@ +#pragma once + +#include "types.h" +extern u8 interpreter(const char* str_cmd, size_t str_cmd_len); diff --git a/include/pdb.h b/include/pdb.h new file mode 100644 index 0000000..965ccc3 --- /dev/null +++ b/include/pdb.h @@ -0,0 +1,5 @@ +#pragma once + +#include "module.h" + +extern void open_pdb(const char* pdb_path, struct module* module); diff --git a/include/stack_walk.h b/include/stack_walk.h new file mode 100644 index 0000000..783cbb9 --- /dev/null +++ b/include/stack_walk.h @@ -0,0 +1,3 @@ +#pragma once + +extern void walk_stack(void* ctx); diff --git a/include/types.h b/include/types.h index a3b0942..463b73f 100644 --- a/include/types.h +++ b/include/types.h @@ -1,3 +1,5 @@ +#pragma once + #include <stdint.h> typedef uint8_t u8; diff --git a/include/utils.h b/include/utils.h new file mode 100644 index 0000000..738ba9f --- /dev/null +++ b/include/utils.h @@ -0,0 +1,23 @@ +#pragma once + +#include "types.h" + +#if defined (_DEBUG) +#define assert(x) if (!(x)) __debugbreak(); +#else +#define assert(x) (x) +#endif + +void print(const char* format, ...); + +u8 is_alpha(char c); + +u8 is_decimal_digit(char c); + +u8 is_hexadecimal_digit(char c); + +void u64toa(u64 number, char* str, u32 base); + +u64 atou64(const char* str, u32 len); + +u8 read_memory(const void* addr, void* buffer, size_t size); |
