-
Notifications
You must be signed in to change notification settings - Fork 22
/
main_common.c
124 lines (100 loc) · 2.97 KB
/
main_common.c
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include "stdafx.h"
#include "main_common.h"
#include "plugin.h"
#include "raedit.h"
#include "assembler_dlg.h"
#include "resource.h"
HINSTANCE hDllInst;
OPTIONS options;
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
hDllInst = hinstDLL;
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
TCHAR *PluginInit(HINSTANCE hInst)
{
INITCOMMONCONTROLSEX icex;
TCHAR *pError;
// Ensure that the common control DLL is loaded.
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&icex);
// For drag'n'drop support
if(FAILED(OleInitialize(NULL)))
return _T("OleInitialize() failed");
// Install RAEdit control
InstallRAEdit(hInst, FALSE);
// Init stuff
pError = AssemblerInit();
if(pError)
{
UnInstallRAEdit();
return pError;
}
// Load options
MyGetintfromini(hInst, _T("disasm_rva"), &options.disasm_rva, 0, 0, 1);
MyGetintfromini(hInst, _T("disasm_rva_reloconly"), &options.disasm_rva_reloconly, 0, 0, 1);
MyGetintfromini(hInst, _T("disasm_label"), &options.disasm_label, 0, 0, 1);
MyGetintfromini(hInst, _T("disasm_extjmp"), &options.disasm_extjmp, 0, 0, 1);
MyGetintfromini(hInst, _T("disasm_hex"), &options.disasm_hex, 0, 4, 0);
MyGetintfromini(hInst, _T("disasm_labelgen"), &options.disasm_labelgen, 0, 2, 0);
MyGetintfromini(hInst, _T("asm_comments"), &options.asm_comments, 0, 0, 1);
MyGetintfromini(hInst, _T("asm_labels"), &options.asm_labels, 0, 0, 1);
MyGetintfromini(hInst, _T("edit_savepos"), &options.edit_savepos, 0, 0, 1);
MyGetintfromini(hInst, _T("edit_tabwidth"), &options.edit_tabwidth, 0, 2, 1);
return NULL;
}
void PluginExit()
{
AssemblerExit();
UnInstallRAEdit();
OleUninitialize();
}
BOOL OpenHelp(HWND hWnd, HINSTANCE hInst)
{
TCHAR szFilePath[MAX_PATH];
DWORD dwPathLen;
dwPathLen = GetModuleFileName(hInst, szFilePath, MAX_PATH);
if(dwPathLen == 0)
return FALSE;
do
{
dwPathLen--;
if(dwPathLen == 0)
return FALSE;
}
while(szFilePath[dwPathLen] != _T('\\'));
dwPathLen++;
szFilePath[dwPathLen] = _T('\0');
dwPathLen += sizeof("multiasm.chm") - 1;
if(dwPathLen > MAX_PATH - 1)
return FALSE;
lstrcat(szFilePath, _T("multiasm.chm"));
return !((int)(UINT_PTR)ShellExecute(hWnd, NULL, szFilePath, NULL, NULL, SW_SHOWNORMAL) <= 32);
}
int AboutMessageBox(HWND hWnd, HINSTANCE hInst)
{
MSGBOXPARAMS mbpMsgBoxParams;
ZeroMemory(&mbpMsgBoxParams, sizeof(MSGBOXPARAMS));
mbpMsgBoxParams.cbSize = sizeof(MSGBOXPARAMS);
mbpMsgBoxParams.hwndOwner = hWnd;
mbpMsgBoxParams.hInstance = hInst;
mbpMsgBoxParams.lpszText =
_T("Multiline Ultimate Assembler v") DEF_VERSION _T("\n")
_T("By RaMMicHaeL\n")
_T("http://rammichael.com/\n")
_T("\n")
_T("Compiled on: ") _T(__DATE__);
mbpMsgBoxParams.lpszCaption = _T("About");
mbpMsgBoxParams.dwStyle = MB_USERICON;
mbpMsgBoxParams.lpszIcon = MAKEINTRESOURCE(IDI_MAIN);
return MessageBoxIndirect(&mbpMsgBoxParams);
}