//
// strncpy_s from 0x180140630 to 0x180140703 (211 bytes)
//
// 4 xrefs:
// > common_expand_argv_wildcards @ 0x180139ba4
// > copy_and_add_argument_to_buffer @ 0x180139cd9
// > copy_and_add_argument_to_buffer @ 0x180139cf6
// > ??> @ 0x180203c20
//
// 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
//
errno_t __cdecl strncpy_s(char *Destination, rsize_t SizeInBytes, const char *Source, rsize_t MaxCount)
{
errno_t v4; // r10d
int *v6; // rax
errno_t v7; // ebx
signed __int64 v9; // rbx
char *v10; // rdx
rsize_t v11; // r8
rsize_t v12; // rdi
char v13; // al
char v14; // al
v4 = 0;
if ( MaxCount )
{
if ( !Destination )
goto LABEL_4;
goto LABEL_8;
}
if ( Destination )
{
LABEL_8:
if ( !SizeInBytes )
goto LABEL_4;
if ( !MaxCount )
{
*Destination = 0;
return v4;
}
if ( !Source )
{
*Destination = 0;
goto LABEL_4;
}
v9 = Source - Destination;
v10 = Destination;
v11 = SizeInBytes;
v12 = MaxCount;
if ( MaxCount == -1 )
{
do
{
v13 = v10[v9];
*v10++ = v13;
if ( !v13 )
break;
--v11;
}
while ( v11 );
}
else
{
do
{
v14 = v10[v9];
*v10++ = v14;
if ( !v14 )
break;
if ( !--v11 )
break;
--v12;
}
while ( v12 );
if ( !v12 )
*v10 = 0;
}
if ( !v11 )
{
if ( MaxCount == -1 )
{
Destination[SizeInBytes - 1] = 0;
return 80;
}
*Destination = 0;
v6 = errno();
v7 = 34;
goto LABEL_5;
}
return v4;
}
if ( SizeInBytes )
{
LABEL_4:
v6 = errno();
v7 = 22;
LABEL_5:
*v6 = v7;
invalid_parameter_noinfo();
return v7;
}
return v4;
}