diff options
author | Jose Fonseca <jfonseca@vmware.com> | 2017-03-10 09:02:08 +0000 |
---|---|---|
committer | Jose Fonseca <jfonseca@vmware.com> | 2017-03-10 09:02:08 +0000 |
commit | 17601b582ea425808955499e0bc61d66375cae14 (patch) | |
tree | e77959272e47fe0cdf4d517cce9d35ea16437ca5 | |
parent | fc599b8670e9a187ac4769a253672fecb14e0f83 (diff) |
inject: Copy DLLs to system dir.dwm-v3
-rw-r--r-- | inject/CMakeLists.txt | 1 | ||||
-rw-r--r-- | inject/injector.cpp | 25 |
2 files changed, 25 insertions, 1 deletions
diff --git a/inject/CMakeLists.txt b/inject/CMakeLists.txt index e98b077d..51ac327e 100644 --- a/inject/CMakeLists.txt +++ b/inject/CMakeLists.txt @@ -42,6 +42,7 @@ target_link_libraries (injector ${GETOPT_LIBRARIES} devcon psapi + os ) install (TARGETS injector RUNTIME DESTINATION bin) install_pdb (injector DESTINATION bin) diff --git a/inject/injector.cpp b/inject/injector.cpp index 95df0020..925d0a6f 100644 --- a/inject/injector.cpp +++ b/inject/injector.cpp @@ -57,6 +57,7 @@ #endif #include "os_version.hpp" +#include "os_string.hpp" #include "uac.hpp" #include "devcon.hpp" #include "inject.h" @@ -553,7 +554,7 @@ main(int argc, char *argv[]) fprintf(stderr, "IsUserInAdminGroup = %i\n", IsUserInAdminGroup()); fprintf(stderr, "IsRunAsAdmin = %i\n", IsRunAsAdmin()); fprintf(stderr, "IsProcessElevated = %i\n", IsProcessElevated()); - if (0) { + if (!IsProcessElevated()) { // Elevate the process. char szPath[MAX_PATH]; GetModuleFileNameA(NULL, szPath, sizeof szPath); @@ -597,7 +598,29 @@ main(int argc, char *argv[]) return 0; } else { + fprintf(stderr, "info: press any key to exit\n"); atexit((void (*)(void)) getchar); + + os::String injecteeDll = os::getProcessName(); + injecteeDll.trimFilename(); + injecteeDll.join(szDllName); + + char szSystemDir[MAX_PATH]; + GetSystemDirectory(szSystemDir, _countof(szSystemDir)); + + os::String dest = szSystemDir; + dest.join(szDllName); + if (!CopyFileA(injecteeDll.str(), dest.str(), FALSE)) { + fprintf(stderr, "error: failed to copy %s to %s\n", injecteeDll.str(), dest.str()); + exit(1); + } + + dest = szSystemDir; + dest.join("dxgitrace.dll"); + if (!CopyFileA(szDll, dest.str(), FALSE)) { + fprintf(stderr, "error: failed to copy %s to %s\n", szDll, dest.str()); + exit(1); + } } HANDLE hSemaphore = NULL; |