<commit_before>/*
This file is part of HadesMem.
Copyright (C) 2010 <NAME> (aka RaptorFactor, Cypherjb, Cypher, Chazwazza).
<http://www.raptorfactor.com/> <<EMAIL>>

HadesMem is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

HadesMem is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with HadesMem.  If not, see <http://www.gnu.org/licenses/>.
*/

// Windows API
#include <Windows.h>

// Boost
#include <boost/format.hpp>

// Hades
#include "Kernel.hpp"
#include "HadesMemory/Memory.hpp"
#include "HadesCommon/Logger.hpp"
#include "HadesCommon/Filesystem.hpp"
#include "HadesRenderer/Renderer.hpp"
#include "HadesCommon/EnsureCleanup.hpp"

// Initialize kernel
// Todo: Ensure safe for reentry
extern "C" __declspec(dllexport) DWORD __stdcall Initialize(HMODULE Module)
{
  try
  {
    // Break to debugger if present
    if (IsDebuggerPresent())
    {
      DebugBreak();
    }
    
    // Initialize logger
    Hades::Util::InitLogger(L"Log", L"Debug");
      
    // Debug output
    HADES_LOG_THREAD_SAFE(std::wcout << boost::wformat(
      L"Hades-Kernel::Initialize: Module Base = %p, Path to Self = %s, "
      L"Path to Bin = %s.") %Module %Hades::Windows::GetSelfPath() 
      %Hades::Windows::GetModulePath(nullptr));
        
    // Initialize Kernel
    static Hades::Kernel::Kernel MyKernel;
    MyKernel.LoadExtension("HadesD3D9.dll");
    MyKernel.LoadExtension("HadesD3D11.dll");
  }
  catch (std::exception const& e)
  {
    // Dump error information
    std::cout << boost::diagnostic_information(e) << std::endl;
  }

  // Success
  return 0;
}

// Entry point
BOOL WINAPI DllMain(
  HINSTANCE /*hinstDLL*/, 
  DWORD /*fdwReason*/, 
  LPVOID /*lpvReserved*/)
{
  // Attempt to detect memory leaks in debug mode
#ifdef _DEBUG
  int CurrentFlags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
  int NewFlags = (_CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_LEAK_CHECK_DF | 
    _CRTDBG_CHECK_ALWAYS_DF);
  _CrtSetDbgFlag(CurrentFlags | NewFlags);
#endif
    
  return TRUE;<commit_msg>* Logging fix.<commit_after>/*
This file is part of HadesMem.
Copyright (C) 2010 <NAME> (aka RaptorFactor, Cypherjb, Cypher, Chazwazza).
<http://www.raptorfactor.com/> <<EMAIL>>

HadesMem is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

HadesMem is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with HadesMem.  If not, see <http://www.gnu.org/licenses/>.
*/

// Windows API
#include <Windows.h>

// Boost
#include <boost/format.hpp>

// Hades
#include "Kernel.hpp"
#include "HadesMemory/Memory.hpp"
#include "HadesCommon/Logger.hpp"
#include "HadesCommon/Filesystem.hpp"
#include "HadesRenderer/Renderer.hpp"
#include "HadesCommon/EnsureCleanup.hpp"

// Initialize kernel
// Todo: Ensure safe for reentry
extern "C" __declspec(dllexport) DWORD __stdcall Initialize(HMODULE Module)
{
  try
  {
    // Break to debugger if present
    if (IsDebuggerPresent())
    {
      DebugBreak();
    }
    
    // Initialize logger
    Hades::Util::InitLogger(L"Log", L"Debug");
      
    // Debug output
    HADES_LOG_THREAD_SAFE(std::wcout << boost::wformat(
      L"Hades-Kernel::Initialize: Module Base = %p, Path to Self = %s, "
      L"Path to Bin = %s.") %Module %Hades::Windows::GetSelfPath() 
      %Hades::Windows::GetModulePath(nullptr) << std::endl);
        
    // Initialize Kernel
    static Hades::Kernel::Kernel MyKernel;
    MyKernel.LoadExtension("HadesD3D9.dll");
    MyKernel.LoadExtension("HadesD3D11.dll");
  }
  catch (std::exception const& e)
  {
    // Dump error information
    std::cout << boost::diagnostic_information(e) << std::endl;
  }

  // Success
  return 0;
}

// Entry point
BOOL WINAPI DllMain(
  HINSTANCE /*hinstDLL*/, 
  DWORD /*fdwReason*/, 
  LPVOID /*lpvReserved*/)
{
  // Attempt to detect memory leaks in debug mode
#ifdef _DEBUG
  int CurrentFlags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
  int NewFlags = (_CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_LEAK_CHECK_DF | 
    _CRTDBG_CHECK_ALWAYS_DF);
  _CrtSetDbgFlag(CurrentFlags | NewFlags);
#endif
    
  return TRUE;
{'fraction_non_alphanumeric': 0.11147948611686698, 'fraction_numerical': 0.0045586406962287605, 'mean_word_length': 3.817365269461078, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5265247', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1557, 'n_words': 470}