-
Notifications
You must be signed in to change notification settings - Fork 4
/
host.h
75 lines (69 loc) · 1.93 KB
/
host.h
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#pragma once
#include <mscoree.h>
// this is per application, you will have to specify the guid that belongs to the appdomain that is open to COM.
// this is filled out to work with BlazeBest's BlazeEngine-IL2CPP project, if you have a different application you will need to change it accordingly.
struct __declspec(uuid("E86B87C8-5FC2-442E-A2AB-EAB2E594FEAE")) INetDomain : IUnknown
{
virtual void Initialize();
virtual void OnApplicationStart();
virtual void MinHook_CreateInstance(LPVOID mGetLicense, LPVOID mVRC_CreateHook, LPVOID mVRC_RemoveHook, LPVOID mVRC_EnableHook, LPVOID mVRC_DisableHook);
};
class host_ctrl : public IHostControl
{
public:
host_ctrl()
{
ref_count = 0;
domain_manager = NULL;
}
virtual ~host_ctrl()
{
if (domain_manager != nullptr)
{
domain_manager->Release();
}
}
INetDomain* get_domainmanager()
{
if (domain_manager)
{
domain_manager->AddRef();
}
return domain_manager;
}
HRESULT __stdcall GetHostManager(REFIID riid, void** ppv)
{
*ppv = NULL;
return E_NOINTERFACE;
}
HRESULT __stdcall SetAppDomainManager(DWORD dwAppDomainID, IUnknown* pUnkAppDomainManager)
{
HRESULT hr = S_OK;
hr = pUnkAppDomainManager->QueryInterface(__uuidof(INetDomain), (PVOID*)&domain_manager);
return hr;
}
// required overrides by IUnknown
HRESULT __stdcall QueryInterface(const IID& iid, void** ppv)
{
if (!ppv) return E_POINTER;
*ppv = this;
AddRef();
return S_OK;
}
ULONG __stdcall AddRef()
{
return InterlockedIncrement(&ref_count);
}
ULONG __stdcall Release()
{
if (InterlockedDecrement(&ref_count) == 0)
{
delete this;
return 0;
}
return ref_count;
}
private:
long ref_count;
INetDomain* domain_manager;
};