api: make #ifdef-s more descriptive

Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2020-10-30 09:33:21 +01:00
parent 4b0470210d
commit eeb42a5f12
3 changed files with 13 additions and 6 deletions

View File

@ -329,7 +329,7 @@ AdapterDeleteAllOurs(void)
void
AdapterInit(void)
{
#if defined(_M_IX86) || defined(_M_ARM)
#ifdef MAYBE_WOW64
typedef BOOL(WINAPI * IsWow64Process2_t)(
_In_ HANDLE hProcess, _Out_ USHORT * pProcessMachine, _Out_opt_ USHORT * pNativeMachine);
HANDLE Kernel32;
@ -1255,7 +1255,7 @@ CreateTemporaryDirectory(_Out_cap_c_(MAX_PATH) WCHAR *RandomTempSubDirectory)
return ERROR_SUCCESS;
}
#if defined(_M_IX86) || defined(_M_ARM)
#ifdef MAYBE_WOW64
typedef struct _PROCESS_STDOUT_STATE
{
@ -1546,7 +1546,7 @@ WintunCreateAdapter(
_Out_ WINTUN_ADAPTER **Adapter,
_Inout_ BOOL *RebootRequired)
{
#if defined(_M_IX86) || defined(_M_ARM)
#ifdef MAYBE_WOW64
if (NativeMachine != IMAGE_FILE_PROCESS)
return CreateAdapterNatively(Pool, Name, RequestedGUID, Adapter, RebootRequired);
#endif
@ -1598,7 +1598,7 @@ cleanupDirectory:
return Result;
}
#if defined(_M_IX86) || defined(_M_ARM)
#ifdef MAYBE_WOW64
static WINTUN_STATUS
DeleteAdapterNatively(_In_ const WINTUN_ADAPTER *Adapter, _Inout_ BOOL *RebootRequired)
@ -1639,7 +1639,7 @@ cleanupArgv:
WINTUN_STATUS WINAPI
WintunDeleteAdapter(_In_ const WINTUN_ADAPTER *Adapter, _Inout_ BOOL *RebootRequired)
{
#if defined(_M_IX86) || defined(_M_ARM)
#ifdef MAYBE_WOW64
if (NativeMachine != IMAGE_FILE_PROCESS)
return DeleteAdapterNatively(Adapter, RebootRequired);
#endif

View File

@ -14,6 +14,13 @@
# define _L(x) __L(x)
#endif
#if defined(_M_IX86) || defined(_M_ARM)
#define MAYBE_WOW64
#endif
#if defined(_M_AMD64) || defined(_M_ARM64) || defined(_DEBUG)
#define ACCEPT_WOW64
#endif
extern HINSTANCE ResourceModule;
extern HANDLE ModuleHeap;
extern SECURITY_ATTRIBUTES *SecurityAttributes;

View File

@ -7,7 +7,7 @@
#define EXPORT comment(linker, "/EXPORT:" __FUNCTION__ "=" __FUNCDNAME__)
#if defined(_M_AMD64) || defined(_M_ARM64) || defined(_DEBUG)
#ifdef ACCEPT_WOW64
static DWORD
WriteFormatted(_In_ DWORD StdHandle, _In_z_ const WCHAR *Template, ...)