-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregsvr32debugger.cpp
More file actions
45 lines (32 loc) · 1.12 KB
/
regsvr32debugger.cpp
File metadata and controls
45 lines (32 loc) · 1.12 KB
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
40
41
42
43
44
45
#include <iostream>
#include <windows.h>
#include <detours.h>
#include <map>
#include <cstdlib>
#include <vector>
#include "utils.h"
#include "detours.h"
#include "cli.h"
#include "printer.h"
typedef HRESULT(STDAPICALLTYPE * DllRegisterServer_t)();
int main(int argc, char** argv)
{
CLI::Options cli = CLI::ReadOptions(argc, argv);
RegLog log;
PatchAllDetours(&log);
if (cli.help || cli.dllPath.empty())
Printer::PrintHelp(cli);
if (cli.dllPath.empty())
return 0;
HMODULE dllHandle = LoadLibraryA(cli.dllPath.c_str());
if (!dllHandle)
return Printer::PrintError("Could not load library ", cli.dllPath);
DllRegisterServer_t dllRegisterServer = (DllRegisterServer_t)GetProcAddress(dllHandle, "DllRegisterServer");
if (!dllRegisterServer)
return Printer::PrintError("DllRegisterServer entrypoint not found in file ", cli.dllPath);
Printer::PrintTitle(cli);
HRESULT result = dllRegisterServer();
if (result == S_OK)
Printer::PrintRegLog(log, cli);
std::cout << "DLLRegisterServer exited with status code " << result << std::endl << std::endl;
}