https://bugs.winehq.org/show_bug.cgi?id=56357 Bug ID: 56357 Summary: Zero sized writes using WriteProcessMemory succeed on Windows, but fail on Wine. testcase source Product: Wine Version: 9.2 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: kernel32 Assignee: wine-bugs(a)winehq.org Reporter: admin(a)sewer56.dev Distribution: --- Created attachment 76082 --> https://bugs.winehq.org/attachment.cgi?id=76082 Precompiled sample C program. [ testcase source ] Zero sized writes using WriteProcessMemory succeed on Windows, but fail on Wine. Build the following program: ```c #include <windows.h> #include <stdio.h> int main() { // Allocate a buffer in memory char* buffer = (char*) VirtualAlloc(NULL, 1024, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); if (buffer == NULL) { printf("Memory allocation failed\n"); return 1; } // Sample data to write (not actually used due to 0-byte length) const char* data = "Sample data"; SIZE_T writtenBytes = 0; // Get a handle to the current process HANDLE processHandle = GetCurrentProcess(); // Attempt to write memory with 0 byte length BOOL result = WriteProcessMemory(processHandle, buffer, data, 0, &writtenBytes); if (result == FALSE) { printf("WriteProcessMemory failed: %lu\n", GetLastError()); } else { printf("WriteProcessMemory succeeded, but 0 bytes were written.\n"); } VirtualFree(buffer, 0, MEM_RELEASE); return 0; } ``` Commandline: ``` x86_64-w64-mingw32-gcc write_process_memory.c -o write_process_memory.exe -lkernel32 ``` When running on Linux, this prints `WriteProcessMemory failed: 87`. When running on Windows, this succeeds `WriteProcessMemory succeeded, but 0 bytes were written`. Tested on x86_64 Archlinux using latest git version of Wine (wine-9.2-286-g232b18d820e). ----------- Extra Notes: I encountered this bug while unit testing a Rust DLL Injection library against Wine: https://github.com/OpenByteDev/dll-syringe/pull/19 -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.