api: refuse to load DLL on init failure
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
e7a85b7b28
commit
08440580c3
@ -64,11 +64,14 @@ DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved)
|
||||
case DLL_PROCESS_ATTACH:
|
||||
ResourceModule = hinstDLL;
|
||||
ModuleHeap = HeapCreate(0, 0, 0);
|
||||
if (!ModuleHeap)
|
||||
return FALSE;
|
||||
ConvertStringSecurityDescriptorToSecurityDescriptorW(
|
||||
L"O:SYD:P(A;;GA;;;SY)", SDDL_REVISION_1, &SecurityAttributes.lpSecurityDescriptor, NULL);
|
||||
AdapterInit();
|
||||
NamespaceInit();
|
||||
NciInit();
|
||||
if (NciInit() != ERROR_SUCCESS)
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
|
@ -15,16 +15,21 @@ DWORD(WINAPI *NciGetConnectionName)
|
||||
_In_ DWORD InDestNameBytes,
|
||||
_Out_opt_ DWORD *OutDestNameBytes);
|
||||
|
||||
void
|
||||
WINTUN_STATUS
|
||||
NciInit(void)
|
||||
{
|
||||
NciModule = LoadLibraryExW(L"nci.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||
if (!NciModule)
|
||||
abort();
|
||||
return GetLastError();
|
||||
NciSetConnectionName =
|
||||
(DWORD(WINAPI *)(const GUID *, const WCHAR *))GetProcAddress(NciModule, "NciSetConnectionName");
|
||||
if (!NciSetConnectionName)
|
||||
return GetLastError();
|
||||
NciGetConnectionName =
|
||||
(DWORD(WINAPI *)(const GUID *, WCHAR *, DWORD, DWORD *))GetProcAddress(NciModule, "NciGetConnectionName");
|
||||
if (!NciGetConnectionName)
|
||||
return GetLastError();
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "wintun.h"
|
||||
#include <Windows.h>
|
||||
|
||||
extern DWORD(WINAPI *NciSetConnectionName)(_In_ const GUID *Guid, _In_z_ const WCHAR *NewName);
|
||||
@ -15,7 +16,7 @@ extern DWORD(WINAPI *NciGetConnectionName)(
|
||||
_In_ DWORD InDestNameBytes,
|
||||
_Out_opt_ DWORD *OutDestNameBytes);
|
||||
|
||||
void
|
||||
WINTUN_STATUS
|
||||
NciInit(void);
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user