Apply clang-format code style to all source files

This commit is contained in:
icex2
2019-10-20 00:50:40 +02:00
parent c600e1a423
commit c3bc8782f4
401 changed files with 13844 additions and 11361 deletions
+26 -14
View File
@@ -16,31 +16,44 @@ static void *avs_heap;
static void *std_heap;
#endif
void avs_context_init(struct property_node *config,
uint32_t avs_heap_size, uint32_t std_heap_size,
avs_log_writer_t log_writer, void *log_writer_ctx)
void avs_context_init(
struct property_node *config,
uint32_t avs_heap_size,
uint32_t std_heap_size,
avs_log_writer_t log_writer,
void *log_writer_ctx)
{
avs_heap = VirtualAlloc(NULL, avs_heap_size, MEM_RESERVE | MEM_COMMIT,
PAGE_READWRITE);
avs_heap = VirtualAlloc(
NULL, avs_heap_size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
if (avs_heap == NULL) {
log_fatal("Failed to VirtualAlloc %d byte AVS heap: %08x",
avs_heap_size, (unsigned int) GetLastError());
log_fatal(
"Failed to VirtualAlloc %d byte AVS heap: %08x",
avs_heap_size,
(unsigned int) GetLastError());
}
#ifdef AVS_HAS_STD_HEAP
std_heap = VirtualAlloc(NULL, std_heap_size, MEM_RESERVE | MEM_COMMIT,
PAGE_READWRITE);
std_heap = VirtualAlloc(
NULL, std_heap_size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
if (std_heap == NULL) {
log_fatal("Failed to VirtualAlloc %d byte \"std\" heap: %08x",
std_heap_size, (unsigned int) GetLastError());
log_fatal(
"Failed to VirtualAlloc %d byte \"std\" heap: %08x",
std_heap_size,
(unsigned int) GetLastError());
}
#endif
#ifdef AVS_HAS_STD_HEAP
avs_boot(config, std_heap, std_heap_size, avs_heap, avs_heap_size,
log_writer, log_writer_ctx);
avs_boot(
config,
std_heap,
std_heap_size,
avs_heap,
avs_heap_size,
log_writer,
log_writer_ctx);
#else
/* AVS v2.16.xx and I suppose onward uses a unified heap */
avs_boot(config, avs_heap, avs_heap_size, NULL, log_writer, log_writer_ctx);
@@ -57,4 +70,3 @@ void avs_context_fini(void)
VirtualFree(avs_heap, 0, MEM_RELEASE);
}
+6 -3
View File
@@ -9,9 +9,12 @@
#define AVS_HAS_STD_HEAP
#endif
void avs_context_init(struct property_node *config,
uint32_t avs_heap_size, uint32_t std_heap_size,
avs_log_writer_t log_writer, void *log_writer_ctx);
void avs_context_init(
struct property_node *config,
uint32_t avs_heap_size,
uint32_t std_heap_size,
avs_log_writer_t log_writer,
void *log_writer_ctx);
void avs_context_fini(void);
#endif
+48 -24
View File
@@ -11,14 +11,14 @@
#include "util/str.h"
PSMAP_BEGIN(ea3_ident_psmap)
PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct ea3_ident, softid,"/ea3/id/softid","")
PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct ea3_ident, hardid,"/ea3/id/hardid","")
PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct ea3_ident, softid, "/ea3/id/softid", "")
PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct ea3_ident, hardid, "/ea3/id/hardid", "")
PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct ea3_ident, pcbid, "/ea3/id/pcbid", "")
PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident, model, "/ea3/soft/model")
PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident, dest, "/ea3/soft/dest")
PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident, spec, "/ea3/soft/spec")
PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident, rev, "/ea3/soft/rev")
PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident, ext, "/ea3/soft/ext")
PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident, dest, "/ea3/soft/dest")
PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident, spec, "/ea3/soft/spec")
PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident, rev, "/ea3/soft/rev")
PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident, ext, "/ea3/soft/ext")
PSMAP_END
void ea3_ident_init(struct ea3_ident *ident)
@@ -26,8 +26,8 @@ void ea3_ident_init(struct ea3_ident *ident)
memset(ident, 0, sizeof(*ident));
}
bool ea3_ident_from_property(struct ea3_ident *ident,
struct property *ea3_config)
bool ea3_ident_from_property(
struct ea3_ident *ident, struct property *ea3_config)
{
return property_psmap_import(ea3_config, NULL, ident, ea3_ident_psmap);
}
@@ -40,8 +40,8 @@ void ea3_ident_hardid_from_ethernet(struct ea3_ident *ident)
result = avs_net_ctrl(1, &netif, sizeof(netif));
if (result < 0) {
log_fatal("avs_net_ctrl call to get MAC address returned error: %d",
result);
log_fatal(
"avs_net_ctrl call to get MAC address returned error: %d", result);
}
ident->hardid[0] = '0';
@@ -49,12 +49,17 @@ void ea3_ident_hardid_from_ethernet(struct ea3_ident *ident)
ident->hardid[2] = '0';
ident->hardid[3] = '0';
hex_encode_uc(netif.mac_addr, sizeof(netif.mac_addr),
ident->hardid + 4, sizeof(ident->hardid) - 4);
hex_encode_uc(
netif.mac_addr,
sizeof(netif.mac_addr),
ident->hardid + 4,
sizeof(ident->hardid) - 4);
}
bool ea3_ident_invoke_module_init(struct ea3_ident *ident,
const struct module_context *module, struct property_node *app_config)
bool ea3_ident_invoke_module_init(
struct ea3_ident *ident,
const struct module_context *module,
struct property_node *app_config)
{
char sidcode_short[17];
char sidcode_long[21];
@@ -63,8 +68,14 @@ bool ea3_ident_invoke_module_init(struct ea3_ident *ident,
/* Set up security env vars */
str_format(security_code, lengthof(security_code), "G*%s%s%s%s",
ident->model, ident->dest, ident->spec, ident->rev);
str_format(
security_code,
lengthof(security_code),
"G*%s%s%s%s",
ident->model,
ident->dest,
ident->spec,
ident->rev);
std_setenv("/env/boot/version", "0.0.0");
std_setenv("/env/profile/security_code", security_code);
@@ -76,8 +87,15 @@ bool ea3_ident_invoke_module_init(struct ea3_ident *ident,
/* Set up the short sidcode string, let dll_entry_init mangle it */
str_format(sidcode_short, lengthof(sidcode_short), "%s%s%s%s%s",
ident->model, ident->dest, ident->spec, ident->rev, ident->ext);
str_format(
sidcode_short,
lengthof(sidcode_short),
"%s%s%s%s%s",
ident->model,
ident->dest,
ident->spec,
ident->rev,
ident->ext);
ok = module_context_invoke_init(module, sidcode_short, app_config);
@@ -95,21 +113,28 @@ bool ea3_ident_invoke_module_init(struct ea3_ident *ident,
/* Set up long-form sidcode env var */
str_format(sidcode_long, lengthof(sidcode_long), "%s:%s:%s:%s:%s",
ident->model, ident->dest, ident->spec, ident->rev, ident->ext);
str_format(
sidcode_long,
lengthof(sidcode_long),
"%s:%s:%s:%s:%s",
ident->model,
ident->dest,
ident->spec,
ident->rev,
ident->ext);
std_setenv("/env/profile/soft_id_code", sidcode_long);
return true;
}
void ea3_ident_to_property(const struct ea3_ident *ident,
struct property *ea3_config)
void ea3_ident_to_property(
const struct ea3_ident *ident, struct property *ea3_config)
{
struct property_node *node;
int i;
for (i = 0 ; ea3_ident_psmap[i].type != 0xFF ; i++) {
for (i = 0; ea3_ident_psmap[i].type != 0xFF; i++) {
node = property_search(ea3_config, 0, ea3_ident_psmap[i].path);
if (node != NULL) {
@@ -119,4 +144,3 @@ void ea3_ident_to_property(const struct ea3_ident *ident,
property_psmap_export(ea3_config, NULL, ident, ea3_ident_psmap);
}
+8 -6
View File
@@ -29,12 +29,14 @@ struct ea3_ident {
};
void ea3_ident_init(struct ea3_ident *ident);
bool ea3_ident_from_property(struct ea3_ident *ident,
struct property *ea3_config);
bool ea3_ident_from_property(
struct ea3_ident *ident, struct property *ea3_config);
void ea3_ident_hardid_from_ethernet(struct ea3_ident *ident);
bool ea3_ident_invoke_module_init(struct ea3_ident *ident,
const struct module_context *module, struct property_node *app_config);
void ea3_ident_to_property(const struct ea3_ident *ident,
struct property *ea3_config);
bool ea3_ident_invoke_module_init(
struct ea3_ident *ident,
const struct module_context *module,
struct property_node *app_config);
void ea3_ident_to_property(
const struct ea3_ident *ident, struct property *ea3_config);
#endif
+42 -26
View File
@@ -5,8 +5,8 @@
#include <stdio.h>
#include <stdlib.h>
#include "imports/avs.h"
#include "imports/avs-ea3.h"
#include "imports/avs.h"
#include "launcher/avs-context.h"
#include "launcher/ea3-config.h"
@@ -15,11 +15,11 @@
#include "launcher/property.h"
#include "launcher/stubs.h"
#include "util/codepage.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/mem.h"
#include "util/str.h"
#include "util/codepage.h"
/* Gratuitous API changes orz */
static AVS_LOG_WRITER(log_callback, chars, nchars, ctx)
@@ -46,23 +46,23 @@ static AVS_LOG_WRITER(log_callback, chars, nchars, ctx)
}
utf16 = xmalloc(sizeof(*utf16) * utf16_len);
result = MultiByteToWideChar(CP_SHIFT_JIS, 0, chars, nchars, utf16,
utf16_len);
result =
MultiByteToWideChar(CP_SHIFT_JIS, 0, chars, nchars, utf16, utf16_len);
if (result == 0) {
abort();
}
utf8_len = WideCharToMultiByte(CP_UTF8, 0, utf16, utf16_len, NULL, 0,
NULL, NULL);
utf8_len =
WideCharToMultiByte(CP_UTF8, 0, utf16, utf16_len, NULL, 0, NULL, NULL);
if (utf8_len == 0) {
abort();
}
utf8 = xmalloc(utf8_len + 2);
result = WideCharToMultiByte(CP_UTF8, 0, utf16, utf16_len, utf8, utf8_len,
NULL, NULL);
result = WideCharToMultiByte(
CP_UTF8, 0, utf16, utf16_len, utf8, utf8_len, NULL, NULL);
if (result == 0) {
abort();
@@ -123,17 +123,18 @@ int main(int argc, const char **argv)
return EXIT_FAILURE;
}
/* If enabled, wait for a remote debugger to attach. Spawning launcher
with a debugger crashes it for some reason (e.g. on jubeat08). However,
/* If enabled, wait for a remote debugger to attach. Spawning launcher
with a debugger crashes it for some reason (e.g. on jubeat08). However,
starting the launcher separately and attaching a remote debugger works */
if (options.remote_debugger) {
log_info("Waiting until debugger attaches to remote process...");
while (true) {
BOOL res = FALSE;
if (!CheckRemoteDebuggerPresent(GetCurrentProcess(), &res)) {
log_fatal("CheckRemoteDebuggerPresent failed: %08x",
log_fatal(
"CheckRemoteDebuggerPresent failed: %08x",
(unsigned int) GetLastError());
}
@@ -149,8 +150,14 @@ int main(int argc, const char **argv)
/* Start up AVS */
if (options.logfile != NULL) {
logfile = CreateFileA(options.logfile, GENERIC_WRITE, FILE_SHARE_READ,
NULL, CREATE_ALWAYS, 0, NULL);
logfile = CreateFileA(
options.logfile,
GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
CREATE_ALWAYS,
0,
NULL);
} else {
logfile = INVALID_HANDLE_VALUE;
}
@@ -162,14 +169,17 @@ int main(int argc, const char **argv)
log_fatal("%s: /config missing", options.avs_config_path);
}
avs_context_init(avs_config_root,
options.avs_heap_size, options.std_heap_size,
log_callback, logfile);
avs_context_init(
avs_config_root,
options.avs_heap_size,
options.std_heap_size,
log_callback,
logfile);
boot_property_free(avs_config);
log_to_external(log_body_misc, log_body_info, log_body_warning,
log_body_fatal);
log_to_external(
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
/* Load game DLL */
@@ -177,14 +187,21 @@ int main(int argc, const char **argv)
/* Load hook DLLs */
for (i = 0 ; i < options.hook_dlls.nitems ; i++) {
for (i = 0; i < options.hook_dlls.nitems; i++) {
hook_dll = *array_item(char *, &options.hook_dlls, i);
if (LoadLibraryA(hook_dll) == NULL) {
LPSTR buffer;
LPSTR buffer;
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR) &buffer, 0, NULL);
FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR) &buffer,
0,
NULL);
log_fatal("%s: Failed to load hook DLL: %s", hook_dll, buffer);
@@ -208,8 +225,8 @@ int main(int argc, const char **argv)
ea3_ident_init(&ea3);
if (!ea3_ident_from_property(&ea3, ea3_config)) {
log_fatal("%s: Error reading IDs from config file",
options.ea3_config_path);
log_fatal(
"%s: Error reading IDs from config file", options.ea3_config_path);
}
if (options.softid != NULL) {
@@ -273,4 +290,3 @@ int main(int argc, const char **argv)
return EXIT_SUCCESS;
}
+15 -9
View File
@@ -18,8 +18,15 @@ void module_context_init(struct module_context *module, const char *path)
if (module->dll == NULL) {
LPSTR buffer;
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR) &buffer, 0, NULL);
FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR) &buffer,
0,
NULL);
log_fatal("%s: Failed to load game DLL: %s", path, buffer);
@@ -29,8 +36,10 @@ void module_context_init(struct module_context *module, const char *path)
module->path = str_dup(path);
}
bool module_context_invoke_init(const struct module_context *module,
char *sidcode, struct property_node *app_config)
bool module_context_invoke_init(
const struct module_context *module,
char *sidcode,
struct property_node *app_config)
{
dll_entry_init_t init;
@@ -42,8 +51,7 @@ bool module_context_invoke_init(const struct module_context *module,
if (init == NULL) {
log_fatal(
"%s: dll_entry_init not found. Is this a game DLL?",
module->path);
"%s: dll_entry_init not found. Is this a game DLL?", module->path);
}
return init(sidcode, app_config);
@@ -60,8 +68,7 @@ bool module_context_invoke_main(const struct module_context *module)
if (main_ == NULL) {
log_fatal(
"%s: dll_entry_main not found. Is this a game DLL?",
module->path);
"%s: dll_entry_main not found. Is this a game DLL?", module->path);
}
return main_();
@@ -79,4 +86,3 @@ void module_context_fini(struct module_context *module)
FreeLibrary(module->dll);
}
}
+4 -2
View File
@@ -11,8 +11,10 @@ struct module_context {
};
void module_context_init(struct module_context *module, const char *path);
bool module_context_invoke_init(const struct module_context *module,
char *sidcode, struct property_node *app_config);
bool module_context_invoke_init(
const struct module_context *module,
char *sidcode,
struct property_node *app_config);
bool module_context_invoke_main(const struct module_context *module);
void module_context_fini(struct module_context *module);
+31 -22
View File
@@ -27,7 +27,7 @@ void options_init(struct options *options)
bool options_read_cmdline(struct options *options, int argc, const char **argv)
{
for (int i = 1 ; i < argc ; i++) {
for (int i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
switch (argv[i][1]) {
case 'A':
@@ -80,7 +80,8 @@ bool options_read_cmdline(struct options *options, int argc, const char **argv)
return false;
}
options->avs_heap_size = (size_t)strtol(argv[++i],NULL,0);
options->avs_heap_size =
(size_t) strtol(argv[++i], NULL, 0);
if (options->avs_heap_size == 0) {
return false;
@@ -94,7 +95,8 @@ bool options_read_cmdline(struct options *options, int argc, const char **argv)
return false;
}
options->std_heap_size = (size_t)strtol(argv[++i],NULL,0);
options->std_heap_size =
(size_t) strtol(argv[++i], NULL, 0);
if (options->std_heap_size == 0) {
return false;
@@ -108,7 +110,8 @@ bool options_read_cmdline(struct options *options, int argc, const char **argv)
return false;
}
*array_append(const char *,&options->hook_dlls)=argv[++i];
*array_append(const char *, &options->hook_dlls) =
argv[++i];
break;
@@ -145,29 +148,35 @@ bool options_read_cmdline(struct options *options, int argc, const char **argv)
void options_print_usage(void)
{
fprintf(stderr,
"Usage: launcher.exe [launcher options...] <app.dll> [hooks options...] \n"
"\n"
" The following options can be specified before the app DLL path:\n"
"\n"
" -A [filename] App configuration file (default: prop/app-config.xml)\n"
" -V [filename] AVS configuration file (default: prop/avs-config.xml)\n"
" -E [filename] ea3 configuration file (default: prop/ea3-config.xml)\n"
" -H [bytes] AVS heap size (default: 16777216)\n"
fprintf(
stderr,
"Usage: launcher.exe [launcher options...] <app.dll> [hooks "
"options...] \n"
"\n"
" The following options can be specified before the app DLL "
"path:\n"
"\n"
" -A [filename] App configuration file (default: "
"prop/app-config.xml)\n"
" -V [filename] AVS configuration file (default: "
"prop/avs-config.xml)\n"
" -E [filename] ea3 configuration file (default: "
"prop/ea3-config.xml)\n"
" -H [bytes] AVS heap size (default: 16777216)\n"
#ifdef AVS_HAS_STD_HEAP
" -T [bytes] 'std' heap size (default 16777216)\n"
" -T [bytes] 'std' heap size (default 16777216)\n"
#endif
" -P [pcbid] Specify PCBID (default: use ea3 config)\n"
" -R [pcbid] Specify Soft ID (default: use ea3 config)\n"
" -K [filename] Load hook DLL (can be specified multiple times)\n"
" -Y [filename] Log to a file in addition to the console\n"
" -D Halt the launcher before bootstrapping AVS until a"
" remote debugger is attached\n"
);
" -P [pcbid] Specify PCBID (default: use ea3 config)\n"
" -R [pcbid] Specify Soft ID (default: use ea3 config)\n"
" -K [filename] Load hook DLL (can be specified multiple "
"times)\n"
" -Y [filename] Log to a file in addition to the console\n"
" -D Halt the launcher before bootstrapping AVS "
"until a"
" remote debugger is attached\n");
}
void options_fini(struct options *options)
{
array_fini(&options->hook_dlls);
}
+4 -7
View File
@@ -49,12 +49,10 @@ struct property *boot_property_load(const char *filename)
buffer = xmalloc(nbytes);
prop = property_create(
PROPERTY_FLAG_READ |
PROPERTY_FLAG_WRITE |
PROPERTY_FLAG_CREATE |
PROPERTY_FLAG_APPEND,
buffer,
nbytes);
PROPERTY_FLAG_READ | PROPERTY_FLAG_WRITE | PROPERTY_FLAG_CREATE |
PROPERTY_FLAG_APPEND,
buffer,
nbytes);
rewind(f);
if (!property_insert_read(prop, 0, boot_property_fread, f_keyhole)) {
@@ -76,4 +74,3 @@ void boot_property_free(struct property *prop)
property_destroy(prop);
free(buffer);
}
+30 -40
View File
@@ -31,7 +31,7 @@ typedef void (*bt_get_fucked_t)(uint32_t /* even in 64-bit */ context);
static HMODULE STDCALL my_GetModuleHandleA(const char *name);
static HMODULE STDCALL my_GetModuleHandleW(const wchar_t *name);
static void * STDCALL my_GetProcAddress(HMODULE dll, const char *name);
static void *STDCALL my_GetProcAddress(HMODULE dll, const char *name);
static void bt_get_ikey_status(struct ikey_status *ik);
@@ -43,47 +43,40 @@ static void bt_fcheck_init(void);
static void *bt_fcheck_main(void *unknown);
static void bt_fcheck_finish(void);
static HMODULE (STDCALL *real_GetModuleHandleA)(const char *name);
static HMODULE (STDCALL *real_GetModuleHandleW)(const wchar_t *name);
static void * (STDCALL *real_GetProcAddress)(HMODULE dll, const char *name);
static HMODULE(STDCALL *real_GetModuleHandleA)(const char *name);
static HMODULE(STDCALL *real_GetModuleHandleW)(const wchar_t *name);
static void *(STDCALL *real_GetProcAddress)(HMODULE dll, const char *name);
static struct stub stub_list[] = {
#if AVS_VERSION >= 1600
{ "k_bt0001", bt_get_ikey_status },
{ "k_bt0002", bt_get_fucked },
{"k_bt0001", bt_get_ikey_status},
{"k_bt0002", bt_get_fucked},
#else
{ "bt_get_ikey_status", bt_get_ikey_status },
{"bt_get_ikey_status", bt_get_ikey_status},
#endif
{ "bt_fcheck_init", bt_fcheck_init },
{ "bt_fcheck_main", bt_fcheck_main },
{ "bt_fcheck_finish", bt_fcheck_finish },
{"bt_fcheck_init", bt_fcheck_init},
{"bt_fcheck_main", bt_fcheck_main},
{"bt_fcheck_finish", bt_fcheck_finish},
};
static struct hook_symbol stub_hook_syms[] = {
{
.name = "GetModuleHandleA",
.patch = my_GetModuleHandleA,
.link = (void *)&real_GetModuleHandleA
},
{
.name = "GetModuleHandleW",
.patch = my_GetModuleHandleW,
.link = (void *)&real_GetModuleHandleW
},
{
.name = "GetProcAddress",
.patch = my_GetProcAddress,
.link = (void *)&real_GetProcAddress
},
{.name = "GetModuleHandleA",
.patch = my_GetModuleHandleA,
.link = (void *) &real_GetModuleHandleA},
{.name = "GetModuleHandleW",
.patch = my_GetModuleHandleW,
.link = (void *) &real_GetModuleHandleW},
{.name = "GetProcAddress",
.patch = my_GetProcAddress,
.link = (void *) &real_GetProcAddress},
};
static HMODULE STDCALL my_GetModuleHandleA(const char *name)
{
/* Check name for null because winio32 calls this with null parameters
when the module is loaded on win xp (doesn't happen on win 7) */
if ( name != NULL &&
(_stricmp(name, "kbt.dll") == 0 ||
_stricmp(name, "kld.dll") == 0)) {
if (name != NULL &&
(_stricmp(name, "kbt.dll") == 0 || _stricmp(name, "kld.dll") == 0)) {
name = NULL;
}
@@ -94,16 +87,15 @@ static HMODULE STDCALL my_GetModuleHandleW(const wchar_t *name)
{
/* Check name for null because winio32 calls this with null parameters
when the module is loaded on win xp (doesn't happen on win 7) */
if ( name != NULL &&
(wcsicmp(name, L"kbt.dll") == 0 ||
wcsicmp(name, L"kld.dll") == 0)) {
if (name != NULL &&
(wcsicmp(name, L"kbt.dll") == 0 || wcsicmp(name, L"kld.dll") == 0)) {
name = NULL;
}
return real_GetModuleHandleW(name);
}
static void * STDCALL my_GetProcAddress(HMODULE dll, const char *name)
static void *STDCALL my_GetProcAddress(HMODULE dll, const char *name)
{
size_t i;
@@ -111,7 +103,7 @@ static void * STDCALL my_GetProcAddress(HMODULE dll, const char *name)
return real_GetProcAddress(dll, name);
}
for (i = 0 ; i < lengthof(stub_list) ; i++) {
for (i = 0; i < lengthof(stub_list); i++) {
if (strcmp(stub_list[i].name, name) == 0) {
return stub_list[i].proc;
}
@@ -125,10 +117,7 @@ static void * STDCALL my_GetProcAddress(HMODULE dll, const char *name)
void stubs_init(void)
{
hook_table_apply(
NULL,
"kernel32.dll",
stub_hook_syms,
lengthof(stub_hook_syms));
NULL, "kernel32.dll", stub_hook_syms, lengthof(stub_hook_syms));
}
static void bt_get_ikey_status(struct ikey_status *ik)
@@ -155,7 +144,8 @@ static void bt_get_fucked(bt_get_fucked_t callback, uint32_t ctx)
#endif
static void bt_fcheck_init(void)
{}
{
}
static void *bt_fcheck_main(void *unknown)
{
@@ -163,5 +153,5 @@ static void *bt_fcheck_main(void *unknown)
}
static void bt_fcheck_finish(void)
{}
{
}