//
// _write from 0x180140260 to 0x18014034b (235 bytes)
//
// 7 xrefs:
// > __acrt_stdio_flush_nolock @ 0x1801389d2
// > write_buffer_nolock @ 0x18013f4f9
// > write_buffer_nolock @ 0x18013f571
// > write_buffer_nolock @ 0x18013f5df
// > write_buffer_nolock @ 0x18013f659
// > ??> @ 0x180203bfc
// > ??> @ 0x180203c08
//
// 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:04 +0000
//
int __cdecl write(int FileHandle, const void *Buf, unsigned int MaxCharCount)
{
__int64 v6; // rsi
int v7; // edi
if ( FileHandle == -2 )
{
*_doserrno() = 0;
*errno() = 9;
return -1;
}
if ( FileHandle < 0
|| FileHandle >= (unsigned int)dword_1801F5560
|| (v6 = (__int64)FileHandle >> 6, (*(_BYTE *)(qword_1801F5160[v6] + 72LL * (FileHandle & 0x3F) + 56) & 1) == 0) )
{
*_doserrno() = 0;
*errno() = 9;
invalid_parameter_noinfo();
return -1;
}
sub_180136164(FileHandle);
v7 = -1;
if ( (*(_BYTE *)(qword_1801F5160[v6] + 72LL * (FileHandle & 0x3F) + 56) & 1) != 0 )
{
v7 = write_nolock((unsigned int)FileHandle, Buf, MaxCharCount);
}
else
{
*errno() = 9;
*_doserrno() = 0;
}
sub_18013618C(FileHandle);
return v7;
}