int __fastcall hdcp_subcmd12_rxinfo(struct hdcp_session *sess, unsigned __int8 *msg, unsigned int len, int *out) { int result; // r0 unsigned int v9; // r8 unsigned int v10; // r10 int v11; // r9 __int16 v12; // r6 __int16 v13; // r9 unsigned int v14; // r0 int v15; // r6 bool v16; // zf int v17; // r0 int v18; // r9 unsigned int v19; // r0 unsigned int seq_valid; // r1 int rx_count; // r8 int v22; // r7 __int64 v23; // r2 _BYTE *v24; // r0 unsigned int mode; // r1 unsigned int v26; // r8 unsigned int v27; // r7 int v28; // r0 int v29; // r1 unsigned int f44; // r2 int v31; // r1 _BYTE *v32; // r1 unsigned int v33; // r3 unsigned int v34; // r6 unsigned int v35; // r7 unsigned int i; // r7 unsigned __int8 *v37; // r1 int v38; // r0 int v39; // r6 int v40; // r2 int v41; // r3 int f4c_high; // r1 unsigned int devid; // r0 int v44; // r0 unsigned int v45; // r6 unsigned __int8 v46; // [sp+4h] [bp-210h] int v47; // [sp+8h] [bp-20Ch] int v48; // [sp+Ch] [bp-208h] int v49; // [sp+10h] [bp-204h] int v50; // [sp+14h] [bp-200h] int v51; // [sp+18h] [bp-1FCh] BYREF unsigned __int16 v52; // [sp+1Ch] [bp-1F8h] BYREF int v53; // [sp+20h] [bp-1F4h] BYREF unsigned __int8 f50_high; // [sp+24h] [bp-1F0h] _BYTE v55[3]; // [sp+25h] [bp-1EFh] BYREF _DWORD v56[8]; // [sp+C0h] [bp-154h] BYREF int v57[8]; // [sp+E0h] [bp-134h] BYREF _BYTE v58[200]; // [sp+100h] [bp-114h] BYREF int v59; // [sp+1C8h] [bp-4Ch] BYREF _DWORD v60[11]; // [sp+1E8h] [bp-2Ch] BYREF v60[10] = *off_40394C; v52 = 0; ta_memclr(v58, 0x10Cu); result = 1; if ( sess == nullptr || msg == nullptr || out == nullptr ) return result; *out = 100; if ( sess->flag_24d != 0 ) { if ( asd_rpc_1a2(sess->devid) != 0 ) return 20; sess->flag_24d = 0; } if ( sess->topology_type == 6 ) { if ( sess->mode == 20 ) { if ( len <= 1 ) goto LABEL_27; v9 = msg[1]; sess->f34 = v9; v10 = *msg; sess->f30 = v10; v11 = msg[2]; sess->rx_count = v11; sess->f3c = msg[3]; if ( msg[1] == 0 && *msg == 0 ) { if ( 5 * msg[2] + 36 == len ) { v12 = 0; v47 = 32; sess->seq_valid = 0; ta_memcpy(v57, msg + 4, 0x20u); ta_memcpy(sess->rx_ids, msg + 36, 5 * v11); v46 = 0; v48 = 0; v50 = 0; v49 = 0; goto LABEL_17; } LABEL_27: sess->err_state = 7; v17 = 109; LABEL_31: *out = v17; return 0; } LABEL_30: sess->err_state = 7; v17 = 107; goto LABEL_31; } if ( len <= 1 ) goto LABEL_27; v9 = msg[1]; sess->f34 = v9; v10 = *msg; sess->f30 = v10; v18 = msg[2]; sess->rx_count = v18; sess->f3c = msg[3]; sess->f40 = msg[5]; sess->f44 = msg[4]; if ( msg[1] != 0 || *msg != 0 ) goto LABEL_30; if ( 5 * msg[2] + 25 != len ) goto LABEL_27; v48 = msg[6]; v50 = msg[7]; v49 = msg[8]; v47 = 16; ta_memcpy(v57, msg + 9, 0x10u); ta_memcpy(sess->rx_ids, msg + 25, 5 * v18); v12 = 0; v46 = 0; } else { if ( len != 176 ) goto LABEL_27; v46 = *msg; v13 = msg[1]; ta_bounded_copy(msg, &v52, 2u); v14 = v52; v9 = (v52 & 8) != 0; sess->f34 = v9; sess->f44 = (v14 & 2) != 0; sess->f40 = v14 & 1; sess->f3c = (v14 >> 9) & 7; v15 = (v14 >> 4) & 0x1F; sess->rx_count = v15; v10 = (v14 & 4) != 0; sess->f30 = v10; v48 = msg[2]; v50 = msg[3]; v49 = msg[4]; v47 = 16; ta_memcpy(v57, msg + 5, 0x10u); ta_memcpy(sess->rx_ids, msg + 21, 5 * v15); v12 = v13 << 8; } LABEL_17: v16 = v9 == 0; if ( v9 == 0 ) v16 = v10 == 0; if ( !v16 ) goto LABEL_30; if ( (sess->f40 != 0 || sess->f44 != 0) && sess->f1c - 1 <= 1 ) { sess->f20 = 0; if ( asd_rpc_1a3(sess->devid, 1) != 0 ) return 17; } v19 = v48 | (v50 << 8) | (v49 << 16); seq_valid = sess->seq_valid; if ( v19 != 0 && seq_valid == 0 || seq_valid == 1 && v19 < sess->seq_num ) { sess->err_state = 7; v17 = 108; goto LABEL_31; } rx_count = sess->rx_count; sess->seq_num = v19; sess->seq_valid = 1; v22 = 5 * rx_count; ta_memcpy(v58, sess->rx_ids, 5 * rx_count); if ( sess->topology_type != 6 ) { v26 = v47; v58[v22] = v46 | v12; v58[v22 + 1] = HIBYTE(v12); v28 = 5; v29 = 2; LABEL_46: v31 = v29 + v22; v27 = v22 + v28; v58[v31] = v48; v32 = &v58[v31]; v32[2] = v49; v32[1] = v50; goto LABEL_47; } v23 = *(_QWORD *)&sess->f30; v58[5 * rx_count] = sess->f3c; v24 = &v58[v22]; mode = sess->mode; v24[2] = BYTE4(v23); v24[1] = rx_count; v24[3] = v23; if ( mode != 20 ) { f44 = sess->f44; v24[5] = *(_QWORD *)&sess->f40; v28 = 9; v58[v22 + 4] = f44; v29 = 6; v26 = v47; goto LABEL_46; } v26 = v47; v27 = v22 + 4; LABEL_47: ta_memcpy(&v59, &sess->rx_ids[189], 0x20u); v60[8] = v26; ta_memcpy_aligned(v60, v57, v26); if ( hdcp_verify_mac(v58, v27, v56, &v51, 0x20u) != 0 ) { sess->err_state = 7; *out = 106; ta_memclr(v56, 0x20u); ta_memclr(v58, 0x10Cu); return 0; } if ( v51 == 32 ) { v33 = v56[5]; v34 = v56[6]; v35 = v56[7]; sess->hash[0] = v56[4]; sess->hash[1] = v33; sess->hash[2] = v34; sess->hash[3] = v35; } ta_memclr(v56, 0x20u); ta_memclr(v58, 0x10Cu); for ( i = 0; i < sess->rx_count; ++i ) { v37 = &sess->rx_ids[5 * i]; v38 = *v37; v39 = v37[3]; v40 = v37[1]; v41 = v37[2]; f50_high = v37[4]; v53 = v38 | (v40 << 8) | ((v41 | (v39 << 8)) << 16); if ( asd_rpc_303(&v53) != 0 ) goto LABEL_59; } if ( asd_rpc_1a8(sess->buf268) != 0 ) return 17; ta_memclr_unaligned(v55, 0x9Bu); f4c_high = HIBYTE(sess->f4c); f50_high = HIBYTE(sess->f50); devid = sess->devid; v53 = f4c_high | (LOBYTE(sess->f50) << 8) | ((BYTE1(sess->f50) | (BYTE2(sess->f50) << 8)) << 16); v44 = asd_rpc_1a7(devid, &v53, 1u, sess->buf268); if ( v44 != 0 || (v45 = sess->rx_count, ta_memcpy(&v53, sess->rx_ids, 5 * v45), (v44 = asd_rpc_1a7(sess->devid, &v53, v45, sess->buf268)) != 0) ) { if ( v44 != 23 ) return 17; LABEL_59: sess->err_state = 7; *out = 112; return 17; } *out = 0; return 0; }