DWORD
__userpurge Function@(
int
a1@,
struct
simulation_context *lpThreadParameter)
{
struct
string *begin;
bool
v3;
_BYTE *s;
struct
string *v5;
char
*v6;
char
*v7;
char
*v8;
struct
simulation_context *v9;
char
*p_load_code_dat_return_string;
unsigned
__int8
*p_userinput_sha256;
int
v12;
char
*v13;
_BYTE *v14;
struct
string *v15;
char
*v16;
unsigned
int
v17;
char
*p_inputstr_sha256;
char
*v19;
char
*v20;
int
v21;
void
*v22;
LRESULT
(__stdcall *sendmessagew)(
HWND
,
UINT
,
WPARAM
,
LPARAM
);
char
*v24;
HWND
hwnd;
char
*v26;
unsigned
__int64
v28;
int
v29;
unsigned
__int64
v30;
struct
string v31;
int
v32;
int
v33;
int
v34;
int
v35;
char
v36;
__int128 v37;
int
v38;
int
v39;
char
v40;
int
v41[18];
char
v42;
int
*v43;
void
(__cdecl *v44)();
int
(__cdecl *v45)(
int
,
int
);
char
*p_load_code_dat_return_string_;
int
size;
unsigned
__int8
*p_userinput_sha256_;
int
v49;
int
v50;
int
v51;
LPVOID
lpAddress;
struct
simulation_context *v53;
char
iftocheck;
void
*Block;
int
v56[39];
struct
string userinput_sha256;
struct
string inputstr_sha256;
struct
string load_code_dat_return_string;
WPARAM
wParam[2];
struct
string tmp;
int
v62;
v53 = lpThreadParameter;
if
( !lpThreadParameter )
return
0;
(*(
void
(__thiscall **)(
struct
simulation_context *))lpThreadParameter->vtbl)(lpThreadParameter);
memset
(&load_code_dat_return_string, 0, 20);
load_code_dat_return_string.capacity = 15;
LOBYTE(load_code_dat_return_string.s) = 0;
v62 = 0;
begin = lpThreadParameter->uuids.begin;
lpAddress = v53->uuids.end;
if
( begin != lpAddress )
{
while
( 1 )
{
v3 = begin->capacity < 0x10u;
s = begin;
iftocheck = 0;
if
( !v3 )
s = begin->s;
v5 = (
struct
string *)load_code_dat(&tmp, &iftocheck, s);
if
( &load_code_dat_return_string != v5 )
{
if
( load_code_dat_return_string.capacity >= 0x10u )
{
v6 = load_code_dat_return_string.s;
if
( (unsigned
int
)(load_code_dat_return_string.capacity + 1) >= 0x1000 )
{
v6 = (
char
*)*((_DWORD *)load_code_dat_return_string.s - 1);
if
( (unsigned
int
)(load_code_dat_return_string.s - v6 - 4) > 0x1F )
goto
LABEL_76;
}
free_(v6);
}
load_code_dat_return_string.size = 0;
load_code_dat_return_string.capacity = 15;
LOBYTE(load_code_dat_return_string.s) = 0;
load_code_dat_return_string = *v5;
v5->size = 0;
v5->capacity = 15;
LOBYTE(v5->s) = 0;
}
if
( tmp.capacity >= 0x10u )
{
v7 = tmp.s;
if
( (unsigned
int
)(tmp.capacity + 1) >= 4096 )
{
v7 = (
char
*)*((_DWORD *)tmp.s - 1);
if
( (unsigned
int
)(tmp.s - v7 - 4) > 31 )
goto
LABEL_76;
}
free_(v7);
}
if
( iftocheck )
break
;
if
( ++begin == lpAddress )
goto
LABEL_17;
}
if
( load_code_dat_return_string.size )
{
v9 = v53;
(*(
void
(__thiscall **)(
struct
simulation_context *,
struct
string *))(v53->vtbl + 4))(v53, &userinput_sha256);
LOBYTE(v62) = 1;
if
( !userinput_sha256.size )
{
SendMessageW((
HWND
)v53->hwnd, 1149u, 0, 0);
LABEL_68:
if
( userinput_sha256.capacity >= 0x10u )
{
v26 = userinput_sha256.s;
if
( (unsigned
int
)(userinput_sha256.capacity + 1) >= 0x1000 )
{
v26 = (
char
*)*((_DWORD *)userinput_sha256.s - 1);
if
( (unsigned
int
)(userinput_sha256.s - v26 - 4) > 0x1F )
goto
LABEL_75;
}
free_(v26);
}
userinput_sha256.size = 0;
userinput_sha256.capacity = 15;
LOBYTE(userinput_sha256.s) = 0;
goto
LABEL_18;
}
p_load_code_dat_return_string = (
char
*)&load_code_dat_return_string;
p_userinput_sha256 = (unsigned
__int8
*)&userinput_sha256;
if
( load_code_dat_return_string.capacity >= 0x10u )
p_load_code_dat_return_string = load_code_dat_return_string.s;
p_load_code_dat_return_string_ = p_load_code_dat_return_string;
if
( userinput_sha256.capacity >= 0x10u )
p_userinput_sha256 = (unsigned
__int8
*)userinput_sha256.s;
p_userinput_sha256_ = p_userinput_sha256;
size = load_code_dat_return_string.size;
iftocheck = 0;
if
( p_userinput_sha256 && p_load_code_dat_return_string && load_code_dat_return_string.size )
{
lpAddress = VirtualAlloc(0, (
SIZE_T
)&loc_A00000, 0x3000u, 0x40u);
if
( lpAddress )
{
Block = 0;
if
( uc_open(1, 0, &Block) )
{
sendmessagew = SendMessageW;
}
else
{
LODWORD(v28) = 17;
uc_ctl((
int
*)Block, 0x44000007u, v28, v30);
memset
(&inputstr_sha256, 0, 20);
inputstr_sha256.capacity = 15;
LOBYTE(inputstr_sha256.s) = 0;
v12 = 0;
v51 = 0;
while
( 1 )
{
memset
(v56, 0,
sizeof
(v56));
v50 = p_userinput_sha256[v12];
memset
(&v31, 0,
sizeof
(v31));
v32 = 0;
v33 = 0;
v37 = 0i64;
v34 = 0;
v35 = 0;
v36 = 0;
v38 = 0;
v39 = 15;
LOBYTE(v37) = 0;
LOBYTE(v62) = 5;
v40 = -1;
sub_412030(v41, v29);
v42 = 0;
LOBYTE(v62) = 7;
memset
(&tmp, 0,
sizeof
(tmp));
std_string_assign__(&tmp,
"%02x"
, 4u);
LOBYTE(v62) = 8;
sub_412190(&v31, &tmp);
LOBYTE(v62) = 7;
if
( tmp.capacity >= 0x10u )
{
v13 = tmp.s;
if
( (unsigned
int
)(tmp.capacity + 1) >= 0x1000 )
{
v13 = (
char
*)*((_DWORD *)tmp.s - 1);
if
( (unsigned
int
)(tmp.s - v13 - 4) > 0x1F )
goto
LABEL_76;
}
free_(v13);
}
tmp.size = 0;
tmp.capacity = 15;
LOBYTE(tmp.s) = 0;
LOBYTE(v62) = 9;
v43 = &v50;
v44 = nullsub_1;
v45 = sub_414C90;
v14 = sub_414130(&v31);
sub_410F70(v14);
LOBYTE(v62) = 11;
sub_40F4A0(&v31);
v15 = sub_4111C0(v56, &tmp);
LOBYTE(v62) = 12;
v16 = (
char
*)v15;
if
( v15->capacity >= 0x10u )
v16 = v15->s;
v17 = v15->size;
if
( v17 > inputstr_sha256.capacity - inputstr_sha256.size )
{
LOBYTE(v49) = 0;
sub_40A700((
void
**)&inputstr_sha256.s, v17, v49, v16, v17);
}
else
{
p_inputstr_sha256 = (
char
*)&inputstr_sha256;
if
( inputstr_sha256.capacity >= 0x10u )
p_inputstr_sha256 = inputstr_sha256.s;
v19 = &p_inputstr_sha256[inputstr_sha256.size];
inputstr_sha256.size += v17;
memmove
(v19, v16, v17);
v19[v17] = 0;
v12 = v51;
}
LOBYTE(v62) = 11;
if
( tmp.capacity >= 0x10u )
{
v20 = tmp.s;
if
( (unsigned
int
)(tmp.capacity + 1) >= 0x1000 )
{
v20 = (
char
*)*((_DWORD *)tmp.s - 1);
if
( (unsigned
int
)(tmp.s - v20 - 4) > 0x1F )
goto
LABEL_76;
}
free_(v20);
}
LOBYTE(v62) = 2;
sub_40F4A0(v56);
v51 = ++v12;
if
( v12 >= 32 )
break
;
p_userinput_sha256 = p_userinput_sha256_;
}
uc_mem_map((
int
)Block, 0, 0, 0xA00000, 7, (
int
)lpAddress);
v21 = size;
uc_mem_write((
int
)Block, 0x43000i64, (
int
)p_load_code_dat_return_string_, size);
v22 = &inputstr_sha256;
if
( inputstr_sha256.capacity >= 0x10u )
v22 = inputstr_sha256.s;
uc_mem_write((
int
)Block, 0x4033i64, (
int
)v22, inputstr_sha256.size);
if
( uc_emu_start(a1, v17, (
int
)Block, 0x43000, 0, v21 + 0x43000, 0, 0i64, 0) )
{
v9 = v53;
sendmessagew = SendMessageW;
}
else
{
*(_OWORD *)wParam = 0i64;
*(_OWORD *)&tmp.field_8 = 0i64;
uc_mem_read((
int
)Block, 0x14390u, 0, (
int
)wParam);
v9 = v53;
sendmessagew = SendMessageW;
iftocheck = 1;
SendMessageW((
HWND
)v53->hwnd, 1150u, (
WPARAM
)wParam, 0);
}
sub_44E300((
int
)Block, 0i64, (unsigned
int
)&loc_A00000);
sub_44D470((
char
*)Block);
if
( inputstr_sha256.capacity >= 0x10u )
{
v24 = inputstr_sha256.s;
if
( (unsigned
int
)(inputstr_sha256.capacity + 1) >= 0x1000 )
{
v24 = (
char
*)*((_DWORD *)inputstr_sha256.s - 1);
if
( (unsigned
int
)(inputstr_sha256.s - v24 - 4) > 0x1F )
LABEL_76:
_invalid_parameter_noinfo_noreturn();
}
free_(v24);
}
}
VirtualFree(lpAddress, 0, 0x8000u);
}
else
{
sendmessagew = SendMessageW;
}
hwnd = (
HWND
)v9->hwnd;
if
( iftocheck )
{
sendmessagew(hwnd, 1147u, 0, 0);
goto
LABEL_68;
}
}
else
{
hwnd = (
HWND
)v53->hwnd;
sendmessagew = SendMessageW;
}
sendmessagew(hwnd, 1149u, 0, 0);
goto
LABEL_68;
}
}
LABEL_17:
SendMessageW((
HWND
)v53->hwnd, 1149u, 0, 0);
LABEL_18:
if
( load_code_dat_return_string.capacity >= 0x10u )
{
v8 = load_code_dat_return_string.s;
if
( (unsigned
int
)(load_code_dat_return_string.capacity + 1) < 0x1000
|| (v8 = (
char
*)*((_DWORD *)load_code_dat_return_string.s - 1),
(unsigned
int
)(load_code_dat_return_string.s - v8 - 4) <= 0x1F) )
{
free_(v8);
return
0;
}
LABEL_75:
_invalid_parameter_noinfo_noreturn();
}
return
0;
}