[Bug 56357] New: Zero sized writes using WriteProcessMemory succeed on Windows, but fail on Wine. testcase source
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.
https://bugs.winehq.org/show_bug.cgi?id=56357 admin(a)sewer56.dev changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Zero sized writes using |Zero sized writes using |WriteProcessMemory succeed |WriteProcessMemory succeed |on Windows, but fail on |on Windows, but fail on |Wine. testcase source |Wine. -- 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.
https://bugs.winehq.org/show_bug.cgi?id=56357 Austin English <austinenglish(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, source, testcase -- 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.
https://bugs.winehq.org/show_bug.cgi?id=56357 Eric Pouech <eric.pouech(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Ever confirmed|0 |1 CC| |eric.pouech(a)gmail.com --- Comment #1 from Eric Pouech <eric.pouech(a)gmail.com> --- Wine currently implements Windows 7 & 8 behavior to fail on 0-length writes. Windows 10 & 11 behavior has changed and now succeeds on 0-length writes. Created https://gitlab.winehq.org/wine/wine/-/merge_requests/5162 A+ -- 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.
https://bugs.winehq.org/show_bug.cgi?id=56357 Eric Pouech <eric.pouech(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |9897719562fc47d8d3476928d3d | |b0dd5eb6dfb28 Resolution|--- |FIXED Status|ASSIGNED |RESOLVED --- Comment #2 from Eric Pouech <eric.pouech(a)gmail.com> --- closing resolved/fixed -- 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.
https://bugs.winehq.org/show_bug.cgi?id=56357 Alexandre Julliard <julliard(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED --- Comment #3 from Alexandre Julliard <julliard(a)winehq.org> --- Closing bugs fixed in 9.4. -- 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.
https://bugs.winehq.org/show_bug.cgi?id=56357 Michael Stefaniuc <mstefani(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |9.0.x -- 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.
http://bugs.winehq.org/show_bug.cgi?id=56357 Michael Stefaniuc <mstefani(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|9.0.x |--- --- Comment #4 from Michael Stefaniuc <mstefani(a)winehq.org> --- Removing the 9.0.x milestone from bug fixes included in 9.0.1. -- 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.
participants (1)
-
WineHQ Bugzilla