Skip to content

Commit

Permalink
Feature: Add _VEIL_LINKER_FORCE_INCLUDE macro.
Browse files Browse the repository at this point in the history
  • Loading branch information
MiroKaku committed Aug 12, 2024
1 parent d7e2f57 commit d96081e
Showing 1 changed file with 63 additions and 18 deletions.
81 changes: 63 additions & 18 deletions Veil.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,29 @@
#define _VEIL_CONCATENATE(a, b) _VEIL_CONCATENATE_(a, b)


//
// Force Include
//

#if defined _M_IX86
#define _VEIL_LINKER_SYMBOL_PREFIX "_"
#elif defined _M_X64 || defined _M_ARM || defined _M_ARM64
#define _VEIL_LINKER_SYMBOL_PREFIX ""
#else
#error Unsupported architecture
#endif

#define _VEIL_LINKER_FORCE_INCLUDE(name) \
__pragma(comment(linker, \
"/include:" \
_VEIL_LINKER_SYMBOL_PREFIX #name \
))


//
// Alternate Name
//

#if defined _M_IX86
#if defined _M_HYBRID
#define _VEIL_DECLARE_ALTERNATE_NAME_PREFIX "#"
Expand Down Expand Up @@ -72,6 +95,11 @@
_VEIL_DECLARE_ALTERNATE_NAME_PREFIX_DATA #alternate_name \
))


//
// Static IAT Hook
//

// The _VEIL_DEFINE_IAT_SYMBOL macro provides an architecture-neutral way of
// defining IAT symbols (__imp_- or _imp__-prefixed symbols).
#ifdef _M_IX86
Expand Down Expand Up @@ -99,6 +127,10 @@
#endif


//
// Declare Helper
//

#define VEIL_DECLARE_STRUCT(name) \
typedef struct _VEIL_CONCATENATE(_, name) name; \
typedef struct _VEIL_CONCATENATE(_, name) * _VEIL_CONCATENATE(P, name); \
Expand All @@ -118,23 +150,9 @@
union _VEIL_CONCATENATE(_, name)


#ifndef __cplusplus
#ifndef CINTERFACE
#define CINTERFACE
#endif

#ifndef COBJMACROS
#define COBJMACROS
#endif
#endif

#ifndef __cplusplus
// This is needed to workaround C17 preprocessor errors when using legacy versions of the Windows SDK. (dmex)
#ifndef MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS
#define MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS 0
#endif
#endif

//
// Versions
//

#define NTDDI_WIN6 0x06000000 // Windows Vista
#define NTDDI_WIN6SP1 0x06000100 // Windows Vista SP1
Expand Down Expand Up @@ -185,9 +203,14 @@
#define NTDDI_WIN11_GA 0x0A00000F // Windows 10.0.25905-25941 / Gallium
#define NTDDI_WIN11_GE 0x0A000010 // Windows 10.0.25947-26100 / Germanium / 24H2

// Fix WDK
// Fix WDK
#define NTDDI_THRESHOLD NTDDI_WINTHRESHOLD


//
// C bool
//

#ifndef __cplusplus
#ifndef __bool_true_false_are_defined
#define __bool_true_false_are_defined 1
Expand All @@ -198,6 +221,28 @@
#define nullptr NULL
#endif


//
// Headers
//

#ifndef __cplusplus
#ifndef CINTERFACE
#define CINTERFACE
#endif

#ifndef COBJMACROS
#define COBJMACROS
#endif
#endif

#ifndef __cplusplus
// This is needed to workaround C17 preprocessor errors when using legacy versions of the Windows SDK. (dmex)
#ifndef MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS
#define MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS 0
#endif
#endif

#ifndef ENABLE_RTL_NUMBER_OF_V2
#define ENABLE_RTL_NUMBER_OF_V2
#endif
Expand Down

0 comments on commit d96081e

Please sign in to comment.