// // sub_E18800 from 0xe18800 to 0xe18ea8 (1704 bytes) // // 1 xrefs: // > @ 0x13fc2e8 // // 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:42 +0000 // __int64 __fastcall sub_E18800(__int64 *a1, _BYTE *a2) { __int64 v4; // x19 __int64 v5; // x24 time_t v6; // x2 time_t v7; // x3 __int64 v8; // x1 time_t v9; // x0 __int64 v10; // x0 unsigned int v11; // w2 int v13; // w0 int v14; // w0 _QWORD *v15; // x19 __time_t v16; // x0 __int64 v17; // x1 _BOOL4 v18; // w0 __int64 v19; // x26 _QWORD *v20; // x21 int v21; // w0 int v22; // w3 __int64 v23; // x2 unsigned __int16 v24; // w1 int *v25; // x0 const char *v26; // x0 int v27; // w25 unsigned int v28; // w24 __int64 v29; // x1 char *v30; // x21 unsigned __int64 v31; // x27 __int64 v32; // d8 unsigned __int64 v33; // x28 _BYTE *v34; // x0 signed __int64 v35; // x25 signed __int64 v36; // x24 char *v37; // x3 size_t v38; // x24 signed __int64 v39; // x25 char *v40; // x0 bool v41; // zf char *v42; // x0 unsigned __int64 v43; // x24 char *v44; // x24 const char *v45; // x25 size_t v46; // x0 __int64 v47; // x0 int v48; // w5 size_t v49; // x0 __int64 v50; // x21 __int64 v51; // x1 char *v52; // [xsp+88h] [xbp+88h] time_t timer; // [xsp+90h] [xbp+90h] BYREF struct sockaddr v54; // [xsp+98h] [xbp+98h] BYREF v4 = a1[195]; v5 = *a1; time(&timer); v6 = *(_QWORD *)(v4 + 48); v7 = timer; if ( v6 < timer ) { *(_DWORD *)(v4 + 8) = -99; *(_DWORD *)v4 = 3; *a2 = 0; goto LABEL_14; } if ( timer > *(int *)(v4 + 32) + *(_QWORD *)(v4 + 56) ) { time((time_t *)(v4 + 56)); v8 = *(_QWORD *)(v4 + 48); v9 = timer; *a2 = 0; if ( v8 - v9 > 0 ) { v10 = **(_QWORD **)(v4 + 16); switch ( *(_DWORD *)v4 ) { case 0: v11 = sub_E17400(v4, 7u); goto LABEL_17; case 1: v11 = sub_E16864(v4, 7); goto LABEL_17; case 2: v11 = sub_E16D28(v4, 7); goto LABEL_17; case 3: sub_DF16E0(v10, "%s\n", "TFTP finished"); goto LABEL_18; default: sub_DF1848(v10, "%s", "Internal state machine error"); v11 = 71; break; } return v11; } LABEL_14: sub_DF1848(v5, "TFTP response timeout"); return 28; } *a2 = 0; if ( v6 - v7 <= 0 ) goto LABEL_14; v13 = sub_E16180(*(_DWORD *)(v4 + 24), -1, 0xFFFFFFFF, 0); if ( v13 == -1 ) { v25 = (int *)__errno(); v26 = (const char *)sub_E15618((__int64)a1, *v25); sub_DF1848(v5, "%s", v26); *(_DWORD *)(v4 + 12) = 5; goto LABEL_10; } if ( !v13 ) goto LABEL_10; v19 = a1[195]; LODWORD(timer) = 128; v20 = (_QWORD *)*a1; v21 = recvfrom(*(_DWORD *)(v19 + 24), *(void **)(v19 + 352), *(_DWORD *)(v19 + 340) + 4, 0, &v54, (socklen_t *)&timer); *(_DWORD *)(v19 + 332) = v21; v22 = v21; if ( !*(_DWORD *)(v19 + 328) ) { v27 = timer; memcpy((void *)(v19 + 200), &v54, (unsigned int)timer); *(_DWORD *)(v19 + 328) = v27; v22 = *(_DWORD *)(v19 + 332); } if ( v22 > 3 ) { v23 = *(_QWORD *)(v19 + 352); v24 = _byteswap_ushort(*(_WORD *)v23); *(_DWORD *)(v19 + 12) = v24; switch ( v24 ) { case 3u: if ( v22 == 4 || (*(unsigned __int8 *)(v23 + 3) | (*(unsigned __int8 *)(v23 + 2) << 8)) != (unsigned __int16)(*(_WORD *)(v19 + 64) + 1) ) { goto LABEL_28; } v28 = sub_DF23A8((__int64)a1, 1, (char *)(v23 + 4), v22 - 4); if ( !v28 ) { v29 = v20[19] + *(_DWORD *)(v19 + 332) - 4; v20[19] = v29; sub_DE8490(v20, v29); goto LABEL_28; } sub_E17910(v19, 5u); return v28; case 4u: goto LABEL_28; case 5u: *(_DWORD *)(v19 + 8) = *(unsigned __int8 *)(v23 + 3) | (*(unsigned __int8 *)(v23 + 2) << 8); sub_DF16E0((__int64)v20, "%s\n", (const char *)(v23 + 4)); goto LABEL_28; case 6u: v30 = (char *)(v23 + 2); v31 = v23 + 2 + v22 - 2; v32 = **(_QWORD **)(v19 + 16); *(_DWORD *)(v19 + 340) = 512; break; default: sub_DF1848((__int64)v20, "%s", "Internal error: Unexpected packet"); goto LABEL_28; } while ( 1 ) { if ( v31 <= (unsigned __int64)v30 ) { LABEL_28: if ( !(unsigned int)sub_DE8648(a1) ) goto LABEL_29; sub_E17910(v19, 5u); return 42; } v33 = v31 - (_QWORD)v30; v34 = memchr(v30, 0, v31 - (_QWORD)v30); if ( v34 ) v35 = v34 - v30; else v35 = v31 - (_QWORD)v30; v36 = v35 + 1; if ( v33 <= v35 + 1 ) goto LABEL_60; v37 = &v30[v36]; v38 = v33 - v36; v52 = v37; v39 = v35 + 2; v40 = (char *)memchr(v37, 0, v38); v41 = v40 == nullptr; v42 = (char *)(v40 - v52); if ( !v41 ) v38 = (size_t)v42; v43 = v39 + v38; if ( v33 < v43 || (v44 = &v30[v43], v45 = &v30[strlen(v30) + 1], !v44) ) { LABEL_60: sub_DF1848(v32, "Malformed ACK packet, rejecting"); return 71; } sub_DF16E0(v32, "got option=(%s) value=(%s)\n", v30, v45); v46 = strlen(v30); if ( (unsigned int)sub_E0AA10(v30, "blksize", v46) ) { v47 = strtol(v45, nullptr, 10); if ( !v47 ) { sub_DF1848(v32, "invalid blocksize value in OACK packet"); return 71; } if ( v47 > 65464 ) { sub_DF1848(v32, "%s (%d)", "blksize is larger than max supported", 65464); return 71; } if ( v47 <= 7 ) { sub_DF1848(v32, "%s (%d)", "blksize is smaller than min supported", 8); return 71; } v48 = *(_DWORD *)(v19 + 344); if ( v47 > v48 ) { sub_DF1848(v32, "%s (%ld)", "server requested blksize larger than allocated", v47); return 71; } *(_DWORD *)(v19 + 340) = v47; sub_DF16E0(v32, "%s (%d) %s (%d)\n", "blksize parsed from OACK", v47, "requested", v48); LABEL_54: v30 = v44; } else { v49 = strlen(v30); if ( !(unsigned int)sub_E0AA10(v30, "tsize", v49) ) goto LABEL_54; v50 = strtol(v45, nullptr, 10); sub_DF16E0(v32, "%s (%ld)\n", "tsize parsed from OACK", v50); if ( *(_BYTE *)(v32 + 1569) ) goto LABEL_54; if ( !v50 ) { sub_DF1848(v32, "invalid tsize -:%s:- value in OACK packet", v45); return 71; } v51 = v50; v30 = v44; sub_DE85E8(v32, v51); } } } sub_DF1848((__int64)v20, "Received too short packet"); *(_DWORD *)(v19 + 12) = 7; LABEL_29: v11 = sub_E17910(v4, *(_DWORD *)(v4 + 12)); LABEL_17: if ( !v11 ) { LABEL_18: v18 = *(_DWORD *)v4 == 3; *a2 = v18; if ( !v18 ) { LABEL_11: v14 = sub_DE8648(a1); v11 = 42; if ( !v14 ) { v15 = (_QWORD *)*a1; v16 = sub_DE6D4C(); return (unsigned int)sub_E01368(v15, v16, v17); } return v11; } sub_E0A54C((__int64)a1, -1, -1, 0, 0, -1, 0); LABEL_10: v11 = 0; if ( *a2 ) return v11; goto LABEL_11; } return v11; }
GD Web Decomp Icon

GD Web Decomp

Raw Source