Files
WoWDBDefs/exedumper/initial_dump_from_binary-3.0.2.8885/injector.cpp
T
Bernd Lörwald 3faf1ab222 initial_dump_from_binary_3.0.2.8885
(cherry picked from commit 45d89b59724dd2523efbde72fca6074326f8c37f)
2018-03-12 21:48:19 +01:00

45 lines
963 B
C++

#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <thread>
#include <chrono>
#include <windows.h>
#include <tlhelp32.h>
#include <easyhook.h>
#include <tchar.h>
int wmain(int argc, WCHAR* argv[])
{
if (argc < 3) {
std::wcout << argv[0] << " dll command_line\n";
return 1;
}
std::wstring dllToInject (argv[1]);
std::wstring exe (argv[2]);
exe = exe.substr (0, exe.find (' '));
std::wstring command_line (argv[2]);
command_line = command_line.substr (command_line.find (' ') + 1);
ULONG pid;
NTSTATUS nt = RhCreateAndInject
( const_cast<WCHAR*> (exe.c_str())
, const_cast<WCHAR*> (command_line.c_str())
, 0
, EASYHOOK_INJECT_DEFAULT
, const_cast<WCHAR*> (dllToInject.c_str())
, nullptr
, nullptr
, 0
, &pid
);
if (nt != 0)
{
std::wcout << "RhCreateAndInject failed with error code = " << nt << "\n " << RtlGetLastErrorString() << "\n";
return 1;
}
return 0;
}