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>
This commit is contained in:
Simon Rozman 2019-06-20 11:24:03 +02:00
parent da3caadf48
commit 9514ef37b3
2 changed files with 4 additions and 0 deletions

View File

@ -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;

View File

@ -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);