//
// write_text_utf16le_nolock from 0x18013ffd4 to 0x1801400ed (281 bytes)
//
// 2 xrefs:
// > _write_nolock @ 0x180140532
// > ??> @ 0x180203bf0
//
// 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 write_text_utf16le_nolock(__int64 a1, int a2, __int16 *a3, unsigned int a4)
{
unsigned __int64 v5; // rbp
__int16 *v6; // rsi
void *v7; // r14
char *v8; // rbx
__int16 v9; // ax
DWORD v10; // ebx
DWORD v11; // eax
DWORD NumberOfBytesWritten; // [rsp+30h] [rbp-1438h] BYREF
_BYTE Buffer[5118]; // [rsp+40h] [rbp-1428h] BYREF
__int16 v15; // [rsp+143Eh] [rbp-2Ah] BYREF
v5 = (unsigned __int64)a3 + a4;
v6 = a3;
v7 = *(void **)(qword_1801F5160[(__int64)a2 >> 6] + 72LL * (a2 & 0x3F) + 40);
*(_QWORD *)a1 = 0;
*(_DWORD *)(a1 + 8) = 0;
if ( (unsigned __int64)a3 < v5 )
{
while ( 1 )
{
v8 = Buffer;
do
{
if ( (unsigned __int64)v6 >= v5 )
break;
v9 = *v6++;
if ( v9 == 10 )
{
*(_DWORD *)(a1 + 8) += 2;
*(_WORD *)v8 = 13;
v8 += 2;
}
*(_WORD *)v8 = v9;
v8 += 2;
}
while ( v8 < (char *)&v15 );
v10 = 2 * ((v8 - Buffer) >> 1);
if ( !WriteFile(v7, Buffer, v10, &NumberOfBytesWritten, nullptr) )
break;
v11 = NumberOfBytesWritten;
*(_DWORD *)(a1 + 4) += NumberOfBytesWritten;
if ( v11 < v10 || (unsigned __int64)v6 >= v5 )
return a1;
}
*(_DWORD *)a1 = GetLastError();
}
return a1;
}