InitSystemFunctions

解读 InitSystemFunctions



//----- (10009460) --------------------------------------------------------
signed int __thiscall InitSystemFunctions(void *this)
{
  int v1; // eax@2
  HMODULE v2; // eax@3
  FARPROC v3; // eax@4
  HMODULE v4; // eax@7
  char Dst; // [sp+0h] [bp-108h]@6
  if ( !dword_10030900 )
  {
    dword_10030900 = 1;
    g_DefaultACL = (int)this;
    v1 = IsSystemNT();
    g_AddVectoredExceptionHandler = AddVectoredExceptionHandlerStub;
    if ( v1 )
    {
      g_CreateMutex = CreateMutexWin32W;
      g_CreateSharedMemory = CreateSharedMemoryWin32W;
      g_CreateSharedFile = CreateSharedFileWin32W;
      g_GetModuleFileNameA = GetModuleFileNameAWin32A;
      g_GetModuleFileNameW = GetModuleFileNameWWin32W;
      g_CreateFile = CreateFileWin32W;
      g_DeleteFile = CIlKernel32::DeleteFileW;
      v2 = GetModuleHandleW(L"kernel32");
      if ( v2 )
      {
        v3 = GetProcAddress(v2, "AddVectoredExceptionHandler");
        if ( v3 )
          g_AddVectoredExceptionHandler = v3;
      }
    }
    else
    {
      g_CreateMutex = CreateMutexWin32A;
      g_CreateSharedMemory = CreateSharedMemoryWin32A;
      g_CreateSharedFile = CreateSharedFileWin32A;
      g_GetModuleFileNameA = GetModuleFileNameAWin32A;
      g_GetModuleFileNameW = GetModuleFileNameWWin32A;
      g_CreateFile = CreateFileWin32A;
      g_DeleteFile = DeleteFileWin32A;
    }
    g_ReleaseMutex = ReleaseMutexWin32;
    g_WaitForSingleObject = (CIlKernel32 *)CIlKernel32::WaitForSingleObject;
    g_CloseHandle = CloseHandleWin32;
    g_MapSharedMemory = MapSharedMemoryWin32;
    g_UnMapSharedMemory = CIlKernel32::UnmapViewOfFile;
    g_SetFilePointer = SetFilePointerWin32;
    g_WriteFile = WriteFileWin32;
    memset(&Dst, 0, 0x104u);
    if ( ExpandEnvironmentStringsA("%windir%\\system32\\dbghelp.dll", &Dst, 0x104u) )
    {
      v4 = LoadLibraryExA(&Dst, 0, 0);
      if ( v4 )
      {
        g_MiniDumpWriteDump = GetProcAddress(v4, "MiniDumpWriteDump");
      }
      else
      {
        g_MiniDumpWriteDump = MiniDumpWriteDumpStub;
        FreeLibrary(0);
      }
    }
    else
    {
      g_MiniDumpWriteDump = MiniDumpWriteDumpStub;
    }
  }
  return 1;
}

你可能感兴趣的:(WCP,操作系统相关,面向语言编程,系统维护)