ReactOS.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
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
List overview
Download
Ros-diffs
November 2021
----- 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
ros-diffs@reactos.org
23 participants
97 discussions
Start a n
N
ew thread
[reactos] 01/01: [DBGHELP] Fix default search path handling. CORE-17073
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4601d948013712974d9fd…
commit 4601d948013712974d9fd6990800c0ecfb36ed36 Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Mon Nov 15 20:11:42 2021 -0500 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Mon Nov 15 20:14:34 2021 -0500 [DBGHELP] Fix default search path handling. CORE-17073 * Allow NULL search path in SymSetSearchPath * Use . instead of concrete current directory * Use _NT_ALT_SYMBOL_PATH variable * Add some tests --- dll/win32/dbghelp/dbghelp.c | 98 ++++++++++++++++++---------- modules/rostests/winetests/dbghelp/dbghelp.c | 67 ++++++++++++++++++- 2 files changed, 128 insertions(+), 37 deletions(-) diff --git a/dll/win32/dbghelp/dbghelp.c b/dll/win32/dbghelp/dbghelp.c index c67f9730125..62c249c411b 100644 --- a/dll/win32/dbghelp/dbghelp.c +++ b/dll/win32/dbghelp/dbghelp.c @@ -191,6 +191,43 @@ struct cpu* cpu_find(DWORD machine) return NULL; } +static WCHAR* make_default_search_path(void) +{ + WCHAR* search_path; + WCHAR* p; + unsigned sym_path_len; + unsigned alt_sym_path_len; + + sym_path_len = GetEnvironmentVariableW(L"_NT_SYMBOL_PATH", NULL, 0); + alt_sym_path_len = GetEnvironmentVariableW(L"_NT_ALT_SYMBOL_PATH", NULL, 0); + + /* The default symbol path is ".[;%_NT_SYMBOL_PATH%][;%_NT_ALT_SYMBOL_PATH%]". + * If the variables exist, the lengths include a null-terminator. We use that + * space for the semicolons, and only add the initial dot and the final null. */ + search_path = HeapAlloc(GetProcessHeap(), 0, + (1 + sym_path_len + alt_sym_path_len + 1) * sizeof(WCHAR)); + if (!search_path) return NULL; + + p = search_path; + *p++ = L'.'; + if (sym_path_len) + { + *p++ = L';'; + GetEnvironmentVariableW(L"_NT_SYMBOL_PATH", p, sym_path_len); + p += sym_path_len - 1; + } + + if (alt_sym_path_len) + { + *p++ = L';'; + GetEnvironmentVariableW(L"_NT_ALT_SYMBOL_PATH", p, alt_sym_path_len); + p += alt_sym_path_len - 1; + } + *p = L'\0'; + + return search_path; +} + /****************************************************************** * SymSetSearchPathW (DBGHELP.@) * @@ -198,14 +235,24 @@ struct cpu* cpu_find(DWORD machine) BOOL WINAPI SymSetSearchPathW(HANDLE hProcess, PCWSTR searchPath) { struct process* pcs = process_find_by_handle(hProcess); + WCHAR* search_path_buffer; if (!pcs) return FALSE; - if (!searchPath) return FALSE; + if (searchPath) + { + search_path_buffer = HeapAlloc(GetProcessHeap(), 0, + (lstrlenW(searchPath) + 1) * sizeof(WCHAR)); + if (!search_path_buffer) return FALSE; + lstrcpyW(search_path_buffer, searchPath); + } + else + { + search_path_buffer = make_default_search_path(); + if (!search_path_buffer) return FALSE; + } HeapFree(GetProcessHeap(), 0, pcs->search_path); - pcs->search_path = lstrcpyW(HeapAlloc(GetProcessHeap(), 0, - (lstrlenW(searchPath) + 1) * sizeof(WCHAR)), - searchPath); + pcs->search_path = search_path_buffer; return TRUE; } @@ -217,16 +264,19 @@ BOOL WINAPI SymSetSearchPath(HANDLE hProcess, PCSTR searchPath) { BOOL ret = FALSE; unsigned len; - WCHAR* sp; + WCHAR* sp = NULL; - len = MultiByteToWideChar(CP_ACP, 0, searchPath, -1, NULL, 0); - if ((sp = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)))) + if (searchPath) { + len = MultiByteToWideChar(CP_ACP, 0, searchPath, -1, NULL, 0); + sp = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + if (!sp) return FALSE; MultiByteToWideChar(CP_ACP, 0, searchPath, -1, sp, len); - - ret = SymSetSearchPathW(hProcess, sp); - HeapFree(GetProcessHeap(), 0, sp); } + + ret = SymSetSearchPathW(hProcess, sp); + + HeapFree(GetProcessHeap(), 0, sp); return ret; } @@ -442,37 +492,13 @@ BOOL WINAPI SymInitializeW(HANDLE hProcess, PCWSTR UserSearchPath, BOOL fInvadeP if (UserSearchPath) { - pcs->search_path = lstrcpyW(HeapAlloc(GetProcessHeap(), 0, + pcs->search_path = lstrcpyW(HeapAlloc(GetProcessHeap(), 0, (lstrlenW(UserSearchPath) + 1) * sizeof(WCHAR)), UserSearchPath); } else { - unsigned size; - unsigned len; - static const WCHAR sym_path[] = {'_','N','T','_','S','Y','M','B','O','L','_','P','A','T','H',0}; - static const WCHAR alt_sym_path[] = {'_','N','T','_','A','L','T','E','R','N','A','T','E','_','S','Y','M','B','O','L','_','P','A','T','H',0}; - - pcs->search_path = HeapAlloc(GetProcessHeap(), 0, (len = MAX_PATH) * sizeof(WCHAR)); - while ((size = GetCurrentDirectoryW(len, pcs->search_path)) >= len) - pcs->search_path = HeapReAlloc(GetProcessHeap(), 0, pcs->search_path, (len *= 2) * sizeof(WCHAR)); - pcs->search_path = HeapReAlloc(GetProcessHeap(), 0, pcs->search_path, (size + 1) * sizeof(WCHAR)); - - len = GetEnvironmentVariableW(sym_path, NULL, 0); - if (len) - { - pcs->search_path = HeapReAlloc(GetProcessHeap(), 0, pcs->search_path, (size + 1 + len + 1) * sizeof(WCHAR)); - pcs->search_path[size] = ';'; - GetEnvironmentVariableW(sym_path, pcs->search_path + size + 1, len); - size += 1 + len; - } - len = GetEnvironmentVariableW(alt_sym_path, NULL, 0); - if (len) - { - pcs->search_path = HeapReAlloc(GetProcessHeap(), 0, pcs->search_path, (size + 1 + len + 1) * sizeof(WCHAR)); - pcs->search_path[size] = ';'; - GetEnvironmentVariableW(alt_sym_path, pcs->search_path + size + 1, len); - } + pcs->search_path = make_default_search_path(); } pcs->lmodules = NULL; diff --git a/modules/rostests/winetests/dbghelp/dbghelp.c b/modules/rostests/winetests/dbghelp/dbghelp.c index 214adb7b16b..f062d647ed9 100644 --- a/modules/rostests/winetests/dbghelp/dbghelp.c +++ b/modules/rostests/winetests/dbghelp/dbghelp.c @@ -132,12 +132,77 @@ static void test_stack_walk(void) #endif /* __i386__ || __x86_64__ */ +static void test_search_path(void) +{ + char search_path[128]; + BOOL ret; + + /* The default symbol path is ".[;%_NT_SYMBOL_PATH%][;%_NT_ALT_SYMBOL_PATH%]". + * We unset both variables earlier so should simply get "." */ + ret = SymGetSearchPath(GetCurrentProcess(), search_path, ARRAY_SIZE(search_path)); + ok(ret == TRUE, "ret = %d\n", ret); + ok(!strcmp(search_path, "."), "Got search path '%s', expected '.'\n", search_path); + + /* Set an arbitrary search path */ + ret = SymSetSearchPath(GetCurrentProcess(), "W:\\"); + ok(ret == TRUE, "ret = %d\n", ret); + ret = SymGetSearchPath(GetCurrentProcess(), search_path, ARRAY_SIZE(search_path)); + ok(ret == TRUE, "ret = %d\n", ret); + ok(!strcmp(search_path, "W:\\"), "Got search path '%s', expected 'W:\\'\n", search_path); + + /* Setting to NULL resets to the default */ + ret = SymSetSearchPath(GetCurrentProcess(), NULL); + ok(ret == TRUE, "ret = %d\n", ret); + ret = SymGetSearchPath(GetCurrentProcess(), search_path, ARRAY_SIZE(search_path)); + ok(ret == TRUE, "ret = %d\n", ret); + ok(!strcmp(search_path, "."), "Got search path '%s', expected '.'\n", search_path); + + /* With _NT_SYMBOL_PATH */ + SetEnvironmentVariableA("_NT_SYMBOL_PATH", "X:\\"); + ret = SymSetSearchPath(GetCurrentProcess(), NULL); + ok(ret == TRUE, "ret = %d\n", ret); + ret = SymGetSearchPath(GetCurrentProcess(), search_path, ARRAY_SIZE(search_path)); + ok(ret == TRUE, "ret = %d\n", ret); + ok(!strcmp(search_path, ".;X:\\"), "Got search path '%s', expected '.;X:\\'\n", search_path); + + /* With both _NT_SYMBOL_PATH and _NT_ALT_SYMBOL_PATH */ + SetEnvironmentVariableA("_NT_ALT_SYMBOL_PATH", "Y:\\"); + ret = SymSetSearchPath(GetCurrentProcess(), NULL); + ok(ret == TRUE, "ret = %d\n", ret); + ret = SymGetSearchPath(GetCurrentProcess(), search_path, ARRAY_SIZE(search_path)); + ok(ret == TRUE, "ret = %d\n", ret); + ok(!strcmp(search_path, ".;X:\\;Y:\\"), "Got search path '%s', expected '.;X:\\;Y:\\'\n", search_path); + + /* With just _NT_ALT_SYMBOL_PATH */ + SetEnvironmentVariableA("_NT_SYMBOL_PATH", NULL); + ret = SymSetSearchPath(GetCurrentProcess(), NULL); + ok(ret == TRUE, "ret = %d\n", ret); + ret = SymGetSearchPath(GetCurrentProcess(), search_path, ARRAY_SIZE(search_path)); + ok(ret == TRUE, "ret = %d\n", ret); + ok(!strcmp(search_path, ".;Y:\\"), "Got search path '%s', expected '.;Y:\\'\n", search_path); + + /* Restore original search path */ + SetEnvironmentVariableA("_NT_ALT_SYMBOL_PATH", NULL); + ret = SymSetSearchPath(GetCurrentProcess(), NULL); + ok(ret == TRUE, "ret = %d\n", ret); + ret = SymGetSearchPath(GetCurrentProcess(), search_path, ARRAY_SIZE(search_path)); + ok(ret == TRUE, "ret = %d\n", ret); + ok(!strcmp(search_path, "."), "Got search path '%s', expected '.'\n", search_path); +} + START_TEST(dbghelp) { - BOOL ret = SymInitialize(GetCurrentProcess(), NULL, TRUE); + BOOL ret; + + /* Don't let the user's environment influence our symbol path */ + SetEnvironmentVariableA("_NT_SYMBOL_PATH", NULL); + SetEnvironmentVariableA("_NT_ALT_SYMBOL_PATH", NULL); + + ret = SymInitialize(GetCurrentProcess(), NULL, TRUE); ok(ret, "got error %u\n", GetLastError()); test_stack_walk(); + test_search_path(); ret = SymCleanup(GetCurrentProcess()); ok(ret, "got error %u\n", GetLastError());
3 years, 1 month
1
0
0
0
[reactos] 06/06: [FONTEXT] Fix font installation
by Mark Jansen
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ab7b004d51c3c38440794…
commit ab7b004d51c3c38440794ce5d3b7fb03c03af2a8 Author: Mark Jansen <mark.jansen(a)reactos.org> AuthorDate: Sun Jul 25 01:11:01 2021 +0200 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Mon Nov 15 20:02:14 2021 +0100 [FONTEXT] Fix font installation --- dll/shellext/fontext/CFontCache.hpp | 3 ++- dll/shellext/fontext/CFontExt.cpp | 45 ++++++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/dll/shellext/fontext/CFontCache.hpp b/dll/shellext/fontext/CFontCache.hpp index e047e6b4b1d..ba9d9e39636 100644 --- a/dll/shellext/fontext/CFontCache.hpp +++ b/dll/shellext/fontext/CFontCache.hpp @@ -45,9 +45,10 @@ protected: CFontCache(); void Insert(CAtlList<CFontInfo>& fonts, const CStringW& KeyName); - void Read(); public: + void Read(); + void SetFontDir(const LPCWSTR Path); const CStringW& FontPath() const { return m_FontFolderPath; } diff --git a/dll/shellext/fontext/CFontExt.cpp b/dll/shellext/fontext/CFontExt.cpp index 23b7e0b2721..7fffa90736e 100644 --- a/dll/shellext/fontext/CFontExt.cpp +++ b/dll/shellext/fontext/CFontExt.cpp @@ -603,10 +603,15 @@ STDMETHODIMP CFontExt::Drop(IDataObject* pDataObj, DWORD grfKeyState, POINTL pt, } } - // TODO: update g_FontCache + // Invalidate our cache + g_FontCache->Read(); + // Notify the system that a font was added SendMessageW(HWND_BROADCAST, WM_FONTCHANGE, 0, 0); + // Notify the shell that the folder contents are changed + SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATHW, g_FontCache->FontPath().GetString(), NULL); + // TODO: Show message return bOK ? S_OK : E_FAIL; @@ -615,15 +620,30 @@ STDMETHODIMP CFontExt::Drop(IDataObject* pDataObj, DWORD grfKeyState, POINTL pt, HRESULT CFontExt::DoInstallFontFile(LPCWSTR pszFontPath, LPCWSTR pszFontsDir, HKEY hkeyFonts) { WCHAR szDestFile[MAX_PATH]; - LPCWSTR pszFileTitle = PathFindFileName(pszFontPath); - CStringW strFontName; - if (!DoGetFontTitle(pszFontPath, strFontName)) + // Add this font to the font list, so we can query the name + if (!AddFontResourceW(pszFontPath)) + { + ERR("AddFontResourceW('%S') failed\n", pszFontPath); + DeleteFileW(szDestFile); return E_FAIL; + } + + CStringW strFontName; + HRESULT hr = DoGetFontTitle(pszFontPath, strFontName); - RemoveFontResourceW(pszFileTitle); + // We got the name, remove it again + RemoveFontResourceW(pszFontPath); + + if (!SUCCEEDED(hr)) + { + ERR("DoGetFontTitle failed (err=0x%x)!\n", hr); + return hr; + } StringCchCopyW(szDestFile, sizeof(szDestFile), pszFontsDir); + + LPCWSTR pszFileTitle = PathFindFileName(pszFontPath); PathAppendW(szDestFile, pszFileTitle); if (!CopyFileW(pszFontPath, szDestFile, FALSE)) { @@ -631,24 +651,18 @@ HRESULT CFontExt::DoInstallFontFile(LPCWSTR pszFontPath, LPCWSTR pszFontsDir, HK return E_FAIL; } - if (!AddFontResourceW(szDestFile)) - { - ERR("AddFontResourceW('%S') failed\n", pszFileTitle); - DeleteFileW(szDestFile); - return E_FAIL; - } - DWORD cbData = (wcslen(pszFileTitle) + 1) * sizeof(WCHAR); LONG nError = RegSetValueExW(hkeyFonts, strFontName, 0, REG_SZ, (const BYTE *)pszFileTitle, cbData); if (nError) { ERR("RegSetValueExW failed with %ld\n", nError); - RemoveFontResourceW(pszFileTitle); DeleteFileW(szDestFile); return E_FAIL; } + AddFontResourceW(szDestFile); + return S_OK; } @@ -659,12 +673,13 @@ CFontExt::DoGetFontTitle(IN LPCWSTR pszFontPath, OUT CStringW& strFontName) BOOL ret = GetFontResourceInfoW(pszFontPath, &cbInfo, NULL, 1); if (!ret || !cbInfo) { - ERR("GetFontResourceInfoW failed\n"); + ERR("GetFontResourceInfoW failed (err: %u)\n", GetLastError()); return E_FAIL; } LPWSTR pszBuffer = strFontName.GetBuffer(cbInfo / sizeof(WCHAR)); ret = GetFontResourceInfoW(pszFontPath, &cbInfo, pszBuffer, 1); + DWORD dwErr = GetLastError();; strFontName.ReleaseBuffer(); if (ret) { @@ -672,6 +687,6 @@ CFontExt::DoGetFontTitle(IN LPCWSTR pszFontPath, OUT CStringW& strFontName) return S_OK; } - ERR("GetFontResourceInfoW failed\n"); + ERR("GetFontResourceInfoW failed (err: %u)\n", dwErr); return E_FAIL; }
3 years, 1 month
1
0
0
0
[reactos] 05/06: [FONTEXT] Simplify HIDA usage
by Mark Jansen
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=54c09f856c315c4266fff…
commit 54c09f856c315c4266fff190aa6ba4524a4e9943 Author: Mark Jansen <mark.jansen(a)reactos.org> AuthorDate: Sun Jul 25 01:10:51 2021 +0200 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Mon Nov 15 20:02:14 2021 +0100 [FONTEXT] Simplify HIDA usage --- dll/shellext/fontext/CFontExt.cpp | 14 ++++++------- dll/shellext/fontext/CFontMenu.cpp | 42 +++++--------------------------------- dll/shellext/fontext/precomp.h | 2 -- 3 files changed, 11 insertions(+), 47 deletions(-) diff --git a/dll/shellext/fontext/CFontExt.cpp b/dll/shellext/fontext/CFontExt.cpp index b2681055cd2..23b7e0b2721 100644 --- a/dll/shellext/fontext/CFontExt.cpp +++ b/dll/shellext/fontext/CFontExt.cpp @@ -505,10 +505,9 @@ STDMETHODIMP CFontExt::DragEnter(IDataObject* pDataObj, DWORD grfKeyState, POINT { *pdwEffect = DROPEFFECT_NONE; - CComHeapPtr<CIDA> cida; - HRESULT hr = _GetCidlFromDataObject(pDataObj, &cida); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; + CDataObjectHIDA cida(pDataObj); + if (FAILED_UNEXPECTEDLY(cida.hr())) + return cida.hr(); *pdwEffect = DROPEFFECT_COPY; return S_OK; @@ -528,10 +527,9 @@ STDMETHODIMP CFontExt::Drop(IDataObject* pDataObj, DWORD grfKeyState, POINTL pt, { *pdwEffect = DROPEFFECT_NONE; - CComHeapPtr<CIDA> cida; - HRESULT hr = _GetCidlFromDataObject(pDataObj, &cida); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; + CDataObjectHIDA cida(pDataObj); + if (!cida) + return E_UNEXPECTED; PCUIDLIST_ABSOLUTE pidlParent = HIDA_GetPIDLFolder(cida); if (!pidlParent) diff --git a/dll/shellext/fontext/CFontMenu.cpp b/dll/shellext/fontext/CFontMenu.cpp index 62464a099ee..fdd20bbd6ef 100644 --- a/dll/shellext/fontext/CFontMenu.cpp +++ b/dll/shellext/fontext/CFontMenu.cpp @@ -2,45 +2,13 @@ * PROJECT: ReactOS Font Shell Extension * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) * PURPOSE: CFontMenu implementation - * COPYRIGHT: Copyright 2019,2020 Mark Jansen <mark.jansen(a)reactos.org> + * COPYRIGHT: Copyright 2019-2021 Mark Jansen <mark.jansen(a)reactos.org> */ #include "precomp.h" WINE_DEFAULT_DEBUG_CHANNEL(fontext); -static CLIPFORMAT g_cfHIDA; - -HRESULT _GetCidlFromDataObject(IDataObject *pDataObject, CIDA** ppcida) -{ - if (g_cfHIDA == NULL) - { - g_cfHIDA = (CLIPFORMAT)RegisterClipboardFormatW(CFSTR_SHELLIDLIST); - } - - FORMATETC fmt = { g_cfHIDA, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - STGMEDIUM medium; - - HRESULT hr = pDataObject->GetData(&fmt, &medium); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; - - LPVOID lpSrc = GlobalLock(medium.hGlobal); - SIZE_T cbSize = GlobalSize(medium.hGlobal); - - *ppcida = (CIDA *)::CoTaskMemAlloc(cbSize); - if (*ppcida) - { - memcpy(*ppcida, lpSrc, cbSize); - hr = S_OK; - } - else - { - hr = E_FAIL; - } - ReleaseStgMedium(&medium); - return hr; -} const char* DFM_TO_STR(UINT uMsg) { @@ -111,10 +79,10 @@ static HRESULT CALLBACK FontFolderMenuCallback(IShellFolder *psf, HWND hwnd, IDa // Preview is the only item we handle if (wParam == 0) { - CComHeapPtr<CIDA> cida; - HRESULT hr = _GetCidlFromDataObject(pdtobj, &cida); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; + CDataObjectHIDA cida(pdtobj); + + if (FAILED_UNEXPECTEDLY(cida.hr())) + return cida.hr(); for (UINT n = 0; n < cida->cidl; ++n) { diff --git a/dll/shellext/fontext/precomp.h b/dll/shellext/fontext/precomp.h index 8037e4cd064..2e46032986d 100644 --- a/dll/shellext/fontext/precomp.h +++ b/dll/shellext/fontext/precomp.h @@ -36,8 +36,6 @@ HRESULT _CFontMenu_CreateInstance(HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY ap HRESULT _CDataObject_CreateInstance(PCIDLIST_ABSOLUTE folder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, LPVOID* ppvOut); -HRESULT _GetCidlFromDataObject(IDataObject *pDataObject, CIDA** ppcida); - inline BOOL IsFontDotExt(LPCWSTR pchDotExt) { static const LPCWSTR array[] =
3 years, 1 month
1
0
0
0
[reactos] 04/06: [SHELL32] Simplify HIDA usage
by Mark Jansen
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fa0f5cc4be10434040346…
commit fa0f5cc4be1043404034638fd991a8fa511649df Author: Mark Jansen <mark.jansen(a)reactos.org> AuthorDate: Sun Jul 25 01:10:24 2021 +0200 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Mon Nov 15 20:02:14 2021 +0100 [SHELL32] Simplify HIDA usage --- dll/win32/shell32/CCopyToMenu.cpp | 44 +++---------------------- dll/win32/shell32/CCopyToMoveToMenu.h | 1 - dll/win32/shell32/CMoveToMenu.cpp | 12 +++---- dll/win32/shell32/COpenWithMenu.cpp | 38 +++++---------------- dll/win32/shell32/droptargets/CFSDropTarget.cpp | 4 ++- dll/win32/shell32/shlfolder.cpp | 31 +++-------------- 6 files changed, 26 insertions(+), 104 deletions(-) diff --git a/dll/win32/shell32/CCopyToMenu.cpp b/dll/win32/shell32/CCopyToMenu.cpp index de2e2921ecd..034acb5d844 100644 --- a/dll/win32/shell32/CCopyToMenu.cpp +++ b/dll/win32/shell32/CCopyToMenu.cpp @@ -9,38 +9,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell); -HRESULT _GetCidlFromDataObject(IDataObject *pDataObject, CIDA** ppcida) -{ - static CLIPFORMAT s_cfHIDA = 0; - if (s_cfHIDA == 0) - { - s_cfHIDA = static_cast<CLIPFORMAT>(RegisterClipboardFormatW(CFSTR_SHELLIDLIST)); - } - - FORMATETC fmt = { s_cfHIDA, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - STGMEDIUM medium; - - HRESULT hr = pDataObject->GetData(&fmt, &medium); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; - - LPVOID lpSrc = GlobalLock(medium.hGlobal); - SIZE_T cbSize = GlobalSize(medium.hGlobal); - - *ppcida = reinterpret_cast<CIDA *>(::CoTaskMemAlloc(cbSize)); - if (*ppcida) - { - memcpy(*ppcida, lpSrc, cbSize); - hr = S_OK; - } - else - { - ERR("Out of memory\n"); - hr = E_FAIL; - } - ReleaseStgMedium(&medium); - return hr; -} CCopyToMenu::CCopyToMenu() : m_idCmdFirst(0), @@ -157,10 +125,9 @@ BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) HRESULT CCopyToMenu::DoRealCopy(LPCMINVOKECOMMANDINFO lpici, LPCITEMIDLIST pidl) { - CComHeapPtr<CIDA> pCIDA; - HRESULT hr = _GetCidlFromDataObject(m_pDataObject, &pCIDA); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; + CDataObjectHIDA pCIDA(m_pDataObject); + if (FAILED_UNEXPECTEDLY(pCIDA.hr())) + return pCIDA.hr(); PCUIDLIST_ABSOLUTE pidlParent = HIDA_GetPIDLFolder(pCIDA); if (!pidlParent) @@ -224,9 +191,8 @@ CStringW CCopyToMenu::DoGetFileTitle() { CStringW ret = L"(file)"; - CComHeapPtr<CIDA> pCIDA; - HRESULT hr = _GetCidlFromDataObject(m_pDataObject, &pCIDA); - if (FAILED_UNEXPECTEDLY(hr)) + CDataObjectHIDA pCIDA(m_pDataObject); + if (FAILED_UNEXPECTEDLY(pCIDA.hr())) return ret; PCUIDLIST_ABSOLUTE pidlParent = HIDA_GetPIDLFolder(pCIDA); diff --git a/dll/win32/shell32/CCopyToMoveToMenu.h b/dll/win32/shell32/CCopyToMoveToMenu.h index 2dfe94825b6..01ee85d30c7 100644 --- a/dll/win32/shell32/CCopyToMoveToMenu.h +++ b/dll/win32/shell32/CCopyToMoveToMenu.h @@ -6,7 +6,6 @@ */ #pragma once -HRESULT _GetCidlFromDataObject(IDataObject *pDataObject, CIDA** ppcida); class CCopyToMenu : public CComCoClass<CCopyToMenu, &CLSID_CopyToMenu>, diff --git a/dll/win32/shell32/CMoveToMenu.cpp b/dll/win32/shell32/CMoveToMenu.cpp index be90f97201a..ec8714ebd9b 100644 --- a/dll/win32/shell32/CMoveToMenu.cpp +++ b/dll/win32/shell32/CMoveToMenu.cpp @@ -124,10 +124,9 @@ BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) HRESULT CMoveToMenu::DoRealMove(LPCMINVOKECOMMANDINFO lpici, LPCITEMIDLIST pidl) { - CComHeapPtr<CIDA> pCIDA; - HRESULT hr = _GetCidlFromDataObject(m_pDataObject, &pCIDA); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; + CDataObjectHIDA pCIDA(m_pDataObject); + if (FAILED_UNEXPECTEDLY(pCIDA.hr())) + return pCIDA.hr(); PCUIDLIST_ABSOLUTE pidlParent = HIDA_GetPIDLFolder(pCIDA); if (!pidlParent) @@ -191,9 +190,8 @@ CStringW CMoveToMenu::DoGetFileTitle() { CStringW ret = L"(file)"; - CComHeapPtr<CIDA> pCIDA; - HRESULT hr = _GetCidlFromDataObject(m_pDataObject, &pCIDA); - if (FAILED_UNEXPECTEDLY(hr)) + CDataObjectHIDA pCIDA(m_pDataObject); + if (FAILED_UNEXPECTEDLY(pCIDA.hr())) return ret; PCUIDLIST_ABSOLUTE pidlParent = HIDA_GetPIDLFolder(pCIDA); diff --git a/dll/win32/shell32/COpenWithMenu.cpp b/dll/win32/shell32/COpenWithMenu.cpp index 335236d96ae..5409f449bd2 100644 --- a/dll/win32/shell32/COpenWithMenu.cpp +++ b/dll/win32/shell32/COpenWithMenu.cpp @@ -1352,53 +1352,33 @@ COpenWithMenu::Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID) { - STGMEDIUM medium; - FORMATETC fmt; - HRESULT hr; - LPIDA pida; LPCITEMIDLIST pidlFolder2; LPCITEMIDLIST pidlChild; - LPCITEMIDLIST pidl; - LPCWSTR pwszExt; TRACE("This %p\n", this); if (pdtobj == NULL) return E_INVALIDARG; - fmt.cfFormat = RegisterClipboardFormatW(CFSTR_SHELLIDLIST); - fmt.ptd = NULL; - fmt.dwAspect = DVASPECT_CONTENT; - fmt.lindex = -1; - fmt.tymed = TYMED_HGLOBAL; - - hr = pdtobj->GetData(&fmt, &medium); - - if (FAILED(hr)) + CDataObjectHIDA pida(pdtobj); + if (FAILED(pida.hr())) { - ERR("pdtobj->GetData failed with 0x%x\n", hr); - return hr; + ERR("pdtobj->GetData failed with 0x%x\n", pida.hr()); + return pida.hr(); } - pida = (LPIDA)GlobalLock(medium.hGlobal); ASSERT(pida->cidl >= 1); - pidlFolder2 = (LPCITEMIDLIST) ((LPBYTE)pida + pida->aoffset[0]); - pidlChild = (LPCITEMIDLIST) ((LPBYTE)pida + pida->aoffset[1]); + pidlFolder2 = HIDA_GetPIDLFolder(pida); + pidlChild = HIDA_GetPIDLItem(pida, 0); if (!_ILIsValue(pidlChild)) { TRACE("pidl is not a file\n"); - GlobalUnlock(medium.hGlobal); - ReleaseStgMedium(&medium); return E_FAIL; } - pidl = ILCombine(pidlFolder2, pidlChild); - - GlobalUnlock(medium.hGlobal); - ReleaseStgMedium(&medium); - + CComHeapPtr<ITEMIDLIST> pidl(ILCombine(pidlFolder2, pidlChild)); if (!pidl) { ERR("no mem\n"); @@ -1407,15 +1387,13 @@ COpenWithMenu::Initialize(PCIDLIST_ABSOLUTE pidlFolder, if (!SHGetPathFromIDListW(pidl, m_wszPath)) { - SHFree((void*)pidl); ERR("SHGetPathFromIDListW failed\n"); return E_FAIL; } - SHFree((void*)pidl); TRACE("szPath %s\n", debugstr_w(m_wszPath)); - pwszExt = PathFindExtensionW(m_wszPath); + LPCWSTR pwszExt = PathFindExtensionW(m_wszPath); if (PathIsExeW(pwszExt) || !_wcsicmp(pwszExt, L".lnk")) { TRACE("file is a executable or shortcut\n"); diff --git a/dll/win32/shell32/droptargets/CFSDropTarget.cpp b/dll/win32/shell32/droptargets/CFSDropTarget.cpp index a25936f2ae9..2660ff84785 100644 --- a/dll/win32/shell32/droptargets/CFSDropTarget.cpp +++ b/dll/win32/shell32/droptargets/CFSDropTarget.cpp @@ -55,6 +55,8 @@ static WCHAR* BuildPathsList(LPCWSTR wszBasePath, int cidl, LPCITEMIDLIST *pidls * CFSDropTarget::_CopyItems * * copies items to this folder + * FIXME: We should not ask the parent folder: 'What is your path', and then manually build paths assuming everything is a simple pidl! + * We should be asking the parent folder: Give me a full name for this pidl (for each child!) */ HRESULT CFSDropTarget::_CopyItems(IShellFolder * pSFFrom, UINT cidl, LPCITEMIDLIST * apidl, BOOL bCopy) @@ -732,4 +734,4 @@ DWORD WINAPI CFSDropTarget::_DoDropThreadProc(LPVOID lpParameter) HRESULT CFSDropTarget_CreateInstance(LPWSTR sPathTarget, REFIID riid, LPVOID * ppvOut) { return ShellObjectCreatorInit<CFSDropTarget>(sPathTarget, riid, ppvOut); -} \ No newline at end of file +} diff --git a/dll/win32/shell32/shlfolder.cpp b/dll/win32/shell32/shlfolder.cpp index 1b967209657..03b4aa4ee11 100644 --- a/dll/win32/shell32/shlfolder.cpp +++ b/dll/win32/shell32/shlfolder.cpp @@ -326,44 +326,23 @@ void AddFSClassKeysToArray(PCUITEMID_CHILD pidl, HKEY* array, UINT* cKeys) HRESULT SH_GetApidlFromDataObject(IDataObject *pDataObject, PIDLIST_ABSOLUTE* ppidlfolder, PUITEMID_CHILD **apidlItems, UINT *pcidl) { - UINT cfShellIDList = RegisterClipboardFormatW(CFSTR_SHELLIDLIST); - if (!cfShellIDList) - return E_FAIL; - - FORMATETC fmt; - InitFormatEtc (fmt, cfShellIDList, TYMED_HGLOBAL); - - HRESULT hr = pDataObject->QueryGetData(&fmt); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; + CDataObjectHIDA cida(pDataObject); - STGMEDIUM medium; - hr = pDataObject->GetData(&fmt, &medium); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; - - /* lock the handle */ - LPIDA lpcida = (LPIDA)GlobalLock(medium.hGlobal); - if (!lpcida) - { - ReleaseStgMedium(&medium); - return E_FAIL; - } + if (FAILED_UNEXPECTEDLY(cida.hr())) + return cida.hr(); /* convert the data into pidl */ LPITEMIDLIST pidl; - LPITEMIDLIST *apidl = _ILCopyCidaToaPidl(&pidl, lpcida); + LPITEMIDLIST *apidl = _ILCopyCidaToaPidl(&pidl, cida); if (!apidl) { - ReleaseStgMedium(&medium); return E_OUTOFMEMORY; } *ppidlfolder = pidl; *apidlItems = apidl; - *pcidl = lpcida->cidl; + *pcidl = cida->cidl; - ReleaseStgMedium(&medium); return S_OK; }
3 years, 1 month
1
0
0
0
[reactos] 03/06: [SENDMAIL] Simplify HIDA usage
by Mark Jansen
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=eb0c005c1bceda61afdee…
commit eb0c005c1bceda61afdee245de5fc03a11bc481f Author: Mark Jansen <mark.jansen(a)reactos.org> AuthorDate: Sun Jul 25 01:09:59 2021 +0200 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Mon Nov 15 20:02:13 2021 +0100 [SENDMAIL] Simplify HIDA usage --- dll/shellext/sendmail/CDeskLinkDropHandler.cpp | 32 +++++--------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/dll/shellext/sendmail/CDeskLinkDropHandler.cpp b/dll/shellext/sendmail/CDeskLinkDropHandler.cpp index 28f01a414a6..8edc76dda2b 100644 --- a/dll/shellext/sendmail/CDeskLinkDropHandler.cpp +++ b/dll/shellext/sendmail/CDeskLinkDropHandler.cpp @@ -59,13 +59,6 @@ CDeskLinkDropHandler::Drop(IDataObject *pDataObject, DWORD dwKeyState, return E_POINTER; } - FORMATETC fmt; - fmt.cfFormat = RegisterClipboardFormatW(CFSTR_SHELLIDLIST); - fmt.ptd = NULL; - fmt.dwAspect = DVASPECT_CONTENT; - fmt.lindex = -1; - fmt.tymed = TYMED_HGLOBAL; - WCHAR szDir[MAX_PATH], szDest[MAX_PATH], szSrc[MAX_PATH]; SHGetSpecialFolderPathW(NULL, szDir, CSIDL_DESKTOPDIRECTORY, FALSE); @@ -74,24 +67,14 @@ CDeskLinkDropHandler::Drop(IDataObject *pDataObject, DWORD dwKeyState, if (FAILED_UNEXPECTEDLY(hr)) return hr; - STGMEDIUM medium; - hr = pDataObject->GetData(&fmt, &medium); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; + CDataObjectHIDA pida(pDataObject); + if (FAILED_UNEXPECTEDLY(pida.hr())) + return pida.hr(); - LPIDA pida = reinterpret_cast<LPIDA>(GlobalLock(medium.hGlobal)); - if (!pida) + LPCITEMIDLIST pidlParent = HIDA_GetPIDLFolder(pida); + for (UINT i = 0; i < pida->cidl; ++i) { - ERR("Error locking global\n"); - ReleaseStgMedium(&medium); - return E_FAIL; - } - - LPBYTE pb = reinterpret_cast<LPBYTE>(pida); - LPCITEMIDLIST pidlParent = reinterpret_cast<LPCITEMIDLIST>(pb + pida->aoffset[0]); - for (UINT i = 1; i <= pida->cidl; ++i) - { - LPCITEMIDLIST pidlChild = reinterpret_cast<LPCITEMIDLIST>(pb + pida->aoffset[i]); + LPCITEMIDLIST pidlChild = HIDA_GetPIDLItem(pida, i); CComHeapPtr<ITEMIDLIST> pidl(ILCombine(pidlParent, pidlChild)); if (!pidl) @@ -137,9 +120,6 @@ CDeskLinkDropHandler::Drop(IDataObject *pDataObject, DWORD dwKeyState, break; } - GlobalUnlock(medium.hGlobal); - ReleaseStgMedium(&medium); - return hr; }
3 years, 1 month
1
0
0
0
[reactos] 02/06: [MYDOCS] Simplify HIDA usage
by Mark Jansen
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=eba16dc9e92886e74eb73…
commit eba16dc9e92886e74eb73ca9ebb90378a62e9d5a Author: Mark Jansen <mark.jansen(a)reactos.org> AuthorDate: Sun Jul 25 01:08:35 2021 +0200 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Mon Nov 15 20:02:13 2021 +0100 [MYDOCS] Simplify HIDA usage --- dll/shellext/mydocs/CMyDocsDropHandler.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/dll/shellext/mydocs/CMyDocsDropHandler.cpp b/dll/shellext/mydocs/CMyDocsDropHandler.cpp index 477ca4b1d7f..92653e4c6d4 100644 --- a/dll/shellext/mydocs/CMyDocsDropHandler.cpp +++ b/dll/shellext/mydocs/CMyDocsDropHandler.cpp @@ -9,8 +9,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(mydocs); -static CLIPFORMAT g_cfHIDA = 0; - CMyDocsDropHandler::CMyDocsDropHandler() { InterlockedIncrement(&g_ModuleRefCnt); @@ -68,23 +66,15 @@ CMyDocsDropHandler::Drop(IDataObject *pDataObject, DWORD dwKeyState, if (FAILED_UNEXPECTEDLY(hr)) return hr; - // get the clipboard format - if (g_cfHIDA == 0) - g_cfHIDA = ::RegisterClipboardFormatW(CFSTR_SHELLIDLIST); - // Retrieve an HIDA (handle of IDA) - STGMEDIUM medium; - FORMATETC fmt = { g_cfHIDA, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - hr = pDataObject->GetData(&fmt, &medium); - if (FAILED_UNEXPECTEDLY(hr)) + CDataObjectHIDA pida(pDataObject); + if (FAILED_UNEXPECTEDLY(pida.hr())) { *pdwEffect = 0; DragLeave(); - return E_FAIL; + return pida.hr(); } - // lock HIDA - LPIDA pida = reinterpret_cast<LPIDA>(GlobalLock(medium.hGlobal)); UINT iItem, cItems = pida->cidl; // get the path of "My Documents" @@ -123,9 +113,6 @@ CMyDocsDropHandler::Drop(IDataObject *pDataObject, DWORD dwKeyState, strSrcList += szSrc; } - // unlock HIDA - GlobalUnlock(medium.hGlobal); - if (iItem != cItems) { // source not found
3 years, 1 month
1
0
0
0
[reactos] 01/06: [SHELL32][SHELL32_APITEST] Add SHGetAttributesFromDataObject
by Mark Jansen
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e5ea6041c96a4ab5f65dc…
commit e5ea6041c96a4ab5f65dc19fda2f8c369ea316f7 Author: Mark Jansen <mark.jansen(a)reactos.org> AuthorDate: Fri Jul 23 20:34:02 2021 +0200 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Mon Nov 15 20:02:13 2021 +0100 [SHELL32][SHELL32_APITEST] Add SHGetAttributesFromDataObject --- dll/win32/shell32/CMakeLists.txt | 1 + dll/win32/shell32/shldataobject.cpp | 103 +++++++ dll/win32/shell32/stubs.cpp | 14 - modules/rostests/apitests/shell32/CMakeLists.txt | 1 + .../shell32/SHGetAttributesFromDataObject.cpp | 319 +++++++++++++++++++++ modules/rostests/apitests/shell32/testlist.c | 2 + sdk/include/psdk/shlobj.h | 12 + sdk/include/reactos/shellutils.h | 65 +++++ 8 files changed, 503 insertions(+), 14 deletions(-) diff --git a/dll/win32/shell32/CMakeLists.txt b/dll/win32/shell32/CMakeLists.txt index 4ebe876caea..2b1f658bacd 100644 --- a/dll/win32/shell32/CMakeLists.txt +++ b/dll/win32/shell32/CMakeLists.txt @@ -53,6 +53,7 @@ list(APPEND SOURCE droptargets/CexeDropHandler.cpp droptargets/CFSDropTarget.cpp droptargets/CRecyclerDropTarget.cpp + shldataobject.cpp shlexec.cpp shlfileop.cpp shlfolder.cpp diff --git a/dll/win32/shell32/shldataobject.cpp b/dll/win32/shell32/shldataobject.cpp new file mode 100644 index 00000000000..4b6d3186271 --- /dev/null +++ b/dll/win32/shell32/shldataobject.cpp @@ -0,0 +1,103 @@ +/* + * PROJECT: shell32 + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: SHGetAttributesFromDataObject implementation + * COPYRIGHT: Copyright 2021 Mark Jansen <mark.jansen(a)reactos.org> + */ + + +#include "precomp.h" + +WINE_DEFAULT_DEBUG_CHANNEL(shell); + + +static CLIPFORMAT g_DataObjectAttributes = 0; +static const DWORD dwDefaultAttributeMask = SFGAO_CANCOPY | SFGAO_CANMOVE | SFGAO_STORAGE | SFGAO_CANRENAME | + SFGAO_CANDELETE | SFGAO_READONLY | SFGAO_STREAM | SFGAO_FOLDER; + +struct DataObjectAttributes +{ + DWORD dwMask; + DWORD dwAttributes; + UINT cItems; +}; + +static_assert(sizeof(DataObjectAttributes) == 0xc, "Unexpected struct size!"); + + +static +HRESULT _BindToObject(PCUIDLIST_ABSOLUTE pidl, CComPtr<IShellFolder>& spFolder) +{ + CComPtr<IShellFolder> spDesktop; + HRESULT hr = SHGetDesktopFolder(&spDesktop); + if (FAILED(hr)) + return hr; + + return spDesktop->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, &spFolder)); +} + +EXTERN_C +HRESULT WINAPI SHGetAttributesFromDataObject(IDataObject* pDataObject, DWORD dwAttributeMask, DWORD* pdwAttributes, UINT* pcItems) +{ + DWORD dwAttributes = 0; + DWORD cItems = 0; + HRESULT hr = S_OK; + + TRACE("(%p, 0x%x, %p, %p)\n", pDataObject, dwAttributeMask, pdwAttributes, pcItems); + + if (!g_DataObjectAttributes) + g_DataObjectAttributes = (CLIPFORMAT)RegisterClipboardFormatW(L"DataObjectAttributes"); + + if (pDataObject) + { + DataObjectAttributes data = {}; + if (FAILED(DataObject_GetData(pDataObject, g_DataObjectAttributes, &data, sizeof(data)))) + { + TRACE("No attributes yet, creating new\n"); + memset(&data, 0, sizeof(data)); + } + + DWORD dwQueryAttributes = dwAttributeMask | dwDefaultAttributeMask; + + if ((data.dwMask & dwQueryAttributes) != dwQueryAttributes) + { + CDataObjectHIDA hida(pDataObject); + CComPtr<IShellFolder> spFolder; + + if (!FAILED_UNEXPECTEDLY(hr = hida.hr()) && + !FAILED_UNEXPECTEDLY(hr = _BindToObject(HIDA_GetPIDLFolder(hida), spFolder))) + { + CSimpleArray<PCUIDLIST_RELATIVE> apidl; + for (UINT n = 0; n < hida->cidl; ++n) + { + apidl.Add(HIDA_GetPIDLItem(hida, n)); + } + + SFGAOF rgfInOut = dwQueryAttributes; + hr = spFolder->GetAttributesOf(apidl.GetSize(), apidl.GetData(), &rgfInOut); + if (!FAILED_UNEXPECTEDLY(hr)) + { + data.dwMask = dwQueryAttributes; + // Only store what we asked for + data.dwAttributes = rgfInOut & dwQueryAttributes; + data.cItems = apidl.GetSize(); + + hr = DataObject_SetData(pDataObject, g_DataObjectAttributes, &data, sizeof(data)); + FAILED_UNEXPECTEDLY(hr); + } + } + } + + // Only give the user what they asked for, not everything else we have! + dwAttributes = data.dwAttributes & dwAttributeMask; + cItems = data.cItems; + } + + if (pdwAttributes) + *pdwAttributes = dwAttributes; + + if (pcItems) + *pcItems = cItems; + + return hr; +} diff --git a/dll/win32/shell32/stubs.cpp b/dll/win32/shell32/stubs.cpp index a5061ad1a9d..2d49322a184 100644 --- a/dll/win32/shell32/stubs.cpp +++ b/dll/win32/shell32/stubs.cpp @@ -1302,20 +1302,6 @@ DWORD WINAPI SHGetComputerDisplayNameW(DWORD param1, DWORD param2, DWORD param3, return E_FAIL; } -/* - * Unimplemented - */ -EXTERN_C HRESULT -WINAPI -SHGetAttributesFromDataObject(IDataObject *pdo, - DWORD dwAttributeMask, - DWORD *pdwAttributes, - UINT *pcItems) -{ - FIXME("SHGetAttributesFromDataObject() stub\n"); - return E_NOTIMPL; -} - /* * Unimplemented */ diff --git a/modules/rostests/apitests/shell32/CMakeLists.txt b/modules/rostests/apitests/shell32/CMakeLists.txt index 990e1463d48..7a175032619 100644 --- a/modules/rostests/apitests/shell32/CMakeLists.txt +++ b/modules/rostests/apitests/shell32/CMakeLists.txt @@ -27,6 +27,7 @@ list(APPEND SOURCE ShellExecuteW.cpp ShellHook.cpp ShellState.cpp + SHGetAttributesFromDataObject.cpp SHLimitInputEdit.cpp menu.cpp shelltest.cpp) diff --git a/modules/rostests/apitests/shell32/SHGetAttributesFromDataObject.cpp b/modules/rostests/apitests/shell32/SHGetAttributesFromDataObject.cpp new file mode 100644 index 00000000000..937045cdc25 --- /dev/null +++ b/modules/rostests/apitests/shell32/SHGetAttributesFromDataObject.cpp @@ -0,0 +1,319 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) + * PURPOSE: Test for SHGetAttributesFromDataObject + * COPYRIGHT: Copyright 2021 Mark Jansen <mark.jansen(a)reactos.org> + */ + +#include "shelltest.h" +#include <ndk/rtlfuncs.h> +#include <stdio.h> +#include <shellutils.h> +#include <shlwapi.h> + + +static CLIPFORMAT g_DataObjectAttributes = 0; +static const DWORD dwDefaultAttributeMask = SFGAO_CANCOPY | SFGAO_CANMOVE | SFGAO_STORAGE | SFGAO_CANRENAME | SFGAO_CANDELETE | + SFGAO_READONLY | SFGAO_STREAM | SFGAO_FOLDER; +static_assert(dwDefaultAttributeMask == 0x2044003B, "Unexpected default attribute mask"); + + +struct TmpFile +{ + WCHAR Buffer[MAX_PATH] = {}; + + void Create(LPCWSTR Folder) + { + GetTempFileNameW(Folder, L"SHG", 0, Buffer); + } + + ~TmpFile() + { + if (Buffer[0]) + { + SetFileAttributesW(Buffer, FILE_ATTRIBUTE_NORMAL); + DeleteFileW(Buffer); + } + } +}; + + +CComPtr<IShellFolder> _BindToObject(PCUIDLIST_ABSOLUTE pidl) +{ + CComPtr<IShellFolder> spDesktop, spResult; + HRESULT hr = SHGetDesktopFolder(&spDesktop); + if (FAILED_UNEXPECTEDLY(hr)) + return spResult; + + if (FAILED_UNEXPECTEDLY(spDesktop->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, &spResult)))) + { + spResult.Release(); + } + return spResult; +} + + +static void ok_attributes_(IDataObject* pDataObject, HRESULT expect_hr, DWORD expect_mask, DWORD expect_attr, UINT expect_items) +{ + FORMATETC fmt = { g_DataObjectAttributes, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; + STGMEDIUM medium = {}; + + HRESULT hr = pDataObject->GetData(&fmt, &medium); + winetest_ok(hr == expect_hr, "Unexpected result from GetData, got 0x%lx, expected 0x%lx\n", hr, expect_hr); + + if (hr == expect_hr && expect_hr == S_OK) + { + LPVOID blob = GlobalLock(medium.hGlobal); + winetest_ok(blob != nullptr, "Failed to lock hGlobal\n"); + if (blob) + { + SIZE_T size = GlobalSize(medium.hGlobal); + winetest_ok(size == 0xc, "Unexpected size, got %lu, expected 12\n", size); + if (size == 0xc) + { + PDWORD data = (PDWORD)blob; + winetest_ok(data[0] == expect_mask, "Unexpected mask, got 0x%lx, expected 0x%lx\n", data[0], expect_mask); + winetest_ok(data[1] == expect_attr, "Unexpected attr, got 0x%lx, expected 0x%lx\n", data[1], expect_attr); + winetest_ok(data[2] == expect_items, "Unexpected item count, got %lu, expected %u\n", data[2], expect_items); + } + GlobalUnlock(medium.hGlobal); + } + } + + if (SUCCEEDED(hr)) + ReleaseStgMedium(&medium); +} + + +#define ok_attributes (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : ok_attributes_ +#define ok_hr_ret(x, y) ok_hr(x, y); if (x != y) return + +static void test_SpecialCases() +{ + DWORD dwAttributeMask = 0, dwAttributes = 123; + UINT cItems = 123; + + HRESULT hr = SHGetAttributesFromDataObject(nullptr, dwAttributeMask, &dwAttributes, &cItems); + ok_hr(hr, S_OK); + ok_int(dwAttributes, 0); + ok_int(cItems, 0); + + cItems = 123; + hr = SHGetAttributesFromDataObject(nullptr, dwAttributeMask, nullptr, &cItems); + ok_hr(hr, S_OK); + ok_int(cItems, 0); + + dwAttributes = 123; + hr = SHGetAttributesFromDataObject(nullptr, dwAttributeMask, &dwAttributes, nullptr); + ok_hr(hr, S_OK); + ok_int(dwAttributes, 0); +} + + +static void test_AttributesRegistration() +{ + WCHAR Buffer[MAX_PATH] = {}; + + GetModuleFileNameW(NULL, Buffer, _countof(Buffer)); + CComHeapPtr<ITEMIDLIST_ABSOLUTE> spPath(ILCreateFromPathW(Buffer)); + + ok(spPath != nullptr, "Unable to create pidl from %S\n", Buffer); + if (spPath == nullptr) + return; + + SFGAOF attributes = dwDefaultAttributeMask; + HRESULT hr; + { + CComPtr<IShellFolder> spFolder; + PCUITEMID_CHILD child; + hr = SHBindToParent(spPath, IID_PPV_ARG(IShellFolder, &spFolder), &child); + ok_hr_ret(hr, S_OK); + + hr = spFolder->GetAttributesOf(1, &child, &attributes); + ok_hr_ret(hr, S_OK); + + attributes &= dwDefaultAttributeMask; + } + + CComHeapPtr<ITEMIDLIST> parent(ILClone(spPath)); + PCIDLIST_RELATIVE child = ILFindLastID(spPath); + ILRemoveLastID(parent); + + CComPtr<IDataObject> spDataObject; + hr = CIDLData_CreateFromIDArray(parent, 1, &child, &spDataObject); + ok_hr_ret(hr, S_OK); + + /* Not registered yet */ + ok_attributes(spDataObject, DV_E_FORMATETC, 0, 0, 0); + + /* Ask for attributes, without specifying any */ + DWORD dwAttributeMask = 0, dwAttributes = 0; + UINT cItems = 0; + hr = SHGetAttributesFromDataObject(spDataObject, dwAttributeMask, &dwAttributes, &cItems); + ok_hr(hr, S_OK); + + /* Now there are attributes registered */ + ok_attributes(spDataObject, S_OK, dwDefaultAttributeMask, attributes, 1); + + // Now add an additional mask value (our exe should have a propsheet!) + dwAttributeMask = SFGAO_HASPROPSHEET; + dwAttributes = 0; + cItems = 0; + hr = SHGetAttributesFromDataObject(spDataObject, dwAttributeMask, &dwAttributes, &cItems); + ok_hr(hr, S_OK); + + // Observe that this is now also cached + ok_attributes(spDataObject, S_OK, dwDefaultAttributeMask | SFGAO_HASPROPSHEET, attributes | SFGAO_HASPROPSHEET, 1); +} + +static void test_MultipleFiles() +{ + TmpFile TmpFile1, TmpFile2, TmpFile3; + + CComHeapPtr<ITEMIDLIST> pidl_tmpfolder; + CComHeapPtr<ITEMIDLIST> pidl1, pidl2, pidl3; + + ITEMIDLIST* items[3] = {}; + SFGAOF attributes_first = dwDefaultAttributeMask; + SFGAOF attributes2 = dwDefaultAttributeMask; + SFGAOF attributes3 = dwDefaultAttributeMask; + SFGAOF attributes_last = dwDefaultAttributeMask; + + HRESULT hr; + { + WCHAR TempFolder[MAX_PATH] = {}; + GetTempPathW(_countof(TempFolder), TempFolder); + + // Create temp files + TmpFile1.Create(TempFolder); + TmpFile2.Create(TempFolder); + TmpFile3.Create(TempFolder); + + // Last file is read-only + SetFileAttributesW(TmpFile3.Buffer, FILE_ATTRIBUTE_READONLY); + + hr = SHParseDisplayName(TempFolder, NULL, &pidl_tmpfolder, NULL, NULL); + ok_hr_ret(hr, S_OK); + + CComPtr<IShellFolder> spFolder = _BindToObject(pidl_tmpfolder); + ok(!!spFolder, "Unable to bind to tmp folder\n"); + if (!spFolder) + return; + + hr = spFolder->ParseDisplayName(NULL, 0, PathFindFileNameW(TmpFile1.Buffer), NULL, &pidl1, NULL); + ok_hr_ret(hr, S_OK); + + hr = spFolder->ParseDisplayName(NULL, 0, PathFindFileNameW(TmpFile2.Buffer), NULL, &pidl2, NULL); + ok_hr_ret(hr, S_OK); + + hr = spFolder->ParseDisplayName(NULL, 0, PathFindFileNameW(TmpFile3.Buffer), NULL, &pidl3, NULL); + ok_hr_ret(hr, S_OK); + + items[0] = pidl1; + items[1] = pidl2; + items[2] = pidl3; + + // Query file attributes + hr = spFolder->GetAttributesOf(1, items, &attributes_first); + ok_hr(hr, S_OK); + + hr = spFolder->GetAttributesOf(2, items, &attributes2); + ok_hr(hr, S_OK); + + hr = spFolder->GetAttributesOf(3, items, &attributes3); + ok_hr(hr, S_OK); + + hr = spFolder->GetAttributesOf(1, items + 2, &attributes_last); + ok_hr(hr, S_OK); + + // Ignore any non-default attributes + attributes_first &= dwDefaultAttributeMask; + attributes2 &= dwDefaultAttributeMask; + attributes3 &= dwDefaultAttributeMask; + attributes_last &= dwDefaultAttributeMask; + } + + // Only 'single' files have the stream attribute set + ok(attributes_first & SFGAO_STREAM, "Expected SFGAO_STREAM on attributes_first (0x%lx)\n", attributes_first); + ok(!(attributes2 & SFGAO_STREAM), "Expected no SFGAO_STREAM on attributes2 (0x%lx)\n", attributes2); + ok(!(attributes3 & SFGAO_STREAM), "Expected no SFGAO_STREAM on attributes3 (0x%lx)\n", attributes3); + ok(attributes_last & SFGAO_STREAM, "Expected SFGAO_STREAM on attributes_last (0x%lx)\n", attributes_last); + + // Only attributes common on all are returned, so only the last has the readonly bit set! + ok(!(attributes_first & SFGAO_READONLY), "Expected no SFGAO_READONLY on attributes_first (0x%lx)\n", attributes_first); + ok(!(attributes2 & SFGAO_READONLY), "Expected no SFGAO_READONLY on attributes2 (0x%lx)\n", attributes2); + ok(!(attributes3 & SFGAO_READONLY), "Expected no SFGAO_READONLY on attributes3 (0x%lx)\n", attributes3); + ok(attributes_last & SFGAO_READONLY, "Expected SFGAO_READONLY on attributes_last (0x%lx)\n", attributes_last); + + // The actual tests + { + // Just the first file + CComPtr<IDataObject> spDataObject; + hr = CIDLData_CreateFromIDArray(pidl_tmpfolder, 1, items, &spDataObject); + ok_hr_ret(hr, S_OK); + + DWORD dwAttributeMask = 0, dwAttributes = 123; + UINT cItems = 123; + hr = SHGetAttributesFromDataObject(spDataObject, dwAttributeMask, &dwAttributes, &cItems); + ok_hr(hr, S_OK); + ok_attributes(spDataObject, S_OK, dwDefaultAttributeMask, attributes_first, 1); + } + + { + // First 2 files + CComPtr<IDataObject> spDataObject; + hr = CIDLData_CreateFromIDArray(pidl_tmpfolder, 2, items, &spDataObject); + ok_hr_ret(hr, S_OK); + + DWORD dwAttributeMask = 0, dwAttributes = 123; + UINT cItems = 123; + hr = SHGetAttributesFromDataObject(spDataObject, dwAttributeMask, &dwAttributes, &cItems); + ok_hr(hr, S_OK); + ok_attributes(spDataObject, S_OK, dwDefaultAttributeMask, attributes2, 2); + } + + { + // All 3 files + CComPtr<IDataObject> spDataObject; + hr = CIDLData_CreateFromIDArray(pidl_tmpfolder, 3, items, &spDataObject); + ok_hr_ret(hr, S_OK); + + DWORD dwAttributeMask = 0, dwAttributes = 123; + UINT cItems = 123; + hr = SHGetAttributesFromDataObject(spDataObject, dwAttributeMask, &dwAttributes, &cItems); + ok_hr(hr, S_OK); + ok_attributes(spDataObject, S_OK, dwDefaultAttributeMask, attributes3, 3); + } + + { + // Only the last file + CComPtr<IDataObject> spDataObject; + hr = CIDLData_CreateFromIDArray(pidl_tmpfolder, 1, items + 2, &spDataObject); + ok_hr_ret(hr, S_OK); + + DWORD dwAttributeMask = 0, dwAttributes = 123; + UINT cItems = 123; + hr = SHGetAttributesFromDataObject(spDataObject, dwAttributeMask, &dwAttributes, &cItems); + ok_hr(hr, S_OK); + ok_attributes(spDataObject, S_OK, dwDefaultAttributeMask, attributes_last, 1); + } +} + +START_TEST(SHGetAttributesFromDataObject) +{ + HRESULT hr; + + hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + ok_hr(hr, S_OK); + if (!SUCCEEDED(hr)) + return; + + g_DataObjectAttributes = (CLIPFORMAT)RegisterClipboardFormatW(L"DataObjectAttributes"); + ok(g_DataObjectAttributes != 0, "Unable to register DataObjectAttributes\n"); + + test_SpecialCases(); + test_AttributesRegistration(); + test_MultipleFiles(); + + CoUninitialize(); +} diff --git a/modules/rostests/apitests/shell32/testlist.c b/modules/rostests/apitests/shell32/testlist.c index 01219082ba3..7c306faa1a7 100644 --- a/modules/rostests/apitests/shell32/testlist.c +++ b/modules/rostests/apitests/shell32/testlist.c @@ -28,6 +28,7 @@ extern void func_ShellExecuteEx(void); extern void func_ShellExecuteW(void); extern void func_ShellHook(void); extern void func_ShellState(void); +extern void func_SHGetAttributesFromDataObject(void); extern void func_SHLimitInputEdit(void); extern void func_SHParseDisplayName(void); @@ -58,6 +59,7 @@ const struct test winetest_testlist[] = { "ShellExecuteW", func_ShellExecuteW }, { "ShellHook", func_ShellHook }, { "ShellState", func_ShellState }, + { "SHGetAttributesFromDataObject", func_SHGetAttributesFromDataObject }, { "SHLimitInputEdit", func_SHLimitInputEdit }, { "SHParseDisplayName", func_SHParseDisplayName }, { 0, 0 } diff --git a/sdk/include/psdk/shlobj.h b/sdk/include/psdk/shlobj.h index 422714c7b9d..f8be3e7d299 100644 --- a/sdk/include/psdk/shlobj.h +++ b/sdk/include/psdk/shlobj.h @@ -2476,6 +2476,18 @@ SHRunControlPanel( _In_ LPCWSTR commandLine, _In_opt_ HWND parent); +/**************************************************************************** + * SHGetAttributesFromDataObject + */ + +HRESULT +WINAPI +SHGetAttributesFromDataObject( + _In_opt_ IDataObject* pdo, + DWORD dwAttributeMask, + _Out_opt_ DWORD* pdwAttributes, + _Out_opt_ UINT* pcItems); + /**************************************************************************** * SHOpenWithDialog */ diff --git a/sdk/include/reactos/shellutils.h b/sdk/include/reactos/shellutils.h index ae8f8dd2519..2dcbd8037b0 100644 --- a/sdk/include/reactos/shellutils.h +++ b/sdk/include/reactos/shellutils.h @@ -559,6 +559,71 @@ static inline PCUIDLIST_RELATIVE HIDA_GetPIDLItem(CIDA const* pida, SIZE_T i) #ifdef __cplusplus +DECLSPEC_SELECTANY CLIPFORMAT g_cfHIDA = NULL; + +// Allow to use the HIDA from an IDataObject without copying it +struct CDataObjectHIDA +{ +private: + STGMEDIUM m_medium; + CIDA* m_cida; + HRESULT m_hr; + +public: + explicit CDataObjectHIDA(IDataObject* pDataObject) + : m_cida(nullptr) + { + m_medium.tymed = TYMED_NULL; + + if (g_cfHIDA == NULL) + { + g_cfHIDA = (CLIPFORMAT)RegisterClipboardFormatW(CFSTR_SHELLIDLISTW); + } + FORMATETC fmt = { g_cfHIDA, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; + + m_hr = pDataObject->GetData(&fmt, &m_medium); + if (FAILED(m_hr)) + { + m_medium.tymed = TYMED_NULL; + return; + } + + m_cida = (CIDA*)::GlobalLock(m_medium.hGlobal); + if (m_cida == nullptr) + { + m_hr = E_UNEXPECTED; + } + } + + ~CDataObjectHIDA() + { + if (m_cida) + ::GlobalUnlock(m_cida); + + ReleaseStgMedium(&m_medium); + } + + HRESULT hr() const + { + return m_hr; + } + + operator bool() const + { + return m_cida != nullptr; + } + + operator const CIDA* () const + { + return m_cida; + } + + const CIDA* operator->() const + { + return m_cida; + } +}; + inline HRESULT DataObject_GetData(IDataObject* pDataObject, CLIPFORMAT clipformat, PVOID pBuffer, SIZE_T dwBufferSize) {
3 years, 1 month
1
0
0
0
[reactos] 01/01: [DRWTSN32] Implement arm context reading
by Mark Jansen
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1f44552d36f41397991d4…
commit 1f44552d36f41397991d4594edada88cd062a107 Author: Mark Jansen <mark.jansen(a)reactos.org> AuthorDate: Sat Jun 5 22:13:22 2021 +0200 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Mon Nov 15 19:57:35 2021 +0100 [DRWTSN32] Implement arm context reading CORE-17605 CORE-17604 --- base/applications/drwtsn32/drwtsn32.cpp | 2 +- base/applications/drwtsn32/main.cpp | 24 +++++++++++++++--- base/applications/drwtsn32/stacktrace.cpp | 42 ++++++++++++++++++++----------- base/applications/drwtsn32/sysinfo.cpp | 2 +- 4 files changed, 51 insertions(+), 19 deletions(-) diff --git a/base/applications/drwtsn32/drwtsn32.cpp b/base/applications/drwtsn32/drwtsn32.cpp index 598e4f0b6b6..c36e97b8558 100644 --- a/base/applications/drwtsn32/drwtsn32.cpp +++ b/base/applications/drwtsn32/drwtsn32.cpp @@ -2,7 +2,7 @@ * PROJECT: Dr. Watson crash reporter * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+
) * PURPOSE: Debug loop - * COPYRIGHT: Copyright 2017 Mark Jansen (mark.jansen(a)reactos.org) + * COPYRIGHT: Copyright 2017 Mark Jansen <mark.jansen(a)reactos.org> */ #include "precomp.h" diff --git a/base/applications/drwtsn32/main.cpp b/base/applications/drwtsn32/main.cpp index f49346ec16a..277542153f2 100644 --- a/base/applications/drwtsn32/main.cpp +++ b/base/applications/drwtsn32/main.cpp @@ -2,7 +2,7 @@ * PROJECT: Dr. Watson crash reporter * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+
) * PURPOSE: Entrypoint / main print function - * COPYRIGHT: Copyright 2017 Mark Jansen (mark.jansen(a)reactos.org) + * COPYRIGHT: Copyright 2017 Mark Jansen <mark.jansen(a)reactos.org> */ #include "precomp.h" @@ -62,10 +62,15 @@ static void PrintThread(FILE* output, DumpData& data, DWORD tid, ThreadData& thr xfprintf(output, "eax:%p ebx:%p ecx:%p edx:%p esi:%p edi:%p" NEWLINE, ctx.Eax, ctx.Ebx, ctx.Ecx, ctx.Edx, ctx.Esi, ctx.Edi); #elif defined(_M_AMD64) - xfprintf(output, "rax:%p rbx:%p rcx:%p rdx:%p rsi:%p rdi:%p" NEWLINE, - ctx.Rax, ctx.Rbx, ctx.Rcx, ctx.Rdx, ctx.Rsi, ctx.Rdi); + xfprintf(output, "rax:%p rbx:%p rcx:%p rdx:%p rsi:%p rdi:%p rbp:%p rsp:%p" NEWLINE, + ctx.Rax, ctx.Rbx, ctx.Rcx, ctx.Rdx, ctx.Rsi, ctx.Rdi, ctx.Rbp, ctx.Rsp); xfprintf(output, "r8:%p r9:%p r10:%p r11:%p r12:%p r13:%p r14:%p r15:%p" NEWLINE, ctx.R8, ctx.R9, ctx.R10, ctx.R11, ctx.R12, ctx.R13, ctx.R14, ctx.R15); +#elif defined(_M_ARM) + xfprintf(output, "r0:%p r1:%p r2:%p r3:%p r4:%p r5:%p r6:%p" NEWLINE, + ctx.R0, ctx.R1, ctx.R2, ctx.R3, ctx.R4, ctx.R5, ctx.R6); + xfprintf(output, "r7:%p r8:%p r9:%p r10:%p r11:%p r12:%p" NEWLINE, + ctx.R7, ctx.R8, ctx.R9, ctx.R10, ctx.R11, ctx.R12); #else #error Unknown architecture #endif @@ -79,6 +84,9 @@ static void PrintThread(FILE* output, DumpData& data, DWORD tid, ThreadData& thr #elif defined(_M_AMD64) xfprintf(output, "rip:%p rsp:%p rbp:%p" NEWLINE, ctx.Rip, ctx.Rsp, ctx.Rbp); +#elif defined(_M_ARM) + xfprintf(output, "sp:%p lr:%p pc:%p cpsr:%p" NEWLINE, + ctx.Sp, ctx.Lr, ctx.Pc, ctx.Cpsr); #else #error Unknown architecture #endif @@ -89,6 +97,16 @@ static void PrintThread(FILE* output, DumpData& data, DWORD tid, ThreadData& thr #if defined(_M_IX86) || defined(_M_AMD64) xfprintf(output, "dr0:%p dr1:%p dr2:%p dr3:%p dr6:%p dr7:%p" NEWLINE, ctx.Dr0, ctx.Dr1, ctx.Dr2, ctx.Dr3, ctx.Dr6, ctx.Dr7); +#elif defined(_M_ARM) + for (int n = 0; n < ARM_MAX_BREAKPOINTS; ++n) + xfprintf(output, "Bvr%d:%p%s", n, ctx.Bvr[n], ((n + 1) == ARM_MAX_BREAKPOINTS) ? NEWLINE : " "); + for (int n = 0; n < ARM_MAX_BREAKPOINTS; ++n) + xfprintf(output, "Bcr%d:%p%s", n, ctx.Bcr[n], ((n + 1) == ARM_MAX_BREAKPOINTS) ? NEWLINE : " "); + + for (int n = 0; n < ARM_MAX_WATCHPOINTS; ++n) + xfprintf(output, "Wvr%d:%p%s", n, ctx.Wvr[n], ((n + 1) == ARM_MAX_WATCHPOINTS) ? NEWLINE : " "); + for (int n = 0; n < ARM_MAX_WATCHPOINTS; ++n) + xfprintf(output, "Wcr%d:%p%s", n, ctx.Wcr[n], ((n + 1) == ARM_MAX_WATCHPOINTS) ? NEWLINE : " "); #else #error Unknown architecture #endif diff --git a/base/applications/drwtsn32/stacktrace.cpp b/base/applications/drwtsn32/stacktrace.cpp index cbd9697ed3b..4742349117b 100644 --- a/base/applications/drwtsn32/stacktrace.cpp +++ b/base/applications/drwtsn32/stacktrace.cpp @@ -2,7 +2,7 @@ * PROJECT: Dr. Watson crash reporter * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+
) * PURPOSE: Print a stacktrace - * COPYRIGHT: Copyright 2017,2018 Mark Jansen (mark.jansen(a)reactos.org) + * COPYRIGHT: Copyright 2017,2018 Mark Jansen <mark.jansen(a)reactos.org> */ #include "precomp.h" @@ -38,25 +38,37 @@ void PrintStackBacktrace(FILE* output, DumpData& data, ThreadData& thread) DWORD MachineType; STACKFRAME64 StackFrame = { { 0 } }; -#ifdef _M_X64 - MachineType = IMAGE_FILE_MACHINE_AMD64; - StackFrame.AddrPC.Offset = thread.Context.Rip; StackFrame.AddrPC.Mode = AddrModeFlat; - StackFrame.AddrStack.Offset = thread.Context.Rsp; - StackFrame.AddrStack.Mode = AddrModeFlat; - StackFrame.AddrFrame.Offset = thread.Context.Rbp; + StackFrame.AddrReturn.Mode = AddrModeFlat; StackFrame.AddrFrame.Mode = AddrModeFlat; -#else + StackFrame.AddrStack.Mode = AddrModeFlat; + StackFrame.AddrBStore.Mode = AddrModeFlat; + + +#if defined(_M_IX86) MachineType = IMAGE_FILE_MACHINE_I386; - StackFrame.AddrPC.Offset = thread.Context.Eip; - StackFrame.AddrPC.Mode = AddrModeFlat; + StackFrame.AddrPC.Offset = thread.Context.Eip; StackFrame.AddrStack.Offset = thread.Context.Esp; - StackFrame.AddrStack.Mode = AddrModeFlat; StackFrame.AddrFrame.Offset = thread.Context.Ebp; - StackFrame.AddrFrame.Mode = AddrModeFlat; +#elif defined(_M_AMD64) + MachineType = IMAGE_FILE_MACHINE_AMD64; + StackFrame.AddrPC.Offset = thread.Context.Rip; + StackFrame.AddrStack.Offset = thread.Context.Rsp; + StackFrame.AddrFrame.Offset = thread.Context.Rbp; +#elif defined(_M_ARM) + MachineType = IMAGE_FILE_MACHINE_ARMNT; + StackFrame.AddrPC.Offset = thread.Context.Pc; + StackFrame.AddrStack.Offset = thread.Context.Sp; + StackFrame.AddrFrame.Offset = thread.Context.R11; +#elif defined(_M_ARM64) + MachineType = IMAGE_FILE_MACHINE_ARM64; + StackFrame.AddrPC.Offset = thread.Context.Pc; + StackFrame.AddrStack.Offset = thread.Context.Sp; + StackFrame.AddrFrame.Offset = thread.Context.u.s.Fp; +#else +#error "Unknown architecture" #endif - #define STACKWALK_MAX_NAMELEN 512 char buf[sizeof(SYMBOL_INFO) + STACKWALK_MAX_NAMELEN] = {0}; SYMBOL_INFO* sym = (SYMBOL_INFO *)buf; @@ -64,7 +76,7 @@ void PrintStackBacktrace(FILE* output, DumpData& data, ThreadData& thread) LONG RecursionDepth = 0; sym->SizeOfStruct = sizeof(sym); - /* FIXME: dump x bytes at EIP here + disasm it! */ + /* FIXME: dump x bytes at PC here + disasm it! */ xfprintf(output, NEWLINE "*----> Stack Back Trace <----*" NEWLINE NEWLINE); bool first = true; @@ -116,6 +128,8 @@ void PrintStackBacktrace(FILE* output, DumpData& data, ThreadData& thread) ULONG_PTR stackPointer = thread.Context.Esp; #elif defined(_M_AMD64) ULONG_PTR stackPointer = thread.Context.Rsp; +#elif defined(_M_ARM) || defined(_M_ARM64) + ULONG_PTR stackPointer = thread.Context.Sp; #else #error Unknown architecture #endif diff --git a/base/applications/drwtsn32/sysinfo.cpp b/base/applications/drwtsn32/sysinfo.cpp index bc96af0d00f..9884758303e 100644 --- a/base/applications/drwtsn32/sysinfo.cpp +++ b/base/applications/drwtsn32/sysinfo.cpp @@ -2,7 +2,7 @@ * PROJECT: Dr. Watson crash reporter * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+
) * PURPOSE: Output system info - * COPYRIGHT: Copyright 2017 Mark Jansen (mark.jansen(a)reactos.org) + * COPYRIGHT: Copyright 2017 Mark Jansen <mark.jansen(a)reactos.org> */ #include "precomp.h"
3 years, 1 month
1
0
0
0
[reactos] 01/01: [WIN32K] Fix a weird control character in dibobj.c CreateDIBPalette() CORE-17848
by Joachim Henze
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f028ca5b083524cc85fd7…
commit f028ca5b083524cc85fd75467b6f8db4e37f0164 Author: Joachim Henze <Joachim.Henze(a)reactos.org> AuthorDate: Mon Nov 15 03:04:37 2021 +0100 Commit: Joachim Henze <Joachim.Henze(a)reactos.org> CommitDate: Mon Nov 15 03:05:20 2021 +0100 [WIN32K] Fix a weird control character in dibobj.c CreateDIBPalette() CORE-17848 --- win32ss/gdi/ntgdi/dibobj.c | 1 - 1 file changed, 1 deletion(-) diff --git a/win32ss/gdi/ntgdi/dibobj.c b/win32ss/gdi/ntgdi/dibobj.c index 33f20d98599..e8d3acc3d2d 100644 --- a/win32ss/gdi/ntgdi/dibobj.c +++ b/win32ss/gdi/ntgdi/dibobj.c @@ -149,7 +149,6 @@ CreateDIBPalette( /* Set the RGB value in the palette */ PALETTE_vSetRGBColorForIndex(ppal, i, crColor); - } } else
3 years, 1 month
1
0
0
0
[reactos] 02/02: [RICHED20_WINETEST] Re-enable crashing test. CORE-16799
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=68c9ac2a826bccccbfbb6…
commit 68c9ac2a826bccccbfbb6994d4eb2ddba4e49511 Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Fri Oct 15 22:21:57 2021 -0400 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Sun Nov 14 20:22:34 2021 -0500 [RICHED20_WINETEST] Re-enable crashing test. CORE-16799 --- modules/rostests/winetests/riched20/richole.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/modules/rostests/winetests/riched20/richole.c b/modules/rostests/winetests/riched20/richole.c index 6de6c02901a..492bdc3fa9a 100644 --- a/modules/rostests/winetests/riched20/richole.c +++ b/modules/rostests/winetests/riched20/richole.c @@ -113,7 +113,6 @@ static ULONG get_refcount(IUnknown *iface) return IUnknown_Release(iface); } -#if 0 /*avoid CORE-16799*/ #define CHECK_TYPEINFO(disp,expected_riid) _check_typeinfo((IDispatch *)disp, expected_riid, __LINE__) static void _check_typeinfo(IDispatch* disp, REFIID expected_riid, int line) { @@ -138,15 +137,12 @@ static void _check_typeinfo(IDispatch* disp, REFIID expected_riid, int line) ITypeInfo_ReleaseTypeAttr(typeinfo, typeattr); ITypeInfo_Release(typeinfo); } -#endif static void test_Interfaces(void) { IRichEditOle *reOle = NULL, *reOle1 = NULL; ITextDocument *txtDoc = NULL; -#if 0 /*avoid CORE-16799*/ ITextDocument2Old *txtDoc2Old = NULL; -#endif ITextSelection *txtSel = NULL, *txtSel2; IUnknown *punk; HRESULT hres; @@ -174,9 +170,7 @@ static void test_Interfaces(void) (void **) &txtDoc); ok(hres == S_OK, "IRichEditOle_QueryInterface\n"); ok(txtDoc != NULL, "IRichEditOle_QueryInterface\n"); -#if 0 /*avoid CORE-16799*/ CHECK_TYPEINFO(txtDoc, &IID_ITextDocument); -#endif hres = ITextDocument_GetSelection(txtDoc, NULL); ok(hres == E_INVALIDARG, "ITextDocument_GetSelection: 0x%x\n", hres); @@ -228,7 +222,6 @@ static void test_Interfaces(void) hres = IRichEditOle_QueryInterface(reOle, &IID_IOleInPlaceSite, (void **) &punk); ok(hres == E_NOINTERFACE, "IRichEditOle_QueryInterface\n"); -#if 0 /*avoid CORE-16799*/ hres = IRichEditOle_QueryInterface(reOle, &IID_ITextDocument2Old, (void **)&txtDoc2Old); ok(hres == S_OK, "IRichEditOle_QueryInterface\n"); ok(txtDoc2Old != NULL, "IRichEditOle_QueryInterface\n"); @@ -238,7 +231,6 @@ static void test_Interfaces(void) CHECK_TYPEINFO(txtDoc2Old, &IID_ITextDocument); ITextDocument2Old_Release(txtDoc2Old); -#endif ITextDocument_Release(txtDoc); IRichEditOle_Release(reOle); @@ -253,7 +245,6 @@ static void test_Interfaces(void) ITextSelection_Release(txtSel); -#if 0 /*avoid CORE-16799*/ w = new_richedit(NULL); res = SendMessageA(w, EM_GETOLEINTERFACE, 0, (LPARAM)&reOle); ok(res, "SendMessage\n"); @@ -266,7 +257,6 @@ static void test_Interfaces(void) ITextDocument2Old_Release(txtDoc2Old); IRichEditOle_Release(reOle); DestroyWindow(w); -#endif } static void test_ITextDocument_Open(void)
3 years, 1 month
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
9
10
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
Results per page:
10
25
50
100
200