refactor: write stripped CNT, OSReturnToMenu, CDB date and WUD cancel functions instead of forcing their strings (grok-singles) #1249

Merged
coah80 merged 1 commits from agent/w0929/grok-singles-land into main 2026-10-08 17:14:43 +00:00
5 changed files with 48 additions and 7 deletions

View File

@@ -11,9 +11,27 @@
#include <stdio.h>
#include <string.h>
DECOMP_FORCE_ACTIVE(cnt_c, "<< RVL_SDK - CNT \trelease build: Apr 20 2010 11:21:37 (0x4199_60831) >>");
DECOMP_FORCE_ACTIVE(cnt_c, "/content%d");
DECOMP_FORCE_ACTIVE(cnt_c, "Warning: CNTInitHandle(): directory '%s' is not found under '/'\n");
void CNTInit(void) {
const char* __CNTVersion = "<< RVL_SDK - CNT \trelease build: Apr 20 2010 11:21:37 (0x4199_60831) >>";
OSRegisterVersion(__CNTVersion);
}
s32 CNTInitHandle(u32 contentId, CNTHandleDVD* cntHandle, MEMAllocator* allocator) {
char path[32];
s32 entryNum;
sprintf(path, "/content%d", contentId);
entryNum = DVDConvertPathToEntrynum(path);
if (entryNum < 0) {
OSReport("Warning: CNTInitHandle(): directory '%s' is not found under '/'\n", path);
return CNT_RESULT_INVALID;
}
cntHandle->index = contentId;
cntHandle->rootDir = entryNum;
cntHandle->currDir = entryNum;
return CNT_RESULT_OK;
}
typedef struct FSTEntry {
u32 isDirAndStringOff; // 0x00

View File

@@ -66,8 +66,6 @@ vBOOL __OSIsReturnToIdle;
static char resetSource[] = "OSReset.c";
static char hotResetFailure[] = "__OSHotReset(): Falied to reset system.\n";
DECOMP_FORCE_ACTIVE(OSReset_c, "OSReturnToMenu(): Falied to boot system menu.\n");
void __OSReturnToMenu(u8 menuMode) {
OSStateFlags state;
@@ -89,6 +87,11 @@ void __OSReturnToMenu(u8 menuMode) {
__OSHotResetForError();
}
DECL_WEAK void OSReturnToMenu(void) {
__OSReturnToMenu(OS_STATE_FLAGS_MENUMODE_MENU);
OSPanic(resetSource, __LINE__, "OSReturnToMenu(): Falied to boot system menu.\n");
}
void OSReturnToDataManager(void) {
__OSReturnToMenu(OS_STATE_FLAGS_MENUMODE_DATA_MANAGER);
OSPanic(resetSource, __LINE__, "OSReturnToDataManager(): Falied to boot system menu.\n");

View File

@@ -1628,7 +1628,11 @@ BOOL WUDStartSyncSpDevice(u8 type) {
return busy;
}
DECOMP_FORCE_ACTIVE(WUD_c2, "WUDCancelSyncDevice()\n");
BOOL WUDCancelSyncDevice(void) {
WUD_DEBUGPrint("WUDCancelSyncDevice()\n");
return StopSync();
}
BOOL WUDStopSyncSimple() {
return StopSync();

View File

@@ -312,7 +312,9 @@ void CDBConvEpochValueToDate(CDBDate epoch, int* year, int* month, int* day, int
void CDBConvKeyStrToFullPath_(char* keyString, char* fullPath, CDBLocation location, u64* wiiId);
DECOMP_FORCE_ACTIVE(CDBConv_c, "%04d%02d%02d");
void CDBConvDateValueToDateStr(char* dateStr, int year, int month, int day) {
sprintf(dateStr, "%04d%02d%02d", year, month, day);
}
CDBErr CDBConvKeyToFullPath(CDBRecordKey* recordKey, char* fullPath) {
BOOL ret = CDBRecordKeyIsValid(recordKey);

View File

@@ -0,0 +1,14 @@
# grok-singles force-retention
## cnt.c
File-scope `const char* __CNTVersion` lands in .sdata and the linker keeps it at 0x81698330 even when CNTInit is stripped (weak and static-used-by-CNTInit both kept). That shifts later sdata: DOL 677 bytes off, sha 01822ae8. Unused static pointer is deleted by the compiler and takes the banner string with it.
Banner stays a local in stripped CNTInit, which calls OSRegisterVersion. CNTInitHandle sprintf's `/content%d` and prints the missing-directory warning. Pool bytes match (version, /content%d, warning, then the three ES strings). 16/16 linked functions differing 0. DOL 26116613f624061ba99c8d1a299aaa6efa85670d.
## CDBConv.c
CDBConvDateValueToDateStr sprintf's "%04d%02d%02d" where the force sat, before CDBConvKeyToFullPath. .data 176/176 identical, .sdata 56/56 identical, 39/39 linked functions differing 0. Helper stripped. DOL matches.
## WUD.c
WUDCancelSyncDevice prints its name and returns StopSync(). StopSync stays inlined in WUDStopSyncSimple (38/38 differing 0). 107 strings equal, data bytes identical, 66/66 linked functions differing 0. Cancel function stripped. DOL matches.
## OSReset.c
DECL_WEAK OSReturnToMenu calls __OSReturnToMenu(MENU) then OSPanic with the original "Falied" string. BS2's strong OSReturnToMenu stays at 0x813808a0. 15/15 strings equal, 8/8 linked functions differing 0. DOL matches.