Compare commits

..

1 Commits

Author SHA1 Message Date
devin
9e76cabe2f decomp(CDBRecord): dead-fn literal fossils + Encrypt 284/284 insn-equal
Restores ~15 link-deadstripped retail fns whose emitted .data fossil
literals exist in the orig object; DOL-verified byte-identical at the
expected vaddrs. CDBRecordEncrypt auto-inlines dead CDBRecordGetFileSize:
284/284 instructions identical. Unit stays NonMatching: Encrypt's 57-byte
residual is an equal-cost register-packing tie-break (18 source probes
documented in tools/decomp-assist/CDBRecord.attempts.md).

Co-authored-by: coah80 <usernamecole7@gmail.com>
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-02 21:22:36 +00:00
17 changed files with 307 additions and 2967 deletions

View File

@@ -53,9 +53,9 @@ Progress
<!-- progress:start -->
| Decompiled | Matched | Linked | Data |
|:---:|:---:|:---:|:---:|
| 99.59% | 91.16% | 74.57% | 99.56% |
| 99.59% | 91.12% | 74.40% | 99.42% |
units 964/1027 complete, functions 12378/12563 matched.
units 963/1027 complete, functions 12376/12563 matched.
decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data
<!-- progress:end -->

View File

@@ -1299,7 +1299,7 @@ config.libs = [
Object(Matching, "ut/ut_RomFont.cpp"),
Object(Matching, "ut/ut_ResFontBase.cpp"),
Object(Matching, "ut/ut_ResFont.cpp"),
Object(Matching, "ut/ut_ArchiveFontBase.cpp"),
Object(NonMatching, "ut/ut_ArchiveFontBase.cpp"),
Object(Matching, "ut/ut_ArchiveFont.cpp"),
Object(Matching, "ut/ut_CharWriter.cpp"),
Object(Matching, "ut/ut_TextWriterBase.cpp"),

View File

@@ -20,7 +20,7 @@ namespace gui {
class Manager;
class EventHandler;
#if defined(IPL_GC_SAVEDATA_NOVTABLE) || defined(IPL_MEMORY_CARD_NOVTABLE) || defined(IPL_SETTING_NOVTABLE)
#if defined(IPL_GC_SAVEDATA_NOVTABLE) || defined(IPL_MEMORY_CARD_NOVTABLE)
class __declspec(novtable) Interface {
#else
class Interface {
@@ -34,14 +34,14 @@ namespace gui {
virtual void draw(Mtx& mtx) {} // 0x14 (0x05)
virtual void draw() {} // 0x18 (0x06)
#if defined(IPL_GC_SAVEDATA_NOVTABLE) || defined(IPL_MEMORY_CARD_NOVTABLE) || defined(IPL_SETTING_NOVTABLE)
#if defined(IPL_GC_SAVEDATA_NOVTABLE) || defined(IPL_MEMORY_CARD_NOVTABLE)
virtual ~Interface(); // 0x1C (0x07)
#else
virtual ~Interface() {} // 0x1C (0x07)
#endif
};
#if defined(IPL_GC_WINDOW_NOVTABLE) || defined(IPL_GC_SAVEDATA_NOVTABLE) || defined(IPL_MEMORY_CARD_NOVTABLE) || defined(IPL_SETTING_NOVTABLE)
#if defined(IPL_GC_WINDOW_NOVTABLE) || defined(IPL_GC_SAVEDATA_NOVTABLE) || defined(IPL_MEMORY_CARD_NOVTABLE)
class __declspec(novtable) EventHandler {
#else
class EventHandler {

View File

@@ -24,7 +24,7 @@ namespace ipl {
mbDisableCon(bDisableCon) {}
#endif
#if defined(IPL_GC_SAVEDATA_NOVTABLE) || defined(IPL_MEMORY_CARD_NOVTABLE) || defined(IPL_SETTING_NOVTABLE)
#if defined(IPL_GC_SAVEDATA_NOVTABLE) || defined(IPL_MEMORY_CARD_NOVTABLE)
virtual ~PaneManager();
#else
virtual ~PaneManager() {}

View File

@@ -50,7 +50,7 @@ namespace ipl {
static BOOL IsLastTicketExpired(ESTitleId* titleId);
static void DeleteExpiredFlagFile();
static s32 DeleteUnauthorizedData(EGG::Heap* heap);
static void DeleteUnauthorizedData(EGG::Heap* heap);
static u32 CheckTmdCountryCode(ESTmdView* tmdView);
static u32 CheckTmdParentalControl(ESTmdView* tmdView);

View File

@@ -252,17 +252,14 @@ namespace nw4r {
}
inline void updateSheetFlags(const void* glgrHdr, u32 groupIdx, u16* sheetOffsets, u32 flagsStep, const u32* sheetFlags) {
const GlyphGroups* glgr = (const GlyphGroups*)((const u8*)glgrHdr + sizeof(BinaryBlockHeader));
int sheetIndex;
u32 groupBitOffset;
u16* sheetOffset = sheetOffsets;
groupBitOffset = groupIdx * flagsStep * 8;
for (sheetIndex = 0; sheetIndex < glgr->sheetCount; sheetOffset++, sheetIndex++) {
u32 groupBitIdx = sheetIndex + groupBitOffset;
const GlyphGroups* glgr = (GlyphGroups*)((u8*)glgrHdr + sizeof(BinaryBlockHeader));
for (int sheetI = 0; sheetI < glgr->sheetCount; sheetI++) {
u32 groupBitIdx = sheetI + groupIdx * flagsStep * 8;
const u32* bitBlockPtr = sheetFlags + (groupBitIdx & ~0x1F) / 32;
u32 bitBlock = *bitBlockPtr;
u32 bitBlock = *(u32*)bitBlockPtr;
if (((bitBlock << (groupBitIdx & 0x1F)) & 0x80000000) != 0) {
*sheetOffset = 1;
sheetOffsets[sheetI] = 1;
}
}
}
@@ -271,16 +268,14 @@ namespace nw4r {
const u32* bitBlocksPtr, u32 sheetFlagsSize) {
HeaderedGlyphGroups* pGlgr = (HeaderedGlyphGroups*)glgrHdr;
int i;
u16* sheetOffset;
for (i = 0, sheetOffset = sheetOffsets; i < pGlgr->inner.sheetCount; sheetOffset++, i++) {
*sheetOffset = 0;
for (int i = 0; i < pGlgr->inner.sheetCount; i++) {
sheetOffsets[i] = 0;
}
for (int i = 0; i < pGlgr->inner.nameCount; i++) {
const char* includedGroups = ctx->pIncludedGroups;
u16 offset = pGlgr->inner.nameOffsets[i];
char* name = (char*)(offset + (u32)hdr);
char* name = (char*)((u8*)hdr + offset);
if (*includedGroups != 0) {
if (!ArchiveFontBase::IncludeName(includedGroups, name)) {
continue;
@@ -293,23 +288,21 @@ namespace nw4r {
inline void convertSheetOffsetBooleansToOffsets(const void* glgrHdr, u16* sheetOffsets) {
HeaderedGlyphGroups* pGlgr = (HeaderedGlyphGroups*)glgrHdr;
int i;
u16 glyphIdxOffset = 0;
u16* sheetOffset;
for (i = 0, sheetOffset = sheetOffsets; i < pGlgr->inner.sheetCount; sheetOffset++, i++) {
if (*sheetOffset == 1) {
*sheetOffset = glyphIdxOffset;
for (int i = 0; i < pGlgr->inner.sheetCount; i++) {
if (sheetOffsets[i] == 1) {
sheetOffsets[i] = glyphIdxOffset;
} else {
*sheetOffset = -1;
sheetOffsets[i] = -1;
glyphIdxOffset += pGlgr->inner.sheetGlyphCount;
}
}
}
inline void copyFlagOffsets(ArchiveFontBase::ConstructContext* ctx, u16* sheetOffsetsScratch, u32 workSize, const u16* sheetOffsetsScratchEnd) {
inline void copyFlagOffsets(ArchiveFontBase::ConstructContext* ctx, u16* sheetOffsetsScratch, u32 workSize, u32 scratchSize) {
u8* sheetOffsets = ctx->pWorkCurr;
ctx->pWorkCurr = sheetOffsets + workSize;
memmove(sheetOffsets, sheetOffsetsScratch, (sheetOffsetsScratchEnd - sheetOffsetsScratch) * sizeof(u16));
memmove(sheetOffsets, sheetOffsetsScratch, scratchSize);
ctx->pSheetOffsets = (u16*)sheetOffsets;
}
@@ -318,64 +311,31 @@ namespace nw4r {
// *sheetOffsetsScratch = (u16*)ROUNDDOWN((u32)((u8*)fontData + remWorkSpace) - sheetOffsetsSize, 2);
// return sheetOffsetsSize;
// }
class FontGlyphGroupsAcs {
public:
explicit FontGlyphGroupsAcs(const ArchiveFontBinaryLayout* font)
: mFont(font), mGroups(&font->glgr) {}
const GlyphGroups& GetGroups() const { return mGroups->inner; }
void SetSheetFlags(u32 flagsStep, const u32* sheetFlags) {
mFlagsStep = flagsStep;
mSheetFlags = sheetFlags;
}
u16 GetNumSheet() const { return mGroups->inner.sheetCount; }
int GetGlyphsPerSheet() const { return mGroups->inner.sheetGlyphCount; }
u16 GetNumSet() const { return mGroups->inner.nameCount; }
const char* GetSetName(int groupIndex) const {
const u16 nameOffset = mGroups->inner.nameOffsets[groupIndex];
return (const char*)(nameOffset + (u32)mFont);
}
bool IsUseSheet(int groupIndex, int sheetIndex) const {
const u32 groupBitIndex = sheetIndex + groupIndex * mFlagsStep * 8;
const u32* bitBlock = mSheetFlags + (groupBitIndex & ~0x1F) / 32;
return ((*bitBlock << (groupBitIndex & 0x1F)) & 0x80000000) != 0;
}
private:
const ArchiveFontBinaryLayout* mFont;
const HeaderedGlyphGroups* mGroups;
u32 mFlagsStep;
const u32* mSheetFlags;
};
ArchiveFontBase::ConstructState ArchiveFontBase::ConstructOpAnalyzeGLGR(ConstructContext* ctx, CachedStreamReader* reader) {
const u32* flagsSheets;
u32 sheetOffsetsSize;
u32 flagsSheetsOff;
u32 glgrInnerLen;
const ArchiveFontBinaryLayout* font;
u16 sheetGlyphCount;
u32 countSheet;
HeaderedGlyphGroups* pGlgr;
const ArchiveFontBinaryLayout* font;
u8* glgrEnd;
u32 expectedMaxSize;
u32 dataBlockCount;
u16* sheetOffsetsScratch;
int groupIndex;
font = (ArchiveFontBinaryLayout*)ctx->pWorkCurr;
glgrInnerLen = ctx->mNextBlockHdr.size - sizeof(BinaryBlockHeader);
// Check for RFNA
if (font->hdr.signature != SIGNATURE_FONT_ARCHIVE) {
return CONSTRUCT_STATE_FATAL_ERR;
}
// Check that there's enough data available, and the space to
// put that data
ENSURE_READER_HAS_SIZE(ctx, reader, glgrInnerLen);
ENSURE_WORK_HAS_SIZE(ctx, glgrInnerLen);
expectedMaxSize = ctx->mNextBlockHdr.size + sizeof(BinaryFileHeader);
// Copy the glgr to work
{
pGlgr = (HeaderedGlyphGroups*)&font->glgr;
glgrEnd = (u8*)pGlgr + (u32)ctx->mNextBlockHdr.size;
@@ -388,45 +348,80 @@ namespace nw4r {
return CONSTRUCT_STATE_FATAL_ERR;
}
FontGlyphGroupsAcs gg(font);
sheetGlyphCount = gg.GetGlyphsPerSheet();
dataBlockCount = font->hdr.dataBlocks;
countSheet = gg.GetNumSheet();
const u32 stepSheetFlags = detail::CalcSizeFlagSet(countSheet);
flagsSheetsOff = detail::CalcOffsetSheetFlags(gg.GetGroups().nameCount, countSheet, gg.GetGroups().smthCount_0x0a,
gg.GetGroups().smthCount_0x0c);
flagsSheets = (const u32*)((flagsSheetsOff & ~3) + (u32)font);
gg.SetSheetFlags(stepSheetFlags, flagsSheets);
// Before here is fine (other than regswaps)
// u16 sheetGlyphCount = FORCE_REACCESS_2(font->glgr.inner.sheetGlyphCount, u16); // 0x1C
// u16 dataBlockCount = FORCE_REACCESS_2(font->hdr.dataBlocks, u16); // 0x0E
// FORCE_REACCESS_2(font->glgr.inner.sheetCount, u16);
// return ConstructOpAnalyzeGLGRInner(ctx, font, pGlgr, glgrEnd);
sheetOffsetsSize = (RoundUp)(countSheet * sizeof(u16), 4);
// u32 fontSizeToEndOfGlgr;
u16 countSheet;
u16 sheetGlyphCount, dataBlockCount;
u32 stepSheetFlags;
u32 flagsSheetsOff;
const u32* flagsSheets;
u32 sheetOffsetsSize;
u16* sheetOffsetsScratch;
u32 sheetOffsetsScratchSize;
sheetGlyphCount = font->glgr.inner.sheetGlyphCount; // 0x1C
dataBlockCount = font->hdr.dataBlocks; // 0x0E
// countName = font->glgr.inner.nameCount;
countSheet = font->glgr.inner.sheetCount;
// count0A = font->glgr.inner.smthCount_0x0a;
// count0C = font->glgr.inner.smthCount_0x0c;
stepSheetFlags = detail::CalcSizeFlagSet(countSheet);
flagsSheetsOff = detail::CalcOffsetSheetFlags(font->glgr.inner.nameCount, countSheet, font->glgr.inner.smthCount_0x0a,
font->glgr.inner.smthCount_0x0c);
flagsSheets = (const u32*)font + (flagsSheetsOff >> 2);
sheetOffsetsSize = ROUNDUP(countSheet * sizeof(u16), 4);
sheetOffsetsScratch = (u16*)ROUNDDOWN((u32)((u8*)font + ctx->remWorkSpace()) - sheetOffsetsSize, 2);
pGlgr = (HeaderedGlyphGroups*)&font->glgr;
ENSURE_WORK_HAS_SIZE(ctx, glgrEnd - (u8*)font + sheetOffsetsSize);
// if (ctx->pWorkEnd - workCurr < fontSizeToEndOfGlgr + sheetOffsetsSize) {
// return CONSTRUCT_STATE_FATAL_ERR;
// }
{
u16* sheetOffset;
int sheetIndex;
for (sheetIndex = 0, sheetOffset = sheetOffsetsScratch; sheetIndex < gg.GetNumSheet(); sheetOffset++, sheetIndex++) {
*sheetOffset = 0;
}
for (groupIndex = 0; groupIndex < gg.GetNumSet(); groupIndex++) {
const char* includedGroups = ctx->pIncludedGroups;
const char* name = gg.GetSetName(groupIndex);
if (*includedGroups && !ArchiveFontBase::IncludeName(includedGroups, name)) {
continue;
}
for (int sheetIndex = 0; sheetIndex < gg.GetNumSheet(); sheetIndex++) {
if (gg.IsUseSheet(groupIndex, sheetIndex)) {
sheetOffsetsScratch[sheetIndex] = 1;
}
}
}
}
// Clear sheet offsets scratch
// for (s32 i = 0; i < pGlgr->inner.sheetCount; i++) {
// sheetOffsetsScratch[i] = 0;
// }
// for (s32 i = 0; i < pGlgr->inner.nameCount; i++) {
// // const char* includedGroups = ctx->pIncludedGroups;
// u16 offset = pGlgr->inner.nameOffsets[i];
// const char* name = (char*)((u8*)font + offset);
// if (*ctx->pIncludedGroups != 0) {
// if (!ArchiveFontBase::IncludeName(ctx->pIncludedGroups, name)) {
// continue;
// }
// }
// updateSheetFlags(pGlgr, i, sheetOffsetsScratch, stepSheetFlags, flagsSheets);
// }
setSheetOffsetBooleans(ctx, pGlgr, font, sheetOffsetsScratch, flagsSheets, stepSheetFlags);
// u16 glyphIdxOffset = 0;
// for (s32 i = 0; i < pGlgr->inner.sheetCount; i++) {
// if (sheetOffsetsScratch[i] == 1) {
// sheetOffsetsScratch[i] = glyphIdxOffset;
// } else {
// sheetOffsetsScratch[i] = -1;
// glyphIdxOffset += pGlgr->inner.sheetGlyphCount;
// }
// }
convertSheetOffsetBooleansToOffsets(pGlgr, sheetOffsetsScratch);
copyFlagOffsets(ctx, sheetOffsetsScratch, sheetOffsetsSize, sheetOffsetsScratch + (u16)countSheet);
sheetOffsetsScratchSize = (u32)countSheet << 1;
sheetOffsetsScratchSize += (sheetOffsetsScratchSize >> 31);
sheetOffsetsScratchSize &= ~1;
copyFlagOffsets(ctx, sheetOffsetsScratch, sheetOffsetsSize, sheetOffsetsScratchSize);
ctx->mSheetCount = countSheet;
ctx->mGlyphsPerSheet = sheetGlyphCount;

View File

@@ -68,14 +68,8 @@ void NETMD5GetDigest(NETMD5Context* context, void* digest) {
memset(context, 0, sizeof(*context));
}
static inline u32 rotateSum(u32 state, const u32* word, u32 constant, int shift) {
// Each rotation half reads its own byte-reversed message word.
u32 right = __lwbrx((void*)word, 0);
u32 left = __lwbrx((void*)word, 0);
return ((state + (left + constant)) << shift) | ((right + (constant + state)) >> (32 - shift));
}
#define STEP(a, b, c, d, f, word, n) ((a) = (b) + rotateSum((a) + (f), word, *constant, n))
#define ROTATE(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
#define STEP(a, b, c, d, f, word, n) ((a) += (f), (a) = (b) + ROTATE(__lwbrx(0, (int)(word)) + (*constant + (a)), n))
static void ProcessBlock(NETMD5Context* context) {
static u32 constants[64] = {0xD76AA478, 0xE8C7B756, 0x242070DB, 0xC1BDCEEE, 0xF57C0FAF, 0x4787C62A, 0xA8304613, 0xFD469501, 0x698098D8, 0x8B44F7AF, 0xFFFF5BB1, 0x895CD7BE, 0x6B901122, 0xFD987193, 0xA679438E, 0x49B40821, 0xF61E2562, 0xC040B340, 0x265E5A51, 0xE9B6C7AA, 0xD62F105D, 0x02441453, 0xD8A1E681, 0xE7D3FBC8, 0x21E1CDE6, 0xC33707D6, 0xF4D50D87, 0x455A14ED, 0xA9E3E905, 0xFCEFA3F8, 0x676F02D9, 0x8D2A4C8A, 0xFFFA3942, 0x8771F681, 0x6D9D6122, 0xFDE5380C, 0xA4BEEA44, 0x4BDECFA9, 0xF6BB4B60, 0xBEBFBC70, 0x289B7EC6, 0xEAA127FA, 0xD4EF3085, 0x04881D05, 0xD9D4D039, 0xE6DB99E5, 0x1FA27CF8, 0xC4AC5665, 0xF4292244, 0x432AFF97, 0xAB9423A7, 0xFC93A039, 0x655B59C3, 0x8F0CCC92, 0xFFEFF47D, 0x85845DD1, 0x6FA87E4F, 0xFE2CE6E0, 0xA3014314, 0x4E0811A1, 0xF7537E82, 0xBD3AF235, 0x2AD7D2BB, 0xEB86D391};
@@ -89,13 +83,13 @@ static void ProcessBlock(NETMD5Context* context) {
block = context->buffer32;
word = block;
constant = constants;
index = indices;
for (round = 0; round < 4; ++round) {
STEP(a,b,c,d,(b & c) | (~b & d),word,7); ++word; ++constant;
STEP(d,a,b,c,(a & b) | (~a & c),word,12); ++word; ++constant;
STEP(c,d,a,b,(d & a) | (~d & b),word,17); ++word; ++constant;
STEP(b,c,d,a,(c & d) | (~c & a),word,22); ++word; ++constant;
}
index = indices;
for (round = 0; round < 4; ++round) {
STEP(a,b,c,d,(b & d) | (c & ~d),block + *index,5); ++index; ++constant;
STEP(d,a,b,c,(a & c) | (b & ~c),block + *index,9); ++index; ++constant;

View File

@@ -7717,27 +7717,30 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
CHANSVmObjHdr* pAcc;
CHANSVmExecutionCtx* ctx;
CHANSVmModule* dbg;
CHANSVmErr loadResult;
opSize = 3;
operandBuf = VmGetOperand(vm, 1, 3);
if (operandBuf == vmNull) {
return CHANS_VM_ERR_CODE_RANGE;
}
pAcc = &pVm->accumulator;
loadResult = CHANSVmDeleteObject(vm, pAcc);
if (loadResult == CHANS_VM_OK) {
result = CHANSVmDeleteObject(vm, pAcc);
if (result == CHANS_VM_OK) {
imm16Val = VM_READ_BE_U16(operandBuf, 0);
ctx = pVm->pActiveCtx;
dbg = ctx->pDbg;
if (imm16Val >= dbg->stringCount || dbg->pStringTbl[imm16Val].pStringData == vmNull) {
loadResult = CHANS_VM_ERR_LOAD_STRING_CONST;
} else {
pAcc->type = CHANS_VM_OBJ_TYPE_STRING;
pAcc->hasData = vmTrue;
pAcc->value.wstring_v = (vmWStringObjVal*)&ctx->pDbg->pStringTbl[imm16Val];
if (imm16Val < dbg->stringCount) {
if (dbg->pStringTbl[imm16Val].pStringData != vmNull) {
goto load_str_ok;
}
}
}
result = loadResult;
result = CHANS_VM_ERR_LOAD_STRING_CONST;
break;
load_str_ok:
pAcc->type = CHANS_VM_OBJ_TYPE_STRING;
pAcc->hasData = vmTrue;
pAcc->value.wstring_v = (vmWStringObjVal*)&ctx->pDbg->pStringTbl[imm16Val];
break;
}

View File

@@ -616,17 +616,6 @@ int AOSS_Init_old(AOSSInitInput* input)
s_accessPointList = 0;
}
resultCode = 0xffffffff;
} else if (state != 0) {
input->status = 0xf;
if (s_accessPointConfig) {
AOSSi_Free(s_accessPointConfig);
s_accessPointConfig = (int *)0x0;
}
if (s_accessPointList) {
AOSSi_Free(s_accessPointList);
s_accessPointList = 0;
}
resultCode = 0xffffffff;
} else {
s_accessPointConfig = (int *)AOSSi_Alloc(0x58);
if (s_accessPointConfig == 0) {
@@ -812,7 +801,7 @@ perform_request:
if (s_socketStarted == 1) {
s_socketStarted = 0;
requestResult = SOCleanup();
if (0 <= requestResult) goto request_socket_cleanup_complete;
if (-1 < requestResult) goto request_socket_cleanup_complete;
requestResult = -1;
}
else {
@@ -885,7 +874,7 @@ request_socket_cleanup_complete:
resultCode = 0xffffffff;
goto finish_initialization;
}
if ((requestResult == 0) && ((u32)*s_accessPointConfig == 1u)) break;
if ((requestResult == 0) && (*s_accessPointConfig == 1)) break;
remainingWait = waitIntervals.limits.response;
for (; remainingWait != 0; remainingWait -= initialSleep) {
if (AOSSi_cancel_flag == 1) {
@@ -1039,9 +1028,11 @@ request_socket_cleanup_complete:
if (0 < requestResult) goto process_received_packet;
receivedPackets = receivedPackets + 1;
if (receivedPackets > attemptCount) {
if (protocolState == 0) s_errorCode = 0xf;
else if (protocolState == 1) s_errorCode = 0x10;
else s_errorCode = 0x11;
switch (protocolState) {
case 0: s_errorCode = 0xf; break;
case 1: s_errorCode = 0x10; break;
default: s_errorCode = 0x11; break;
}
protocolResult = -1;
goto close_protocol_socket;
}
@@ -1229,7 +1220,7 @@ wait_for_packet:
resultCode = 0xffffffff;
goto finish_initialization;
}
if ((state == 0) && ((u32)*s_accessPointConfig == 1u)) break;
if ((state == 0) && (*s_accessPointConfig == 1)) break;
remainingWait = waitIntervals.limits.response;
for (; remainingWait != 0; remainingWait -= initialSleep) {
if (AOSSi_cancel_flag == 1) {
@@ -1308,9 +1299,11 @@ wait_for_packet:
}
protocolState = requestResult;
if (receivedPackets > waitSettings.halfwords.high) {
if (requestResult == 0) s_errorCode = 0xf;
else if (requestResult == 1) s_errorCode = 0x10;
else s_errorCode = 0x11;
switch (requestResult) {
case 0: s_errorCode = 0xf; break;
case 1: s_errorCode = 0x10; break;
default: s_errorCode = 0x11; break;
}
protocolResult = -1;
goto close_protocol_socket;
}
@@ -1329,9 +1322,10 @@ wait_for_packet:
resultCode = 0xffffffff;
goto finish_initialization;
}
AOSSi_Sleep(retryDelay > 100 ? 100 : retryDelay);
if (retryDelay <= 100) delayStep = retryDelay;
else delayStep = 100;
if (retryDelay > 100) AOSSi_Sleep(100);
else AOSSi_Sleep(retryDelay);
if (retryDelay > 100) delayStep = 100;
else delayStep = retryDelay;
}
if (AOSSi_cancel_flag == 1) {
input->status = 0xf;
@@ -1356,7 +1350,7 @@ close_protocol_socket:
if (s_socketStarted == 1) {
s_socketStarted = 0;
state = SOCleanup();
if (0 <= state) goto protocol_socket_cleanup_complete;
if (-1 < state) goto protocol_socket_cleanup_complete;
state = -1;
}
else {

View File

@@ -1547,7 +1547,6 @@ s32 ATERMRunConfigProtocol(void) {
break;
case 5:
{
s32 messageLength;
u8 optionIds[7] = {6, 0, 1, 2, 3, 4, 5};
AtermRequestOption8* shortOption = (AtermRequestOption8*)gAtermRequestOptions;
AtermRequestOption16* longOption;
@@ -1590,14 +1589,13 @@ s32 ATERMRunConfigProtocol(void) {
longOption++;
}
optionEnd = (u8*)longOption;
messageLength = ATERMBuildEncryptedMessage((u16*)gAtermConfigurationResult.packetBuffer, 2,
gAtermMessageLength = ATERMBuildEncryptedMessage((u16*)gAtermConfigurationResult.packetBuffer, 2,
(u16*)response->data, optionEnd - gAtermRequestOptions + 8, NULL);
gAtermMessageLength = messageLength;
sendAddress.length = 8;
sendAddress.family = 2;
sendAddress.address = 0xFFFFFFFF;
sendAddress.port = SOHtoNs(0xE601);
SOSendTo(socket, gAtermConfigurationResult.packetBuffer, messageLength, 0, &sendAddress);
SOSendTo(socket, gAtermConfigurationResult.packetBuffer, gAtermMessageLength, 0, &sendAddress);
lastSendTime = (u32)(OSGetTime() / (__mulhwu(reciprocal, OS_BUS_CLOCK >> 2) >> 6));
gAtermProtocolState = 6;
break;
@@ -1658,10 +1656,6 @@ s32 ATERMRunConfigProtocol(void) {
(__mulhwu(reciprocal, OS_BUS_CLOCK >> 2) >> 6));
u32 index;
u32 digestBytes;
u32 state0;
u32 state1;
u32 state2;
u32 state3;
memcpy(response->authentication.challenge,
optionValue, 8);
digestContext.bitCountHigh = 0;
@@ -1683,26 +1677,22 @@ s32 ATERMRunConfigProtocol(void) {
ATERMMd5Update(&digestContext, gAtermDigestFill,
digestBytes < 56 ? 56 - digestBytes : 120 - digestBytes);
ATERMMd5Update(&digestContext, digestLength, sizeof(digestLength));
state0 = digestContext.state[0];
state1 = digestContext.state[1];
state2 = digestContext.state[2];
state3 = digestContext.state[3];
response->authentication.digest[0] = state0;
response->authentication.digest[1] = state0 >> 8;
response->authentication.digest[2] = state0 >> 16;
response->authentication.digest[3] = state0 >> 24;
response->authentication.digest[4] = state1;
response->authentication.digest[5] = state1 >> 8;
response->authentication.digest[6] = state1 >> 16;
response->authentication.digest[7] = state1 >> 24;
response->authentication.digest[8] = state2;
response->authentication.digest[9] = state2 >> 8;
response->authentication.digest[10] = state2 >> 16;
response->authentication.digest[11] = state2 >> 24;
response->authentication.digest[12] = state3;
response->authentication.digest[13] = state3 >> 8;
response->authentication.digest[14] = state3 >> 16;
response->authentication.digest[15] = state3 >> 24;
response->authentication.digest[0] = digestContext.state[0];
response->authentication.digest[1] = digestContext.state[0] >> 8;
response->authentication.digest[2] = digestContext.state[0] >> 16;
response->authentication.digest[3] = digestContext.state[0] >> 24;
response->authentication.digest[4] = digestContext.state[1];
response->authentication.digest[5] = digestContext.state[1] >> 8;
response->authentication.digest[6] = digestContext.state[1] >> 16;
response->authentication.digest[7] = digestContext.state[1] >> 24;
response->authentication.digest[8] = digestContext.state[2];
response->authentication.digest[9] = digestContext.state[2] >> 8;
response->authentication.digest[10] = digestContext.state[2] >> 16;
response->authentication.digest[11] = digestContext.state[2] >> 24;
response->authentication.digest[12] = digestContext.state[3];
response->authentication.digest[13] = digestContext.state[3] >> 8;
response->authentication.digest[14] = digestContext.state[3] >> 16;
response->authentication.digest[15] = digestContext.state[3] >> 24;
{
u8* contextByte = (u8*)&digestContext;
for (index = 0; index < sizeof(digestContext); index++) {
@@ -1730,7 +1720,6 @@ s32 ATERMRunConfigProtocol(void) {
{
AtermRequestOption16* option = (AtermRequestOption16*)response->authentication.decoded.options;
AtermSocketAddress sendAddress;
s32 messageLength;
memset(response->data, 0, 8);
memset(option, 0, 4);
option->type = SOHtoNs(0x102);
@@ -1739,14 +1728,13 @@ s32 ATERMRunConfigProtocol(void) {
memcpy(option->value, response->authentication.digest, 8);
gAtermReplyLength = (u8*)(option + 1) - response->data;
response->authentication.decoded.length = gAtermReplyLength - 8;
messageLength = ATERMBuildEncryptedMessage((u16*)gAtermConfigurationResult.packetBuffer, 4,
gAtermMessageLength = ATERMBuildEncryptedMessage((u16*)gAtermConfigurationResult.packetBuffer, 4,
(u16*)response->data, gAtermReplyLength, gAtermConfigurationResult.connectionPrefix);
gAtermMessageLength = messageLength;
sendAddress.length = 8;
sendAddress.family = 2;
sendAddress.address = 0xFFFFFFFF;
sendAddress.port = SOHtoNs(0xE601);
SOSendTo(socket, gAtermConfigurationResult.packetBuffer, messageLength, 0, &sendAddress);
SOSendTo(socket, gAtermConfigurationResult.packetBuffer, gAtermMessageLength, 0, &sendAddress);
lastSendTime = (u32)(OSGetTime() / (__mulhwu(reciprocal, OS_BUS_CLOCK >> 2) >> 6));
memset(&gScanSettings, 0, 0x254);
gAtermProtocolState = 8;

View File

@@ -1,4 +1,3 @@
#define IPL_SETTING_NOVTABLE
#define IPL_SETTING_RECT_OUT_OF_LINE
#define IPL_SETTING_IMPLEMENTATION
#include "scene/setting/iplSetting.h"
@@ -1510,8 +1509,7 @@ namespace ipl {
}
if (mpWiiSettingFlag->smthMsgData >= 2 && mpWiiSettingFlag->smthMsgData <= 7) {
GXRenderModeObj renderMode;
renderMode = *System::getRenderModeObj();
GXRenderModeObj renderMode = *System::getRenderModeObj();
u32 left;
u32 top;
u32 width;

View File

@@ -884,180 +884,172 @@ namespace ipl {
return ret;
}
static inline void verifySavedataZD(EGG::Heap* heap, ESTitleId titleId, NANDFileInfo* fileInfo) {
char path[NAND_MAX_PATH];
s32 ret;
u8* saveData = NULL;
BOOL fileOpen = FALSE;
BOOL deleteSaveData = FALSE;
sprintf(path, "/title/%08x/%08x/data/%s", (u32)((titleId & 0x00FFFFFFFFFFFFFFULL) >> 32), (u32)(titleId & 0x00FFFFFFFFFFFFFFULL), "zeldaTp.dat");
if (!ESMisc::ChangeUid(titleId)) {
OSReport("%s::%s: ChangeUid failed\n", __FILE__, __FUNCTION__);
ESMisc::DeleteTitle(heap, titleId);
} else {
ret = NANDPrivateOpen(path, fileInfo, NAND_ACCESS_READ);
if (ret == NAND_RESULT_NOEXISTS) {
OSReport("%s::%s: Does not exist %s: %d\n", __FILE__, __FUNCTION__, path, ret);
} else if (ret != NAND_RESULT_OK) {
OSReport("%s::%s: Open save data file failed: %d\n", __FILE__, __FUNCTION__, ret);
} else {
fileOpen = TRUE;
saveData = (u8*)heap->alloc(0x4000, -DEFAULT_ALIGN);
if (saveData == NULL) {
OSReport("%s::%s: Alloc failed: %d\n", __FILE__, __FUNCTION__, -2);
} else {
memset(saveData, 0, 0x4000);
ret = NANDRead(fileInfo, saveData, 0x4000);
if (ret < 0) {
OSReport("%s::%s: Read file failed: %d\n", __FILE__, __FUNCTION__, ret);
goto cleanup;
} else if (ret != 0x4000) {
OSReport("%s::%s: File size is not correct: %d\n", __FILE__, __FUNCTION__, ret);
deleteSaveData = TRUE;
} else {
u32 offset = 8;
u32 j = 0;
BOOL valid = FALSE;
while (j < 3) {
u8* block = saveData + offset;
if (!checkForNullTermination((char*)block + 0x4e, 8) ||
!checkForNullTermination((char*)block + 0x58, 8) ||
!checkForNullTermination((char*)block + 0x72, 8) ||
!checkForNullTermination((char*)block + 0x8e, 8) ||
!checkForNullTermination((char*)block + 0x1b4, 0x11) ||
!checkForNullTermination((char*)block + 0x1c5, 0x11)) {
goto verify_failed;
}
j++;
offset += 0xa94;
}
offset = 0x2008;
j = 0;
while (j < 3) {
u8* block = saveData + offset;
if (!checkForNullTermination((char*)block + 0x4e, 8) ||
!checkForNullTermination((char*)block + 0x58, 8) ||
!checkForNullTermination((char*)block + 0x72, 8) ||
!checkForNullTermination((char*)block + 0x8e, 8) ||
!checkForNullTermination((char*)block + 0x1b4, 0x11) ||
!checkForNullTermination((char*)block + 0x1c5, 0x11)) {
goto verify_failed;
}
j++;
offset += 0xa94;
}
valid = TRUE;
verify_failed:
if (!valid) {
OSReport("%s::%s: Verify failed for %016llx\n", __FILE__, __FUNCTION__,
titleId);
deleteSaveData = TRUE;
}
}
NANDClose(fileInfo);
fileOpen = FALSE;
if (deleteSaveData) {
ESMisc::DeleteSavedata(titleId, heap);
}
}
}
}
cleanup:
if (saveData != NULL) {
heap->free(saveData);
}
if (fileOpen) {
NANDClose(fileInfo);
}
ESMisc::ChangeUid(SYSMENU_TITLE_ID);
}
static inline void DeleteTicketsForce(EGG::Heap* heap, ESTitleId titleId, u8* ticketViews, u32* ticketViewCount) {
ESTicketView* ticketViewList = NULL;
s32 ret;
memset(ticketViews, 0, OSRoundUp32B(sizeof(ESTicketView)));
ret = ES_GetTicketViews(titleId, NULL, ticketViewCount);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, __FUNCTION__, ret, titleId);
} else if (*ticketViewCount != 0) {
ticketViewList = (ESTicketView*)heap->alloc(*ticketViewCount * OSRoundUp32B(sizeof(ESTicketView)), -DEFAULT_ALIGN);
ret = ES_GetTicketViews(titleId, ticketViewList, ticketViewCount);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, __FUNCTION__, ret, titleId);
} else {
for (u32 j = 0; j < *ticketViewCount; j++) {
memcpy(ticketViews, (u8*)ticketViewList + j * sizeof(ESTicketView), sizeof(ESTicketView));
ret = ES_DeleteTicket((ESTicketView*)ticketViews);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_DeleteTicket failed: %d for %016llx\n", __FILE__, __FUNCTION__, ret,
((ESTicketView*)ticketViews)->ticketId);
}
}
}
}
if (ticketViewList != NULL) {
heap->free(ticketViewList);
}
}
static inline s32 InitSavedata(EGG::Heap* heap) {
u8 ticketViews[OSRoundUp32B(sizeof(ESTicketView))] ALIGN32;
NANDFileInfo fileInfo ALIGN32;
u32 ticketViewCount;
ESTitleId* titleIds = NULL;
void ESMisc::DeleteUnauthorizedData(EGG::Heap* heap) {
u32 titleCount = 0;
ESTitleId* titleIds = NULL;
char path[88];
NANDFileInfo fileInfo ALIGN32;
u8 ticketViews[0xe0] ALIGN32;
u32 ticketViewCount;
ESTicketView* ticketViewList;
s32 ret = ES_ListTitlesOnCard(NULL, &titleCount);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: Failed to ES_ListTitlesOnCard1: %d\n", __FILE__, __FUNCTION__, ret);
goto cleanup;
}
titleIds = (ESTitleId*)heap->alloc(OSRoundUp32B(titleCount * sizeof(ESTitleId)), -DEFAULT_ALIGN);
if (ret == ES_ERR_OK) {
titleIds = (ESTitleId*)heap->alloc(OSRoundUp32B(titleCount * sizeof(ESTitleId)), -DEFAULT_ALIGN);
if (titleIds == NULL) {
OSReport("%s::%s: Unable to allocate\n", __FILE__, __FUNCTION__);
goto cleanup;
}
ret = ES_ListTitlesOnCard(titleIds, &titleCount);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: Failed to ES_ListTitlesOnCard2: %d\n", __FILE__, __FUNCTION__, ret);
goto cleanup;
}
OSReport("%s::%s: Unable to allocate\n", __FILE__, "InitSavedata");
} else {
ret = ES_ListTitlesOnCard(titleIds, &titleCount);
if (ret == ES_ERR_OK) {
u32 titleIdOffset = 0;
for (u32 i = 0; i < titleCount; i++) {
if ((titleIds[i] & 0xFFFFFFFFFFFFFF00ULL) == 0x00010000525A4400ULL) {
verifySavedataZD(heap, titleIds[i], &fileInfo);
u32 titleIdHi = *(u32*)((u8*)titleIds + titleIdOffset);
u32 titleIdLo = *(u32*)((u8*)titleIds + titleIdOffset + 4);
if ((titleIdLo & 0xffffff00) == 0x525a4400 && titleIdHi == 0x10000) {
u8* saveData = NULL;
BOOL fileOpen = FALSE;
BOOL deleteSaveData = FALSE;
sprintf(path - 8, "/title/%08x/%08x/data/%s", titleIdHi & 0xffffff, titleIdLo, "zeldaTp.dat");
if (!ChangeUid(((ESTitleId)titleIdHi << 32) | titleIdLo)) {
OSReport("%s::%s: ChangeUid failed\n", __FILE__, "verifySavedataZD");
DeleteTitle(heap, ((ESTitleId)titleIdHi << 32) | titleIdLo);
} else {
ret = NANDPrivateOpen(path - 8, (NANDFileInfo*)((u8*)&fileInfo - 0x20), NAND_ACCESS_READ);
if (ret == NAND_RESULT_NOEXISTS) {
OSReport("%s::%s: Does not exist %s: %d\n", __FILE__, "verifySavedataZD", path - 8, ret);
} else if (ret != NAND_RESULT_OK) {
OSReport("%s::%s: Open save data file failed: %d\n", __FILE__, "verifySavedataZD", ret);
} else {
fileOpen = TRUE;
saveData = (u8*)heap->alloc(0x4000, -DEFAULT_ALIGN);
if (saveData == NULL) {
OSReport("%s::%s: Alloc failed: %d\n", __FILE__, "verifySavedataZD", -2);
} else {
memset(saveData, 0, 0x4000);
ret = NANDRead((NANDFileInfo*)((u8*)&fileInfo - 0x20), saveData, 0x4000);
if (ret < 0) {
OSReport("%s::%s: Read file failed: %d\n", __FILE__, "verifySavedataZD", ret);
} else if (ret != 0x4000) {
OSReport("%s::%s: File size is not correct: %d\n", __FILE__, "verifySavedataZD", ret);
deleteSaveData = TRUE;
} else {
u32 offset = 8;
u32 j = 0;
BOOL valid = FALSE;
while (j < 3) {
u8* block = saveData + offset;
if (!checkForNullTermination((char*)block + 0x4e, 8) ||
!checkForNullTermination((char*)block + 0x58, 8) ||
!checkForNullTermination((char*)block + 0x72, 8) ||
!checkForNullTermination((char*)block + 0x8e, 8) ||
!checkForNullTermination((char*)block + 0x1b4, 0x11) ||
!checkForNullTermination((char*)block + 0x1c5, 0x11)) {
goto verify_failed;
}
j++;
offset += 0xa94;
}
offset = 0x2008;
j = 0;
while (j < 3) {
u8* block = saveData + offset;
if (!checkForNullTermination((char*)block + 0x4e, 8) ||
!checkForNullTermination((char*)block + 0x58, 8) ||
!checkForNullTermination((char*)block + 0x72, 8) ||
!checkForNullTermination((char*)block + 0x8e, 8) ||
!checkForNullTermination((char*)block + 0x1b4, 0x11) ||
!checkForNullTermination((char*)block + 0x1c5, 0x11)) {
goto verify_failed;
}
j++;
offset += 0xa94;
}
valid = TRUE;
verify_failed:
if (!valid) {
OSReport("%s::%s: Verify failed for %016llx\n", __FILE__, "verifySavedataZD",
((ESTitleId)titleIdHi << 32) | titleIdLo);
deleteSaveData = TRUE;
}
}
NANDClose((NANDFileInfo*)((u8*)&fileInfo - 0x20));
fileOpen = FALSE;
if (deleteSaveData) {
DeleteSavedata(((ESTitleId)titleIdHi << 32) | titleIdLo, heap);
}
}
}
}
if (saveData != NULL) {
heap->free(saveData);
}
if (fileOpen) {
NANDClose((NANDFileInfo*)((u8*)&fileInfo - 0x20));
}
ChangeUid(SYSMENU_TITLE_ID);
continue;
}
switch (titleIds[i]) {
case 0x0001000844495343ULL:
case 0x000100014A4F4449ULL:
case 0x0001000148415858ULL:
case 0x0001000844564458ULL:
case 0x000100084449534BULL:
ES_DeleteTitle(titleIds[i]);
DeleteTicketsForce(heap, titleIds[i], ticketViews, &ticketViewCount);
break;
if ((((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x0001000844495343ULL ||
((((ESTitleId)titleIdHi << 32) | titleIdLo) < 0x0001000844495343ULL &&
((((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x000100014a4f4449ULL ||
((((ESTitleId)titleIdHi << 32) | titleIdLo) > 0x000100014a4f4449ULL &&
(((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x0001000148415858ULL))) ||
((((ESTitleId)titleIdHi << 32) | titleIdLo) > 0x0001000844495343ULL &&
((((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x0001000844564458ULL ||
((((ESTitleId)titleIdHi << 32) | titleIdLo) > 0x0001000844564458ULL &&
(((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x000100084449534bULL)))) {
ESTitleId titleId = *(ESTitleId*)((u8*)titleIds + titleIdOffset);
ES_DeleteTitle(titleId);
ticketViewList = NULL;
memset(ticketViews, 0, sizeof(ticketViews));
ret = ES_GetTicketViews(titleId, NULL, &ticketViewCount);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, "DeleteTicketsForce", ret, titleId);
} else if (ticketViewCount != 0) {
ticketViewList = (ESTicketView*)heap->alloc(ticketViewCount * 0xe0, -DEFAULT_ALIGN);
ret = ES_GetTicketViews(titleId, ticketViewList, &ticketViewCount);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, "DeleteTicketsForce", ret, titleId);
} else {
for (u32 j = 0; j < ticketViewCount; j++) {
memcpy(ticketViews, (u8*)ticketViewList + j * sizeof(ESTicketView), 0xd8);
ret = ES_DeleteTicket((ESTicketView*)ticketViews);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_DeleteTicket failed: %d for %016llx\n", __FILE__, "DeleteTicketsForce", ret,
((ESTicketView*)ticketViews)->ticketId);
}
}
}
}
if (ticketViewList != NULL) {
heap->free(ticketViewList);
}
}
titleIdOffset += 8;
}
} else {
OSReport("%s::%s: Failed to ES_ListTitlesOnCard2: %d\n", __FILE__, "InitSavedata", ret);
}
}
} else {
OSReport("%s::%s: Failed to ES_ListTitlesOnCard1: %d\n", __FILE__, "InitSavedata", ret);
}
cleanup:
if (titleIds != NULL) {
heap->free(titleIds);
}
return ret;
}
s32 ESMisc::DeleteUnauthorizedData(EGG::Heap* heap) {
return InitSavedata(heap);
return;
}
BOOL checkForNullTermination(char* str, u32 len) {

View File

@@ -1,41 +0,0 @@
# CHANSVm load-constant error preservation
Baseline: 449529d92405f8f7fda610660c7794914a81dfe6. Scope: CHANSVm.c only; no linking classifications or headers changed.
## Retained correction
LOAD_STRING_CONST must preserve a failure from CHANSVmDeleteObject. The original object tests the deletion return and branches directly to the local result merge when it is nonzero. The load-string error is selected only after deletion succeeds and the constant index is out of range or has no string payload. The prior C instead overwrote every deletion error with CHANS_VM_ERR_LOAD_STRING_CONST.
A native destructor that returns false is a concrete error-producing path through CHANSVmDeleteObject; this distinction is observable, not merely a compiler-scheduling preference.
The new local loadResult preserves that error, keeps constant validation and installation inside the successful-deletion block, and merges the result afterward. Target and rebuilt blocks have the same instruction count and control-flow destinations; remaining operand differences are registers. No strings, data layout, or generated jump-table destinations changed.
## Measurements
- All 233 target functions have compiled C implementations; this is not a claim that all are exact or independently behavior-proven.
- Instruction-exact functions: 221/233 -> 221/233; every objdiff-exact function also passes ctxdiff.
- Unit decompiled/fuzzy: 99.364426% -> 99.383840%.
- Exact code: 37608/53564 bytes -> 37608/53564 bytes (70.211334%).
- Exact data: 6904/6904 bytes -> 6904/6904 bytes (100%).
- CHANSVmStep: 96.466080% -> 96.673584%; 1253/1253 instructions; ctxdiff differing positions 314 -> 297.
- Per-function score regressions relative to the fresh baseline report: zero.
- The unit remains NonMatching/unlinked; no link flags were changed.
## Attempts
1. Read previous round/wave logs and recent local trials; establish live baseline and run pool_diff first: 125 strings identical.
2. Replace the load-string shared error/goto path with a typed local error result and successful-deletion-only constant validation. Retained: correct error behavior, higher fuzzy score, unchanged exact code/data.
3. Separately tried consolidating GET_PROPERTY_NAME's local found flag and removing two unused array-index assignments. Rejected and restored completely: Step shrank to 1249 instructions and data dropped to 2232/6904. This unrelated trial is absent from the final source.
## Validation
- Full 43U build passed with the assigned wibo wrapper and WIBO_SJIS_MISSING_IMPORTS=1.
- DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d.
- pool_diff: 125/125 identical strings.
- .data: 4672/4672 bytes identical; all 352 canonical relocations identical.
- .rodata: 1432/1432 bytes identical; all 258 canonical relocations identical.
- All 233 functions compared with ctxdiff/odiff: 221 exact; no falsely exact objdiff functions.
- git diff --check passed.
- Source-extracted host C harness passed six load-constant cases: missing operand; deletion failure with valid index; deletion failure with invalid index; invalid index after successful deletion; null payload; successful installation. The harness stubs surrounding VM dependencies and checks C behavior only; no Wii runtime execution is claimed.
Source is paused after this focused candidate for parent review. The remaining 12 functions are still non-exact.

View File

@@ -1,86 +0,0 @@
# MD5 rotation-expression reconstruction, 2026-10-02
Baseline: `449529d9`, 43U only. Owned source: `libs/RevoEX/src/net/md5.c`.
The current user priority permits validated structural/fuzzy improvements before
exact matching and linking. This is a partial matching candidate, not an exact
match or a linking change. AES experiments were saved outside the checkout and
AES was restored to the baseline before this candidate was validated.
## Source evidence
- Ground truth: `build/43U/obj/libs/RevoEX/src/net/md5.o`, `ProcessBlock`.
- The target is 0x4C8 bytes / 306 instructions, with a 0x20-byte stack frame.
- Each of the sixteen unrolled MD5 steps contains two byte-reversed word loads.
The first pair is at function-relative offsets 0x3C and 0x40. The right-shift
half consumes the first value, and the left-shift half consumes the second.
- The target retains four additions across the two rotation halves: the
right-shift half adds the message word to (round constant + state), and the
left-shift half adds the state to (message word + round constant). The state
includes the round Boolean function. The first rotation uses right shift 25
and left shift 7; the remaining shifts follow the existing MD5 round schedule.
- The index-table address is first materialized after the first sixteen steps,
rather than before the sequential-word round.
- The inline helper expresses these real unsigned 32-bit operands and restores
the target-sized body. It introduces no assembly, volatile qualifier,
uninitialized value, fake storage, padding, or compiler-option change.
- All four round algorithms, all 64 constants, all 48 indices, and all public
API bodies are otherwise unchanged. The old ROTATE macro became unused and
was removed.
## Attempts
1. Direct pointer-form byte-reversed loads and alternate ordinary arithmetic
groupings: 274-294 instructions, at best near the starting score. Rejected.
2. A typed inline endian-load wrapper: improved instruction similarity but
retained 276 instructions and insufficient target operation boundaries.
3. Rotation-expression helpers without independent load results: 288-290
instructions, approximately 41-44% ProcessBlock fuzzy. Rejected.
4. Explicitly named byte-reversed operands for the two rotation halves:
306 instructions / 81.82026% fuzzy. Retained the target's first-read/right-
shift ordering. Reversing those loads reached 82.0% but added two instructions
and contradicted the target's operand ordering, so it was rejected.
5. Sequential partial-sum statements and equivalent regroupings did not
improve the retained structural form. No register-only declaration sweep.
## Validation
Command setup:
`python3 configure.py --version 43U --wrapper ../toolchain/wibo-build/wibo`
`WIBO_SJIS_MISSING_IMPORTS=1 ../.venv/bin/ninja`
- `pool_diff.py`: identical empty MD5 string pool, 0/0 strings.
- `.data`: all 448 bytes identical. The source `.sdata` is the one-byte
end marker (0x80); the target has the same byte followed by seven alignment
zeros. This existing section-size difference is unchanged, and objdiff
reports `.sdata` and unit data at 100%. No padding was added.
- `NETMD5Init`: 16/16 instructions, ctxdiff diffs 0, objdiff 100%.
- `NETMD5Update`: 60/60 instructions, ctxdiff diffs 0, objdiff 100%.
- `NETMD5GetDigest`: 74/74 instructions, ctxdiff diffs 0, objdiff 100%.
- `ProcessBlock`: 294 -> 306 instructions against target 306;
43.290848 -> 81.82026% fuzzy. Final ctxdiff has 255 positional differences,
primarily allocation, scheduling and remaining arithmetic grouping. Not exact.
- MD5 unit: 61.945175 -> 87.80044% fuzzy; exact 3/4 -> 3/4;
exact code 600/1824 unchanged; data 456/456 (100%) unchanged; unlinked unchanged.
- Full 1027-unit report: no unit regressed in exact functions, exact code,
exact data or fuzzy score versus the baseline report. Overall fuzzy moved
99.588615 -> 99.60437%; exact code and linking did not change.
- Full 43U build passed. `build/43U/ok` passed. DOL SHA1:
`26116613f624061ba99c8d1a299aaa6efa85670d`.
Host algorithm validation: `/tmp/crypto-remainder/validate_md5.py` compiles the
production source unchanged with host shims for PPC byte-reversed intrinsics.
It verifies ProcessBlock through NETMD5Update with externally supplied RFC1321
padding, comparing state words with Python hashlib. The host test deliberately
does not exercise GetDigest's platform-specific big-endian length stores.
Result: 3,088 successful digest/chunking comparisons, covering the seven RFC1321
example strings, one million `a` bytes, 1,500 seeded messages, lengths around
55/56/63/64/65 and larger block boundaries, and fixed/random chunk sizes.
Run: `python3 /tmp/crypto-remainder/validate_md5.py`.
Local evidence (not committed or uploaded): `/tmp/crypto-remainder/md5.target`,
`md5-final.ctx`, `md5-final.json`, `baseline.json`, `full-build.log`, and the
host test plus its header shim. Only source and this summary are committed.
GATE: partial decompilation candidate validated; no regressions; exact matching
and linking remain open. No claim of all-100% completion.

View File

@@ -1,129 +0,0 @@
# System remainder decompilation, 2026-10-02
Baseline: `449529d92405f8f7fda610660c7794914a81dfe6`.
Branch: `agent/bittle/allhands-system-decompile`.
Owned units: `src/utility/iplESMisc.cpp`, `src/scene/setting/AOSS.c`,
`src/scene/setting/ATERM.c`. Parent additionally approved the single ESMisc
return-type declaration change in `include/utility/iplESMisc.h`.
The current user priority is complete source reconstruction first, exact code
matching second, linking last. This candidate is decompilation progress, not an
exact match or a linking change. No configuration, symbol, split, or link flag
was changed. AOSS and ATERM are unchanged.
## Initial audit
- Read AGENTS.md, CONTRIBUTING.md, local skill inventory, AOSS/ATERM attempt
histories, and ESMisc rounds 9/11. The sole local skill is unrelated TypeSafe
integration guidance.
- Configured and built only 43U with the approved Wibo wrapper.
- Before source work, pool_diff found ATERM 0/0 strings and AOSS 1/1 identical.
ESMisc first diverged at string 83; both contained 114 strings.
- ESMisc's 30 exact functions were preserved in earlier rounds, but a meaningful
helper reconstruction had been discarded solely because it was not exact.
Reconstructed it from the current C++ and target object, without importing an
old experimental source or altering linker behavior.
## ESMisc reconstruction
Restored three ordinary inline boundaries named by the target's diagnostic
literals: `verifySavedataZD`, `DeleteTicketsForce`, and `InitSavedata`.
`ESMisc::DeleteUnauthorizedData` returns the initializer status.
Concrete correctness corrections:
1. Use a real NAND_MAX_PATH buffer and a real caller-owned, 32-byte-aligned
NANDFileInfo. Removed the out-of-object `path - 8` and `fileInfo - 0x20`
accesses. The caller also owns the aligned, rounded ticket-view scratch.
2. Traverse `ESTitleId` values by typed array index, with one unconditional loop
increment for every title. The old verifier branch continued without
advancing its separate byte offset and could repeat the same title.
3. Replace the handwritten nested 64-bit switch-lowering expression with the
five actual title cases and the independently masked save-title predicate.
4. Preserve the two ES_ListTitlesOnCard results independently of inlined file
and ticket operation status. The public declaration now returns s32.
5. A negative NANDRead result jumps to cleanup, which frees the save buffer
before closing the still-open file. The old source took the success-path
close before freeing it. Successful or invalid-size reads retain their
close-before-delete/free path.
6. Use sizeof(ESTicketView) for the 0xD8-byte copy and OSRoundUp32B for the 0xE0
scratch/allocation extent, preserving the target's distinct sizes.
### ABI and control-flow evidence
Target function: address 0x813673E0, size 0x704 (449 instructions).
At original object offsets 0x1D20 and 0x1D9C, the two enumeration return values
are saved in r27. Calls through both verifier/ticket paths leave that saved
value independent. At 0x23C0 it is copied to return register r3 after the
optional title-list free. The prior void declaration discarded this ABI.
The only declaration is in include/utility/iplESMisc.h. The only call is
src/system/iplSystem.cpp:680; it intentionally ignores the result. The symbol
name is unchanged because the return type is not encoded in this member name.
All 1027 compiled source objects were compared after a forced full rebuild;
iplSystem and every unit except iplESMisc were byte/relocation unchanged.
The target's verifier branch joins the common increment at 0x238C (index +1,
byte offset +8). Its negative-read path joins cleanup at 0x2104, whereas its
successful close begins at 0x20E0. The reconstruction restores these distinct
paths instead of compensating with stack offsets or register tricks.
### Measurements
| Unit / measure | Before | After |
| --- | ---: | ---: |
| ESMisc exact functions | 30/31 | 30/31 |
| ESMisc exact code | 9404/11200 | 9404/11200 |
| ESMisc fuzzy | 96.76036% | 99.33143% |
| DeleteUnauthorizedData fuzzy | 79.797325% | 95.830734% |
| Function instructions | 434/449 | 446/449 |
| ESMisc matched data | 4416/4416 | 4416/4416 |
| ATERM exact / fuzzy / data | 17/26; 96.624664%; 18584/18864 | unchanged |
| AOSS exact / fuzzy / data | 16/21; 96.777916%; 3928/3928 | unchanged |
| Whole-report fuzzy | 99.588615% | 99.598236% |
pool_diff now reports all 114 strings identical. The source .data is 4378
bytes and exactly equals the original section's first 4378 bytes. The target
section is 4384 bytes and ends in six zero alignment bytes. No synthetic
padding was added. The objdiff data score remains 100%, and the literal audit
checks 204 arguments in all 30 exact functions with zero candidates or errors.
The candidate remains non-exact. ctxdiff shows 446/449 instructions and
remaining register allocation, -1 mask materialization, and scratch-pointer
lifetime differences. No brute-force declaration/register search was run.
## Validation
Commands:
- python3 configure.py --version 43U --wrapper ../toolchain/wibo-build/wibo
- Delete generated native `build/43U/src/**/*.o`, retaining a private baseline
object snapshot for comparison.
- WIBO_SJIS_MISSING_IMPORTS=1 ../.venv/bin/ninja all_source build/43U/report.json build/43U/ok
- PYTHONPATH=../local-tools ../.venv/bin/python tools/decomp-assist/pool_diff.py
- PYTHONPATH=../local-tools ../.venv/bin/python tools/decomp-assist/ctxdiff.py src/utility/iplESMisc DeleteUnauthorizedData__Q33ipl7utility6ESMiscFPQ23EGG4Heap
- PYTHONPATH=../local-tools ../.venv/bin/python tools/decomp-assist/literal_reference_diff.py src/utility/iplESMisc
- Compare every unit in the fresh report and all 1027 source objects' allocated
bytes and normalized relocations against the baseline.
- git diff --check
Full rebuild passed (1031 Ninja steps). DOL SHA1:
`26116613f624061ba99c8d1a299aaa6efa85670d`.
Only the ESMisc report changed: its fuzzy and one function's fuzzy improved.
No report metric regressed. Only ESMisc's allocated .text and .data changed:
.text 11360 -> 11408 bytes (390 relocations on both sides), .data 4378 -> 4378
bytes (zero relocations). Every other allocated section/object is unchanged.
A temporary host harness extracted the actual reconstructed helper bodies,
substituted fake Wii/heap calls, and exercised 12 control-flow scenarios:
first and second enumeration errors, title-list allocation failure, mixed
Zelda/blocked/ordinary title traversal, negative read, short read, second-save
verification failure, absent file, save-buffer allocation failure, ChangeUid
failure, ticket enumeration failure, and zero-ticket handling. Tests ran with
AddressSanitizer and UndefinedBehaviorSanitizer. LeakSanitizer is unavailable
under the execution environment's ptrace, so only that component was disabled.
The harness is supplemental behavioral validation, not a retail runtime test.
GATE: focused decompilation improvement; full 43U/DOL and no-regression checks
pass; exact-matching gate remains incomplete at 30/31. No linking claimed.

File diff suppressed because it is too large Load Diff

View File

@@ -1,48 +0,0 @@
# setting leaf — attempt log
## Decode landed this wave
### iplSetting::draw — struct-copy emission split (91.53 → 97.69, unit 99.29 → 99.70)
`GXRenderModeObj renderMode = *System::getRenderModeObj();` emitted a memcpy-style
word-copy loop (lwzu/stwu, ~8 insns). Orig emits a memberwise copy (lhz/sth for u16
fields, lwz/stw for u32, lbz/stb for the u8 arrays — ~30 insns).
Fix: split declaration from assignment:
```
GXRenderModeObj renderMode;
renderMode = *System::getRenderModeObj();
```
Copy-INITIALIZATION of a C++ POD goes through MWCC's aggregate/memcpy path;
copy-ASSIGNMENT expands memberwise. draw now 629 vs orig 632 insns.
### AOSS_Init_old (prior session, committed this wave)
dead-but-emitted else arm (`else if (state != 0)` chained-beq form), `0 <= x`
bound form, `(u32)*ptr == 1u` cast, two switch→if/else decodes, ternary-arg Sleep.
## Walls verified (ties, not structure)
### scanAP — `subi+cntlzw` bool-materialization family (3 sites)
`if (!mpMainLayout->getAnim(i)->isPlaying())` — orig materializes the callee's
bool (`addi r0,r3,-1; cntlzw; rlwinm. r0,r0,27,5,31; bne`), mine fuses to
`cmpwi 1; beq`. Tried: bool local, named Animator* local, `== true`, `== false`,
`!= 0` on the inline's return, `AnimState`-typed and `u32`-typed mState —
MWCC folds every form to the direct compare. No out-of-line isPlaying exists on
either side. Residual also includes 2-3 insns of lwz/addi scheduling ties.
### convertRevIP (98.70)
Normalized-identical instruction stream (73=73 insns); fuzzy residual is a
word-level register binding — regname family.
### draw residual (97.69, -3 insns)
Two clusters: a `bne`/`beq+lbz+b` 3-insn branch-layout diff around the
browserWindow guard (O56-62), and an int→f32 divide/store scheduling window
(`srawi/stw/lfd/fsubs/fmr`, O275-293). The `beq '#F'` diffs in the normalized
log are normalization artifacts (branch-target immediates), not real diffs.
### AOSS/AOSSSendHelloRequest
Identical unrolled CRC x8 structure verified; residual is table-base pinning.
### ATERM Md5Update
Index-form kept (fuzzy 91.26 > pointer-walk 84.21 — fuzzy is positional).
## Owner ruling (PR #973)
Dead objects that only pad a section are forbidden; unreferenced .sbss/.data
gaps stay unowned unless a target relocation references the address.