// // sub_E1C978 from 0xe1c978 to 0xe1d4d4 (2908 bytes) // // 1 xrefs: // > sub_E1B8F8 @ 0xe1b940 // // This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True! // // Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA // Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings // Generated at Fri, 27 Nov 2026 13:09:44 +0000 // __int64 __fastcall sub_E1C978(__int64 a1) { __int64 v1; // x27 unsigned int v3; // w21 unsigned int v4; // w19 __int64 result; // x0 char *v6; // x28 size_t v7; // x0 __int64 v8; // x5 __int64 v9; // x19 __int64 v10; // x28 __int64 v11; // x28 __int64 v12; // x0 __int64 v13; // x0 int v14; // w1 unsigned int v15; // w0 char *v16; // x28 char *v17; // x0 const char *v18; // x2 const char *v19; // x3 const char *v20; // x0 const char *v21; // x1 char *v22; // x0 __int64 v23; // x1 int v24; // w1 __int64 v25; // x28 int v26; // t1 unsigned __int8 *v27; // x26 int v28; // w19 unsigned __int8 *v29; // x5 unsigned __int64 v30; // x3 unsigned __int8 *v31; // x28 int v32; // t1 void *v33; // x28 char *v34; // x26 int v35; // w0 int v36; // w0 int v37; // w0 int v38; // w0 const char *v39; // x2 unsigned __int64 v40; // x26 __int64 v41; // x5 size_t v42; // x28 size_t v43; // x2 _QWORD *v44; // x1 const char *v45; // x2 const char *v46; // x4 const char *v47; // x3 unsigned int v48; // [xsp+98h] [xbp+98h] char *v49; // [xsp+98h] [xbp+98h] unsigned __int64 v50; // [xsp+98h] [xbp+98h] size_t v51; // [xsp+98h] [xbp+98h] __int64 v52; // [xsp+98h] [xbp+98h] unsigned int v53; // [xsp+ACh] [xbp+ACh] BYREF __int64 v54; // [xsp+B0h] [xbp+B0h] BYREF char *v55; // [xsp+B8h] [xbp+B8h] BYREF char v56[24]; // [xsp+C0h] [xbp+C0h] BYREF v1 = a1 + 1560; v54 = 0; v3 = *(_DWORD *)(a1 + 608); if ( *(_DWORD *)(a1 + 1672) != 4 ) { if ( *(_QWORD *)(a1 + 1608) ) return sub_E20BE0(v1); while ( 1 ) { v4 = sub_E20870(v3, v1, &v53, &v54); if ( v4 ) return v4; if ( v53 == -1 ) return 8; if ( !v53 ) return 0; switch ( *(_DWORD *)(v1 + 112) ) { case 1: if ( v53 == 79 ) { *(_DWORD *)(v1 + 132) = 0; *(_DWORD *)(v1 + 140) = 0; *(_BYTE *)(v1 + 165) = 0; result = sub_E1AEB4(a1, "CAPABILITY"); if ( !(_DWORD)result ) goto LABEL_127; } else { sub_DF1848(*(_QWORD *)a1, "Got unexpected imap-server response"); return 8; } return result; case 2: v13 = *(_QWORD *)a1; if ( v53 == 42 ) { v27 = (unsigned __int8 *)(v13 + 2826); v28 = *(unsigned __int8 *)(v13 + 2826); while ( 1 ) { while ( 1 ) { if ( !v28 ) goto LABEL_31; if ( v28 != 13 && v28 != 32 && (unsigned __int8)(v28 - 9) > 1u ) break; v28 = *++v27; } v29 = v27 + 1; v30 = 0; do { v31 = v29; v32 = *v29++; v28 = v32; ++v30; } while ( (v32 & 0xFFFFFFDF) != 0 && (unsigned __int8)(v32 - 9) > 1u && v28 != 13 ); switch ( v30 ) { case 8uLL: v36 = memcmp(v27, "STARTTLS", 8u); v30 = 8; if ( v36 ) goto LABEL_97; v27 += 8; *(_BYTE *)(v1 + 165) = 1; v28 = *v27; break; case 0xDuLL: v37 = memcmp(v27, "LOGINDISABLED", 0xDu); v30 = 13; if ( v37 ) goto LABEL_97; v27 += 13; *(_BYTE *)(v1 + 166) = 1; v28 = *v27; break; case 7uLL: v38 = memcmp(v27, "SASL-IR", 7u); v30 = 7; if ( v38 ) { LABEL_97: v50 = v30; if ( !memcmp(v27, "AUTH=", 5u) ) { v33 = v27 + 5; v34 = (char *)(v50 - 5); v35 = sub_E248B4(v33); if ( v35 && v34 == v55 ) *(_DWORD *)(v1 + 132) |= v35; v28 = (unsigned __int8)v34[(_QWORD)v33]; v27 = (unsigned __int8 *)&v34[(_QWORD)v33]; } else { LABEL_96: v27 = v31; } } else { v27 += 7; *(_BYTE *)(v1 + 167) = 1; v28 = *v27; } break; default: if ( v30 <= 5 ) goto LABEL_96; goto LABEL_97; } } } if ( v53 != 79 ) { if ( !(unsigned __int8)sub_E24B90(a1 + 1680, a1) ) goto LABEL_40; v15 = sub_E24BB0(a1 + 1680, a1, *(unsigned __int8 *)(v1 + 167), &v55); if ( !v15 ) { if ( (_DWORD)v55 == 1 ) goto LABEL_151; if ( *(_BYTE *)(v1 + 166) || (*(_DWORD *)(v1 + 152) & 1) == 0 ) { LABEL_135: sub_DF16E0(*(_QWORD *)a1, "No known authentication mechanisms supported!\n"); return 67; } if ( !*(_BYTE *)(a1 + 960) ) goto LABEL_40; LABEL_56: v16 = sub_E1B0FC(*(char **)(a1 + 536), 0); v17 = sub_E1B0FC(*(char **)(a1 + 544), 0); if ( v16 ) v18 = v16; else v18 = &byte_11B8890; if ( v17 ) v19 = v17; else v19 = &byte_11B8890; v49 = v17; v4 = sub_E1AEB4(a1, "LOGIN %s %s", v18, v19); off_154A3C8(v16); off_154A3C8(v49); if ( v4 ) return v4; *(_DWORD *)(v1 + 112) = 6; goto LABEL_31; } goto LABEL_67; } v14 = *(_DWORD *)(v13 + 1584); if ( !v14 || *(_BYTE *)(a1 + 664) ) { LABEL_69: if ( !(unsigned __int8)sub_E24B90(a1 + 1680, a1) ) goto LABEL_40; v15 = sub_E24BB0(a1 + 1680, a1, *(unsigned __int8 *)(v1 + 167), &v55); if ( !v15 ) { if ( (_DWORD)v55 == 1 ) { LABEL_151: *(_DWORD *)(v1 + 112) = 5; } else { if ( *(_BYTE *)(v1 + 166) || (*(_DWORD *)(v1 + 152) & 1) == 0 ) goto LABEL_135; if ( *(_BYTE *)(a1 + 960) ) { v4 = sub_E1B530(a1); if ( v4 ) return v4; goto LABEL_31; } LABEL_40: *(_DWORD *)(v1 + 112) = 0; } LABEL_31: if ( !*(_DWORD *)(v1 + 112) ) return 0; goto LABEL_32; } LABEL_67: v4 = v15; if ( v15 ) return v4; goto LABEL_31; } if ( !*(_BYTE *)(v1 + 165) ) { if ( v14 == 1 ) goto LABEL_69; sub_DF1848(v13, "STARTTLS not supported."); return 64; } result = sub_E1AEB4(a1, "STARTTLS"); if ( (_DWORD)result ) return result; *(_DWORD *)(v1 + 112) = 3; LABEL_32: if ( !(unsigned __int8)sub_E20CB8(v1) ) return 0; break; case 3: v12 = *(_QWORD *)a1; if ( v53 == 79 ) { result = sub_E30164(a1, 0, a1 + 1676); if ( (_DWORD)result ) return result; if ( *(_DWORD *)(v1 + 112) != 4 ) *(_DWORD *)(v1 + 112) = 4; if ( *(_BYTE *)(v1 + 116) ) { *(_QWORD *)(a1 + 1024) = &off_13FC3E0; *(_BYTE *)(a1 + 952) = 1; *(_DWORD *)(v1 + 132) = 0; *(_DWORD *)(v1 + 140) = 0; *(_BYTE *)(v1 + 165) = 0; result = sub_E1AEB4(a1, "CAPABILITY"); if ( (_DWORD)result ) return result; LABEL_127: *(_DWORD *)(v1 + 112) = 2; } goto LABEL_32; } if ( *(_DWORD *)(v12 + 1584) != 1 ) { sub_DF1848(v12, "STARTTLS denied. %c", v53); return 64; } goto LABEL_69; case 5: v11 = *(_QWORD *)a1; v4 = sub_E24FEC(a1 + 1680, a1); if ( v4 ) return v4; if ( (_DWORD)v55 ) { if ( (_DWORD)v55 == 2 ) *(_DWORD *)(v1 + 112) = 0; goto LABEL_31; } if ( *(_BYTE *)(v1 + 166) || (*(_DWORD *)(v1 + 152) & 1) == 0 ) { sub_DF1848(v11, "Authentication cancelled"); return 67; } if ( !*(_BYTE *)(a1 + 960) ) { *(_DWORD *)(v1 + 112) = *(unsigned __int8 *)(a1 + 960); goto LABEL_31; } goto LABEL_56; case 6: if ( v53 == 79 ) goto LABEL_7; sub_DF1848(*(_QWORD *)a1, aAccessDenied); return 67; case 7: case 0xD: v48 = v53; v6 = (char *)(*(_QWORD *)a1 + 2824LL); v7 = strlen(v6); if ( v48 == 42 ) { v6[v7] = 10; v51 = v7; v4 = sub_DF23A8(a1, 1, v6, v7 + 1); v6[v51] = 0; if ( v4 ) return v4; goto LABEL_31; } result = 21; if ( v48 != 79 ) return result; LABEL_7: *(_DWORD *)(v1 + 112) = 0; return 0; case 8: v9 = *(_QWORD *)a1; v10 = *(_QWORD *)(*(_QWORD *)a1 + 536LL); if ( v53 == 42 ) { if ( sscanf((const char *)(v9 + 2826), "OK [UIDVALIDITY %19[0123456789]]", v56) == 1 ) { off_154A3C8(*(void **)(v1 + 176)); *(_QWORD *)(v1 + 176) = 0; *(_QWORD *)(v1 + 176) = off_154A3D8(v56); } } else { if ( v53 != 79 ) { v4 = 67; sub_DF1848(*(_QWORD *)a1, "Select failed"); return v4; } v20 = *(const char **)(v10 + 16); if ( v20 ) { v21 = *(const char **)(v1 + 176); if ( v21 ) { if ( strcmp(v20, v21) ) { sub_DF1848(v9, "Mailbox UIDVALIDITY has changed"); return 78; } } } v22 = off_154A3D8(*(const char **)(v10 + 8)); v23 = *(_QWORD *)(v10 + 56); *(_QWORD *)(v1 + 168) = v22; if ( v23 ) { v15 = sub_E1B764((_DWORD *)a1); goto LABEL_67; } if ( *(_QWORD *)(v10 + 48) ) { v39 = *(const char **)(*(_QWORD *)(*(_QWORD *)a1 + 536LL) + 48LL); if ( !v39 ) { v4 = 3; sub_DF1848(*(_QWORD *)a1, "Cannot SEARCH without a query string."); return v4; } v4 = sub_E1AEB4(a1, "SEARCH %s", v39); if ( v4 ) return v4; *(_DWORD *)(v1 + 112) = 13; } else { v44 = *(_QWORD **)(*(_QWORD *)a1 + 536LL); v45 = (const char *)v44[3]; if ( !v45 ) { v4 = 3; sub_DF1848(*(_QWORD *)a1, "Cannot FETCH without a UID."); return v4; } v46 = (const char *)v44[5]; v47 = (const char *)v44[4]; if ( v46 ) { if ( !v47 ) v47 = &byte_11B8890; v4 = sub_E1AEB4(a1, "FETCH %s BODY[%s]<%s>", v45, v47, v46); } else { if ( !v47 ) v47 = &byte_11B8890; v4 = sub_E1AEB4(a1, "FETCH %s BODY[%s]", v45, v47); } if ( v4 ) return v4; *(_DWORD *)(v1 + 112) = 9; } } goto LABEL_31; case 9: v8 = *(_QWORD *)a1; if ( v53 != 42 ) { sub_DE85E8(*(_QWORD *)a1, -1); *(_DWORD *)(v1 + 112) = 0; return 78; } v24 = *(unsigned __int8 *)(v8 + 2824); v25 = v8 + 2824; if ( v24 != 123 ) { do { if ( !v24 ) break; v26 = *(unsigned __int8 *)++v25; v24 = v26; } while ( v26 != 123 ); } if ( v24 == 123 && (v52 = *(_QWORD *)a1, v40 = strtol((const char *)(v25 + 1), &v55, 10), (__int64)&v55[-v25] > 1) && *v55 == 125 && v55[1] == 13 && !v55[2] ) { sub_DF16E0(v52, "Found %lu bytes to download\n", v40); sub_DE85E8(v52, v40); v41 = v52; if ( *(_QWORD *)v1 ) { v42 = *(_QWORD *)(v1 + 8); if ( v40 <= v42 ) v42 = v40; result = sub_DF23A8(a1, 1, *(char **)v1, v42); if ( (_DWORD)result ) return result; *(_QWORD *)(v52 + 152) += v42; sub_DF16E0(v52, "Written %lu bytes, %lu bytes are left for transfer\n", v42, v40 - v42); v43 = *(_QWORD *)(v1 + 8); if ( v42 >= v43 ) { off_154A3C8(*(void **)v1); *(_QWORD *)v1 = 0; *(_QWORD *)(v1 + 8) = 0; v41 = v52; } else { memmove(*(void **)v1, (const void *)(*(_QWORD *)v1 + v42), v43 - v42); v41 = v52; *(_QWORD *)(v1 + 8) -= v42; } } if ( v40 == *(_QWORD *)(v41 + 152) ) { sub_E0A54C(a1, -1, -1, 0, 0, -1, 0); } else { *(_QWORD *)(v41 + 136) = v40; sub_E0A54C(a1, 0, v40, 0, 0, -1, 0); } *(_DWORD *)(v1 + 112) = 0; } else { v4 = 8; sub_DF1848(**(_QWORD **)(v1 + 88), "Failed to parse FETCH response."); *(_DWORD *)(v1 + 112) = 0; } if ( v4 ) return v4; goto LABEL_31; case 0xA: result = 8; if ( v53 != 79 ) return result; *(_DWORD *)(v1 + 112) = 0; return 0; case 0xB: result = 25; if ( v53 == 43 ) { sub_DE8618(*(_QWORD *)a1, *(_QWORD *)(*(_QWORD *)a1 + 36088LL)); sub_E0A54C(a1, -1, -1, 0, 0, 0, 0); *(_DWORD *)(v1 + 112) = 0; return 0; } return result; case 0xC: result = 25; if ( v53 != 79 ) return result; *(_DWORD *)(v1 + 112) = 0; return 0; default: goto LABEL_7; } } } result = sub_E30164(a1, 0, a1 + 1676); if ( (_DWORD)result ) return result; if ( *(_DWORD *)(v1 + 112) != 4 ) *(_DWORD *)(v1 + 112) = 4; if ( !*(_BYTE *)(v1 + 116) ) return 0; *(_BYTE *)(a1 + 952) = 1; *(_QWORD *)(a1 + 1024) = &off_13FC3E0; *(_DWORD *)(v1 + 132) = 0; *(_DWORD *)(v1 + 140) = 0; *(_BYTE *)(v1 + 165) = 0; result = sub_E1AEB4(a1, "CAPABILITY"); if ( !(_DWORD)result ) *(_DWORD *)(v1 + 112) = 2; return result; }
GD Web Decomp Icon

GD Web Decomp

Raw Source