pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS

Difference between
modified post 646d8f0 by Anonymous on Wed 18th Dec 2024 10:13
original post 817e by Anonymous on Mon 16th Dec 2024 17:51
Download diff
Show old version | new version | both versions

    
1-
diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
1+
diff --git a/build.vc19/nfs41_driver/nfs41_driver.vcxproj b/build.vc19/nfs41_driver/nfs41_driver.vcxproj
2-
index 1c39ab6..0e0107c 100644
2+
index 0affe23..9c55630 100644
3-
--- a/sys/nfs41sys_driver.h
3+
--- a/build.vc19/nfs41_driver/nfs41_driver.vcxproj
4-
+++ b/sys/nfs41sys_driver.h
4+
+++ b/build.vc19/nfs41_driver/nfs41_driver.vcxproj
5-
@@ -48,8 +48,10 @@
5+
@@ -144,7 +144,7 @@
6-
     (POOL_FLAG_UNINITIALIZED|POOL_FLAG_CACHE_ALIGNED)
6+
       <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
7-
7+
     </ClCompile>
8-
 #define RxAllocatePoolWithTag(rxallocpool, numbytes, tag) \
8+
     <Link>
9-
-    ExAllocatePool2(((((rxallocpool) == NonPagedPoolNx)? \
9+
-      <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib</AdditionalDependencies>
10-
-            POOL_FLAG_NON_PAGED:POOL_FLAG_NON_PAGED_EXECUTE) | \
10+
+      <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib;$(DDK_LIB_PATH)\tdi.lib</AdditionalDependencies>
11-
+    ExAllocatePool2((( \
11+
     </Link>
12-
+            ((rxallocpool) == PagedPool)?POOL_FLAG_PAGED: \
12+
   </ItemDefinitionGroup>
13-
+                (((rxallocpool) == NonPagedPoolNx)? \
13+
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
14-
+                    POOL_FLAG_NON_PAGED:POOL_FLAG_NON_PAGED_EXECUTE)) | \
14+
@@ -158,7 +158,7 @@
15-
             RXALLOCATEPOOL_DEFAULT_ALLOCATEPOOL2FLAGS), \
15+
       <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
16-
         (numbytes), (tag))
16+
     </ClCompile>
17-
 #endif /* EXALLOCATEPOOLWITHTAG_DEPRECATED */
17+
     <Link>
18-
diff --git a/sys/nfs41sys_readwrite.c b/sys/nfs41sys_readwrite.c
18+
-      <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib</AdditionalDependencies>
19-
index 050819c..b34a4a3 100644
19+
+      <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib;$(DDK_LIB_PATH)\tdi.lib</AdditionalDependencies>
20-
--- a/sys/nfs41sys_readwrite.c
20+
     </Link>
21-
+++ b/sys/nfs41sys_readwrite.c
21+
   </ItemDefinitionGroup>
22-
@@ -58,6 +58,7 @@
22+
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
23-
 #include <winerror.h>
23+
@@ -172,7 +172,7 @@
24-
24+
       <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
25-
 #include <Ntstrsafe.h>
25+
     </ClCompile>
26-
+#include <stdbool.h>
26+
     <Link>
27-
27+
-      <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib</AdditionalDependencies>
28-
 #include "nfs41sys_buildconfig.h"
28+
+      <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib;$(DDK_LIB_PATH)\tdi.lib</AdditionalDependencies>
29-
29+
     </Link>
30-
@@ -333,7 +334,7 @@ NTSTATUS nfs41_Write(
30+
     <DriverSign>
31-
     IN OUT PRX_CONTEXT RxContext)
31+
       <FileDigestAlgorithm>sha256</FileDigestAlgorithm>
32-
 {
32+
@@ -189,7 +189,7 @@
33-
     NTSTATUS status = STATUS_INSUFFICIENT_RESOURCES;
33+
       <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
34-
-    nfs41_updowncall_entry *entry;
34+
     </ClCompile>
35-
+    nfs41_updowncall_entry *entry = NULL;
35+
     <Link>
36-
     BOOLEAN async = FALSE;
36+
-      <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib</AdditionalDependencies>
37-
     PLOWIO_CONTEXT LowIoContext  = &RxContext->LowIoContext;
37+
+      <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib;$(DDK_LIB_PATH)\tdi.lib</AdditionalDependencies>
38-
     __notnull PMRX_SRV_OPEN SrvOpen = RxContext->pRelevantSrvOpen;
38+
     </Link>
39-
@@ -344,6 +345,11 @@ NTSTATUS nfs41_Write(
39+
     <DriverSign>
40-
     __notnull PNFS41_FCB nfs41_fcb = NFS41GetFcbExtension(RxContext->pFcb);
40+
       <FileDigestAlgorithm>sha256</FileDigestAlgorithm>
41-
     __notnull PNFS41_FOBX nfs41_fobx = NFS41GetFobxExtension(RxContext->pFobx);
41+
@@ -206,7 +206,7 @@
42-
     DWORD io_delay;
42+
       <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
43-
+#if 1
43+
     </ClCompile>
44-
+    void *userbuffer_mem = NULL;
44+
     <Link>
45-
+    PMDL userbuffer_mdl = NULL;
45+
-      <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib</AdditionalDependencies>
46-
+    PVOID UserBuffer = NULL;
46+
+      <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib;$(DDK_LIB_PATH)\tdi.lib</AdditionalDependencies>
47-
+#endif
47+
     </Link>
48-
 #ifdef ENABLE_TIMINGS
48+
   </ItemDefinitionGroup>
49-
     LARGE_INTEGER t1, t2;
49+
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
50-
     t1 = KeQueryPerformanceCounter(NULL);
50+
@@ -220,7 +220,7 @@
51-
@@ -362,9 +368,43 @@ NTSTATUS nfs41_Write(
51+
       <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
52-
         pNetRootContext->nfs41d_version, SrvOpen->pAlreadyPrefixedName, &entry);
52+
     </ClCompile>
53-
     if (status) goto out;
53+
     <Link>
54-
54+
-      <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib</AdditionalDependencies>
55-
+#if 1
55+
+      <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib;$(DDK_LIB_PATH)\tdi.lib</AdditionalDependencies>
56-
+    userbuffer_mem = RxAllocatePoolWithTag(NonPagedPoolNx,
56+
     </Link>
57-
+        LowIoContext->ParamsFor.ReadWrite.ByteCount,
57+
   </ItemDefinitionGroup>
58-
+        NFS41_MM_POOLTAG_DOWN);
58+
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
59-
+    if (userbuffer_mem == NULL) {
59+
@@ -234,7 +234,7 @@
60-
+        status = STATUS_NO_MEMORY;
60+
       <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
61-
+        goto out;
61+
     </ClCompile>
62-
+    }
62+
     <Link>
63-
+
63+
-      <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib</AdditionalDependencies>
64-
+    UserBuffer = RxLowIoGetBufferAddress(RxContext);
64+
+      <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib;$(DDK_LIB_PATH)\tdi.lib</AdditionalDependencies>
65-
+    if (UserBuffer == NULL) {
65+
     </Link>
66-
+        status = STATUS_NO_MEMORY;
66+
     <DriverSign>
67-
+        goto out;
67+
       <FileDigestAlgorithm>sha256</FileDigestAlgorithm>
68-
+    }
68+
@@ -251,7 +251,7 @@
69-
+
69+
       <AdditionalOptions>/std:c17 /Zc:preprocessor- /kernel /wd4100 /wd4201 /wd5104</AdditionalOptions>
70-
+    userbuffer_mdl = IoAllocateMdl(userbuffer_mem,
70+
     </ClCompile>
71-
+        LowIoContext->ParamsFor.ReadWrite.ByteCount,
71+
     <Link>
72-
+        FALSE, FALSE, NULL);
72+
-      <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib</AdditionalDependencies>
73-
+    if (userbuffer_mdl == NULL) {
73+
+      <AdditionalDependencies>$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\hal.lib;$(DDK_LIB_PATH)\BufferOverflowfastfailK.lib;$(DDK_LIB_PATH)\ksecdd.lib;$(DDK_LIB_PATH)\rxce.lib;$(DDK_LIB_PATH)\rdbsslib.lib;$(DDK_LIB_PATH)\tdi.lib</AdditionalDependencies>
74-
+        status = STATUS_NO_MEMORY;
74+
     </Link>
75-
+        goto out;
75+
     <DriverSign>
76-
+    }
76+
       <FileDigestAlgorithm>sha256</FileDigestAlgorithm>
77-
+
77+
diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
78-
+    MmProbeAndLockPages(userbuffer_mdl, KernelMode, IoModifyAccess);
78+
index 1c39ab6..0e0107c 100644
79-
+
79+
--- a/sys/nfs41sys_driver.h
80-
+    (void)RtlCopyMemory(userbuffer_mem,
80+
+++ b/sys/nfs41sys_driver.h
81-
+        ((char *)UserBuffer)+LowIoContext->ParamsFor.ReadWrite.ByteOffset,
81+
@@ -48,8 +48,10 @@
82-
+        LowIoContext->ParamsFor.ReadWrite.ByteCount);
82+
     (POOL_FLAG_UNINITIALIZED|POOL_FLAG_CACHE_ALIGNED)
9283
93-
     if (FlagOn(RxContext->CurrentIrpSp->FileObject->Flags,
84+
 #define RxAllocatePoolWithTag(rxallocpool, numbytes, tag) \
94-
             FO_SYNCHRONOUS_IO) == FALSE) {
85+
-    ExAllocatePool2(((((rxallocpool) == NonPagedPoolNx)? \
95-
@@ -420,6 +460,17 @@ NTSTATUS nfs41_Write(
86+
-            POOL_FLAG_NON_PAGED:POOL_FLAG_NON_PAGED_EXECUTE) | \
96-
     }
87+
+    ExAllocatePool2((( \
97-
     nfs41_UpcallDestroy(entry);
88+
+            ((rxallocpool) == PagedPool)?POOL_FLAG_PAGED: \
98-
 out:
89+
+                (((rxallocpool) == NonPagedPoolNx)? \
99-
+#if 1
90+
+                    POOL_FLAG_NON_PAGED:POOL_FLAG_NON_PAGED_EXECUTE)) | \
100-
+    if (!async) {
91+
             RXALLOCATEPOOL_DEFAULT_ALLOCATEPOOL2FLAGS), \
101-
+        if (userbuffer_mdl) {
92+
         (numbytes), (tag))
102-
+            IoFreeMdl(userbuffer_mdl);
93+
 #endif /* EXALLOCATEPOOLWITHTAG_DEPRECATED */
103-
+        }
94+
diff --git a/sys/nfs41sys_readwrite.c b/sys/nfs41sys_readwrite.c
104-
+        if (userbuffer_mem) {
95+
index 050819c..a70ead2 100644
105-
+            RxFreePool(userbuffer_mem);
96+
--- a/sys/nfs41sys_readwrite.c
106-
+        }
97+
+++ b/sys/nfs41sys_readwrite.c
107-
+    }
98+
@@ -58,6 +58,8 @@
108-
+#endif
99+
 #include <winerror.h>
113100
114-
101+
 #include <Ntstrsafe.h>
115-
102+
+#include <stdbool.h>
116-
103+
+#include <tdikrnl.h>
117104
118-
105+
 #include "nfs41sys_buildconfig.h"
119106
120-
107+
@@ -333,7 +335,7 @@ NTSTATUS nfs41_Write(
121-
108+
     IN OUT PRX_CONTEXT RxContext)
122-
109+
 {
123-
110+
     NTSTATUS status = STATUS_INSUFFICIENT_RESOURCES;
124-
111+
-    nfs41_updowncall_entry *entry;
125-
112+
+    nfs41_updowncall_entry *entry = NULL;
126-
113+
     BOOLEAN async = FALSE;
127-
114+
     PLOWIO_CONTEXT LowIoContext  = &RxContext->LowIoContext;
128-
115+
     __notnull PMRX_SRV_OPEN SrvOpen = RxContext->pRelevantSrvOpen;
129-
116+
@@ -344,6 +346,11 @@ NTSTATUS nfs41_Write(
130-
117+
     __notnull PNFS41_FCB nfs41_fcb = NFS41GetFcbExtension(RxContext->pFcb);
131-
118+
     __notnull PNFS41_FOBX nfs41_fobx = NFS41GetFobxExtension(RxContext->pFobx);
132-
119+
     DWORD io_delay;
133-
120+
+#if 1
134-
121+
+    void *userbuffer_mem = NULL;
135-
122+
+    PMDL userbuffer_mdl = NULL;
136-
123+
+//    PVOID UserBuffer = NULL;
137-
124+
+#endif
138-
125+
 #ifdef ENABLE_TIMINGS
139-
126+
     LARGE_INTEGER t1, t2;
140-
127+
     t1 = KeQueryPerformanceCounter(NULL);
141-
128+
@@ -362,9 +369,151 @@ NTSTATUS nfs41_Write(
142-
129+
         pNetRootContext->nfs41d_version, SrvOpen->pAlreadyPrefixedName, &entry);
143-
130+
     if (status) goto out;
144131
145-
132+
+#if 1
146-
133+
+    ULONG padded_readwrite_bytecount = LowIoContext->ParamsFor.ReadWrite.ByteCount + (8192) /* fixme */;
147-
134+
+
148-
135+
+#if 1
149-
136+
+    userbuffer_mem = ExAllocatePool2(POOL_FLAG_PAGED, padded_readwrite_bytecount, NFS41_MM_POOLTAG_DOWN);
150-
137+
+#else
151-
138+
+    userbuffer_mem = RxAllocatePoolWithTag(NonPagedPoolNx,
152-
139+
+        padded_readwrite_bytecount,
153-
140+
+        NFS41_MM_POOLTAG_DOWN);
154-
141+
+#endif
155-
142+
+    if (userbuffer_mem == NULL) {
156-
143+
+        status = STATUS_NO_MEMORY;
157-
144+
+        goto out;
158-
145+
+    }
159-
146+
+
160-
147+
+    RtlZeroMemory(userbuffer_mem, padded_readwrite_bytecount);
161-
148+
+#if 0
162-
149+
+    UserBuffer = RxLowIoGetBufferAddress(RxContext);
163-
150+
+    if (UserBuffer == NULL) {
164-
151+
+        status = STATUS_NO_MEMORY;
165-
152+
+        goto out;
166-
153+
+    }
167-
154+
+#endif
168-
155+
+    userbuffer_mdl = IoAllocateMdl(userbuffer_mem,
169-
156+
+        padded_readwrite_bytecount,
170-
157+
+        FALSE, FALSE, NULL);
171-
158+
+    if (userbuffer_mdl == NULL) {
172-
159+
+        status = STATUS_NO_MEMORY;
173-
160+
+        goto out;
174-
161+
+    }
175-
162+
+
176-
163+
+#if 1
177-
164+
+#pragma warning( push )
178-
165+
+/*
179-
166+
+ * C28145: "The opaque MDL structure should not be modified by a
180-
167+
+ * driver.", |MDL_MAPPING_CAN_FAIL| is the exception
181-
168+
+ */
182-
169+
+#pragma warning (disable : 28145)
183-
170+
+        userbuffer_mdl->MdlFlags |= MDL_MAPPING_CAN_FAIL;
184-
171+
+#pragma warning( pop )
185-
172+
+#endif
186-
173+
+
187-
174+
+    MmProbeAndLockPages(userbuffer_mdl, KernelMode, IoModifyAccess);
188-
175+
+
189-
176+
+#if 1
190-
177+
+
191-
178+
+#if 1
192-
179+
+    PVOID Src;
193-
180+
+
194-
181+
+    if ((Src = MmGetSystemAddressForMdlSafe(LowIoContext->ParamsFor.ReadWrite.Buffer, NormalPagePriority)) == NULL) {
195-
182+
+        return STATUS_INSUFFICIENT_RESOURCES;
196-
183+
+    }
197-
184+
+
198-
185+
+    ULONG mdl_bytecount = MmGetMdlByteCount(LowIoContext->ParamsFor.ReadWrite.Buffer);
199-
186+
+
200-
187+
+    if (mdl_bytecount < LowIoContext->ParamsFor.ReadWrite.ByteCount) {
201-
188+
+        DbgP("#### ERROR: mdl_bytecount(=%lld) < LowIoContext->ParamsFor.ReadWrite.ByteCount(=%lld)\n",
202-
189+
+            (long long)mdl_bytecount,
203-
190+
+            (long long)LowIoContext->ParamsFor.ReadWrite.ByteCount);
204-
191+
+        DbgP("ReadWrite.Buffer=(Next=0x%p, Size=%ld, MdlFlags=0x%lx, "
205-
192+
+            "Process=0x%p, MappedSystemVa=0x%p, StartVa=0x%p, "
206-
193+
+            "ByteCount=%ld, ByteOffset=%ld)\n",
207-
194+
+            (void *)LowIoContext->ParamsFor.ReadWrite.Buffer->Next,
208-
195+
+            (long)LowIoContext->ParamsFor.ReadWrite.Buffer->Size,
209-
196+
+            (long)LowIoContext->ParamsFor.ReadWrite.Buffer->MdlFlags,
210-
197+
+            (void *)LowIoContext->ParamsFor.ReadWrite.Buffer->Process,
211-
198+
+            (void *)LowIoContext->ParamsFor.ReadWrite.Buffer->MappedSystemVa,
212-
199+
+            (void *)LowIoContext->ParamsFor.ReadWrite.Buffer->StartVa,
213-
200+
+            (long)LowIoContext->ParamsFor.ReadWrite.Buffer->ByteCount,
214-
201+
+            (long)LowIoContext->ParamsFor.ReadWrite.Buffer->ByteOffset);
215-
202+
+        return STATUS_INTERNAL_ERROR;
216-
203+
+    }
217-
204+
+
218-
205+
+#if 1
219-
206+
+    volatile char *cp_dest = userbuffer_mem;
220-
207+
+    volatile char *cp_src = ((char *)Src)+LowIoContext->ParamsFor.ReadWrite.ByteOffset;
221-
208+
+    volatile char tmpbyte;
222-
209+
+
223-
210+
+    long long cp_i;
224-
211+
+
225-
212+
+    long long cp_max = LowIoContext->ParamsFor.ReadWrite.ByteCount;
226-
213+
+
227-
214+
+    if (LowIoContext->ParamsFor.ReadWrite.ByteOffset)
228-
215+
+        cp_max--;
229-
216+
+
230-
217+
+    for (cp_i = 0 ; cp_i < cp_max ; cp_i++) {
231-
218+
+        tmpbyte = *cp_src++;
232-
219+
+
233-
220+
+        *cp_dest++ = tmpbyte;
234-
221+
+    }
235-
222+
+#else
236-
223+
+    (void)RtlCopyMemory(userbuffer_mem,
237-
224+
+        ((char *)Src)+LowIoContext->ParamsFor.ReadWrite.ByteOffset,
238-
225+
+        LowIoContext->ParamsFor.ReadWrite.ByteCount);
239-
226+
+#endif
240-
227+
+#else
241-
228+
+    ULONG bytescopied = 0UL;
242-
229+
+    NTSTATUS tdi_status;
243-
230+
+
244-
231+
+    tdi_status = TdiCopyMdlToBuffer(LowIoContext->ParamsFor.ReadWrite.Buffer,
245-
232+
+        (ULONG)LowIoContext->ParamsFor.ReadWrite.ByteOffset /* fixme: Add assert LONGLONG2ULONG cast */,
246-
233+
+        userbuffer_mem,
247-
234+
+        0,
248-
235+
+        LowIoContext->ParamsFor.ReadWrite.ByteCount+1,
249-
236+
+        &bytescopied);
250-
237+
+
251-
238+
+    if (((tdi_status != STATUS_SUCCESS) && (tdi_status != STATUS_BUFFER_OVERFLOW)) ||
252-
239+
+        (bytescopied != LowIoContext->ParamsFor.ReadWrite.ByteCount)) {
253-
240+
+        DbgP("#### ERROR: tdi_status=0x%lx || (bytescopied(=%lld) != ReadWrite.ByteCount(=%lld))\n",
254-
241+
+            (long)tdi_status,
255-
242+
+            (long long)bytescopied,
256-
243+
+            (long long)LowIoContext->ParamsFor.ReadWrite.ByteCount);
257-
244+
+        DbgP("ReadWrite.Buffer=(Next=0x%p, Size=%ld, MdlFlags=0x%lx, "
258-
245+
+            "Process=0x%p, MappedSystemVa=0x%p, StartVa=0x%p, "
259-
246+
+            "ByteCount=%ld, ByteOffset=%ld)\n",
260-
247+
+            (void *)LowIoContext->ParamsFor.ReadWrite.Buffer->Next,
261-
248+
+            (long)LowIoContext->ParamsFor.ReadWrite.Buffer->Size,
262-
249+
+            (long)LowIoContext->ParamsFor.ReadWrite.Buffer->MdlFlags,
263-
250+
+            (void *)LowIoContext->ParamsFor.ReadWrite.Buffer->Process,
264-
251+
+            (void *)LowIoContext->ParamsFor.ReadWrite.Buffer->MappedSystemVa,
265-
252+
+            (void *)LowIoContext->ParamsFor.ReadWrite.Buffer->StartVa,
266-
253+
+            (long)LowIoContext->ParamsFor.ReadWrite.Buffer->ByteCount,
267-
254+
+            (long)LowIoContext->ParamsFor.ReadWrite.Buffer->ByteOffset);
268-
255+
+    }
269-
256+
+    if ((bytescopied == 0) && (LowIoContext->ParamsFor.ReadWrite.ByteCount > 0)) {
270-
257+
+        DbgP("requesting STATUS_RETRY\n");
271-
258+
+//        status = STATUS_RETRY;
272-
259+
+//        goto out;
273-
260+
+    }
274-
261+
+
275-
262+
+#endif
276-
263+
+#else
277-
264+
+    (void)RtlCopyMemory(userbuffer_mem,
278-
265+
+        ((char *)UserBuffer)+LowIoContext->ParamsFor.ReadWrite.ByteOffset,
279-
266+
+        LowIoContext->ParamsFor.ReadWrite.ByteCount);
280-
267+
+#endif
281-
268+
+
282-
269+
+    entry->u.ReadWrite.MdlAddress = userbuffer_mdl;
283-
270+
+    entry->buf_len = LowIoContext->ParamsFor.ReadWrite.ByteCount;
284-
271+
+    entry->u.ReadWrite.offset = 0;
285-
272+
+#else
286-
273+
     entry->u.ReadWrite.MdlAddress = LowIoContext->ParamsFor.ReadWrite.Buffer;
287-
274+
     entry->buf_len = LowIoContext->ParamsFor.ReadWrite.ByteCount;
288-
275+
     entry->u.ReadWrite.offset = LowIoContext->ParamsFor.ReadWrite.ByteOffset;
289-
276+
+#endif
290277
291-
278+
     if (FlagOn(RxContext->CurrentIrpSp->FileObject->Flags,
292-
279+
             FO_SYNCHRONOUS_IO) == FALSE) {
293-
280+
@@ -420,6 +569,17 @@ NTSTATUS nfs41_Write(
294-
281+
     }
295-
282+
     nfs41_UpcallDestroy(entry);
296-
283+
 out:
297-
284+
+#if 1
298-
285+
+    if (!async) {
299-
286+
+        if (userbuffer_mdl) {
300-
287+
+            IoFreeMdl(userbuffer_mdl);
301-
288+
+        }
302-
289+
+        if (userbuffer_mem) {
303-
290+
+            RxFreePool(userbuffer_mem);
304-
291+
+        }
305-
292+
+    }
306-
293+
+#endif
307-
294+
+
308-
295+
 #ifdef ENABLE_TIMINGS
309-
296+
     t2 = KeQueryPerformanceCounter(NULL);
310-
297+
     InterlockedIncrement(&write.tops);
311298

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at