forked from win32ss/VxKex
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathKexComm.h
170 lines (133 loc) · 3.7 KB
/
KexComm.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
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
167
168
169
170
#pragma once
#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
//
// VxKex Common Components
//
#include <VxKex.h>
#include <Windows.h>
#include <tchar.h>
#include <strsafe.h>
#include <malloc.h>
#include <stdarg.h>
#undef MAX_PATH
#define MAX_PATH ((SIZE_T) 260)
#define ASSUME __assume
#define NORETURN __declspec(noreturn)
#define STATIC static
#define INLINE _inline
#define VOLATILE volatile
#define DECLSPEC_EXPORT __declspec(dllexport)
#define CHECKED(x) if (!(x)) goto Error
#define CONCAT(a,b) a##b
#define L(str) CONCAT(L,str)
#define snwprintf_s _snwprintf_s
#define vscwprintf _vscwprintf
#define wcsicmp _wcsicmp
#define wcsnicmp _wcsnicmp
#define StackAlloc _alloca
#define until(condition) while (!(condition))
#define unless(condition) if (!(condition))
#define otherwise else
#define and &&
#define or ||
#define not !
#define is ==
#define is_not !=
typedef LPVOID *PPVOID;
typedef unsigned __int64 QWORD, *PQWORD, *LPQWORD, **PPQWORD;
typedef LONG KPRIORITY;
typedef LONG NTSTATUS;
EXTERN_C VOID SetFriendlyAppName(
IN LPCWSTR lpszFriendlyName);
EXTERN_C LPCWSTR Win32ErrorAsString(
IN DWORD dw);
EXTERN_C LPCWSTR NtStatusAsString(
IN NTSTATUS st);
EXTERN_C LPCWSTR GetLastErrorAsString(
VOID);
EXTERN_C VOID MessageBoxV(
IN UINT uType OPTIONAL,
IN LPCWSTR lpszFmt,
IN va_list ap);
EXTERN_C VOID ErrorBoxF(
IN LPCWSTR lpszFmt, ...);
EXTERN_C NORETURN VOID CriticalErrorBoxF(
IN LPCWSTR lpszFmt, ...);
EXTERN_C VOID WarningBoxF(
IN LPCWSTR lpszFmt, ...);
EXTERN_C VOID InfoBoxF(
IN LPCWSTR lpszFmt, ...);
EXTERN_C BOOL RegReadSz(
IN HKEY hKey,
IN LPCWSTR lpszSubKey,
IN LPCWSTR lpszValueName OPTIONAL,
OUT LPWSTR lpszData,
IN DWORD dwcchData);
EXTERN_C BOOL RegWriteSz(
IN HKEY hKey,
IN LPCWSTR lpszSubKey,
IN LPCWSTR lpszValueName OPTIONAL,
IN LPCWSTR lpszData OPTIONAL);
EXTERN_C BOOL RegReadDw(
IN HKEY hKey,
IN LPCWSTR lpszSubKey,
IN LPCWSTR lpszValueName OPTIONAL,
OUT LPDWORD lpdwData);
EXTERN_C BOOL RegWriteDw(
IN HKEY hKey,
IN LPCWSTR lpszSubKey,
IN LPCWSTR lpszValueName OPTIONAL,
IN DWORD dwData);
EXTERN_C BOOL RegDelValue(
IN HKEY hKey,
IN LPCWSTR lpszSubKey,
IN LPCWSTR lpszValueName);
VOID PrintF(
IN LPCWSTR lpszFmt, ...);
HANDLE CreateTempFile(
IN LPCWSTR lpszPrefix,
IN DWORD dwDesiredAccess,
IN DWORD dwShareMode,
IN LPSECURITY_ATTRIBUTES lpSecurityAttributes);
BOOL WriteFileWF(
IN HANDLE hFile,
IN LPCWSTR lpszFmt, ...);
LPWSTR ConvertDeviceHarddiskToDosPath(
IN LPWSTR lpszPath);
LPWSTR GetFilePathFromHandle(
IN HANDLE hFile);
LPVOID __AutoHeapAllocHelper(
IN SIZE_T cb);
LPVOID __AutoStackAllocHelper(
IN LPVOID lpv);
VOID __AutoFreeHelper(
IN LPVOID lpv);
LPWSTR GetCommandLineWithoutImageName(
VOID);
FORCEINLINE LPVOID DefHeapAlloc(
IN SIZE_T cb)
{
return HeapAlloc(GetProcessHeap(), 0, cb);
}
FORCEINLINE VOID DefHeapFree(
IN LPVOID lpBase)
{
HeapFree(GetProcessHeap(), 0, lpBase);
}
FORCEINLINE LPVOID DefHeapReAlloc(
IN LPVOID lpBase,
IN SIZE_T cbNew)
{
return HeapReAlloc(GetProcessHeap(), 0, lpBase, cbNew);
}
// application can override this
#ifndef __MAX_STACK_ALLOC_SIZE
# define __MAX_STACK_ALLOC_SIZE 1024
#endif
#define AutoAlloc(cb) (((cb) < __MAX_STACK_ALLOC_SIZE) ? __AutoStackAllocHelper(StackAlloc((cb) + 1)) : __AutoHeapAllocHelper((cb) + 1))
#define AutoFree(lpv) do { __AutoFreeHelper(lpv); lpv = NULL; } while(0)
#ifdef UNICODE
# define WriteFileF WriteFileWF
#else
# define WriteFileF WriteFileAF
#endif