-
Notifications
You must be signed in to change notification settings - Fork 23
/
VMDLL.cpp
87 lines (65 loc) · 1.92 KB
/
VMDLL.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
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
76
77
78
79
80
81
82
83
84
85
86
87
// VMDLL.cpp : Implementation of DLL Exports, etc.
#ifndef _DEBUG
#pragma optimize("s", on)
#pragma auto_inline(off)
#endif
#include "ist.h"
#include <initguid.h>
#include "DolphinSmalltalk.h"
#include "VMDll.h"
#include "dlldatax.h"
#pragma code_seg(ATL_SEG)
#include "DolphinSmalltalk_i.c"
#ifndef VMDLL
#error "This file is part of the VM DLL"
#endif
/////////////////////////////////////////////////////////////////////////////
// Globals
CDolphinVMModule _Module;
/////////////////////////////////////////////////////////////////////////////
// Registration helper
HRESULT CDolphinVMModule::RegisterAsEventSource() const
{
static TCHAR* szKeyStem = _T("SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\");
HRESULT hr;
TCHAR szKey[512];
_tcscpy(szKey, szKeyStem);
_tcscat(szKey, _T("Dolphin"));
CRegKey rkeyEvSrc;
// Register as an event source with message table in this DLL
LONG ret = rkeyEvSrc.Create(HKEY_LOCAL_MACHINE, szKey);
if (ret == ERROR_SUCCESS)
{
TCHAR szModule[_MAX_PATH];
::GetModuleFileName(_AtlBaseModule.GetModuleInstance(), szModule, _MAX_PATH);
rkeyEvSrc.SetStringValue(_T("EventMessageFile"), szModule);
rkeyEvSrc.SetDWORDValue(_T("TypesSupported"), 7);
hr = S_OK;
}
else
hr = AtlHresultFromWin32(ret);
return hr;
}
HRESULT CDolphinVMModule::RegisterServer(BOOL bRegTypeLib)
{
HRESULT hr = CAtlModuleT<CDolphinVMModule>::RegisterServer(bRegTypeLib);
if (SUCCEEDED(hr))
hr = RegisterAsEventSource();
return hr;
}
///////////////////////////////////////////////////////////////////////////////
// Common entry points
#include "DllModule.cpp"
///////////////////////////////////////////////////////////////////////////////
// Other common functions
HMODULE __stdcall GetResLibHandle()
{
extern HMODULE GetVMModule();
return GetVMModule();
}
#pragma code_seg(INIT_SEG)
HINSTANCE GetApplicationInstance()
{
extern HINSTANCE hApplicationInstance;
return hApplicationInstance;
}