mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-17 02:09:17 +01:00
Add new IPC function
This commit is contained in:
parent
aed66958e9
commit
532d6f8454
@ -1,6 +1,7 @@
|
||||
#include "retain_vars.h"
|
||||
#include "utils/overlay_helper.h"
|
||||
replacement_data_t gbl_replacement_data __attribute__((section(".data")));
|
||||
to_link_and_load_data_t gbl_to_link_and_load_data[MAXIMUM_PLUGINS] __attribute__((section(".data")));
|
||||
dyn_linking_relocation_data_t gbl_dyn_linking_data __attribute__((section(".data")));
|
||||
|
||||
bool gInBackground __attribute__((section(".data"))) = false;
|
||||
|
@ -6,6 +6,7 @@
|
||||
//#include <dynamic_libs/gx2_functions.h>
|
||||
|
||||
extern replacement_data_t gbl_replacement_data;
|
||||
extern to_link_and_load_data_t gbl_to_link_and_load_data[MAXIMUM_PLUGINS];
|
||||
extern dyn_linking_relocation_data_t gbl_dyn_linking_data;
|
||||
|
||||
extern bool g_NotInLoader;
|
||||
|
@ -126,7 +126,6 @@ void afterLoadAndLink() {
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_PLUGIN);
|
||||
}
|
||||
|
||||
|
||||
extern "C" void doStart(int argc, char **argv);
|
||||
// We need to wrap it to make sure the main function is called AFTER our code.
|
||||
// The compiler tries to optimize this otherwise and calling the main function earlier
|
||||
@ -178,6 +177,7 @@ extern "C" void doStart(int argc, char **argv) {
|
||||
//initMemory();
|
||||
//SplashScreen(1, "Memory mapping was completed!", 0,0);
|
||||
|
||||
memset(gbl_to_link_and_load_data,0, sizeof(gbl_to_link_and_load_data));
|
||||
|
||||
// Init space
|
||||
DynamicLinkingHelper::getInstance()->clearAll();
|
||||
@ -201,7 +201,6 @@ extern "C" void doStart(int argc, char **argv) {
|
||||
pluginLoader->loadAndLinkPlugins(pluginList);
|
||||
pluginLoader->clearPluginInformation(pluginList);
|
||||
delete pluginLoader;
|
||||
|
||||
afterLoadAndLink();
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("Mapping was already done\n");
|
||||
@ -214,6 +213,29 @@ extern "C" void doStart(int argc, char **argv) {
|
||||
//MemoryMapping::readTestValuesFromMemory();
|
||||
}
|
||||
|
||||
if(gbl_to_link_and_load_data[0].name[0] != 0) {
|
||||
ResolveRelocations();
|
||||
CallHook(WUPS_LOADER_HOOK_DEINIT_PLUGIN);
|
||||
|
||||
// Restore patches as the patched functions could change.
|
||||
RestorePatches();
|
||||
DynamicLinkingHelper::getInstance()->clearAll();
|
||||
|
||||
PluginLoader * pluginLoader = new PluginLoader((void*)PLUGIN_LOCATION_START_ADDRESS, (void*)PLUGIN_LOCATION_END_ADDRESS);
|
||||
std::vector<PluginInformation *> pluginList;
|
||||
for(int i = 0; gbl_to_link_and_load_data[i].name[0] != 0; i++) {
|
||||
PluginInformation * info = PluginInformation::loadPluginInformation(gbl_to_link_and_load_data[i].name);
|
||||
if(info != NULL) {
|
||||
pluginList.push_back(info);
|
||||
}
|
||||
}
|
||||
pluginLoader->loadAndLinkPlugins(pluginList);
|
||||
pluginLoader->clearPluginInformation(pluginList);
|
||||
delete pluginLoader;
|
||||
afterLoadAndLink();
|
||||
memset(gbl_to_link_and_load_data,0, sizeof(gbl_to_link_and_load_data));
|
||||
}
|
||||
|
||||
ResolveRelocations();
|
||||
|
||||
MemoryUtils::init();
|
||||
|
@ -81,6 +81,10 @@ struct replacement_data_t {
|
||||
replacement_data_plugin_t plugin_data[MAXIMUM_PLUGINS];
|
||||
};
|
||||
|
||||
struct to_link_and_load_data_t {
|
||||
char name[256];
|
||||
};
|
||||
|
||||
void new_PatchInvidualMethodHooks(replacement_data_plugin_t * data);
|
||||
void new_RestoreInvidualInstructions(replacement_data_plugin_t * plugin_data);
|
||||
uint32_t new_GetAddressOfFunction(const char * functionName,wups_loader_library_type_t library);
|
||||
|
@ -226,6 +226,43 @@ int ipc_ioctl(ipcmessage *message) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IOCTL_PLUGIN_LOADER_LINK_VIA_INFORMATION_ON_RESTART: {
|
||||
DEBUG_FUNCTION_LINE("IOCTL_PLUGIN_LOADER_LINK_VIA_INFORMATION_ON_RESTART\n");
|
||||
if(message->ioctl.length_in != 8 || message->ioctl.length_io < 4) {
|
||||
res = IPC_ERROR_INVALID_SIZE;
|
||||
} else {
|
||||
plugin_information_handle * plugin_handle_list = (plugin_information_handle *) message->ioctl.buffer_in[0];
|
||||
uint32_t plugin_handle_list_size = (uint32_t) message->ioctl.buffer_in[1];
|
||||
|
||||
//DEBUG_FUNCTION_LINE("plugin_handle_list %08X size %d\n",plugin_handle_list,plugin_handle_list_size);
|
||||
|
||||
uint32_t * linkedCount = (uint32_t *)message->ioctl.buffer_io;
|
||||
*linkedCount = 0;
|
||||
|
||||
int inGlobal = 0;
|
||||
for(uint32_t i = 0; i < plugin_handle_list_size; i++ ) {
|
||||
plugin_information_handle curHandle = plugin_handle_list[i];
|
||||
//DEBUG_FUNCTION_LINE("Adding handle %08X\n",curHandle);
|
||||
if(curHandle != 0/* && (PluginInformation* curInformation = dynamic_cast<PluginInformation*>(curHandle))*/) {
|
||||
PluginInformation* curInformation = (PluginInformation *)curHandle;
|
||||
if(inGlobal<=31){
|
||||
strncpy(gbl_to_link_and_load_data[inGlobal].name, curInformation->getPath().c_str(), 256);
|
||||
inGlobal++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; gbl_to_link_and_load_data[i].name[0] != 0; i++) {
|
||||
//DEBUG_FUNCTION_LINE("%s\n",gbl_to_link_and_load_data[i].name);
|
||||
}
|
||||
|
||||
//DEBUG_FUNCTION_LINE("inGlobal size is %d\n",inGlobal);
|
||||
gInBackground = false;
|
||||
|
||||
*linkedCount = inGlobal;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
res = IPC_ERROR_INVALID_ARG;
|
||||
break;
|
||||
|
@ -16,13 +16,14 @@ extern "C" {
|
||||
#define IPC_ERROR_INVALID_ARG 0xFFFFFFFE
|
||||
#define IPC_ERROR_FAILED_ALLOC 0xFFFFFFFD
|
||||
|
||||
#define IOCTL_OPEN_PLUGIN_LOADER 0x01
|
||||
#define IOCTL_CLOSE_PLUGIN_LOADER 0x02
|
||||
#define IOCTL_PLUGIN_LOADER_GET_INFORMATION_FOR_PATH 0x03
|
||||
#define IOCTL_PLUGIN_LOADER_GET_INFORMATION_LOADED 0x04
|
||||
#define IOCTL_PLUGIN_LOADER_GET_INFORMATION_DETAILS 0x05
|
||||
#define IOCTL_PLUGIN_LOADER_DELETE_INFORMATION 0x06
|
||||
#define IOCTL_PLUGIN_LOADER_LINK_VIA_INFORMATION 0x07
|
||||
#define IOCTL_OPEN_PLUGIN_LOADER 0x01
|
||||
#define IOCTL_CLOSE_PLUGIN_LOADER 0x02
|
||||
#define IOCTL_PLUGIN_LOADER_GET_INFORMATION_FOR_PATH 0x03
|
||||
#define IOCTL_PLUGIN_LOADER_GET_INFORMATION_LOADED 0x04
|
||||
#define IOCTL_PLUGIN_LOADER_GET_INFORMATION_DETAILS 0x05
|
||||
#define IOCTL_PLUGIN_LOADER_DELETE_INFORMATION 0x06
|
||||
#define IOCTL_PLUGIN_LOADER_LINK_VIA_INFORMATION 0x07
|
||||
#define IOCTL_PLUGIN_LOADER_LINK_VIA_INFORMATION_ON_RESTART 0x08
|
||||
|
||||
/* IPC message */
|
||||
typedef struct ipcmessage {
|
||||
|
Loading…
Reference in New Issue
Block a user