diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index 1d64ab0ff4d..249d4d2cd9c 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -7604,7 +7604,16 @@ HRESULT WINAPI StgOpenStorage( /* * Validate the sharing mode */ - if (!(grfMode & (STGM_TRANSACTED|STGM_PRIORITY))) + if (grfMode & STGM_DIRECT_SWMR) + { + if ((STGM_SHARE_MODE(grfMode) != STGM_SHARE_DENY_WRITE) && + (STGM_SHARE_MODE(grfMode) != STGM_SHARE_DENY_NONE)) + { + hr = STG_E_INVALIDFLAG; + goto end; + } + } + else if (!(grfMode & (STGM_TRANSACTED|STGM_PRIORITY))) switch(STGM_SHARE_MODE(grfMode)) { case STGM_SHARE_EXCLUSIVE: diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c index b9d41cdbf84..d6640c23b2f 100644 --- a/dlls/ole32/tests/storage32.c +++ b/dlls/ole32/tests/storage32.c @@ -1889,7 +1889,7 @@ static void test_access(void) STGM_SHARE_EXCLUSIVE | STGM_DIRECT, 0, &stg); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); - test_file_access("winetest", create); + test_file_access(fileA, create); hr = IStorage_Commit(stg, STGC_DEFAULT); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); @@ -1955,6 +1955,21 @@ static void test_access(void) test_file_access(fileA, create_close); DeleteFileA(fileA); + + /* STGM_DIRECT_SWMR | STGM_READ | STGM_SHARE_DENY_NONE - reader mode for direct SWMR mode */ + hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE | STGM_SHARE_DENY_WRITE | STGM_TRANSACTED, 0, &stg); + ok(hr == S_OK, "got %08x\n", hr); + IStorage_Release(stg); + + hr = StgOpenStorage(fileW, NULL, STGM_DIRECT_SWMR | STGM_READ | STGM_SHARE_DENY_NONE, NULL, 0, &stg); + ok(hr == S_OK, "got %08x\n", hr); + + test_file_access(fileA, create); + + IStorage_Release(stg); + test_file_access(fileA, create_close); + + DeleteFileA(fileA); } static void test_readonly(void)