-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathmain.cpp
166 lines (147 loc) · 5.54 KB
/
main.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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#include "main.h"
char settings_ini[256] = "";
bool start_ontop = false;
int bkColor = GetSysColor(15);
HBRUSH hbr = CreateSolidBrush(bkColor);
typedef BOOL(WINAPI *ChangeWindowMessageFilter_p)(
_In_ UINT message,
_In_ DWORD dwFlag
);
static BOOL MyChangeWindowMessageFilter(UINT message, DWORD dwFlag)
{
static ChangeWindowMessageFilter_p func = (ChangeWindowMessageFilter_p)GetProcAddress(GetModuleHandleW(L"user32.dll"), "ChangeWindowMessageFilter");
return func ? func(message, dwFlag) : FALSE;
}
BOOL CALLBACK DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
{
char rnd_title[256] = "";
WORD rnd_word[2] = {0};
rnd_word[0] = (GetTickCount() & 0xFFFF);
sprintf(rnd_title, "[%.04X] %s", rnd_word[0]^rnd_word[1], caption);
SetWindowTextA(hwndDlg, rnd_title);
SendMessageA(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIconA(hInst, MAKEINTRESOURCE(IDI_ICON1)));
SendMessageA(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIconA(hInst, MAKEINTRESOURCE(IDI_ICON2)));
InitTabStruct(hwndDlg, IDC_TAB1, true, true);
SetEngineVariable(UE_ENGINE_NO_CONSOLE_WINDOW, true);
AddTabbedDialog(hInst, hwndDlg, "KeyGen", DLG_KEYCREATE, KG_DlgKeyGenerate, 0, 1);
AddTabbedDialog(hInst, hwndDlg, "Analysis", DLG_ANALYSIS, DlgAnalysis, 0, 1);
AddTabbedDialog(hInst, hwndDlg, "EncDec", DLG_ENCDEC, DlgEncDec, 0, 1);
AddTabbedDialog(hInst, hwndDlg, "Version", DLG_VERSION, VF_DlgMain, 1, 1);
AddTabbedDialog(hInst, hwndDlg, "Certs", DLG_CERTTOOL, CT_DlgMain, 1, 1);
AddTabbedDialog(hInst, hwndDlg, "Inline", DLG_INLINEHELPER, IH_DlgMain, 1, 1);
AddTabbedDialog(hInst, hwndDlg, "EVLog", DLG_EVLOG, EV_DlgMain, 1, 1);
//AddTabbedDialog(hInst, hwndDlg, "Nano", DLG_NANO, MSC_DlgMain, 0, 0);
AddTabbedDialog(hInst, hwndDlg, "Misc", DLG_MISC, MSC_DlgMain, 1, 1);
//SelectTab(hwndDlg, 4);
if(start_ontop)
{
SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
CheckDlgButton(hwndDlg, IDC_CHK_ONTOP, 1);
}
int c_MSGFLT_ALLOW = 1;
MyChangeWindowMessageFilter(WM_DROPFILES, c_MSGFLT_ALLOW);
MyChangeWindowMessageFilter(WM_COPYDATA, c_MSGFLT_ALLOW);
MyChangeWindowMessageFilter(0x0049, c_MSGFLT_ALLOW);
}
return TRUE;
case WM_CLOSE:
{
EndDialog(hwndDlg, 0);
}
return TRUE;
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case IDC_CHK_ONTOP:
{
NoFocus();
start_ontop = !!IsDlgButtonChecked(hwndDlg, LOWORD(wParam));
if(start_ontop)
SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
else
SetWindowPos(hwndDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
}
return TRUE;
case IDC_BTN_EXIT:
{
NoFocus();
SendMessageA(hwndDlg, WM_CLOSE, 0, 0);
}
return TRUE;
case IDC_BTN_ABOUT:
{
NoFocus();
DialogBoxA(hInst, MAKEINTRESOURCE(DLG_ABOUT), hwndDlg, DlgAbout);
}
return TRUE;
case IDC_BTN_HELP:
{
NoFocus();
SendMessageA(hwndDlg, WM_HELP, 0, 0);
}
return TRUE;
}
}
return TRUE;
}
return FALSE;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
hInst = hInstance;
InitCommonControls();
LoadLibrary("riched20.dll");
GetModuleFileNameA(hInst, sg_szAKTDirectory, 256);
int i = strlen(sg_szAKTDirectory);
while(sg_szAKTDirectory[i] != '\\')
i--;
sg_szAKTDirectory[i] = 0;
strcpy(program_dir, sg_szAKTDirectory);
strcpy(sg_szPluginIniFilePath, sg_szAKTDirectory);
strcat(sg_szPluginIniFilePath, "\\plugins\\plugins.ini");
strcpy(sg_loaded_binary, sg_szAKTDirectory);
strcat(sg_loaded_binary, "\\loaded_binary.mem");
DeleteFile(sg_loaded_binary);
strcpy(sg_security_code, sg_szAKTDirectory);
strcat(sg_security_code, "\\security_code.mem");
DeleteFile(sg_security_code);
DeleteFileA(sg_szPluginIniFilePath);
IH_GetPluginList();
SetCurrentDirectoryA(sg_szAKTDirectory);
char setting[10] = "";
sprintf(settings_ini, "%s\\Armadillo_KeyTool.ini", sg_szAKTDirectory);
GetPrivateProfileStringA("Settings", "ontop", "", setting, 10, settings_ini);
if(setting[0] == '1')
start_ontop = true;
GetPrivateProfileStringA("Settings", "nologversion", "", setting, 10, settings_ini);
if(setting[0] == '1')
log_version = false;
GetPrivateProfileStringA("Settings", "nologcerttool", "", setting, 10, settings_ini);
if(setting[0] == '1')
CT_logtofile = false;
int retn = DialogBox(hInst, MAKEINTRESOURCE(DLG_MAIN), 0, DlgMain);
if(start_ontop)
setting[0] = '1';
else
setting[0] = '0';
WritePrivateProfileStringA("Settings", "ontop", setting, settings_ini);
if(!CT_logtofile)
setting[0] = '1';
else
setting[0] = '0';
WritePrivateProfileStringA("Settings", "nologcerttool", setting, settings_ini);
if(!log_version)
setting[0] = '1';
else
setting[0] = '0';
WritePrivateProfileStringA("Settings", "nologversion", setting, settings_ini);
DeleteFile(sg_szPluginIniFilePath);
DeleteFile(sg_loaded_binary);
DeleteFile(sg_security_code);
return retn;
}