diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2019-09-21 20:26:57 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2019-09-21 20:26:57 +0200 |
commit | ff0593c6421b7f5aef9eb292edf75d04b2e2f8eb (patch) | |
tree | c06a28ff6ac15698196b72723ccf7fd67f88dae7 | |
parent | adcfd9f77a8af13533cfa76d2349d7d55a5c2470 (diff) |
example DLL mapping code
-rw-r--r-- | CMD/CMD.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/CMD/CMD.cpp b/CMD/CMD.cpp index 03caee4..a9e4388 100644 --- a/CMD/CMD.cpp +++ b/CMD/CMD.cpp @@ -1,6 +1,7 @@ #include "pch.h" #include "KMemDriver.h" #include "KInterface.h" +#include "DLLHelper.h" #include <iostream> #include <iomanip> @@ -139,6 +140,25 @@ int wmain(int argc, wchar_t **argv) if (!ki.VFree(targetPID, targetAddr, targetSize)) { std::wcout << L"VFree failed" << std::endl; } + + static bool map_test_dll = true; + if (map_test_dll) { + map_test_dll = false; + DLLHelper dll; + if (!dll.Init(targetPID, "./TestDLL.dll")) { + std::wcout << L"DLL Init failed" << std::endl; + } + if (!dll.VerifyHeader()) { + std::wcout << L"DLL VerifyHeader failed" << std::endl; + } + if (!dll.InitTargetMemory()) { + std::wcout << L"DLL InitTargetMemory failed" << std::endl; + } + if (!dll.FixImports()) { + std::wcout << L"DLL FixImports failed" << std::endl; + } + std::wcout << L"DLL mapping succesful" << std::endl; + } } catch (std::runtime_error& err) { std::wcout << err.what() << std::endl; |