-
Notifications
You must be signed in to change notification settings - Fork 91
/
dllmain.cpp
45 lines (34 loc) · 1.15 KB
/
dllmain.cpp
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
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full
// license information.
#include "dllmain.h"
#include "class_factory.h"
const IID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
const IID IID_IClassFactory = {0x00000001, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
HINSTANCE DllHandle;
extern "C" {
BOOL STDMETHODCALLTYPE DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
DllHandle = hModule;
return TRUE;
}
HRESULT STDMETHODCALLTYPE DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
// {918728DD-259F-4A6A-AC2B-B85E1B658318}
const GUID CLSID_CorProfiler = {0x918728dd, 0x259f, 0x4a6a, {0xac, 0x2b, 0xb8, 0x5e, 0x1b, 0x65, 0x83, 0x18}};
if (ppv == NULL || rclsid != CLSID_CorProfiler)
{
return E_FAIL;
}
auto factory = new ClassFactory;
if (factory == NULL)
{
return E_FAIL;
}
return factory->QueryInterface(riid, ppv);
}
HRESULT STDMETHODCALLTYPE DllCanUnloadNow()
{
return S_OK;
}
}