summaryrefslogtreecommitdiffstats
path: root/sys/compat/ndis/kern_windrv.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/compat/ndis/kern_windrv.c')
-rw-r--r--sys/compat/ndis/kern_windrv.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/sys/compat/ndis/kern_windrv.c b/sys/compat/ndis/kern_windrv.c
index f231863..5572988 100644
--- a/sys/compat/ndis/kern_windrv.c
+++ b/sys/compat/ndis/kern_windrv.c
@@ -311,6 +311,24 @@ windrv_unload(mod, img, len)
#define WINDRV_LOADED htonl(0x42534F44)
+#ifdef __amd64__
+static void
+patch_user_shared_data_address(vm_offset_t img, size_t len)
+{
+ unsigned long i, n, max_addr, *addr;
+
+ n = len - sizeof(unsigned long);
+ max_addr = KI_USER_SHARED_DATA + sizeof(kuser_shared_data);
+ for (i = 0; i < n; i++) {
+ addr = (unsigned long *)(img + i);
+ if (*addr >= KI_USER_SHARED_DATA && *addr < max_addr) {
+ *addr -= KI_USER_SHARED_DATA;
+ *addr += (unsigned long)&kuser_shared_data;
+ }
+ }
+}
+#endif
+
/*
* Loader routine for actual Windows driver modules, ultimately
* calls the driver's DriverEntry() routine.
@@ -363,6 +381,10 @@ windrv_load(mod, img, len, bustype, devlist, regvals)
return (ENOEXEC);
}
+#ifdef __amd64__
+ patch_user_shared_data_address(img, len);
+#endif
+
/* Dynamically link USBD.SYS -- optional */
if (pe_get_import_descriptor(img, &imp_desc, "USBD") == 0) {
if (pe_patch_imports(img, "USBD", usbd_functbl))
OpenPOWER on IntegriCloud