From 8719b4570a2d10dd49a0d3a47e24f5c55bdda85e Mon Sep 17 00:00:00 2001 From: Amlal Date: Sun, 22 Sep 2024 17:46:11 +0200 Subject: :boom: A big refactor on the filesystem structure. Signed-off-by: Amlal --- dev/base/RunDLL64/build.json | 19 +++++++++++++++++++ dev/base/RunDLL64/src/LauncherMain.cxx | 22 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 dev/base/RunDLL64/build.json create mode 100644 dev/base/RunDLL64/src/LauncherMain.cxx (limited to 'dev/base/RunDLL64') diff --git a/dev/base/RunDLL64/build.json b/dev/base/RunDLL64/build.json new file mode 100644 index 00000000..a69dbb11 --- /dev/null +++ b/dev/base/RunDLL64/build.json @@ -0,0 +1,19 @@ +{ + "compiler_path": "x86_64-w64-mingw32-g++", + "compiler_std": "c++20", + "headers_path": ["../", "./", "../../"], + "sources_path": ["src/*.cxx"], + "output_name": "rundll64.exe", + "compiler_flags": [ + "-ffreestanding", + "-fno-rtti", + "-fno-exceptions", + " -Wl,--subsystem=17" + ], + "cpp_macros": [ + "__RUNDLL_AMD64__", + "cRunDLLVersion=0x0100", + "cRunDLLVersionHighest=0x0100", + "cRunDLLVersionLowest=0x0100" + ] +} diff --git a/dev/base/RunDLL64/src/LauncherMain.cxx b/dev/base/RunDLL64/src/LauncherMain.cxx new file mode 100644 index 00000000..ed1ab65c --- /dev/null +++ b/dev/base/RunDLL64/src/LauncherMain.cxx @@ -0,0 +1,22 @@ +#include + +typedef int (*MainKind)(int, char**); + +int WinMain(int argc, char* argv[]) +{ + if (argc < 3) + return -1; + + auto mainDll = LdrOpenDLL(argv[1], argv[2]); + + int (*entrypointOff)(int, char**) = (MainKind)LdrGetDLLProc(argv[3], mainDll); + + if (!entrypointOff) + return -1; + + int ret = entrypointOff(argc, argv); + + LdrCloseDLL(mainDll); + + return ret; +} -- cgit v1.2.3