Huw Davies : ole32: In simple mode, CreateStream with the STGM_CREATE flag should fail.

Alexandre Julliard julliard at winehq.org
Tue Jun 2 08:44:30 CDT 2009


Module: wine
Branch: master
Commit: cc8c36c44c7b761eaa4bf3e1c461999f12e5a48b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=cc8c36c44c7b761eaa4bf3e1c461999f12e5a48b

Author: Huw Davies <huw at codeweavers.com>
Date:   Mon Jun  1 11:06:10 2009 +0100

ole32: In simple mode, CreateStream with the STGM_CREATE flag should fail.

---

 dlls/ole32/storage32.c       |    3 +++
 dlls/ole32/tests/storage32.c |   34 ++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 670d751..212c1ff 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -992,6 +992,9 @@ static HRESULT WINAPI StorageBaseImpl_CreateStream(
       return STG_E_ACCESSDENIED;
   }
 
+  if(This->ancestorStorage->base.openFlags & STGM_SIMPLE)
+    if(grfMode & STGM_CREATE) return STG_E_INVALIDFLAG;
+
   /*
    * Initialize the out parameter
    */
diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c
index 55f7145..b426d94 100644
--- a/dlls/ole32/tests/storage32.c
+++ b/dlls/ole32/tests/storage32.c
@@ -1343,6 +1343,39 @@ void test_readonly(void)
     DeleteFileA("winetest");
 }
 
+static void test_simple(void)
+{
+    /* Tests for STGM_SIMPLE mode */
+
+    static const WCHAR szPrefix[] = { 's','t','g',0 };
+    static const WCHAR szDot[] = { '.',0 };
+    WCHAR filename[MAX_PATH];
+    IStorage *stg;
+    HRESULT r;
+    IStream *stm;
+    static const WCHAR stmname[] = { 'C','O','N','T','E','N','T','S',0 };
+
+    if(!GetTempFileNameW(szDot, szPrefix, 0, filename))
+        return;
+
+    DeleteFileW(filename);
+
+    r = StgCreateDocfile( filename, STGM_SIMPLE | STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_READWRITE, 0, &stg);
+    ok(r == S_OK, "got %08x\n", r);
+
+    r = IStorage_CreateStream(stg, stmname, STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_READWRITE, 0, 0, &stm);
+    ok(r == STG_E_INVALIDFLAG, "got %08x\n", r);
+    r = IStorage_CreateStream(stg, stmname, STGM_SHARE_EXCLUSIVE | STGM_READWRITE, 0, 0, &stm);
+    ok(r == S_OK, "got %08x\n", r);
+
+    IStream_Release(stm);
+
+    IStorage_Commit(stg, STGC_DEFAULT);
+    IStorage_Release(stg);
+
+    DeleteFileW(filename);
+}
+
 START_TEST(storage32)
 {
     test_hglobal_storage_stat();
@@ -1357,4 +1390,5 @@ START_TEST(storage32)
     test_access();
     test_writeclassstg();
     test_readonly();
+    test_simple();
 }




More information about the wine-cvs mailing list