//
// common_stat<_stat64i32> from 0x1801290c8 to 0x180129212 (330 bytes)
//
// 3 xrefs:
// > _stat64i32 @ 0x180129871
// > _stat64i32 @ 0x180129928
// > ??> @ 0x180202a68
//
// 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 common_stat<_stat64i32>(wchar_t *a1, __int64 a2)
{
unsigned int v2; // esi
HANDLE FileW; // rbx
int v7; // eax
__int64 v8; // rax
int v9; // [rsp+68h] [rbp+10h] BYREF
v2 = 0;
if ( !a2 || (*(_OWORD *)a2 = 0, *(_OWORD *)(a2 + 16) = 0, *(_OWORD *)(a2 + 32) = 0, !a1) )
{
*_doserrno() = 0;
*errno() = 22;
invalid_parameter_noinfo();
return 0xFFFFFFFFLL;
}
FileW = CreateFileW(a1, 0x80u, 7u, nullptr, 3u, 0x2000000u, nullptr);
if ( FileW == (HANDLE)-1LL )
{
if ( is_usable_drive_or_unc_root(a1) )
{
*(_WORD *)(a2 + 6) = convert_to_stat_mode(16, a1);
*(_WORD *)(a2 + 8) = 1;
v9 = 0;
if ( get_drive_number_from_path(a1, &v9) )
{
v7 = v9 - 1;
*(_DWORD *)(a2 + 16) = v9 - 1;
*(_DWORD *)a2 = v7;
v8 = common_loctotime_t<__int64>(1980, 1, 1, 0, 0, 0, -1);
*(_QWORD *)(a2 + 32) = v8;
*(_QWORD *)(a2 + 24) = v8;
*(_QWORD *)(a2 + 40) = v8;
goto LABEL_7;
}
}
else
{
_acrt_errno_map_os_error(2);
}
goto LABEL_6;
}
if ( !(unsigned __int8)common_stat_handle_file_opened<_stat64i32>(a1) )
{
LABEL_6:
v2 = -1;
*(_OWORD *)a2 = 0;
*(_OWORD *)(a2 + 16) = 0;
*(_OWORD *)(a2 + 32) = 0;
}
LABEL_7:
if ( FileW != (HANDLE)-1LL )
CloseHandle(FileW);
return v2;
}