winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
January 2009
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
3 participants
1348 discussions
Start a n
N
ew thread
Andrey Turkin : ole32: Do not crash in WriteClassStg if passed NULL pointer .
by Alexandre Julliard
15 Jan '09
15 Jan '09
Module: wine Branch: master Commit: d20ab01ed27e48e44fee8f2cb78a7804e78a26d4 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=d20ab01ed27e48e44fee8f2cb…
Author: Andrey Turkin <andrey.turkin(a)gmail.com> Date: Wed Jan 14 22:31:06 2009 +0300 ole32: Do not crash in WriteClassStg if passed NULL pointer. --- dlls/ole32/storage32.c | 3 ++ dlls/ole32/tests/storage32.c | 51 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 0 deletions(-) diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index fe84804..48a655f 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -6281,6 +6281,9 @@ HRESULT WINAPI WriteClassStg(IStorage* pStg, REFCLSID rclsid) if(!pStg) return E_INVALIDARG; + if(!rclsid) + return STG_E_INVALIDPOINTER; + hRes = IStorage_SetClass(pStg, rclsid); return hRes; diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c index f65af73..da2d0aa 100644 --- a/dlls/ole32/tests/storage32.c +++ b/dlls/ole32/tests/storage32.c @@ -803,6 +803,56 @@ static void test_storage_refcount(void) DeleteFileW(filename); } +static void test_writeclassstg(void) +{ + static const WCHAR szPrefix[] = { 's','t','g',0 }; + static const WCHAR szDot[] = { '.',0 }; + WCHAR filename[MAX_PATH]; + IStorage *stg = NULL; + HRESULT r; + CLSID temp_cls; + + if(!GetTempFileNameW(szDot, szPrefix, 0, filename)) + return; + + DeleteFileW(filename); + + /* create the file */ + r = StgCreateDocfile( filename, STGM_CREATE | STGM_SHARE_EXCLUSIVE | + STGM_READWRITE, 0, &stg); + ok(r==S_OK, "StgCreateDocfile failed\n"); + + r = ReadClassStg( NULL, NULL ); + ok(r == E_INVALIDARG, "ReadClassStg should return E_INVALIDARG instead of 0x%08X\n", r); + + r = ReadClassStg( stg, NULL ); + ok(r == E_INVALIDARG, "ReadClassStg should return E_INVALIDARG instead of 0x%08X\n", r); + + temp_cls.Data1 = 0xdeadbeef; + r = ReadClassStg( stg, &temp_cls ); + ok(r == S_OK, "ReadClassStg failed with 0x%08X\n", r); + + ok(IsEqualCLSID(&temp_cls, &CLSID_NULL), "ReadClassStg returned wrong clsid\n"); + + r = WriteClassStg( NULL, NULL ); + ok(r == E_INVALIDARG, "WriteClassStg should return E_INVALIDARG instead of 0x%08X\n", r); + + r = WriteClassStg( stg, NULL ); + ok(r == STG_E_INVALIDPOINTER, "WriteClassStg should return STG_E_INVALIDPOINTER instead of 0x%08X\n", r); + + r = WriteClassStg( stg, &test_stg_cls ); + ok( r == S_OK, "WriteClassStg failed with 0x%08X\n", r); + + r = ReadClassStg( stg, &temp_cls ); + ok( r == S_OK, "ReadClassStg failed with 0x%08X\n", r); + ok(IsEqualCLSID(&temp_cls, &test_stg_cls), "ReadClassStg returned wrong clsid\n"); + + r = IStorage_Release( stg ); + ok (r == 0, "storage not released\n"); + + DeleteFileW(filename); +} + static void test_streamenum(void) { static const WCHAR szPrefix[] = { 's','t','g',0 }; @@ -1229,4 +1279,5 @@ START_TEST(storage32) test_transact(); test_ReadClassStm(); test_access(); + test_writeclassstg(); }
1
0
0
0
Andrey Turkin : ole32: Add IContextCallback interface to context object.
by Alexandre Julliard
15 Jan '09
15 Jan '09
Module: wine Branch: master Commit: 37d27c38ceffc8aa67eb7ac561ff83373bf7c194 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=37d27c38ceffc8aa67eb7ac56…
Author: Andrey Turkin <andrey.turkin(a)gmail.com> Date: Wed Jan 14 20:28:09 2009 +0300 ole32: Add IContextCallback interface to context object. --- dlls/ole32/compobj.c | 112 ++++++++++++++++++++++++++++++++++++-------- dlls/ole32/tests/compobj.c | 4 -- 2 files changed, 92 insertions(+), 24 deletions(-) diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index d778478..9501473 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -55,6 +55,7 @@ #include "objbase.h" #include "ole2.h" #include "ole2ver.h" +#include "ctxtcall.h" #include "compobj_private.h" @@ -3703,19 +3704,37 @@ HRESULT WINAPI CoRegisterChannelHook(REFGUID guidExtension, IChannelHook *pChann typedef struct Context { const IComThreadingInfoVtbl *lpVtbl; + const IContextCallbackVtbl *lpCallbackVtbl; LONG refs; APTTYPE apttype; } Context; -static HRESULT WINAPI Context_QueryInterface(IComThreadingInfo *iface, REFIID riid, LPVOID *ppv) +static inline Context *impl_from_IComThreadingInfo( IComThreadingInfo *iface ) +{ + return (Context *)((char*)iface - FIELD_OFFSET(Context, lpVtbl)); +} + +static inline Context *impl_from_IContextCallback( IContextCallback *iface ) +{ + return (Context *)((char*)iface - FIELD_OFFSET(Context, lpCallbackVtbl)); +} + +static HRESULT Context_QueryInterface(Context *iface, REFIID riid, LPVOID *ppv) { *ppv = NULL; if (IsEqualIID(riid, &IID_IComThreadingInfo) || IsEqualIID(riid, &IID_IUnknown)) { - *ppv = iface; - IUnknown_AddRef(iface); + *ppv = &iface->lpVtbl; + } else if (IsEqualIID(riid, &IID_IContextCallback)) + { + *ppv = &iface->lpCallbackVtbl; + } + + if (*ppv) + { + IUnknown_AddRef((IUnknown*)*ppv); return S_OK; } @@ -3723,24 +3742,40 @@ static HRESULT WINAPI Context_QueryInterface(IComThreadingInfo *iface, REFIID ri return E_NOINTERFACE; } -static ULONG WINAPI Context_AddRef(IComThreadingInfo *iface) +static ULONG Context_AddRef(Context *This) { - Context *This = (Context *)iface; return InterlockedIncrement(&This->refs); } -static ULONG WINAPI Context_Release(IComThreadingInfo *iface) +static ULONG Context_Release(Context *This) { - Context *This = (Context *)iface; ULONG refs = InterlockedDecrement(&This->refs); if (!refs) HeapFree(GetProcessHeap(), 0, This); return refs; } -static HRESULT WINAPI Context_GetCurrentApartmentType(IComThreadingInfo *iface, APTTYPE *apttype) +static HRESULT WINAPI Context_CTI_QueryInterface(IComThreadingInfo *iface, REFIID riid, LPVOID *ppv) +{ + Context *This = impl_from_IComThreadingInfo(iface); + return Context_QueryInterface(This, riid, ppv); +} + +static ULONG WINAPI Context_CTI_AddRef(IComThreadingInfo *iface) +{ + Context *This = impl_from_IComThreadingInfo(iface); + return Context_AddRef(This); +} + +static ULONG WINAPI Context_CTI_Release(IComThreadingInfo *iface) +{ + Context *This = impl_from_IComThreadingInfo(iface); + return Context_Release(This); +} + +static HRESULT WINAPI Context_CTI_GetCurrentApartmentType(IComThreadingInfo *iface, APTTYPE *apttype) { - Context *This = (Context *)iface; + Context *This = impl_from_IComThreadingInfo(iface); TRACE("(%p)\n", apttype); @@ -3748,9 +3783,9 @@ static HRESULT WINAPI Context_GetCurrentApartmentType(IComThreadingInfo *iface, return S_OK; } -static HRESULT WINAPI Context_GetCurrentThreadType(IComThreadingInfo *iface, THDTYPE *thdtype) +static HRESULT WINAPI Context_CTI_GetCurrentThreadType(IComThreadingInfo *iface, THDTYPE *thdtype) { - Context *This = (Context *)iface; + Context *This = impl_from_IComThreadingInfo(iface); TRACE("(%p)\n", thdtype); @@ -3767,13 +3802,13 @@ static HRESULT WINAPI Context_GetCurrentThreadType(IComThreadingInfo *iface, THD return S_OK; } -static HRESULT WINAPI Context_GetCurrentLogicalThreadId(IComThreadingInfo *iface, GUID *logical_thread_id) +static HRESULT WINAPI Context_CTI_GetCurrentLogicalThreadId(IComThreadingInfo *iface, GUID *logical_thread_id) { FIXME("(%p): stub\n", logical_thread_id); return E_NOTIMPL; } -static HRESULT WINAPI Context_SetCurrentLogicalThreadId(IComThreadingInfo *iface, REFGUID logical_thread_id) +static HRESULT WINAPI Context_CTI_SetCurrentLogicalThreadId(IComThreadingInfo *iface, REFGUID logical_thread_id) { FIXME("(%s): stub\n", debugstr_guid(logical_thread_id)); return E_NOTIMPL; @@ -3781,15 +3816,51 @@ static HRESULT WINAPI Context_SetCurrentLogicalThreadId(IComThreadingInfo *iface static const IComThreadingInfoVtbl Context_Threading_Vtbl = { - Context_QueryInterface, - Context_AddRef, - Context_Release, - Context_GetCurrentApartmentType, - Context_GetCurrentThreadType, - Context_GetCurrentLogicalThreadId, - Context_SetCurrentLogicalThreadId + Context_CTI_QueryInterface, + Context_CTI_AddRef, + Context_CTI_Release, + Context_CTI_GetCurrentApartmentType, + Context_CTI_GetCurrentThreadType, + Context_CTI_GetCurrentLogicalThreadId, + Context_CTI_SetCurrentLogicalThreadId }; +static HRESULT WINAPI Context_CC_QueryInterface(IContextCallback *iface, REFIID riid, LPVOID *ppv) +{ + Context *This = impl_from_IContextCallback(iface); + return Context_QueryInterface(This, riid, ppv); +} + +static ULONG WINAPI Context_CC_AddRef(IContextCallback *iface) +{ + Context *This = impl_from_IContextCallback(iface); + return Context_AddRef(This); +} + +static ULONG WINAPI Context_CC_Release(IContextCallback *iface) +{ + Context *This = impl_from_IContextCallback(iface); + return Context_Release(This); +} + +static HRESULT WINAPI Context_CC_ContextCallback(IContextCallback *iface, PFNCONTEXTCALL pCallback, + ComCallData *param, REFIID riid, int method, IUnknown *punk) +{ + Context *This = impl_from_IContextCallback(iface); + + FIXME("(%p/%p)->(%p, %p, %s, %d, %p)\n", This, iface, pCallback, param, debugstr_guid(riid), method, punk); + return E_NOTIMPL; +} + +static const IContextCallbackVtbl Context_Callback_Vtbl = +{ + Context_CC_QueryInterface, + Context_CC_AddRef, + Context_CC_Release, + Context_CC_ContextCallback +}; + + /*********************************************************************** * CoGetObjectContext [OLE32.@] * @@ -3823,6 +3894,7 @@ HRESULT WINAPI CoGetObjectContext(REFIID riid, void **ppv) return E_OUTOFMEMORY; context->lpVtbl = &Context_Threading_Vtbl; + context->lpCallbackVtbl = &Context_Callback_Vtbl; context->refs = 1; if (apt->multi_threaded) context->apttype = APTTYPE_MTA; diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c index d74138f..63891b7 100644 --- a/dlls/ole32/tests/compobj.c +++ b/dlls/ole32/tests/compobj.c @@ -1001,9 +1001,7 @@ static void test_CoGetObjectContext(void) ok(refs == 0, "pComThreadingInfo should have 0 refs instead of %d refs\n", refs); hr = pCoGetObjectContext(&IID_IContextCallback, (void **)&pContextCallback); - todo_wine { ok_ole_success(hr, "CoGetObjectContext(ContextCallback)"); - } if (hr == S_OK) { @@ -1030,9 +1028,7 @@ static void test_CoGetObjectContext(void) ok(refs == 0, "pComThreadingInfo should have 0 refs instead of %d refs\n", refs); hr = pCoGetObjectContext(&IID_IContextCallback, (void **)&pContextCallback); - todo_wine { ok_ole_success(hr, "CoGetObjectContext(ContextCallback)"); - } if (hr == S_OK) {
1
0
0
0
Juan Lang : shell32: Document SHFlushSFCache, and remove an unneeded fixme.
by Alexandre Julliard
15 Jan '09
15 Jan '09
Module: wine Branch: master Commit: ba48d37837206d175b010c0413f0147e045d18d6 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=ba48d37837206d175b010c041…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Wed Jan 14 08:31:04 2009 -0800 shell32: Document SHFlushSFCache, and remove an unneeded fixme. --- dlls/shell32/shellord.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/dlls/shell32/shellord.c b/dlls/shell32/shellord.c index d8a6a0f..5622484 100644 --- a/dlls/shell32/shellord.c +++ b/dlls/shell32/shellord.c @@ -1995,8 +1995,13 @@ BOOL WINAPI LinkWindow_UnregisterClass(void) /************************************************************************* * SHFlushSFCache (SHELL32.526) + * + * Notifies the shell that a user-specified special folder location has changed. + * + * NOTES + * In Wine, the shell folder registry values are not cached, so this function + * has no effect. */ void WINAPI SHFlushSFCache(void) { - FIXME("()\n"); }
1
0
0
0
Hans Leidekker : wininet: Send a content length header for all verbs other than GET.
by Alexandre Julliard
15 Jan '09
15 Jan '09
Module: wine Branch: master Commit: 1c07d94ddcb2cd46a06a14dcf553bfaf0454fe1f URL:
http://source.winehq.org/git/wine.git/?a=commit;h=1c07d94ddcb2cd46a06a14dcf…
Author: Hans Leidekker <hans(a)codeweavers.com> Date: Wed Jan 14 16:20:11 2009 +0100 wininet: Send a content length header for all verbs other than GET. --- dlls/wininet/http.c | 2 +- dlls/wininet/tests/http.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index cdcf8e1..a5352e4 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -3236,7 +3236,7 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders, if (!lpwhr->lpszVerb) lpwhr->lpszVerb = WININET_strdupW(szGET); - if (dwContentLength || !strcmpW(lpwhr->lpszVerb, szPost)) + if (dwContentLength || strcmpW(lpwhr->lpszVerb, szGET)) { sprintfW(contentLengthStr, szContentLength, dwContentLength); HTTP_HttpAddRequestHeadersW(lpwhr, contentLengthStr, -1L, HTTP_ADDREQ_FLAG_ADD_IF_NEW); diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index 34f4708..19eb982 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -1408,7 +1408,9 @@ static DWORD CALLBACK server_thread(LPVOID param) else send(c, notokmsg, sizeof notokmsg-1, 0); } - if (strstr(buffer, "POST /test5")) + if (strstr(buffer, "POST /test5") || + strstr(buffer, "RPC_IN_DATA /test5") || + strstr(buffer, "RPC_OUT_DATA /test5")) { if (strstr(buffer, "Content-Length: 0")) { @@ -2013,6 +2015,8 @@ static void test_http_connection(void) test_proxy_direct(si.port); test_header_handling_order(si.port); test_basic_request(si.port, "POST", "/test5"); + test_basic_request(si.port, "RPC_IN_DATA", "/test5"); + test_basic_request(si.port, "RPC_OUT_DATA", "/test5"); test_basic_request(si.port, "GET", "/test6"); test_connection_header(si.port); test_http1_1(si.port);
1
0
0
0
Alexandre Julliard : kernel32/tests: Add test cases for reading/ writing process memory from an invalid buffer address.
by Alexandre Julliard
15 Jan '09
15 Jan '09
Module: wine Branch: master Commit: 31fd0663936d3b6228a45f326f9221fc1fe9054f URL:
http://source.winehq.org/git/wine.git/?a=commit;h=31fd0663936d3b6228a45f326…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Jan 14 20:36:42 2009 +0100 kernel32/tests: Add test cases for reading/writing process memory from an invalid buffer address. --- dlls/kernel32/tests/virtual.c | 37 +++++++++++++++++++++++++++++++++---- 1 files changed, 33 insertions(+), 4 deletions(-) diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index 6990543..ae812cd 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -84,8 +84,8 @@ static void test_VirtualAllocEx(void) return; } - src = HeapAlloc( GetProcessHeap(), 0, alloc_size ); - dst = HeapAlloc( GetProcessHeap(), 0, alloc_size ); + src = VirtualAlloc( NULL, alloc_size, MEM_COMMIT, PAGE_READWRITE ); + dst = VirtualAlloc( NULL, alloc_size, MEM_COMMIT, PAGE_READWRITE ); for (i = 0; i < alloc_size; i++) src[i] = i & 0xff; @@ -96,11 +96,40 @@ static void test_VirtualAllocEx(void) b = ReadProcessMemory(hProcess, addr1, dst, alloc_size, &bytes_read); ok(b && (bytes_read == alloc_size), "%lu bytes read\n", bytes_read); ok(!memcmp(src, dst, alloc_size), "Data from remote process differs\n"); + + /* test invalid source buffers */ + + b = VirtualProtect( src + 0x2000, 0x2000, PAGE_NOACCESS, &old_prot ); + ok( b, "VirtualProtect failed error %u\n", GetLastError() ); + b = WriteProcessMemory(hProcess, addr1, src, alloc_size, &bytes_written); + ok( !b, "WriteProcessMemory succeeded\n" ); + ok( GetLastError() == ERROR_NOACCESS || + GetLastError() == ERROR_PARTIAL_COPY, /* vista */ + "wrong error %u\n", GetLastError() ); + ok( bytes_written == 0, "%lu bytes written\n", bytes_written ); + b = ReadProcessMemory(hProcess, addr1, src, alloc_size, &bytes_read); + ok( !b, "ReadProcessMemory succeeded\n" ); + ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() ); + ok( bytes_read == 0, "%lu bytes written\n", bytes_read ); + + b = VirtualProtect( src, 0x2000, PAGE_NOACCESS, &old_prot ); + ok( b, "VirtualProtect failed error %u\n", GetLastError() ); + b = WriteProcessMemory(hProcess, addr1, src, alloc_size, &bytes_written); + ok( !b, "WriteProcessMemory succeeded\n" ); + ok( GetLastError() == ERROR_NOACCESS || + GetLastError() == ERROR_PARTIAL_COPY, /* vista */ + "wrong error %u\n", GetLastError() ); + ok( bytes_written == 0, "%lu bytes written\n", bytes_written ); + b = ReadProcessMemory(hProcess, addr1, src, alloc_size, &bytes_read); + ok( !b, "ReadProcessMemory succeeded\n" ); + ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() ); + ok( bytes_read == 0, "%lu bytes written\n", bytes_read ); + b = pVirtualFreeEx(hProcess, addr1, 0, MEM_RELEASE); ok(b != 0, "VirtualFreeEx, error %u\n", GetLastError()); - HeapFree( GetProcessHeap(), 0, src ); - HeapFree( GetProcessHeap(), 0, dst ); + VirtualFree( src, 0, MEM_FREE ); + VirtualFree( dst, 0, MEM_FREE ); /* * The following tests parallel those in test_VirtualAlloc()
1
0
0
0
Alexandre Julliard : ntdll: Check buffer for access in NtRead/ WriteVirtualMemory.
by Alexandre Julliard
15 Jan '09
15 Jan '09
Module: wine Branch: master Commit: 858a7efdd40e21895bd6b0e6f2954563fc729039 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=858a7efdd40e21895bd6b0e6f…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Jan 14 20:36:27 2009 +0100 ntdll: Check buffer for access in NtRead/WriteVirtualMemory. This also triggers page faults needed for DIB section access and write watches. --- dlls/ntdll/virtual.c | 40 ++++++++++++++++++++++++++++------------ 1 files changed, 28 insertions(+), 12 deletions(-) diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index 74e72fd..16e1e50 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -2615,14 +2615,22 @@ NTSTATUS WINAPI NtReadVirtualMemory( HANDLE process, const void *addr, void *buf { NTSTATUS status; - SERVER_START_REQ( read_process_memory ) + if (virtual_check_buffer_for_write( buffer, size )) { - req->handle = wine_server_obj_handle( process ); - req->addr = wine_server_client_ptr( addr ); - wine_server_set_reply( req, buffer, size ); - if ((status = wine_server_call( req ))) size = 0; + SERVER_START_REQ( read_process_memory ) + { + req->handle = wine_server_obj_handle( process ); + req->addr = wine_server_client_ptr( addr ); + wine_server_set_reply( req, buffer, size ); + if ((status = wine_server_call( req ))) size = 0; + } + SERVER_END_REQ; + } + else + { + status = STATUS_ACCESS_VIOLATION; + size = 0; } - SERVER_END_REQ; if (bytes_read) *bytes_read = size; return status; } @@ -2637,14 +2645,22 @@ NTSTATUS WINAPI NtWriteVirtualMemory( HANDLE process, void *addr, const void *bu { NTSTATUS status; - SERVER_START_REQ( write_process_memory ) + if (virtual_check_buffer_for_read( buffer, size )) { - req->handle = wine_server_obj_handle( process ); - req->addr = wine_server_client_ptr( addr ); - wine_server_add_data( req, buffer, size ); - if ((status = wine_server_call( req ))) size = 0; + SERVER_START_REQ( write_process_memory ) + { + req->handle = wine_server_obj_handle( process ); + req->addr = wine_server_client_ptr( addr ); + wine_server_add_data( req, buffer, size ); + if ((status = wine_server_call( req ))) size = 0; + } + SERVER_END_REQ; + } + else + { + status = STATUS_PARTIAL_COPY; + size = 0; } - SERVER_END_REQ; if (bytes_written) *bytes_written = size; return status; }
1
0
0
0
Alexandre Julliard : kernel32: Remove the DIB section hack in WriteFile now that NtWriteFile takes care of it .
by Alexandre Julliard
15 Jan '09
15 Jan '09
Module: wine Branch: master Commit: e016d2ec5e38a4128840d5444225a2ecfaead5de URL:
http://source.winehq.org/git/wine.git/?a=commit;h=e016d2ec5e38a4128840d5444…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Jan 14 20:20:14 2009 +0100 kernel32: Remove the DIB section hack in WriteFile now that NtWriteFile takes care of it. --- dlls/kernel32/file.c | 10 ---------- 1 files changed, 0 insertions(+), 10 deletions(-) diff --git a/dlls/kernel32/file.c b/dlls/kernel32/file.c index 608a539..92dbedf 100644 --- a/dlls/kernel32/file.c +++ b/dlls/kernel32/file.c @@ -560,16 +560,6 @@ BOOL WINAPI WriteFile( HANDLE hFile, LPCVOID buffer, DWORD bytesToWrite, status = NtWriteFile(hFile, hEvent, NULL, cvalue, piosb, buffer, bytesToWrite, poffset, NULL); - /* FIXME: NtWriteFile does not always cause page faults, generate them now */ - if (status == STATUS_INVALID_USER_BUFFER && !IsBadReadPtr( buffer, bytesToWrite )) - { - status = NtWriteFile(hFile, hEvent, NULL, cvalue, piosb, - buffer, bytesToWrite, poffset, NULL); - if (status != STATUS_INVALID_USER_BUFFER) - FIXME("Could not access memory (%p,%d) at first, now OK. Protected by DIBSection code?\n", - buffer, bytesToWrite); - } - if (status == STATUS_PENDING && !overlapped) { WaitForSingleObject( hFile, INFINITE );
1
0
0
0
Alexandre Julliard : gdi32/tests: Add a test case for calling WriteFile with the DIB section bits as buffer.
by Alexandre Julliard
15 Jan '09
15 Jan '09
Module: wine Branch: master Commit: d2b217e90a3222506605037263fd57222c639543 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=d2b217e90a322250660503726…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Jan 14 20:19:42 2009 +0100 gdi32/tests: Add a test case for calling WriteFile with the DIB section bits as buffer. --- dlls/gdi32/tests/bitmap.c | 58 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-) diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c index 3f8a674..b4dc09e 100644 --- a/dlls/gdi32/tests/bitmap.c +++ b/dlls/gdi32/tests/bitmap.c @@ -396,6 +396,62 @@ static void test_dib_info(HBITMAP hbm, const void *bits, const BITMAPINFOHEADER test_color_todo(c, exp, GetPixel, todo_getp); \ } +static void test_dib_bits_access( HBITMAP hdib, void *bits ) +{ + MEMORY_BASIC_INFORMATION info; + char bmibuf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)]; + DWORD data[256]; + BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf; + HDC hdc = GetDC(0); + char filename[MAX_PATH]; + HANDLE file; + DWORD written; + INT ret; + + ok(VirtualQuery(bits, &info, sizeof(info)) == sizeof(info), + "VirtualQuery failed\n"); + ok(info.BaseAddress == bits, "%p != %p\n", info.BaseAddress, bits); + ok(info.AllocationBase == bits, "%p != %p\n", info.AllocationBase, bits); + ok(info.AllocationProtect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.AllocationProtect); + ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State); + ok(info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.Protect); + ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type); + + memset( pbmi, 0, sizeof(bmibuf) ); + memset( data, 0xcc, sizeof(data) ); + pbmi->bmiHeader.biSize = sizeof(pbmi->bmiHeader); + pbmi->bmiHeader.biHeight = 16; + pbmi->bmiHeader.biWidth = 16; + pbmi->bmiHeader.biBitCount = 32; + pbmi->bmiHeader.biPlanes = 1; + pbmi->bmiHeader.biCompression = BI_RGB; + + ret = SetDIBits( hdc, hdib, 0, 16, data, pbmi, DIB_RGB_COLORS ); + ok( ret == 16, "SetDIBits failed\n" ); + + ok(VirtualQuery(bits, &info, sizeof(info)) == sizeof(info), + "VirtualQuery failed\n"); + ok(info.BaseAddress == bits, "%p != %p\n", info.BaseAddress, bits); + ok(info.AllocationBase == bits, "%p != %p\n", info.AllocationBase, bits); + ok(info.AllocationProtect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.AllocationProtect); + ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State); + ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type); + /* it has been protected now */ + todo_wine ok(info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.Protect); + + /* try writing protected bits to a file */ + + GetTempFileNameA( ".", "dib", 0, filename ); + file = CreateFileA( filename, GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, + CREATE_ALWAYS, 0, 0 ); + ok( file != INVALID_HANDLE_VALUE, "failed to open %s error %u\n", filename, GetLastError() ); + ret = WriteFile( file, bits, 8192, &written, NULL ); + ok( ret, "WriteFile failed error %u\n", GetLastError() ); + if (ret) ok( written == 8192, "only wrote %u bytes\n", written ); + CloseHandle( file ); + DeleteFileA( filename ); +} + static void test_dibsections(void) { HDC hdc, hdcmem, hdcmem2; @@ -455,6 +511,8 @@ static void test_dibsections(void) ok(info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.Protect); ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type); + test_dib_bits_access( hdib, bits ); + test_dib_info(hdib, bits, &pbmi->bmiHeader); DeleteObject(hdib);
1
0
0
0
Alexandre Julliard : kernel32/tests: Add test cases for reading/ writing from an invalid buffer address.
by Alexandre Julliard
15 Jan '09
15 Jan '09
Module: wine Branch: master Commit: 8de57bd541c3aec98ef68ae3e5d8b4d4d431d0b1 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=8de57bd541c3aec98ef68ae3e…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Jan 14 20:18:29 2009 +0100 kernel32/tests: Add test cases for reading/writing from an invalid buffer address. --- dlls/kernel32/tests/file.c | 92 +++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 91 insertions(+), 1 deletions(-) diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c index abbb413..ed893fc 100644 --- a/dlls/kernel32/tests/file.c +++ b/dlls/kernel32/tests/file.c @@ -1673,10 +1673,11 @@ static void test_async_file_errors(void) static void test_read_write(void) { - DWORD bytes, ret; + DWORD bytes, ret, old_prot; HANDLE hFile; char temp_path[MAX_PATH]; char filename[MAX_PATH]; + char *mem; static const char prefix[] = "pfx"; ret = GetTempPathA(MAX_PATH, temp_path); @@ -1726,6 +1727,95 @@ static void test_read_write(void) "ret = %d, error %d\n", ret, GetLastError()); ok(!bytes, "bytes = %d\n", bytes); + /* test passing protected memory as buffer */ + + mem = VirtualAlloc( NULL, 0x4000, MEM_COMMIT, PAGE_READWRITE ); + ok( mem != NULL, "failed to allocate virtual mem error %u\n", GetLastError() ); + + ret = WriteFile( hFile, mem, 0x4000, &bytes, NULL ); + ok( ret, "WriteFile failed error %u\n", GetLastError() ); + ok( bytes == 0x4000, "only wrote %x bytes\n", bytes ); + + ret = VirtualProtect( mem + 0x2000, 0x2000, PAGE_NOACCESS, &old_prot ); + ok( ret, "VirtualProtect failed error %u\n", GetLastError() ); + + ret = WriteFile( hFile, mem, 0x4000, &bytes, NULL ); + ok( !ret, "WriteFile succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_USER_BUFFER || + GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */ + "wrong error %u\n", GetLastError() ); + ok( bytes == 0, "wrote %x bytes\n", bytes ); + + ret = WriteFile( (HANDLE)0xdead, mem, 0x4000, &bytes, NULL ); + ok( !ret, "WriteFile succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_HANDLE || /* handle is checked before buffer on NT */ + GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */ + "wrong error %u\n", GetLastError() ); + ok( bytes == 0, "wrote %x bytes\n", bytes ); + + ret = VirtualProtect( mem, 0x2000, PAGE_NOACCESS, &old_prot ); + ok( ret, "VirtualProtect failed error %u\n", GetLastError() ); + + ret = WriteFile( hFile, mem, 0x4000, &bytes, NULL ); + ok( !ret, "WriteFile succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_USER_BUFFER || + GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */ + "wrong error %u\n", GetLastError() ); + ok( bytes == 0, "wrote %x bytes\n", bytes ); + + SetFilePointer( hFile, 0, NULL, FILE_BEGIN ); + + ret = ReadFile( hFile, mem, 0x4000, &bytes, NULL ); + ok( !ret, "ReadFile succeeded\n" ); + ok( GetLastError() == ERROR_NOACCESS || + GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */ + "wrong error %u\n", GetLastError() ); + ok( bytes == 0, "read %x bytes\n", bytes ); + + ret = VirtualProtect( mem, 0x2000, PAGE_READONLY, &old_prot ); + ok( ret, "VirtualProtect failed error %u\n", GetLastError() ); + + ret = ReadFile( hFile, mem, 0x4000, &bytes, NULL ); + ok( !ret, "ReadFile succeeded\n" ); + ok( GetLastError() == ERROR_NOACCESS || + GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */ + "wrong error %u\n", GetLastError() ); + ok( bytes == 0, "read %x bytes\n", bytes ); + + ret = VirtualProtect( mem, 0x2000, PAGE_READWRITE, &old_prot ); + ok( ret, "VirtualProtect failed error %u\n", GetLastError() ); + + ret = ReadFile( hFile, mem, 0x4000, &bytes, NULL ); + ok( !ret, "ReadFile succeeded\n" ); + ok( GetLastError() == ERROR_NOACCESS || + GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */ + "wrong error %u\n", GetLastError() ); + ok( bytes == 0, "read %x bytes\n", bytes ); + + SetFilePointer( hFile, 0x1234, NULL, FILE_BEGIN ); + SetEndOfFile( hFile ); + SetFilePointer( hFile, 0, NULL, FILE_BEGIN ); + + ret = ReadFile( hFile, mem, 0x4000, &bytes, NULL ); + ok( !ret, "ReadFile succeeded\n" ); + ok( GetLastError() == ERROR_NOACCESS || + GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */ + "wrong error %u\n", GetLastError() ); + ok( bytes == 0, "read %x bytes\n", bytes ); + + ret = ReadFile( hFile, mem, 0x2000, &bytes, NULL ); + ok( ret, "ReadFile failed error %u\n", GetLastError() ); + ok( bytes == 0x1234, "read %x bytes\n", bytes ); + + ret = ReadFile( hFile, NULL, 1, &bytes, NULL ); + ok( !ret, "ReadFile succeeded\n" ); + ok( GetLastError() == ERROR_NOACCESS || + GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */ + "wrong error %u\n", GetLastError() ); + ok( bytes == 0, "read %x bytes\n", bytes ); + + VirtualFree( mem, 0, MEM_FREE ); + ret = CloseHandle(hFile); ok( ret, "CloseHandle: error %d\n", GetLastError()); ret = DeleteFileA(filename);
1
0
0
0
Alexandre Julliard : ntdll: Check buffer for access in NtReadFile before performing I/O.
by Alexandre Julliard
15 Jan '09
15 Jan '09
Module: wine Branch: master Commit: 63bff0937f949379193b6d3b87b03edeaaf77d52 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=63bff0937f949379193b6d3b8…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Jan 14 20:17:52 2009 +0100 ntdll: Check buffer for access in NtReadFile before performing I/O. This also triggers page faults needed for write watches. --- dlls/ntdll/file.c | 15 +++++++++------ dlls/ntdll/ntdll_misc.h | 1 + dlls/ntdll/virtual.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c index 60aec8a..cbb0eac 100644 --- a/dlls/ntdll/file.c +++ b/dlls/ntdll/file.c @@ -568,6 +568,12 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent, &needs_close, &type, &options ); if (status) return status; + if (!virtual_check_buffer_for_write( buffer, length )) + { + status = STATUS_ACCESS_VIOLATION; + goto done; + } + if (type == FD_TYPE_FILE && offset && offset->QuadPart != (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */ ) { /* async I/O doesn't make sense on regular files */ @@ -615,14 +621,11 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent, } else if (type == FD_TYPE_FILE) continue; /* no async I/O on regular files */ } - else + else if (errno != EAGAIN) { if (errno == EINTR) continue; - if (errno != EAGAIN) - { - status = FILE_GetNtStatus(); - goto done; - } + if (!total) status = FILE_GetNtStatus(); + goto done; } if (!(options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT))) diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index 2fcdb1a..306b36d 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -142,6 +142,7 @@ extern void virtual_clear_thread_stack(void); extern BOOL virtual_handle_stack_fault( void *addr ); extern NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err ); extern BOOL virtual_check_buffer_for_read( const void *ptr, SIZE_T size ); +extern BOOL virtual_check_buffer_for_write( void *ptr, SIZE_T size ); extern void VIRTUAL_SetForceExec( BOOL enable ); extern void VIRTUAL_UseLargeAddressSpace(void); extern struct _KUSER_SHARED_DATA *user_shared_data; diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index 33c946f..74e72fd 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -1551,6 +1551,39 @@ BOOL virtual_check_buffer_for_read( const void *ptr, SIZE_T size ) /*********************************************************************** + * virtual_check_buffer_for_write + * + * Check if a memory buffer can be written to, triggering page faults if needed for write watches. + */ +BOOL virtual_check_buffer_for_write( void *ptr, SIZE_T size ) +{ + if (!size) return TRUE; + if (!ptr) return FALSE; + + __TRY + { + volatile char *p = ptr; + SIZE_T count = size; + + while (count > page_size) + { + *p |= 0; + p += page_size; + count -= page_size; + } + p[0] |= 0; + p[count - 1] |= 0; + } + __EXCEPT_PAGE_FAULT + { + return FALSE; + } + __ENDTRY + return TRUE; +} + + +/*********************************************************************** * VIRTUAL_SetForceExec * * Whether to force exec prot on all views.
1
0
0
0
← Newer
1
...
66
67
68
69
70
71
72
...
135
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
Results per page:
10
25
50
100
200