Skip to content

Commit 826b105

Browse files
vxiiduui486
vxiiduu
authored andcommitted
Create FUNDING.yml
1 parent fb1a531 commit 826b105

File tree

347 files changed

+84637
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

347 files changed

+84637
-0
lines changed

.github/FUNDING.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# These are supported funding model platforms
2+
3+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
12+
polar: # Replace with a single Polar username
13+
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
14+
custom: https://paypal.me/vxiiduu

00-Common Headers/KexAssert.h

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
//
3+
// Module Name:
4+
//
5+
// KexAssert.h
6+
//
7+
// Abstract:
8+
//
9+
// ASSERT and ASSUME macros.
10+
//
11+
// Author:
12+
//
13+
// vxiiduu (26-Sep-2022)
14+
//
15+
// Environment:
16+
//
17+
// ASSERT displays an error box when compiling for an EXE target.
18+
// Otherwise, it will simply cause a breakpoint in the current process.
19+
//
20+
// ASSUME can be used anywhere.
21+
//
22+
// Revision History:
23+
//
24+
// vxiiduu 26-Sep-2022 Initial creation.
25+
// vxiiduu 22-Feb-2022 Remove obsolete CHECKED macro.
26+
//
27+
///////////////////////////////////////////////////////////////////////////////
28+
29+
#pragma once
30+
31+
//
32+
// Uncomment the macro definition to keep asserts enabled in release builds.
33+
//
34+
//#define RELEASE_ASSERTS_ENABLED
35+
36+
//
37+
// == Guidelines for ASSERT Macro Usage in the VxKex Codebase ==
38+
//
39+
// 1. Use a space between ASSERT and (.
40+
// Bad: ASSERT(Pointer != NULL);
41+
// Good: ASSERT (Pointer != NULL);
42+
//
43+
// 2. Do not omit the conditional operator.
44+
// Bad: ASSERT (Pointer);
45+
// Good: ASSERT (Pointer != NULL);
46+
//
47+
// 3. Use only one condition in an ASSERT macro.
48+
// Bad: ASSERT (Pointer != NULL && Size != 0);
49+
//
50+
// Good: ASSERT (Pointer != NULL);
51+
// ASSERT (Size != 0);
52+
//
53+
// 4. When asserting that a particular code-path will not be executed, use
54+
// the comma operator to give the user/developer an explanation for what
55+
// happened. Remember, no other context is given besides the condition
56+
// inside the ASSERT macro.
57+
// Bad: ASSERT (FALSE);
58+
// Good: ASSERT (("The event ID is not valid", FALSE));
59+
//
60+
#if defined(_DEBUG) || defined(RELEASE_ASSERTS_ENABLED)
61+
# define ASSERTS_ENABLED
62+
# if defined(KEX_TARGET_TYPE_EXE) && !defined(KEX_DISABLE_GRAPHICAL_ASSERTS)
63+
# define ASSERT(Condition) if (!(Condition)) { \
64+
BOOLEAN ShouldRaiseException = ReportAssertionFailure( \
65+
__FILEW__, __LINE__, __FUNCTIONW__, L#Condition); \
66+
if (ShouldRaiseException) __int2c(); \
67+
}
68+
# define SOFT_ASSERT ASSERT
69+
# else
70+
# define ASSERT(Condition) do { if (!(Condition)) { DbgPrint("Assertion failure: %s (%s:%d in %s)\r\n", #Condition, __FILE__, __LINE__, __FUNCTION__); __int2c(); } } while(0)
71+
# define SOFT_ASSERT (Condition) do { if (!(Condition)) { DbgPrint("Soft assertion failure: %s (%S:%d in %s)\r\n", #Condition, __FILE__, __LINE__, __FUNCTION); } while (0)
72+
# endif
73+
#else
74+
# define ASSERT(Condition)
75+
#endif
76+
77+
#ifndef _DEBUG
78+
# define ASSUME __assume
79+
# define NOT_REACHED ASSUME(FALSE)
80+
#else
81+
# define ASSUME ASSERT
82+
# define NOT_REACHED ASSUME(("Execution should not have reached this point", FALSE))
83+
#endif
84+
85+
86+
#define NOTHING

00-Common Headers/KexComm.h

