I decided to learn how to write DLLs, just for the sake of interest, to see what happens. I found several videos on this topic and, began to try to understand what this person actually writes, after 3 views of this video I went to the code, but I did not write it on the game that was shining in the video (Just because I don’t like to repeat everything 1 in 1). The result is the following: Hack.cpp

#include <Windows.h> #include <iostream> #include "ExMachina.h" #include <io.h> #include <stdio.h> #include <fcntl.h> 

Creating a thread.

 DWORD WINAPI ExMachina_Thread(LPVOID lpReserved); 

Implementation.

 DWORD APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: CreateThread(NULL, NULL, ExMachina_Thread, NULL, NULL, NULL); case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return true; }; 

Next is the console call method.

 void CreateConsole() { int hConHandle = 0; HANDLE lStdHandle = 0; FILE *fp = 0; AllocConsole(); SetConsoleTitle("ExMachina Debug"); lStdHandle = GetStdHandle(STD_OUTPUT_HANDLE); hConHandle = _open_osfhandle(PtrToUlong(lStdHandle), _O_TEXT); fp = _fdopen(hConHandle, "w"); *stdout = *fp; setvbuf(stdout, NULL, _IONBF, 0); } 

Well, respectively, the stream itself and its functions:

 DWORD WINAPI ExMachina_Thread(LPVOID lpReserved) { CreateConsole(); DWORD Address = (DWORD)GetModuleHandle("hta.exe") + 0x6135E4; ExMachina* EXMACHINA = ExMachina::Singleton(Address, 0x118); for (;;Sleep(75)) { printf("Succesfly inject 0x%x", EXMACHINA); std::cout << "Succesfly inject 0x%X", EXMACHINA; } } 

As you can see from the connected libraries there are both stdio.h and iostream, but neither one nor the other information that I need does not display. What can you do about it?

  • You can disassemble the tail - Console appeared? - nick_n_a
  • You can disassemble from the head - your DLL is loaded? You can see ... let's say the old ProcessExplorer from Sysinternals. Maybe you do not have enough rights to implement. - nick_n_a
  • @nick_n_a Console has appeared. - MedBED
  • And yes, the DLL, judging by the error that occurs in cases of repeated dll compilation when it injects from the Visual Studio folder, loaded into the game. - MedBED
  • Why so hard (do FILE * ) try to drive an outdated _lwrite((int)lStdHandle, "Hello", 5); Use plain WriteFile . If you write Hello - then redo the output. I did not make such a difficult conclusion to the console. - nick_n_a

0