mirror of
https://github.com/wiiu-env/AromaBaseModule.git
synced 2025-04-22 15:51:26 +02:00
Compare commits
28 Commits
AromaBaseM
...
main
Author | SHA1 | Date | |
---|---|---|---|
![]() |
08ab912f9a | ||
![]() |
e67f5f9725 | ||
![]() |
c02aed1daa | ||
![]() |
df60ed4401 | ||
![]() |
2349cc1581 | ||
![]() |
db349f0178 | ||
![]() |
4ee72d785b | ||
![]() |
ed4edfc2db | ||
![]() |
2c5f1bb7e2 | ||
![]() |
68fbbf05d7 | ||
![]() |
e89efe1d31 | ||
![]() |
270cd1dabb | ||
![]() |
ca15b44a12 | ||
![]() |
ef42550673 | ||
![]() |
72ff59de95 | ||
![]() |
69a0e31081 | ||
![]() |
4fb8ca0713 | ||
![]() |
a5fb305b2f | ||
![]() |
efcbfefeca | ||
![]() |
7fc494df91 | ||
![]() |
52e9a80255 | ||
![]() |
07e2682f9b | ||
![]() |
1d00a414d2 | ||
![]() |
24013d147f | ||
![]() |
bd836ed3aa | ||
![]() |
e3a1c85c92 | ||
![]() |
4803d90ddf | ||
![]() |
15c0971aae |
10
.github/dependabot.yml
vendored
Normal file
10
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "docker"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
30
.github/workflows/ci.yml
vendored
30
.github/workflows/ci.yml
vendored
@ -9,15 +9,15 @@ jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: clang-format
|
||||
run: |
|
||||
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source
|
||||
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./source
|
||||
build-binary:
|
||||
runs-on: ubuntu-22.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: create version.h
|
||||
run: |
|
||||
git_hash=$(git rev-parse --short "$GITHUB_SHA")
|
||||
@ -42,32 +42,18 @@ jobs:
|
||||
run: |
|
||||
echo REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") >> $GITHUB_ENV
|
||||
echo DATETIME=$(echo $(date '+%Y%m%d-%H%M%S')) >> $GITHUB_ENV
|
||||
echo COMMIT_MESSAGES=$(echo "${{join(github.event.commits.*.message, '||END||') }}" | sed -e 's/||END||/\r\n/g') >> $GITHUB_ENV
|
||||
- uses: actions/download-artifact@master
|
||||
with:
|
||||
name: binary
|
||||
- name: zip artifact
|
||||
run: zip -r ${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip *.wms
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
uses: "softprops/action-gh-release@v2"
|
||||
with:
|
||||
tag_name: ${{ env.REPOSITORY_NAME }}-${{ env.DATETIME }}
|
||||
release_name: Nightly-${{ env.REPOSITORY_NAME }}-${{ env.DATETIME }}
|
||||
draft: false
|
||||
prerelease: true
|
||||
body: |
|
||||
Not a stable release:
|
||||
${{ env.COMMIT_MESSAGES }}
|
||||
- name: Upload Release Asset
|
||||
id: upload-release-asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
||||
asset_path: ./${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip
|
||||
asset_name: ${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip
|
||||
asset_content_type: application/zip
|
||||
generate_release_notes: true
|
||||
name: Nightly-${{ env.REPOSITORY_NAME }}-${{ env.DATETIME }}
|
||||
files: |
|
||||
./${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip
|
8
.github/workflows/pr.yml
vendored
8
.github/workflows/pr.yml
vendored
@ -6,15 +6,15 @@ jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: clang-format
|
||||
run: |
|
||||
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source
|
||||
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./source
|
||||
check-build-with-logging:
|
||||
runs-on: ubuntu-22.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: build binary with logging
|
||||
run: |
|
||||
docker build . -t builder
|
||||
@ -25,7 +25,7 @@ jobs:
|
||||
runs-on: ubuntu-22.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: create version.h
|
||||
run: |
|
||||
git_hash=$(git rev-parse --short "${{ github.event.pull_request.head.sha }}")
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,3 +8,4 @@ build/
|
||||
cmake-build-debug/
|
||||
CMakeLists.txt
|
||||
*.wms
|
||||
*.zip
|
||||
|
@ -1,6 +1,7 @@
|
||||
FROM wiiuenv/devkitppc:20220917
|
||||
FROM ghcr.io/wiiu-env/devkitppc:20241128
|
||||
|
||||
COPY --from=wiiuenv/libfunctionpatcher:20220904 /artifacts $DEVKITPRO
|
||||
COPY --from=wiiuenv/wiiumodulesystem:20221005 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/libfunctionpatcher:20230621 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/wiiumodulesystem:20250208 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/libkernel:20230621 /artifacts $DEVKITPRO
|
||||
|
||||
WORKDIR project
|
||||
|
12
Makefile
12
Makefile
@ -41,7 +41,7 @@ CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__
|
||||
CXXFLAGS := $(CFLAGS) -std=c++20
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -T$(WUMS_ROOT)/share/libfunctionpatcher.ld $(WUMSSPECS)
|
||||
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -Tfunctionpatcher.ld -T$(WUMS_ROOT)/share/libkernel.ld $(WUMSSPECS)
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
CXXFLAGS += -DDEBUG -g
|
||||
@ -53,7 +53,7 @@ CXXFLAGS += -DDEBUG -DVERBOSE_DEBUG -g
|
||||
CFLAGS += -DDEBUG -DVERBOSE_DEBUG -g
|
||||
endif
|
||||
|
||||
LIBS := -lwums -lwut -lfunctionpatcher
|
||||
LIBS := -lwums -lwut -lfunctionpatcher -lkernel
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level
|
||||
@ -79,6 +79,7 @@ export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
DEFFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.def)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -96,7 +97,7 @@ endif
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
||||
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
export OFILES_SRC := $(DEFFILES:.def=.o) $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
|
||||
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
||||
|
||||
@ -145,6 +146,11 @@ $(OFILES_SRC) : $(HFILES_BIN)
|
||||
#-------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.def
|
||||
$(SILENTMSG) $(notdir $<)
|
||||
$(SILENTCMD)rplimportgen $< $*.s $*.ld $(ERROR_FILTER)
|
||||
$(SILENTCMD)$(CC) -x assembler-with-cpp $(ASFLAGS) -c $*.s -o $@ $(ERROR_FILTER)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
|
@ -34,4 +34,4 @@ docker run -it --rm -v ${PWD}:/project aromabasemodule-builder make clean
|
||||
|
||||
## Format the code via docker
|
||||
|
||||
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source -i`
|
||||
`docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./source -i`
|
@ -6,7 +6,8 @@
|
||||
void initApplicationEndsHook() {
|
||||
DEBUG_FUNCTION_LINE("Patch ApplicationEndsHook functions");
|
||||
for (uint32_t i = 0; i < applicationendshook_function_replacements_size; i++) {
|
||||
if (!FunctionPatcherPatchFunction(&applicationendshook_function_replacements[i], nullptr)) {
|
||||
bool wasPatched = false;
|
||||
if (FunctionPatcher_AddFunctionPatch(&applicationendshook_function_replacements[i], nullptr, &wasPatched) != FUNCTION_PATCHER_RESULT_SUCCESS || !wasPatched) {
|
||||
OSFatal("AromaBaseModule: Failed to patch ApplicationEndsHook function");
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ DECL_FUNCTION(uint32_t, OSReceiveMessage, OSMessageQueue *queue, OSMessage *mess
|
||||
if (message->args[0] == 0xD1E0D1E0) {
|
||||
ZombiUFix();
|
||||
CallHook(WUMS_HOOK_APPLICATION_REQUESTS_EXIT);
|
||||
CallHook(WUMS_HOOK_ALL_APPLICATION_REQUESTS_EXIT_DONE);
|
||||
}
|
||||
}
|
||||
lastData0 = message->args[0];
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include "logger.h"
|
||||
#include <malloc.h>
|
||||
|
||||
extern "C" FunctionPatcherStatus FPAddFunctionPatch(function_replacement_data_t *function_data, PatchedFunctionHandle *outHandle, bool *outHasBeenPatched);
|
||||
|
||||
void initDynload() {
|
||||
gLoadedRPLData = (LOADED_RPL *) malloc(sizeof(LOADED_RPL) * gModuleData->number_modules);
|
||||
if (!gLoadedRPLData) {
|
||||
@ -18,7 +20,9 @@ void initDynload() {
|
||||
|
||||
DEBUG_FUNCTION_LINE("Patch functions for dynload patches");
|
||||
for (uint32_t i = 0; i < dynload_function_replacements_size; i++) {
|
||||
if (!FunctionPatcherPatchFunction(&dynload_function_replacements[i], nullptr)) {
|
||||
bool wasPatched = false;
|
||||
// We need to use FPAddFunctionPatch because we can't use libfunctionpatcher yet. This patch enables it though.
|
||||
if (FPAddFunctionPatch(&dynload_function_replacements[i], nullptr, &wasPatched) != FUNCTION_PATCHER_RESULT_SUCCESS || !wasPatched) {
|
||||
OSFatal("AromaBaseModule: Failed to patch function for dynload patches");
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include "loader_defines.h"
|
||||
#include "logger.h"
|
||||
#include <coreinit/dynload.h>
|
||||
#include <coreinit/title.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <wums.h>
|
||||
|
||||
@ -27,11 +29,21 @@ DECL_FUNCTION(OSDynLoad_Error, OSDynLoad_Acquire, char const *name, OSDynLoad_Mo
|
||||
}
|
||||
}
|
||||
|
||||
OSDynLoad_Error result = real_OSDynLoad_Acquire(name, outModule);
|
||||
if (result == OS_DYNLOAD_OK) {
|
||||
return OS_DYNLOAD_OK;
|
||||
if (name != nullptr && name[0] == '~') {
|
||||
char cpy[64] = {};
|
||||
snprintf(cpy, sizeof(cpy), "%s", name);
|
||||
char *curPtr = &cpy[1];
|
||||
while (*curPtr != '\0') {
|
||||
if (*curPtr == '/') {
|
||||
*curPtr = '|';
|
||||
}
|
||||
curPtr++;
|
||||
}
|
||||
return real_OSDynLoad_Acquire(cpy, outModule);
|
||||
}
|
||||
|
||||
OSDynLoad_Error result = real_OSDynLoad_Acquire(name, outModule);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -150,8 +162,21 @@ DECL_FUNCTION(int32_t, sCheckOne, LOADED_RPL *rpl) {
|
||||
return real_sCheckOne(rpl);
|
||||
}
|
||||
|
||||
DECL_FUNCTION(void, sACPLoadOnDone, void) {
|
||||
if (OSGetTitleID() == 0x0005000010140900L) { // オセロ (Othello)
|
||||
DEBUG_FUNCTION_LINE_INFO("Skip sACPLoadOnDone for オセロ (Othello) as it might slow down exiting.");
|
||||
// For some unknown reason unloading the nn_acp.rpl after playing Othello
|
||||
// takes 30-100 seconds when many plugins are loaded... We take the very hacky and lazy route
|
||||
// and just stop calling it and pray this won't break anything.
|
||||
return;
|
||||
}
|
||||
|
||||
return real_sACPLoadOnDone();
|
||||
}
|
||||
|
||||
function_replacement_data_t dynload_function_replacements[] = {
|
||||
REPLACE_FUNCTION_VIA_ADDRESS(__OSDynLoad_InternalAcquire, 0x32029054, 0x101C400 + 0x0cc54),
|
||||
REPLACE_FUNCTION_VIA_ADDRESS(sACPLoadOnDone, 0x3201C400 + 0x29de0, 0x101C400 + 0x29de0),
|
||||
REPLACE_FUNCTION_VIA_ADDRESS(__OSDynLoad_InternalAcquire, 0x3201C400 + 0x0cc54, 0x101C400 + 0x0cc54),
|
||||
REPLACE_FUNCTION_VIA_ADDRESS(LiFindRPLByName, 0x32004BC4, 0x01004bc4),
|
||||
REPLACE_FUNCTION_VIA_ADDRESS(LiBinSearchExport, 0x320002f8, 0x010002f8),
|
||||
REPLACE_FUNCTION_VIA_ADDRESS(sCheckOne, 0x32007294, 0x01007294),
|
||||
|
4
source/functionpatcher.def
Normal file
4
source/functionpatcher.def
Normal file
@ -0,0 +1,4 @@
|
||||
:NAME homebrew_functionpatcher
|
||||
|
||||
:TEXT
|
||||
FPAddFunctionPatch
|
@ -1,4 +1,5 @@
|
||||
#include "dynload/loader_defines.h"
|
||||
#include <function_patcher/fpatching_defines.h>
|
||||
#include <wums.h>
|
||||
|
||||
extern module_information_t *gModuleData;
|
||||
|
@ -41,6 +41,7 @@ extern "C" {
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, "## WARN## ", "", FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, "##ERROR## ", "", FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_INFO(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, "## INFO## ", "", FMT, ##ARGS)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_ERR_LAMBDA(FILENAME, FUNCTION, LINE, FMT, ARGS...) LOG_EX(FILENAME, FUNCTION, LINE, WHBLogPrintf, "##ERROR## ", "", FMT, ##ARGS);
|
||||
|
||||
@ -58,6 +59,7 @@ extern "C" {
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, "## WARN## ", "\n", FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, "##ERROR## ", "\n", FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_INFO(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, "## INFO## ", "\n", FMT, ##ARGS)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_ERR_LAMBDA(FILENAME, FUNCTION, LINE, FMT, ARGS...) LOG_EX(FILENAME, FUNCTION, LINE, OSReport, "##ERROR## ", "\n", FMT, ##ARGS);
|
||||
|
||||
|
@ -6,12 +6,14 @@
|
||||
#include "sdrefcount/refcount.h"
|
||||
#include "symbolnamepatcher/symbolname.h"
|
||||
#include "version.h"
|
||||
#include <function_patcher/function_patching.h>
|
||||
#include <wums.h>
|
||||
|
||||
WUMS_MODULE_EXPORT_NAME("homebrew_basemodule");
|
||||
WUMS_MODULE_SKIP_INIT_FINI();
|
||||
WUMS_DEPENDS_ON(homebrew_functionpatcher);
|
||||
|
||||
#define VERSION "v0.1.3"
|
||||
#define VERSION "v0.2.6"
|
||||
|
||||
WUMS_INITIALIZE(args) {
|
||||
initLogging();
|
||||
@ -23,10 +25,18 @@ WUMS_INITIALIZE(args) {
|
||||
OSFatal("AromaBaseModule: The module information struct version does not match.");
|
||||
}
|
||||
|
||||
// First init Dynload to have proper OSDynLoad support!
|
||||
initDynload();
|
||||
|
||||
// Now init the library so we can use it for the other patches.
|
||||
if (FunctionPatcher_InitLibrary() != FUNCTION_PATCHER_RESULT_SUCCESS) {
|
||||
OSFatal("homebrew_basemodule: FunctionPatcher_InitLibrary failed");
|
||||
}
|
||||
|
||||
initApplicationEndsHook();
|
||||
initSDRefCount();
|
||||
initSymbolNamePatcher();
|
||||
initDynload();
|
||||
|
||||
initCommonPatches();
|
||||
|
||||
deinitLogging();
|
||||
|
@ -1,7 +1,9 @@
|
||||
#include "globals.h"
|
||||
#include "logger.h"
|
||||
#include "patches_replacements.h"
|
||||
#include <coreinit/cache.h>
|
||||
#include <cstdlib>
|
||||
#include <kernel/kernel.h>
|
||||
|
||||
// init is not called for this module. We need to make sure to init these values in initCommonPatches()
|
||||
uint32_t gHeapMask;
|
||||
@ -21,11 +23,20 @@ void initCommonPatches() {
|
||||
|
||||
DEBUG_FUNCTION_LINE("Do common patches");
|
||||
for (uint32_t i = 0; i < patches_function_replacements_size; i++) {
|
||||
if (!FunctionPatcherPatchFunction(&patches_function_replacements[i], nullptr)) {
|
||||
bool wasPatched = false;
|
||||
if (FunctionPatcher_AddFunctionPatch(&patches_function_replacements[i], nullptr, &wasPatched) != FUNCTION_PATCHER_RESULT_SUCCESS || !wasPatched) {
|
||||
OSFatal("AromaBaseModule: Failed apply common patches");
|
||||
}
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Common patches finished");
|
||||
|
||||
// Patch loader.elf to spit out less warnings when loading .rpx built with wut
|
||||
KernelNOPAtPhysicalAddress(0x0100b770 - 0x01000000 + 0x32000000);
|
||||
KernelNOPAtPhysicalAddress(0x0100b800 - 0x01000000 + 0x32000000);
|
||||
KernelNOPAtPhysicalAddress(0x0100b7b8 - 0x01000000 + 0x32000000);
|
||||
ICInvalidateRange(reinterpret_cast<void *>(0x0100b770), 0x04);
|
||||
ICInvalidateRange(reinterpret_cast<void *>(0x0100b800), 0x04);
|
||||
ICInvalidateRange(reinterpret_cast<void *>(0x0100b7b8), 0x04);
|
||||
}
|
||||
|
||||
void commonPatchesStart() {
|
||||
|
@ -4,11 +4,19 @@
|
||||
#include "patches.h"
|
||||
#include <coreinit/filesystem_fsa.h>
|
||||
#include <coreinit/title.h>
|
||||
#include <sysapp/launch.h>
|
||||
|
||||
static inline bool IsInHardcodedHomebrewMemoryRegion(void *addr) {
|
||||
if ((uint32_t) addr >= 0x00800000 && (uint32_t) addr < 0x01000000) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DECL_FUNCTION(FSStatus, FSAddClient, FSClient *client, FSErrorFlag errorMask) {
|
||||
auto res = real_FSAddClient(client, errorMask);
|
||||
if (res == FS_STATUS_OK) {
|
||||
if (((uint32_t) client & 0xF0000000) != gHeapMask) {
|
||||
if (((uint32_t) client & 0xF0000000) != gHeapMask && !IsInHardcodedHomebrewMemoryRegion(client)) {
|
||||
gNonHomebrewFSClientCount++;
|
||||
}
|
||||
}
|
||||
@ -18,7 +26,7 @@ DECL_FUNCTION(FSStatus, FSAddClient, FSClient *client, FSErrorFlag errorMask) {
|
||||
DECL_FUNCTION(FSStatus, FSDelClient, FSClient *client, FSErrorFlag errorMask) {
|
||||
auto res = real_FSDelClient(client, errorMask);
|
||||
if (res == FS_STATUS_OK) {
|
||||
if (((uint32_t) client & 0xF0000000) != gHeapMask) {
|
||||
if (((uint32_t) client & 0xF0000000) != gHeapMask && !IsInHardcodedHomebrewMemoryRegion(client)) {
|
||||
gNonHomebrewFSClientCount--;
|
||||
}
|
||||
}
|
||||
@ -42,15 +50,31 @@ DECL_FUNCTION(uint32_t, FSGetClientNum) {
|
||||
titleID == 0x0005000010115D00 || // The Smurfs™ 2 EUR
|
||||
titleID == 0x0005000010113300 // The Smurfs™ 2 USA
|
||||
) {
|
||||
DEBUG_FUNCTION_LINE("Fake FSGetClientNum num to %d instead of %d", gNonHomebrewFSClientCount, real_FSGetClientNum());
|
||||
DEBUG_FUNCTION_LINE_INFO("Fake FSGetClientNum num to %d instead of %d", gNonHomebrewFSClientCount, real_FSGetClientNum());
|
||||
return gNonHomebrewFSClientCount;
|
||||
}
|
||||
return real_FSGetClientNum();
|
||||
}
|
||||
|
||||
DECL_FUNCTION(uint32_t, SYSReturnToCaller, void *args) {
|
||||
// Fix jumping back to the System Settings when exiting the System Transfer
|
||||
auto curTitleID = OSGetTitleID();
|
||||
if (curTitleID == 0x0005001010062000L || curTitleID == 0x0005001010062100L || curTitleID == 0x0005001010062200L) {
|
||||
SysAppSettingsArgs set_args{};
|
||||
// Jump directly to the Transfer Menu
|
||||
set_args.jumpTo = SYS_SETTINGS_JUMP_TO_SOFTWARE_TRANSFER;
|
||||
_SYSLaunchSettings(&set_args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return real_SYSReturnToCaller(args);
|
||||
}
|
||||
|
||||
function_replacement_data_t patches_function_replacements[] = {
|
||||
REPLACE_FUNCTION(FSAddClient, LIBRARY_COREINIT, FSAddClient),
|
||||
REPLACE_FUNCTION(FSDelClient, LIBRARY_COREINIT, FSDelClient),
|
||||
REPLACE_FUNCTION(FSGetClientNum, LIBRARY_COREINIT, FSGetClientNum),
|
||||
REPLACE_FUNCTION(SYSReturnToCaller, LIBRARY_SYSAPP, SYSReturnToCaller),
|
||||
};
|
||||
|
||||
uint32_t patches_function_replacements_size = sizeof(patches_function_replacements) / sizeof(function_replacement_data_t);
|
@ -21,7 +21,8 @@ void initSDRefCount() {
|
||||
|
||||
DEBUG_FUNCTION_LINE("Patch SDRefCount functions");
|
||||
for (uint32_t i = 0; i < sdrefcount_function_replacements_size; i++) {
|
||||
if (!FunctionPatcherPatchFunction(&sdrefcount_function_replacements[i], nullptr)) {
|
||||
bool wasPatched = false;
|
||||
if (FunctionPatcher_AddFunctionPatch(&sdrefcount_function_replacements[i], nullptr, &wasPatched) != FUNCTION_PATCHER_RESULT_SUCCESS || !wasPatched) {
|
||||
OSFatal("AromaBaseModule: Failed to patch function for sd ref counting");
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ void NWF_Fix() {
|
||||
int state = OSDisableInterrupts();
|
||||
OSThread *t = *((OSThread **) 0x100567F8);
|
||||
while (t) {
|
||||
if (std::string_view(t->name) == "PlatformInputAppStateListenerThread") {
|
||||
if (t->name != nullptr && std::string_view(t->name) == "PlatformInputAppStateListenerThread") {
|
||||
t->priority = 0x80;
|
||||
OSReport("Set priority to %d for thread \"%s\" (%08X) to prevent it from running/crashing\n", t->priority, t->name, t);
|
||||
}
|
||||
@ -300,6 +300,7 @@ DECL_FUNCTION(void, __PPCExit, uint32_t u1) {
|
||||
NWF_Fix();
|
||||
|
||||
CallHook(WUMS_HOOK_APPLICATION_ENDS);
|
||||
CallHook(WUMS_HOOK_ALL_APPLICATION_ENDS_DONE);
|
||||
CallHook(WUMS_HOOK_FINI_WUT_SOCKETS);
|
||||
CallHook(WUMS_HOOK_FINI_WUT_DEVOPTAB);
|
||||
if (gSDMountRefCount > 0) {
|
||||
|
@ -5,7 +5,8 @@
|
||||
void initSymbolNamePatcher() {
|
||||
DEBUG_FUNCTION_LINE("Patch SymbolNamePatcher functions");
|
||||
for (uint32_t i = 0; i < symbolname_function_replacements_size; i++) {
|
||||
if (!FunctionPatcherPatchFunction(&symbolname_function_replacements[i], nullptr)) {
|
||||
bool wasPatched = false;
|
||||
if (FunctionPatcher_AddFunctionPatch(&symbolname_function_replacements[i], nullptr, &wasPatched) != FUNCTION_PATCHER_RESULT_SUCCESS || !wasPatched) {
|
||||
OSFatal("AromaBaseModule: Failed to patch SymbolNamePatcher function");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user