-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproxy.cpp
More file actions
39 lines (28 loc) · 872 Bytes
/
Copy pathproxy.cpp
File metadata and controls
39 lines (28 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "pch.h"
#include "Logger.h"
#include "Proxy.h"
HMODULE versionHMod;
void IProxy::Attach() {
LOG("Attaching to process.");
const auto name = GetTargetDllName();
const auto path = GetTargetDllPath();
LOG("Loading original dll: " << name << "\n From: " << path);
versionHMod = LoadLibrary(path.c_str());
if (versionHMod == nullptr) {
LOG("Unable to load base " << name << " dll.");
return;
}
LOG("Orig " << name << " loaded.");
}
void IProxy::Detach() {
const auto name = GetTargetDllName();
LOG("Unloading orig " << name << ".");
FreeLibrary(versionHMod);
}
std::string IProxy::GetDllPathFromSysPath(const std::string& dllName) {
char sysPath[MAX_PATH];
GetSystemDirectory(sysPath, MAX_PATH);
strcat_s(sysPath, "\\");
strcat_s(sysPath, dllName.c_str());
return sysPath;
}