mirror of
https://github.com/Maschell/WiiUPluginLoader.git
synced 2024-11-22 08:09:16 +01:00
Added support for the Video Memory hook.
This commit is contained in:
parent
40bb31885a
commit
7f491da297
@ -54,6 +54,7 @@
|
||||
#include "patcher/hooks_patcher.h"
|
||||
#include "patcher/hooks_patcher_static.h"
|
||||
#include "plugin/dynamic_linking_defines.h"
|
||||
#include "myutils/mem_utils.h"
|
||||
#include "myutils/mocha.h"
|
||||
#include "myutils/libntfs.h"
|
||||
#include "myutils/libfat.h"
|
||||
@ -135,6 +136,7 @@ extern "C" int32_t Menu_Main(int32_t argc, char **argv) {
|
||||
CSettings::destroyInstance();
|
||||
PluginLoader::destroyInstance();
|
||||
|
||||
MemoryUtils::init();
|
||||
}
|
||||
|
||||
DEBUG_FUNCTION_LINE("Patch own stuff\n");
|
||||
@ -171,6 +173,7 @@ extern "C" int32_t Menu_Main(int32_t argc, char **argv) {
|
||||
}
|
||||
|
||||
if(result == APPLICATION_CLOSE_APPLY || result == APPLICATION_CLOSE_APPLY_MEMORY) {
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_VID_MEM);
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_KERNEL);
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_FS);
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_OVERLAY);
|
||||
|
@ -76,6 +76,14 @@ uint32_t MemoryMapping::getHeapSize() {
|
||||
return getAreaSizeFromPageTable(MEMORY_START_PLUGIN_HEAP,MEMORY_START_PLUGIN_HEAP_END - MEMORY_START_PLUGIN_HEAP);
|
||||
}
|
||||
|
||||
uint32_t MemoryMapping::getVideoMemoryAddress() {
|
||||
return MEMORY_START_VIDEO_SPACE;
|
||||
}
|
||||
|
||||
uint32_t MemoryMapping::getVideoMemorySize() {
|
||||
return getAreaSizeFromPageTable(MEMORY_START_VIDEO_SPACE,MEMORY_START_VIDEO_SPACE_END - MEMORY_START_VIDEO_SPACE);
|
||||
}
|
||||
|
||||
void MemoryMapping::searchEmptyMemoryRegions() {
|
||||
DEBUG_FUNCTION_LINE("Searching for empty memory.\n");
|
||||
|
||||
|
37
src/myutils/mem_utils.cpp
Normal file
37
src/myutils/mem_utils.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2018 Maschell
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
#include <utils/logger.h>
|
||||
#include <wups.h>
|
||||
#include <stdarg.h>
|
||||
#include "dynamic_libs/os_functions.h"
|
||||
#include "mem_utils.h"
|
||||
#include "mymemory/memory_mapping.h"
|
||||
|
||||
|
||||
int32_t memHandle __attribute__((section(".data"))) = -1;
|
||||
|
||||
void MemoryUtils::init(){
|
||||
memHandle = MEMCreateExpHeapEx((void*)MemoryMapping::getVideoMemoryAddress(), MemoryMapping::getVideoMemorySize(), 0);
|
||||
}
|
||||
|
||||
void* MemoryUtils::alloc(uint32_t size, int32_t align){
|
||||
return MEMAllocFromExpHeapEx(memHandle,size, align);
|
||||
}
|
||||
|
||||
void MemoryUtils::free(void * ptr){
|
||||
MEMFreeToExpHeap(memHandle,ptr);
|
||||
}
|
32
src/myutils/mem_utils.h
Normal file
32
src/myutils/mem_utils.h
Normal file
@ -0,0 +1,32 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2018 Maschell
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
#ifndef __MEMORY_UTILS_UTILS_H_
|
||||
#define __SCREEN_UTILS_H_
|
||||
|
||||
class MemoryUtils {
|
||||
public:
|
||||
static void init();
|
||||
|
||||
static void* alloc(uint32_t size, int32_t align);
|
||||
|
||||
static void free(void * ptr);
|
||||
private:
|
||||
MemoryUtils() {}
|
||||
~MemoryUtils() {}
|
||||
|
||||
};
|
||||
#endif
|
@ -14,6 +14,7 @@
|
||||
#include "common/common.h"
|
||||
#include "common/retain_vars.h"
|
||||
#include "myutils/overlay_helper.h"
|
||||
#include "myutils/mem_utils.h"
|
||||
#include "kernel/syscalls.h"
|
||||
|
||||
void CallHook(wups_loader_hook_type_t hook_type) {
|
||||
@ -112,7 +113,12 @@ void CallHookEx(wups_loader_hook_type_t hook_type, int32_t plugin_index_needed)
|
||||
((void (*)(wups_loader_init_kernel_args_t))((uint32_t*)func_ptr) )(args);
|
||||
plugin_data->kernel_init_done = true;
|
||||
}
|
||||
} else {
|
||||
} else if(hook_type == WUPS_LOADER_HOOK_INIT_VID_MEM){
|
||||
wups_loader_init_vid_mem_args_t args;
|
||||
args.vid_mem_alloc_ptr = &MemoryUtils::alloc;
|
||||
args.vid_mem_free_ptr = &MemoryUtils::free;
|
||||
((void (*)(wups_loader_init_vid_mem_args_t))((uint32_t*)func_ptr) )(args);
|
||||
}else {
|
||||
DEBUG_FUNCTION_LINE("ERROR: HOOK TYPE WAS NOT IMPLEMENTED %08X \n",hook_type);
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user