diff options
author | Simon Rozman <simon@rozman.si> | 2019-06-20 11:24:03 +0200 |
---|---|---|
committer | Simon Rozman <simon@rozman.si> | 2019-06-20 11:54:58 +0200 |
commit | 9514ef37b398dd82006a7253ac2db3f2bfef1e68 (patch) | |
tree | f96cb9e9bb68bbb49809b4196b027c673904e34d | |
parent | Accept IRP_MJ_WRITE when paused but silently drop the packets (diff) | |
download | wintun-9514ef37b398dd82006a7253ac2db3f2bfef1e68.tar.xz wintun-9514ef37b398dd82006a7253ac2db3f2bfef1e68.zip |
Save some valuable lessons learned on Windows internals
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
-rw-r--r-- | undocumented.h | 1 | ||||
-rw-r--r-- | wintun.c | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/undocumented.h b/undocumented.h index 112be0d..39cc09e 100644 --- a/undocumented.h +++ b/undocumented.h @@ -29,5 +29,6 @@ typedef struct _SYSTEM_HANDLE_INFORMATION_EX } SYSTEM_HANDLE_INFORMATION_EX, *PSYSTEM_HANDLE_INFORMATION_EX; extern NTSTATUS ZwQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, PVOID SystemInformation, ULONG SystemInformationLength, ULONG *ReturnLength); +extern NDIS_HANDLE NdisWdfGetAdapterContextFromAdapterHandle(PVOID DeviceExtension); extern POBJECT_TYPE *IoDeviceObjectType; @@ -66,6 +66,7 @@ typedef struct _TUN_CTX { * atomic and then releasing. It's similar to setting the atomic and then calling rcu_barrier(). */ EX_SPIN_LOCK TransitionLock; + /* This is actually a pointer to NDIS_MINIPORT_BLOCK struct. */ NDIS_HANDLE MiniportAdapterHandle; NDIS_STATISTICS_INFO Statistics; @@ -1023,6 +1024,8 @@ static NDIS_STATUS TunInitializeEx(NDIS_HANDLE MiniportAdapterHandle, NDIS_HANDL goto cleanup_NdisDeregisterDeviceEx; } + /* Jason reverse engineered and found NdisWdfGetAdapterContextFromAdapterHandle. + * Switch from device object's "Reserved" to this when we drop support for Windows 8.1. */ DEVICE_OBJECT *functional_device; NdisMGetDeviceProperty(MiniportAdapterHandle, NULL, &functional_device, NULL, NULL, NULL); |