//
// common_getdcwd from 0x18013becc to 0x18013c033 (359 bytes)
//
// 2 xrefs:
// > sub_18013C0B4 @ 0x18013c0d1
// > ??> @ 0x18020398c
//
// 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:02 +0000
//
_WORD *__fastcall common_getdcwd(int a1, _WORD *a2, int a3)
{
__int64 v3; // rsi
int v5; // ebx
__int64 v7; // rbx
_WORD *v8; // [rsp+20h] [rbp-40h] BYREF
__int64 v9; // [rsp+28h] [rbp-38h]
void *Block; // [rsp+30h] [rbp-30h]
__int64 v11; // [rsp+38h] [rbp-28h]
__int64 v12; // [rsp+40h] [rbp-20h]
char v13; // [rsp+48h] [rbp-18h]
__int64 FileName; // [rsp+50h] [rbp-10h] BYREF
v3 = a3;
v5 = a1;
if ( a3 < 0 )
goto LABEL_2;
if ( a1 )
{
if ( !(unsigned int)validdrive() )
{
*_doserrno() = 15;
*errno() = 13;
goto LABEL_3;
}
}
else
{
v5 = getdrive();
}
if ( v5 )
{
wcscpy((wchar_t *)&FileName + 1, L":.");
LOWORD(FileName) = v5 + 64;
}
else
{
wcscpy((wchar_t *)&FileName, L".");
}
if ( a2 )
{
if ( (int)v3 <= 0 )
{
LABEL_2:
*errno() = 22;
LABEL_3:
invalid_parameter_noinfo();
return nullptr;
}
*a2 = 0;
v9 = v3;
v11 = v3;
v8 = a2;
Block = a2;
v12 = 0;
v13 = 0;
if ( (unsigned int)unknown_libname_66((const WCHAR *)&FileName, (__int64)&v8) )
return nullptr;
return a2;
}
else
{
v8 = nullptr;
v9 = 0;
v12 = 0;
Block = j__malloc_base(2 * v3);
if ( Block )
{
v13 = 1;
v11 = v3;
}
else
{
v13 = 0;
v11 = 0;
}
if ( (unsigned int)__acrt_get_full_path_name_wide<__crt_win32_buffer_public_dynamic_resizing>(
(LPCWSTR)&FileName,
(__int64)&v8) )
{
if ( v13 )
free(Block);
return nullptr;
}
v7 = __crt_win32_buffer::detach((__int64 *)&v8);
if ( v13 )
free(Block);
return (_WORD *)v7;
}
}