api: split adapter creation/deletion to delegator and worker functions
Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
3dacd1c6ce
commit
5a3a217b0b
@ -1492,20 +1492,15 @@ cleanupMutex:
|
||||
return Result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
WINTUN_STATUS WINAPI
|
||||
WintunCreateAdapter(
|
||||
static WINTUN_STATUS
|
||||
CreateAdapterNatively(
|
||||
_In_z_count_c_(MAX_POOL) const WCHAR *Pool,
|
||||
_In_z_count_c_(MAX_ADAPTER_NAME) const WCHAR *Name,
|
||||
_In_opt_ const GUID *RequestedGUID,
|
||||
_Out_ WINTUN_ADAPTER **Adapter,
|
||||
_Inout_ BOOL *RebootRequired)
|
||||
{
|
||||
#if defined(_M_IX86) || defined(_M_ARM)
|
||||
if (NativeMachine != IMAGE_FILE_PROCESS)
|
||||
{
|
||||
LOG(WINTUN_LOG_INFO, L"Spawning native process for the job");
|
||||
LOG(WINTUN_LOG_INFO, L"Spawning native process");
|
||||
WCHAR RequestedGUIDStr[MAX_GUID_STRING_LEN];
|
||||
WCHAR Arguments[15 + MAX_POOL + 3 + MAX_ADAPTER_NAME + 2 + MAX_GUID_STRING_LEN + 1];
|
||||
if (_snwprintf_s(
|
||||
@ -1544,10 +1539,24 @@ WintunCreateAdapter(
|
||||
}
|
||||
if (wcstoul(Argv[2], NULL, 16))
|
||||
*RebootRequired = TRUE;
|
||||
cleanupArgv:
|
||||
cleanupArgv:
|
||||
LocalFree(Argv);
|
||||
return Result;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
WINTUN_STATUS WINAPI
|
||||
WintunCreateAdapter(
|
||||
_In_z_count_c_(MAX_POOL) const WCHAR *Pool,
|
||||
_In_z_count_c_(MAX_ADAPTER_NAME) const WCHAR *Name,
|
||||
_In_opt_ const GUID *RequestedGUID,
|
||||
_Out_ WINTUN_ADAPTER **Adapter,
|
||||
_Inout_ BOOL *RebootRequired)
|
||||
{
|
||||
#if defined(_M_IX86) || defined(_M_ARM)
|
||||
if (NativeMachine != IMAGE_FILE_PROCESS)
|
||||
return CreateAdapterNatively(Pool, Name, RequestedGUID, Adapter, RebootRequired);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_EV) || defined(HAVE_WHQL)
|
||||
@ -1601,13 +1610,12 @@ cleanupDirectory:
|
||||
#endif
|
||||
}
|
||||
|
||||
WINTUN_STATUS WINAPI
|
||||
WintunDeleteAdapter(_In_ const WINTUN_ADAPTER *Adapter, _Inout_ BOOL *RebootRequired)
|
||||
{
|
||||
#if defined(_M_IX86) || defined(_M_ARM)
|
||||
if (NativeMachine != IMAGE_FILE_PROCESS)
|
||||
{
|
||||
LOG(WINTUN_LOG_INFO, L"Spawning native process for the job");
|
||||
|
||||
static WINTUN_STATUS
|
||||
DeleteAdapterNatively(_In_ const WINTUN_ADAPTER *Adapter, _Inout_ BOOL *RebootRequired)
|
||||
{
|
||||
LOG(WINTUN_LOG_INFO, L"Spawning native process");
|
||||
WCHAR GuidStr[MAX_GUID_STRING_LEN];
|
||||
WCHAR Arguments[14 + MAX_GUID_STRING_LEN + 1];
|
||||
if (_snwprintf_s(
|
||||
@ -1633,10 +1641,19 @@ WintunDeleteAdapter(_In_ const WINTUN_ADAPTER *Adapter, _Inout_ BOOL *RebootRequ
|
||||
Result = wcstoul(Argv[0], NULL, 16);
|
||||
if (wcstoul(Argv[1], NULL, 16))
|
||||
*RebootRequired = TRUE;
|
||||
cleanupArgv:
|
||||
cleanupArgv:
|
||||
LocalFree(Argv);
|
||||
return Result;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
WINTUN_STATUS WINAPI
|
||||
WintunDeleteAdapter(_In_ const WINTUN_ADAPTER *Adapter, _Inout_ BOOL *RebootRequired)
|
||||
{
|
||||
#if defined(_M_IX86) || defined(_M_ARM)
|
||||
if (NativeMachine != IMAGE_FILE_PROCESS)
|
||||
return DeleteAdapterNatively(Adapter, RebootRequired);
|
||||
#endif
|
||||
|
||||
HDEVINFO DevInfo;
|
||||
|
Loading…
Reference in New Issue
Block a user