Compare commits
4 Commits
cleanup/se
...
agent/w100
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50c607f457 | ||
|
|
d5133925f4 | ||
|
|
f26eeb4527 | ||
|
|
559687ce69 |
@@ -21841,7 +21841,7 @@ globalNames__Q23www9trasition = .sdata:0x81696300; // type:object size:0x8 scope
|
|||||||
@1425 = .sdata:0x81696308; // type:object size:0x1 scope:local
|
@1425 = .sdata:0x81696308; // type:object size:0x1 scope:local
|
||||||
gEnableDpd = .sdata:0x81696310; // type:object size:0x4 data:4byte
|
gEnableDpd = .sdata:0x81696310; // type:object size:0x4 data:4byte
|
||||||
globalNames__Q23www10wiisetting = .sdata:0x81696314; // type:object size:0x8
|
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_8169631D = .sdata:0x8169631D; // type:object size:0x8 data:string
|
||||||
lbl_81696325 = .sdata:0x81696325; // type:object size:0x4 data:string
|
lbl_81696325 = .sdata:0x81696325; // type:object size:0x4 data:string
|
||||||
lbl_81696329 = .sdata:0x81696329; // type:object size:0x8 data:string
|
lbl_81696329 = .sdata:0x81696329; // type:object size:0x8 data:string
|
||||||
|
|||||||
@@ -397,6 +397,8 @@ s32 WADImportGetBlocks(char* path, MEMAllocator* allocator, WADLocation location
|
|||||||
s32 result;
|
s32 result;
|
||||||
u32 fileOffset;
|
u32 fileOffset;
|
||||||
WADFileEntry* allocatedFiles;
|
WADFileEntry* allocatedFiles;
|
||||||
|
void* fileNames;
|
||||||
|
void* titleList;
|
||||||
BOOL streamOpened;
|
BOOL streamOpened;
|
||||||
u32 transferId;
|
u32 transferId;
|
||||||
u32 contentCount;
|
u32 contentCount;
|
||||||
@@ -406,9 +408,11 @@ s32 WADImportGetBlocks(char* path, MEMAllocator* allocator, WADLocation location
|
|||||||
u32 skipTitleMeta = flags & 4;
|
u32 skipTitleMeta = flags & 4;
|
||||||
WADFileHeader* fileHeader;
|
WADFileHeader* fileHeader;
|
||||||
|
|
||||||
streamOpened = FALSE;
|
|
||||||
fileOffset = 0;
|
fileOffset = 0;
|
||||||
|
fileNames = 0;
|
||||||
|
titleList = 0;
|
||||||
allocatedFiles = 0;
|
allocatedFiles = 0;
|
||||||
|
streamOpened = FALSE;
|
||||||
memset(&workspace.unpackInfo, 0, sizeof(WADUnpackInfo));
|
memset(&workspace.unpackInfo, 0, sizeof(WADUnpackInfo));
|
||||||
if (fileListOut != 0) {
|
if (fileListOut != 0) {
|
||||||
*fileListOut = 0;
|
*fileListOut = 0;
|
||||||
@@ -521,6 +525,12 @@ s32 WADImportGetBlocks(char* path, MEMAllocator* allocator, WADLocation location
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
_WADFreeMemory(&workspace.unpackInfo, allocator);
|
_WADFreeMemory(&workspace.unpackInfo, allocator);
|
||||||
|
if (fileNames != 0) {
|
||||||
|
_WADMemFree(allocator, fileNames);
|
||||||
|
}
|
||||||
|
if (titleList != 0) {
|
||||||
|
_WADMemFree(allocator, titleList);
|
||||||
|
}
|
||||||
if ((fileListOut != 0) && (result != 0)) {
|
if ((fileListOut != 0) && (result != 0)) {
|
||||||
if (allocatedFiles != 0) {
|
if (allocatedFiles != 0) {
|
||||||
_WADMemFree(allocator, allocatedFiles);
|
_WADMemFree(allocator, allocatedFiles);
|
||||||
@@ -535,7 +545,7 @@ cleanup:
|
|||||||
|
|
||||||
static s32 WAD_815BFFA8(WADImportLoopArgs* args) {
|
static s32 WAD_815BFFA8(WADImportLoopArgs* args) {
|
||||||
s32 fd = args->fd;
|
s32 fd = args->fd;
|
||||||
s32 result = 0;
|
s32 result;
|
||||||
u32 remaining = args->size;
|
u32 remaining = args->size;
|
||||||
WADImportTransfer* transfer = args->transfer;
|
WADImportTransfer* transfer = args->transfer;
|
||||||
u32 bufferIndex = 0;
|
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,
|
s32 WADImportEx(char* path, MEMAllocator* allocator, WADLocation location, u32 offset, u32 flags,
|
||||||
WADProcessCallback processCallback) {
|
WADProcessCallback processCallback) {
|
||||||
s32 result = 0;
|
s32 result;
|
||||||
ESHash* sharedContentHashes = 0;
|
ESHash* sharedContentHashes = 0;
|
||||||
ESContentId* installedContentIds = 0;
|
ESContentId* installedContentIds = 0;
|
||||||
ESContentMeta* matchingContents = 0;
|
ESContentMeta* matchingContents = 0;
|
||||||
@@ -1181,7 +1191,7 @@ static s32 WAD_815C1288(WADExportLoopArgs* args) {
|
|||||||
u32 remaining = args->size;
|
u32 remaining = args->size;
|
||||||
u32 bufferIndex = 0;
|
u32 bufferIndex = 0;
|
||||||
WADImportTransfer* transfer = args->transfer;
|
WADImportTransfer* transfer = args->transfer;
|
||||||
s32 result = 0;
|
s32 result;
|
||||||
|
|
||||||
for (; (remaining != 0) && (result == 0); bufferIndex ^= 1) {
|
for (; (remaining != 0) && (result == 0); bufferIndex ^= 1) {
|
||||||
OSMutex* mutex;
|
OSMutex* mutex;
|
||||||
@@ -1257,6 +1267,7 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
|
|||||||
s32 contentExportStarted;
|
s32 contentExportStarted;
|
||||||
s32 threadCreated = FALSE;
|
s32 threadCreated = FALSE;
|
||||||
s32 fileFd;
|
s32 fileFd;
|
||||||
|
WADBackupHeader* headerBlockHeader;
|
||||||
|
|
||||||
titleMetaSize = 0;
|
titleMetaSize = 0;
|
||||||
contentDataSize = 0;
|
contentDataSize = 0;
|
||||||
@@ -1377,7 +1388,6 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
|
|||||||
result = 0;
|
result = 0;
|
||||||
if (path == 0) {
|
if (path == 0) {
|
||||||
*sizeOut = totalSize + 0x340;
|
*sizeOut = totalSize + 0x340;
|
||||||
result = 0;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
outputBuffer = _WADMemAlloc(allocator, 0x10000);
|
outputBuffer = _WADMemAlloc(allocator, 0x10000);
|
||||||
@@ -1398,6 +1408,7 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
|
|||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
headerBlockHeader = &headerBlock.header;
|
||||||
paddedSize = sizeof(headerBlock);
|
paddedSize = sizeof(headerBlock);
|
||||||
memset(&headerBlock, 0, paddedSize);
|
memset(&headerBlock, 0, paddedSize);
|
||||||
if ((u32)WADWriteStream(&stream, &headerBlock, paddedSize) != 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.fileSize = fileDataSize;
|
||||||
headerBlock.header.numFiles = fileCount;
|
headerBlock.header.numFiles = fileCount;
|
||||||
headerBlock.header.backupAreaLen = totalSize + 0x340;
|
headerBlock.header.backupAreaLen = totalSize + 0x340;
|
||||||
result = ES_GetDeviceId(&headerBlock.header.deviceId);
|
result = ES_GetDeviceId(&headerBlockHeader->deviceId);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if ((flags & 1) != 0) {
|
if ((flags & 1) != 0) {
|
||||||
memcpy(&headerBlock.header.cidx, &existingContentMask, sizeof(existingContentMask));
|
memcpy(&headerBlockHeader->cidx, &existingContentMask, sizeof(existingContentMask));
|
||||||
}
|
}
|
||||||
if ((flags & 2) != 0) {
|
if ((flags & 2) != 0) {
|
||||||
u32 currentTitleLow;
|
u32 currentTitleLow;
|
||||||
@@ -1442,7 +1453,7 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
|
|||||||
headerBlock.header.titleId = ((u64)currentTitleHigh << 32) | currentTitleLow;
|
headerBlock.header.titleId = ((u64)currentTitleHigh << 32) | currentTitleLow;
|
||||||
}
|
}
|
||||||
if (_WADGetTransferId(transferMac) != 0) {
|
if (_WADGetTransferId(transferMac) != 0) {
|
||||||
memcpy(headerBlock.header.deviceMac, transferMac, sizeof(headerBlock.header.deviceMac));
|
memcpy(headerBlockHeader->deviceMac, transferMac, sizeof(headerBlockHeader->deviceMac));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SHA1Reset(hashContext);
|
SHA1Reset(hashContext);
|
||||||
@@ -1683,9 +1694,13 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_done:
|
file_done:
|
||||||
|
if (fileHeaderBuffer->flags[2] == 1) {
|
||||||
|
fileFd = -1;
|
||||||
|
}
|
||||||
if (fileOpened) {
|
if (fileOpened) {
|
||||||
NANDClose(&savedFile);
|
NANDClose(&savedFile);
|
||||||
}
|
}
|
||||||
|
fileFd = -1;
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
readSize = (fileHeaderBuffer->fileSize + 0x3F) & ~0x3F;
|
readSize = (fileHeaderBuffer->fileSize + 0x3F) & ~0x3F;
|
||||||
totalSize -= readSize;
|
totalSize -= readSize;
|
||||||
@@ -2921,7 +2936,7 @@ static void _WADRandPad(void* buffer, u32 size) {
|
|||||||
|
|
||||||
static s32 WAD_815C43E0(WADHashThreadArgs* args) {
|
static s32 WAD_815C43E0(WADHashThreadArgs* args) {
|
||||||
void* context = args->context;
|
void* context = args->context;
|
||||||
s32 result = 0;
|
s32 result;
|
||||||
u32 remaining = args->size;
|
u32 remaining = args->size;
|
||||||
WADImportTransfer* transfer = args->transfer;
|
WADImportTransfer* transfer = args->transfer;
|
||||||
u32 bufferIndex = 0;
|
u32 bufferIndex = 0;
|
||||||
@@ -3524,6 +3539,9 @@ s32 WADImportDVDExForBS(const char* path, void* buffer, u32 bufferSize) {
|
|||||||
parts.titleMeta = readBuffer + sectionOffset;
|
parts.titleMeta = readBuffer + sectionOffset;
|
||||||
sectionOffset += (header.tmdSize + 0x3F) & ~0x3F;
|
sectionOffset += (header.tmdSize + 0x3F) & ~0x3F;
|
||||||
}
|
}
|
||||||
|
if (header.contentSize != 0) {
|
||||||
|
contentBuffer = readBuffer + sectionOffset;
|
||||||
|
}
|
||||||
contentBuffer = readBuffer + sectionOffset;
|
contentBuffer = readBuffer + sectionOffset;
|
||||||
remainingBufferSize = bufferSize - sectionOffset;
|
remainingBufferSize = bufferSize - sectionOffset;
|
||||||
if ((u32)sectionOffset > bufferSize) {
|
if ((u32)sectionOffset > bufferSize) {
|
||||||
|
|||||||
31
tools/decomp-assist/wad.attempts.md
Normal file
31
tools/decomp-assist/wad.attempts.md
Normal 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.
|
||||||
Reference in New Issue
Block a user