[PATCH 0/2] MR8982: ole32: Fix the return value for StgOpenStorageOnILockBytes().
The attached files below are respectively the source code files for the test demo on Windows, the compiled executable program, and the test demo's running results on Windows. [test-stg.c](/uploads/d6729704bcf9c8d62ac7ced450f81d5e/test-stg.c) [Project1.exe](/uploads/7f291e05bc31bf726ae8050568e7ebc7/Project1.exe)  Signed-off-by: chenjiangyi <chenjiangyi(a)uniontech.com> -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8982
From: chenjiangyi <chenjiangyi(a)uniontech.com> Signed-off-by: chenjiangyi <chenjiangyi(a)uniontech.com> --- dlls/ole32/tests/storage32.c | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c index 0b75affdf8a..e40d32da394 100644 --- a/dlls/ole32/tests/storage32.c +++ b/dlls/ole32/tests/storage32.c @@ -3814,6 +3814,8 @@ static void test_custom_lockbytes(void) HRESULT hr; IStorage* stg; IStream* stm; + BYTE invalid_data[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A }; + ULARGE_INTEGER offset = {0}; CreateTestLockBytes(&lockbytes); @@ -3870,6 +3872,52 @@ static void test_custom_lockbytes(void) ok(hr==STG_E_INVALIDFUNCTION, "StgCreateDocfileOnILockBytes failed %lx\n", hr); DeleteTestLockBytes(lockbytes); + + /*test empty lockbytes*/ + CreateTestLockBytes(&lockbytes); + + hr = StgOpenStorageOnILockBytes(&lockbytes->ILockBytes_iface, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, NULL, 0, &stg); + todo_wine ok(hr == STG_E_FILEALREADYEXISTS, "StgOpenStorageOnILockBytes on empty lockbytes failed: %lx\n", hr); + + if (stg) + IStorage_Release(stg); + DeleteTestLockBytes(lockbytes); + + /*test empty lockbytes with different mode*/ + CreateTestLockBytes(&lockbytes); + + hr = StgOpenStorageOnILockBytes(&lockbytes->ILockBytes_iface, NULL, STGM_READWRITE | STGM_SHARE_DENY_WRITE | STGM_TRANSACTED, NULL, 0, &stg); + todo_wine ok(hr == STG_E_FILEALREADYEXISTS, "StgOpenStorageOnILockBytes on empty lockbytes with different mode failed: %lx\n", hr); + + if (stg) + IStorage_Release(stg); + DeleteTestLockBytes(lockbytes); + + /*test invalid lockbytes*/ + CreateTestLockBytes(&lockbytes); + + hr = ILockBytes_WriteAt(&lockbytes->ILockBytes_iface, offset, invalid_data, sizeof(invalid_data), NULL); + ok(hr == S_OK, "ILockBytes_WriteAt failed: %lx\n", hr); + + hr = StgOpenStorageOnILockBytes(&lockbytes->ILockBytes_iface, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, NULL, 0, &stg); + todo_wine ok(hr == STG_E_FILEALREADYEXISTS, "StgOpenStorageOnILockBytes on invalid lockbytes failed: %lx\n", hr); + + if (stg) + IStorage_Release(stg); + DeleteTestLockBytes(lockbytes); + + /*test invalid lockbytes with different mode*/ + CreateTestLockBytes(&lockbytes); + + hr = ILockBytes_WriteAt(&lockbytes->ILockBytes_iface, offset, invalid_data, sizeof(invalid_data), NULL); + ok(hr == S_OK, "ILockBytes_WriteAt failed: %lx\n", hr); + + hr = StgOpenStorageOnILockBytes(&lockbytes->ILockBytes_iface, NULL, STGM_READWRITE | STGM_SHARE_DENY_WRITE | STGM_TRANSACTED, NULL, 0, &stg); + todo_wine ok(hr == STG_E_FILEALREADYEXISTS, "StgOpenStorageOnILockBytes on invalid lockbytes with different mode failed: %lx\n", hr); + + if (stg) + IStorage_Release(stg); + DeleteTestLockBytes(lockbytes); } START_TEST(storage32) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8982
From: chenjiangyi <chenjiangyi(a)uniontech.com> Signed-off-by: chenjiangyi <chenjiangyi(a)uniontech.com> --- dlls/ole32/storage32.c | 2 +- dlls/ole32/tests/storage32.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index 72dfbe85bd8..d3f4760cfe1 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -2895,7 +2895,7 @@ static HRESULT StorageImpl_LoadFileHeader( offset.LowPart = 0; hr = StorageImpl_ReadAt(This, offset, headerBigBlock, HEADER_SIZE, &bytes_read); if (SUCCEEDED(hr) && bytes_read != HEADER_SIZE) - hr = STG_E_FILENOTFOUND; + hr = STG_E_FILEALREADYEXISTS; /* * Extract the information from the header. diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c index e40d32da394..1780203fe12 100644 --- a/dlls/ole32/tests/storage32.c +++ b/dlls/ole32/tests/storage32.c @@ -3877,7 +3877,7 @@ static void test_custom_lockbytes(void) CreateTestLockBytes(&lockbytes); hr = StgOpenStorageOnILockBytes(&lockbytes->ILockBytes_iface, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, NULL, 0, &stg); - todo_wine ok(hr == STG_E_FILEALREADYEXISTS, "StgOpenStorageOnILockBytes on empty lockbytes failed: %lx\n", hr); + ok(hr == STG_E_FILEALREADYEXISTS, "StgOpenStorageOnILockBytes on empty lockbytes failed: %lx\n", hr); if (stg) IStorage_Release(stg); @@ -3887,7 +3887,7 @@ static void test_custom_lockbytes(void) CreateTestLockBytes(&lockbytes); hr = StgOpenStorageOnILockBytes(&lockbytes->ILockBytes_iface, NULL, STGM_READWRITE | STGM_SHARE_DENY_WRITE | STGM_TRANSACTED, NULL, 0, &stg); - todo_wine ok(hr == STG_E_FILEALREADYEXISTS, "StgOpenStorageOnILockBytes on empty lockbytes with different mode failed: %lx\n", hr); + ok(hr == STG_E_FILEALREADYEXISTS, "StgOpenStorageOnILockBytes on empty lockbytes with different mode failed: %lx\n", hr); if (stg) IStorage_Release(stg); @@ -3900,7 +3900,7 @@ static void test_custom_lockbytes(void) ok(hr == S_OK, "ILockBytes_WriteAt failed: %lx\n", hr); hr = StgOpenStorageOnILockBytes(&lockbytes->ILockBytes_iface, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, NULL, 0, &stg); - todo_wine ok(hr == STG_E_FILEALREADYEXISTS, "StgOpenStorageOnILockBytes on invalid lockbytes failed: %lx\n", hr); + ok(hr == STG_E_FILEALREADYEXISTS, "StgOpenStorageOnILockBytes on invalid lockbytes failed: %lx\n", hr); if (stg) IStorage_Release(stg); @@ -3913,7 +3913,7 @@ static void test_custom_lockbytes(void) ok(hr == S_OK, "ILockBytes_WriteAt failed: %lx\n", hr); hr = StgOpenStorageOnILockBytes(&lockbytes->ILockBytes_iface, NULL, STGM_READWRITE | STGM_SHARE_DENY_WRITE | STGM_TRANSACTED, NULL, 0, &stg); - todo_wine ok(hr == STG_E_FILEALREADYEXISTS, "StgOpenStorageOnILockBytes on invalid lockbytes with different mode failed: %lx\n", hr); + ok(hr == STG_E_FILEALREADYEXISTS, "StgOpenStorageOnILockBytes on invalid lockbytes with different mode failed: %lx\n", hr); if (stg) IStorage_Release(stg); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8982
This merge request was approved by Esme Povirk. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8982
participants (3)
-
chenjiangyi -
Esme Povirk (@madewokherd) -
JiangYi Chen (@meshine)