//
// common_assert_to_message_box_build_string
from 0x180130ed4 to 0x1801313d8 (1284 bytes)
//
// 3 xrefs:
// > common_assert_to_message_box @ 0x180130e68
// > ??> @ 0x180202eac
// > ??> @ 0x180202eb8
//
// 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:58 +0000
//
errno_t __fastcall common_assert_to_message_box_build_string(
wchar_t *Destination,
rsize_t SizeInWords,
wchar_t *Source,
wchar_t *a4,
int Value,
LPCWSTR lpModuleName)
{
BOOL ModuleHandle; // eax
__int64 v11; // rbp
WCHAR *v12; // rcx
__int64 v13; // rdx
__int64 v14; // rax
size_t v15; // rsi
__int64 v16; // rax
unsigned __int64 v17; // rsi
wchar_t v18; // ax
unsigned __int64 v19; // r14
wchar_t *v20; // rcx
unsigned __int64 v21; // r12
bool v22; // cf
const wchar_t *v23; // r8
unsigned __int64 v24; // r14
errno_t v25; // eax
__int64 v26; // rax
__int64 v27; // rcx
__int64 v28; // rax
__int64 v29; // rax
const wchar_t *v30; // r8
rsize_t v31; // rdx
wchar_t *v32; // rcx
errno_t result; // eax
HMODULE phModule; // [rsp+30h] [rbp-278h] BYREF
wchar_t Filename[264]; // [rsp+40h] [rbp-268h] BYREF
if ( wcscpy_s(Destination, SizeInWords, L"Assertion failed!") )
goto LABEL_66;
if ( wcscat_s(Destination, SizeInWords, L"\n\n") )
goto LABEL_66;
if ( wcscat_s(Destination, SizeInWords, L"Program: ") )
goto LABEL_66;
memset(Filename, 0, 0x20Au);
phModule = nullptr;
ModuleHandle = GetModuleHandleExW(6u, lpModuleName, &phModule);
phModule = (HMODULE)((unsigned __int64)phModule & -(__int64)ModuleHandle);
if ( !GetModuleFileNameW(phModule, Filename, 0x105u) )
{
if ( wcscpy_s(Filename, 0x105u, L"") )
goto LABEL_66;
}
v11 = -1;
v12 = Filename;
v13 = -1;
do
++v13;
while ( Filename[v13] );
if ( (unsigned __int64)(v13 + 11) > 0x40 )
{
v14 = 2 * v13 - 106;
v15 = 522 - v14;
v12 = (wchar_t *)((char *)Filename + v14);
if ( !(wchar_t *)((char *)Filename + v14) )
{
*errno() = 22;
goto LABEL_68;
}
if ( v15 < 6 )
{
memset(v12, 0, v15);
*errno() = 34;
LABEL_68:
invalid_parameter_noinfo();
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
*(_DWORD *)v12 = *(_DWORD *)asc_180172F20;
v12[2] = 46;
}
if ( wcscat_s(Destination, SizeInWords, v12)
|| wcscat_s(Destination, SizeInWords, asc_180172F28)
|| wcscat_s(Destination, SizeInWords, L"File: ") )
{
goto LABEL_66;
}
v16 = -1;
do
++v16;
while ( a4[v16] );
if ( (unsigned __int64)(v16 + 8) <= 0x40 )
{
v23 = a4;
LABEL_65:
v25 = wcscat_s(Destination, SizeInWords, v23);
goto LABEL_36;
}
v17 = -1;
do
++v17;
while ( a4[v17] );
v18 = a4[v17 - 1];
v19 = 1;
if ( v18 != 92 )
{
v20 = &a4[v17 - 1];
do
{
if ( v18 == 47 )
break;
if ( v19 >= v17 )
break;
--v20;
++v19;
v18 = *v20;
}
while ( *v20 != 92 );
}
v21 = v17 - v19;
v22 = v17 - v19 < 0x26;
if ( v17 - v19 > 0x26 )
{
if ( v19 < 0x12 )
{
if ( wcsncat_s(Destination, SizeInWords, a4, 53 - v19) || wcscat_s(Destination, SizeInWords, asc_180172F20) )
goto LABEL_66;
v23 = &a4[v21];
goto LABEL_65;
}
v22 = v21 < 0x26;
}
if ( !v22 )
{
if ( wcsncat_s(Destination, SizeInWords, a4, 0x23u)
|| wcscat_s(Destination, SizeInWords, asc_180172F20)
|| wcsncat_s(Destination, SizeInWords, &a4[v21], 8u)
|| wcscat_s(Destination, SizeInWords, asc_180172F20) )
{
goto LABEL_66;
}
v23 = &a4[v17 - 7];
goto LABEL_65;
}
v24 = v19 >> 1;
if ( wcsncat_s(Destination, SizeInWords, a4, 53 - v24) || wcscat_s(Destination, SizeInWords, asc_180172F20) )
goto LABEL_66;
v25 = wcscat_s(Destination, SizeInWords, &a4[v17 - v24]);
LABEL_36:
if ( v25 )
goto LABEL_66;
if ( wcscat_s(Destination, SizeInWords, asc_180172F28) )
goto LABEL_66;
if ( wcscat_s(Destination, SizeInWords, L"Line: ") )
goto LABEL_66;
v26 = -1;
do
++v26;
while ( Destination[v26] );
v27 = -1;
do
++v27;
while ( Destination[v27] );
if ( itow_s(Value, &Destination[v27], SizeInWords - v26, 10)
|| wcscat_s(Destination, SizeInWords, L"\n\n")
|| wcscat_s(Destination, SizeInWords, L"Expression: ") )
{
goto LABEL_66;
}
v28 = -1;
do
++v28;
while ( Destination[v28] );
v29 = v28 + 176;
do
++v11;
while ( Source[v11] );
v30 = Source;
v31 = SizeInWords;
v32 = Destination;
if ( v29 + v11 > SizeInWords )
{
if ( wcsncat_s(Destination, SizeInWords, Source, SizeInWords - v29 - 3) )
goto LABEL_66;
v30 = asc_180172F20;
v31 = SizeInWords;
v32 = Destination;
}
if ( wcscat_s(v32, v31, v30)
|| wcscat_s(Destination, SizeInWords, L"\n\n")
|| wcscat_s(
Destination,
SizeInWords,
L"For information on how your program can cause an assertion\n"
"failure, see the Visual C++ documentation on asserts")
|| wcscat_s(Destination, SizeInWords, L"\n\n")
|| (result = wcscat_s(Destination, SizeInWords, L"(Press Retry to debug the application - JIT must be enabled)")) != 0 )
{
LABEL_66:
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
return result;
}