mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[NOTEPAD] Use FILE_SHARE_READ and OPEN_ALWAYS for writing (#6880)
Fix access denial on writing file "C:\freeldr.ini". JIRA issue: CORE-19575 - Add FILE_SHARE_READ flag and delete FILE_SHARE_WRITE flag in CreateFileW call. - Use OPEN_ALWAYS instead of CREATE_ALWAYS, and then explicitly use SetEndOfFile function.
This commit is contained in:
parent
3e97f76a33
commit
a64cccd711
1 changed files with 6 additions and 2 deletions
|
@ -249,8 +249,10 @@ static BOOL DoSaveFile(VOID)
|
||||||
|
|
||||||
WaitCursor(TRUE);
|
WaitCursor(TRUE);
|
||||||
|
|
||||||
hFile = CreateFileW(Globals.szFileName, GENERIC_WRITE, FILE_SHARE_WRITE,
|
/* Use OPEN_ALWAYS instead of CREATE_ALWAYS in order to succeed
|
||||||
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
* even if the file has HIDDEN or SYSTEM attributes */
|
||||||
|
hFile = CreateFileW(Globals.szFileName, GENERIC_WRITE, FILE_SHARE_READ,
|
||||||
|
NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
if (hFile == INVALID_HANDLE_VALUE)
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
ShowLastError();
|
ShowLastError();
|
||||||
|
@ -281,6 +283,8 @@ static BOOL DoSaveFile(VOID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Truncate the file and close it */
|
||||||
|
SetEndOfFile(hFile);
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
|
||||||
if (bRet)
|
if (bRet)
|
||||||
|
|
Loading…
Reference in a new issue