You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.0 KiB
40 lines
1.0 KiB
// 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<FILE**>(stdin), "CONIN$", "r", stdin);
|
|
freopen_s(reinterpret_cast<FILE**>(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<LPTHREAD_START_ROUTINE>(main_thread), module_entry, 0, nullptr) != INVALID_HANDLE_VALUE)
|
|
return true;
|
|
else
|
|
FreeLibraryAndExitThread(module_entry, EXIT_FAILURE);
|
|
else
|
|
return false;
|
|
}
|
|
|
|
|