Untitled
unknown
plain_text
a year ago
13 kB
11
Indexable
char __cdecl EPC_GetShakataJoho(_DWORD *a1, char *a2, int a3, char *a4, int a5, int *a6, int a7) {
// Variable declarations
int v7, v8, v9, v10, v11, result, v13, v15, v16, v17, v18, v19, v22;
char v14, v28, v44, JOHOKT;
const char *v20;
size_t v21;
_DWORD *v23;
int *v30, ErrorStatus, v24, v25, v26, v29;
unsigned int i, j, k;
void *v64;
char v89, v91, v93, Buf2[24], Src[24], v82, v83, v84, v94[4], v95, v96[4], v97[4], v98[4], v99[4], v103[4], v104[4];
char v76[40], v77[4], v80[4];
int v88, v90, v100, v101, v102, v72, v71, v74, v105, v69, v70, v73, v78[10], v81[10], v75[3];
// Initialize memory
memset(&byte;_10012CE0, 0, 9); // 9 byte
memset(&byte;_10012C10, 0, 6); // 6 byte
memset(&unk;_10012C3C, 0, 7); // 7 byte
sub_10008645(v76); // v76 is char[40]
v89 = v82 = v90 = v91 = v83 = v84 = 0;
sub_10008B42(&v88;); // int
sub_10004495(&v95;); // char
qt_mt312_819(v99, v75[0]); // v75 is int[3]
qt_mt312_819(v97, v75[0]);
qt_mt312_819(v103, v75[0]);
qt_mt312_819(v104, v75[0]);
v74 = v7;
((void (__thiscall *)(int *, char *))CreateQString)(&v74;, Source);
v74 = v8;
((void (__thiscall *)(int *, char *))CreateQString)(&v74;, Source);
v74 = v9;
((void (__thiscall *)(int *, char *))CreateQString)(&v74;, aF002);
file_settings_getmstfilename(&v102;);
((void (__thiscall *)(_DWORD *, char *))CreateQString)(v75, Source);
v74 = v10;
((void (__thiscall *)(int *, char *))CreateQString)(&v74;, Source);
v72 = v11;
((void (__thiscall *)(int *, char *))CreateQString)(&v72;, aF002);
file_settings_getIDXfilename(&v100;);
result = *(_DWORD *)(*(_DWORD *)qt_mt312_11848(&v102;, &v105;) + 12) & 0x3FFFFFFF;
qt_mt312_1453(&v105;);
if (!result) {
v74 = v13;
((void (__thiscall *)(int *, char *))CreateQString)(&v74;, Source);
EPC_SetErrorStatus(1000, 0);
v14 = 0;
goto cleanup;
}
sub_10004495(&v101;);
qt_mt312_819(v98, v75[0]);
CreateQString(v96, Source, v75[0]);
memset(Src, 0, 0x15u);
memset(Buf2, 0, 0x15u);
v74 = 0;
v73 = 0;
v72 = v15;
((void (__thiscall *)(int *, int))qt_mt312_163)(&v72;, 35);
v16 = a3;
if (qt_mt312_5492(a3) == -1) {
handle_error_case();
} else {
handle_success_case();
}
handle_final_cases();
cleanup:
cleanup_memory();
return 0;
}
void handle_error_case() {
v74 = 1;
v73 = 0;
v19 = qt_mt312_5750(&a3;, &unk;_10010034, -1);
v105 = qt_mt312_5488(v16, v19, v73, v74);
qt_mt312_1453(&a3;);
if (v105 < 0) {
if ((*(_DWORD *)(*(_DWORD *)v16 + 12) & 0x3FFFFFFF) != 0) {
v22 = 20;
do {
qt_mt312_2476(v16, &unk;_10010030);
--v22;
} while (v22);
sub_10001B45(v16, Src, 20);
sub_10001B45(v16, Buf2, 20);
}
} else {
CreateQString(&v105;, Source, v75[0]);
CreateQString(&a3;, &unk;_10010034, v75[0]);
qt_mt312_9711(v16, &a3;, &v105;);
qt_mt312_1453(&a3;);
qt_mt312_1453(&v105;);
v20 = (const char *)qt_mt312_3380(v16);
if (v20) {
v21 = strlen(v20);
} else {
v21 = 0;
}
memset(Src, 1, 0x15u); // it's 21 in decimal
sub_10001B45(v16, Src, v21);
memset(Buf2, 255, 0x15u);
sub_10001B45(v16, Buf2, v21);
}
}
void handle_success_case() {
qt_mt312_1880(v97, v16);
qt_mt312_1880(v99, v97);
CreateQString(&v105;, asc_10010054, v75[0]);
CreateQString(&a3;, asc_10010050, v75[0]);
v17 = qt_mt312_732(&v92;, &a3;, 1, 0, &v105;);
qt_mt312_9712(v16, v17);
qt_mt312_1424(&v92;);
qt_mt312_1453(&a3;);
qt_mt312_1453(&v105;);
CreateQString(&v105;, aZzzzzzzzzzzzzz, v75[0]);
CreateQString(&a3;, asc_10010050, v75[0]);
v18 = qt_mt312_732(&v92;, &a3;, 1, 0, &v105;);
qt_mt312_9712(v99, v18);
qt_mt312_1424(&v92;);
qt_mt312_1453(&a3;);
qt_mt312_1453(&v105;);
sub_10001B45(v16, Src, 20);
sub_10001B45(v99, Buf2, 20);
}
bool check_condition(void* ptr) {
return (*(unsigned int*)(*(unsigned int*)ptr + 12) & 0x3FFFFFFF) != 0;
}
void handle_final_cases() {
v23 = a1;
if (check_condition(v16) || !check_condition(a1)) {
if (check_condition(v16)) {
if (check_condition(a1)) {
process_a1();
} else {
process_else_a1();
}
} else {
process_final_else();
}
} else {
sub_1000905C(&v92;);
sub_10001B45(v23, &v89;, 6);
sub_10002F73(&v89;, a2, &v92;);
if (EPC_GetErrorStatus(v94, v103, v104) != ERROR_STATUS_OK) {
if (*(_DWORD *)(v92 + 12)) {
process_v92();
}
}
}
}
void process_a1() {
// Copy 6 bytes from a1 to v89
sub_10001B45(a1, &v89;, 6);
// Set up some parameters
v74 = a7;
v73 = v50;
// Call a function (likely for file or data processing)
((void (__thiscall *)(char **, int *))qt_mt312_814)(&v73;, &v100;);
// Set up more parameters
v73 = v51;
// Call the same function again with different parameters
((void (__thiscall *)(char **, int *))qt_mt312_814)(&v73;, &v102;);
// Get some kind of information or status
JOHOKT = EPC_GetJOHOKT(Src, Buf2, (unsigned int)v23, (int)a2, a4, a5, v72, (char)v73);
// Get an error status
ErrorStatus = EPC_GetErrorStatus(v94, v103, v104);
// Check for errors or invalid status
if (!JOHOKT || ErrorStatus == 1000) {
v14 = 0;
goto cleanup;
}
}
void process_else_a1() {
sub_10004528(&a1;);
v74 = (int)&a1;
v73 = v54;
((void (__thiscall *)(char **, int *))qt_mt312_814)(&v73;, &v100;);
v73 = v55;
((void (__thiscall *)(char **, int *))qt_mt312_814)(&v73;, &v102;);
v56 = EPC_GetJOHOKT(Src, Buf2, (unsigned int)v23, (int)a2, a4, a5, v72, (char)v73);
v57 = EPC_GetErrorStatus(v94, v103, v104);
if (!v56 || v57 == 1000) {
sub_10004691(a1);
goto cleanup;
}
process_a1_else_for_loop();
}
void process_a1_else_for_loop() {
sub_10004495(&a3;);
sub_10004495(&v105;);
for (i = 0; i < a1[3]; ++i) {
a4 = 0;
if (*(_DWORD *)(a3 + 12)) {
while (1) {
sub_10004648(&a3;);
v59 = sub_10004947(a4) + 12;
sub_10004675(&a1;);
v60 = sub_10004947(i);
v74 = v59;
if ((unsigned __int8)qt_mt312_2185(v60 + 12))
break;
if ((unsigned int)++a4 >= *(_DWORD *)(a3 + 12))
goto LABEL_59;
}
sub_10004675(&a1;);
v67 = sub_10004947(i);
sub_10004548(&a2;, v67 + 12);
} else {
process_a1_else_for_loop_inner();
}
}
sub_10004691(v105);
sub_10004691(a3);
sub_10004691(a1);
}
void process_a1_else_for_loop_inner() {
v61 = 0;
if (*(_DWORD *)(v105 + 12)) {
while (1) {
v74 = sub_10004506(v61);
v62 = sub_10004578(i);
if ((unsigned __int8)qt_mt312_2185(v62))
break;
if ((unsigned int)++v61 >= *(_DWORD *)(v105 + 12))
goto LABEL_62;
}
} else {
LABEL_62:
qt_mt312_819(&a5;, v75[0]);
v74 = (int)&a5;
v63 = sub_10004578(i);
v64 = (void *)qt_mt312_3380(v63);
EPC_GetCdNo(v64, v74);
if (EPC_GetErrorStatus(v94, v103, v104) == 1000) {
qt_mt312_1453(&a5;);
sub_10004691(v105);
sub_10004691(a3);
goto cleanup;
}
v65 = sub_10004858(&a5;);
v74 = i;
if (v65) {
v66 = sub_10004578(v74);
sub_10004548(v85, v66);
v74 = sub_10004578(i);
v73 = &v79;
} else {
v74 = sub_10004578(v74);
v73 = &v93;
}
sub_100044D6(v73, v74);
qt_mt312_1453(&a5;);
}
}
void process_final_else() {
sub_10001B45(a2, &v82;, 9);
sub_10008F90(v77);
sub_1000326F(&v82;, v77);
sub_10008F90(v80);
if (EPC_GetErrorStatus(v94, v103, v104) == 1000) {
LABEL_48:
sub_100045BC(v80);
sub_100045BC(v77);
goto cleanup;
}
a2 = 0;
if ((*(int (__thiscall **)(int *))v78[0])(v78) > 0) {
v33 = a6;
do {
v34 = qt_mt312_3436(v78, a2);
qt_mt312_814(&a3;, v34, v75[0]);
sub_10001B45(&a3;, &v89;, 6);
qt_mt312_1453(&a3;);
qt_mt312_819(&a6;, v75[0]);
EPC_GetCdNo(&v89;, &a6;);
v35 = *v33;
a1 = 0;
if (*(_DWORD *)(v35 + 12)) {
while (1) {
sub_10004648(v33);
v36 = sub_10004947(a1);
v74 = (int)&a6;
if ((unsigned __int8)qt_mt312_2185(v36 + 12))
break;
a1 = (_DWORD *)((char *)a1 + 1);
if ((unsigned int)a1 >= *(_DWORD *)(*v33 + 12))
goto LABEL_38;
}
((void (__thiscall *)(int *, int))qt_mt312_814)(&v74;, v34 + 8);
v73 = v37;
sub_10001BA8(&v73;);
v72 = v38;
sub_10003C4E(&v72;);
sub_10008FBE(v72, (char)v73, v74);
}
LABEL_38:
qt_mt312_1453(&a6;);
++a2;
v39 = (*(int (__thiscall **)(int *))v78[0])(v78);
} while ((int)a2 < v39);
}
if ((*(int (__thiscall **)(int *))v81[0])(v81)) {
a2 = 0;
if ((*(int (__thiscall **)(int *))v81[0])(v81) > 0) {
while (1) {
v40 = qt_mt312_3436(v81, a2);
qt_mt312_814(&a6;, v40 + 8, v75[0]);
sub_10001B45(&a6;, Src, 20);
qt_mt312_1453(&a6;);
memcpy(Buf2, Src, 0x14u);
sub_10004528(&a1;);
v74 = (int)&a1;
v73 = v41;
((void (__thiscall *)(char **, int *))qt_mt312_814)(&v73;, &v100;);
v71 = v42;
((void (__thiscall *)(int *, int *))qt_mt312_814)(&v71;, &v102;);
v71 = a5;
v70 = a4;
v69 = sub_10001BA8(&v105;);
v43 = sub_10003C4E(&a3;);
v44 = EPC_GetJOHOKT(Src, Buf2, v43, v69, v70, v71, v72, (char)v73);
qt_mt312_1453(&a3;);
qt_mt312_1453(&v105;);
v45 = EPC_GetErrorStatus(v94, v103, v104);
if (!v44 || v45 == 1000)
break;
v46 = a1;
for (j = 0; j < a1[3]; ++j) {
sub_10004675(&a1;);
v48 = sub_10004947(j);
sub_10004548(v85, v48 + 12);
v46 = a1;
}
sub_10004691(v46);
++a2;
v49 = (*(int (__thiscall **)(int *))v81[0])(v81);
if ((int)a2 >= v49)
goto LABEL_46;
}
sub_10004691(a1);
goto LABEL_48;
}
}
LABEL_46:
sub_100045BC(v80);
sub_100045BC(v77);
}
void process_v92() {
v24 = sub_10004338(&a2;, &v92;);
sub_100044B5(v24);
sub_10004691(a2);
a2 = 0;
if (*(_DWORD *)(v101 + 12)) {
while (1) {
sub_10004648(&v101;);
v25 = sub_10004947(a2);
qt_mt312_1880(v98, v25 + 12);
sub_10001B45(v98, Src, 20);
memcpy(Buf2, Src, 0x14u);
sub_10004528(&a6;);
v75[1] = &a6;
v75[0] = v26;
((void (__thiscall *)(_DWORD *, int *))qt_mt312_814)(v75, &v100;);
v73 = v27;
((void (__thiscall *)(char **, int *))qt_mt312_814)(&v73;, &v102;);
v28 = EPC_GetJOHOKT(Src, Buf2, (unsigned int)v23, (int)v96, a4, a5, v72, (char)v73);
v29 = EPC_GetErrorStatus(v94, v103, v104);
if (!v28 || v29 == 1000)
break;
v30 = a6;
for (k = 0; k < a6[3]; ++k) {
sub_10004675(&a6;);
v32 = sub_10004947(k);
sub_10004548(&a3;, v32 + 12);
v30 = a6;
}
sub_10004691(v30);
if ((unsigned int)++a2 >= *(_DWORD *)(v101 + 12))
goto LABEL_26;
v23 = a1;
}
sub_10004691(a6);
goto LABEL_28;
}
LABEL_26:
sub_10004691(v92);
goto cleanup;
}
void cleanup_memory() {
qt_mt312_1453(v96);
qt_mt312_1453(v98);
sub_10004691(v101);
qt_mt312_1453(&v100;);
qt_mt312_1453(&v102;);
qt_mt312_1453(v104);
qt_mt312_1453(v103);
qt_mt312_1453(v97);
qt_mt312_1453(v99);
sub_10004691(v95);
sub_10004691(v88);
sub_10001BBD(v76);
}
Editor is loading...
Leave a Comment