//
// PlatformToolbox::getUniqueUserID from 0x14008b7f0 to 0x14008b9c7 (471 bytes)
//
// 4 xrefs:
// > GameManager::firstLoad @ 0x1402850fa
// > ??> @ 0x14088c228
// > ??> @ 0x14088c238
// > ??> @ 0x14091286c
//
// 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 11:25:59 +0000
//
__int64 __fastcall PlatformToolbox::getUniqueUserID(__int64 a1)
{
HANDLE CurrentThread; // rax
HANDLE CurrentProcess; // rax
int v4; // eax
cocos2d::CCString *v5; // rax
const char *CString; // rax
size_t v7; // r8
__int128 *v8; // rcx
__int64 v9; // r8
char *v10; // rbx
__int128 *v11; // rcx
__int64 v12; // rax
__int64 v13; // r8
__int128 *v14; // r10
__int128 *v15; // rcx
char *v16; // r10
char *v17; // r10
__int64 v18; // rdx
__int128 *v19; // rcx
__int64 v20; // rbx
__int128 v21; // xmm1
HANDLE TokenHandle[2]; // [rsp+20h] [rbp-48h] BYREF
__int128 v24; // [rsp+30h] [rbp-38h] BYREF
__int128 v25; // [rsp+40h] [rbp-28h]
TokenHandle[0] = nullptr;
CurrentThread = GetCurrentThread();
if ( OpenThreadToken(CurrentThread, 8u, 0, TokenHandle)
|| (CurrentProcess = GetCurrentProcess(), OpenProcessToken(CurrentProcess, 8u, TokenHandle)) )
{
sub_14008B620((__int64)&v24, TokenHandle[0]);
v8 = &v24;
LOBYTE(v9) = 45;
if ( *((_QWORD *)&v25 + 1) > 0xFu )
v8 = (__int128 *)v24;
v10 = (char *)v8 + v25;
v11 = &v24;
if ( *((_QWORD *)&v25 + 1) > 0xFu )
v11 = (__int128 *)v24;
v12 = sub_140677120(v11, v10, v9);
if ( (char *)v12 != v10 )
{
LOBYTE(v13) = 45;
v12 = sub_140677150(v12, v10, v13);
}
v14 = &v24;
v15 = &v24;
if ( *((_QWORD *)&v25 + 1) > 0xFu )
v14 = (__int128 *)v24;
v16 = (char *)v14 + v25;
if ( *((_QWORD *)&v25 + 1) > 0xFu )
v15 = (__int128 *)v24;
v17 = &v16[-v12];
v18 = v12 - (_QWORD)v15;
v19 = &v24;
if ( (__int64)v25 - v18 < (unsigned __int64)v17 )
v17 = (char *)(v25 - v18);
if ( *((_QWORD *)&v25 + 1) > 0xFu )
v19 = (__int128 *)v24;
v20 = v25 - (_QWORD)v17;
memmove((char *)v19 + v18, &v17[(_QWORD)v19 + v18], v25 - (_QWORD)v17 - v18 + 1);
*(_QWORD *)&v25 = v20;
CloseHandle(TokenHandle[0]);
v21 = v25;
*(_OWORD *)a1 = v24;
*(_OWORD *)(a1 + 16) = v21;
}
else
{
v4 = rand();
v5 = cocos2d::CCString::createWithFormat("NoUDID_%lld", (unsigned int)(v4 % 10000000));
CString = cocos2d::CCString::getCString(v5);
v7 = -1;
*(_OWORD *)a1 = 0;
*(_QWORD *)(a1 + 16) = 0;
*(_QWORD *)(a1 + 24) = 0;
do
++v7;
while ( CString[v7] );
sub_14003D230((_QWORD *)a1, CString, v7);
}
return a1;
}