//
// wcsncat_s from 0x180139118 to 0x180139215 (253 bytes)
//
// 6 xrefs:
// > common_assert_to_message_box_build_string @ 0x1801310f7
// > common_assert_to_message_box_build_string @ 0x180131149
// > common_assert_to_message_box_build_string @ 0x18013126c
// > common_assert_to_message_box_build_string @ 0x180131325
// > common_assert_to_message_box_build_string @ 0x180131355
// > ??> @ 0x180203794
//
// 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
//
errno_t __cdecl wcsncat_s(wchar_t *Destination, rsize_t SizeInWords, const wchar_t *Source, rsize_t MaxCount)
{
errno_t v4; // r10d
rsize_t v5; // rbx
wchar_t *v6; // r11
int *v7; // rax
errno_t v8; // ebx
rsize_t v10; // rdi
signed __int64 v11; // r8
wchar_t v12; // ax
wchar_t v13; // ax
v4 = 0;
v5 = SizeInWords;
v6 = Destination;
if ( MaxCount )
{
if ( !Destination )
goto LABEL_4;
goto LABEL_8;
}
if ( Destination )
{
LABEL_8:
if ( !SizeInWords )
goto LABEL_4;
if ( MaxCount && !Source )
{
*Destination = 0;
goto LABEL_4;
}
v10 = MaxCount;
do
{
if ( !*Destination )
break;
++Destination;
--SizeInWords;
}
while ( SizeInWords );
if ( !SizeInWords )
{
*v6 = 0;
goto LABEL_4;
}
if ( MaxCount == -1 )
{
v11 = (char *)Source - (char *)Destination;
do
{
v12 = *(wchar_t *)((char *)Destination + v11);
*Destination++ = v12;
if ( !v12 )
break;
--SizeInWords;
}
while ( SizeInWords );
}
else
{
if ( MaxCount )
{
do
{
v13 = *Source++;
*Destination++ = v13;
if ( !v13 )
break;
if ( !--SizeInWords )
break;
--v10;
}
while ( v10 );
}
if ( !v10 )
*Destination = 0;
}
if ( !SizeInWords )
{
if ( MaxCount == -1 )
{
v6[v5 - 1] = 0;
return 80;
}
*v6 = 0;
v7 = errno();
v8 = 34;
goto LABEL_5;
}
return v4;
}
if ( SizeInWords )
{
LABEL_4:
v7 = errno();
v8 = 22;
LABEL_5:
*v7 = v8;
invalid_parameter_noinfo();
return v8;
}
return v4;
}