//
// _close_nolock from 0x180138c1c to 0x180138cd9 (189 bytes)
//
// 2 xrefs:
// > __crt_seh_guarded_call::operator @ 0x180138b4a
// > ??> @ 0x180203710
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 10:55:01 +0000
//
__int64 __fastcall close_nolock(int a1)
{
__int64 v1; // rdi
DWORD LastError; // ebx
intptr_t osfhandle; // rbx
void *v4; // rax
v1 = a1;
if ( get_osfhandle(a1) == -1
|| ((_DWORD)v1 == 1 && (*(_BYTE *)(qword_1801F5160[0] + 200) & 1) != 0
|| (_DWORD)v1 == 2 && (*(_BYTE *)(qword_1801F5160[0] + 128) & 1) != 0)
&& (osfhandle = get_osfhandle(2), get_osfhandle(1) == osfhandle)
|| (v4 = (void *)get_osfhandle(v1), CloseHandle(v4)) )
{
LastError = 0;
}
else
{
LastError = GetLastError();
}
free_osfhnd(v1);
*(_BYTE *)(qword_1801F5160[v1 >> 6] + 72 * (v1 & 0x3F) + 56) = 0;
if ( !LastError )
return 0;
_acrt_errno_map_os_error(LastError);
return 0xFFFFFFFFLL;
}