//
// common_getenv_s from 0x180128e48 to 0x180128f3f (247 bytes)
//
// 3 xrefs:
// > common_getenv_s @ 0x180128f40
// > ??> @ 0x180202a44
// > ??> @ 0x180202a50
//
// 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:54:56 +0000
//
__int64 __fastcall common_getenv_s(rsize_t *a1, wchar_t *a2, rsize_t a3, wchar_t *a4)
{
unsigned int v8; // ebx
int v9; // eax
const wchar_t *v10; // r8
__int64 v11; // rax
rsize_t v12; // rax
sub_1801346AC(11);
v8 = 0;
if ( !a1 )
goto LABEL_2;
*a1 = 0;
if ( a2 )
{
if ( !a3 )
goto LABEL_8;
LABEL_7:
v9 = 1;
goto LABEL_9;
}
if ( !a3 )
goto LABEL_7;
LABEL_8:
v9 = 0;
LABEL_9:
if ( !v9 )
{
LABEL_2:
v8 = 22;
*errno() = 22;
invalid_parameter_noinfo();
goto LABEL_19;
}
if ( a2 )
*a2 = 0;
v10 = common_getenv_nolock(a4);
if ( v10 )
{
v11 = -1;
do
++v11;
while ( v10[v11] );
v12 = v11 + 1;
*a1 = v12;
if ( a3 )
{
if ( v12 <= a3 )
{
if ( wcscpy_s(a2, a3, v10) )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
else
{
v8 = 34;
}
}
}
LABEL_19:
sub_180134700(11);
return v8;
}