diff --git a/dokan/dokan.c b/dokan/dokan.c index ee205a81..5624c01c 100644 --- a/dokan/dokan.c +++ b/dokan/dokan.c @@ -1366,8 +1366,8 @@ VOID DOKANAPI DokanMapKernelToUserCreateFileFlags( } VOID DOKANAPI DokanInit() { - // ensure 64-bit alignment - assert(FIELD_OFFSET(EVENT_INFORMATION, Buffer) % 8 == 0); + // ensure 64-byte alignment, memcpy runs much faster on 64-byte aligned buffer on moden CPU + static_assert(FIELD_OFFSET(EVENT_INFORMATION, Buffer) % 64 == 0, "alignment error"); // this is not as safe as a critical section so to some degree we rely on // the user to do the right thing diff --git a/sys/public.h b/sys/public.h index b7c74be6..1b967404 100644 --- a/sys/public.h +++ b/sys/public.h @@ -388,6 +388,7 @@ typedef struct _EVENT_INFORMATION { ULONG64 Context; ULONG BufferLength; ULONG PullEventTimeoutMs; + UCHAR Padding[24]; // ensure buffer is 64-byte aligned UCHAR Buffer[DOKAN_EVENT_INFO_MIN_BUFFER_SIZE]; } EVENT_INFORMATION, *PEVENT_INFORMATION;