- diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
- index 1c39ab6..0e0107c 100644
- --- a/sys/nfs41sys_driver.h
- +++ b/sys/nfs41sys_driver.h
- @@ -48,8 +48,10 @@
- (POOL_FLAG_UNINITIALIZED|POOL_FLAG_CACHE_ALIGNED)
- #define RxAllocatePoolWithTag(rxallocpool, numbytes, tag) \
- - ExAllocatePool2(((((rxallocpool) == NonPagedPoolNx)? \
- - POOL_FLAG_NON_PAGED:POOL_FLAG_NON_PAGED_EXECUTE) | \
- + ExAllocatePool2((( \
- + ((rxallocpool) == PagedPool)?POOL_FLAG_PAGED: \
- + (((rxallocpool) == NonPagedPoolNx)? \
- + POOL_FLAG_NON_PAGED:POOL_FLAG_NON_PAGED_EXECUTE)) | \
- RXALLOCATEPOOL_DEFAULT_ALLOCATEPOOL2FLAGS), \
- (numbytes), (tag))
- #endif /* EXALLOCATEPOOLWITHTAG_DEPRECATED */
- diff --git a/sys/nfs41sys_readwrite.c b/sys/nfs41sys_readwrite.c
- index 050819c..b34a4a3 100644
- --- a/sys/nfs41sys_readwrite.c
- +++ b/sys/nfs41sys_readwrite.c
- @@ -58,6 +58,7 @@
- #include <winerror.h>
- #include <Ntstrsafe.h>
- +#include <stdbool.h>
- #include "nfs41sys_buildconfig.h"
- @@ -333,7 +334,7 @@ NTSTATUS nfs41_Write(
- IN OUT PRX_CONTEXT RxContext)
- {
- NTSTATUS status = STATUS_INSUFFICIENT_RESOURCES;
- - nfs41_updowncall_entry *entry;
- + nfs41_updowncall_entry *entry = NULL;
- BOOLEAN async = FALSE;
- PLOWIO_CONTEXT LowIoContext = &RxContext->LowIoContext;
- __notnull PMRX_SRV_OPEN SrvOpen = RxContext->pRelevantSrvOpen;
- @@ -344,6 +345,11 @@ NTSTATUS nfs41_Write(
- __notnull PNFS41_FCB nfs41_fcb = NFS41GetFcbExtension(RxContext->pFcb);
- __notnull PNFS41_FOBX nfs41_fobx = NFS41GetFobxExtension(RxContext->pFobx);
- DWORD io_delay;
- +#if 1
- + void *userbuffer_mem = NULL;
- + PMDL userbuffer_mdl = NULL;
- + PVOID UserBuffer = NULL;
- +#endif
- #ifdef ENABLE_TIMINGS
- LARGE_INTEGER t1, t2;
- t1 = KeQueryPerformanceCounter(NULL);
- @@ -362,9 +368,43 @@ NTSTATUS nfs41_Write(
- pNetRootContext->nfs41d_version, SrvOpen->pAlreadyPrefixedName, &entry);
- if (status) goto out;
- +#if 1
- + userbuffer_mem = RxAllocatePoolWithTag(NonPagedPoolNx,
- + LowIoContext->ParamsFor.ReadWrite.ByteCount,
- + NFS41_MM_POOLTAG_DOWN);
- + if (userbuffer_mem == NULL) {
- + status = STATUS_NO_MEMORY;
- + goto out;
- + }
- +
- + UserBuffer = RxLowIoGetBufferAddress(RxContext);
- + if (UserBuffer == NULL) {
- + status = STATUS_NO_MEMORY;
- + goto out;
- + }
- +
- + userbuffer_mdl = IoAllocateMdl(userbuffer_mem,
- + LowIoContext->ParamsFor.ReadWrite.ByteCount,
- + FALSE, FALSE, NULL);
- + if (userbuffer_mdl == NULL) {
- + status = STATUS_NO_MEMORY;
- + goto out;
- + }
- +
- + MmProbeAndLockPages(userbuffer_mdl, KernelMode, IoModifyAccess);
- +
- + (void)RtlCopyMemory(userbuffer_mem,
- + ((char *)UserBuffer)+LowIoContext->ParamsFor.ReadWrite.ByteOffset,
- + LowIoContext->ParamsFor.ReadWrite.ByteCount);
- +
- + entry->u.ReadWrite.MdlAddress = userbuffer_mdl;
- + entry->buf_len = LowIoContext->ParamsFor.ReadWrite.ByteCount;
- + entry->u.ReadWrite.offset = 0;
- +#else
- entry->u.ReadWrite.MdlAddress = LowIoContext->ParamsFor.ReadWrite.Buffer;
- entry->buf_len = LowIoContext->ParamsFor.ReadWrite.ByteCount;
- entry->u.ReadWrite.offset = LowIoContext->ParamsFor.ReadWrite.ByteOffset;
- +#endif
- if (FlagOn(RxContext->CurrentIrpSp->FileObject->Flags,
- FO_SYNCHRONOUS_IO) == FALSE) {
- @@ -420,6 +460,17 @@ NTSTATUS nfs41_Write(
- }
- nfs41_UpcallDestroy(entry);
- out:
- +#if 1
- + if (!async) {
- + if (userbuffer_mdl) {
- + IoFreeMdl(userbuffer_mdl);
- + }
- + if (userbuffer_mem) {
- + RxFreePool(userbuffer_mem);
- + }
- + }
- +#endif
- +
- #ifdef ENABLE_TIMINGS
- t2 = KeQueryPerformanceCounter(NULL);
- InterlockedIncrement(&write.tops);
workaround for wintar zero bytes in text files bug
Posted by Anonymous on Mon 16th Dec 2024 17:51
raw | new post
view followups (newest first): workaround for wintar zero bytes in text files bug by Anonymous
modification of post by Anonymous (view diff)
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.