+276
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
//
3+
// Module Name:
4+
//
5+
// KexComm.h
6+
//
7+
// Abstract:
8+
//
9+
// VxKex common header file. Every project which is a part of VxKex must
10+
// include this file unless there is a very good reason not to.
11+
//
12+
// Author:
13+
//
14+
// vxiiduu (30-Sep-2022)
15+
//
16+
// Environment:
17+
//
18+
// Refer to included header files for information about their contents.
19+
//
20+
// Revision History:
21+
//
22+
// vxiiduu 30-Sep-2022 Initial creation.
23+
//
24+
///////////////////////////////////////////////////////////////////////////////
25+
26+
#pragma once
27+
28+
#if !defined(KEX_ARCH_X64) && !defined(KEX_ARCH_X86)
29+
# if defined(_M_X64)
30+
# define KEX_ARCH_X64
31+
# elif defined(_M_IX86)
32+
# define KEX_ARCH_X86
33+
# else
34+
# error Invalid CPU architecture for VxKex. Only x86 and x64 are supported.
35+
# endif
36+
#endif
37+
38+
#ifndef KEX_ENV_NATIVE
39+
# define KEX_ENV_WIN32
40+
#endif
41+
42+
#if defined(KEX_ENV_NATIVE) && defined(KEX_ENV_WIN32)
43+
# error Only one of the KEX_ENV_ macros may be defined.
44+
#endif
45+
46+
// Define Unicode macros.
47+
// __FILEW__ and __FUNCTIONW__ are already defined somewhere inside the windows
48+
// headers.
49+
#define CONCAT(a,b) a##b
50+
#define _L(str) CONCAT(L,str)
51+
#define __DATEW__ _L(__DATE__)
52+
#define __TIMEW__ _L(__TIME__)
53+
#define __TIMESTAMPW__ _L(__TIMESTAMP__)
54+
#define __FUNCDNAMEW__ _L(__FUNCDNAME__)
55+
#define __FUNCSIGW__ _L(__FUNCSIG__)
56+
57+
//
58+
// Define convenience macros so we don't need #ifdef in the middle of code.
59+
//
60+
#ifdef _DEBUG
61+
# define KexIsDebugBuild TRUE
62+
# define KexIsReleaseBuild FALSE
63+
#else
64+
# define KexIsDebugBuild FALSE
65+
# define KexIsReleaseBuild TRUE
66+
#endif
67+
68+
#ifdef KEX_ARCH_X64
69+
# define KexIs32BitBuild FALSE
70+
# define KexIs64BitBuild TRUE
71+
#else
72+
# define KexIs32BitBuild TRUE
73+
# define KexIs64BitBuild FALSE
74+
#endif
75+
76+
#pragma region Header Includes
77+
// these two must be included before other headers (esp. KexStrSafe.h), or
78+
// undefined symbol errors can occur
79+
# include <KexComp.h>
80+
# include <KexLnk.h>
81+
82+
# ifdef KEX_ENV_NATIVE
83+
//
84+
// We can't use any of this stuff in a native environment,
85+
// so we disable it to avoid mistakes/accidentally calling
86+
// unusable APIs.
87+
//
88+
# define NOGDICAPMASKS
89+
# define NOVIRTUALKEYCODES
90+
# define NOWINMESSAGES
91+
# define NOWINSTYLES
92+
# define NOSYSMETRICS
93+
# define NOMENUS
94+
# define NOICONS
95+
# define NOKEYSTATES
96+
# define NOSYSCOMMANDS
97+
# define NORASTEROPS
98+
# define NOSHOWWINDOW
99+
# define NOATOM
100+
# define NOCLIPBOARD
101+
# define NOCOLOR
102+
# define NOCTLMGR
103+
# define NODRAWTEXT
104+
# define NOGDI
105+
# define NOKERNEL
106+
# define NOUSER
107+
# define NONLS
108+
# define NOMB
109+
# define NOMEMMGR
110+
# define NOMSG
111+
# define NOOPENFILE
112+
# define NOSCROLL
113+
# define NOTEXTMETRIC
114+
# define NOWH
115+
# define NOWINOFFSETS
116+
# define NOCOMM
117+
# define NOKANJI
118+
# define NOHELP
119+
# define NOPROFILER
120+
# define NODEFERWINDOWPOS
121+
# define NOMCX
122+
# define NOCRYPT
123+
# define NOMETAFILE
124+
# define NOSERVICE
125+
# define NOSOUND
126+
# endif
127+
128+
# define COBJMACROS
129+
# define CINTERFACE
130+
131+
# define STRICT
132+
# define WIN32_NO_STATUS
133+
134+
# ifdef __INTELLISENSE__
135+
# undef __cplusplus
136+
# endif
137+
138+
// attempt to make vxkex build with newer sdk's as well.
139+
// no guarantees. if you install the win10 sdk and it doesn't build, tough luck.
140+
// don't ask me to make shit build on your windows 11 with newest SDK.
141+
# define _WIN32_WINNT 0x0601
142+
143+
# include <Windows.h>
144+
# include <NtDll.h>
145+
# include <StdArg.h>
146+
147+
# ifdef KEX_TARGET_TYPE_SYS
148+
# include <NtKrnl.h>
149+
# endif
150+
151+
# ifdef __INTELLISENSE__
152+
# undef NULL
153+
# define NULL 0
154+
# endif
155+
156+
# if defined(KEX_ENV_WIN32) && !defined(NOUSER)
157+
// Generally speaking we import from SHLWAPI only for the Path*
158+
// functions. In the future we will dogfood our own PathCch* functions
159+
// and avoid importing from SHLWAPI altogether.
160+
161+
// SHLWAPI string functions are EXTREMELY slow. Do not use them, ever.
162+
# define NO_SHLWAPI_STRFCNS
163+
164+
// Ok, we'll make an exception for StrFormatByteSizeW -_-
165+
# define StrFormatByteSize StrFormatByteSizeW
166+
PWSTR StrFormatByteSizeW(LONGLONG qdw, PWSTR pszBuf, UINT cchBuf);
167+
168+
# define NO_SHLWAPI_ISOS
169+
# define NO_SHLWAPI_STREAM
170+
# define NO_SHLWAPI_HTTP
171+
# define NO_SHLWAPI_GDI
172+
# define NO_SHLWAPI_STOPWATCH
173+
# pragma comment(lib, "shlwapi.lib")
174+
# include <Shlwapi.h>
175+
# endif
176+
177+
// Some bullshit warning about a "deprecated" function in intrin.h
178+
// get rid of the stupid warning
179+
# pragma warning(push)
180+
# pragma warning(disable:4995)
181+
# include <Intrin.h>
182+
# pragma warning(pop)
183+
184+
# include <KexTypes.h>
185+
# include <KexVer.h>
186+
187+
# if defined(KEX_ENV_WIN32) && !defined(KEX_TARGET_TYPE_LIB)
188+
# include <KexGui.h>
189+
# include <KexW32ML.h>
190+
# include <KxCfgHlp.h>
191+
# endif
192+
193+
# include <KexAssert.h>
194+
195+
# ifdef KEX_TARGET_TYPE_SYS
196+
# include <NtStrSafe.h>
197+
# else
198+
# include <KexStrSafe.h>
199+
# include <KexPathCch.h>
200+
# include <SafeAlloc.h>
201+
# endif
202+
#pragma endregion
203+
204+
#pragma region Extended Language Constructs
205+
# define try __try
206+
# define except __except
207+
# define finally __finally
208+
# define leave __leave
209+
# define throw(Status) RtlRaiseStatus(Status)
210+
# define asm __asm
211+
212+
# ifndef until
213+
# define until(Condition) while (!(Condition))
214+
# endif
215+
216+
# define unless(Condition) if (!(Condition))
217+
# define ReturnAddress _ReturnAddress
218+
219+
# define PopulationCount16 __popcnt16
220+
# define PopulationCount __popcnt
221+
# define PopulationCount64 __popcnt64
222+
#pragma endregion
223+
224+
#pragma region Convenience Macros
225+
//
226+
// Convert a HRESULT code to a Win32 error code.
227+
// Note that not all HRESULT codes can be mapped to a valid Win32 error code.
228+
//
229+
# define WIN32_FROM_HRESULT(x) (HRESULT_CODE(x))
230+
231+
# define LODWORD(ull) ((ULONG) (ull))
232+
# define HIDWORD(ull) ((ULONG) ((ULONGLONG) (ull) >> 32))
233+
234+
//
235+
// Convert a relative virtual address (e.g. as found in PE image files) to a
236+
// real virtual address which can be read, written, dereferenced etc.
237+
// VA_TO_RVA does the opposite.
238+
//
239+
# define RVA_TO_VA(base, rva) ((PVOID) (((PBYTE) (base)) + (rva)))
240+
# define VA_TO_RVA(base, va) ((ULONG_PTR) (((PBYTE) (va)) - ((PBYTE) (base))))
241+
242+
//
243+
// Convert a boolean to a string which can be displayed to the user.
244+
//
245+
# define BOOLEAN_AS_STRING(b) ((b) ? L"TRUE" : L"FALSE")
246+
247+
//
248+
// Lookup an entry in a static entry table with bounds clamping.
249+
//
250+
# define ARRAY_LOOKUP_BOUNDS_CHECKED(Array, Index) Array[max(0, min((Index), ARRAYSIZE(Array) - 1))]
251+
252+
//
253+
// Convert a byte count to a character count (assuming a character is
254+
// 2 bytes long, as it always is when dealing with windows unicode strings)
255+
// and vice versa.
256+
//
257+
# define CB_TO_CCH(Cb) ((Cb) >> 1)
258+
# define CCH_TO_CB(Cch) ((Cch) << 1)
259+
260+
//
261+
// Check that a kernel handle is not NULL or INVALID_HANDLE_VALUE.
262+
// Keep in mind that NtCurrentProcess() will not be valid if checked with
263+
// this macro, so you will have to special-case it in any code that uses
264+
// process handles.
265+
//
266+
# define VALID_HANDLE(Handle) \
267+
(((Handle) != NULL) && \
268+
((Handle) != INVALID_HANDLE_VALUE) && \
269+
!(((ULONG_PTR) (Handle)) & 3) && \
270+
(((ULONG_PTR) (Handle)) <= ULONG_MAX))
271+
272+
# define KexDebugCheckpoint() if (KexIsDebugBuild && NtCurrentPeb()->BeingDebugged) __debugbreak()
273+
274+
# define InterlockedIncrement16 _InterlockedIncrement16
275+
# define InterlockedDecrement16 _InterlockedDecrement16
276+
#pragma endregion

0 commit comments

Comments
 (0)