Code cleanup

This commit is contained in:
Maschell 2021-09-18 12:21:27 +02:00
parent a968fb3277
commit ed792716fe
3 changed files with 25 additions and 42 deletions

View File

@ -62,43 +62,26 @@ void CallHookEx(plugin_information_t *pluginInformation, wups_loader_hook_type_t
void *func_ptr = hook_data->func_pointer;
if (func_ptr != nullptr) {
//DEBUG_FUNCTION_LINE("function pointer is %08x",func_ptr);
if (hook_type == WUPS_LOADER_HOOK_INIT_PLUGIN) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_DEINIT_PLUGIN) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_APPLICATION_STARTS) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_FUNCTIONS_PATCHED) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_APPLICATION_ENDS) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_APPLICATION_REQUESTS_EXIT) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_INIT_WUT_MALLOC) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_FINI_WUT_MALLOC) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_INIT_WUT_NEWLIB) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_FINI_WUT_NEWLIB) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_INIT_WUT_STDCPP) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_FINI_WUT_STDCPP) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_INIT_WUT_SOCKETS) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_FINI_WUT_SOCKETS) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_RELEASE_FOREGROUND) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND) {
((void (*)()) ((uint32_t *) func_ptr))();
} else if (hook_type == WUPS_LOADER_HOOK_VSYNC) {
if (hook_type == WUPS_LOADER_HOOK_INIT_PLUGIN ||
hook_type == WUPS_LOADER_HOOK_DEINIT_PLUGIN ||
hook_type == WUPS_LOADER_HOOK_APPLICATION_STARTS ||
hook_type == WUPS_LOADER_HOOK_FUNCTIONS_PATCHED ||
hook_type == WUPS_LOADER_HOOK_APPLICATION_ENDS ||
hook_type == WUPS_LOADER_HOOK_APPLICATION_REQUESTS_EXIT ||
hook_type == WUPS_LOADER_HOOK_INIT_WUT_MALLOC ||
hook_type == WUPS_LOADER_HOOK_FINI_WUT_MALLOC ||
hook_type == WUPS_LOADER_HOOK_INIT_WUT_NEWLIB ||
hook_type == WUPS_LOADER_HOOK_FINI_WUT_NEWLIB ||
hook_type == WUPS_LOADER_HOOK_INIT_WUT_STDCPP ||
hook_type == WUPS_LOADER_HOOK_FINI_WUT_STDCPP ||
hook_type == WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB ||
hook_type == WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB ||
hook_type == WUPS_LOADER_HOOK_INIT_WUT_SOCKETS ||
hook_type == WUPS_LOADER_HOOK_FINI_WUT_SOCKETS ||
hook_type == WUPS_LOADER_HOOK_RELEASE_FOREGROUND ||
hook_type == WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND ||
hook_type == WUPS_LOADER_HOOK_VSYNC
){
((void (*)()) ((uint32_t *) func_ptr))();
} else {
DEBUG_FUNCTION_LINE("######################################");

View File

@ -77,12 +77,12 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des
// }
auto distance = static_cast<int32_t>(value) - static_cast<int32_t>(target);
if (distance > 0x1FFFFFC || distance < -0x1FFFFFC) {
if (trampolin_data == NULL) {
if (trampolin_data == nullptr) {
DEBUG_FUNCTION_LINE("***24-bit relative branch cannot hit target. Trampolin isn't provided");
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X", value, target, distance);
return false;
} else {
relocation_trampolin_entry_t *freeSlot = NULL;
relocation_trampolin_entry_t *freeSlot = nullptr;
for (uint32_t i = 0; i < trampolin_data_length; i++) {
// We want to override "old" relocations of imports
// Pending relocations have the status RELOC_TRAMP_IMPORT_IN_PROGRESS.
@ -96,7 +96,7 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des
break;
}
}
if (freeSlot == NULL) {
if (freeSlot == nullptr) {
DEBUG_FUNCTION_LINE("***24-bit relative branch cannot hit target. Trampolin data list is full");
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X", value, target, target - (uint32_t) &(freeSlot->trampolin[0]));
return false;

View File

@ -24,7 +24,7 @@ extern "C" int32_t WUPSLoadAndLinkByDataHandle(const plugin_data_handle *plugin_
if (plugin_data_handle_list != nullptr && plugin_data_handle_list_size != 0) {
for (uint32_t i = 0; i < plugin_data_handle_list_size; i++) {
plugin_data_handle handle = plugin_data_handle_list[i];
PluginData *pluginData = (PluginData *) handle;
auto *pluginData = (PluginData *) handle;
DEBUG_FUNCTION_LINE("Saving plugin data %08X", pluginData);
PluginDataPersistence::save(&gLinkOnReload.plugin_data[gLinkOnReload.number_used_plugins], *pluginData);
@ -44,7 +44,7 @@ extern "C" int32_t WUPSDeletePluginContainer(const plugin_container_handle *hand
if (handle_list != nullptr && handle_list_size != 0) {
for (uint32_t i = 0; i < handle_list_size; i++) {
auto handle = handle_list[i];
PluginContainer *pluginContainer = (PluginContainer *) handle;
auto *pluginContainer = (PluginContainer *) handle;
DEBUG_FUNCTION_LINE("Delete plugin container: %08X", pluginContainer);
delete pluginContainer;
}