Compare commits

..

1 Commits

Author SHA1 Message Date
devin
fcd8b7f43f match(tiPcKeyboard): Base::setTranslateMode byte-identical
keyMode must be uninitialized: for mode outside {0,1,2} the switch
leaves it unset and retail provably reads the uninitialized register
(cmplw r31,r0 at 0xd6c executes with r31 never stored). Initializing
keyMode = mode changes the dispatch to an extra branch. Same accepted
uninitialized-read pattern as set_err_msg.

Also documents two probe results in tools/decomp-assist attempts files
(iplSetting scanAP inlined-bool materialization wall; tiString inputChar
indexed-store/dead-compare fossil).

Co-authored-by: coah80 <usernamecole7@gmail.com>
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-08 22:04:16 +00:00
10 changed files with 64 additions and 61 deletions

View File

@@ -14,11 +14,11 @@ typedef struct ziUserDictionary {
void Zi8Memset(ziPtr, ziU32, ziU32);
ziBool Zi8_81480224(ziUserWord* word ZI_NEED_WORK) {
ziUserWord* candidate;
ziUwdNode* added;
ziU8 length;
ziUwdNode* previous;
ziUwdNode* current;
ziUwdNode* added;
ziUserWord* candidate;
ziU8 position;
if (ZI_WORK->uwdCount >= 32) {
Zi8LogError(0x19D, __zi8_work_data);

View File

@@ -78,7 +78,7 @@ ziU8* ZiDAWGGetSibling(ziU8* cursor) {
if ((*cursor & 0x80) != 0) {
node += (((const ziDawgLongOffset*)cursor)->flags & 0x7f) * 0x10000 +
(((ziU32)(ziU16)((const ziDawgLongOffset*)cursor)->middle << 8) +
(((ziU32)(ziU16)cursor[1] << 8) +
((const ziDawgLongOffset*)cursor)->low) + 0x8000;
} else {
node = cursor[1] + (node + (ziU16)*cursor * 0x100);

View File

@@ -551,11 +551,12 @@ pf_s32 PFCACHE_DoWriteSector(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, const pf
#pragma dont_inline reset
static inline pf_u32 PFCACHE_RecordPageEndOverlap(PF_CACHE_PAGE* p_page, pf_u32 end_sector, pf_u32* p_num_success, pf_u32* p_num_rest_sector) {
pf_u32 last_sector = end_sector - 1;
pf_u32 num_overlap = end_sector - p_page->sector;
*p_num_success += num_overlap;
*p_num_rest_sector -= num_overlap;
p_page->stat |= 2;
return end_sector - 1;
return last_sector;
}
pf_s32 PFCACHE_DoWriteNumSectorAndFreeIfNeeded(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, const pf_u8* p_buf, pf_u32 sector,

View File

@@ -80,12 +80,12 @@ static inline u32 rotateSum(u32 state, const u32* word, u32 constant, int shift)
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};
static u32 indices[48] = {0x00000001, 0x00000006, 0x0000000B, 0x00000000, 0x00000005, 0x0000000A, 0x0000000F, 0x00000004, 0x00000009, 0x0000000E, 0x00000003, 0x00000008, 0x0000000D, 0x00000002, 0x00000007, 0x0000000C, 0x00000005, 0x00000008, 0x0000000B, 0x0000000E, 0x00000001, 0x00000004, 0x00000007, 0x0000000A, 0x0000000D, 0x00000000, 0x00000003, 0x00000006, 0x00000009, 0x0000000C, 0x0000000F, 0x00000002, 0x00000000, 0x00000007, 0x0000000E, 0x00000005, 0x0000000C, 0x00000003, 0x0000000A, 0x00000001, 0x00000008, 0x0000000F, 0x00000006, 0x0000000D, 0x00000004, 0x0000000B, 0x00000002, 0x00000009};
u32 b = context->b, c = context->c, d = context->d, a = context->a;
const u32* word;
u32* block;
u32 a = context->a, b = context->b, c = context->c, d = context->d;
u32* word;
u32* constant;
const u32* index;
u32* index;
int round;
u32* block;
block = context->buffer32;
word = block;
constant = constants;
@@ -97,22 +97,22 @@ static void ProcessBlock(NETMD5Context* context) {
}
index = indices;
for (round = 0; round < 4; ++round) {
STEP(a,b,c,d,(b & d) | (c & ~d),block + *index++,5); ++constant;
STEP(d,a,b,c,(a & c) | (b & ~c),block + *index++,9); ++constant;
STEP(c,d,a,b,(d & b) | (a & ~b),block + *index++,14); ++constant;
STEP(b,c,d,a,(c & a) | (d & ~a),block + *index++,20); ++constant;
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;
STEP(c,d,a,b,(d & b) | (a & ~b),block + *index,14); ++index; ++constant;
STEP(b,c,d,a,(c & a) | (d & ~a),block + *index,20); ++index; ++constant;
}
for (round = 0; round < 4; ++round) {
STEP(a,b,c,d,d ^ b ^ c,block + *index++,4); ++constant;
STEP(d,a,b,c,c ^ a ^ b,block + *index++,11); ++constant;
STEP(c,d,a,b,b ^ d ^ a,block + *index++,16); ++constant;
STEP(b,c,d,a,a ^ c ^ d,block + *index++,23); ++constant;
STEP(a,b,c,d,d ^ b ^ c,block + *index,4); ++index; ++constant;
STEP(d,a,b,c,c ^ a ^ b,block + *index,11); ++index; ++constant;
STEP(c,d,a,b,b ^ d ^ a,block + *index,16); ++index; ++constant;
STEP(b,c,d,a,a ^ c ^ d,block + *index,23); ++index; ++constant;
}
for (round = 0; round < 4; ++round) {
STEP(a,b,c,d,c ^ (b | ~d),block + *index++,6); ++constant;
STEP(d,a,b,c,b ^ (a | ~c),block + *index++,10); ++constant;
STEP(c,d,a,b,a ^ (d | ~b),block + *index++,15); ++constant;
STEP(b,c,d,a,d ^ (c | ~a),block + *index++,21); ++constant;
STEP(a,b,c,d,c ^ (b | ~d),block + *index,6); ++index; ++constant;
STEP(d,a,b,c,b ^ (a | ~c),block + *index,10); ++index; ++constant;
STEP(c,d,a,b,a ^ (d | ~b),block + *index,15); ++index; ++constant;
STEP(b,c,d,a,d ^ (c | ~a),block + *index,21); ++index; ++constant;
}
context->a += a;
context->b += b;

View File

@@ -77,18 +77,16 @@ s32 NHTTPi_compareTokenN_HdrRecvBuf(const NHTTPResponseInfo* response, s32 posit
s32 offset;
int character;
if (position >= limit) {
goto tail;
}
FindHeaderBlock(response, position, &block, &offset);
character = ReadHeaderChar(response, &block, &offset);
while (LowerCase((s8)character) == LowerCase(*token)) {
if (*token == 0 || *token == ' ' || *token == delimiter || position == limit - 1) return 0;
if (position < limit) {
FindHeaderBlock(response, position, &block, &offset);
character = ReadHeaderChar(response, &block, &offset);
++position;
++token;
while (LowerCase((s8)character) == LowerCase(*token)) {
if (*token == 0 || *token == ' ' || *token == delimiter || position == limit - 1) return 0;
character = ReadHeaderChar(response, &block, &offset);
++position;
++token;
}
}
tail:
return -1;
}

View File

@@ -140,18 +140,20 @@ int SOGetSockName(int socket, void* address) {
s32 rm;
NameRequest* request;
SOSockAddr* reply;
SOSockAddr* addr;
addr=address;
if((result=SOiPrepare(NULL,&rm))==0) {
if(!address || ((SOSockAddr*)address)->len>8 || ((SOSockAddr*)address)->len<8) result=-28;
if(!addr || addr->len>8 || addr->len<8) result=-28;
else {
size=(((SOSockAddr*)address)->len+63)&~31;
size=(addr->len+63)&~31;
request=SOiAlloc(12,size);
if(!request) result=-49;
else {
request->socket=socket;
reply=&request->address;
memcpy(reply,address,((SOSockAddr*)address)->len);
result=IOS_Ioctl(rm,7,request,4,reply,((SOSockAddr*)address)->len);
if(result>=0) memcpy(address,reply,reply->len);
memcpy(reply,addr,addr->len);
result=IOS_Ioctl(rm,7,request,4,reply,addr->len);
if(result>=0) memcpy(addr,reply,reply->len);
SOiFree(12,request,size);
}
}

View File

@@ -1610,7 +1610,7 @@ namespace textinput {
}
void Base::setTranslateMode(TranslateMode mode) {
u32 keyMode = mode;
u32 keyMode;
switch (mode) {
case TM_Direct:
keyMode = 0;

View File

@@ -163,28 +163,3 @@ FINAL POOL libs/RevoEX/src/net/md5: POOL IDENTICAL up to 0 (mine=0 base=0) |
FINAL OPEN AUDIT ProcessBlock: objdiff=43.290848%, 7 distinct successful source hashes; structural/exact,lengths=((225, 300), 294, 306); 294/306 retained instructions, frame0x20. Indexed addresses, duplicated swapped loads, associated rotation sums and sequential cursor scheduling differ. Honest typed helper/materialized addresses reach306/306; seven source variants and93 declaration builds leave36 structural differences.
COMPLETENESS AUDIT PASS: all 7 remaining functions have at least3 distinct successful source-level attempts logged in this MAX round; build failures excluded. No experimental source/header changes retained. No untried function remains.
FINAL FULL GATE PASS: all4 owned units, clean43U build, SHA1 26116613f624061ba99c8d1a299aaa6efa85670d; exact30/31,11/14,0/2,3/4; matched_code9404,1388,0,600; matched_data4416,112,0,456. Regression0, forbidden0, readability0. NHTTPi_intToStr95/95 ctxdiff0 after clean build. Seven remaining functions audited14/6/19/10/8/8/7 distinct successful MAX source attempts, all at least3. No additional source changes after final gate.
## md5 ProcessBlock — w1010/smallflips round (0457e29c)
- DECODE: base's per-step `addi r4,r4,4` index-pointer advances are `*index++`
post-increment inside the STEP arg (`block + *index++`); separate `++index`
stmts get merged to one `addi +16` per unrolled iteration by MWCC. With the
increment inside the expression: 294/306 -> 306/306 exact SIZE.
- Also landed: `u32 b,c,d,a` state-decl order (a last) -> 32 ops; ptr decls
`word; block; constant; index; round;` (block last) -> 32; states-first is
load-bearing (ptrs-first decl = 62).
- Residual 32 ops: pure web-coloring {word:r4/r7, block:r8/r9, const:r9/r8,
a:r0 stays, b/c/d shifted by word's home}. ~10 decl/assign/type forms tried.
- zidawg1 CHARattribute {ctx<->key} r30/r31 + GetGraphInfo {ctx,graph,result}
r25/r26/r29: decl-order, alias, for-loop forms all invariant (7/9 ops).
- zi8uwd: `word->priority > candidate->priority` IS orig's operand order
(base `bgt`); `position[candidate->text]`/`*(position+text)` forms don't
flip the `add` operand order; `*(position+4+(u8*)candidate)` does flip it
but reshuffles webs to 15 ops. Kept `<` form at 8 ops.
- SOGetSockName: memcpy arg-materialization order (mr r3 last vs first):
inline dest, temp len, ptr-arith dest — all invariant (2 ops).
- FAAttach: index r0-vs-r5 scratch home — inline-index (129), u32/two-stmt/
decl-init (121-126), store-order swap — all invariant or regress (6 ops).
- iplKeyboard create: base saves 6 callee regs (arcLink->r26 separate from
multiArc->r30); mine coalesces to 5. allocator-hoist, no-paren new,
split-decl forms invariant (48 ops). Extra weak emissions (onEvent/onInput/
onOutOfLength/3 dtors) are upstream state, not leaf-introduced.

View File

@@ -0,0 +1,14 @@
## scanAP (w1010 revisit) — inlined-bool materialization wall
Orig inlines `Animator::isPlaying()` (`mState == 1` at +0x14) 3x but always as a
MATERIALIZED bool: `lwz rX,0x14; addi r0,rX,-1; cntlzw r0,r0; rlwinm. r0,r0,27,5,31; bne`.
Ours fuses to `lwz r0,0x14; cmpwi r0,1; beq` — 6 insns shorter overall (272 vs 266).
Tried and rejected (MWCC normalizes/folds all of them):
- `isPlaying() == false` at the call site
- `bool playing = anim->isPlaying(); if (!playing)` named local (fuses; eggColorFader's
fadeOut materializes only because `success` is also RETURNED — a second value-use)
- `int isPlaying()` return type — still fuses
- `return !(mState != ANIM_STATE_PLAY)` in the header — still fuses
Conclusion: orig's bool crosses a real value-boundary (2nd use, or a different inlined
shape we haven't identified). Same family as the fused-compare fossil in CHANSVm.
Also tried: convertRevIP untouched (98.7, 292B).

View File

@@ -15,3 +15,16 @@ Initial reconstruction uses the sibling tiString and tiUtil headers, real member
## character predicates
The sibling util declarations return bool, while target callers normalize an integer result. Guarded u32 declarations preserve every other translation unit and make all three predicates 16/16 with zero differences.
## inputChar (w1010 orchestrator probe) — indexed-store + dead-compare fossil
Orig mode==3 block (this->0x24==3) emits: `sth r6,0x10` (input[0]=0, r6=0 reused as
value), `cmplwi r4,0xa` (DEAD compare — no branch consumes it), then indexed stores
`slwi r0,r6,1; sthx r4,buf,r0; addi r6,1; slwi r0,r6,1; clrlwi r29,r6,0x10; sthx r5,buf,r0`
= input[i]=ch; i++; input[i]=0 with the index kept SYMBOLIC despite li i,0.
Ours: direct-offset `sth r4,0x10; li r29,1; sth r5,0x12` (125 vs 136 insns).
Tried: `input[i]=ch; i++; input[i]=0; count=i` — MWCC constant-folds i to 0,
re-emits direct offsets. Index must be runtime-opaque in orig (loop bound from a
call result, or a non-foldable form). Dead `cmplwi r4,0xa` matches the documented
dead-compare-fossil family (both-branch merge). Also: count lands in r29 via
clrlwi (u16) — count is i.
Unresolved: what source produces symbolic-index stores + dead compare.