Compare commits

..

1 Commits

Author SHA1 Message Date
devin
af0636d9dc decomp: wad vestigial-locals + decl-order decode (stays NonMatching, fuzzy 98.94->99.03)
Co-authored-by: coah80 <usernamecole7@gmail.com>
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-02 22:32:35 +00:00
9 changed files with 101 additions and 120 deletions

View File

@@ -21895,7 +21895,7 @@ globalNames__Q23www9trasition = .sdata:0x81696300; // type:object size:0x8 scope
@1425 = .sdata:0x81696308; // type:object size:0x1 scope:local
gEnableDpd = .sdata:0x81696310; // type:object size:0x4 data:4byte
globalNames__Q23www10wiisetting = .sdata:0x81696314; // type:object size:0x8
lbl_8169631C = .sdata:0x8169631C; // type:object size:0x1
@17315 = .sdata:0x8169631C; // type:object size:0x1 scope:local
lbl_8169631D = .sdata:0x8169631D; // type:object size:0x8 data:string
lbl_81696325 = .sdata:0x81696325; // type:object size:0x4 data:string
lbl_81696329 = .sdata:0x81696329; // type:object size:0x8 data:string

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

@@ -255,7 +255,7 @@ s32 WADGetTitleVersionEx(char* path, ESTitleId* titleId, u16* titleVersion, WADL
s32 headerInfo;
WADTitleMetadata* metadataBuffer = &metadata;
WADHeader* headerBuffer = (WADHeader*)headerBytes;
s32 result;
s32 result = 0;
u32 titleDataOffset;
s32 type;
@@ -397,6 +397,8 @@ s32 WADImportGetBlocks(char* path, MEMAllocator* allocator, WADLocation location
s32 result;
u32 fileOffset;
WADFileEntry* allocatedFiles;
void* fileNames;
void* titleList;
BOOL streamOpened;
u32 transferId;
u32 contentCount;
@@ -406,9 +408,11 @@ s32 WADImportGetBlocks(char* path, MEMAllocator* allocator, WADLocation location
u32 skipTitleMeta = flags & 4;
WADFileHeader* fileHeader;
streamOpened = FALSE;
fileOffset = 0;
fileNames = 0;
titleList = 0;
allocatedFiles = 0;
streamOpened = FALSE;
memset(&workspace.unpackInfo, 0, sizeof(WADUnpackInfo));
if (fileListOut != 0) {
*fileListOut = 0;
@@ -521,6 +525,12 @@ s32 WADImportGetBlocks(char* path, MEMAllocator* allocator, WADLocation location
cleanup:
_WADFreeMemory(&workspace.unpackInfo, allocator);
if (fileNames != 0) {
_WADMemFree(allocator, fileNames);
}
if (titleList != 0) {
_WADMemFree(allocator, titleList);
}
if ((fileListOut != 0) && (result != 0)) {
if (allocatedFiles != 0) {
_WADMemFree(allocator, allocatedFiles);
@@ -535,7 +545,7 @@ cleanup:
static s32 WAD_815BFFA8(WADImportLoopArgs* args) {
s32 fd = args->fd;
s32 result = 0;
s32 result;
u32 remaining = args->size;
WADImportTransfer* transfer = args->transfer;
u32 bufferIndex = 0;
@@ -561,7 +571,7 @@ static s32 WAD_815BFFA8(WADImportLoopArgs* args) {
s32 WADImportEx(char* path, MEMAllocator* allocator, WADLocation location, u32 offset, u32 flags,
WADProcessCallback processCallback) {
s32 result = 0;
s32 result;
ESHash* sharedContentHashes = 0;
ESContentId* installedContentIds = 0;
ESContentMeta* matchingContents = 0;
@@ -1257,6 +1267,7 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
s32 contentExportStarted;
s32 threadCreated = FALSE;
s32 fileFd;
WADBackupHeader* headerBlockHeader;
titleMetaSize = 0;
contentDataSize = 0;
@@ -1377,7 +1388,6 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
result = 0;
if (path == 0) {
*sizeOut = totalSize + 0x340;
result = 0;
goto cleanup;
}
outputBuffer = _WADMemAlloc(allocator, 0x10000);
@@ -1398,6 +1408,7 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
if (result != 0) {
goto cleanup;
}
headerBlockHeader = &headerBlock.header;
paddedSize = sizeof(headerBlock);
memset(&headerBlock, 0, paddedSize);
if ((u32)WADWriteStream(&stream, &headerBlock, paddedSize) != paddedSize) {
@@ -1414,12 +1425,12 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
headerBlock.header.fileSize = fileDataSize;
headerBlock.header.numFiles = fileCount;
headerBlock.header.backupAreaLen = totalSize + 0x340;
result = ES_GetDeviceId(&headerBlock.header.deviceId);
result = ES_GetDeviceId(&headerBlockHeader->deviceId);
if (result != 0) {
goto cleanup;
}
if ((flags & 1) != 0) {
memcpy(&headerBlock.header.cidx, &existingContentMask, sizeof(existingContentMask));
memcpy(&headerBlockHeader->cidx, &existingContentMask, sizeof(existingContentMask));
}
if ((flags & 2) != 0) {
u32 currentTitleLow;
@@ -1442,7 +1453,7 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
headerBlock.header.titleId = ((u64)currentTitleHigh << 32) | currentTitleLow;
}
if (_WADGetTransferId(transferMac) != 0) {
memcpy(headerBlock.header.deviceMac, transferMac, sizeof(headerBlock.header.deviceMac));
memcpy(headerBlockHeader->deviceMac, transferMac, sizeof(headerBlockHeader->deviceMac));
}
}
SHA1Reset(hashContext);
@@ -1683,9 +1694,13 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
}
}
file_done:
if (fileHeaderBuffer->flags[2] == 1) {
fileFd = -1;
}
if (fileOpened) {
NANDClose(&savedFile);
}
fileFd = -1;
if (result != 0) {
readSize = (fileHeaderBuffer->fileSize + 0x3F) & ~0x3F;
totalSize -= readSize;
@@ -3524,6 +3539,9 @@ s32 WADImportDVDExForBS(const char* path, void* buffer, u32 bufferSize) {
parts.titleMeta = readBuffer + sectionOffset;
sectionOffset += (header.tmdSize + 0x3F) & ~0x3F;
}
if (header.contentSize != 0) {
contentBuffer = readBuffer + sectionOffset;
}
contentBuffer = readBuffer + sectionOffset;
remainingBufferSize = bufferSize - sectionOffset;
if ((u32)sectionOffset > bufferSize) {

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

@@ -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.

View File

@@ -0,0 +1,31 @@
## WADBackupEx decode (this leaf session)
- file_done region: orig CFG has inner `goto file_done` edges landing PAST a `flags[2]==1`
check (goto-specialized entries). Faithful source = label inside the flags-if:
`if (hdr->flags[2]==1) { file_done: if (fileOpened) NANDClose(&savedFile); }`.
Orig folds the outer if to a dead lbz+cmplwi fossil (no bne) via edge-prop that
fileOpened==0 on the flags!=1 path; our MWCC emits the bne (+4B).
- result=0 at file-loop head: orig keeps ZERO in dedicated callee reg (r31);
ours spills an extra zero to stack slot (extra stw+lwz). keep-vs-remat wall.
- Several base+offset addi folds (0x340+8 vs 0x348 etc.) = documented fold family.
- GetBlocks vestigial NULL ptr locals + conditional frees = orig-faithful decode (solved).
- DVDExForBS `if (header.contentSize != 0)` dead-check fossil = conditional-assign
overwritten by later unconditional assign (solved).
## WADBackupEx decode round 2 (fossil + ptr web)
- Dead-compare fossil SOLVED: `if (A) { X = v; } ... X = v;` — conditional assign whose
store is killed by a later unconditional assign → MWCC keeps lbz+cmplwi, drops bne.
Applied: `if (flags[2]==1) { fileFd = -1; } if (fileOpened) NANDClose; fileFd = -1;`
reproduces orig's exact `lbz;cmplwi;lwz;cmpwi;beq` sequence (-8B wall gone).
- file_done label placement: label sits BEFORE the flags-if (inner gotos land past it,
outer bne/beq edges land on it) — `file_done:` above the fossil if.
- result=0 redundant-store dedup inside `if (path==0)` arm: orig omits it (already 0).
- &headerBlock member-address chains: orig emits `addi r3,r1,0x340; addi r3,r3,+off`
(remat base + member offset) for deviceId/cidx/deviceMac args. Best source form =
`WADBackupHeader* headerBlockHeader = &headerBlock.header` used for the three
member args → `addi r3,r18,+off` (structurally right; r18-kept vs orig remat =
keep-vs-remat wall). `(&x)->y` and `x.y` fold to absolute; per-site ptr assigns
fold remat+offset — all worse.
- Remaining diffs (all documented keep-vs-remat/web-coloring): `li 0;stw` vs `li;mr`
for result head store, `addi r1,0x340` remats vs r18/mr, stw 0x814/lwz 0x80c spill
webs, `li -1` fileFd slot, addi+0x80 loop-IV position, `addi r1,0x3c0` remat order.