// // CAST_cbc_encrypt from 0xe79c4c to 0xe7a1e4 (1432 bytes) // // 3 xrefs: // > sub_E605BC @ 0xe60650 // > sub_E605BC @ 0xe606c4 // > @ 0x9f750 // // This function is hookable on this platform! // // Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA // Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings // __int64 *__fastcall CAST_cbc_encrypt(__int64 a1, _BYTE *a2, __int64 a3, int *a4, __int64 a5, int a6) { _BYTE *v6; // d8 __int64 v7; // x19 unsigned __int64 v11; // x26 unsigned int v12; // w6 unsigned int v13; // w5 unsigned __int64 v14; // x26 _BYTE *v15; // x20 __int64 v16; // x28 __int64 v17; // x27 int v18; // w4 int v19; // w8 int v20; // w7 __int64 v21; // x27 int v22; // w3 int v23; // w2 unsigned __int64 v24; // x24 unsigned int v25; // w28 unsigned int v26; // w22 _BYTE *v27; // x20 __int64 v28; // x27 int v29; // w26 unsigned int v30; // w25 unsigned int v31; // w26 unsigned int v32; // w6 int v33; // w5 int v34; // w6 unsigned __int64 v35; // x28 int v36; // w3 int v37; // w20 unsigned int v38; // w19 int v39; // w20 int v40; // w4 _BYTE *v41; // x22 int v42; // w26 int v44; // w3 int v45; // w3 int v46; // w0 int v47; // w3 int v48; // w0 int v49; // w2 __int64 v50; // x1 int v51; // w2 int v52; // w0 int v53; // w2 char v54; // w4 char v55; // w3 unsigned int v56; // w7 unsigned int v57; // w2 char v58; // w1 char v59; // w0 _BYTE *v60; // x0 _BYTE *v61; // x1 _BYTE *v62; // x1 __int64 v63; // [xsp+88h] [xbp+88h] BYREF unsigned int v64; // [xsp+98h] [xbp+98h] BYREF unsigned int v65; // [xsp+9Ch] [xbp+9Ch] v6 = a2; v7 = a1; if ( a6 ) { v11 = a3 - 8; v12 = _byteswap_ulong(*(_DWORD *)a5); v13 = _byteswap_ulong(*(_DWORD *)(a5 + 4)); if ( a3 - 8 < 0 ) { v17 = a1; } else { v14 = v11 >> 3; v15 = a2; v16 = 8 * (v14 + 1); v17 = a1 + v16; do { v18 = *(unsigned __int8 *)(v7 + 6); v7 += 8; v15 += 8; v19 = *(unsigned __int8 *)(v7 - 3); v20 = *(unsigned __int8 *)(v7 - 4); v64 = v12 ^ _byteswap_ulong(*(_DWORD *)(v7 - 8)); v65 = v13 ^ ((v18 << 8) | (v19 << 16) | (v20 << 24) | *(unsigned __int8 *)(v7 - 1)); CAST_encrypt((int *)&v64, (__int64)a4); v12 = v64; v13 = v65; *(v15 - 8) = HIBYTE(v64); *(v15 - 5) = v12; *(v15 - 7) = BYTE2(v12); *(v15 - 6) = BYTE1(v12); *(v15 - 4) = HIBYTE(v13); *(v15 - 3) = BYTE2(v13); *(v15 - 2) = BYTE1(v13); *(v15 - 1) = v13; } while ( v7 != v17 ); v11 = a3 - 16 - 8 * v14; v6 += v16; } if ( v11 == -8 ) { v56 = HIBYTE(v12); v54 = BYTE2(v12); v55 = BYTE1(v12); v57 = HIBYTE(v13); v58 = BYTE2(v13); v59 = BYTE1(v13); } else { v21 = v17 + v11 + 8; if ( v11 + 7 <= 6 ) { switch ( (int)v11 ) { case -7: v22 = 0; v53 = 0; goto LABEL_25; case -6: v22 = 0; v51 = 0; goto LABEL_24; case -5: v22 = 0; v50 = v21; v49 = 0; goto LABEL_23; case -4: v22 = 0; goto LABEL_22; case -3: v47 = 0; goto LABEL_21; case -2: v45 = 0; goto LABEL_20; case -1: v44 = *(unsigned __int8 *)--v21; v45 = v44 << 8; LABEL_20: v46 = *(unsigned __int8 *)--v21; v47 = v45 | (v46 << 16); LABEL_21: v48 = *(unsigned __int8 *)--v21; v22 = v47 | (v48 << 24); LABEL_22: v49 = *(unsigned __int8 *)(v21 - 1); v50 = v21 - 1; LABEL_23: v21 = v50 - 1; v51 = v49 | (*(unsigned __int8 *)(v50 - 1) << 8); LABEL_24: v52 = *(unsigned __int8 *)--v21; v53 = v51 | (v52 << 16); LABEL_25: v23 = v53 | (*(unsigned __int8 *)(v21 - 1) << 24); break; default: goto LABEL_8; } } else { LABEL_8: v22 = 0; v23 = 0; } v64 = v23 ^ v12; v65 = v22 ^ v13; CAST_encrypt((int *)&v64, (__int64)a4); v54 = BYTE2(v64); v55 = BYTE1(v64); v56 = HIBYTE(v64); v57 = HIBYTE(v65); v58 = BYTE2(v65); v59 = BYTE1(v65); LOBYTE(v12) = v64; LOBYTE(v13) = v65; v6[1] = BYTE2(v64); *v6 = v56; v6[2] = v55; v6[3] = v12; v6[4] = v57; v6[5] = v58; v6[6] = v59; v6[7] = v13; } BYTE6(v63) = v59; LOBYTE(v63) = v56; BYTE1(v63) = v54; BYTE2(v63) = v55; BYTE3(v63) = v12; BYTE4(v63) = v57; BYTE5(v63) = v58; HIBYTE(v63) = v13; *(_QWORD *)a5 = v63; return &v63; } else { v24 = a3 - 8; v25 = _byteswap_ulong(*(_DWORD *)a5); v26 = _byteswap_ulong(*(_DWORD *)(a5 + 4)); if ( a3 - 8 < 0 ) { v31 = v26; v30 = _byteswap_ulong(*(_DWORD *)a5); v28 = a1; } else { v27 = a2; v28 = a1 + 8 * ((v24 >> 3) + 1); do { v29 = *(unsigned __int8 *)(v7 + 6); v7 += 8; v27 += 8; v30 = _byteswap_ulong(*(_DWORD *)(v7 - 8)); v31 = (v29 << 8) | (*(unsigned __int8 *)(v7 - 3) << 16) | (*(unsigned __int8 *)(v7 - 4) << 24) | *(unsigned __int8 *)(v7 - 1); v64 = v30; v65 = v31; CAST_decrypt((int *)&v64, a4); v32 = v65; v33 = v25 ^ v64; *(v27 - 5) = v25 ^ v64; v34 = v26 ^ v32; *(v27 - 8) = HIBYTE(v33); *(v27 - 7) = BYTE2(v33); v25 = v30; *(v27 - 6) = BYTE1(v33); v26 = v31; *(v27 - 4) = HIBYTE(v34); *(v27 - 3) = BYTE2(v34); *(v27 - 2) = BYTE1(v34); *(v27 - 1) = v34; } while ( v7 != v28 ); v6 += 8 * (v24 >> 3) + 8; v24 = a3 - 16 - 8 * (v24 >> 3); } if ( v24 != -8 ) { v36 = *(unsigned __int8 *)(v28 + 6); v37 = *(unsigned __int8 *)(v28 + 7) | (*(unsigned __int8 *)(v28 + 4) << 24) | (*(unsigned __int8 *)(v28 + 5) << 16); v38 = _byteswap_ulong(*(_DWORD *)v28); v64 = v38; v39 = v37 | (v36 << 8); v65 = v39; CAST_decrypt((int *)&v64, a4); v40 = v30 ^ v64; v35 = v24 + 8; v41 = &v6[v24 + 8]; v42 = v31 ^ v65; if ( v24 + 7 <= 6 ) { switch ( (int)v24 ) { case -7: v62 = &v6[v35]; goto LABEL_40; case -6: goto LABEL_39; case -5: v61 = &v6[v35]; goto LABEL_38; case -4: goto LABEL_37; case -3: v60 = &v6[v35]; goto LABEL_36; case -2: goto LABEL_35; case -1: *--v41 = BYTE1(v42); LABEL_35: v60 = v41 - 1; *(v41 - 1) = BYTE2(v42); LABEL_36: v41 = v60 - 1; *(v60 - 1) = HIBYTE(v42); LABEL_37: v61 = v41 - 1; *(v41 - 1) = v40; LABEL_38: v41 = v61 - 1; *(v61 - 1) = BYTE1(v40); LABEL_39: v62 = v41 - 1; *(v41 - 1) = BYTE2(v40); LABEL_40: v31 = v39; v30 = v38; *(v62 - 1) = HIBYTE(v40); break; default: goto LABEL_15; } } else { LABEL_15: v31 = v39; v30 = v38; } } *(_BYTE *)(a5 + 7) = v31; *(_BYTE *)(a5 + 3) = v30; *(_BYTE *)a5 = HIBYTE(v30); *(_BYTE *)(a5 + 1) = BYTE2(v30); *(_BYTE *)(a5 + 2) = BYTE1(v30); *(_BYTE *)(a5 + 4) = HIBYTE(v31); *(_BYTE *)(a5 + 5) = BYTE2(v31); *(_BYTE *)(a5 + 6) = BYTE1(v31); return (__int64 *)HIWORD(v31); } }
GD Web Decomp Icon

GD Web Decomp

Raw Source