WIP: bemanitools 6

highly WIP, what’s “working”:
- iidxhook 9 to 24
- launcher
- inject
This commit is contained in:
icex2
2024-06-12 17:41:20 +02:00
parent 81821490bd
commit acf2498939
693 changed files with 20706 additions and 8272 deletions

View File

View File

@@ -0,0 +1,74 @@
#define LOG_MODULE "procmon-dllmain"
#include <windows.h>
#include "core/log-bt-ext.h"
#include "core/log-bt.h"
#include "core/thread-crt-ext.h"
#include "launcher/property-util.h"
#include "procmon/config.h"
#include "procmon/procmon.h"
#include "util/fs.h"
// TODO move this to a separate "standalone dllmain bootstrap" module in sdk
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
{
struct property *property;
struct property_node *root_node;
struct procmon_config config;
// TODO provide compatibility mode here? ctx set to...something?
// to figure out if this is loaded/run by any bemanitools loader
// or not.
if (reason == DLL_PROCESS_ATTACH) {
core_thread_crt_ext_impl_set();
core_log_bt_ext_init_with_stderr();
// TODO make this somehow configurable?
// have additional stuff on procmon configuration xml
// <dllmain>
// <log>
// have the same log stuff here as with launcher like file, level, rotation etc
// </log>
// <procmon>
// ....
// </procmon>
// </dllmain>
core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_INFO);
log_info("DLL_PROCESS_ATTACH");
if (path_exists("procmon-config.xml")) {
property = property_util_load("procmon-config.xml");
root_node = property_search(NULL, "hook/procmon");
if (!root_node) {
// TODO error handling
}
procmon_config_init(&config);
procmon_config_load(root_node, &config);
procmon_init(&config);
} else {
log_warning("No configuration file found, defaulting");
procmon_config_init(&config);
procmon_init(&config);
}
} else if (reason == DLL_PROCESS_DETACH) {
log_info("DLL_PROCESS_DETACH");
procmon_fini();
core_log_bt_fini();
}
return TRUE;
}

View File

@@ -0,0 +1,15 @@
void btsdk_dllmain_bootstrap_process_attach()
{
// TODO have the whole stuff to bootstrap independently of hook API
// with logging setup etc.
// provide stuff via recovering from command line args or env vars?
}
void btsdk_dllmain_bootstrap_process_detach()
{
// TODO cleanup
core_log_bt_fini();
}

View File

@@ -0,0 +1,12 @@
#ifndef DLLMAIN_BOOTSTRAP_H
#define DLLMAIN_BOOTSTRAP_H
#include <stdint.h>
#include "imports/avs.h"
void btsdk_dllmain_bootstrap_process_attach();
void btsdk_dllmain_bootstrap_process_detach();
#endif

0
btsdk/example/hook/log.c Normal file
View File

View File

@@ -0,0 +1,21 @@
void btapi_thread_impl_set()
{
}
int btapi_thread_create(int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority)
{
}
void btapi_thread_join(int thread_id, int *result)
{
}
void btapi_thread_destroy(int thread_id)
{
}

View File

@@ -0,0 +1,3 @@
void btapi_thread_impl_set();