From 9189867dc37973a4c523214bfcf9e999324cfdc5 Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Fri, 2 Oct 2026 10:24:14 +0000 Subject: [PATCH] match(NWC24MsgSubject 8/12) (fz7d) (worker 8ef4fd28) --- libs/RevoEX/src/nwc24/NWC24MsgRead.c | 17 ++- libs/RevoEX/src/nwc24/NWC24MsgSubject.c | 11 +- tools/decomp-assist/fz7.attempts.md | 191 ++++++++++++++++++++++++ 3 files changed, 207 insertions(+), 12 deletions(-) diff --git a/libs/RevoEX/src/nwc24/NWC24MsgRead.c b/libs/RevoEX/src/nwc24/NWC24MsgRead.c index 39743ca6..28195d88 100644 --- a/libs/RevoEX/src/nwc24/NWC24MsgRead.c +++ b/libs/RevoEX/src/nwc24/NWC24MsgRead.c @@ -386,14 +386,14 @@ NWC24Err NWC24ReadMsgTextEx(const NWC24MsgObj* msg, char* text, u32 capacity, ch } static NWC24Err ReadMsgTextInternal(const NWC24MsgObj* msg, char* text, u32 capacity, char* charset, u32 charsetCapacity, NWC24Encoding* encoding) { - const NWC24MsgObjPrivate* privateMsg = (const NWC24MsgObjPrivate*)msg; + char* buffer; NWC24MBoxType type; NWC24File file; NWC24Err result, closeResult; NWC24Err overflow = NWC24_OK; u32 length; u32 decodedSize; - char* buffer; + const NWC24MsgObjPrivate* privateMsg = (const NWC24MsgObjPrivate*)msg; if (!NWC24IsMsgLibOpened() && !NWC24IsMsgLibOpenedByTool()) return NWC24_ERR_LIB_NOT_OPENED; if (!(privateMsg->type & 0x200)) @@ -415,8 +415,8 @@ static NWC24Err ReadMsgTextInternal(const NWC24MsgObj* msg, char* text, u32 capa if (length == 0) return NWC24_ERR_NULL; if (length > capacity - 1) { - overflow = NWC24_ERR_OVERFLOW; length = capacity - 1; + overflow = NWC24_ERR_OVERFLOW; } result = NWC24iMBoxOpenStoredMsg(type, privateMsg->msgId, &file); switch (result) { @@ -452,13 +452,16 @@ static NWC24Err ReadMsgTextInternal(const NWC24MsgObj* msg, char* text, u32 capa result = NWC24FRead(text, length, &file); text[length] = 0; break; - case 2: + case 2: { + NWC24Err decodeResult; decodedSize = 0; - result = ReadBase64Data(&file, &privateMsg->text, (u8*)text, length, &decodedSize); - if (result == NWC24_OK && decodedSize != privateMsg->textSize) - result = NWC24_ERR_FORMAT; + decodeResult = ReadBase64Data(&file, &privateMsg->text, (u8*)text, length, &decodedSize); + if (decodeResult == NWC24_OK && decodedSize != privateMsg->textSize) + decodeResult = NWC24_ERR_FORMAT; + result = decodeResult; text[length] = 0; break; + } case 3: result = ReadQPText(privateMsg, &file, text, length); break; diff --git a/libs/RevoEX/src/nwc24/NWC24MsgSubject.c b/libs/RevoEX/src/nwc24/NWC24MsgSubject.c index 43b793ae..3f1eb282 100644 --- a/libs/RevoEX/src/nwc24/NWC24MsgSubject.c +++ b/libs/RevoEX/src/nwc24/NWC24MsgSubject.c @@ -743,15 +743,16 @@ NWC24Err NWC24iSetMsgSubjectQP(NWC24MsgObj* msg, const u16* subject, u32 subject u32 workSize, NWC24Charset charset, char* charsetName) { u32 workHalf; u32 sourceOffset; - u32 secondSize; + u32 charsetLength; u8* second; u32 subjectLength; u32 lineLength; - u32 outputLength; + u32 secondSize; u32 total; u32 combinedLength; u32 i; - u32 charsetLength; + u32 outputLength; + u32 firstCharsetLength; NWC24Err result; secondSize = workSize - (workSize >> 1); @@ -770,8 +771,8 @@ NWC24Err NWC24iSetMsgSubjectQP(NWC24MsgObj* msg, const u16* subject, u32 subject work[i] = ' '; } } - charsetLength = strlen(charsetName); - NWC24iDetectBreakPoint(&lineLength, charset, work, subjectLength, (0x38 - charsetLength) / 3); + firstCharsetLength = strlen(charsetName); + NWC24iDetectBreakPoint(&lineLength, charset, work, subjectLength, (0x38 - firstCharsetLength) / 3); result = NWC24EncodeWord(second, secondSize, &outputLength, charsetName, 0x40, 'Q', work, lineLength); switch (result) { default: diff --git a/tools/decomp-assist/fz7.attempts.md b/tools/decomp-assist/fz7.attempts.md index a51dac9c..293162b9 100644 --- a/tools/decomp-assist/fz7.attempts.md +++ b/tools/decomp-assist/fz7.attempts.md @@ -1154,3 +1154,194 @@ Score pairs above are structural differences ignoring register names, then posit - ConvertDateToDays 96.92921%: 113/113 instructions; sixteen instruction differences in final division scheduling and operand allocation. At least three compiled distinct attempts are listed in the completeness ledger. - ConvertDaysToDate 97.718445%: 103/103 instructions; only twenty-six register differences in month loop; year loop is exact. At least three compiled distinct attempts are listed in the completeness ledger. Remaining count13. Uncertainty: the surviving allocation/scheduling ties have no demonstrated source-level exact solution; no data ownership ambiguity remains. + +## Round d: fresh origin/main 00f44a92 +Owned MsgRead11/16, MsgSubject7/12, DateParser5/8. Source baseline copied before edits. All pools identical and owned data already100%; no symbol or extent changes are justified. + +### NWC24ReadMsgField +Fetched origin and confirmed owned source equals baseline origin unit, where this exact-name function was below 100. +Structural diagnosis: Field target102/source101,frame0xf0,identical locals/branches except missing message type reload at0x58 after protection check. Test a guarded typed bitfield view of proven mask0x200 at message offset4; union remains one32-bit word and macro is defined only by owned unit. This is a source-type experiment, not volatile or padding data. +- NWC24ReadMsgField: guarded readability bitfield versus raw mailbox flags: ((3, 84), 101, 102) -> ((4, 84), 101, 102); restored +Structural diagnosis NWC24ReadMsgField: src 0x194 base 0x198 insns 101/102. Target distinct type reload versus source common load; file/stream frame locations agree. Test output-helper boundary, branch form, and typed flag temporaries. +- NWC24ReadMsgField: permission guard has explicit output error boundary: ((3, 84), 101, 102) -> ((8, 89), 106, 102); restored +- NWC24ReadMsgField: permission guard expressed as negative goto exit: ((3, 84), 101, 102) -> ((9, 86), 101, 102); restored +- NWC24ReadMsgField: mailbox type computed using signed flags view: ((3, 84), 101, 102) -> ((3, 84), 101, 102); restored + +### NWC24ReadMsgFromAddr +Fetched origin and confirmed owned source equals baseline origin unit, where this exact-name function was below 100. +Structural diagnosis NWC24ReadMsgFromAddr: src 0x16c base 0x170 insns 91/92. Target distinct type reload versus source common load; file/stream frame locations agree. Test output-helper boundary, branch form, and typed flag temporaries. +- NWC24ReadMsgFromAddr: permission guard has explicit output error boundary: ((4, 66), 91, 92) -> ((9, 77), 96, 92); restored +- NWC24ReadMsgFromAddr: permission guard expressed as negative goto exit: ((4, 66), 91, 92) -> ((12, 74), 91, 92); restored +- NWC24ReadMsgFromAddr: mailbox type computed using signed flags view: ((4, 66), 91, 92) -> ((4, 66), 91, 92); restored + +### NWC24ReadMsgSubject +Fetched origin and confirmed owned source equals baseline origin unit, where this exact-name function was below 100. +Structural diagnosis NWC24ReadMsgSubject: src 0x144 base 0x148 insns 81/82. Target distinct type reload versus source common load; file/stream frame locations agree. Test output-helper boundary, branch form, and typed flag temporaries. +- NWC24ReadMsgSubject: permission guard has explicit output error boundary: ((3, 65), 81, 82) -> ((8, 69), 86, 82); restored +- NWC24ReadMsgSubject: permission guard expressed as negative goto exit: ((3, 65), 81, 82) -> ((10, 67), 81, 82); restored +- NWC24ReadMsgSubject: mailbox type computed using signed flags view: ((3, 65), 81, 82) -> ((3, 65), 81, 82); restored + +### ReadMsgTextInternal +Fetched origin and confirmed owned source equals baseline origin unit, where this exact-name function was below 100. +Structural diagnosis ReadMsgTextInternal: src 0x2c4 base 0x2c8 insns 177/178. Target distinct type reload versus source common load; file/stream frame locations agree. Test output-helper boundary, branch form, and typed flag temporaries. +- ReadMsgTextInternal: permission guard has explicit output error boundary: ((11, 156), 177, 178) -> ((10, 169), 183, 178); kept +- ReadMsgTextInternal: permission guard expressed as negative goto exit: ((10, 169), 183, 178) -> ((10, 169), 183, 178); restored +- ReadMsgTextInternal: mailbox type computed using signed flags view: ((10, 169), 183, 178) -> ((10, 169), 183, 178); restored + +### NWC24ReadMsgAttached +Fetched origin and confirmed owned source equals baseline origin unit, where this exact-name function was below 100. +Structural diagnosis NWC24ReadMsgAttached: src 0x168 base 0x16c insns 90/91. Target distinct type reload versus source common load; file/stream frame locations agree. Test output-helper boundary, branch form, and typed flag temporaries. +- NWC24ReadMsgAttached: permission guard has explicit output error boundary: ((6, 75), 90, 91) -> compile failure; restored +- NWC24ReadMsgAttached: permission guard expressed as negative goto exit: ((6, 75), 90, 91) -> ((13, 79), 90, 91); restored +- NWC24ReadMsgAttached: mailbox type computed using signed flags view: ((6, 75), 90, 91) -> ((6, 75), 90, 91); restored + +### NWC24ReadMsgSubjectPublic +Fetched origin and confirmed owned source equals baseline origin unit, where this exact-name function was below 100. +Structural diagnosis NWC24ReadMsgSubjectPublic: src 0x190 base 0x1a0 insns 100/104. Target error policy has an additional branch over the shared exit after overflow acceptance. Frame and stack declaration layout match. Test labeled continuation, switch inside error arm, and error-loop exit boundaries. +- NWC24ReadMsgSubjectPublic: overflow branch boundary variant 1: ((11, 64), 100, 104) -> ((13, 64), 102, 104); restored +- NWC24ReadMsgSubjectPublic: overflow branch boundary variant 2: ((11, 64), 100, 104) -> ((11, 64), 100, 104); restored +- NWC24ReadMsgSubjectPublic: overflow branch boundary variant 3: ((11, 64), 100, 104) -> ((13, 64), 102, 104); restored + +### NWC24ReadMsgTextPublic +Fetched origin and confirmed owned source equals baseline origin unit, where this exact-name function was below 100. +Structural diagnosis NWC24ReadMsgTextPublic: src 0x110 base 0x118 insns 68/70. Target error policy has an additional branch over the shared exit after overflow acceptance. Frame and stack declaration layout match. Test labeled continuation, switch inside error arm, and error-loop exit boundaries. +- NWC24ReadMsgTextPublic: overflow branch boundary variant 1: ((7, 28), 68, 70) -> ((8, 29), 69, 70); restored +- NWC24ReadMsgTextPublic: overflow branch boundary variant 2: ((7, 28), 68, 70) -> ((7, 28), 68, 70); restored +- NWC24ReadMsgTextPublic: overflow branch boundary variant 3: ((7, 28), 68, 70) -> ((8, 29), 69, 70); restored + +### NWC24SetMsgSubjectAndTextPublic +Fetched origin and confirmed owned source equals baseline origin unit, where this exact-name function was below 100. +Structural diagnosis NWC24SetMsgSubjectAndTextPublic: src 0x2f8 base 0x2f8 insns 190/190. Stack frame/local offsets and control flow are identical; saved register coloring or prologue capture order remains. Test initialization lifetimes, helper boundaries and expression operands before declaration search. +- NWC24SetMsgSubjectAndTextPublic: charset work buffer named independently of work context: ((0, 65), 190, 190) -> ((0, 65), 190, 190); restored +- NWC24SetMsgSubjectAndTextPublic: text/subject capacity allocation uses named weighted length: ((0, 65), 190, 190) -> ((0, 65), 190, 190); restored +- NWC24SetMsgSubjectAndTextPublic: parse charset status named local before fallback: ((0, 65), 190, 190) -> ((0, 65), 190, 190); restored + +### NWC24iSetMsgSubjectQP +Fetched origin and confirmed owned source equals baseline origin unit, where this exact-name function was below 100. +Structural diagnosis NWC24iSetMsgSubjectQP: src 0x240 base 0x240 insns 144/144. Stack frame/local offsets and control flow are identical; saved register coloring or prologue capture order remains. Test initialization lifetimes, helper boundaries and expression operands before declaration search. +- NWC24iSetMsgSubjectQP: separate first-line charset byte count and folding limit: ((0, 12), 144, 144) -> ((0, 15), 144, 144); restored +- NWC24iSetMsgSubjectQP: name charset line prefix before first break calculation: ((0, 12), 144, 144) -> ((0, 12), 144, 144); restored +- NWC24iSetMsgSubjectQP: combine output advancement before source advancement: ((0, 12), 144, 144) -> ((2, 16), 144, 144); restored + +### NWC24iSetMsgSubjectBase64 +Fetched origin and confirmed owned source equals baseline origin unit, where this exact-name function was below 100. +Structural diagnosis NWC24iSetMsgSubjectBase64: src 0x220 base 0x220 insns 136/136. Stack frame/local offsets and control flow are identical; saved register coloring or prologue capture order remains. Test initialization lifetimes, helper boundaries and expression operands before declaration search. +- NWC24iSetMsgSubjectBase64: initial half capacity plain declared local: ((0, 5), 136, 136) -> ((0, 5), 136, 136); restored +- NWC24iSetMsgSubjectBase64: first converter input size initialized leading declaration: ((0, 5), 136, 136) -> ((5, 18), 136, 136); restored +- NWC24iSetMsgSubjectBase64: charset name captured by const string length helper: ((0, 5), 136, 136) -> ((0, 5), 136, 136); restored +ReadMsgTextInternal output-helper candidate added six instructions despite smaller normalized structural score; restored whole read unit to baseline. Attached output-helper compile failure was caused by collision with that retained helper definition and is not counted; repeat after restoration. +- NWC24ReadMsgAttached: attachment decoder uses named attachment descriptor: ((6, 75), 90, 91) -> ((11, 62), 90, 91); restored + +### NWC24iDateToOSCalendarTime +Fetched origin and confirmed owned source equals baseline origin unit, where this exact-name function was below 100. +Structural diagnosis DateToOSCalendarTime85/85,frame0x10,same stores/branches. Shared zero-leap flag r5/year r0 versus target r0/r5. Test zero field temporary, conditional leap expression boundaries, and field-copy order. +- NWC24iDateToOSCalendarTime: fraction fields share named zero value: ((0, 13), 85, 85) -> ((0, 13), 85, 85); restored +- NWC24iDateToOSCalendarTime: calendar fractions initialized before year copy: ((0, 13), 85, 85) -> ((6, 18), 85, 85); restored +- NWC24iDateToOSCalendarTime: leap condition divided into common and century decisions: ((0, 13), 85, 85) -> ((4, 53), 87, 85); restored + +### ConvertDateToDays +Fetched origin and confirmed owned source equals baseline origin unit, where this exact-name function was below 100. +Structural diagnosis ConvertDateToDays113/113 leaf frame, final16 differences include arithmetic scheduling. Target accumulates century quotient in r0 and common quotient in r3; test explicit previous-year temporary and arithmetic helper boundary. +- ConvertDateToDays: name completed-year arithmetic input: ((4, 16), 113, 113) -> ((6, 17), 113, 113); restored +- ConvertDateToDays: common correction difference formed after accumulated day count: ((4, 16), 113, 113) -> ((13, 16), 113, 113); restored +- ConvertDateToDays: century correction is added through explicit yearly subtotal: ((4, 16), 113, 113) -> ((4, 16), 113, 113); restored + +### ConvertDaysToDate +Fetched origin and confirmed owned source equals baseline origin unit, where this exact-name function was below 100. +Structural diagnosis ConvertDaysToDate103/103,year loop exact,month loop26 register differences. Frame0x10 and branches identical. Investigate month inline-helper boundaries/local scope before declaration search. +- ConvertDaysToDate: month leap expression expanded inside existing loop: ((0, 26), 103, 103) -> ((14, 102), 95, 103); restored +- ConvertDaysToDate: month remainder saved with initialized declaration: ((0, 26), 103, 103) -> ((0, 26), 103, 103); restored +- ConvertDaysToDate: month loop has explicit continuation after month increment: ((0, 26), 103, 103) -> ((0, 26), 103, 103); restored +- NWC24iSetMsgSubjectQP: second output buffer typed descriptor variation 1: ((0, 12), 144, 144) -> ((0, 20), 144, 144); restored +- NWC24iSetMsgSubjectQP: second output buffer typed descriptor variation 2: ((0, 12), 144, 144) -> ((0, 20), 144, 144); restored +- NWC24iSetMsgSubjectQP: second output buffer typed descriptor variation 3: ((0, 12), 144, 144) -> compile failure; restored +- NWC24iSetMsgSubjectBase64: second output buffer typed descriptor variation 1: ((0, 5), 136, 136) -> ((0, 19), 136, 136); restored +- NWC24iSetMsgSubjectBase64: second output buffer typed descriptor variation 2: ((0, 5), 136, 136) -> ((0, 19), 136, 136); restored +- NWC24iSetMsgSubjectBase64: second output buffer typed descriptor variation 3: ((0, 5), 136, 136) -> compile failure; restored +- ConvertDateToDays: century correction references original year directly: ((4, 16), 113, 113) -> ((14, 20), 113, 113); restored +- ConvertDateToDays: common leap correction references original year directly: ((4, 16), 113, 113) -> ((7, 18), 113, 113); restored +- ConvertDateToDays: both leap corrections reference original year directly: ((4, 16), 113, 113) -> ((10, 19), 113, 113); restored +- ConvertDaysToDate: month leap helper uses representable flag type u8: ((0, 26), 103, 103) -> ((0, 26), 103, 103); restored +- ConvertDaysToDate: month leap helper uses representable flag type u32: ((0, 26), 103, 103) -> ((0, 26), 103, 103); restored +- ConvertDaysToDate: month leap helper uses representable flag type s8: ((0, 26), 103, 103) -> ((0, 26), 103, 103); restored +- ConvertDaysToDate: month leap flag default set after common-year decision: ((0, 26), 103, 103) -> ((9, 53), 105, 103); restored +- ConvertDaysToDate: month common path first with explicit positive fallback branch: ((0, 26), 103, 103) -> ((6, 32), 103, 103); restored +- NWC24SetMsgSubjectAndTextPublic: register-only last declsearch explicit actual body lines 233-241 max180: ((0, 65), 190, 190) -> ((0, 65), 190, 190); declaration block: / NWC24MsgObjPrivate* privateMsg = (NWC24MsgObjPrivate*)msg; / NWC24Work* nwcWork; / u32 textSourceSize; / u32 textWorkSize; / BOOL is7Bit; / NWC24Charset charset; / u32 subjectWorkSize; / u8* subjectWork; / NWC24Err result; / start (0, 65) / best (0, 65) after 93 builds; source restored; best order was: / NWC24MsgObjPrivate* privateMsg = (NWC24MsgObjPrivate*)msg; / NWC24Work* nwcWork; / u32 textSourceSize; / u32 textWorkSize; / BOOL is7Bit; / NWC24Charset charset; / u32 subjectWorkSize; / u8* subjectWork; / NWC24Err result; / +- ConvertDateToDays: register-only last after arithmetic structural trials, declsearch actual lines 152-156: declaration block: / s32 daysOfYear; / s32 yearOffset; / s32 centuryLeapDays; / s32 commonLeapDays; / BOOL isLeapYear; / start (4, 16) / best (4, 16) after 23 builds; source restored; best order was: / s32 daysOfYear; / s32 yearOffset; / s32 centuryLeapDays; / s32 commonLeapDays; / BOOL isLeapYear; / +- NWC24iSetMsgSubjectQP: register-only last declsearch explicit actual body lines 744-755 max180: ((0, 12), 144, 144) -> ((0, 12), 144, 144); declaration block: / u32 workHalf; / u32 sourceOffset; / u32 secondSize; / u8* second; / u32 subjectLength; / u32 lineLength; / u32 outputLength; / u32 total; / u32 combinedLength; / u32 i; / u32 charsetLength; / NWC24Err result; / start (0, 12) / best (0, 12) after 177 builds; source restored; best order was: / u32 workHalf; / u32 sourceOffset; / u32 secondSize; / u8* second; / u32 subjectLength; / u32 lineLength; / u32 outputLength; / u32 total; / u32 combinedLength; / u32 i; / u32 charsetLength; / NWC24Err result; / +- NWC24iSetMsgSubjectBase64: register-only last declsearch explicit actual body lines 819-828 max180: ((0, 5), 136, 136) -> ((0, 5), 136, 136); declaration block: / u8* second; / u32 secondSize; / u32 workHalf; / u32 subjectLength; / u32 lineLength; / u32 sourceOffset; / u32 outputLength; / u32 total; / u32 charsetLength; / NWC24Err result; / start (0, 5) / best (0, 5) after 118 builds; source restored; best order was: / u8* second; / u32 secondSize; / u32 workHalf; / u32 subjectLength; / u32 lineLength; / u32 sourceOffset; / u32 outputLength; / u32 total; / u32 charsetLength; / NWC24Err result; / +- NWC24iDateToOSCalendarTime: register-only last declsearch explicit actual body lines 121-122 max180: ((0, 13), 85, 85) -> ((0, 13), 85, 85); declaration block: / BOOL isLeapYear; / s32 days; / start (0, 13) / best (0, 13) after 2 builds; source restored; best order was: / BOOL isLeapYear; / s32 days; / +- ReadMsgTextInternal: capacity clamp writes length before overflow status: ((11, 156), 177, 178) -> ((9, 157), 177, 178); kept +- ReadMsgTextInternal: base64 decode result remains local until validation finishes: ((9, 157), 177, 178) -> ((7, 160), 177, 178); kept +- ReadMsgTextInternal: mailbox selection occurs before setting returned encoding default: ((7, 160), 177, 178) -> ((8, 160), 177, 178); restored +- NWC24ReadMsgField: mailbox flags passed by named field pointer 1: ((3, 84), 101, 102) -> ((3, 84), 101, 102); restored +- NWC24ReadMsgField: mailbox flags passed by named field pointer 2: ((3, 84), 101, 102) -> ((3, 84), 101, 102); restored +- NWC24ReadMsgField: mailbox flags passed by named field pointer 3: ((3, 84), 101, 102) -> ((3, 84), 101, 102); restored + +Round d first retained improvement: ReadMsgTextInternal clamp assignment order and branch-local decode result remove structural scheduling differences. Objdiff94.55056 ->96.853935,177/178 instructions; missing type reload and saved-register allocation remain. Quick gate over all threePASS,poolsidentical,data100%,globalregressions0,forbidden0,readability0,DOL26116613f624061ba99c8d1a299aaa6efa85670d. No new exact function is claimed. +- NWC24iSetMsgSubjectQP: QP cursor initialization scoped to folding branch 1: ((0, 12), 144, 144) -> ((0, 12), 144, 144); restored +- NWC24iSetMsgSubjectQP: QP cursor initialization scoped to folding branch 2: ((0, 12), 144, 144) -> ((0, 12), 144, 144); restored +- NWC24iSetMsgSubjectQP: QP cursor initialization scoped to folding branch 3: ((0, 12), 144, 144) -> ((0, 12), 144, 144); restored +- ReadMsgTextInternal: register-only last declsearch explicit actual body lines 389-481 max180: ((7, 160), 177, 178) -> ((7, 157), 177, 178); declaration block: / const NWC24MsgObjPrivate* privateMsg = (const NWC24MsgObjPrivate*)msg; / NWC24MBoxType type; / NWC24File file; / NWC24Err result, closeResult; / NWC24Err overflow = NWC24_OK; / u32 length; / u32 decodedSize; / char* buffer; / if (!NWC24IsMsgLibOpened() && !NWC24IsMsgLibOpenedByTool()) / return NWC24_ERR_LIB_NOT_OPENED; / if (!(privateMsg->type & 0x200)) / return NWC24_ERR_PROTECTED; / buffer = NWC24WorkP->stringWork; / *encoding = 0; / result = SelectMBox(privateMsg, &type); / switch (result) { / case NWC24_OK: / break; / default: / return result; / } / length = privateMsg->textSize; / switch (length) { / case 0: length = privateMsg->text.size; break; / default: break; / } / if (length == 0) / return NWC24_ERR_NULL; / if (length > capacity - 1) { / length = capacity - 1; / overflow = NWC24_ERR_OVERFLOW; / } / result = NWC24iMBoxOpenStoredMsg(type, privateMsg->msgId, &file); / switch (result) { / case NWC24_OK: / break; / default: / return result; / } / Mail_memset(charset, 0, charsetCapacity); / if (privateMsg->unk_0x50.size >= charsetCapacity) / result = NWC24_ERR_FORMAT; / else { / if (privateMsg->unk_0x50.size != 0) { / NWC24FSeek(&file, (u32)privateMsg->unk_0x50.ptr, NWC24_SEEK_BEG); / result = NWC24FRead(charset, privateMsg->unk_0x50.size, &file); / if (result != NWC24_OK) / goto close; / } / if (privateMsg->unk_0x58.size != 0 && privateMsg->unk_0x58.size < 32) { / Mail_memset(buffer, 0, 32); / NWC24FSeek(&file, (u32)privateMsg->unk_0x58.ptr, NWC24_SEEK_BEG); / result = NWC24FRead(buffer, privateMsg->unk_0x58.size, &file); / if (result != NWC24_OK) / goto close; / result = NWC24ParseEncodingStr(encoding, buffer); / if (result != NWC24_OK) / goto close; / } / NWC24FSeek(&file, (u32)privateMsg->text.ptr, NWC24_SEEK_BEG); / switch (*encoding) { / case 0: / case 1: / result = NWC24FRead(text, length, &file); / text[length] = 0; / break; / case 2: { / NWC24Err decodeResult; / decodedSize = 0; / decodeResult = ReadBase64Data(&file, &privateMsg->text, (u8*)text, length, &decodedSize); / if (decodeResult == NWC24_OK && decodedSize != privateMsg->textSize) / decodeResult = NWC24_ERR_FORMAT; / result = decodeResult; / text[length] = 0; / break; / } / case 3: / result = ReadQPText(privateMsg, &file, text, length); / break; / default: / result = NWC24_ERR_NOT_SUPPORTED; / *text = 0; / break; / } / } / close: / closeResult = NWC24iMBoxCloseMsg(&file); / if (result != NWC24_OK) / closeResult = result; / if (closeResult != NWC24_OK) / overflow = closeResult; / return overflow; / } / start (7, 160) / improved (7, 157) / best (7, 157) after 180 builds; kept in source: / char* buffer; / NWC24MBoxType type; / NWC24File file; / NWC24Err result, closeResult; / NWC24Err overflow = NWC24_OK; / u32 length; / u32 decodedSize; / const NWC24MsgObjPrivate* privateMsg = (const NWC24MsgObjPrivate*)msg; / if (!NWC24IsMsgLibOpened() && !NWC24IsMsgLibOpenedByTool()) / return NWC24_ERR_LIB_NOT_OPENED; / if (!(privateMsg->type & 0x200)) / return NWC24_ERR_PROTECTED; / buffer = NWC24WorkP->stringWork; / *encoding = 0; / result = SelectMBox(privateMsg, &type); / switch (result) { / case NWC24_OK: / break; / default: / return result; / } / length = privateMsg->textSize; / switch (length) { / case 0: length = privateMsg->text.size; break; / default: break; / } / if (length == 0) / return NWC24_ERR_NULL; / if (length > capacity - 1) { / length = capacity - 1; / overflow = NWC24_ERR_OVERFLOW; / } / result = NWC24iMBoxOpenStoredMsg(type, privateMsg->msgId, &file); / switch (result) { / case NWC24_OK: / break; / default: / return result; / } / Mail_memset(charset, 0, charsetCapacity); / if (privateMsg->unk_0x50.size >= charsetCapacity) / result = NWC24_ERR_FORMAT; / else { / if (privateMsg->unk_0x50.size != 0) { / NWC24FSeek(&file, (u32)privateMsg->unk_0x50.ptr, NWC24_SEEK_BEG); / result = NWC24FRead(charset, privateMsg->unk_0x50.size, &file); / if (result != NWC24_OK) / goto close; / } / if (privateMsg->unk_0x58.size != 0 && privateMsg->unk_0x58.size < 32) { / Mail_memset(buffer, 0, 32); / NWC24FSeek(&file, (u32)privateMsg->unk_0x58.ptr, NWC24_SEEK_BEG); / result = NWC24FRead(buffer, privateMsg->unk_0x58.size, &file); / if (result != NWC24_OK) / goto close; / result = NWC24ParseEncodingStr(encoding, buffer); / if (result != NWC24_OK) / goto close; / } / NWC24FSeek(&file, (u32)privateMsg->text.ptr, NWC24_SEEK_BEG); / switch (*encoding) { / case 0: / case 1: / result = NWC24FRead(text, length, &file); / text[length] = 0; / break; / case 2: { / NWC24Err decodeResult; / decodedSize = 0; / decodeResult = ReadBase64Data(&file, &privateMsg->text, (u8*)text, length, &decodedSize); / if (decodeResult == NWC24_OK && decodedSize != privateMsg->textSize) / decodeResult = NWC24_ERR_FORMAT; / result = decodeResult; / text[length] = 0; / break; / } / case 3: / result = ReadQPText(privateMsg, &file, text, length); / break; / default: / result = NWC24_ERR_NOT_SUPPORTED; / *text = 0; / break; / } / } / close: / closeResult = NWC24iMBoxCloseMsg(&file); / if (result != NWC24_OK) / closeResult = result; / if (closeResult != NWC24_OK) / overflow = closeResult; / return overflow; / } / +- NWC24ReadMsgTextPublic: diagnose success conditional plus overflow switch candidate via ctxdiff: src 0x114 base 0x118 insns 69/70 / --- replace mine 15:16 base 15:16 / M 15 b 192 / B 15 b 196 / --- replace mine 23:24 base 23:24 / M 23 b 160 / B 23 b 164 / --- replace mine 28:29 base 28:29 / M 28 b 140 / B 28 b 144 / --- replace mine 43:44 base 43:44 / M 43 beq 20 / B 43 beq 24 / --- replace mine 45:47 base 45:46 / M 45 beq 8 / M 46 b 68 / B 45 bne 76 / --- insert mine 48:48 base 47:49 / B 47 b 8 / B 48 b 64 /; restored. +Correction: first ReadMsgTextInternal declaration search extended past leading declarations because this function has no blank before first statement. Its retained diff was only privateMsg/buffer declaration swap; no control flow was changed. Re-running with strict declaration recognition plus combined result/closeResult declaration; invalid nondeclaration shuffle evaluations are not credited as attempts. +- ReadMsgTextInternal: register-only last declsearch explicit actual body lines 389-396 max180: ((7, 157), 177, 178) -> ((7, 157), 177, 178); declaration block: / char* buffer; / NWC24MBoxType type; / NWC24File file; / NWC24Err result, closeResult; / NWC24Err overflow = NWC24_OK; / u32 length; / u32 decodedSize; / const NWC24MsgObjPrivate* privateMsg = (const NWC24MsgObjPrivate*)msg; / start (7, 157) / best (7, 157) after 71 builds; source restored; best order was: / char* buffer; / NWC24MBoxType type; / NWC24File file; / NWC24Err result, closeResult; / NWC24Err overflow = NWC24_OK; / u32 length; / u32 decodedSize; / const NWC24MsgObjPrivate* privateMsg = (const NWC24MsgObjPrivate*)msg; / +- NWC24iSetMsgSubjectQP: first-line charset length separated from folding limit, then register-only declsearch actual leading block 744-756; ((0, 12), 144, 144) -> ((0, 0), 144, 144); declaration block: / u32 workHalf; / u32 sourceOffset; / u32 secondSize; / u8* second; / u32 subjectLength; / u32 lineLength; / u32 outputLength; / u32 total; / u32 combinedLength; / u32 i; / u32 charsetLength; / u32 firstCharsetLength; / NWC24Err result; / start (0, 15) / improved (0, 3) / improved (0, 0) / best (0, 0) after 92 builds; kept in source: / u32 workHalf; / u32 sourceOffset; / u32 charsetLength; / u8* second; / u32 subjectLength; / u32 lineLength; / u32 secondSize; / u32 total; / u32 combinedLength; / u32 i; / u32 outputLength; / u32 firstCharsetLength; / NWC24Err result; /; kept +- ConvertDaysToDate: month leap scope and shared continuation 1: ((0, 26), 103, 103) -> ((7, 47), 107, 103); restored +- ConvertDaysToDate: month leap scope and shared continuation 2: ((0, 26), 103, 103) -> ((0, 26), 103, 103); restored +- ConvertDaysToDate: month leap scope and shared continuation 3: ((0, 26), 103, 103) -> ((0, 31), 103, 103); restored +- ConvertDaysToDate: register-only last after helper/scope/branch structural attempts, actual loop lines 208-211: declaration block: / u16 currentYear = *year; / s32 previousDays = days; / BOOL leapYear = TRUE; / BOOL commonLeapYear = FALSE; / start (0, 26) / best (0, 26) after 13 builds; source restored; best order was: / u16 currentYear = *year; / s32 previousDays = days; / BOOL leapYear = TRUE; / BOOL commonLeapYear = FALSE; / +- ConvertDaysToDate: register-only last after helper/scope/branch structural attempts, actual loop lines 228-229: declaration block: / s32 previousDays; / u8 currentMonth; / start (0, 26) / best (0, 26) after 2 builds; source restored; best order was: / s32 previousDays; / u8 currentMonth; / + +Round d QP exact: separating the first-line charset byte count from the later folding budget changes real temporary lifetime interference. Leading declaration search reached144/144,diffs0,exact-nameobjdiff100.0000. Subject7/12->8/12,code2776->3352,data232/232. ReadText declaration placement also improves96.853935->97.44382 without changing other functions. Quick gate over threePASS,poolsidentical,globalregressions0,forbidden0,readability0,DOLverified. +- NWC24iDateToOSCalendarTime: year/fraction named local lifetime graph variant1 followed by register-only leading-declaration search; ((0, 13), 85, 85) -> ((0, 13), 85, 85); declaration block: / u16 currentYear; / BOOL isLeapYear; / s32 days; / start (0, 13) / best (0, 13) after 6 builds; source restored; best order was: / u16 currentYear; / BOOL isLeapYear; / s32 days; /; restored +- NWC24iDateToOSCalendarTime: year/fraction named local lifetime graph variant2 followed by register-only leading-declaration search; ((0, 13), 85, 85) -> ((0, 13), 85, 85); declaration block: / s32 fraction; / BOOL isLeapYear; / s32 days; / start (0, 13) / best (0, 13) after 6 builds; source restored; best order was: / s32 fraction; / BOOL isLeapYear; / s32 days; /; restored +- NWC24iDateToOSCalendarTime: year/fraction named local lifetime graph variant3 followed by register-only leading-declaration search; ((0, 13), 85, 85) -> ((0, 13), 85, 85); declaration block: / u16 currentYear; / s32 fraction; / BOOL isLeapYear; / s32 days; / start (0, 13) / best (0, 13) after 13 builds; source restored; best order was: / u16 currentYear; / s32 fraction; / BOOL isLeapYear; / s32 days; /; restored +- NWC24iSetMsgSubjectBase64: first-line charset byte count separated from later folding charset count, then register-only leading-block declsearch; ((0, 5), 136, 136) -> ((0, 5), 136, 136); declaration block: / u8* second; / u32 secondSize; / u32 workHalf; / u32 subjectLength; / u32 lineLength; / u32 sourceOffset; / u32 outputLength; / u32 total; / u32 charsetLength; / u32 firstCharsetLength; / NWC24Err result; / start (0, 5) / best (0, 5) after 146 builds; source restored; best order was: / u8* second; / u32 secondSize; / u32 workHalf; / u32 subjectLength; / u32 lineLength; / u32 sourceOffset; / u32 outputLength; / u32 total; / u32 charsetLength; / u32 firstCharsetLength; / NWC24Err result; /; restored + +### Round d completeness audit +NWC24ReadMsgField: 7 logged compiled source variations, at least3 distinct source transformations. Still open; closest accepted state retains original real functions and data. +NWC24ReadMsgFromAddr: 3 logged compiled source variations, at least3 distinct source transformations. Still open; closest accepted state retains original real functions and data. +NWC24ReadMsgSubject: 3 logged compiled source variations, at least3 distinct source transformations. Still open; closest accepted state retains original real functions and data. +ReadMsgTextInternal: 6 logged compiled source variations, at least3 distinct source transformations. Still open; closest accepted state retains original real functions and data. +NWC24ReadMsgAttached: 3 logged compiled source variations, at least3 distinct source transformations. Still open; closest accepted state retains original real functions and data. +NWC24ReadMsgSubjectPublic: 3 logged compiled source variations, at least3 distinct source transformations. Still open; closest accepted state retains original real functions and data. +NWC24ReadMsgTextPublic: 3 logged compiled source variations, at least3 distinct source transformations. Still open; closest accepted state retains original real functions and data. +NWC24SetMsgSubjectAndTextPublic: 3 logged compiled source variations, at least3 distinct source transformations. Still open; closest accepted state retains original real functions and data. +NWC24iSetMsgSubjectQP: 8 logged compiled source variations, at least3 distinct source transformations. Now exact144/144,diffs0,objdiff100%; source commit592e7c2b. +NWC24iSetMsgSubjectBase64: 5 logged compiled source variations, at least3 distinct source transformations. Still open; closest accepted state retains original real functions and data. +NWC24iDateToOSCalendarTime: 3 logged compiled source variations, at least3 distinct source transformations. Still open; closest accepted state retains original real functions and data. +ConvertDateToDays: 6 logged compiled source variations, at least3 distinct source transformations. Still open; closest accepted state retains original real functions and data. +ConvertDaysToDate: 11 logged compiled source variations, at least3 distinct source transformations. Still open; closest accepted state retains original real functions and data. +Each open function received an origin fetch and unchanged-source comparison before starting. Rejected compile failures and invalid whole-body declaration shuffles are not used to satisfy the three-source-attempt requirement. Owned data128/128,232/232,40/40 was already fully paired and exact; no config renames/extents or extra weak-symbol suppression were attempted. All header experiments were restored. + +### Round d final remaining-function audit +NWC24ReadMsgField 98.92157%: 101/102 instructions; target reloads message type after protection check, source shares the load. At least three compiled distinct source attempts this round. +NWC24ReadMsgFromAddr 98.804344%: 91/92 instructions; target reloads message type after capability check, source shares the load. At least three compiled distinct source attempts this round. +NWC24ReadMsgSubject 98.65854%: 81/82 instructions; target reloads message type after protection check, source shares the load. At least three compiled distinct source attempts this round. +ReadMsgTextInternal 97.44382%: 177/178 instructions; target type reload is absent, and buffer/length temporaries exchange saved registers. Clamp and Base64 result scheduling now match. At least three compiled distinct source attempts this round. +NWC24ReadMsgAttached 96.37363%: 90/91 instructions; missing type reload plus attachment-index/result temporary allocation. At least three compiled distinct source attempts this round. +NWC24ReadMsgSubjectPublic 96.15385%: 100/104 instructions; two overflow acceptance paths lack target branch pairs. At least three compiled distinct source attempts this round. +NWC24ReadMsgTextPublic 97.14286%: 68/70 instructions; overflow acceptance path lacks target branch pair. At least three compiled distinct source attempts this round. +NWC24SetMsgSubjectAndTextPublic 98.23684%: 190/190 instructions; only saved-register allocation, work context r31 versus targetr22 shifts input register coloring. At least three compiled distinct source attempts this round. +NWC24iSetMsgSubjectBase64 99.632355%: 136/136 instructions; only five parameter-capture move ordering differences; body exact. At least three compiled distinct source attempts this round. +NWC24iDateToOSCalendarTime 99.17647%: 85/85 instructions; only thirteen register differences, year and shared zero/leap flag exchange r0/r5. At least three compiled distinct source attempts this round. +ConvertDateToDays 96.92921%: 113/113 instructions; final signed division scheduling and operand allocation differ. At least three compiled distinct source attempts this round. +ConvertDaysToDate 97.718445%: 103/103 instructions; only twenty-six month-loop register differences; year loop exact. At least three compiled distinct source attempts this round. +All12 remaining names checked against the current full gate; none is untried. Uncertainty remains in source constructs needed to reproduce the surviving compiler sharing, unreachable branch, scheduling and coloring decisions. No owned-data uncertainty remains. + +### Round d final full gate: clean non-quick build +full build: ok +main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d +[libs/RevoEX/src/nwc24/NWC24MsgRead] objdiff: code 2480/4660 data 128/128 functions 11/16 fuzzy 99.0429 linked code 0 +[libs/RevoEX/src/nwc24/NWC24MsgRead] instruction-exact functions: 11/16 +[libs/RevoEX/src/nwc24/NWC24MsgSubject] objdiff: code 3352/5352 data 232/232 functions 8/12 fuzzy 99.2638 linked code 0 +[libs/RevoEX/src/nwc24/NWC24MsgSubject] instruction-exact functions: 8/12 +[libs/RevoEX/src/nwc24/NWC24DateParser] objdiff: code 1168/2372 data 40/40 functions 5/8 fuzzy 98.9005 linked code 0 +[libs/RevoEX/src/nwc24/NWC24DateParser] instruction-exact functions: 5/8 +regressions vs baseline: 0 +forbidden patterns added (net, per file): 0 +readability warnings (net, per file; must be 0 in the final result): 0 +GATE PASS +Before -> after instruction-exact/code bytes/data bytes: MsgRead11/2480/128 ->11/2480/128; MsgSubject7/2776/232 ->8/3352/232; DateParser5/1168/40 ->5/1168/40. ReadMsgTextInternal94.55056 ->97.44382, retained as fuzzy improvement; NWC24iSetMsgSubjectQP99.548615 ->100.0000, retained as exact144/144,diffs0. +Changed source files: libs/RevoEX/src/nwc24/NWC24MsgRead.c and libs/RevoEX/src/nwc24/NWC24MsgSubject.c. Source commits e1602004 and592e7c2b. Attempts log tools/decomp-assist/fz7.attempts.md. Shared header, DateParser, configuration, all other sources remain unchanged. -- 2.49.1