//
// sub_140078340 from 0x140078340 to 0x140078506 (454 bytes)
//
// 2 xrefs:
// > PlatformToolbox::getUniqueUserID @ 0x1400785eb
// > ??> @ 0x1406c666c
//
// 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
//
// Hidden C++ exception states: #wind=1
__int64 __fastcall sub_140078340(__int64 a1, void *a2)
{
size_t v4; // r8
const char *v5; // rdx
PSID *v6; // rdi
size_t v7; // r8
int v8; // eax
cocos2d::CCString *v9; // rax
const char *CString; // rax
DWORD TokenInformationLength; // [rsp+30h] [rbp-58h] BYREF
LPSTR StringSid; // [rsp+38h] [rbp-50h] BYREF
__int128 Src; // [rsp+48h] [rbp-40h] BYREF
__m128i si128; // [rsp+58h] [rbp-30h]
StringSid = (LPSTR)a1;
TokenInformationLength = 0;
if ( !GetTokenInformation(a2, TokenUser, nullptr, 0, &TokenInformationLength) && GetLastError() != 122 )
{
*(_OWORD *)a1 = 0;
*(_QWORD *)(a1 + 16) = 0;
*(_QWORD *)(a1 + 24) = 0;
v4 = -1;
do
++v4;
while ( *(_BYTE *)v4 );
v5 = nullptr;
LABEL_16:
sub_14003A930((_QWORD *)a1, v5, v4);
return a1;
}
v6 = (PSID *)LocalAlloc(0x40u, TokenInformationLength);
if ( !v6 )
{
LABEL_13:
v8 = rand();
v9 = cocos2d::CCString::createWithFormat("NoUDID_%lld", (unsigned int)(v8 % 10000000));
CString = cocos2d::CCString::getCString(v9);
*(_OWORD *)a1 = 0;
*(_QWORD *)(a1 + 16) = 0;
*(_QWORD *)(a1 + 24) = 0;
v4 = -1;
do
++v4;
while ( CString[v4] );
v5 = CString;
goto LABEL_16;
}
StringSid = nullptr;
if ( !GetTokenInformation(a2, TokenUser, v6, TokenInformationLength, &TokenInformationLength)
|| !ConvertSidToStringSidA(*v6, &StringSid) )
{
LocalFree(v6);
goto LABEL_13;
}
Src = 0;
si128 = _mm_load_si128((const __m128i *)&xmmword_140623F30);
LOBYTE(Src) = 0;
v7 = -1;
do
++v7;
while ( StringSid[v7] );
sub_140041270(&Src, StringSid, v7);
LocalFree(StringSid);
LocalFree(v6);
*(_OWORD *)a1 = Src;
*(__m128i *)(a1 + 16) = si128;
return a1;
}