api: RebootRequire is an _Out_
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
6c40f24498
commit
ffab1eabe3
@ -1689,11 +1689,11 @@ WintunCreateAdapter(
|
|||||||
_In_z_count_c_(MAX_ADAPTER_NAME) const WCHAR *Name,
|
_In_z_count_c_(MAX_ADAPTER_NAME) const WCHAR *Name,
|
||||||
_In_opt_ const GUID *RequestedGUID,
|
_In_opt_ const GUID *RequestedGUID,
|
||||||
_Out_ WINTUN_ADAPTER **Adapter,
|
_Out_ WINTUN_ADAPTER **Adapter,
|
||||||
_Inout_ BOOL *RebootRequired)
|
_Out_ BOOL *RebootRequired)
|
||||||
{
|
{
|
||||||
if (!ElevateToSystem())
|
if (!ElevateToSystem())
|
||||||
return LOG(WINTUN_LOG_ERR, L"Failed to impersonate SYSTEM user"), ERROR_ACCESS_DENIED;
|
return LOG(WINTUN_LOG_ERR, L"Failed to impersonate SYSTEM user"), ERROR_ACCESS_DENIED;
|
||||||
|
*RebootRequired = FALSE;
|
||||||
DWORD Result = ERROR_SUCCESS;
|
DWORD Result = ERROR_SUCCESS;
|
||||||
#ifdef MAYBE_WOW64
|
#ifdef MAYBE_WOW64
|
||||||
if (NativeMachine != IMAGE_FILE_PROCESS)
|
if (NativeMachine != IMAGE_FILE_PROCESS)
|
||||||
@ -1848,11 +1848,12 @@ cleanupArgv:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
WINTUN_STATUS WINAPI
|
WINTUN_STATUS WINAPI
|
||||||
WintunDeleteAdapter(_In_ const WINTUN_ADAPTER *Adapter, _In_ BOOL ForceCloseSessions, _Inout_ BOOL *RebootRequired)
|
WintunDeleteAdapter(_In_ const WINTUN_ADAPTER *Adapter, _In_ BOOL ForceCloseSessions, _Out_ BOOL *RebootRequired)
|
||||||
{
|
{
|
||||||
if (!ElevateToSystem())
|
if (!ElevateToSystem())
|
||||||
return LOG(WINTUN_LOG_ERR, L"Failed to impersonate SYSTEM user"), ERROR_ACCESS_DENIED;
|
return LOG(WINTUN_LOG_ERR, L"Failed to impersonate SYSTEM user"), ERROR_ACCESS_DENIED;
|
||||||
|
|
||||||
|
*RebootRequired = FALSE;
|
||||||
DWORD Result;
|
DWORD Result;
|
||||||
#ifdef MAYBE_WOW64
|
#ifdef MAYBE_WOW64
|
||||||
if (NativeMachine != IMAGE_FILE_PROCESS)
|
if (NativeMachine != IMAGE_FILE_PROCESS)
|
||||||
|
@ -111,10 +111,10 @@ WintunCreateAdapter(
|
|||||||
_In_z_count_c_(MAX_ADAPTER_NAME) const WCHAR *Name,
|
_In_z_count_c_(MAX_ADAPTER_NAME) const WCHAR *Name,
|
||||||
_In_opt_ const GUID *RequestedGUID,
|
_In_opt_ const GUID *RequestedGUID,
|
||||||
_Out_ WINTUN_ADAPTER **Adapter,
|
_Out_ WINTUN_ADAPTER **Adapter,
|
||||||
_Inout_ BOOL *RebootRequired);
|
_Out_ BOOL *RebootRequired);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @copydoc WINTUN_DELETE_ADAPTER_FUNC
|
* @copydoc WINTUN_DELETE_ADAPTER_FUNC
|
||||||
*/
|
*/
|
||||||
WINTUN_STATUS WINAPI
|
WINTUN_STATUS WINAPI
|
||||||
WintunDeleteAdapter(_In_ const WINTUN_ADAPTER *Adapter, _In_ BOOL ForceCloseSessions, _Inout_ BOOL *RebootRequired);
|
WintunDeleteAdapter(_In_ const WINTUN_ADAPTER *Adapter, _In_ BOOL ForceCloseSessions, _Out_ BOOL *RebootRequired);
|
||||||
|
@ -105,7 +105,7 @@ VOID __stdcall CreateAdapter(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
WINTUN_ADAPTER *Adapter;
|
WINTUN_ADAPTER *Adapter;
|
||||||
BOOL RebootRequired = FALSE;
|
BOOL RebootRequired;
|
||||||
DWORD Result = WintunCreateAdapter(Argv[2], Argv[3], Argc > 4 ? &RequestedGUID : NULL, &Adapter, &RebootRequired);
|
DWORD Result = WintunCreateAdapter(Argv[2], Argv[3], Argc > 4 ? &RequestedGUID : NULL, &Adapter, &RebootRequired);
|
||||||
WCHAR GuidStr[MAX_GUID_STRING_LEN];
|
WCHAR GuidStr[MAX_GUID_STRING_LEN];
|
||||||
WriteFormatted(
|
WriteFormatted(
|
||||||
@ -137,7 +137,7 @@ VOID __stdcall DeleteAdapter(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int
|
|||||||
BOOL ForceCloseSessions = wcstoul(Argv[2], NULL, 10);
|
BOOL ForceCloseSessions = wcstoul(Argv[2], NULL, 10);
|
||||||
if (FAILED(CLSIDFromString(Argv[3], &Adapter.CfgInstanceID)))
|
if (FAILED(CLSIDFromString(Argv[3], &Adapter.CfgInstanceID)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
BOOL RebootRequired = FALSE;
|
BOOL RebootRequired;
|
||||||
WriteFormatted(
|
WriteFormatted(
|
||||||
STD_OUTPUT_HANDLE,
|
STD_OUTPUT_HANDLE,
|
||||||
L"%1!X! %2!X!",
|
L"%1!X! %2!X!",
|
||||||
@ -167,7 +167,7 @@ VOID __stdcall DoThingsForDebugging(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLin
|
|||||||
{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }
|
{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }
|
||||||
};
|
};
|
||||||
WINTUN_ADAPTER *Adapter;
|
WINTUN_ADAPTER *Adapter;
|
||||||
BOOL RebootRequired = FALSE;
|
BOOL RebootRequired;
|
||||||
assert(WintunCreateAdapter(L"Wintun", L"Test", &TestGuid, &Adapter, &RebootRequired) == ERROR_SUCCESS);
|
assert(WintunCreateAdapter(L"Wintun", L"Test", &TestGuid, &Adapter, &RebootRequired) == ERROR_SUCCESS);
|
||||||
assert(!RebootRequired);
|
assert(!RebootRequired);
|
||||||
TUN_SESSION *Session;
|
TUN_SESSION *Session;
|
||||||
|
10
api/wintun.h
10
api/wintun.h
@ -40,8 +40,7 @@ typedef void *WINTUN_ADAPTER_HANDLE;
|
|||||||
* @param Adapter Pointer to a handle to receive the adapter handle. Must be released with
|
* @param Adapter Pointer to a handle to receive the adapter handle. Must be released with
|
||||||
* WintunFreeAdapter.
|
* WintunFreeAdapter.
|
||||||
*
|
*
|
||||||
* @param RebootRequired Pointer to a boolean flag to be set to TRUE in case SetupAPI suggests a reboot. Must be
|
* @param RebootRequired Pointer to a boolean flag to be set to TRUE in case SetupAPI suggests a reboot.
|
||||||
* initialised to FALSE manually before this function is called.
|
|
||||||
*
|
*
|
||||||
* @return ERROR_SUCCESS on success; Win32 error code otherwise.
|
* @return ERROR_SUCCESS on success; Win32 error code otherwise.
|
||||||
*/
|
*/
|
||||||
@ -50,7 +49,7 @@ typedef WINTUN_STATUS(WINAPI *WINTUN_CREATE_ADAPTER_FUNC)(
|
|||||||
_In_z_count_c_(MAX_ADAPTER_NAME) const WCHAR *Name,
|
_In_z_count_c_(MAX_ADAPTER_NAME) const WCHAR *Name,
|
||||||
_In_opt_ const GUID *RequestedGUID,
|
_In_opt_ const GUID *RequestedGUID,
|
||||||
_Out_ WINTUN_ADAPTER_HANDLE *Adapter,
|
_Out_ WINTUN_ADAPTER_HANDLE *Adapter,
|
||||||
_Inout_ BOOL *RebootRequired);
|
_Out_ BOOL *RebootRequired);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a Wintun adapter.
|
* Deletes a Wintun adapter.
|
||||||
@ -61,15 +60,14 @@ typedef WINTUN_STATUS(WINAPI *WINTUN_CREATE_ADAPTER_FUNC)(
|
|||||||
* with extreme care, as this is resource intensive and may put processes into an undefined
|
* with extreme care, as this is resource intensive and may put processes into an undefined
|
||||||
* or unpredictable state. Most users should set this to FALSE.
|
* or unpredictable state. Most users should set this to FALSE.
|
||||||
*
|
*
|
||||||
* @param RebootRequired Pointer to a boolean flag to be set to TRUE in case SetupAPI suggests a reboot. Must be
|
* @param RebootRequired Pointer to a boolean flag to be set to TRUE in case SetupAPI suggests a reboot.
|
||||||
* initialised to FALSE manually before this function is called.
|
|
||||||
*
|
*
|
||||||
* @return ERROR_SUCCESS on success or the adapter was not found; Win32 error code otherwise.
|
* @return ERROR_SUCCESS on success or the adapter was not found; Win32 error code otherwise.
|
||||||
*/
|
*/
|
||||||
typedef WINTUN_STATUS(WINAPI *WINTUN_DELETE_ADAPTER_FUNC)(
|
typedef WINTUN_STATUS(WINAPI *WINTUN_DELETE_ADAPTER_FUNC)(
|
||||||
_In_ WINTUN_ADAPTER_HANDLE Adapter,
|
_In_ WINTUN_ADAPTER_HANDLE Adapter,
|
||||||
_In_ BOOL ForceCloseSessions,
|
_In_ BOOL ForceCloseSessions,
|
||||||
_Inout_ BOOL *RebootRequired);
|
_Out_ BOOL *RebootRequired);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by WintunEnumAdapters for each adapter in the pool.
|
* Called by WintunEnumAdapters for each adapter in the pool.
|
||||||
|
Loading…
Reference in New Issue
Block a user