//
// wcsncpy_s from 0x18013d648 to 0x18013d72c (228 bytes)
//
// 4 xrefs:
// > tzset_env_copy_to_tzname @ 0x18013cc6b
// > tzset_os_copy_to_tzname @ 0x18013d27b
// > ??> @ 0x180203ac4
// > ??> @ 0x180203ad0
//
// 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:03 +0000
//
errno_t __cdecl wcsncpy_s(wchar_t *Destination, rsize_t SizeInWords, const wchar_t *Source, rsize_t MaxCount)
{
errno_t v4; // r10d
int *v6; // rax
errno_t v7; // ebx
signed __int64 v9; // rbx
wchar_t *v10; // rdx
rsize_t v11; // r8
rsize_t v12; // rdi
wchar_t v13; // ax
wchar_t v14; // ax
v4 = 0;
if ( MaxCount )
{
if ( !Destination )
goto LABEL_4;
goto LABEL_8;
}
if ( Destination )
{
LABEL_8:
if ( !SizeInWords )
goto LABEL_4;
if ( !MaxCount )
{
*Destination = 0;
return v4;
}
if ( !Source )
{
*Destination = 0;
goto LABEL_4;
}
v9 = (char *)Source - (char *)Destination;
v10 = Destination;
v11 = SizeInWords;
v12 = MaxCount;
if ( MaxCount == -1 )
{
do
{
v13 = *(wchar_t *)((char *)v10 + v9);
*v10++ = v13;
if ( !v13 )
break;
--v11;
}
while ( v11 );
}
else
{
do
{
v14 = *(wchar_t *)((char *)v10 + v9);
*v10++ = v14;
if ( !v14 )
break;
if ( !--v11 )
break;
--v12;
}
while ( v12 );
if ( !v12 )
*v10 = 0;
}
if ( !v11 )
{
if ( MaxCount == -1 )
{
Destination[SizeInWords - 1] = 0;
return 80;
}
*Destination = 0;
v6 = errno();
v7 = 34;
goto LABEL_5;
}
return v4;
}
if ( SizeInWords )
{
LABEL_4:
v6 = errno();
v7 = 22;
LABEL_5:
*v6 = v7;
invalid_parameter_noinfo();
return v7;
}
return v4;
}