https://bugs.winehq.org/show_bug.cgi?id=46956
Bug ID: 46956 Summary: ReplaceFile cannot replace the current executable Product: Wine Version: 1.6.2 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: kernel32 Assignee: wine-bugs@winehq.org Reporter: shaggie76@hotmail.com Distribution: ---
Created attachment 64085 --> https://bugs.winehq.org/attachment.cgi?id=64085 A simple VS2017 console project that you can compile to test this.
The ReplaceFile API can be used to update the currently running exe file; this does not work with WINE.
This bug prevents the Warframe launcher from working properly.
A simple program that demonstrates this is:
#include <windows.h> #include <tchar.h>
int main(int argc, const char* argv[]) { TCHAR exePath[MAX_PATH]; TCHAR tmpPath[MAX_PATH];
GetModuleFileName(GetModuleHandle(NULL), exePath, MAX_PATH); _tcscpy_s(tmpPath, MAX_PATH, exePath); _tcscat_s(tmpPath, MAX_PATH, TEXT(".tmp"));
if(!CopyFile(exePath, tmpPath, FALSE)) { _tprintf(TEXT("CopyFile(%s, %s, FALSE) failed [0x%08X]\n"), exePath, tmpPath, GetLastError()); return(1); }
/* this has worked from at least as far back as WinXP and continues to work on Win10 */ if(!ReplaceFile(exePath, tmpPath, NULL, 0, NULL, NULL)) { _tprintf(TEXT("ReplaceFile(%s, %s, NULL, 0, NULL, NULL) failed [0x%08X]\n"), exePath, tmpPath, GetLastError()); return(1); }
/* A proper test would check that the file was actually updated but this is sufficient to demonstrate the bug */ _tprintf(TEXT("No errors!\n"));
return(0); }
Under WINE this prints:
ReplaceFile(Z:\home\glen\WineReplaceFile.exe, Z:\home\glen\WineReplaceFile.exe.tmp, NULL, 0, NULL, NULL) failed [0x00000497]
Under real WinXP to Win10 this prints:
No errors!