diff --git a/api/adapter.c b/api/adapter.c index bc166c6..8cdf4a9 100644 --- a/api/adapter.c +++ b/api/adapter.c @@ -1689,11 +1689,11 @@ WintunCreateAdapter( _In_z_count_c_(MAX_ADAPTER_NAME) const WCHAR *Name, _In_opt_ const GUID *RequestedGUID, _Out_ WINTUN_ADAPTER **Adapter, - _Inout_ BOOL *RebootRequired) + _Out_ BOOL *RebootRequired) { if (!ElevateToSystem()) return LOG(WINTUN_LOG_ERR, L"Failed to impersonate SYSTEM user"), ERROR_ACCESS_DENIED; - + *RebootRequired = FALSE; DWORD Result = ERROR_SUCCESS; #ifdef MAYBE_WOW64 if (NativeMachine != IMAGE_FILE_PROCESS) @@ -1848,11 +1848,12 @@ cleanupArgv: #endif 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()) return LOG(WINTUN_LOG_ERR, L"Failed to impersonate SYSTEM user"), ERROR_ACCESS_DENIED; + *RebootRequired = FALSE; DWORD Result; #ifdef MAYBE_WOW64 if (NativeMachine != IMAGE_FILE_PROCESS) diff --git a/api/adapter.h b/api/adapter.h index 628299a..541c437 100644 --- a/api/adapter.h +++ b/api/adapter.h @@ -111,10 +111,10 @@ WintunCreateAdapter( _In_z_count_c_(MAX_ADAPTER_NAME) const WCHAR *Name, _In_opt_ const GUID *RequestedGUID, _Out_ WINTUN_ADAPTER **Adapter, - _Inout_ BOOL *RebootRequired); + _Out_ BOOL *RebootRequired); /** * @copydoc WINTUN_DELETE_ADAPTER_FUNC */ 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); diff --git a/api/rundll32.c b/api/rundll32.c index d594723..a397501 100644 --- a/api/rundll32.c +++ b/api/rundll32.c @@ -105,7 +105,7 @@ VOID __stdcall CreateAdapter(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int goto cleanup; WINTUN_ADAPTER *Adapter; - BOOL RebootRequired = FALSE; + BOOL RebootRequired; DWORD Result = WintunCreateAdapter(Argv[2], Argv[3], Argc > 4 ? &RequestedGUID : NULL, &Adapter, &RebootRequired); WCHAR GuidStr[MAX_GUID_STRING_LEN]; WriteFormatted( @@ -137,7 +137,7 @@ VOID __stdcall DeleteAdapter(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int BOOL ForceCloseSessions = wcstoul(Argv[2], NULL, 10); if (FAILED(CLSIDFromString(Argv[3], &Adapter.CfgInstanceID))) goto cleanup; - BOOL RebootRequired = FALSE; + BOOL RebootRequired; WriteFormatted( STD_OUTPUT_HANDLE, 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 } }; WINTUN_ADAPTER *Adapter; - BOOL RebootRequired = FALSE; + BOOL RebootRequired; assert(WintunCreateAdapter(L"Wintun", L"Test", &TestGuid, &Adapter, &RebootRequired) == ERROR_SUCCESS); assert(!RebootRequired); TUN_SESSION *Session; diff --git a/api/wintun.h b/api/wintun.h index b6e1663..7258caf 100644 --- a/api/wintun.h +++ b/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 * WintunFreeAdapter. * - * @param RebootRequired Pointer to a boolean flag to be set to TRUE in case SetupAPI suggests a reboot. Must be - * initialised to FALSE manually before this function is called. + * @param RebootRequired Pointer to a boolean flag to be set to TRUE in case SetupAPI suggests a reboot. * * @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_opt_ const GUID *RequestedGUID, _Out_ WINTUN_ADAPTER_HANDLE *Adapter, - _Inout_ BOOL *RebootRequired); + _Out_ BOOL *RebootRequired); /** * 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 * 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 - * initialised to FALSE manually before this function is called. + * @param RebootRequired Pointer to a boolean flag to be set to TRUE in case SetupAPI suggests a reboot. * * @return ERROR_SUCCESS on success or the adapter was not found; Win32 error code otherwise. */ typedef WINTUN_STATUS(WINAPI *WINTUN_DELETE_ADAPTER_FUNC)( _In_ WINTUN_ADAPTER_HANDLE Adapter, _In_ BOOL ForceCloseSessions, - _Inout_ BOOL *RebootRequired); + _Out_ BOOL *RebootRequired); /** * Called by WintunEnumAdapters for each adapter in the pool.