diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-06-24 12:12:13 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-06-25 16:18:03 +0200 |
commit | ed2f5cc225365268acd36eab1562ab02a1c3e89d (patch) | |
tree | fa0a92e406954ab8cd07dc242555339b0ae3b65d /api/session.c | |
parent | driver: hard code security descriptor bytes (diff) | |
download | wintun-ed2f5cc225365268acd36eab1562ab02a1c3e89d.tar.xz wintun-ed2f5cc225365268acd36eab1562ab02a1c3e89d.zip |
api: don't auto-elevate
There's no longer a need to do this for every API call. This only exists
now for the pnp guid reuse workaround hack.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | api/session.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/api/session.c b/api/session.c index 763dd83..d266d5d 100644 --- a/api/session.c +++ b/api/session.c @@ -77,7 +77,7 @@ _Return_type_success_(return != NULL) TUN_SESSION *WINAPI if (!Session) { LastError = GetLastError(); - goto out; + goto cleanup; } const ULONG RingSize = TUN_RING_SIZE(Capacity); BYTE *AllocatedRegion = VirtualAlloc(0, (size_t)RingSize * 2, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); @@ -86,18 +86,13 @@ _Return_type_success_(return != NULL) TUN_SESSION *WINAPI LastError = LOG_LAST_ERROR(L"Failed to allocate ring memory (requested size: 0x%zx)", (size_t)RingSize * 2); goto cleanupRings; } - if (!ElevateToSystem()) - { - LastError = LOG(WINTUN_LOG_ERR, L"Failed to impersonate SYSTEM user"); - goto cleanupAllocatedRegion; - } Session->Descriptor.Send.RingSize = RingSize; Session->Descriptor.Send.Ring = (TUN_RING *)AllocatedRegion; Session->Descriptor.Send.TailMoved = CreateEventW(&SecurityAttributes, FALSE, FALSE, NULL); if (!Session->Descriptor.Send.TailMoved) { LastError = LOG_LAST_ERROR(L"Failed to create send event"); - goto cleanupToken; + goto cleanupAllocatedRegion; } Session->Descriptor.Receive.RingSize = RingSize; @@ -129,7 +124,6 @@ _Return_type_success_(return != NULL) TUN_SESSION *WINAPI LastError = LOG_LAST_ERROR(L"Failed to register rings"); goto cleanupHandle; } - RevertToSelf(); Session->Capacity = Capacity; (void)InitializeCriticalSectionAndSpinCount(&Session->Receive.Lock, LOCK_SPIN_COUNT); (void)InitializeCriticalSectionAndSpinCount(&Session->Send.Lock, LOCK_SPIN_COUNT); @@ -140,13 +134,11 @@ cleanupReceiveTailMoved: CloseHandle(Session->Descriptor.Receive.TailMoved); cleanupSendTailMoved: CloseHandle(Session->Descriptor.Send.TailMoved); -cleanupToken: - RevertToSelf(); cleanupAllocatedRegion: VirtualFree(AllocatedRegion, 0, MEM_RELEASE); cleanupRings: Free(Session); -out: +cleanup: SetLastError(LastError); return NULL; } |