mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[WORDPAD] Use FILE_SHARE_READ and OPEN_ALWAYS for writing (#6883)
Follow-up to #6880. Fix access denial on writing file "C:\freeldr.ini". JIRA issue: CORE-19575 - Add FILE_SHARE_READ flag in CreateFileW call. - Use OPEN_ALWAYS instead of CREATE_ALWAYS, and then explicitly use SetEndOfFile function.
This commit is contained in:
parent
a64cccd711
commit
2b0d1faaa9
1 changed files with 11 additions and 0 deletions
|
@ -843,8 +843,15 @@ static BOOL DoSaveFile(LPCWSTR wszSaveFileName, WPARAM format)
|
|||
EDITSTREAM stream;
|
||||
LRESULT ret;
|
||||
|
||||
#ifdef __REACTOS__
|
||||
/* Use OPEN_ALWAYS instead of CREATE_ALWAYS in order to succeed
|
||||
* even if the file has HIDDEN or SYSTEM attributes */
|
||||
hFile = CreateFileW(wszSaveFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
#else
|
||||
hFile = CreateFileW(wszSaveFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
#endif
|
||||
|
||||
if(hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
|
@ -870,6 +877,10 @@ static BOOL DoSaveFile(LPCWSTR wszSaveFileName, WPARAM format)
|
|||
|
||||
ret = SendMessageW(hEditorWnd, EM_STREAMOUT, format, (LPARAM)&stream);
|
||||
|
||||
#ifdef __REACTOS__
|
||||
/* Truncate the file and close it */
|
||||
SetEndOfFile(hFile);
|
||||
#endif
|
||||
CloseHandle(hFile);
|
||||
|
||||
SetFocus(hEditorWnd);
|
||||
|
|
Loading…
Reference in a new issue