Revision: 9134 https://osdn.net/projects/ttssh2/scm/svn/commits/9134 Author: nmaya Date: 2021-01-23 00:00:52 +0900 (Sat, 23 Jan 2021) Log Message: ----------- CreateFile の共有モードを修正 - GENERIC_WRITE で開くときに FILE_SHARE_WRITE で共有している箇所を 0 (共有しない)に修正 - Win16 API の _lcreat, _lopen はロックしないので、互換性のため FILE_SHARE_READ | FILE_SHARE_WRITE に変更 - TTL の filecreate, fileopen のファイルハンドルは filelock でロックするので、 FILE_SHARE_READ | FILE_SHARE_WRITE に変更 dwShareMode で指定する共有モードは、後続の"ファイルを開く"操作に対して「有効にする」アクセスを指定する > https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea > Enables subsequent open operations on a file or device to request xxx access. #41305 の修正を含む Ticket Links: ------------ https://osdn.net/projects/ttssh2/tracker/detail/41305 Modified Paths: -------------- trunk/doc/en/html/about/history.html trunk/doc/ja/html/about/history.html trunk/teraterm/common/win16api.c trunk/teraterm/teraterm/filesys_log.cpp trunk/teraterm/ttpfile/filesys_win32.cpp trunk/teraterm/ttpmacro/ttl.cpp -------------- next part -------------- Modified: trunk/doc/en/html/about/history.html =================================================================== --- trunk/doc/en/html/about/history.html 2021-01-16 05:37:28 UTC (rev 9133) +++ trunk/doc/en/html/about/history.html 2021-01-22 15:00:52 UTC (rev 9134) @@ -41,6 +41,7 @@ <li>Bug fixes <ul> + <li><a href="../macro/command/filecreate.html">filecreate</a>, <a href="../macro/command/fileopen.html">fileopen</a> \x83}\x83N\x83\x8D\x83R\x83}\x83\x93\x83h\x82ŊJ\x82\xA2\x82\xBD\x83t\x83@\x83C\x83\x8B\x83n\x83\x93\x83h\x83\x8B\x82\xAA\x83\x8D\x83b\x83N\x82\xB5\x82Ă\xA2\x82\xE9\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li> </ul> </li> Modified: trunk/doc/ja/html/about/history.html =================================================================== --- trunk/doc/ja/html/about/history.html 2021-01-16 05:37:28 UTC (rev 9133) +++ trunk/doc/ja/html/about/history.html 2021-01-22 15:00:52 UTC (rev 9134) @@ -41,6 +41,7 @@ <li>Bug fixes <ul> + <li><a href="../macro/command/filecreate.html">filecreate</a>, <a href="../macro/command/fileopen.html">fileopen</a> \x83}\x83N\x83\x8D\x83R\x83}\x83\x93\x83h\x82ŊJ\x82\xA2\x82\xBD\x83t\x83@\x83C\x83\x8B\x83n\x83\x93\x83h\x83\x8B\x82\xAA\x83\x8D\x83b\x83N\x82\xB5\x82Ă\xA2\x82\xE9\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li> </ul> </li> Modified: trunk/teraterm/common/win16api.c =================================================================== --- trunk/teraterm/common/win16api.c 2021-01-16 05:37:28 UTC (rev 9133) +++ trunk/teraterm/common/win16api.c 2021-01-22 15:00:52 UTC (rev 9134) @@ -30,6 +30,12 @@ #include <assert.h> /** + * Win16 API \x82\xCC _lcreat, _lopen \x82̓\x8D\x83b\x83N\x82\xB5\x82Ȃ\xA2\x82̂ŁA + * \x8C݊\xB7\x90\xAB\x82̂\xBD\x82\xDF CreateFile() \x82\xCC dwShareMode \x82ɂ\xCD + * FILE_SHARE_READ | FILE_SHARE_WRITE \x82\xF0\x8Ew\x92肷\x82\xE9\x81B + */ + +/** * win16_lcreat() \x82\xCC wchar_t\x94\xC5 * @param[in] iAttribute teraterm\x82ł\xCD0\x82\xB5\x82\xA9\x8Eg\x97p\x82\xB5\x82Ȃ\xA2 * @retval handle @@ -41,7 +47,7 @@ HANDLE handle; assert(iAttribute == 0); handle = CreateFileW(FileName, - GENERIC_WRITE, FILE_SHARE_WRITE, NULL, + GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); return handle; } @@ -57,7 +63,7 @@ HANDLE handle; assert(iAttribute == 0); handle = CreateFileA(FileName, - GENERIC_WRITE, FILE_SHARE_WRITE, NULL, + GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); return handle; } @@ -75,13 +81,13 @@ case OF_READ: // read only handle = CreateFileW(FileName, - GENERIC_READ, FILE_SHARE_READ, NULL, + GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); break; case OF_WRITE: // write handle = CreateFileW(FileName, - GENERIC_WRITE, FILE_SHARE_WRITE, NULL, + GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); break; default: @@ -104,13 +110,13 @@ case OF_READ: // read only handle = CreateFileA(FileName, - GENERIC_READ, FILE_SHARE_READ, NULL, + GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); break; case OF_WRITE: // write handle = CreateFileA(FileName, - GENERIC_WRITE, FILE_SHARE_WRITE, NULL, + GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); break; default: Modified: trunk/teraterm/teraterm/filesys_log.cpp =================================================================== --- trunk/teraterm/teraterm/filesys_log.cpp 2021-01-16 05:37:28 UTC (rev 9133) +++ trunk/teraterm/teraterm/filesys_log.cpp 2021-01-22 15:00:52 UTC (rev 9134) @@ -679,6 +679,8 @@ static void OpenLogFile(PFileVar fv) { + // LogLockExclusive \x82\xAA\x97L\x8C\xF8\x82ȏꍇ\x82ɂ܂\xC1\x82\xBD\x82\xAD\x8B\xA4\x97L\x82\xB5\x82Ȃ\xA2\x82ƁA + // \x8F\x91\x82\xAB\x8D\x9E\x82ݒ\x86\x82̃\x8D\x83O\x83t\x83@\x83C\x83\x8B\x82𑼂̃G\x83f\x83B\x83^\x82ŊJ\x82\xAF\x82Ȃ\xA2\x82\xBD\x82\xDF int dwShareMode = FILE_SHARE_READ; if (!ts.LogLockExclusive) { dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; Modified: trunk/teraterm/ttpfile/filesys_win32.cpp =================================================================== --- trunk/teraterm/ttpfile/filesys_win32.cpp 2021-01-16 05:37:28 UTC (rev 9133) +++ trunk/teraterm/ttpfile/filesys_win32.cpp 2021-01-22 15:00:52 UTC (rev 9134) @@ -77,7 +77,7 @@ TFileIOWin32 *data = (TFileIOWin32 *)fv->data; wc filenameW = GetFilenameW(data, filename); HANDLE hFile = _CreateFileW(filenameW, - GENERIC_WRITE, FILE_SHARE_WRITE, NULL, + GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { data->FileHandle = INVALID_HANDLE_VALUE; Modified: trunk/teraterm/ttpmacro/ttl.cpp =================================================================== --- trunk/teraterm/ttpmacro/ttl.cpp 2021-01-16 05:37:28 UTC (rev 9133) +++ trunk/teraterm/ttpmacro/ttl.cpp 2021-01-22 15:00:52 UTC (rev 9134) @@ -1207,7 +1207,7 @@ wc FName1W = wc::fromUtf8(FName1); HANDLE FH1 = _CreateFileW(FName1W, - GENERIC_WRITE, FILE_SHARE_WRITE, NULL, + GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (FH1 == INVALID_HANDLE_VALUE) { SetResult(3); @@ -1315,8 +1315,10 @@ return Err; } wc FNameW = wc::fromUtf8(FName); + // TTL \x82̃t\x83@\x83C\x83\x8B\x83n\x83\x93\x83h\x83\x8B\x82\xCD filelock \x82Ń\x8D\x83b\x83N\x82\xB7\x82\xE9\x82̂ŁA + // dwShareMode \x82ł̋\xA4\x97L\x83\x82\x81[\x83h\x82\xCD Read/Write \x82Ƃ\xE0\x97L\x8C\xF8\x82ɂ\xB7\x82\xE9\x81B FH = _CreateFileW(FNameW, - GENERIC_WRITE|GENERIC_READ, FILE_SHARE_WRITE, NULL, + GENERIC_WRITE|GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (FH == INVALID_HANDLE_VALUE) { SetResult(2); @@ -1417,10 +1419,12 @@ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); } else { - // \x83t\x83@\x83C\x83\x8B\x82\xF0\x83I\x81[\x83v\x83\x93\x82\xB7\x82\xE9\x81A - // \x91\xB6\x8D݂\xB5\x82Ȃ\xA2\x8Fꍇ\x82͍쐬\x82\xB5\x82\xBD\x8C\xE3\x83I\x81[\x83v\x83\x93\x82\xB7\x82\xE9 + // \x83t\x83@\x83C\x83\x8B\x82\xF0\x83I\x81[\x83v\x83\x93\x82\xB7\x82\xE9\x81B + // \x91\xB6\x8D݂\xB5\x82Ȃ\xA2\x8Fꍇ\x82͍쐬\x82\xB5\x82\xBD\x8C\xE3\x83I\x81[\x83v\x83\x93\x82\xB7\x82\xE9\x81B + // TTL \x82̃t\x83@\x83C\x83\x8B\x83n\x83\x93\x83h\x83\x8B\x82\xCD filelock \x82Ń\x8D\x83b\x83N\x82\xB7\x82\xE9\x82̂ŁA + // dwShareMode \x82ł̋\xA4\x97L\x83\x82\x81[\x83h\x82\xCD Read/Write \x82Ƃ\xE0\x97L\x8C\xF8\x82ɂ\xB7\x82\xE9\x81B FH = _CreateFileW(FNameW, - GENERIC_WRITE|GENERIC_READ, FILE_SHARE_WRITE, NULL, + GENERIC_WRITE|GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); } if (FH == INVALID_HANDLE_VALUE) {