//
// cocos2d::CCImage::initWithString from 0x18007cdd0 to 0x18007d0a5 (725 bytes)
//
// 7 xrefs:
// > cocos2d::CCTexture2D::initWithString @ 0x1800a5bcc
// > cocos2d::CCTexture2D::initWithString @ 0x1800a5d3e
// > ??> @ 0x18013bf50
// > ??> @ 0x18013bf60
// > ??> @ 0x18013bf78
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b4e60
//
// 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
//
char __fastcall cocos2d::CCImage::initWithString(
__int64 a1,
const CHAR *a2,
LONG a3,
int a4,
int a5,
char *a6,
unsigned int a7)
{
unsigned __int16 v11; // bx
__int16 v12; // si
void *v13; // rax
bool v14; // sf
int v15; // ecx
void *lpvBits; // rax
int v17; // r9d
int v18; // r8d
unsigned __int8 *v19; // rax
int v20; // ecx
HGDIOBJ StockObject; // rax
HDC DC; // rbx
LONG v24; // [rsp+40h] [rbp-88h] BYREF
int v25; // [rsp+44h] [rbp-84h]
_BYTE bmi[52]; // [rsp+48h] [rbp-80h] BYREF
int v27; // [rsp+7Ch] [rbp-4Ch]
if ( !a2 )
return 0;
if ( dword_1801A87A0 > *(_DWORD *)(*((_QWORD *)NtCurrentTeb()->ThreadLocalStoragePointer + (unsigned int)TlsIndex)
+ 4LL) )
{
Init_thread_header(&dword_1801A87A0);
if ( dword_1801A87A0 == -1 )
{
*(_OWORD *)&hdc = 0;
StockObject = GetStockObject(17);
*(_OWORD *)&xmmword_1801A8780 = 0;
LOBYTE(xmmword_1801A8780) = 0;
ho = StockObject;
xmmword_1801A8790 = (__int128)_mm_load_si128((const __m128i *)&xmmword_1800E7160);
qword_1801A8778 = nullptr;
DC = GetDC(nullptr);
hdc = CreateCompatibleDC(DC);
ReleaseDC(nullptr, DC);
atexit(sub_1800E3BA0);
Init_thread_footer(&dword_1801A87A0);
}
}
if ( !(unsigned __int8)sub_18007D8A0(&hdc, a6, a7) )
cocos2d::CCLog((cocos2d *)"Can't found font(%s), use system default", a6);
v24 = a3;
v25 = a4;
if ( !(unsigned int)sub_18007C6D0((__int64)&hdc, a2, &v24, a5) )
return 0;
v11 = v25;
v12 = v24;
v13 = operator new(4 * v24 * v25);
*(_QWORD *)(a1 + 64) = v13;
if ( !v13 )
return 0;
v27 = 0;
memset(&bmi[4], 0, 48);
*(_DWORD *)bmi = 40;
if ( !GetDIBits(hdc, (HBITMAP)*(&hdc + 1), 0, 0, nullptr, (LPBITMAPINFO)bmi, 0) )
return 0;
v14 = -*(_DWORD *)&bmi[8] < 0;
v15 = -*(_DWORD *)&bmi[8];
*(_WORD *)(a1 + 56) = v12;
*(_WORD *)(a1 + 58) = v11;
if ( v14 )
v15 = *(_DWORD *)&bmi[8];
*(_WORD *)(a1 + 72) = 1;
*(_DWORD *)(a1 + 60) = 8;
lpvBits = *(void **)(a1 + 64);
*(_DWORD *)&bmi[8] = -v15;
GetDIBits(hdc, (HBITMAP)*(&hdc + 1), 0, v11, lpvBits, (LPBITMAPINFO)bmi, 0);
v17 = 0;
if ( *(_WORD *)(a1 + 58) )
{
do
{
v18 = 0;
v19 = (unsigned __int8 *)(*(_QWORD *)(a1 + 64) + 4LL * v17 * *(unsigned __int16 *)(a1 + 56));
if ( *(_WORD *)(a1 + 56) )
{
do
{
v20 = *v19;
v19 += 4;
++v18;
*((_DWORD *)v19 - 1) |= (v20 << 24) | 0xFFFFFF;
}
while ( v18 < *(unsigned __int16 *)(a1 + 56) );
}
++v17;
}
while ( v17 < *(unsigned __int16 *)(a1 + 58) );
}
return 1;
}