// dllmain.cpp : Defines the entry point for the DLL application. #include "pch.h" void __stdcall main_thread(HMODULE current_module) { const auto create_console = []() -> bool { if (AllocConsole()) { freopen_s(reinterpret_cast(stdin), "CONIN$", "r", stdin); freopen_s(reinterpret_cast(stdout), "CONOUT$", "w", stdout); SetConsoleTitleA("[amlegit_dll] - xerox@hacks.ltd"); return true; } return false; }; //check to make sure we actually alloc console if (!create_console()) FreeLibraryAndExitThread(current_module, EXIT_FAILURE); std::cout << "[+] Hello world" << std::endl; FreeConsole(); FreeLibraryAndExitThread(current_module, EXIT_SUCCESS); } bool __stdcall DllMain(HMODULE module_entry, std::uint32_t call_reason, void*) { if (call_reason == DLL_PROCESS_ATTACH) if (CreateThread(nullptr, 0, reinterpret_cast(main_thread), module_entry, 0, nullptr) != INVALID_HANDLE_VALUE) return true; else FreeLibraryAndExitThread(module_entry, EXIT_FAILURE); else return false; }