#include <windows.h>
#include <defs.h>
//-------------------------------------------------------------------------
// Function declarations
#define __thiscall __cdecl // Test compile in C mode
int __cdecl sub_401000(int a1, int a2, int a3);
int __cdecl sub_401050(int a1, int a2, int a3, int a4);
char __cdecl sub_4010F0(int a1, unsigned int a2);
char __cdecl sub_401120(int a1, unsigned int a2);
void __cdecl sub_401150(int a1, int a2);
char __cdecl sub_4013D0(char *a1, char a2);
int __cdecl sub_401B00(int a1);
char __cdecl sub_401B50(char *a1, char a2);
char *__cdecl sub_401ED0(void *a1, int a2, void *a3);
void __cdecl sub_401F00(FILE *a1, int a2, int a3, int a4, int a5, size_t a6, time_t a7);
int __cdecl sub_402520(FILE *, int, int, int, int); // idb
void __cdecl sub_4027E0(int a1);
int __cdecl main(int argc, const char **argv, const char **envp);
void __thiscall sub_402C90(int this);
int __thiscall sub_402CD0(void *this, int a2);
int __thiscall sub_402D50(int this, int a2, unsigned int a3, unsigned int a4);
void *__cdecl sub_402EF0(unsigned int a1);
int __thiscall sub_402F00(void *this);
int __thiscall sub_402F10(int this, const char **a2);
int sub_402F50(void); // weak
int __thiscall sub_402F60(int this, const char **a2);
LPVOID __thiscall sub_402FA0(LPVOID lpMem, char a2);
int __thiscall sub_4030C0(int this, void *a2);
int __thiscall sub_403100(int this, const void *a2, int a3);
int __stdcall sub_4031A0(int a1, int a2, const void *a3);
void *__thiscall sub_4031D0(void *this, int a2);
int __thiscall nullsub_1(_DWORD); // weak
void __thiscall sub_403240(int this);
void *__stdcall sub_403270(const void *a1);
void __stdcall sub_4032C0(LPVOID lpMem, int a2);
int __thiscall sub_4032F0(int this, void *a2, int a3);
int __thiscall sub_403420(int this, int a2, unsigned int a3, int a4);
int __thiscall sub_403480(void *this, int a2, unsigned int a3, int a4);
int __cdecl sub_403510(int a1, int a2, const char *a3);
void __cdecl sub_403650(LPVOID lpMem, int a2);
int __cdecl sub_403680(int a1, int a2, int a3);
int __cdecl sub_4037C0(signed int a1);
int __cdecl sub_403980(int a1, int a2);
int __stdcall sub_4039A0(int a1);
int __thiscall sub_4039C0(void *this, int a2);
int __thiscall sub_4039D0(int this, int a2);
// _DWORD __stdcall unknown_libname_1(_DWORD); weak
void *__thiscall sub_4039F0(void *this, int a2, int a3);
int __thiscall sub_403A00(void *this, signed int a2);
void __cdecl __noreturn sub_403A60(void *a1);
char *__thiscall sub_403B40(void *this, void *a2, int a3);
int __cdecl sub_403BC0(int a1, int a2, int a3, int a4, int a5);
BOOL __cdecl sub_403C10(int a1, const char *a2);
int __thiscall sub_403C50(void *this, int a2, int a3, int a4);
int __thiscall sub_403CC0(int this, int a2, int a3, int a4);
int __thiscall sub_403CF0(int this, void *a2, int a3, int a4);
int __cdecl sub_403D20(int a1);
int __cdecl sub_403EC0(int a1);
char *__thiscall sub_403ED0(void *this, void *a2, int a3, int a4);
int __thiscall sub_403F50(int this, int a2, int a3, int a4);
int __thiscall sub_4040F0(int this, void *a2, int a3, int a4);
int __cdecl sub_404280(unsigned int a1, int a2);
int __thiscall sub_4043B0(void *this, int a2, int a3, int a4);
int __cdecl sub_404430(int a1, int a2, int a3);
int sub_404460();
int __cdecl sub_404470(int a1, int a2, int a3);
signed int __cdecl sub_4044A0(int a1, int *a2, int a3, int *a4);
int __cdecl sub_404570(int a1, int a2);
signed int __cdecl sub_4045E0(int a1);
signed int __cdecl sub_4046D0(int a1);
int __cdecl sub_4047A0(int a1, int a2, int a3);
signed int __cdecl sub_404880(int a1, int a2, int a3);
signed int __cdecl sub_4049C0(int a1, int a2);
signed int __cdecl sub_404AC0(int a1);
// int printf(const char *, ...);
// int __cdecl fclose(FILE *);
void __cdecl sub_4051BC(LPVOID lpMem);
// void *__cdecl malloc(size_t);
LPVOID __cdecl sub_405263(unsigned int a1);
// size_t __cdecl fwrite(const void *, size_t, size_t, FILE *);
// int __cdecl feof(FILE *);
// size_t __cdecl fread(void *, size_t, size_t, FILE *);
// FILE *__cdecl fopen(const char *, const char *);
// __int32 __cdecl ftell(FILE *);
void __cdecl sub_40565F(LPVOID lpMem);
// void *__cdecl memcpy(void *, const void *, size_t);
// struct tm *__cdecl localtime(const time_t *);
// __int32 __cdecl _findfirst(const char *, struct _finddata_t *);
// int __cdecl _findnext(__int32, struct _finddata_t *);
// int sprintf(char *, const char *, ...);
int __thiscall sub_405D4A(int this);
LPVOID __thiscall sub_405D5B(LPVOID lpMem, char a2);
void __thiscall sub_405DC1(int this);
// _DWORD __stdcall _CxxThrowException(_DWORD, _DWORD); weak
// void *__cdecl operator new(unsigned int); idb
// char *__cdecl strncpy(char *, const char *, size_t);
// _DWORD __cdecl _setjmp3(_DWORD, _DWORD);
// void __cdecl __noreturn longjmp(jmp_buf, int);
void __noreturn sub_4073FC();
int sub_40761D();
// _DWORD __cdecl flsall(_DWORD); weak
char __cdecl sub_407693(int a1);
__int32 sub_4076C0();
signed int __cdecl sub_407808(int a1);
// _DWORD __cdecl __sbh_heap_init(_DWORD); weak
// _DWORD __cdecl __sbh_find_block(_DWORD); weak
unsigned int __cdecl sub_4078D8(unsigned int a1, int a2);
// _DWORD __cdecl __sbh_alloc_block(_DWORD); weak
// _DWORD __cdecl __sbh_resize_block(_DWORD, _DWORD, _DWORD); weak
void **sub_4083AC();
int __cdecl sub_4084F0(LPVOID lpMem); // idb
void __cdecl sub_408546(int a1);
unsigned int __cdecl sub_408608(unsigned int a1, int a2, int a3);
void __cdecl sub_40865F(int a1, int a2, int a3);
int __cdecl sub_4086A4(unsigned int a1);
int __cdecl sub_4088AC(int a1, unsigned int a2, unsigned int a3);
signed int __cdecl sub_4089D0(int a1, int a2, unsigned int a3, unsigned int a4);
// _DWORD __cdecl _callnewh(_DWORD); weak
// void *__cdecl memcpy_0(void *, const void *, size_t);
LPVOID __cdecl sub_40A218(LPVOID lpMem, SIZE_T dwBytes);
SIZE_T __cdecl sub_40A4B8(LPCVOID lpMem);
LPVOID __cdecl sub_40AF25(size_t a1, int a2);
// void __cdecl __noreturn abort();
// __int32 __cdecl strtol(const char *, char **, int);
// char *__cdecl strchr(const char *, int);
// char *__cdecl strstr(const char *, const char *);
// int __cdecl strncmp(const char *, const char *, size_t);
// void *__cdecl memset(void *, int, size_t);
// int __cdecl deflateEnd(_DWORD); weak
// int __cdecl deflate(_DWORD, _DWORD); weak
// int __cdecl deflateInit2_(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD); weak
// int __cdecl _mkdir(const char *);
// int __usercall sub_40CE70@<eax>(int a1@<ebp>);
// void __usercall sub_40CE78(int a1@<ebp>);
// void __usercall sub_40CE80(int a1@<ebp>);
// void __usercall sub_40CE88(int a1@<ebp>);
// int __usercall sub_40CE90@<eax>(int a1@<ebp>);
// void __usercall sub_40CE98(int a1@<ebp>);
// void __usercall sub_40CEA0(int a1@<ebp>);
// void __usercall sub_40CEA8(int a1@<ebp>);
// void __usercall sub_40CEB0(int a1@<ebp>);
// void __usercall sub_40CEB8(int a1@<ebp>);
// void __usercall sub_40CEC0(int a1@<ebp>);
// int __usercall sub_40CEE0@<eax>(int a1@<ebp>);
// void __usercall sub_40CEEB(int a1@<ebp>);
// void __usercall sub_40CEF6(int a1@<ebp>);
// int __usercall sub_40CF01@<eax>(int a1@<ebp>);
// int __usercall sub_40CF0C@<eax>(int a1@<ebp>);
// void __usercall sub_40CF17(int a1@<ebp>);
// void __usercall sub_40CF22(int a1@<ebp>);
// void __usercall sub_40CF2D(int a1@<ebp>);
// int __usercall sub_40CF38@<eax>(int a1@<ebp>);
// int __usercall sub_40CF43@<eax>(int a1@<ebp>);
// void __usercall sub_40CF4E(int a1@<ebp>);
// void __usercall sub_40CF59(int a1@<ebp>);
// void __usercall sub_40CF64(int a1@<ebp>);
// int __usercall sub_40CF6F@<eax>(int a1@<ebp>);
// void __usercall sub_40CF7A(int a1@<ebp>);
// int __usercall sub_40CF85@<eax>(int a1@<ebp>);
// void __usercall sub_40CF90(int a1@<ebp>);
// int __usercall sub_40CF9B@<eax>(int a1@<ebp>);
// int __usercall sub_40CFA6@<eax>(int a1@<ebp>);
// int __usercall sub_40CFB1@<eax>(int a1@<ebp>);
// int __usercall sub_40CFD0@<eax>(int a1@<ebp>);
// void __usercall sub_40CFDB(int a1@<ebp>);
// void __usercall sub_40CFE6(int a1@<ebp>);
// int __usercall sub_40CFF1@<eax>(int a1@<ebp>);
// int __usercall sub_40D010@<eax>(int a1@<ebp>);
// void __usercall sub_40D01B(int a1@<ebp>);
// void __usercall sub_40D026(int a1@<ebp>);
// int __usercall sub_40D031@<eax>(int a1@<ebp>);
// void __usercall sub_40D03C(int a1@<ebp>);
// void __usercall sub_40D047(int a1@<ebp>);
// int __usercall sub_40D052@<eax>(int a1@<ebp>);
// int __usercall sub_40D05D@<eax>(int a1@<ebp>);
// int __usercall sub_40D068@<eax>(int a1@<ebp>);
// int __usercall sub_40D073@<eax>(int a1@<ebp>);
// int __usercall sub_40D090@<eax>(int a1@<ebp>);
// void __usercall sub_40D09B(int a1@<ebp>);
// void __usercall sub_40D0A6(int a1@<ebp>);
// int __usercall sub_40D0B1@<eax>(int a1@<ebp>);
// int __usercall sub_40D0BC@<eax>(int a1@<ebp>);
// int __usercall sub_40D0E0@<eax>(int a1@<ebp>);
// void __usercall sub_40D0EB(int a1@<ebp>);
// int __usercall sub_40D0F6@<eax>(int a1@<ebp>);
// int __usercall sub_40D110@<eax>(int a1@<ebp>);
// void __usercall sub_40D11B(int a1@<ebp>);
// void __usercall sub_40D126(int a1@<ebp>);
// void __usercall sub_40D131(int a1@<ebp>);
// int __usercall sub_40D139@<eax>(int a1@<ebp>);
// void __usercall sub_40D144(int a1@<ebp>);
// int __usercall sub_40D160@<eax>(int a1@<ebp>);
// void __usercall sub_40D190(int a1@<ebp>);
// int __usercall sub_40D19B@<eax>(int a1@<ebp>);
// int __usercall sub_40D1A3@<eax>(int a1@<ebp>);
// void __usercall sub_40D1AE(int a1@<ebp>);
// int __usercall sub_40D1D0@<eax>(int a1@<ebp>);
// int __usercall sub_40D1D8@<eax>(int a1@<ebp>);
// void __usercall sub_40D1E0(int a1@<ebp>);
// void __usercall sub_40D1E8(int a1@<ebp>);
// void __usercall sub_40D1F0(int a1@<ebp>);
// int __usercall sub_40D220@<eax>(int a1@<ebp>);
// int __usercall sub_40D228@<eax>(int a1@<ebp>);
// void __usercall sub_40D230(int a1@<ebp>);
// void __usercall sub_40D238(int a1@<ebp>);
// void __usercall sub_40D240(int a1@<ebp>);
// int __usercall sub_40D270@<eax>(int a1@<ebp>);
// int __usercall sub_40D290@<eax>(int a1@<ebp>);
// void __usercall sub_40D29B(int a1@<ebp>);
// void __usercall sub_40D2A6(int a1@<ebp>);
// BOOL __stdcall HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem);
// LPVOID __stdcall HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes);
// HMODULE __stdcall GetModuleHandleA(LPCSTR lpModuleName);
// DWORD __stdcall GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize);
// DWORD __stdcall GetEnvironmentVariableA(LPCSTR lpName, LPSTR lpBuffer, DWORD nSize);
// BOOL __stdcall GetVersionExA(LPOSVERSIONINFOA lpVersionInformation);
// BOOL __stdcall HeapDestroy(HANDLE hHeap);
// HANDLE __stdcall HeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize);
// BOOL __stdcall VirtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType);
// LPVOID __stdcall VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect);
// LPVOID __stdcall HeapReAlloc(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem, SIZE_T dwBytes);
// SIZE_T __stdcall HeapSize(HANDLE hHeap, DWORD dwFlags, LPCVOID lpMem);
//-------------------------------------------------------------------------
// Data declarations
int CRC32_m_tab[] = { 0 }; // weak
int (__thiscall *off_40E508)(LPVOID lpMem, char) = &sub_402FA0; // weak
int (__thiscall *off_40E510)(LPVOID lpMem, char) = &sub_402FA0; // weak
int (__thiscall *off_40E518)(LPVOID lpMem, char) = &sub_402FA0; // weak
int (__thiscall *off_40E520)(LPVOID lpMem, char) = &sub_402FA0; // weak
__int16 word_40E528[] = { 3 }; // weak
__int16 word_40E564[] = { 0 }; // weak
__int16 word_40E5A0[] = { 1 }; // weak
__int16 word_40E5DC[] = { 0 }; // weak
_UNKNOWN unk_40E618; // weak
_UNKNOWN unk_40E63E; // weak
int (__thiscall *off_40E644)(LPVOID lpMem, char) = &sub_405D5B; // weak
_UNKNOWN unk_40EF90; // weak
_UNKNOWN unk_40EFA0; // weak
int dword_410040 = 4294967295; // weak
char aCompressErrorD[] = "Compress error: %d\n"; // idb
char a1_2_1[6] = "1.2.1"; // weak
char asc_410060[2] = "/"; // weak
char asc_410064[3] = "/\\"; // weak
char a_[2] = "."; // weak
char aS[] = "[%s]\n"; // idb
char aWb[] = "wb"; // idb
char a_decrypted[11] = ".decrypted"; // weak
char aCanTOpenInputF[] = "Can't open input file\n"; // idb
char aRb[] = "rb"; // idb
char aUS[] = "%u %s\n"; // idb
char aW[] = "w"; // idb
char a_txt[5] = ".txt"; // weak
char aCanTOpenS[] = "Can't open [%s]\n"; // idb
char a__[3] = ".."; // weak
char aSSS_[] = "%s/%s/%s/*.*"; // idb
char aSS_[] = "%s/%s/*.*"; // idb
char aS_[] = "%s/*.*"; // idb
char aS_mrs[] = "%s.mrs"; // idb
char aUnknownOption[] = "Encrypter MRS by Christopher_99 2015 5 codes... Unknown option\n"; // idb
char aDonTLeaveUnpac[] = " Don't leave unpacked folders and/or backup files in the GunZ directory!\n"; // idb
char aWarning[] = " Warning:\n"; // idb
char aMakeSystem_mrs[] = " (make system.mrs and pack files ./system/*.* to it)\n"; // idb
char aMrs_exeCSystem[] = " mrs.exe c system\n"; // idb
char aUnpackSystem_m[] = " (unpack system.mrs to directory ./system/ )\n"; // idb
char aMrs_exeDSystem[] = " mrs.exe d system.mrs\n"; // idb
char aExamples[] = " Examples:\n"; // idb
char aCCompressDirec[] = " p - compress directory to archive\n"; // idb
char aDDecompressArc[] = " u - decompress archive to directory\n"; // idb
char aUsageMrs_exeDC[] = " Usage: mrs.exe d|c filename\n"; // idb
char a_mrsFilesPacke[] = " .mrs files packer/unpacker v0.1 (c) by Christopher_99 2015\n"; // idb
char asc_4102D8[] = "\n"; // idb
char aBasic_string[13] = "basic_string"; // weak
int dword_410390 = 1; // weak
void *off_410398 = &unk_412E10; // weak
void *off_4103A0 = &unk_412DF0; // weak
void *off_410690 = &off_410690; // weak
LPVOID off_410694 = &off_410690; // idb
int dword_4106A0 = 4294967295; // weak
void **off_4126B0 = &off_410690; // weak
int dword_4126B4 = 480; // weak
_UNKNOWN unk_412DA0; // weak
int dword_412DA4[] = { 0 }; // weak
int dword_412DE4 = 0; // weak
int dword_412DE8 = 0; // weak
int dword_412DEC = 0; // weak
int (*dword_4130D0)(void); // weak
int dword_4130D4; // weak
int dword_4130D8; // weak
int dword_4136DC; // weak
int dword_4136E0; // weak
void *dword_4136E4; // idb
int dword_4136E8; // weak
LPVOID lpMem; // idb
int dword_4136F0; // weak
HANDLE hHeap; // idb
int dword_4136F8; // weak
//----- (00401000) --------------------------------------------------------
int __cdecl sub_401000(int a1, int a2, int a3)
{
int v3; // ecx@2
int v4; // esi@2
int v5; // eax@2
int result; // eax@4
if ( a2 )
{
v3 = a1;
v4 = a2;
v5 = a3;
do
{
v5 = CRC32_m_tab[*(_BYTE *)v3++ ^ (unsigned __int8)v5] ^ ((unsigned int)v5 >> 8);
--v4;
}
while ( v4 );
result = ~v5;
}
else
{
result = ~a3;
}
return result;
}
// 40E108: using guessed type int CRC32_m_tab[];
//----- (00401050) --------------------------------------------------------
int __cdecl sub_401050(int a1, int a2, int a3, int a4)
{
int result; // eax@2
int v5; // eax@3
int v6; // [sp+0h] [bp-38h]@1
int v7; // [sp+Ch] [bp-2Ch]@1
int v8; // [sp+10h] [bp-28h]@1
int v9; // [sp+14h] [bp-24h]@2
int v10; // [sp+20h] [bp-18h]@1
int v11; // [sp+24h] [bp-14h]@1
int v12; // [sp+28h] [bp-10h]@1
v10 = 0;
v11 = 0;
v12 = 0;
deflateInit2_(&v6, 8, 8, -15, 9, 0, a1_2_1, 56, a1, a2);
v7 = a3;
v8 = a4;
if ( deflate(&v6, 4) == 1 )
{
deflateEnd(&v6);
result = v9;
}
else
{
v5 = deflateEnd(&v6);
printf(aCompressErrorD, v5);
result = 0;
}
return result;
}
// 40CE20: using guessed type int __cdecl deflateEnd(_DWORD);
// 40CE26: using guessed type int __cdecl deflate(_DWORD, _DWORD);
// 40CE2C: using guessed type int __cdecl deflateInit2_(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD);
//----- (004010F0) --------------------------------------------------------
char __cdecl sub_4010F0(int a1, unsigned int a2)
{
unsigned int v2; // ecx@1
char v3; // al@2
char result; // al@2
v2 = 0;
if ( a2 )
{
do
{
v3 = __ROR1__(*(_BYTE *)(a1 + v2), 3);
result = ((((((v3 ^ 0x5E) + 3) ^ 3) + 3) + 0xB9) - 20; //xD operación básica xD :3 con 7 codes
++v2;
*(_BYTE *)(a1 + v2 - 1) = result; // Resultado
}
while ( v2 < a2 ); // xD >5
}
return result;
}
//----- (00401120) --------------------------------------------------------
char __cdecl sub_401120(int a1, unsigned int a2)
{
unsigned int v2; // ecx@1
char result; // al@2
v2 = 0;
if ( a2 )
{
do
{
result = __ROL1__((((((*(_BYTE *)(a1 + v2++) + 20) -0xB9) -3 ) ^ 3) - 3) ^ 0x5E, 3);
*(_BYTE *)(a1 + v2 - 1) = result; //Resultado
}
while ( v2 < a2 ); // Xd 3>5
}
return result;
}
//----- (00401150) --------------------------------------------------------
void __cdecl sub_401150(int a1, int a2)
{
int v2; // esi@1
int v3; // ebp@1
int v4; // eax@2
int v5; // edi@7
int v6; // eax@8
int v7; // eax@8
int v8; // eax@15
int v9; // ecx@15
int v10; // eax@15
int v11; // eax@15
char v12; // [sp+Fh] [bp-3Dh]@3
int v13; // [sp+10h] [bp-3Ch]@1
int v14; // [sp+14h] [bp-38h]@1
int v15; // [sp+18h] [bp-34h]@1
char *v16; // [sp+1Ch] [bp-30h]@7
char *v17; // [sp+20h] [bp-2Ch]@7
char *v18; // [sp+24h] [bp-28h]@7
char v19; // [sp+28h] [bp-24h]@2
char v20; // [sp+34h] [bp-18h]@8
int v21; // [sp+48h] [bp-4h]@1
v2 = a2;
v3 = sub_403420(a2, (int)asc_410064, 0, strlen(asc_410064));
v21 = 0;
sub_4039D0((int)&v13, (int)&a2);
LOBYTE(v21) = 2;
v13 = sub_4037C0(8);
v14 = v13;
v15 = v13 + 8;
*(_BYTE *)v13 = 0;
v21 = 3;
if ( v3 == -1 )
{
if ( (int *)v2 != &v13 )
sub_403C50(&v13, *(_DWORD *)v2, *(_DWORD *)(v2 + 4), (int)&v12);
}
else
{
v4 = sub_402D50(v2, (int)&v19, 0, v3);
LOBYTE(v21) = 4;
if ( (int *)v4 != &v13 )
sub_403C50(&v13, *(_DWORD *)v4, *(_DWORD *)(v4 + 4), (int)&v12);
LOBYTE(v21) = 3;
sub_402C90((int)&v19);
}
LOBYTE(v21) = 5;
sub_4039D0((int)&v16, (int)&v12);
LOBYTE(v21) = 7;
v16 = (char *)sub_4037C0(8);
v17 = v16;
v18 = v16 + 8;
*v16 = 0;
v5 = a1;
LOBYTE(v21) = 8;
if ( (unsigned __int8)sub_403C10(a1, (const char *)&unk_412DA0) )
{
sub_402CD0(&v16, (int)&v13);
}
else
{
v6 = sub_403510((int)&v20, v5, asc_410060);
LOBYTE(v21) = 9;
v7 = sub_403680((int)&v19, v6, (int)&v13);
LOBYTE(v21) = 10;
if ( (char **)v7 != &v16 )
sub_403C50(&v16, *(_DWORD *)v7, *(_DWORD *)(v7 + 4), (int)&a1);
LOBYTE(v21) = 9;
sub_402C90((int)&v19);
LOBYTE(v21) = 8;
sub_402C90((int)&v20);
}
_mkdir(v16);
if ( v3 != -1 )
{
if ( !(unsigned __int8)sub_403C10(v5, (const char *)&unk_412DA0) )
sub_4030C0(v5, asc_410060);
v8 = sub_402D50(v2, (int)&v20, 0, v3);
v9 = *(_DWORD *)(v8 + 4);
v10 = *(_DWORD *)v8;
LOBYTE(v21) = 11;
sub_403CC0(v5, v10, v9, (int)&a1);
LOBYTE(v21) = 8;
sub_402C90((int)&v20);
v11 = sub_402D50(v2, (int)&v20, v3 + 1, 0xFFFFFFFF);
LOBYTE(v21) = 12;
sub_402CD0((void *)v2, v11);
LOBYTE(v21) = 8;
sub_402C90((int)&v20);
sub_401150(v5, v2);
}
LOBYTE(v21) = 3;
sub_402C90((int)&v16);
v21 = -1;
sub_402C90((int)&v13);
}
//----- (004013D0) --------------------------------------------------------
char __cdecl sub_4013D0(char *a1, char a2)
{
FILE *v2; // ebp@1
char result; // al@2
FILE *v4; // edi@4
void *v5; // esi@15
int v6; // eax@17
const void *v7; // ebp@17
int v8; // eax@18
int v9; // eax@18
int v10; // eax@22
int v11; // eax@22
int v12; // eax@26
int v13; // eax@26
int v14; // eax@29
FILE *v15; // esi@30
FILE *v16; // esi@31
int v17; // eax@31
_BYTE v18[11]; // [sp+Dh] [bp-593h]@4
int v19; // [sp+18h] [bp-588h]@31
char *v20; // [sp+1Ch] [bp-584h]@4
int v21; // [sp+20h] [bp-580h]@29
int v22; // [sp+24h] [bp-57Ch]@31
char v23; // [sp+2Bh] [bp-575h]@29
FILE *v24; // [sp+2Ch] [bp-574h]@4
char v25; // [sp+32h] [bp-56Eh]@19
char v26; // [sp+33h] [bp-56Dh]@23
FILE *v27; // [sp+34h] [bp-56Ch]@1
char v28; // [sp+3Bh] [bp-565h]@27
char v29; // [sp+3Ch] [bp-564h]@6
LPVOID lpMem; // [sp+40h] [bp-560h]@21
int v31; // [sp+48h] [bp-558h]@31
size_t v32; // [sp+4Ch] [bp-554h]@17
char v33; // [sp+50h] [bp-550h]@6
size_t v34; // [sp+5Eh] [bp-542h]@15
int v35; // [sp+62h] [bp-53Eh]@17
int v36; // [sp+66h] [bp-53Ah]@9
size_t v37; // [sp+6Ch] [bp-534h]@17
char v38; // [sp+70h] [bp-530h]@26
char v39; // [sp+7Ch] [bp-524h]@22
char v40; // [sp+88h] [bp-518h]@18
int v41; // [sp+94h] [bp-50Ch]@10
char v42; // [sp+194h] [bp-40Ch]@13
int v43; // [sp+59Ch] [bp-4h]@4
v2 = fopen(a1, aRb);
v27 = v2;
if ( v2 )
{
if ( a2 )
{
v43 = 0;
sub_4039D0((int)&v20, (int)&v18[1]);
LOBYTE(v43) = 1;
v18[0] = v18[1];
sub_403ED0(&v20, a1, (int)&a1[strlen(a1)], (int)v18);
LOBYTE(v43) = 3;
sub_403CF0((int)&v20, a_decrypted, (int)&a_decrypted[strlen(a_decrypted)], (int)v18);
v4 = fopen(v20, aWb);
v24 = v4;
v43 = 4;
sub_403240((int)&v20);
v43 = -1;
}
else
{
v4 = v24;
}
fread(&v29, 4u, 1u, v2);
sub_4010F0((int)&v29, 4u);
fread(&v33, 1u, 0x1Au, v2);
if ( !feof(v2) )
{
do
{
sub_4010F0((int)&v33, 0x1Au);
if ( a2 )
fwrite(&v33, 1u, 0x1Au, v4);
if ( !(_WORD)v36 )
break;
fread(&v41, 1u, (unsigned __int16)v36, v2);
sub_4010F0((int)&v41, (unsigned __int16)v36);
*((_BYTE *)&v41 + (unsigned __int16)v36) = 0;
if ( !(_BYTE)v41 )
break;
printf(aS, &v41);
if ( a2 )
fwrite(&v41, 1u, (unsigned __int16)v36, v4);
fread(&v42, 1u, HIWORD(v36), v2);
sub_4010F0((int)&v42, HIWORD(v36));
if ( a2 )
fwrite(&v42, 1u, HIWORD(v36), v4);
v5 = malloc(v34);
fread(v5, 1u, v34, v2);
if ( a2 )
fwrite(v5, 1u, v34, v4);
v6 = (int)malloc(v35 + 16);
v32 = v35 + 16;
v7 = (const void *)v6;
v37 = v34;
sub_4044A0(v6, (int *)&v32, (int)v5, (int *)&v37);
sub_4051BC(v5);
v43 = 5;
sub_4039D0((int)&v18[3], (int)&v18[1]);
LOBYTE(v43) = 6;
v18[0] = v18[1];
sub_403ED0(&v18[3], a1, (int)&a1[strlen(a1)], (int)v18);
LOBYTE(v43) = 8;
if ( sub_403480(&v18[3], (int)a_, 0xFFFFFFFF, strlen(a_)) != -1 )
{
v8 = sub_403480(&v18[3], (int)a_, 0xFFFFFFFF, strlen(a_));
v9 = sub_402D50((int)&v18[3], (int)&v40, 0, v8);
LOBYTE(v43) = 9;
if ( (_BYTE *)v9 != &v18[3] )
sub_403C50(&v18[3], *(_DWORD *)v9, *(_DWORD *)(v9 + 4), (int)&v25);
LOBYTE(v43) = 10;
sub_403240((int)&v40);
_mkdir(*(const char **)&v18[3]);
}
LOBYTE(v43) = 11;
sub_4039D0((int)&lpMem, (int)&v18[2]);
v18[0] = v18[2];
LOBYTE(v43) = 12;
sub_403ED0(&lpMem, &v41, (int)((char *)&v41 + strlen((const char *)&v41)), (int)v18);
LOBYTE(v43) = 14;
if ( sub_403480(&lpMem, (int)asc_410064, 0xFFFFFFFF, strlen(asc_410064)) != -1 )
{
v10 = sub_403480(&lpMem, (int)asc_410064, 0xFFFFFFFF, strlen(asc_410064));
v11 = sub_402D50((int)&lpMem, (int)&v39, 0, v10);
LOBYTE(v43) = 15;
if ( (LPVOID *)v11 != &lpMem )
sub_403C50(&lpMem, *(_DWORD *)v11, *(_DWORD *)(v11 + 4), (int)&v26);
LOBYTE(v43) = 16;
sub_403240((int)&v39);
LOBYTE(v43) = 14;
sub_401150((int)&v18[3], (int)&lpMem);
}
sub_403100((int)&v18[3], a1, (int)&a1[strlen(a1)]);
if ( sub_403480(&v18[3], (int)a_, 0xFFFFFFFF, strlen(a_)) != -1 )
{
v12 = sub_403480(&v18[3], (int)a_, 0xFFFFFFFF, strlen(a_));
v13 = sub_402D50((int)&v18[3], (int)&v38, 0, v12);
LOBYTE(v43) = 17;
if ( (_BYTE *)v13 != &v18[3] )
sub_403C50(&v18[3], *(_DWORD *)v13, *(_DWORD *)(v13 + 4), (int)&v28);
LOBYTE(v43) = 18;
sub_403240((int)&v38);
LOBYTE(v43) = 14;
_mkdir(*(const char **)&v18[3]);
}
sub_403510((int)&v20, (int)&v18[3], asc_410060);
LOBYTE(v43) = 19;
sub_403CF0((int)&v20, &v41, (int)((char *)&v41 + strlen((const char *)&v41)), (int)&v23);
v14 = sub_403480(&v20, (int)asc_410064, 0xFFFFFFFF, strlen(asc_410064));
if ( v14 + 1 != v21 - (_DWORD)v20 )
{
v15 = fopen(v20, aWb);
fwrite(v7, 1u, v32, v15);
fclose(v15);
}
sub_4051BC((LPVOID)v7);
LOBYTE(v43) = 20;
sub_4032C0(v20, v22 - (_DWORD)v20);
LOBYTE(v43) = 21;
sub_4032C0(lpMem, v31 - (_DWORD)lpMem);
v43 = 22;
sub_4032C0(*(LPVOID *)&v18[3], v19 - *(_DWORD *)&v18[3]);
v16 = v27;
v43 = -1;
fread(&v29, 4u, 1u, v27);
sub_4010F0((int)&v29, 4u);
fread(&v33, 1u, 0x1Au, v16);
v17 = feof(v16);
v4 = v24;
v2 = v16;
}
while ( !v17 );
}
fclose(v2);
result = a2;
if ( a2 )
result = fclose(v4);
}
else
{
result = printf(aCanTOpenInputF);
}
return result;
}
//----- (00401B00) --------------------------------------------------------
int __cdecl sub_401B00(int a1)
{
unsigned int v1; // ecx@1
v1 = *(_DWORD *)(a1 + 20);
if ( v1 <= 0x7BC )
{
if ( v1 > 0x50 )
v1 -= 80;
}
else
{
v1 -= 1980;
}
return ((*(_DWORD *)(a1 + 12) + 32 * (16 * v1 + *(_DWORD *)(a1 + 16) + 1)) << 16) | ((*(_DWORD *)a1 >> 1)
+ 32
* (*(_DWORD *)(a1 + 4)
+ (*(_DWORD *)(a1 + 8) << 6)));
}
//----- (00401B50) --------------------------------------------------------
char __cdecl sub_401B50(char *a1, char a2)
{
FILE *v2; // esi@1
char result; // al@2
signed int v4; // kr04_4@4
FILE *v5; // ebp@4
char *v6; // ecx@4
int v7; // eax@4
unsigned int v8; // eax@7
int v9; // ST38_4@12
void *v10; // edi@12
void *v11; // eax@12
char v12; // [sp+Eh] [bp-65Ah]@4
_BYTE v13[5]; // [sp+Fh] [bp-659h]@4
char *v14; // [sp+14h] [bp-654h]@4
char *v15; // [sp+18h] [bp-650h]@4
int v16; // [sp+1Ch] [bp-64Ch]@4
size_t v17; // [sp+22h] [bp-646h]@12
int v18; // [sp+26h] [bp-642h]@12
int v19; // [sp+2Ah] [bp-63Eh]@12
char v20; // [sp+30h] [bp-638h]@15
int v21; // [sp+48h] [bp-620h]@16
char v22[256]; // [sp+5Ch] [bp-60Ch]@12
char v23[256]; // [sp+15Ch] [bp-50Ch]@16
char v24; // [sp+25Ch] [bp-40Ch]@12
int v25; // [sp+664h] [bp-4h]@4
v2 = fopen(a1, aRb);
if ( v2 )
{
if ( a2 )
{
v25 = 0;
v14 = 0;
v15 = 0;
sub_4039F0(&v16, (int)&v12, 0);
LOBYTE(v25) = 1;
v4 = strlen(a1) + 1;
sub_403A00(&v14, v4);
v15 = sub_401ED0(a1, (int)&a1[v4 - 1], v14);
*v15 = 0;
LOBYTE(v25) = 3;
v13[0] = v12;
sub_4040F0((int)&v14, a_txt, (int)&a_txt[strlen(a_txt)], (int)v13);
v5 = fopen(v14, aW);
v6 = v14;
v7 = v16 - (_DWORD)v14;
if ( v14 )
{
if ( (unsigned int)v7 <= 0x80 )
{
v8 = (unsigned int)(v7 - 1) >> 3;
*(_DWORD *)v14 = dword_412DA4[v8];
dword_412DA4[v8] = (int)v6;
}
else
{
sub_40565F(v14);
}
}
}
else
{
v5 = *(FILE **)&v13[1];
}
ftell(v2);
fread(&v13[1], 4u, 1u, v2);
if ( !feof(v2) )
{
while ( 1 )
{
sub_4010F0((int)&v13[1], 4u);
if ( *(_DWORD *)&v13[1] == 84083208 )
break;
if ( *(_DWORD *)&v13[1] == 67324752 )
{
fread(&v14, 1u, 0x1Au, v2);
sub_4010F0((int)&v14, 0x1Au);
fread(v22, 1u, (unsigned __int16)v19, v2);
sub_4010F0((int)v22, (unsigned __int16)v19);
v9 = v18;
v22[(unsigned __int16)v19] = 0;
printf(aUS, v9, v22);
fread(&v24, 1u, HIWORD(v19), v2);
sub_4010F0((int)&v24, HIWORD(v19));
v10 = malloc(v17);
fread(v10, 1u, v17, v2);
v11 = malloc(v18 + 16);
sub_4051BC(v11);
sub_4051BC(v10);
}
else
{
if ( dword_410040 == -1 )
dword_410040 = ftell(v2) - 4;
fread(&v20, 1u, 0x2Au, v2);
if ( feof(v2) )
goto LABEL_20;
sub_4010F0((int)&v20, 0x2Au);
fread(v23, 1u, (unsigned __int16)v21, v2);
sub_4010F0((int)v23, (unsigned __int16)v21);
v23[(unsigned __int16)v21] = 0;
}
ftell(v2);
fread(&v13[1], 4u, 1u, v2);
if ( feof(v2) )
goto LABEL_20;
}
fread(&v14, 1u, 0x12u, v2);
sub_4010F0((int)&v14, 0x12u);
}
LABEL_20:
fclose(v2);
result = a2;
if ( a2 )
result = fclose(v5);
}
else
{
result = printf(aCanTOpenInputF);
}
return result;
}
// 410040: using guessed type int dword_410040;
// 412DA4: using guessed type int dword_412DA4[];
// 401B50: using guessed type char var_60C[256];
// 401B50: using guessed type char var_50C[256];
//----- (00401ED0) --------------------------------------------------------
char *__cdecl sub_401ED0(void *a1, int a2, void *a3)
{
char *result; // eax@2
if ( (void *)a2 == a1 )
result = (char *)a3;
else
result = (char *)memcpy(a3, a1, a2 - (_DWORD)a1) + a2 - (_DWORD)a1;
return result;
}
//----- (00401F00) --------------------------------------------------------
void __cdecl sub_401F00(FILE *a1, int a2, int a3, int a4, int a5, size_t a6, time_t a7)
{
char v7; // al@1
char v8; // al@3
struct tm *v9; // eax@5
void *v10; // edi@7
unsigned int v11; // kr38_4@9
size_t v12; // esi@9
void *v13; // edi@9
unsigned int v14; // ecx@9
char v15; // dl@9
int v16; // esi@9
char *v17; // ecx@9
int v18; // eax@9
unsigned int v19; // eax@12
int v20; // ecx@13
int v21; // eax@13
unsigned int v22; // eax@16
int v23; // [sp-8h] [bp-8D8h]@9
__int16 *v24; // [sp-4h] [bp-8D4h]@9
char v25[6]; // [sp+12h] [bp-8BEh]@1
int v26; // [sp+18h] [bp-8B8h]@1
int v27; // [sp+1Ch] [bp-8B4h]@1
size_t v28; // [sp+20h] [bp-8B0h]@5
char *v29; // [sp+24h] [bp-8ACh]@3
int v30; // [sp+28h] [bp-8A8h]@3
int v31; // [sp+2Ch] [bp-8A4h]@3
char v32; // [sp+30h] [bp-8A0h]@9
char v33; // [sp+31h] [bp-89Fh]@9
char v34; // [sp+32h] [bp-89Eh]@9
char v35; // [sp+33h] [bp-89Dh]@9
char v36; // [sp+34h] [bp-89Ch]@9
char v37; // [sp+35h] [bp-89Bh]@9
char v38; // [sp+36h] [bp-89Ah]@9
char v39; // [sp+37h] [bp-899h]@9
char v40; // [sp+38h] [bp-898h]@9
char v41; // [sp+39h] [bp-897h]@9
char v42; // [sp+3Ah] [bp-896h]@9
char v43; // [sp+3Bh] [bp-895h]@9
char v44; // [sp+3Ch] [bp-894h]@9
char v45; // [sp+3Dh] [bp-893h]@9
char v46; // [sp+3Eh] [bp-892h]@9
char v47; // [sp+3Fh] [bp-891h]@9
char v48; // [sp+40h] [bp-890h]@9
char v49; // [sp+41h] [bp-88Fh]@9
char v50; // [sp+42h] [bp-88Eh]@9
char v51; // [sp+43h] [bp-88Dh]@9
char v52; // [sp+44h] [bp-88Ch]@9
char v53; // [sp+45h] [bp-88Bh]@9
char v54; // [sp+46h] [bp-88Ah]@9
char v55; // [sp+47h] [bp-889h]@9
char v56; // [sp+48h] [bp-888h]@9
char v57; // [sp+49h] [bp-887h]@9
char v58; // [sp+4Ah] [bp-886h]@9
char v59; // [sp+4Bh] [bp-885h]@9
char v60; // [sp+4Ch] [bp-884h]@9
char v61; // [sp+4Dh] [bp-883h]@9
char v62; // [sp+4Eh] [bp-882h]@9
char v63; // [sp+4Fh] [bp-881h]@9
char v64; // [sp+50h] [bp-880h]@9
char v65; // [sp+51h] [bp-87Fh]@9
char v66; // [sp+52h] [bp-87Eh]@9
char v67; // [sp+53h] [bp-87Dh]@9
__int32 v68; // [sp+54h] [bp-87Ch]@5
void *lpMem; // [sp+58h] [bp-878h]@7
int v70; // [sp+5Ch] [bp-874h]@5
int v71; // [sp+60h] [bp-870h]@9
__int16 v72; // [sp+64h] [bp-86Ch]@5
__int16 v73; // [sp+66h] [bp-86Ah]@5
__int16 v74; // [sp+68h] [bp-868h]@5
int v75; // [sp+6Ah] [bp-866h]@5
int v76; // [sp+6Eh] [bp-862h]@9
size_t v77; // [sp+72h] [bp-85Eh]@9
size_t v78; // [sp+76h] [bp-85Ah]@5
__int16 v79; // [sp+7Ah] [bp-856h]@5
__int16 v80; // [sp+7Ch] [bp-854h]@9
int v81; // [sp+80h] [bp-850h]@5
int v82; // [sp+84h] [bp-84Ch]@5
int v83; // [sp+88h] [bp-848h]@5
int v84; // [sp+8Ch] [bp-844h]@5
int v85; // [sp+90h] [bp-840h]@5
int v86; // [sp+94h] [bp-83Ch]@5
__int16 v87; // [sp+98h] [bp-838h]@9
__int16 v88; // [sp+9Ah] [bp-836h]@9
__int16 v89; // [sp+9Ch] [bp-834h]@9
__int16 v90; // [sp+9Eh] [bp-832h]@9
int v91; // [sp+A0h] [bp-830h]@9
int v92; // [sp+A4h] [bp-82Ch]@9
size_t v93; // [sp+A8h] [bp-828h]@9
size_t v94; // [sp+ACh] [bp-824h]@9
__int16 v95; // [sp+B0h] [bp-820h]@9
__int16 v96; // [sp+B2h] [bp-81Eh]@9
__int16 v97; // [sp+B4h] [bp-81Ch]@9
__int16 v98; // [sp+B6h] [bp-81Ah]@9
__int16 v99; // [sp+B8h] [bp-818h]@9
int v100; // [sp+BAh] [bp-816h]@9
__int32 v101; // [sp+BEh] [bp-812h]@9
char v102[1026]; // [sp+C2h] [bp-80Eh]@9
char v103; // [sp+4C4h] [bp-40Ch]@9
int v104; // [sp+8CCh] [bp-4h]@1
v104 = 0;
*(_DWORD *)&v25[2] = 0;
v26 = 0;
sub_4039F0(&v27, (int)&v25[1], 0);
LOBYTE(v104) = 1;
sub_403B40(&v25[2], (void *)a4, a4 + strlen((const char *)a4));
v7 = *(_BYTE *)a4;
LOBYTE(v104) = 3;
if ( v7 )
{
v25[0] = v25[1];
sub_4040F0((int)&v25[2], asc_410060, (int)&asc_410060[strlen(asc_410060)], (int)v25);
}
v25[0] = v25[1];
sub_4040F0((int)&v25[2], (void *)a5, a5 + strlen((const char *)a5), (int)v25);
LOBYTE(v104) = 4;
v29 = 0;
v30 = 0;
sub_4039F0(&v31, (int)&v25[1], 0);
LOBYTE(v104) = 5;
v25[0] = v25[1];
sub_403ED0(&v29, (void *)a3, a3 + strlen((const char *)a3), (int)v25);
v8 = *(_BYTE *)a3;
LOBYTE(v104) = 7;
if ( v8 )
{
v25[0] = v25[1];
sub_4040F0((int)&v29, asc_410060, (int)&asc_410060[strlen(asc_410060)], (int)v25);
}
v25[0] = v25[1];
sub_403F50((int)&v29, *(int *)&v25[2], v26, (int)v25);
v68 = ftell(a1);
v70 = 67324752;
sub_401120((int)&v70, 4u);
fwrite(&v70, 4u, 1u, a1);
v9 = localtime(&a7);
v86 = v9->tm_year + 1900;
v85 = v9->tm_mon;
v84 = v9->tm_mday;
v83 = v9->tm_hour;
v82 = v9->tm_min;
v81 = v9->tm_sec;
v72 = 20;
v73 = 0;
v74 = 8;
v75 = sub_401B00((int)&v81);
v78 = a6;
v79 = strlen(*(const char **)&v25[2]);
v28 = (size_t)fopen(v29, aRb);
if ( v28 )
{
v10 = malloc(a6 + 1);
lpMem = malloc(a6 + 50);
if ( a6 > 0 )
fread(v10, 1u, a6, (FILE *)v28);
fclose((FILE *)v28);
v71 = sub_401000((int)v10, a6, -1);
v76 = v71;
v28 = sub_401050((int)v10, a6, (int)lpMem, a6 + 50);
v77 = v28;
sub_4051BC(v10);
v80 = 36;
sub_401120((int)&v72, 0x1Au);
fwrite(&v72, 1u, 0x1Au, a1);
strcpy(&v103, *(const char **)&v25[2]);
v11 = strlen(&v103) + 1;
sub_401120((int)&v103, v11 - 1);
fwrite(&v103, 1u, v11 - 1, a1);
v32 = 10;
v33 = 0;
v34 = 32;
v35 = 0;
v36 = 0;
v37 = 0;
v38 = 0;
v39 = 0;
v40 = 1;
v41 = 0;
v42 = 24;
v43 = 0;
v44 = 124;
v45 = 121;
v46 = 82;
v47 = 40;
v48 = -123;
v50 = -59;
v58 = -59;
v66 = -59;
v49 = -34;
v51 = 1;
v52 = -78;
v53 = 2;
v54 = -121;
v55 = 90;
v56 = -86;
v57 = -34;
v59 = 1;
v60 = 112;
v61 = -12;
v62 = -106;
v63 = 2;
v64 = 41;
v65 = -43;
v67 = 1;
sub_401120((int)&v32, 0x24u);
fwrite(&v32, 1u, 0x24u, a1);
v12 = v28;
v13 = lpMem;
fwrite(lpMem, 1u, v28, a1);
sub_4051BC(v13);
v87 = 25;
v88 = 20;
v89 = 0;
v90 = 8;
v91 = sub_401B00((int)&v81);
v92 = v71;
v94 = a6;
v93 = v12;
v101 = v68;
v95 = strlen(*(const char **)&v25[2]);
v96 = 0;
v97 = 0;
v98 = 0;
v99 = 0;
v100 = 32;
v14 = strlen(*(const char **)&v25[2]) + 1;
v15 = v14;
v16 = *(_DWORD *)&v25[2];
v14 >>= 2;
qmemcpy(v102, *(const void **)&v25[2], 4 * v14);
v24 = &v87;
qmemcpy(&v102[4 * v14], (const void *)(v16 + 4 * v14), v15 & 3);
v23 = 0;
sub_4039C0((void *)a2, (int)&v23);
sub_4031A0((int)&v68, v23, v24);
v17 = v29;
v18 = v31 - (_DWORD)v29;
if ( v29 )
{
if ( (unsigned int)v18 <= 0x80 )
{
v19 = (unsigned int)(v18 - 1) >> 3;
*(_DWORD *)v29 = dword_412DA4[v19];
dword_412DA4[v19] = (int)v17;
}
else
{
sub_40565F(v29);
}
}
v20 = *(_DWORD *)&v25[2];
v21 = v27 - *(_DWORD *)&v25[2];
if ( *(_DWORD *)&v25[2] )
{
if ( (unsigned int)v21 <= 0x80 )
{
v22 = (unsigned int)(v21 - 1) >> 3;
**(_DWORD **)&v25[2] = dword_412DA4[v22];
dword_412DA4[v22] = v20;
}
else
{
sub_40565F(*(LPVOID *)&v25[2]);
}
}
}
else
{
printf(aCanTOpenS, v29);
LOBYTE(v104) = 8;
sub_4032C0(v29, v31 - (_DWORD)v29);
v104 = 9;
sub_4032C0(*(LPVOID *)&v25[2], v27 - *(_DWORD *)&v25[2]);
}
}
// 412DA4: using guessed type int dword_412DA4[];
// 401F00: using guessed type char var_80E[1026];
//----- (00402520) --------------------------------------------------------
int __cdecl sub_402520(FILE *a1, int a2, int a3, int a4, int a5)
{
int result; // eax@4
char v6; // al@7
char lpMem[6]; // [sp+Ah] [bp-536h]@7
int v8; // [sp+10h] [bp-530h]@7
int v9; // [sp+14h] [bp-52Ch]@7
__int32 i; // [sp+18h] [bp-528h]@4
struct _finddata_t v11; // [sp+1Ch] [bp-524h]@4
char v12; // [sp+134h] [bp-40Ch]@2
int v13; // [sp+53Ch] [bp-4h]@7
if ( *(_BYTE *)a4 )
sprintf(&v12, aSSS_, a3, a4, a5);
else
sprintf(&v12, aSS_, a3, a5);
result = _findfirst(&v12, &v11);
for ( i = result; result != -1; result = _findnext(i, &v11) )
{
if ( strcmp(v11.name, a_) && strcmp(v11.name, a__) )
{
v13 = 0;
*(_DWORD *)&lpMem[2] = 0;
v8 = 0;
sub_4039F0(&v9, (int)&lpMem[1], 0);
LOBYTE(v13) = 1;
lpMem[0] = lpMem[1];
sub_403ED0(&lpMem[2], (void *)a4, a4 + strlen((const char *)a4), (int)lpMem);
v6 = *(_BYTE *)a4;
LOBYTE(v13) = 3;
if ( v6 )
{
lpMem[0] = lpMem[1];
sub_4040F0((int)&lpMem[2], asc_410060, (int)&asc_410060[strlen(asc_410060)], (int)lpMem);
}
lpMem[0] = lpMem[1];
sub_4040F0((int)&lpMem[2], (void *)a5, a5 + strlen((const char *)a5), (int)lpMem);
if ( v11.attrib & 0x10 )
{
sub_402520(a1, a2, a3, *(int *)&lpMem[2], (int)v11.name);
v13 = 4;
sub_4032C0(*(LPVOID *)&lpMem[2], v9 - *(_DWORD *)&lpMem[2]);
}
else
{
sub_401F00(a1, a2, a3, *(int *)&lpMem[2], (int)v11.name, v11.size, v11.time_create);
v13 = 5;
if ( *(_DWORD *)&lpMem[2] )
{
if ( (unsigned int)(v9 - *(_DWORD *)&lpMem[2]) <= 0x80 )
sub_403980(*(int *)&lpMem[2], v9 - *(_DWORD *)&lpMem[2]);
else
sub_40565F(*(LPVOID *)&lpMem[2]);
}
}
v13 = -1;
}
}
return result;
}
//----- (004027E0) --------------------------------------------------------
void __cdecl sub_4027E0(int a1)
{
FILE *v1; // ebx@1
__int32 v2; // ebp@1
__int32 v3; // edi@8
void *v4; // ebp@8
unsigned int v5; // kr08_4@9
__int32 v6; // esi@11
__int16 v7; // dx@11
void *i; // ecx@11
void *v9; // ecx@13
__int16 j; // dx@13
LPVOID v11; // eax@15
void *v12; // esi@15
void *v13; // ecx@16
LPVOID lpMem; // [sp+10h] [bp-94Ch]@1
char v15; // [sp+17h] [bp-945h]@1
int v16; // [sp+18h] [bp-944h]@11
int v17; // [sp+1Ch] [bp-940h]@11
__int32 v18; // [sp+20h] [bp-93Ch]@11
__int32 v19; // [sp+24h] [bp-938h]@11
__int16 v20; // [sp+28h] [bp-934h]@11
int v21; // [sp+2Ch] [bp-930h]@9
int v22; // [sp+30h] [bp-92Ch]@11
__int32 v23; // [sp+34h] [bp-928h]@8
struct _finddata_t v24; // [sp+38h] [bp-924h]@1
char v25; // [sp+150h] [bp-80Ch]@1
char v26; // [sp+550h] [bp-40Ch]@9
int v27; // [sp+958h] [bp-4h]@1
v27 = 0;
sub_4031D0(&lpMem, (int)&v15);
LOBYTE(v27) = 2;
sprintf(&v25, aS_mrs, a1);
v1 = fopen(&v25, aWb);
sprintf(&v25, aS_, a1);
v2 = _findfirst(&v25, &v24);
if ( v2 != -1 )
{
do
{
if ( strcmp(v24.name, a_) && strcmp(v24.name, a__) )
{
if ( v24.attrib & 0x10 )
sub_402520(v1, (int)&lpMem, a1, (int)&unk_412DA0, (int)v24.name);
else
sub_401F00(v1, (int)&lpMem, a1, (int)&unk_412DA0, (int)v24.name, v24.size, v24.time_create);
}
}
while ( _findnext(v2, &v24) != -1 );
}
v3 = ftell(v1);
v23 = v3;
v4 = *(void **)lpMem;
if ( *(LPVOID *)lpMem != lpMem )
{
do
{
v21 = 33639248;
sub_401120((int)&v21, 4u);
fwrite(&v21, 4u, 1u, v1);
sub_401120((int)((char *)v4 + 8), 0x2Au);
fwrite((char *)v4 + 8, 1u, 0x2Au, v1);
strcpy(&v26, (const char *)v4 + 50);
v5 = strlen(&v26) + 1;
sub_401120((int)&v26, v5 - 1);
fwrite(&v26, 1u, v5 - 1, v1);
v4 = *(void **)v4;
}
while ( v4 != lpMem );
v3 = v23;
}
v6 = ftell(v1);
v22 = 84083208;
sub_401120((int)&v22, 4u);
fwrite(&v22, 4u, 1u, v1);
v7 = 0;
v17 = 0;
v16 = 0;
v18 = 0;
v19 = 0;
v20 = 0;
for ( i = *(void **)lpMem; i != lpMem; ++v7 )
i = *(void **)i;
LOWORD(v17) = v7;
v9 = *(void **)lpMem;
for ( j = 0; v9 != lpMem; ++j )
v9 = *(void **)v9;
HIWORD(v17) = j;
v18 = v6 - v3;
v19 = v3;
v20 = 0;
sub_401120((int)&v16, 0x12u);
fwrite(&v16, 1u, 0x12u, v1);
fclose(v1);
v11 = lpMem;
v12 = *(void **)lpMem;
while ( v12 != v11 )
{
v13 = v12;
v12 = *(void **)v12;
if ( v13 )
{
sub_40565F(v13);
v11 = lpMem;
}
}
*(_DWORD *)v11 = v11;
*((_DWORD *)lpMem + 1) = lpMem;
if ( lpMem )
sub_40565F(lpMem);
}
//----- (00402B20) --------------------------------------------------------
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax@2
if ( argc >= 3 )
{
result = *argv[1];
switch ( result )
{
case 76:
case 108:
LOBYTE(result) = sub_401B50((char *)argv[2], 0);
break;
case 68:
case 69:
case 88:
case 100:
case 101:
case 120:
LOBYTE(result) = sub_4013D0((char *)argv[2], 0);
break;
case 65:
case 67:
case 97:
case 99:
sub_4027E0((int)argv[2]);
break;
default:
result = printf(aUnknownOption);
break;
case 90:
case 122:
return result;
}
}
else
{
printf(asc_4102D8);
printf(a_mrsFilesPacke);
printf(asc_4102D8);
printf(aUsageMrs_exeDC);
printf(aDDecompressArc);
printf(aCCompressDirec);
printf(aExamples);
printf(aMrs_exeDSystem);
printf(aUnpackSystem_m);
printf(aMrs_exeCSystem);
printf(aMakeSystem_mrs);
printf(aWarning);
printf(aDonTLeaveUnpac);
result = printf(asc_4102D8);
}
return result;
}
//----- (00402C90) --------------------------------------------------------
void __thiscall sub_402C90(int this)
{
void *v1; // eax@1
int v2; // ecx@1
unsigned int v3; // ecx@4
v1 = *(void **)this;
v2 = *(_DWORD *)(this + 8) - *(_DWORD *)this;
if ( v1 )
{
if ( (unsigned int)v2 <= 0x80 )
{
v3 = (unsigned int)(v2 - 1) >> 3;
*(_DWORD *)v1 = dword_412DA4[v3];
dword_412DA4[v3] = (int)v1;
}
else
{
sub_40565F(v1);
}
}
}
// 412DA4: using guessed type int dword_412DA4[];
//----- (00402CD0) --------------------------------------------------------
int __thiscall sub_402CD0(void *this, int a2)
{
int v2; // edi@1
int v3; // ecx@2
int v4; // eax@2
void *v5; // esi@2
char v6; // dl@4
const void *v7; // ebx@7
v2 = (int)this;
if ( (void *)a2 != this )
{
v3 = *(_DWORD *)(a2 + 4);
v4 = *(_DWORD *)a2;
v5 = *(void **)v2;
if ( *(_DWORD *)a2 == v3 )
goto LABEL_7;
while ( v5 != *(void **)(v2 + 4) )
{
v6 = *(_BYTE *)v4++;
*(_BYTE *)v5 = v6;
v5 = (char *)v5 + 1;
if ( v4 == v3 )
goto LABEL_7;
}
if ( v4 != v3 )
{
sub_403F50(v2, v4, v3, (int)&a2);
}
else
{
LABEL_7:
v7 = *(const void **)(v2 + 4);
if ( v5 != v7 )
{
memcpy(v5, v7, 1u);
*(_DWORD *)(v2 + 4) += (_BYTE *)v5 - (_BYTE *)v7;
return v2;
}
}
}
return v2;
}
//----- (00402D50) --------------------------------------------------------
int __thiscall sub_402D50(int this, int a2, unsigned int a3, unsigned int a4)
{
int v4; // ebp@1
int v5; // ecx@1
int v6; // ecx@4
bool v7; // cf@4
int *v8; // ecx@4
int v9; // edi@6
int v10; // ebp@6
int v11; // edi@6
int v12; // eax@6
void *v13; // eax@9
int v14; // ebx@11
int v15; // eax@11
int v16; // eax@11
int v18; // eax@12
int v19; // [sp-8h] [bp-144h]@8
char v20; // [sp+Fh] [bp-12Dh]@2
int v21; // [sp+10h] [bp-12Ch]@1
int v22; // [sp+17h] [bp-125h]@2
int (__thiscall **v23)(LPVOID, char); // [sp+24h] [bp-118h]@2
int v24; // [sp+138h] [bp-4h]@2
v4 = *(_DWORD *)this;
v5 = *(_DWORD *)(this + 4) - *(_DWORD *)this;
v21 = 0;
if ( a3 > v5 )
{
v24 = 0;
sub_4039D0((int)((char *)&v22 + 1), (int)&v20);
LOBYTE(v24) = 1;
sub_403B40((char *)&v22 + 1, aBasic_string, (int)&aBasic_string[strlen(aBasic_string)]);
LOBYTE(v24) = 2;
sub_402F10((int)&v23, (const char **)((char *)&v22 + 1));
v23 = &off_40E508;
_CxxThrowException(&v23, &unk_40EFA0);
}
v6 = v5 - a3;
v21 = v6;
v7 = v6 < a4;
v8 = &v21;
if ( !v7 )
v8 = (int *)&a4;
v9 = v4 + *v8;
v10 = a3 + v4;
*(_DWORD *)a2 = 0;
*(_DWORD *)(a2 + 4) = 0;
v11 = a3 + v9;
*(_DWORD *)(a2 + 8) = 0;
v24 = 3;
v12 = v11 - v10 + 1;
v21 = v11 - v10 + 1;
if ( (unsigned int)v12 > 0xFFFFFFFF || (unsigned int)v12 <= 0 )
{
LOBYTE(v24) = 4;
v18 = sub_4032F0((int)((char *)&v22 + 1), aBasic_string, (int)&v22);
LOBYTE(v24) = 5;
sub_402F60((int)&v23, (const char **)v18);
_CxxThrowException(&v23, &unk_40EF90);
}
v19 = v11 - v10 + 1;
if ( (unsigned int)v12 <= 0x80 )
v13 = (void *)sub_4037C0(v19);
else
v13 = sub_402EF0(v19);
v14 = (int)v13;
v15 = v21;
*(_DWORD *)a2 = v14;
*(_DWORD *)(a2 + 4) = v14;
*(_DWORD *)(a2 + 8) = v14 + v15;
sub_404460();
sub_403EC0((int)&v20);
v16 = sub_404470(v10, v11, v14);
*(_DWORD *)(a2 + 4) = v16;
*(_BYTE *)v16 = 0;
return a2;
}
// 405E15: using guessed type _DWORD __stdcall _CxxThrowException(_DWORD, _DWORD);
// 40E508: using guessed type int (__thiscall *off_40E508)(LPVOID lpMem, char);
//----- (00402EF0) --------------------------------------------------------
void *__cdecl sub_402EF0(unsigned int a1)
{
return operator new(a1);
}
//----- (00402F00) --------------------------------------------------------
int __thiscall sub_402F00(void *this)
{
return (int)((char *)this + 12);
}
//----- (00402F10) --------------------------------------------------------
int __thiscall sub_402F10(int this, const char **a2)
{
int v2; // esi@1
v2 = this;
sub_405D4A(this);
*(_DWORD *)v2 = &off_40E518;
strncpy((char *)(v2 + 12), *a2, 0x100u);
*(_BYTE *)(v2 + 267) = 0;
*(_DWORD *)v2 = &off_40E510;
return v2;
}
// 40E510: using guessed type int (__thiscall *off_40E510)(LPVOID lpMem, char);
// 40E518: using guessed type int (__thiscall *off_40E518)(LPVOID lpMem, char);
//----- (00402F60) --------------------------------------------------------
int __thiscall sub_402F60(int this, const char **a2)
{
int v2; // esi@1
v2 = this;
sub_405D4A(this);
*(_DWORD *)v2 = &off_40E518;
strncpy((char *)(v2 + 12), *a2, 0x100u);
*(_BYTE *)(v2 + 267) = 0;
*(_DWORD *)v2 = &off_40E520;
return v2;
}
// 40E518: using guessed type int (__thiscall *off_40E518)(LPVOID lpMem, char);
// 40E520: using guessed type int (__thiscall *off_40E520)(LPVOID lpMem, char);
//----- (00402FA0) --------------------------------------------------------
LPVOID __thiscall sub_402FA0(LPVOID lpMem, char a2)
{
LPVOID v2; // esi@1
v2 = lpMem;
sub_402F50();
if ( a2 & 1 )
sub_40565F(v2);
return v2;
}
// 402F50: using guessed type int sub_402F50(void);
//----- (004030C0) --------------------------------------------------------
int __thiscall sub_4030C0(int this, void *a2)
{
return sub_4040F0(this, a2, (int)((char *)a2 + strlen((const char *)a2)), (int)&a2);
}
//----- (00403100) --------------------------------------------------------
int __thiscall sub_403100(int this, const void *a2, int a3)
{
int v3; // ebp@1
int v4; // ebx@1
void *v5; // edi@1
unsigned int v6; // eax@1
unsigned int v7; // ecx@1
const void *v8; // edi@2
void *v9; // esi@2
v3 = a3;
v4 = this;
v5 = *(void **)this;
v6 = a3 - (_DWORD)a2;
v7 = *(_DWORD *)(this + 4) - *(_DWORD *)this;
if ( a3 - (signed int)a2 > v7 )
{
qmemcpy(v5, a2, v7);
sub_4040F0(v4, (char *)a2 + *(_DWORD *)(v4 + 4) - *(_DWORD *)v4, v3, (int)&a3);
}
else
{
qmemcpy(v5, a2, v6);
v8 = *(const void **)(v4 + 4);
v9 = (void *)(v6 + *(_DWORD *)v4);
if ( v9 != v8 )
{
memcpy(v9, v8, 1u);
*(_DWORD *)(v4 + 4) += (_BYTE *)v9 - (_BYTE *)v8;
return v4;
}
}
return v4;
}
//----- (004031A0) --------------------------------------------------------
int __stdcall sub_4031A0(int a1, int a2, const void *a3)
{
void *v3; // eax@1
int v4; // edx@1
v3 = sub_403270(a3);
v4 = *(_DWORD *)(a2 + 4);
*(_DWORD *)v3 = a2;
*((_DWORD *)v3 + 1) = v4;
*(_DWORD *)v4 = v3;
*(_DWORD *)(a2 + 4) = v3;
*(_DWORD *)a1 = v3;
return a1;
}
//----- (004031D0) --------------------------------------------------------
void *__thiscall sub_4031D0(void *this, int a2)
{
void *v2; // esi@1
void *v3; // eax@1
v2 = this;
*(_DWORD *)this = 0;
v3 = operator new(0x434u);
*(_DWORD *)v3 = v3;
*((_DWORD *)v3 + 1) = v3;
*(_DWORD *)v2 = v3;
return v2;
}
//----- (00403240) --------------------------------------------------------
void __thiscall sub_403240(int this)
{
if ( *(_DWORD *)this )
{
if ( (unsigned int)(*(_DWORD *)(this + 8) - *(_DWORD *)this) <= 0x80 )
sub_403980(*(_DWORD *)this, *(_DWORD *)(this + 8) - *(_DWORD *)this);
else
sub_40565F(*(LPVOID *)this);
}
}
//----- (00403270) --------------------------------------------------------
void *__stdcall sub_403270(const void *a1)
{
void *result; // eax@1
result = operator new(0x434u);
if ( result != (void *)-8 )
qmemcpy((char *)result + 8, a1, 0x42Au);
return result;
}
//----- (004032C0) --------------------------------------------------------
void __stdcall sub_4032C0(LPVOID lpMem, int a2)
{
if ( lpMem )
{
if ( (unsigned int)a2 <= 0x80 )
sub_403980((int)lpMem, a2);
else
sub_40565F(lpMem);
}
}
//----- (004032F0) --------------------------------------------------------
int __thiscall sub_4032F0(int this, void *a2, int a3)
{
int v3; // esi@1
unsigned int v4; // kr04_4@1
unsigned int v5; // ecx@1
char *v6; // eax@4
void *v7; // eax@5
const char **v9; // eax@12
char v10[5]; // [sp+13h] [bp-131h]@1
void *v11; // [sp+18h] [bp-12Ch]@5
int v12; // [sp+1Ch] [bp-128h]@1
char v13; // [sp+2Ch] [bp-118h]@12
int v14; // [sp+140h] [bp-4h]@1
v3 = this;
*(_DWORD *)this = 0;
*(_DWORD *)(this + 4) = 0;
v12 = this;
*(_DWORD *)(this + 8) = 0;
v4 = strlen((const char *)a2) + 1;
v14 = 0;
v5 = v4 - 1;
*(_DWORD *)&v10[1] = v4 - 1;
if ( v4 > 0xFFFFFFFF || v4 <= 0 )
{
LOBYTE(v14) = 2;
v9 = (const char **)sub_4032F0(aBasic_string, (int)v10);
LOBYTE(v14) = 3;
sub_402F60((int)&v13, v9);
_CxxThrowException(&v13, &unk_40EF90);
}
if ( v4 <= 0x80 )
{
v7 = (void *)dword_412DA4[v5 >> 3];
LOBYTE(v14) = 1;
v11 = v7;
if ( v7 )
{
dword_412DA4[(v4 - 1) >> 3] = *(_DWORD *)v7;
v6 = (char *)v11;
goto LABEL_9;
}
v6 = (char *)sub_403D20(v4);
}
else
{
v6 = (char *)operator new(v4);
}
v5 = *(_DWORD *)&v10[1];
LABEL_9:
*(_DWORD *)v3 = v6;
*(_DWORD *)(v3 + 4) = v6;
*(_DWORD *)(v3 + 8) = &v6[v4];
if ( (char *)a2 + v4 - 1 != a2 )
v6 = (char *)memcpy(v6, a2, v5) + *(_DWORD *)&v10[1];
*(_DWORD *)(v3 + 4) = v6;
*v6 = 0;
return v3;
}
// 405E15: using guessed type _DWORD __stdcall _CxxThrowException(_DWORD, _DWORD);
// 412DA4: using guessed type int dword_412DA4[];
//----- (00403420) --------------------------------------------------------
int __thiscall sub_403420(int this, int a2, unsigned int a3, int a4)
{
int v4; // edi@1
int v5; // ecx@1
int result; // eax@2
int v7; // edx@3
int v8; // esi@4
int v9; // eax@5
int v10; // eax@9
v4 = *(_DWORD *)(this + 4);
v5 = *(_DWORD *)this;
if ( a3 < v4 - v5 )
{
v7 = v5 + a3;
if ( v5 + a3 == v4 )
{
LABEL_9:
v10 = v4;
}
else
{
v8 = a4 + a2;
while ( 1 )
{
v9 = a2;
if ( a2 != v8 )
break;
LABEL_8:
++v7;
if ( v7 == v4 )
goto LABEL_9;
}
while ( *(_BYTE *)v7 != *(_BYTE *)v9 )
{
++v9;
if ( v9 == v8 )
goto LABEL_8;
}
v10 = v7;
}
if ( v10 == v4 )
result = -1;
else
result = v10 - v5;
}
else
{
result = -1;
}
return result;
}
//----- (00403480) --------------------------------------------------------
int __thiscall sub_403480(void *this, int a2, unsigned int a3, int a4)
{
void *v4; // esi@1
int v5; // ecx@1
int v6; // eax@1
int result; // eax@2
int v8; // eax@3
bool v9; // cf@3
int *v10; // eax@3
int v11; // edi@5
int v12; // ecx@5
int v13; // ST04_4@5
int v14; // esi@5
int v15; // [sp-18h] [bp-1Ch]@5
int v16; // [sp-14h] [bp-18h]@5
int v17; // [sp-10h] [bp-14h]@5
unsigned int v18; // [sp-Ch] [bp-10h]@5
void *v19; // [sp+0h] [bp-4h]@1
v19 = this;
v4 = this;
v5 = *(_DWORD *)this;
v6 = *((_DWORD *)v4 + 1) - v5;
if ( (unsigned int)v6 >= 1 )
{
v8 = v6 - 1;
v19 = (void *)v8;
v9 = a3 < v8;
v10 = (int *)&a3;
if ( !v9 )
v10 = (int *)&v19;
v11 = v5 + *v10 + 1;
v18 = a3;
v17 = a2 + a4;
v16 = a2;
v15 = a2 + a4;
sub_4039C0(v4, (int)&v15);
v13 = v12;
unknown_libname_1(v11);
sub_403BC0((int)&a3, v13, v15, v16, v17);
v14 = *(_DWORD *)v4;
if ( a3 == v14 )
result = -1;
else
result = a3 - v14 - 1;
}
else
{
result = -1;
}
return result;
}
// 4039E0: using guessed type _DWORD __stdcall unknown_libname_1(_DWORD);
//----- (00403510) --------------------------------------------------------
int __cdecl sub_403510(int a1, int a2, const char *a3)
{
void *v3; // ebp@1
unsigned int v4; // kr04_4@1
int v5; // edi@1
int v6; // eax@1
int v7; // edx@1
int v8; // ecx@1
int v9; // esi@1
int v10; // eax@1
int v11; // ST00_4@1
char v13; // [sp+13h] [bp-1Dh]@1
int v14; // [sp+14h] [bp-1Ch]@1
LPVOID lpMem; // [sp+18h] [bp-18h]@1
int v16; // [sp+1Ch] [bp-14h]@1
int v17; // [sp+20h] [bp-10h]@1
int v18; // [sp+2Ch] [bp-4h]@1
v3 = (void *)a3;
v4 = strlen(a3) + 1;
v5 = a2;
v14 = 0;
v6 = sub_4039A0((int)&a2);
v7 = *(_DWORD *)v5;
v8 = *(_DWORD *)(v5 + 4);
v18 = 1;
v9 = v8 + v4 - 1 - v7;
lpMem = 0;
v16 = 0;
sub_4039F0(&v17, v6, 0);
LOBYTE(v18) = 2;
sub_403A00(&lpMem, v9 + 1);
*(_BYTE *)v16 = 0;
v10 = *(_DWORD *)(v5 + 4);
v11 = *(_DWORD *)v5;
LOBYTE(v18) = 4;
sub_403F50((int)&lpMem, v11, v10, (int)&a3);
sub_4040F0((int)&lpMem, v3, (int)((char *)v3 + v4 - 1), (int)&a3);
sub_4039A0((int)&v13);
*(_DWORD *)a1 = 0;
*(_DWORD *)(a1 + 4) = 0;
*(_DWORD *)(a1 + 8) = 0;
LOBYTE(v18) = 5;
sub_4043B0((void *)a1, (int)lpMem, v16, (int)&a3);
v14 = 1;
LOBYTE(v18) = 0;
if ( lpMem )
sub_403650(lpMem, v17 - (_DWORD)lpMem);
return a1;
}
//----- (00403650) --------------------------------------------------------
void __cdecl sub_403650(LPVOID lpMem, int a2)
{
if ( (unsigned int)a2 <= 0x80 )
sub_403980((int)lpMem, a2);
else
sub_40565F(lpMem);
}
//----- (00403680) --------------------------------------------------------
int __cdecl sub_403680(int a1, int a2, int a3)
{
int v3; // edi@1
int v4; // ebp@1
int v5; // ecx@1
int v6; // eax@1
int v7; // esi@1
int v8; // esi@1
int v9; // eax@1
int v10; // ST00_4@1
int v11; // edi@1
int v12; // ebp@1
int v13; // eax@1
LPVOID lpMem; // [sp+14h] [bp-18h]@1
int v16; // [sp+18h] [bp-14h]@1
int v17; // [sp+1Ch] [bp-10h]@1
int v18; // [sp+28h] [bp-4h]@1
v3 = a2;
v4 = a3;
v18 = 1;
v5 = *(_DWORD *)a3;
v6 = *(_DWORD *)(a2 + 4);
v7 = *(_DWORD *)(a3 + 4) - *(_DWORD *)a2;
lpMem = 0;
v8 = v6 + v7 - v5;
v16 = 0;
sub_4039F0(&v17, (int)&a3, 0);
LOBYTE(v18) = 2;
sub_403A00(&lpMem, v8 + 1);
*(_BYTE *)v16 = 0;
v9 = *(_DWORD *)(v3 + 4);
v10 = *(_DWORD *)v3;
LOBYTE(v18) = 4;
sub_403F50((int)&lpMem, v10, v9, (int)&a2);
sub_403F50((int)&lpMem, *(_DWORD *)v4, *(_DWORD *)(v4 + 4), (int)&a2);
sub_4039A0((int)&a2);
*(_DWORD *)a1 = 0;
*(_DWORD *)(a1 + 4) = 0;
*(_DWORD *)(a1 + 8) = 0;
v11 = v16;
v12 = (int)lpMem;
LOBYTE(v18) = 5;
sub_403A00((void *)a1, v16 - (_DWORD)lpMem + 1);
v13 = sub_404430(v12, v11, *(_DWORD *)a1);
*(_DWORD *)(a1 + 4) = v13;
*(_BYTE *)v13 = 0;
LOBYTE(v18) = 0;
if ( lpMem )
sub_403650(lpMem, v17 - (_DWORD)lpMem);
return a1;
}
//----- (004037C0) --------------------------------------------------------
int __cdecl sub_4037C0(signed int a1)
{
int result; // eax@1
unsigned int v2; // eax@3
unsigned int v3; // esi@3
int v4; // ebx@3
unsigned int v5; // ebx@7
unsigned int v6; // eax@8
void *v7; // eax@9
unsigned int v8; // ecx@10
unsigned int v9; // eax@11
int v10; // edx@11
int v11; // eax@11
signed int v12; // edi@17
int v13; // edx@17
int v14; // ecx@17
result = dword_412DA4[(unsigned int)(a1 - 1) >> 3];
if ( result )
{
dword_412DA4[(unsigned int)(a1 - 1) >> 3] = *(_DWORD *)result;
return result;
}
v2 = dword_412DEC - dword_412DE8;
v3 = (a1 + 7) & 0xFFFFFFF8;
v4 = 20;
a1 = 20;
if ( dword_412DEC - dword_412DE8 < 20 * v3 )
{
if ( v2 >= v3 )
{
v4 = v2 / v3;
result = dword_412DE8;
a1 = v4;
dword_412DE8 += v3 * v4;
goto LABEL_16;
}
v5 = ((((unsigned int)dword_412DE4 >> 4) + 7) & 0xFFFFFFF8) + 40 * v3;
if ( dword_412DEC != dword_412DE8 )
{
v6 = (v2 - 1) >> 3;
*(_DWORD *)dword_412DE8 = dword_412DA4[v6];
dword_412DA4[v6] = dword_412DE8;
}
v7 = operator new(v5);
dword_412DE8 = (int)v7;
if ( !v7 )
{
v8 = v3;
if ( v3 <= 0x80 )
{
while ( 1 )
{
v9 = (v8 - 1) >> 3;
v10 = 4 * v9 + 4271524;
v11 = dword_412DA4[v9];
if ( v11 )
break;
v8 += 8;
if ( v8 > 0x80 )
goto LABEL_13;
}
*(_DWORD *)v10 = *(_DWORD *)v11;
dword_412DE8 = v11;
dword_412DEC = v8 + v11;
result = sub_404280(v3, (int)&a1);
goto LABEL_15;
}
LABEL_13:
dword_412DEC = 0;
v7 = operator new(v5);
dword_412DE8 = (int)v7;
}
dword_412DE4 += v5;
dword_412DEC = (int)((char *)v7 + v5);
result = sub_404280(v3, (int)&a1);
LABEL_15:
v4 = a1;
LABEL_16:
if ( v4 == 1 )
return result;
goto LABEL_17;
}
result = dword_412DE8;
dword_412DE8 += 20 * v3;
LABEL_17:
v12 = 1;
dword_412DA4[(v3 - 1) >> 3] = result + v3;
v13 = result + v3;
v14 = v3 + result + v3;
if ( v4 != 2 )
{
do
{
*(_DWORD *)v13 = v14;
v13 = v14;
++v12;
v14 += v3;
}
while ( a1 - 1 != v12 );
}
*(_DWORD *)v13 = 0;
return result;
}
// 412DA4: using guessed type int dword_412DA4[];
// 412DE4: using guessed type int dword_412DE4;
// 412DE8: using guessed type int dword_412DE8;
// 412DEC: using guessed type int dword_412DEC;
//----- (00403980) --------------------------------------------------------
int __cdecl sub_403980(int a1, int a2)
{
unsigned int v2; // eax@1
int v3; // edx@1
int result; // eax@1
v2 = (unsigned int)(a2 - 1) >> 3;
v3 = dword_412DA4[v2];
result = 4 * v2 + 4271524;
*(_DWORD *)a1 = v3;
*(_DWORD *)result = a1;
return result;
}
// 412DA4: using guessed type int dword_412DA4[];
//----- (004039A0) --------------------------------------------------------
int __stdcall sub_4039A0(int a1)
{
return a1;
}
//----- (004039C0) --------------------------------------------------------
int __thiscall sub_4039C0(void *this, int a2)
{
int result; // eax@1
result = a2;
*(_DWORD *)a2 = *(_DWORD *)this;
return result;
}
//----- (004039D0) --------------------------------------------------------
int __thiscall sub_4039D0(int this, int a2)
{
int result; // eax@1
result = this;
*(_DWORD *)this = 0;
*(_DWORD *)(this + 4) = 0;
*(_DWORD *)(this + 8) = 0;
return result;
}
//----- (004039F0) --------------------------------------------------------
void *__thiscall sub_4039F0(void *this, int a2, int a3)
{
void *result; // eax@1
result = this;
*(_DWORD *)this = a3;
return result;
}
//----- (00403A00) --------------------------------------------------------
int __thiscall sub_403A00(void *this, signed int a2)
{
void *v2; // edi@1
void *v3; // eax@4
int result; // eax@4
int v5; // eax@5
v2 = this;
if ( (unsigned int)a2 > 0xFFFFFFFF || !a2 )
sub_403A60(aBasic_string);
if ( (unsigned int)a2 <= 0x80 )
{
v5 = sub_4037C0(a2);
*(_DWORD *)v2 = v5;
*((_DWORD *)v2 + 1) = v5;
result = a2 + v5;
*((_DWORD *)v2 + 2) = result;
}
else
{
v3 = operator new(a2);
*(_DWORD *)v2 = v3;
*((_DWORD *)v2 + 1) = v3;
result = (int)((char *)v3 + a2);
*((_DWORD *)v2 + 2) = result;
}
return result;
}
//----- (00403A60) --------------------------------------------------------
void __cdecl __noreturn sub_403A60(void *a1)
{
signed int v1; // kr04_4@1
char v2; // [sp+13h] [bp-125h]@1
char *v3; // [sp+14h] [bp-124h]@1
char *v4; // [sp+18h] [bp-120h]@1
char v5; // [sp+1Ch] [bp-11Ch]@1
int (__thiscall **v6)(LPVOID, char); // [sp+20h] [bp-118h]@1
char v7; // [sp+2Ch] [bp-10Ch]@1
char v8; // [sp+12Bh] [bp-Dh]@2
int v9; // [sp+134h] [bp-4h]@1
v9 = 0;
v3 = 0;
v4 = 0;
sub_4039F0(&v5, (int)&v2, 0);
v1 = strlen((const char *)a1) + 1;
LOBYTE(v9) = 1;
sub_403A00(&v3, v1);
v4 = sub_401ED0(a1, (int)((char *)a1 + v1 - 1), v3);
*v4 = 0;
LOBYTE(v9) = 2;
sub_405D4A((int)&v6);
v6 = &off_40E518;
strncpy(&v7, v3, 0x100u);
v8 = 0;
v6 = &off_40E520;
_CxxThrowException(&v6, &unk_40EF90);
}
// 405E15: using guessed type _DWORD __stdcall _CxxThrowException(_DWORD, _DWORD);
// 40E518: using guessed type int (__thiscall *off_40E518)(LPVOID lpMem, char);
// 40E520: using guessed type int (__thiscall *off_40E520)(LPVOID lpMem, char);
//----- (00403B40) --------------------------------------------------------
char *__thiscall sub_403B40(void *this, void *a2, int a3)
{
void *v3; // esi@1
int v4; // ebx@1
void *v5; // eax@4
int v6; // eax@5
char *result; // eax@7
int v8; // [sp-4h] [bp-14h]@3
v3 = this;
v4 = a3 - (_DWORD)a2 + 1;
if ( (unsigned int)v4 > 0xFFFFFFFF || a3 - (_DWORD)a2 == -1 )
sub_403A60(aBasic_string);
v8 = a3 - (_DWORD)a2 + 1;
if ( (unsigned int)v4 <= 0x80 )
{
v6 = sub_4037C0(v8);
*(_DWORD *)v3 = v6;
*((_DWORD *)v3 + 1) = v6;
*((_DWORD *)v3 + 2) = v4 + v6;
}
else
{
v5 = operator new(v8);
*(_DWORD *)v3 = v5;
*((_DWORD *)v3 + 1) = v5;
*((_DWORD *)v3 + 2) = (char *)v5 + v4;
}
result = *(char **)v3;
if ( (void *)a3 != a2 )
result = (char *)memcpy(result, a2, a3 - (_DWORD)a2) + a3 - (_DWORD)a2;
*((_DWORD *)v3 + 1) = result;
*result = 0;
return result;
}
//----- (00403BC0) --------------------------------------------------------
int __cdecl sub_403BC0(int a1, int a2, int a3, int a4, int a5)
{
int v5; // esi@1
int v6; // eax@2
int result; // eax@6
v5 = a2;
if ( a2 == a3 )
{
LABEL_6:
result = a1;
*(_DWORD *)a1 = a3;
}
else
{
while ( 1 )
{
v6 = a4;
if ( a4 != a5 )
break;
LABEL_5:
--v5;
if ( v5 == a3 )
goto LABEL_6;
}
while ( *(_BYTE *)(v5 - 1) != *(_BYTE *)v6 )
{
++v6;
if ( v6 == a5 )
goto LABEL_5;
}
result = a1;
*(_DWORD *)a1 = v5;
}
return result;
}
//----- (00403C10) --------------------------------------------------------
BOOL __cdecl sub_403C10(int a1, const char *a2)
{
unsigned int v2; // ecx@1
v2 = strlen(a2);
return *(_DWORD *)(a1 + 4) - *(_DWORD *)a1 == v2 && !memcmp(*(const void **)a1, a2, v2);
}
//----- (00403C50) --------------------------------------------------------
int __thiscall sub_403C50(void *this, int a2, int a3, int a4)
{
int v4; // eax@1
int v5; // edi@1
int v6; // ecx@1
void *v7; // esi@1
char v8; // dl@3
const void *v9; // ebx@6
v4 = a2;
v5 = (int)this;
v6 = a3;
v7 = *(void **)v5;
if ( a2 == a3 )
goto LABEL_6;
while ( v7 != *(void **)(v5 + 4) )
{
v8 = *(_BYTE *)v4++;
*(_BYTE *)v7 = v8;
v7 = (char *)v7 + 1;
if ( v4 == v6 )
goto LABEL_6;
}
if ( v4 != v6 )
{
sub_403F50(v5, v4, v6, (int)&a2);
}
else
{
LABEL_6:
v9 = *(const void **)(v5 + 4);
if ( v7 != v9 )
{
memcpy(v7, v9, 1u);
*(_DWORD *)(v5 + 4) += (_BYTE *)v7 - (_BYTE *)v9;
return v5;
}
}
return v5;
}
//----- (00403CC0) --------------------------------------------------------
int __thiscall sub_403CC0(int this, int a2, int a3, int a4)
{
char v5; // [sp+1h] [bp-1h]@1
v5 = a3;
return sub_403F50(this, a2, a3, (int)&v5);
}
//----- (00403CF0) --------------------------------------------------------
int __thiscall sub_403CF0(int this, void *a2, int a3, int a4)
{
char v5; // [sp+1h] [bp-1h]@1
v5 = a3;
return sub_4040F0(this, a2, a3, (int)&v5);
}
//----- (00403D20) --------------------------------------------------------
int __cdecl sub_403D20(int a1)
{
unsigned int v1; // esi@1
unsigned int v2; // eax@1
int v3; // ebx@1
int result; // eax@2
unsigned int v5; // ebx@5
unsigned int v6; // eax@6
void *v7; // eax@7
unsigned int v8; // ecx@8
unsigned int v9; // eax@9
int v10; // edx@9
int v11; // eax@9
signed int v12; // edi@15
int v13; // edx@15
int v14; // ecx@15
int v15; // [sp+0h] [bp-4h]@1
v1 = (a1 + 7) & 0xFFFFFFF8;
v2 = dword_412DEC - dword_412DE8;
v3 = 20;
v15 = 20;
if ( dword_412DEC - dword_412DE8 < 20 * v1 )
{
if ( v2 >= v1 )
{
v3 = v2 / v1;
result = dword_412DE8;
v15 = v3;
dword_412DE8 += v1 * v3;
goto LABEL_14;
}
v5 = ((((unsigned int)dword_412DE4 >> 4) + 7) & 0xFFFFFFF8) + 40 * v1;
if ( dword_412DEC != dword_412DE8 )
{
v6 = (v2 - 1) >> 3;
*(_DWORD *)dword_412DE8 = dword_412DA4[v6];
dword_412DA4[v6] = dword_412DE8;
}
v7 = operator new(v5);
dword_412DE8 = (int)v7;
if ( !v7 )
{
v8 = (a1 + 7) & 0xFFFFFFF8;
if ( v1 <= 0x80 )
{
while ( 1 )
{
v9 = (v8 - 1) >> 3;
v10 = 4 * v9 + 4271524;
v11 = dword_412DA4[v9];
if ( v11 )
break;
v8 += 8;
if ( v8 > 0x80 )
goto LABEL_11;
}
*(_DWORD *)v10 = *(_DWORD *)v11;
dword_412DE8 = v11;
dword_412DEC = v8 + v11;
result = sub_404280(v1, (int)&v15);
goto LABEL_13;
}
LABEL_11:
dword_412DEC = 0;
v7 = operator new(v5);
dword_412DE8 = (int)v7;
}
dword_412DE4 += v5;
dword_412DEC = (int)((char *)v7 + v5);
result = sub_404280(v1, (int)&v15);
LABEL_13:
v3 = v15;
LABEL_14:
if ( v3 == 1 )
return result;
goto LABEL_15;
}
result = dword_412DE8;
dword_412DE8 += 20 * v1;
LABEL_15:
v12 = 1;
dword_412DA4[(v1 - 1) >> 3] = result + v1;
v13 = result + v1;
v14 = v1 + result + v1;
if ( v3 != 2 )
{
do
{
*(_DWORD *)v13 = v14;
v13 = v14;
++v12;
v14 += v1;
}
while ( v15 - 1 != v12 );
}
*(_DWORD *)v13 = 0;
return result;
}
// 412DA4: using guessed type int dword_412DA4[];
// 412DE4: using guessed type int dword_412DE4;
// 412DE8: using guessed type int dword_412DE8;
// 412DEC: using guessed type int dword_412DEC;
//----- (00403EC0) --------------------------------------------------------
int __cdecl sub_403EC0(int a1)
{
int result; // eax@1
result = a1;
*(_BYTE *)a1 = a1;
return result;
}
//----- (00403ED0) --------------------------------------------------------
char *__thiscall sub_403ED0(void *this, void *a2, int a3, int a4)
{
void *v4; // esi@1
int v5; // ebx@1
void *v6; // eax@4
int v7; // eax@5
char *result; // eax@7
int v9; // [sp-4h] [bp-14h]@3
v4 = this;
v5 = a3 - (_DWORD)a2 + 1;
if ( (unsigned int)v5 > 0xFFFFFFFF || a3 - (_DWORD)a2 == -1 )
sub_403A60(aBasic_string);
v9 = a3 - (_DWORD)a2 + 1;
if ( (unsigned int)v5 <= 0x80 )
{
v7 = sub_4037C0(v9);
*(_DWORD *)v4 = v7;
*((_DWORD *)v4 + 1) = v7;
*((_DWORD *)v4 + 2) = v5 + v7;
}
else
{
v6 = operator new(v9);
*(_DWORD *)v4 = v6;
*((_DWORD *)v4 + 1) = v6;
*((_DWORD *)v4 + 2) = (char *)v6 + v5;
}
result = *(char **)v4;
if ( (void *)a3 != a2 )
result = (char *)memcpy(result, a2, a3 - (_DWORD)a2) + a3 - (_DWORD)a2;
*((_DWORD *)v4 + 1) = result;
*result = 0;
return result;
}
//----- (00403F50) --------------------------------------------------------
int __thiscall sub_403F50(int this, int a2, int a3, int a4)
{
int v4; // esi@1
int v5; // edi@2
int v6; // ebx@2
LPVOID *v7; // eax@6
int v8; // ebx@8
void *v9; // edi@10
int v10; // eax@13
LPVOID v11; // ecx@13
int v12; // eax@13
int v13; // ebx@13
int v14; // eax@15
int v16; // [sp+0h] [bp-28h]@1
int v17; // [sp+Ch] [bp-1Ch]@6
LPVOID lpMem; // [sp+10h] [bp-18h]@2
char v19; // [sp+16h] [bp-12h]@16
char v20; // [sp+17h] [bp-11h]@13
int *v21; // [sp+18h] [bp-10h]@1
int v22; // [sp+24h] [bp-4h]@13
v21 = &v16;
v4 = this;
if ( a2 != a3 )
{
v5 = a3 - a2;
v6 = *(_DWORD *)(this + 4) - *(_DWORD *)this;
lpMem = (LPVOID)(*(_DWORD *)(this + 4) - *(_DWORD *)this);
if ( (unsigned int)(a3 - a2) > 0xFFFFFFFE || v6 > (unsigned int)(-2 - v5) )
sub_403A60(aBasic_string);
if ( v5 + v6 <= (unsigned int)(*(_DWORD *)(this + 8) - *(_DWORD *)this - 1) )
{
v19 = BYTE3(a2);
sub_404430(a2 + 1, a3, *(_DWORD *)(this + 4) + 1);
*(_BYTE *)(*(_DWORD *)(v4 + 4) + v5) = 0;
**(_BYTE **)(v4 + 4) = *(_BYTE *)a2;
*(_DWORD *)(v4 + 4) += v5;
}
else
{
v17 = a3 - a2;
v7 = (LPVOID *)&v17;
if ( v6 >= (unsigned int)v5 )
v7 = &lpMem;
v8 = (int)((char *)*v7 + v6 + 1);
v17 = v8;
if ( v8 )
{
if ( (unsigned int)v8 <= 0x80 )
v9 = (void *)sub_4037C0(v8);
else
v9 = operator new(v8);
}
else
{
v9 = 0;
}
v10 = *(_DWORD *)(v4 + 4);
v11 = *(LPVOID *)v4;
v20 = BYTE3(a2);
lpMem = v9;
v22 = 0;
v12 = sub_404430((int)v11, v10, (int)v9);
v20 = BYTE3(a2);
v13 = sub_404430(a2, a3, v12);
v22 = -1;
*(_BYTE *)v13 = 0;
if ( *(_DWORD *)v4 )
sub_403650(*(LPVOID *)v4, *(_DWORD *)(v4 + 8) - *(_DWORD *)v4);
v14 = v17;
*(_DWORD *)v4 = v9;
*(_DWORD *)(v4 + 4) = v13;
*(_DWORD *)(v4 + 8) = (char *)v9 + v14;
}
}
return v4;
}
//----- (004040F0) --------------------------------------------------------
int __thiscall sub_4040F0(int this, void *a2, int a3, int a4)
{
int v4; // esi@1
int v5; // ebx@2
size_t v6; // edi@2
int *v7; // eax@6
int v8; // eax@8
int v9; // eax@13
LPVOID v10; // ecx@13
int v11; // eax@13
char *v12; // ebx@13
LPVOID v13; // eax@15
int v14; // ecx@15
int v16; // [sp+0h] [bp-24h]@1
int v17; // [sp+Ch] [bp-18h]@2
LPVOID lpMem; // [sp+10h] [bp-14h]@10
int *v19; // [sp+14h] [bp-10h]@1
int v20; // [sp+20h] [bp-4h]@13
v4 = this;
v19 = &v16;
if ( a2 != (void *)a3 )
{
v5 = *(_DWORD *)(this + 4) - *(_DWORD *)this;
v6 = a3 - (_DWORD)a2;
v17 = *(_DWORD *)(this + 4) - *(_DWORD *)this;
if ( (unsigned int)(a3 - (_DWORD)a2) > 0xFFFFFFFE || v5 > -2 - v6 )
sub_403A60(aBasic_string);
if ( v6 + v5 <= *(_DWORD *)(this + 8) - *(_DWORD *)this - 1 )
{
if ( (void *)a3 != (char *)a2 + 1 )
memcpy((void *)(*(_DWORD *)(this + 4) + 1), (char *)a2 + 1, a3 - (_DWORD)((char *)a2 + 1));
*(_BYTE *)(*(_DWORD *)(v4 + 4) + v6) = 0;
**(_BYTE **)(v4 + 4) = *(_BYTE *)a2;
*(_DWORD *)(v4 + 4) += v6;
}
else
{
a3 -= (signed int)a2;
v7 = &a3;
if ( v5 >= v6 )
v7 = &v17;
v8 = *v7 + v5 + 1;
v17 = v8;
if ( v8 )
{
if ( (unsigned int)v8 <= 0x80 )
lpMem = (LPVOID)sub_4037C0(v8);
else
lpMem = operator new(v8);
}
else
{
lpMem = 0;
}
v9 = *(_DWORD *)(v4 + 4);
v10 = *(LPVOID *)v4;
BYTE3(a3) = BYTE3(a2);
v20 = 0;
v11 = sub_404430((int)v10, v9, (int)lpMem);
v12 = (char *)memcpy((void *)v11, a2, v6) + v6;
v20 = -1;
*v12 = 0;
if ( *(_DWORD *)v4 )
sub_403650(*(LPVOID *)v4, *(_DWORD *)(v4 + 8) - *(_DWORD *)v4);
v13 = lpMem;
v14 = v17;
*(_DWORD *)v4 = lpMem;
*(_DWORD *)(v4 + 4) = v12;
*(_DWORD *)(v4 + 8) = (char *)v13 + v14;
}
}
return v4;
}
//----- (00404280) --------------------------------------------------------
int __cdecl sub_404280(unsigned int a1, int a2)
{
int result; // eax@1
unsigned int v3; // edx@1
int v4; // ecx@1
unsigned int v5; // esi@2
unsigned int v6; // edi@4
unsigned int v7; // edx@5
unsigned int v8; // ecx@7
unsigned int v9; // edx@8
int v10; // edx@8
int v11; // edx@11
int v12; // eax@15
int v13; // edx@15
result = dword_412DE8;
v3 = dword_412DEC - dword_412DE8;
v4 = a1 * *(_DWORD *)a2;
if ( dword_412DEC - dword_412DE8 >= (unsigned int)v4 )
{
LABEL_13:
dword_412DE8 = v4 + result;
return result;
}
v5 = dword_412DE4;
while ( v3 < a1 )
{
v6 = (((v5 >> 4) + 7) & 0xFFFFFFF8) + 2 * v4;
if ( v3 )
{
v7 = (v3 - 1) >> 3;
*(_DWORD *)result = dword_412DA4[v7];
dword_412DA4[v7] = dword_412DE8;
}
result = (int)operator new(v6);
dword_412DE8 = result;
if ( !result )
{
v8 = a1;
if ( a1 <= 0x80 )
{
while ( 1 )
{
v9 = (v8 - 1) >> 3;
result = dword_412DA4[v9];
v10 = 4 * v9 + 4271524;
if ( result )
break;
v8 += 8;
if ( v8 > 0x80 )
goto LABEL_10;
}
*(_DWORD *)v10 = *(_DWORD *)result;
v5 = dword_412DE4;
v11 = result + v8;
dword_412DE8 = result;
dword_412DEC = result + v8;
goto LABEL_12;
}
LABEL_10:
dword_412DEC = 0;
result = (int)operator new(v6);
dword_412DE8 = result;
}
v11 = result + v6;
v5 = v6 + dword_412DE4;
dword_412DEC = result + v6;
dword_412DE4 += v6;
LABEL_12:
v3 = v11 - result;
v4 = a1 * *(_DWORD *)a2;
if ( v3 >= v4 )
goto LABEL_13;
}
*(_DWORD *)a2 = v3 / a1;
v12 = a1 * (v3 / a1);
v13 = dword_412DE8;
dword_412DE8 += v12;
return v13;
}
// 412DA4: using guessed type int dword_412DA4[];
// 412DE4: using guessed type int dword_412DE4;
// 412DE8: using guessed type int dword_412DE8;
// 412DEC: using guessed type int dword_412DEC;
//----- (004043B0) --------------------------------------------------------
int __thiscall sub_4043B0(void *this, int a2, int a3, int a4)
{
void *v4; // esi@1
int v5; // edi@1
void *v6; // eax@4
int v7; // eax@5
int result; // eax@7
int v9; // ecx@7
int v10; // edi@8
char v11; // dl@9
int v12; // [sp-4h] [bp-14h]@3
v4 = this;
v5 = a3 - a2 + 1;
if ( (unsigned int)v5 > 0xFFFFFFFF || a3 - a2 == -1 )
sub_403A60(aBasic_string);
v12 = a3 - a2 + 1;
if ( (unsigned int)v5 <= 0x80 )
{
v7 = sub_4037C0(v12);
*(_DWORD *)v4 = v7;
*((_DWORD *)v4 + 1) = v7;
*((_DWORD *)v4 + 2) = v5 + v7;
}
else
{
v6 = operator new(v12);
*(_DWORD *)v4 = v6;
*((_DWORD *)v4 + 1) = v6;
*((_DWORD *)v4 + 2) = (char *)v6 + v5;
}
result = *(_DWORD *)v4;
v9 = a2;
if ( a3 - a2 > 0 )
{
v10 = a3 - a2;
do
{
v11 = *(_BYTE *)v9++;
*(_BYTE *)result++ = v11;
--v10;
}
while ( v10 );
}
*((_DWORD *)v4 + 1) = result;
*(_BYTE *)result = 0;
return result;
}
//----- (00404430) --------------------------------------------------------
int __cdecl sub_404430(int a1, int a2, int a3)
{
int result; // eax@1
int v4; // esi@2
result = a3;
if ( a2 - a1 > 0 )
{
v4 = a2 - a1;
do
{
*(_BYTE *)result = *(_BYTE *)(a1 - a3 + result);
++result;
--v4;
}
while ( v4 );
}
return result;
}
//----- (00404460) --------------------------------------------------------
int sub_404460()
{
return 0;
}
//----- (00404470) --------------------------------------------------------
int __cdecl sub_404470(int a1, int a2, int a3)
{
int v3; // ecx@1
int v4; // esi@2
int result; // eax@2
char v6; // dl@3
v3 = a1;
if ( a2 - a1 <= 0 )
{
result = a3;
}
else
{
v4 = a2 - a1;
result = a3;
do
{
v6 = *(_BYTE *)v3++;
*(_BYTE *)result++ = v6;
--v4;
}
while ( v4 );
}
return result;
}
//----- (004044A0) --------------------------------------------------------
signed int __cdecl sub_4044A0(int a1, int *a2, int a3, int *a4)
{
int v4; // edx@1
int v5; // edx@1
signed int result; // eax@2
int v7; // esi@3
int v8; // eax@3
bool v9; // zf@10
bool v10; // sf@10
int v11; // [sp+8h] [bp-60h]@1
int v12; // [sp+Ch] [bp-5Ch]@1
int v13; // [sp+10h] [bp-58h]@1
int v14; // [sp+14h] [bp-54h]@1
int v15; // [sp+18h] [bp-50h]@1
int v16; // [sp+1Ch] [bp-4Ch]@1
int v17; // [sp+20h] [bp-48h]@1
int v18; // [sp+24h] [bp-44h]@1
char v19; // [sp+28h] [bp-40h]@1
v11 = a1;
v4 = *a2;
v14 = a3;
v12 = v4;
v5 = *a4;
v13 = 0;
v15 = v5;
v16 = 0;
v17 = 0;
v18 = 0;
if ( _setjmp3(&v19, 0) )
{
result = 2;
LABEL_12:
v9 = result == 0;
v10 = result < 0;
}
else
{
while ( 1 )
{
v7 = sub_404570((int)&v11, 1);
v8 = sub_404570((int)&v11, 2);
if ( v8 )
{
if ( v8 == 1 )
result = sub_4046D0((int)&v11);
else
result = v8 == 2 ? sub_404AC0((int)&v11) : -1;
}
else
{
result = sub_4045E0((int)&v11);
}
v9 = result == 0;
v10 = result < 0;
if ( result )
break;
if ( v7 )
goto LABEL_12;
}
}
if ( v10 || v9 )
{
*a2 = v13;
*a4 = v16;
}
return result;
}
//----- (00404570) --------------------------------------------------------
int __cdecl sub_404570(int a1, int a2)
{
signed int v2; // ebp@1
int v3; // esi@2
int v4; // ecx@3
int v5; // ebx@3
v2 = *(_DWORD *)(a1 + 24);
if ( *(_DWORD *)(a1 + 28) < a2 )
{
do
{
v3 = *(_DWORD *)(a1 + 20);
if ( v3 == *(_DWORD *)(a1 + 16) )
longjmp((int *__attribute__((__org_typedef(jmp_buf))) )(a1 + 32), 1);
v4 = *(_DWORD *)(a1 + 28);
v5 = *(_BYTE *)(*(_DWORD *)(a1 + 12) + v3) << v4;
v4 += 8;
*(_DWORD *)(a1 + 28) = v4;
v2 |= v5;
*(_DWORD *)(a1 + 20) = v3 + 1;
}
while ( v4 < a2 );
}
*(_DWORD *)(a1 + 28) -= a2;
*(_DWORD *)(a1 + 24) = v2 >> a2;
return v2 & ((1 << a2) - 1);
}
//----- (004045E0) --------------------------------------------------------
signed int __cdecl sub_4045E0(int a1)
{
int v1; // ecx@1
int v3; // eax@3
int v4; // edx@3
int v5; // ecx@3
int v6; // edi@3
int v7; // edi@3
char v8; // bl@3
int v9; // ebp@3
int v10; // ecx@4
int v11; // eax@5
int v12; // eax@10
int v13; // edi@10
int v14; // eax@11
int v15; // edx@12
int v16; // ecx@14
v1 = *(_DWORD *)(a1 + 20);
*(_DWORD *)(a1 + 24) = 0;
*(_DWORD *)(a1 + 28) = 0;
if ( (unsigned int)(v1 + 4) > *(_DWORD *)(a1 + 16) )
return 2;
v3 = *(_DWORD *)(a1 + 12);
v4 = *(_BYTE *)(v3 + v1);
v5 = v1 + 1;
v6 = v4;
LOBYTE(v4) = 0;
*(_DWORD *)(a1 + 20) = v5;
BYTE1(v4) = *(_BYTE *)(v5 + v3);
v7 = (unsigned __int16)v4 | v6;
++v5;
*(_DWORD *)(a1 + 20) = v5;
v8 = *(_BYTE *)(v5 + v3);
v9 = v5 + 1;
*(_DWORD *)(a1 + 20) = v5 + 1;
if ( v8 != ~(_BYTE)v7 )
return -2;
v10 = *(_BYTE *)(v3 + v9);
*(_DWORD *)(a1 + 20) = v9 + 1;
if ( v10 != (unsigned __int8)~BYTE1(v7) )
return -2;
v11 = v7 + v9 + 1;
if ( (unsigned int)v11 > *(_DWORD *)(a1 + 16) )
return 2;
if ( !*(_DWORD *)a1 )
{
v16 = *(_DWORD *)(a1 + 8);
*(_DWORD *)(a1 + 20) = v11;
*(_DWORD *)(a1 + 8) = v7 + v16;
return 0;
}
if ( (unsigned int)(v7 + *(_DWORD *)(a1 + 8)) > *(_DWORD *)(a1 + 4) )
return 1;
v12 = v7;
v13 = v7 - 1;
if ( !v12 )
return 0;
v14 = v13 + 1;
do
{
*(_BYTE *)(*(_DWORD *)(a1 + 8) + *(_DWORD *)a1) = *(_BYTE *)(*(_DWORD *)(a1 + 20) + *(_DWORD *)(a1 + 12));
v15 = *(_DWORD *)(a1 + 20) + 1;
--v14;
++*(_DWORD *)(a1 + 8);
*(_DWORD *)(a1 + 20) = v15;
}
while ( v14 );
return 0;
}
//----- (004046D0) --------------------------------------------------------
signed int __cdecl sub_4046D0(int a1)
{
char v2; // [sp+0h] [bp-240h]@2
char v3; // [sp+120h] [bp-120h]@2
char v4; // [sp+200h] [bp-40h]@2
int v5; // [sp+230h] [bp-10h]@2
int v6; // [sp+234h] [bp-Ch]@2
int v7; // [sp+238h] [bp-8h]@2
int v8; // [sp+23Ch] [bp-4h]@2
if ( dword_410390 )
{
memset32(&v2, 524296, 0x48u);
memset32(&v3, 589833, 0x38u);
memset32(&v4, 458759, 0xCu);
v5 = 524296;
v6 = 524296;
v7 = 524296;
v8 = 524296;
sub_4047A0((int)&off_410398, (int)&v2, 288);
memset32(&v2, 327685, 0xFu);
sub_4047A0((int)&off_4103A0, (int)&v2, 30);
dword_410390 = 0;
}
return sub_404880(a1, (int)&off_410398, (int)&off_4103A0);
}
// 410390: using guessed type int dword_410390;
// 410398: using guessed type void *off_410398;
// 4103A0: using guessed type void *off_4103A0;
//----- (004047A0) --------------------------------------------------------
int __cdecl sub_4047A0(int a1, int a2, int a3)
{
signed int v3; // eax@1
int v4; // ecx@4
int v5; // esi@4
int result; // eax@7
int v7; // esi@8
signed int v8; // ecx@8
int v9; // edi@8
char *v10; // ecx@11
signed int v11; // edi@11
__int16 v12; // dx@12
__int16 v13; // dx@12
int v14; // esi@13
int v15; // edx@14
__int16 v16; // [sp+10h] [bp-20h]@16
__int16 v17; // [sp+12h] [bp-1Eh]@11
char v18; // [sp+14h] [bp-1Ch]@11
v3 = 0;
do
{
v3 += 2;
*(_WORD *)(*(_DWORD *)a1 + v3 - 2) = 0;
}
while ( v3 <= 30 );
if ( a3 > 0 )
{
v4 = a2;
v5 = a3;
do
{
++*(_WORD *)(*(_DWORD *)a1 + 2 * *(_WORD *)v4);
v4 += 2;
--v5;
}
while ( v5 );
}
if ( **(_WORD **)a1 == a3 )
{
result = 0;
}
else
{
result = 1;
v7 = *(_DWORD *)a1 + 2;
v8 = 1;
v9 = *(_DWORD *)a1 + 2;
while ( 1 )
{
result = 2 * result - *(_WORD *)v9;
if ( result < 0 )
break;
++v8;
v9 += 2;
if ( v8 > 15 )
{
v17 = 0;
v10 = &v18;
v11 = 14;
do
{
v12 = *((_WORD *)v10 - 1);
v10 += 2;
v13 = *(_WORD *)v7 + v12;
v7 += 2;
--v11;
*((_WORD *)v10 - 1) = v13;
}
while ( v11 );
v14 = 0;
if ( a3 > 0 )
{
v15 = a2;
do
{
if ( *(_WORD *)v15 )
*(_WORD *)(*(_DWORD *)(a1 + 4) + 2 * (*(&v16 + *(_WORD *)v15))++) = v14;
++v14;
v15 += 2;
}
while ( v14 < a3 );
}
return result;
}
}
}
return result;
}
//----- (00404880) --------------------------------------------------------
signed int __cdecl sub_404880(int a1, int a2, int a3)
{
signed int v3; // ebx@1
int v4; // ecx@4
int v5; // eax@6
int v6; // ebx@8
int v7; // edi@9
signed int v8; // eax@9
int v9; // ebp@10
unsigned int v10; // eax@10
int v11; // ebp@10
int v12; // eax@13
int v13; // edi@13
int v14; // eax@14
v3 = sub_4049C0(a1, a2);
if ( v3 < 0 )
return v3;
while ( 1 )
{
if ( v3 < 256 )
{
if ( *(_DWORD *)a1 )
{
v4 = *(_DWORD *)(a1 + 8);
if ( v4 == *(_DWORD *)(a1 + 4) )
return 1;
*(_BYTE *)(v4 + *(_DWORD *)a1) = v3;
}
v5 = *(_DWORD *)(a1 + 8) + 1;
goto LABEL_18;
}
if ( v3 <= 256 )
goto LABEL_19;
v6 = v3 - 257;
if ( v6 >= 29 )
return -9;
v7 = word_40E528[v6] + sub_404570(a1, word_40E564[v6]);
v8 = sub_4049C0(a1, a3);
v3 = v8;
if ( v8 < 0 )
return v3;
v9 = sub_404570(a1, word_40E5DC[v8]);
v10 = *(_DWORD *)(a1 + 8);
v11 = word_40E5A0[v3] + v9;
if ( v11 > v10 )
return -10;
if ( !*(_DWORD *)a1 )
{
v5 = v7 + v10;
LABEL_18:
*(_DWORD *)(a1 + 8) = v5;
goto LABEL_19;
}
if ( v7 + v10 > *(_DWORD *)(a1 + 4) )
return 1;
v12 = v7;
v13 = v7 - 1;
if ( v12 )
{
v14 = v13 + 1;
do
{
*(_BYTE *)(*(_DWORD *)(a1 + 8) + *(_DWORD *)a1) = *(_BYTE *)(*(_DWORD *)(a1 + 8) - v11 + *(_DWORD *)a1);
--v14;
++*(_DWORD *)(a1 + 8);
}
while ( v14 );
}
LABEL_19:
if ( v3 == 256 )
return 0;
v3 = sub_4049C0(a1, a2);
if ( v3 < 0 )
return v3;
}
}
// 40E528: using guessed type __int16 word_40E528[];
// 40E564: using guessed type __int16 word_40E564[];
// 40E5A0: using guessed type __int16 word_40E5A0[];
// 40E5DC: using guessed type __int16 word_40E5DC[];
//----- (004049C0) --------------------------------------------------------
signed int __cdecl sub_4049C0(int a1, int a2)
{
int v2; // ecx@1
int v3; // esi@1
int v4; // ebp@1
signed int v5; // edi@1
int v6; // eax@1
int v7; // ebx@1
int v8; // edx@3
int v9; // esi@3
int v10; // eax@4
int v11; // ecx@4
int v12; // edx@5
int v13; // edx@8
signed int v15; // [sp+10h] [bp-Ch]@1
int v16; // [sp+14h] [bp-8h]@1
int v17; // [sp+18h] [bp-4h]@1
v2 = a1;
v3 = *(_DWORD *)(a1 + 28);
v4 = 0;
v5 = *(_DWORD *)(a1 + 24);
v6 = 0;
v17 = *(_DWORD *)(a1 + 28);
v16 = 0;
v15 = 1;
v7 = *(_DWORD *)a2 + 2;
while ( 1 )
{
v8 = v3;
v9 = v3 - 1;
if ( v8 )
break;
LABEL_7:
v3 = 16 - v15;
if ( 16 == v15 )
return -9;
v13 = *(_DWORD *)(v2 + 20);
if ( v13 == *(_DWORD *)(v2 + 16) )
longjmp((int *__attribute__((__org_typedef(jmp_buf))) )(v2 + 32), 1);
v5 = *(_BYTE *)(*(_DWORD *)(v2 + 12) + v13);
*(_DWORD *)(a1 + 20) = v13 + 1;
if ( v3 > 8 )
v3 = 8;
v2 = a1;
}
while ( 1 )
{
v7 += 2;
v10 = v5 & 1 | v6;
v11 = *(_WORD *)(v7 - 2);
v5 >>= 1;
if ( v10 < v11 + v4 )
break;
v16 += v11;
v4 = 2 * (v11 + v4);
v6 = 2 * v10;
++v15;
v12 = v9--;
if ( !v12 )
{
v2 = a1;
goto LABEL_7;
}
}
*(_DWORD *)(a1 + 28) = ((_BYTE)v17 - (_BYTE)v15) & 7;
*(_DWORD *)(a1 + 24) = v5;
return *(_WORD *)(*(_DWORD *)(a2 + 4) + 2 * (v10 + v16 - v4));
}
//----- (00404AC0) --------------------------------------------------------
signed int __cdecl sub_404AC0(int a1)
{
int v1; // eax@1
int v2; // ebx@1
int v3; // eax@1
int v4; // edi@1
int v5; // esi@1
int v6; // eax@3
_UNKNOWN *v7; // edi@4
__int16 v8; // ax@5
int v9; // ecx@5
int v10; // eax@8
int v11; // edx@9
signed int result; // eax@13
int v13; // esi@14
signed int v14; // eax@15
int v15; // ebx@17
int v16; // eax@19
int v17; // edx@24
int v18; // eax@24
unsigned int v19; // edx@25
__int16 v20; // ax@25
int v21; // ebx@25
__int16 *v22; // edi@25
int v23; // edi@25
int v24; // ecx@25
int v25; // eax@30
int v26; // eax@33
int v27; // [sp+10h] [bp-550h]@4
int v28; // [sp+10h] [bp-550h]@14
int v29; // [sp+14h] [bp-54Ch]@1
char *v30; // [sp+18h] [bp-548h]@1
char *v31; // [sp+1Ch] [bp-544h]@1
int v32; // [sp+20h] [bp-540h]@1
char *v33; // [sp+24h] [bp-53Ch]@1
char *v34; // [sp+28h] [bp-538h]@1
int v35; // [sp+2Ch] [bp-534h]@4
char v36; // [sp+30h] [bp-530h]@1
char v37; // [sp+50h] [bp-510h]@1
char v38; // [sp+70h] [bp-4F0h]@1
__int16 v39; // [sp+AAh] [bp-4B6h]@19
__int16 v40[316]; // [sp+ACh] [bp-4B4h]@5
char v41; // [sp+324h] [bp-23Ch]@1
v30 = &v37;
v31 = &v41;
v33 = &v36;
v34 = &v38;
v1 = sub_404570(a1, 5);
v2 = v1 + 257;
v32 = v1 + 257;
v3 = sub_404570(a1, 5);
v4 = v3 + 1;
v29 = v3 + 1;
v5 = sub_404570(a1, 4) + 4;
if ( v2 > 286 || v4 > 30 )
return -3;
v6 = 0;
if ( v5 <= 0 )
goto LABEL_8;
v7 = &unk_40E618;
v27 = v5;
v35 = v5;
do
{
v8 = sub_404570(a1, 3);
v9 = *(_WORD *)v7;
v7 = (char *)v7 + 2;
v40[v9] = v8;
--v27;
}
while ( v27 );
if ( v5 < 19 )
{
v6 = v35;
v4 = v29;
LABEL_8:
v10 = 2 * v6 + 4253208;
do
{
v11 = *(_WORD *)v10;
v10 += 2;
v40[v11] = 0;
}
while ( v10 < (signed int)&unk_40E63E );
goto LABEL_12;
}
v4 = v29;
LABEL_12:
if ( sub_4047A0((int)&v30, (int)v40, 19) )
return -4;
v13 = 0;
v28 = v4 + v2;
while ( v13 < v28 )
{
v14 = sub_4049C0(a1, (int)&v30);
if ( v14 >= 16 )
{
v15 = 0;
if ( v14 == 16 )
{
if ( !v13 )
return -5;
v15 = *(&v39 + v13);
v16 = sub_404570(a1, 2) + 3;
}
else if ( v14 == 17 )
{
v16 = sub_404570(a1, 3) + 3;
}
else
{
v16 = sub_404570(a1, 7) + 11;
}
if ( v16 + v13 > v28 )
return -6;
v17 = v16;
v18 = v16 - 1;
if ( v17 )
{
v19 = v18 + 1;
v20 = v15;
v21 = v15 << 16;
LOWORD(v21) = v20;
v22 = &v40[v13];
memset32(v22, v21, v19 >> 1);
v23 = (int)&v22[2 * (v19 >> 1)];
v24 = v19 & 1;
v13 += v19;
while ( v24 )
{
*(_WORD *)v23 = v20;
v23 += 2;
--v24;
}
}
v2 = v32;
v4 = v29;
}
else
{
v40[v13++] = v14;
}
}
v25 = sub_4047A0((int)&v30, (int)v40, v2);
if ( v25 < 0 || v25 > 0 && v2 - *(_WORD *)v30 != 1 )
{
result = -7;
}
else
{
v26 = sub_4047A0((int)&v33, (int)&v40[v2], v4);
if ( v26 < 0 || v26 > 0 && v4 - *(_WORD *)v33 != 1 )
result = -8;
else
result = sub_404880(a1, (int)&v30, (int)&v33);
}
return result;
}
// 404AC0: using guessed type __int16 var_4B4[316];
//----- (004051BC) --------------------------------------------------------
void __cdecl sub_4051BC(LPVOID lpMem)
{
int v1; // esi@1
unsigned int v2; // eax@3
int v3; // eax@6
void *v4; // [sp-4h] [bp-Ch]@3
int v5; // [sp+4h] [bp-4h]@6
v1 = (int)lpMem;
if ( lpMem )
{
if ( dword_4136F8 == 3 )
{
v2 = __sbh_find_block(lpMem);
v4 = (void *)v1;
if ( v2 )
{
sub_4078D8(v2, v1);
return;
}
}
else
{
if ( dword_4136F8 == 2 )
{
v3 = sub_408608((unsigned int)lpMem, (int)&v5, (int)&lpMem);
if ( v3 )
{
sub_40865F(v5, (int)lpMem, v3);
return;
}
}
v4 = (void *)v1;
}
HeapFree(hHeap, 0, v4);
}
}
// 4078AD: using guessed type _DWORD __cdecl __sbh_find_block(_DWORD);
// 4136F8: using guessed type int dword_4136F8;
//----- (00405263) --------------------------------------------------------
LPVOID __cdecl sub_405263(unsigned int a1)
{
signed int v1; // esi@1
LPVOID result; // eax@3
unsigned int v3; // esi@7
v1 = a1;
if ( dword_4136F8 == 3 )
{
if ( a1 <= dword_4136F0 )
{
result = (LPVOID)__sbh_alloc_block(a1);
if ( result )
return result;
}
goto LABEL_12;
}
if ( dword_4136F8 != 2 )
{
LABEL_12:
if ( !a1 )
v1 = 1;
v3 = (v1 + 15) & 0xFFFFFFF0;
return HeapAlloc(hHeap, 0, v3);
}
if ( a1 )
v3 = (a1 + 15) & 0xFFFFFFF0;
else
v3 = 16;
if ( v3 > dword_4126B4 )
return HeapAlloc(hHeap, 0, v3);
result = (LPVOID)sub_4086A4(v3 >> 4);
if ( !result )
return HeapAlloc(hHeap, 0, v3);
return result;
}
// 407C01: using guessed type _DWORD __cdecl __sbh_alloc_block(_DWORD);
// 4126B4: using guessed type int dword_4126B4;
// 4136F0: using guessed type int dword_4136F0;
// 4136F8: using guessed type int dword_4136F8;
//----- (0040565F) --------------------------------------------------------
void __cdecl sub_40565F(LPVOID lpMem)
{
sub_4051BC(lpMem);
}
//----- (00405D4A) --------------------------------------------------------
int __thiscall sub_405D4A(int this)
{
int result; // eax@1
result = this;
*(_DWORD *)(this + 4) = 0;
*(_DWORD *)(this + 8) = 0;
*(_DWORD *)this = &off_40E644;
return result;
}
// 40E644: using guessed type int (__thiscall *off_40E644)(LPVOID lpMem, char);
//----- (00405D5B) --------------------------------------------------------
LPVOID __thiscall sub_405D5B(LPVOID lpMem, char a2)
{
LPVOID v2; // esi@1
v2 = lpMem;
sub_405DC1((int)lpMem);
if ( a2 & 1 )
sub_40565F(v2);
return v2;
}
//----- (00405DC1) --------------------------------------------------------
void __thiscall sub_405DC1(int this)
{
bool v1; // zf@1
v1 = *(_DWORD *)(this + 8) == 0;
*(_DWORD *)this = &off_40E644;
if ( !v1 )
sub_40565F(*(LPVOID *)(this + 4));
}
// 40E644: using guessed type int (__thiscall *off_40E644)(LPVOID lpMem, char);
//----- (004073FC) --------------------------------------------------------
void __noreturn sub_4073FC()
{
if ( dword_4130D0 )
dword_4130D0();
abort();
}
// 4130D0: using guessed type int (*dword_4130D0)(void);
//----- (0040761D) --------------------------------------------------------
int sub_40761D()
{
return flsall(1);
}
// 407626: using guessed type _DWORD __cdecl flsall(_DWORD);
//----- (00407693) --------------------------------------------------------
char __cdecl sub_407693(int a1)
{
HMODULE v1; // eax@1
int v2; // ecx@2
*(_DWORD *)a1 = 0;
v1 = GetModuleHandleA(0);
if ( *(_WORD *)v1 == 23117 )
{
v2 = *((_DWORD *)v1 + 15);
if ( v2 )
{
v1 = (HMODULE)((char *)v1 + v2);
*(_BYTE *)a1 = *((_BYTE *)v1 + 26);
LOBYTE(v1) = *((_BYTE *)v1 + 27);
*(_BYTE *)(a1 + 1) = (_BYTE)v1;
}
}
return (char)v1;
}
//----- (004076C0) --------------------------------------------------------
__int32 sub_4076C0()
{
__int32 result; // eax@4
CHAR *v1; // ecx@6
CHAR v2; // al@7
CHAR *v3; // eax@12
CHAR *v4; // ecx@13
CHAR v5; // al@14
char *v6; // eax@20
const char *v7; // eax@21
const char *v8; // ecx@21
CHAR Buffer; // [sp+4h] [bp-122Ch]@5
CHAR Filename; // [sp+1094h] [bp-19Ch]@13
struct _OSVERSIONINFOA VersionInformation; // [sp+1198h] [bp-98h]@1
unsigned __int8 v12; // [sp+122Ch] [bp-4h]@29
VersionInformation.dwOSVersionInfoSize = 148;
if ( GetVersionExA(&VersionInformation)
&& VersionInformation.dwPlatformId == 2
&& VersionInformation.dwMajorVersion >= 5 )
{
result = 1;
}
else
{
if ( !GetEnvironmentVariableA("__MSVCRT_HEAP_SELECT", &Buffer, 0x1090u) )
goto LABEL_32;
v1 = &Buffer;
if ( Buffer )
{
do
{
v2 = *v1;
if ( *v1 >= 97 && v2 <= 122 )
*v1 = v2 - 32;
++v1;
}
while ( *v1 );
}
if ( !strncmp("__GLOBAL_HEAP_SELECTED", &Buffer, 0x16u) )
{
v3 = &Buffer;
}
else
{
GetModuleFileNameA(0, &Filename, 0x104u);
v4 = &Filename;
if ( Filename )
{
do
{
v5 = *v4;
if ( *v4 >= 97 && v5 <= 122 )
*v4 = v5 - 32;
++v4;
}
while ( *v4 );
}
v3 = strstr(&Buffer, &Filename);
}
if ( !v3 )
goto LABEL_32;
v6 = strchr(v3, 44);
if ( !v6 )
goto LABEL_32;
v7 = v6 + 1;
v8 = v7;
while ( *v8 )
{
if ( *v8 == 59 )
*v8 = 0;
else
++v8;
}
result = strtol(v7, 0, 10);
if ( result != 2 && result != 3 && result != 1 )
{
LABEL_32:
sub_407693((int)&v12);
result = 3 - (v12 < 6u);
}
}
return result;
}
//----- (00407808) --------------------------------------------------------
signed int __cdecl sub_407808(int a1)
{
__int32 v1; // eax@2
void **v2; // eax@3
hHeap = HeapCreate(a1 == 0, 0x1000u, 0);
if ( !hHeap )
return 0;
v1 = sub_4076C0();
dword_4136F8 = v1;
if ( v1 == 3 )
{
v2 = (void **)__sbh_heap_init(1016);
}
else
{
if ( v1 != 2 )
return 1;
v2 = sub_4083AC();
}
if ( !v2 )
{
HeapDestroy(hHeap);
return 0;
}
return 1;
}
// 407865: using guessed type _DWORD __cdecl __sbh_heap_init(_DWORD);
// 4136F8: using guessed type int dword_4136F8;
//----- (004078D8) --------------------------------------------------------
unsigned int __cdecl sub_4078D8(unsigned int a1, int a2)
{
unsigned int result; // eax@1
int v3; // esi@1
unsigned int v4; // edi@1
signed int v5; // ecx@1
int v6; // ebx@2
int v7; // edx@3
int v8; // ecx@7
unsigned int v9; // ebx@7
bool v10; // zf@7
int v11; // ecx@9
unsigned int v12; // ebx@9
int v13; // ecx@11
int v14; // edx@14
int v15; // ebx@17
unsigned int v16; // esi@24
unsigned int v17; // esi@26
int v18; // ecx@33
void *v19; // eax@43
int v20; // [sp+Ch] [bp-10h]@1
signed int v21; // [sp+10h] [bp-Ch]@2
signed int v22; // [sp+14h] [bp-8h]@2
int v23; // [sp+18h] [bp-4h]@1
int v24; // [sp+28h] [bp+Ch]@2
int v25; // [sp+28h] [bp+Ch]@17
char v26; // [sp+2Bh] [bp+Fh]@34
result = *(_DWORD *)(a1 + 16);
v3 = a2 - 4;
v4 = (unsigned int)(a2 - *(_DWORD *)(a1 + 12)) >> 15;
v20 = 516 * v4 + result + 324;
v5 = *(_DWORD *)(a2 - 4) - 1;
v23 = *(_DWORD *)(a2 - 4) - 1;
if ( !(v5 & 1) )
{
v6 = v5 + v3;
v21 = *(_DWORD *)(v5 + v3);
v22 = *(_DWORD *)(a2 - 8);
v24 = v5 + v3;
if ( !(v21 & 1) )
{
v7 = (v21 >> 4) - 1;
if ( (unsigned int)v7 > 0x3F )
v7 = 63;
if ( *(_DWORD *)(v6 + 4) == *(_DWORD *)(v6 + 8) )
{
if ( (unsigned int)v7 >= 0x20 )
{
v11 = v7 + result + 4;
v12 = ~(0x80000000 >> (v7 - 32));
*(_DWORD *)(result + 4 * v4 + 196) &= v12;
v10 = (*(_BYTE *)v11)-- == 1;
if ( v10 )
*(_DWORD *)(a1 + 4) &= v12;
}
else
{
v8 = v7 + result + 4;
v9 = ~(0x80000000 >> v7);
*(_DWORD *)(result + 4 * v4 + 68) &= v9;
v10 = (*(_BYTE *)v8)-- == 1;
if ( v10 )
*(_DWORD *)a1 &= v9;
}
v13 = v23;
v6 = v24;
}
else
{
v13 = v23;
}
v5 = v21 + v13;
*(_DWORD *)(*(_DWORD *)(v6 + 8) + 4) = *(_DWORD *)(v6 + 4);
v23 = v5;
*(_DWORD *)(*(_DWORD *)(v24 + 4) + 8) = *(_DWORD *)(v24 + 8);
}
v14 = (v5 >> 4) - 1;
if ( (unsigned int)v14 > 0x3F )
v14 = 63;
if ( v22 & 1 )
{
v15 = a1;
}
else
{
v25 = v3 - v22;
v15 = (v22 >> 4) - 1;
if ( (unsigned int)v15 > 0x3F )
v15 = 63;
v23 = v22 + v5;
v14 = ((v22 + v5) >> 4) - 1;
if ( (unsigned int)v14 > 0x3F )
v14 = 63;
if ( v15 != v14 )
{
if ( *(_DWORD *)(v25 + 4) == *(_DWORD *)(v25 + 8) )
{
if ( (unsigned int)v15 >= 0x20 )
{
v17 = ~(0x80000000 >> (v15 - 32));
*(_DWORD *)(result + 4 * v4 + 196) &= v17;
v10 = (*(_BYTE *)(v15 + result + 4))-- == 1;
if ( v10 )
*(_DWORD *)(a1 + 4) &= v17;
}
else
{
v16 = ~(0x80000000 >> v15);
*(_DWORD *)(result + 4 * v4 + 68) &= v16;
v10 = (*(_BYTE *)(v15 + result + 4))-- == 1;
if ( v10 )
*(_DWORD *)a1 &= v16;
}
}
*(_DWORD *)(*(_DWORD *)(v25 + 8) + 4) = *(_DWORD *)(v25 + 4);
*(_DWORD *)(*(_DWORD *)(v25 + 4) + 8) = *(_DWORD *)(v25 + 8);
}
v3 = v25;
}
if ( v22 & 1 || v15 != v14 )
{
v18 = v20 + 8 * v14;
*(_DWORD *)(v3 + 4) = *(_DWORD *)(v20 + 8 * v14 + 4);
*(_DWORD *)(v3 + 8) = v18;
*(_DWORD *)(v18 + 4) = v3;
*(_DWORD *)(*(_DWORD *)(v3 + 4) + 8) = v3;
if ( *(_DWORD *)(v3 + 4) == *(_DWORD *)(v3 + 8) )
{
v26 = *(_BYTE *)(v14 + result + 4);
*(_BYTE *)(v14 + result + 4) = v26 + 1;
if ( (unsigned int)v14 >= 0x20 )
{
if ( !v26 )
*(_DWORD *)(a1 + 4) |= 0x80000000 >> (v14 - 32);
*(_DWORD *)(result + 4 * v4 + 196) |= 0x80000000 >> (v14 - 32);
}
else
{
if ( !v26 )
*(_DWORD *)a1 |= 0x80000000 >> v14;
*(_DWORD *)(result + 4 * v4 + 68) |= 0x80000000 >> v14;
}
}
}
*(_DWORD *)v3 = v23;
*(_DWORD *)(v23 + v3 - 4) = v23;
result += 516 * v4 + 324;
v10 = *(_DWORD *)v20 == 1;
--*(_DWORD *)result;
if ( v10 )
{
if ( dword_4136E4 )
{
VirtualFree((LPVOID)(*((_DWORD *)dword_4136E4 + 3) + (dword_4136DC << 15)), 0x8000u, 0x4000u);
*((_DWORD *)dword_4136E4 + 2) |= 0x80000000 >> dword_4136DC;
*(_DWORD *)(*((_DWORD *)dword_4136E4 + 4) + 4 * dword_4136DC + 196) = 0;
--*(_BYTE *)(*((_DWORD *)dword_4136E4 + 4) + 67);
v19 = dword_4136E4;
if ( !*(_BYTE *)(*((_DWORD *)dword_4136E4 + 4) + 67) )
{
*((_DWORD *)dword_4136E4 + 1) &= 0xFFFFFFFE;
v19 = dword_4136E4;
}
if ( *((_DWORD *)v19 + 2) == -1 )
{
VirtualFree(*((LPVOID *)v19 + 3), 0, 0x8000u);
HeapFree(hHeap, 0, *((LPVOID *)dword_4136E4 + 4));
memcpy(
dword_4136E4,
(char *)dword_4136E4 + 20,
(size_t)((char *)lpMem + 20 * dword_4136E8-- - (_DWORD)dword_4136E4 - 20));
if ( a1 > (unsigned int)dword_4136E4 )
a1 -= 20;
dword_4136E0 = (int)lpMem;
}
}
result = a1;
dword_4136DC = v4;
dword_4136E4 = (void *)a1;
}
}
return result;
}
// 4136DC: using guessed type int dword_4136DC;
// 4136E0: using guessed type int dword_4136E0;
// 4136E8: using guessed type int dword_4136E8;
//----- (004083AC) --------------------------------------------------------
void **sub_4083AC()
{
void **v0; // esi@2
LPVOID v1; // eax@4
unsigned int v2; // edi@4
int v3; // eax@12
signed int v4; // ebp@12
int v5; // edx@13
if ( dword_4106A0 == -1 )
{
v0 = &off_410690;
}
else
{
v0 = (void **)HeapAlloc(hHeap, 0, 0x2020u);
if ( !v0 )
return 0;
}
v1 = VirtualAlloc(0, 0x400000u, 0x2000u, 4u);
v2 = (unsigned int)v1;
if ( !v1 )
{
LABEL_19:
if ( v0 != &off_410690 )
HeapFree(hHeap, 0, v0);
return 0;
}
if ( !VirtualAlloc(v1, 0x10000u, 0x1000u, 4u) )
{
VirtualFree((LPVOID)v2, 0, 0x8000u);
goto LABEL_19;
}
if ( v0 == &off_410690 )
{
if ( !off_410690 )
off_410690 = &off_410690;
if ( !off_410694 )
off_410694 = &off_410690;
}
else
{
*v0 = &off_410690;
v0[1] = off_410694;
off_410694 = v0;
*(_DWORD *)v0[1] = v0;
}
v0[5] = (void *)(v2 + 0x400000);
v3 = (int)(v0 + 6);
v0[3] = v0 + 38;
v0[4] = (void *)v2;
v0[2] = v0 + 6;
v4 = 0;
do
{
v5 = v4++ >= 16;
*(_DWORD *)v3 = ((v5 - 1) & 0xF1) - 1;
*(_DWORD *)(v3 + 4) = 241;
v3 += 8;
}
while ( v4 < 1024 );
memset((void *)v2, 0, 0x10000u);
while ( v2 < (unsigned int)((char *)v0[4] + 0x10000) )
{
*(_BYTE *)(v2 + 248) = -1;
*(_DWORD *)v2 = v2 + 8;
*(_DWORD *)(v2 + 4) = 240;
v2 += 4096;
}
return v0;
}
// 410690: using guessed type void *off_410690;
// 4106A0: using guessed type int dword_4106A0;
//----- (004084F0) --------------------------------------------------------
int __cdecl sub_4084F0(LPVOID lpMem)
{
int result; // eax@1
result = VirtualFree(*((LPVOID *)lpMem + 4), 0, 0x8000u);
if ( off_4126B0 == lpMem )
{
result = *((_DWORD *)lpMem + 1);
off_4126B0 = (void **)*((_DWORD *)lpMem + 1);
}
if ( lpMem == &off_410690 )
{
dword_4106A0 = -1;
}
else
{
**((_DWORD **)lpMem + 1) = *(_DWORD *)lpMem;
*(_DWORD *)(*(_DWORD *)lpMem + 4) = *((_DWORD *)lpMem + 1);
result = HeapFree(hHeap, 0, lpMem);
}
return result;
}
// 410690: using guessed type void *off_410690;
// 4106A0: using guessed type int dword_4106A0;
// 4126B0: using guessed type void **off_4126B0;
//----- (00408546) --------------------------------------------------------
void __cdecl sub_408546(int a1)
{
LPVOID v1; // esi@1
int v2; // edi@3
signed int v3; // ebx@3
unsigned int v4; // eax@6
LPVOID v5; // ecx@11
int v6; // eax@13
signed int v7; // edx@13
int v8; // [sp+Ch] [bp-4h]@3
v1 = off_410694;
do
{
if ( *((_DWORD *)v1 + 4) != -1 )
{
v8 = 0;
v2 = (int)((char *)v1 + 8208);
v3 = 4190208;
do
{
if ( *(_DWORD *)v2 == 240 && VirtualFree((LPVOID)(*((_DWORD *)v1 + 4) + v3), 0x1000u, 0x4000u) )
{
*(_DWORD *)v2 = -1;
--dword_4130D4;
v4 = *((_DWORD *)v1 + 3);
if ( !v4 || v4 > v2 )
*((_DWORD *)v1 + 3) = v2;
++v8;
--a1;
if ( !a1 )
break;
}
v3 -= 4096;
v2 -= 8;
}
while ( v3 >= 0 );
v5 = v1;
v1 = (LPVOID)*((_DWORD *)v1 + 1);
if ( v8 && *((_DWORD *)v5 + 6) == -1 )
{
v6 = (int)((char *)v5 + 32);
v7 = 1;
do
{
if ( *(_DWORD *)v6 != -1 )
break;
++v7;
v6 += 8;
}
while ( v7 < 1024 );
if ( v7 == 1024 )
sub_4084F0(v5);
}
}
}
while ( v1 != off_410694 && a1 > 0 );
}
// 4130D4: using guessed type int dword_4130D4;
//----- (00408608) --------------------------------------------------------
unsigned int __cdecl sub_408608(unsigned int a1, int a2, int a3)
{
void **v3; // ecx@1
v3 = &off_410690;
while ( a1 <= (unsigned int)v3[4] || a1 >= (unsigned int)v3[5] )
{
v3 = (void **)*v3;
if ( v3 == &off_410690 )
return 0;
}
if ( !(a1 & 0xF) && (a1 & 0xFFF) >= 0x100 )
{
*(_DWORD *)a2 = v3;
*(_DWORD *)a3 = a1 & 0xFFFFF000;
return ((signed int)(a1 - (a1 & 0xFFFFF000) - 256) >> 4) + (a1 & 0xFFFFF000) + 8;
}
return 0;
}
// 410690: using guessed type void *off_410690;
//----- (0040865F) --------------------------------------------------------
void __cdecl sub_40865F(int a1, int a2, int a3)
{
int v3; // eax@1
bool v4; // zf@1
v3 = a1 + 8 * ((a2 - *(_DWORD *)(a1 + 16)) >> 12) + 24;
*(_DWORD *)v3 += *(_BYTE *)a3;
*(_BYTE *)a3 = 0;
v4 = *(_DWORD *)v3 == 240;
*(_DWORD *)(v3 + 4) = 241;
if ( v4 )
{
++dword_4130D4;
if ( dword_4130D4 == 32 )
sub_408546(16);
}
}
// 4130D4: using guessed type int dword_4130D4;
//----- (004086A4) --------------------------------------------------------
int __cdecl sub_4086A4(unsigned int a1)
{
void **v1; // esi@1
void *v2; // edx@2
int v3; // edi@3
int v4; // eax@3
unsigned int v5; // ebx@4
int result; // eax@6
void **v7; // edi@22
void *v8; // ebx@27
void *v9; // eax@27
int i; // esi@27
unsigned int v11; // ecx@31
int v12; // eax@32
int v13; // eax@34
bool v14; // cf@35
void **v15; // eax@40
void *v16; // ecx@41
int v17; // [sp+Ch] [bp-8h]@11
int v18; // [sp+10h] [bp-4h]@3
int v19; // [sp+10h] [bp-4h]@11
signed int v20; // [sp+10h] [bp-4h]@27
v1 = off_4126B0;
do
{
v2 = v1[4];
if ( v2 == (void *)-1 )
{
v5 = a1;
}
else
{
v3 = (int)v1[2];
v4 = (int)((char *)v2 + 4096 * (((_BYTE *)v1[2] - (_BYTE *)v1 - 24) >> 3));
v18 = (int)((char *)v2 + 4096 * (((_BYTE *)v1[2] - (_BYTE *)v1 - 24) >> 3));
if ( v3 < (unsigned int)(v1 + 2054) )
{
while ( 1 )
{
v5 = a1;
if ( *(_DWORD *)v3 >= (signed int)a1 && *(_DWORD *)(v3 + 4) > a1 )
{
result = sub_4088AC(v4, *(_DWORD *)v3, a1);
if ( result )
{
LABEL_21:
off_4126B0 = v1;
*(_DWORD *)v3 -= v5;
v1[2] = (void *)v3;
return result;
}
v4 = v18;
*(_DWORD *)(v3 + 4) = a1;
}
v3 += 8;
v4 += 4096;
v18 = v4;
if ( v3 >= (unsigned int)(v1 + 2054) )
goto LABEL_11;
}
}
v5 = a1;
LABEL_11:
v3 = (int)(v1 + 6);
v17 = (int)v1[2];
v19 = (int)v1[4];
if ( (unsigned int)(v1 + 6) < v17 )
{
do
{
if ( *(_DWORD *)v3 >= (signed int)v5 && *(_DWORD *)(v3 + 4) > v5 )
{
result = sub_4088AC(v19, *(_DWORD *)v3, v5);
if ( result )
goto LABEL_21;
*(_DWORD *)(v3 + 4) = v5;
}
v19 += 4096;
v3 += 8;
}
while ( v3 < (unsigned int)v17 );
}
}
v1 = (void **)*v1;
}
while ( v1 != off_4126B0 );
v7 = &off_410690;
while ( v7[4] == (void *)-1 || !v7[3] )
{
v7 = (void **)*v7;
if ( v7 == &off_410690 )
{
v15 = sub_4083AC();
if ( v15 )
{
v16 = v15[4];
*((_BYTE *)v16 + 8) = v5;
off_4126B0 = v15;
*(_DWORD *)v16 = (char *)v16 + v5 + 8;
*((_DWORD *)v16 + 1) = 240 - v5;
v15[6] = (char *)v15[6] - (unsigned __int8)v5;
return (int)((char *)v16 + 256);
}
return 0;
}
}
v8 = v7[3];
v20 = 0;
v9 = v8;
for ( i = (int)((char *)v7[4] + 4096 * (((_BYTE *)v8 - (_BYTE *)v7 - 24) >> 3)); *(_DWORD *)v9 == -1; ++v20 )
{
if ( v20 >= 16 )
break;
v9 = (char *)v9 + 8;
}
if ( VirtualAlloc((LPVOID)i, v20 << 12, 0x1000u, 4u) != (LPVOID)i )
return 0;
v11 = (unsigned int)v8;
if ( v20 > 0 )
{
v12 = i + 4;
do
{
*(_BYTE *)(v12 + 244) = -1;
*(_DWORD *)(v12 - 4) = v12 + 4;
*(_DWORD *)v12 = 240;
*(_DWORD *)v11 = 240;
*(_DWORD *)(v11 + 4) = 241;
v12 += 4096;
v11 += 8;
--v20;
}
while ( v20 );
}
off_4126B0 = v7;
v13 = (int)(v7 + 2054);
while ( 1 )
{
v14 = v11 < v13;
if ( v11 >= v13 )
break;
if ( *(_DWORD *)v11 == -1 )
{
v14 = v11 < v13;
break;
}
v11 += 8;
}
v7[3] = (void *)(v14 ? v11 : 0);
*(_BYTE *)(i + 8) = a1;
v7[2] = v8;
*(_DWORD *)v8 -= a1;
*(_DWORD *)(i + 4) -= a1;
result = i + 256;
*(_DWORD *)i = i + a1 + 8;
return result;
}
// 410690: using guessed type void *off_410690;
// 4126B0: using guessed type void **off_4126B0;
//----- (004088AC) --------------------------------------------------------
int __cdecl sub_4088AC(int a1, unsigned int a2, unsigned int a3)
{
int v3; // ecx@1
unsigned int v4; // esi@1
unsigned int v5; // edi@1
int v6; // ebx@1
int v7; // eax@1
int v8; // eax@5
int v9; // esi@6
int v10; // ebx@10
signed int v11; // esi@10
int v12; // esi@20
int v13; // ebx@24
signed int v14; // eax@24
unsigned int v16; // [sp+Ch] [bp-4h]@1
int v17; // [sp+18h] [bp+8h]@1
v3 = a1;
v4 = *(_DWORD *)(a1 + 4);
v5 = *(_DWORD *)a1;
v6 = a1 + 248;
v16 = *(_DWORD *)a1;
v7 = *(_DWORD *)a1;
v17 = a1 + 248;
if ( v4 >= a3 )
{
*(_BYTE *)v5 = a3;
if ( v5 + a3 >= v6 )
{
*(_DWORD *)(v3 + 4) = 0;
*(_DWORD *)v3 = v3 + 8;
}
else
{
*(_DWORD *)v3 += a3;
*(_DWORD *)(v3 + 4) -= a3;
}
v8 = v5 + 8;
return 16 * v8 - 15 * v3;
}
v9 = v5 + v4;
if ( *(_BYTE *)v9 )
v7 = v9;
if ( v7 + a3 >= v6 )
{
LABEL_20:
v12 = v3 + 8;
while ( v12 < v5 && v12 + a3 < v17 )
{
if ( *(_BYTE *)v12 )
{
v12 += *(_BYTE *)v12;
}
else
{
v13 = v12 + 1;
v14 = 1;
while ( !*(_BYTE *)v13 )
{
++v13;
++v14;
}
if ( v14 >= a3 )
{
if ( v12 + a3 >= v17 )
{
*(_DWORD *)(v3 + 4) = 0;
*(_DWORD *)v3 = v3 + 8;
}
else
{
*(_DWORD *)v3 = v12 + a3;
*(_DWORD *)(v3 + 4) = v14 - a3;
}
*(_BYTE *)v12 = a3;
v8 = v12 + 8;
return 16 * v8 - 15 * v3;
}
a2 -= v14;
if ( a2 < a3 )
return 0;
v12 = v13;
}
}
return 0;
}
while ( *(_BYTE *)v7 )
{
v7 += *(_BYTE *)v7;
LABEL_19:
if ( v7 + a3 >= v17 )
goto LABEL_20;
}
v10 = v7 + 1;
v11 = 1;
while ( !*(_BYTE *)v10 )
{
++v10;
++v11;
}
if ( v11 < a3 )
{
if ( v7 == v16 )
{
*(_DWORD *)(v3 + 4) = v11;
}
else
{
a2 -= v11;
if ( a2 < a3 )
return 0;
}
v5 = v16;
v7 = v10;
goto LABEL_19;
}
if ( v7 + a3 >= v17 )
{
*(_DWORD *)(v3 + 4) = 0;
*(_DWORD *)v3 = v3 + 8;
}
else
{
*(_DWORD *)v3 = v7 + a3;
*(_DWORD *)(v3 + 4) = v11 - a3;
}
*(_BYTE *)v7 = a3;
v8 = v7 + 8;
return 16 * v8 - 15 * v3;
}
//----- (004089D0) --------------------------------------------------------
signed int __cdecl sub_4089D0(int a1, int a2, unsigned int a3, unsigned int a4)
{
unsigned int v4; // ecx@1
int v5; // edi@1
int v6; // esi@4
int i; // eax@5
bool v8; // zf@6
int v9; // eax@14
int v11; // [sp+Ch] [bp-4h]@1
v4 = *(_BYTE *)a3;
v11 = 0;
v5 = a1 + 8 * ((a2 - *(_DWORD *)(a1 + 16)) >> 12) + 24;
if ( v4 > a4 )
{
*(_BYTE *)a3 = a4;
*(_DWORD *)v5 += v4 - a4;
*(_DWORD *)(v5 + 4) = 241;
return 1;
}
if ( v4 < a4 )
{
v6 = a3 + a4;
if ( a2 + 248 >= a3 + a4 )
{
for ( i = v4 + a3; ; ++i )
{
v8 = i == v6;
if ( i >= (unsigned int)v6 )
break;
if ( *(_BYTE *)i )
{
v8 = i == v6;
break;
}
}
if ( v8 )
{
*(_BYTE *)a3 = a4;
if ( a3 <= *(_DWORD *)a2 && (unsigned int)v6 > *(_DWORD *)a2 )
{
if ( v6 >= (unsigned int)(a2 + 248) )
{
*(_DWORD *)(a2 + 4) = 0;
*(_DWORD *)a2 = a2 + 8;
}
else
{
v9 = 0;
*(_DWORD *)a2 = v6;
if ( !*(_BYTE *)v6 )
{
do
++v9;
while ( !*(_BYTE *)(v6 + v9) );
}
*(_DWORD *)(a2 + 4) = v9;
}
}
*(_DWORD *)v5 += v4 - a4;
return 1;
}
}
}
return v11;
}
//----- (0040A218) --------------------------------------------------------
LPVOID __cdecl sub_40A218(LPVOID lpMem, SIZE_T dwBytes)
{
LPVOID result; // eax@2
unsigned int v3; // esi@3
LPVOID v4; // edi@6
unsigned int v5; // eax@7
unsigned int v6; // ebx@7
size_t v7; // eax@11
size_t v8; // eax@18
unsigned int v9; // eax@36
int v10; // ebx@36
size_t v11; // eax@41
size_t v12; // eax@46
int v13; // [sp+Ch] [bp-4h]@36
if ( !lpMem )
return malloc(dwBytes);
v3 = dwBytes;
if ( !dwBytes )
{
sub_4051BC(lpMem);
return 0;
}
if ( dword_4136F8 == 3 )
{
while ( 1 )
{
v4 = 0;
if ( v3 <= 0xFFFFFFE0 )
break;
LABEL_26:
if ( !dword_4130D8 )
return v4;
if ( !_callnewh(v3) )
return 0;
}
v5 = __sbh_find_block(lpMem);
v6 = v5;
if ( !v5 )
{
LABEL_22:
if ( !v3 )
v3 = 1;
v3 = (v3 + 15) & 0xFFFFFFF0;
v4 = HeapReAlloc(hHeap, 0, lpMem, v3);
LABEL_25:
if ( v4 )
return v4;
goto LABEL_26;
}
if ( v3 <= dword_4136F0 )
{
v4 = lpMem;
if ( __sbh_resize_block(v5, lpMem, v3) )
goto LABEL_14;
v4 = (LPVOID)__sbh_alloc_block(v3);
if ( v4 )
{
v7 = *((_DWORD *)lpMem - 1) - 1;
if ( v7 >= v3 )
v7 = v3;
memcpy_0(v4, lpMem, v7);
v6 = __sbh_find_block(lpMem);
sub_4078D8(v6, (int)lpMem);
LABEL_14:
if ( v4 )
goto LABEL_21;
goto LABEL_15;
}
}
LABEL_15:
if ( !v3 )
v3 = 1;
v3 = (v3 + 15) & 0xFFFFFFF0;
v4 = HeapAlloc(hHeap, 0, v3);
if ( v4 )
{
v8 = *((_DWORD *)lpMem - 1) - 1;
if ( v8 >= v3 )
v8 = v3;
memcpy_0(v4, lpMem, v8);
sub_4078D8(v6, (int)lpMem);
}
LABEL_21:
if ( v6 )
goto LABEL_25;
goto LABEL_22;
}
if ( dword_4136F8 == 2 )
{
if ( dwBytes <= 0xFFFFFFE0 )
{
if ( dwBytes )
v3 = (dwBytes + 15) & 0xFFFFFFF0;
else
v3 = 16;
}
while ( 1 )
{
v4 = 0;
if ( v3 > 0xFFFFFFE0 )
goto LABEL_51;
v9 = sub_408608((unsigned int)lpMem, (int)&v13, (int)&dwBytes);
v10 = v9;
if ( !v9 )
{
v4 = HeapReAlloc(hHeap, 0, lpMem, v3);
goto LABEL_50;
}
if ( v3 < dword_4126B4 )
{
if ( sub_4089D0(v13, dwBytes, v9, v3 >> 4) )
{
v4 = lpMem;
goto LABEL_44;
}
v4 = (LPVOID)sub_4086A4(v3 >> 4);
if ( v4 )
{
v11 = 16 * *(_BYTE *)v10;
if ( v11 >= v3 )
v11 = v3;
memcpy_0(v4, lpMem, v11);
sub_40865F(v13, dwBytes, v10);
LABEL_44:
if ( v4 )
return v4;
goto LABEL_45;
}
}
LABEL_45:
v4 = HeapAlloc(hHeap, 0, v3);
if ( !v4 )
goto LABEL_51;
v12 = 16 * *(_BYTE *)v10;
if ( v12 >= v3 )
v12 = v3;
memcpy_0(v4, lpMem, v12);
sub_40865F(v13, dwBytes, v10);
LABEL_50:
if ( v4 )
return v4;
LABEL_51:
if ( !dword_4130D8 )
return v4;
if ( !_callnewh(v3) )
return 0;
}
}
while ( 1 )
{
result = 0;
if ( v3 <= 0xFFFFFFE0 )
{
if ( !v3 )
v3 = 1;
v3 = (v3 + 15) & 0xFFFFFFF0;
result = HeapReAlloc(hHeap, 0, lpMem, v3);
if ( result )
break;
}
if ( !dword_4130D8 )
break;
if ( !_callnewh(v3) )
return 0;
}
return result;
}
// 4078AD: using guessed type _DWORD __cdecl __sbh_find_block(_DWORD);
// 407C01: using guessed type _DWORD __cdecl __sbh_alloc_block(_DWORD);
// 4080B6: using guessed type _DWORD __cdecl __sbh_resize_block(_DWORD, _DWORD, _DWORD);
// 408A79: using guessed type _DWORD __cdecl _callnewh(_DWORD);
// 4126B4: using guessed type int dword_4126B4;
// 4130D8: using guessed type int dword_4130D8;
// 4136F0: using guessed type int dword_4136F0;
// 4136F8: using guessed type int dword_4136F8;
//----- (0040A4B8) --------------------------------------------------------
SIZE_T __cdecl sub_40A4B8(LPCVOID lpMem)
{
SIZE_T result; // eax@3
unsigned int v2; // eax@6
char v3; // [sp+4h] [bp-8h]@6
char v4; // [sp+8h] [bp-4h]@6
if ( dword_4136F8 == 3 )
{
if ( __sbh_find_block(lpMem) )
result = *((_DWORD *)lpMem - 1) - 9;
else
result = HeapSize(hHeap, 0, lpMem);
}
else if ( dword_4136F8 == 2 && (v2 = sub_408608((unsigned int)lpMem, (int)&v3, (int)&v4)) != 0 )
{
result = 16 * *(_BYTE *)v2;
}
else
{
result = HeapSize(hHeap, 0, lpMem);
}
return result;
}
// 4078AD: using guessed type _DWORD __cdecl __sbh_find_block(_DWORD);
// 4136F8: using guessed type int dword_4136F8;
//----- (0040AF25) --------------------------------------------------------
LPVOID __cdecl sub_40AF25(size_t a1, int a2)
{
unsigned int v2; // esi@1
LPVOID v3; // edi@5
size_t v5; // [sp+10h] [bp+8h]@1
v2 = a2 * a1;
v5 = a2 * a1;
if ( v5 <= 0xFFFFFFE0 )
{
if ( !v2 )
v2 = 1;
v2 = (v2 + 15) & 0xFFFFFFF0;
}
do
{
v3 = 0;
if ( v2 > 0xFFFFFFE0 )
goto LABEL_14;
if ( dword_4136F8 == 3 )
{
if ( v5 > dword_4136F0 )
goto LABEL_13;
v3 = (LPVOID)__sbh_alloc_block(v5);
if ( !v3 )
goto LABEL_13;
memset(v3, 0, v5);
return v3;
}
if ( dword_4136F8 == 2 && v2 <= dword_4126B4 )
{
v3 = (LPVOID)sub_4086A4(v2 >> 4);
if ( v3 )
{
memset(v3, 0, v2);
return v3;
}
}
LABEL_13:
v3 = HeapAlloc(hHeap, 8u, v2);
if ( v3 )
return v3;
LABEL_14:
if ( !dword_4130D8 )
return v3;
}
while ( _callnewh(v2) );
return 0;
}
// 407C01: using guessed type _DWORD __cdecl __sbh_alloc_block(_DWORD);
// 408A79: using guessed type _DWORD __cdecl _callnewh(_DWORD);
// 4126B4: using guessed type int dword_4126B4;
// 4130D8: using guessed type int dword_4130D8;
// 4136F0: using guessed type int dword_4136F0;
// 4136F8: using guessed type int dword_4136F8;
//----- (0040CE70) --------------------------------------------------------
int __usercall sub_40CE70@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 + 8);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040CE78) --------------------------------------------------------
void __usercall sub_40CE78(int a1@<ebp>)
{
sub_402C90(a1 - 60);
}
//----- (0040CE80) --------------------------------------------------------
void __usercall sub_40CE80(int a1@<ebp>)
{
sub_402C90(a1 - 60);
}
//----- (0040CE88) --------------------------------------------------------
void __usercall sub_40CE88(int a1@<ebp>)
{
sub_402C90(a1 - 36);
}
//----- (0040CE90) --------------------------------------------------------
int __usercall sub_40CE90@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 61);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040CE98) --------------------------------------------------------
void __usercall sub_40CE98(int a1@<ebp>)
{
sub_402C90(a1 - 48);
}
//----- (0040CEA0) --------------------------------------------------------
void __usercall sub_40CEA0(int a1@<ebp>)
{
sub_402C90(a1 - 48);
}
//----- (0040CEA8) --------------------------------------------------------
void __usercall sub_40CEA8(int a1@<ebp>)
{
sub_402C90(a1 - 24);
}
//----- (0040CEB0) --------------------------------------------------------
void __usercall sub_40CEB0(int a1@<ebp>)
{
sub_402C90(a1 - 36);
}
//----- (0040CEB8) --------------------------------------------------------
void __usercall sub_40CEB8(int a1@<ebp>)
{
sub_402C90(a1 - 24);
}
//----- (0040CEC0) --------------------------------------------------------
void __usercall sub_40CEC0(int a1@<ebp>)
{
sub_402C90(a1 - 24);
}
//----- (0040CEE0) --------------------------------------------------------
int __usercall sub_40CEE0@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 1426);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040CEEB) --------------------------------------------------------
void __usercall sub_40CEEB(int a1@<ebp>)
{
sub_402C90(a1 - 1412);
}
//----- (0040CEF6) --------------------------------------------------------
void __usercall sub_40CEF6(int a1@<ebp>)
{
sub_402C90(a1 - 1412);
}
//----- (0040CF01) --------------------------------------------------------
int __usercall sub_40CF01@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 1404);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040CF0C) --------------------------------------------------------
int __usercall sub_40CF0C@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 1426);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040CF17) --------------------------------------------------------
void __usercall sub_40CF17(int a1@<ebp>)
{
sub_402C90(a1 - 1424);
}
//----- (0040CF22) --------------------------------------------------------
void __usercall sub_40CF22(int a1@<ebp>)
{
sub_402C90(a1 - 1424);
}
//----- (0040CF2D) --------------------------------------------------------
void __usercall sub_40CF2D(int a1@<ebp>)
{
sub_402C90(a1 - 1304);
}
//----- (0040CF38) --------------------------------------------------------
int __usercall sub_40CF38@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 1296);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040CF43) --------------------------------------------------------
int __usercall sub_40CF43@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 1425);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040CF4E) --------------------------------------------------------
void __usercall sub_40CF4E(int a1@<ebp>)
{
sub_402C90(a1 - 1376);
}
//----- (0040CF59) --------------------------------------------------------
void __usercall sub_40CF59(int a1@<ebp>)
{
sub_402C90(a1 - 1376);
}
//----- (0040CF64) --------------------------------------------------------
void __usercall sub_40CF64(int a1@<ebp>)
{
sub_402C90(a1 - 1316);
}
//----- (0040CF6F) --------------------------------------------------------
int __usercall sub_40CF6F@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 1308);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040CF7A) --------------------------------------------------------
void __usercall sub_40CF7A(int a1@<ebp>)
{
sub_402C90(a1 - 1328);
}
//----- (0040CF85) --------------------------------------------------------
int __usercall sub_40CF85@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 1320);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040CF90) --------------------------------------------------------
void __usercall sub_40CF90(int a1@<ebp>)
{
sub_402C90(a1 - 1412);
}
//----- (0040CF9B) --------------------------------------------------------
int __usercall sub_40CF9B@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 1404);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040CFA6) --------------------------------------------------------
int __usercall sub_40CFA6@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 1368);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040CFB1) --------------------------------------------------------
int __usercall sub_40CFB1@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 1416);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040CFD0) --------------------------------------------------------
int __usercall sub_40CFD0@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 1626);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040CFDB) --------------------------------------------------------
void __usercall sub_40CFDB(int a1@<ebp>)
{
sub_402C90(a1 - 1620);
}
//----- (0040CFE6) --------------------------------------------------------
void __usercall sub_40CFE6(int a1@<ebp>)
{
sub_402C90(a1 - 1620);
}
//----- (0040CFF1) --------------------------------------------------------
int __usercall sub_40CFF1@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 1612);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D010) --------------------------------------------------------
int __usercall sub_40D010@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 2237);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D01B) --------------------------------------------------------
void __usercall sub_40D01B(int a1@<ebp>)
{
sub_402C90(a1 - 2236);
}
//----- (0040D026) --------------------------------------------------------
void __usercall sub_40D026(int a1@<ebp>)
{
sub_402C90(a1 - 2236);
}
//----- (0040D031) --------------------------------------------------------
int __usercall sub_40D031@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 2237);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D03C) --------------------------------------------------------
void __usercall sub_40D03C(int a1@<ebp>)
{
sub_402C90(a1 - 2220);
}
//----- (0040D047) --------------------------------------------------------
void __usercall sub_40D047(int a1@<ebp>)
{
sub_402C90(a1 - 2220);
}
//----- (0040D052) --------------------------------------------------------
int __usercall sub_40D052@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 2212);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D05D) --------------------------------------------------------
int __usercall sub_40D05D@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 2228);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D068) --------------------------------------------------------
int __usercall sub_40D068@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 2212);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D073) --------------------------------------------------------
int __usercall sub_40D073@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 2228);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D090) --------------------------------------------------------
int __usercall sub_40D090@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 1333);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D09B) --------------------------------------------------------
void __usercall sub_40D09B(int a1@<ebp>)
{
sub_402C90(a1 - 1332);
}
//----- (0040D0A6) --------------------------------------------------------
void __usercall sub_40D0A6(int a1@<ebp>)
{
sub_402C90(a1 - 1332);
}
//----- (0040D0B1) --------------------------------------------------------
int __usercall sub_40D0B1@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 1324);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D0BC) --------------------------------------------------------
int __usercall sub_40D0BC@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 1324);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D0E0) --------------------------------------------------------
int __usercall sub_40D0E0@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 2373);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D0EB) --------------------------------------------------------
void __usercall sub_40D0EB(int a1@<ebp>)
{
int v1; // edi@1
void *v2; // esi@1
void *v3; // eax@2
void *v4; // edi@5
v1 = a1 - 2380;
v2 = (void *)**(_DWORD **)(a1 - 2380);
if ( v2 != *(void **)(a1 - 2380) )
{
do
{
v3 = v2;
v2 = *(void **)v2;
if ( v3 )
sub_40565F(v3);
}
while ( v2 != *(void **)v1 );
}
**(_DWORD **)v1 = *(_DWORD *)v1;
*(_DWORD *)(*(_DWORD *)v1 + 4) = *(_DWORD *)v1;
v4 = *(void **)v1;
if ( v4 )
sub_40565F(v4);
}
//----- (0040D0F6) --------------------------------------------------------
int __usercall sub_40D0F6@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 2380);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D110) --------------------------------------------------------
int __usercall sub_40D110@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 301);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D11B) --------------------------------------------------------
void __usercall sub_40D11B(int a1@<ebp>)
{
sub_402C90(a1 - 292);
}
//----- (0040D126) --------------------------------------------------------
void __usercall sub_40D126(int a1@<ebp>)
{
sub_402C90(a1 - 292);
}
//----- (0040D131) --------------------------------------------------------
void __usercall sub_40D131(int a1@<ebp>)
{
sub_402C90(*(_DWORD *)(a1 + 4));
}
//----- (0040D139) --------------------------------------------------------
int __usercall sub_40D139@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 293);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D144) --------------------------------------------------------
void __usercall sub_40D144(int a1@<ebp>)
{
sub_402C90(a1 - 292);
}
//----- (0040D160) --------------------------------------------------------
int __usercall sub_40D160@<eax>(int a1@<ebp>)
{
return nullsub_1(*(_DWORD *)(a1 - 16));
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D190) --------------------------------------------------------
void __usercall sub_40D190(int a1@<ebp>)
{
sub_402C90(*(_DWORD *)(a1 - 296));
}
//----- (0040D19B) --------------------------------------------------------
int __usercall sub_40D19B@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 32);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D1A3) --------------------------------------------------------
int __usercall sub_40D1A3@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 305);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D1AE) --------------------------------------------------------
void __usercall sub_40D1AE(int a1@<ebp>)
{
sub_402C90(a1 - 292);
}
//----- (0040D1D0) --------------------------------------------------------
int __usercall sub_40D1D0@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 + 8);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D1D8) --------------------------------------------------------
int __usercall sub_40D1D8@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 16);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D1E0) --------------------------------------------------------
void __usercall sub_40D1E0(int a1@<ebp>)
{
sub_402C90(a1 - 24);
}
//----- (0040D1E8) --------------------------------------------------------
void __usercall sub_40D1E8(int a1@<ebp>)
{
sub_402C90(*(_DWORD *)(a1 + 4));
}
//----- (0040D1F0) --------------------------------------------------------
void __usercall sub_40D1F0(int a1@<ebp>)
{
if ( *(_DWORD *)(a1 - 28) & 1 )
sub_402C90(*(_DWORD *)(a1 + 4));
}
//----- (0040D220) --------------------------------------------------------
int __usercall sub_40D220@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 + 12);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D228) --------------------------------------------------------
int __usercall sub_40D228@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 16);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D230) --------------------------------------------------------
void __usercall sub_40D230(int a1@<ebp>)
{
sub_402C90(a1 - 24);
}
//----- (0040D238) --------------------------------------------------------
void __usercall sub_40D238(int a1@<ebp>)
{
sub_402C90(*(_DWORD *)(a1 + 4));
}
//----- (0040D240) --------------------------------------------------------
void __usercall sub_40D240(int a1@<ebp>)
{
if ( *(_DWORD *)(a1 - 28) & 1 )
sub_402C90(*(_DWORD *)(a1 + 4));
}
//----- (0040D270) --------------------------------------------------------
int __usercall sub_40D270@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 8);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D290) --------------------------------------------------------
int __usercall sub_40D290@<eax>(int a1@<ebp>)
{
return nullsub_1(a1 - 293);
}
// 403230: using guessed type int __thiscall nullsub_1(_DWORD);
//----- (0040D29B) --------------------------------------------------------
void __usercall sub_40D29B(int a1@<ebp>)
{
sub_402C90(a1 - 292);
}
//----- (0040D2A6) --------------------------------------------------------
void __usercall sub_40D2A6(int a1@<ebp>)
{
sub_402C90(a1 - 292);
}
// ALL OK, 167 function(s) have been successfully decompiled
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.