ac6db7788a
While Doxygen correctly locates the function documentation when it is written directly preceding the function body, Microsoft Visual Studio IDE does not. The former requires the documentation to precede the function declaration. Signed-off-by: Simon Rozman <simon@rozman.si>
70 lines
1.9 KiB
C
70 lines
1.9 KiB
C
/* SPDX-License-Identifier: GPL-2.0
|
|
*
|
|
* Copyright (C) 2018-2020 WireGuard LLC. All Rights Reserved.
|
|
*/
|
|
|
|
#include "pch.h"
|
|
|
|
HINSTANCE ResourceModule;
|
|
|
|
WINTUN_STATUS WINAPI
|
|
WintunGetVersion(
|
|
_Out_ DWORD *DriverVersionMaj,
|
|
_Out_ DWORD *DriverVersionMin,
|
|
_Out_ DWORD *NdisVersionMaj,
|
|
_Out_ DWORD *NdisVersionMin)
|
|
{
|
|
HKEY Key;
|
|
DWORD Result =
|
|
RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\Wintun", 0, KEY_QUERY_VALUE, &Key);
|
|
if (Result != ERROR_SUCCESS)
|
|
return LOG_ERROR(L"Failed to open registry key", Result);
|
|
Result = RegistryQueryDWORD(Key, L"DriverMajorVersion", DriverVersionMaj);
|
|
if (Result != ERROR_SUCCESS)
|
|
{
|
|
LOG(WINTUN_LOG_ERR, L"Failed to query DriverMajorVersion value");
|
|
goto cleanupKey;
|
|
}
|
|
Result = RegistryQueryDWORD(Key, L"DriverMinorVersion", DriverVersionMin);
|
|
if (Result != ERROR_SUCCESS)
|
|
{
|
|
LOG(WINTUN_LOG_ERR, L"Failed to query DriverMinorVersion value");
|
|
goto cleanupKey;
|
|
}
|
|
Result = RegistryQueryDWORD(Key, L"NdisMajorVersion", NdisVersionMaj);
|
|
if (Result != ERROR_SUCCESS)
|
|
{
|
|
LOG(WINTUN_LOG_ERR, L"Failed to query NdisMajorVersion value");
|
|
goto cleanupKey;
|
|
}
|
|
Result = RegistryQueryDWORD(Key, L"NdisMinorVersion", NdisVersionMin);
|
|
if (Result != ERROR_SUCCESS)
|
|
LOG(WINTUN_LOG_ERR, L"Failed to query NdisMinorVersion value");
|
|
cleanupKey:
|
|
RegCloseKey(Key);
|
|
return Result;
|
|
}
|
|
|
|
BOOL APIENTRY
|
|
DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved)
|
|
{
|
|
UNREFERENCED_PARAMETER(lpvReserved);
|
|
|
|
switch (fdwReason)
|
|
{
|
|
case DLL_PROCESS_ATTACH:
|
|
ResourceModule = hinstDLL;
|
|
AdapterInit();
|
|
NamespaceInit();
|
|
NciInit();
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
NciCleanup();
|
|
NamespaceCleanup();
|
|
AdapterCleanup();
|
|
break;
|
|
}
|
|
return TRUE;
|
|
}
|