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
May 2020
----- 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
28 participants
193 discussions
Start a n
N
ew thread
[reactos] 03/06: [SHELL32] Update CFileSysEnum to be maintaineable CORE-16908
by Mark Jansen
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b1003ae909f5a76d38944…
commit b1003ae909f5a76d38944852c82c5bdd863ab15d Author: Mark Jansen <mark.jansen(a)reactos.org> AuthorDate: Mon Apr 27 16:11:21 2020 +0200 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sun May 17 17:09:04 2020 +0200 [SHELL32] Update CFileSysEnum to be maintaineable CORE-16908 --- dll/win32/shell32/folders/CFSFolder.cpp | 264 ++++++++++++++++++-------------- dll/win32/shell32/folders/CFSFolder.h | 36 ++--- 2 files changed, 161 insertions(+), 139 deletions(-) diff --git a/dll/win32/shell32/folders/CFSFolder.cpp b/dll/win32/shell32/folders/CFSFolder.cpp index cfba27e0008..266a7478367 100644 --- a/dll/win32/shell32/folders/CFSFolder.cpp +++ b/dll/win32/shell32/folders/CFSFolder.cpp @@ -1,53 +1,23 @@ - /* - * file system folder - * - * Copyright 1997 Marcus Meissner - * Copyright 1998, 1999, 2002 Juergen Schmied - * Copyright 2019 Katayama Hirofumi MZ - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * PROJECT: shell32 + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: file system folder + * COPYRIGHT: Copyright 1997 Marcus Meissner + * Copyright 1998, 1999, 2002 Juergen Schmied + * Copyright 2019 Katayama Hirofumi MZ + * Copyright 2020 Mark Jansen (mark.jansen(a)reactos.org) */ #include <precomp.h> WINE_DEFAULT_DEBUG_CHANNEL (shell); -HKEY OpenKeyFromFileType(PCUIDLIST_RELATIVE pidl, LPCWSTR KeyName) -{ - HKEY hkey; +static HRESULT SHELL32_GetCLSIDForDirectory(LPCWSTR pwszDir, LPCWSTR KeyName, CLSID* pclsidFolder); - if (!_ILIsValue(pidl)) - { - ERR("Invalid pidl!\n"); - return NULL; - } - FileStructW* pDataW = _ILGetFileStructW(pidl); - if (!pDataW) - { - ERR("Invalid pidl!\n"); - return NULL; - } - - LPWSTR pExtension = PathFindExtensionW(pDataW->wszName); - if (!pExtension || *pExtension == NULL) - { - WARN("No extension for %S!\n", pDataW->wszName); - return NULL; - } +HKEY OpenKeyFromFileType(LPWSTR pExtension, LPCWSTR KeyName) +{ + HKEY hkey; WCHAR FullName[MAX_PATH]; DWORD dwSize = sizeof(FullName); @@ -60,7 +30,7 @@ HKEY OpenKeyFromFileType(PCUIDLIST_RELATIVE pidl, LPCWSTR KeyName) res = RegGetValueW(HKEY_CLASSES_ROOT, pExtension, NULL, RRF_RT_REG_SZ, NULL, FullName, &dwSize); if (res) { - WARN("Failed to get progid for file %S, extension %S (%x), address %x, pidl: %x, error %d\n", pDataW->wszName, pExtension, pExtension, &dwSize, pidl, res); + WARN("Failed to get progid for extension %S (%x), error %d\n", pExtension, pExtension, res); return NULL; } @@ -75,9 +45,33 @@ HKEY OpenKeyFromFileType(PCUIDLIST_RELATIVE pidl, LPCWSTR KeyName) return hkey; } -HRESULT GetCLSIDForFileType(PCUIDLIST_RELATIVE pidl, LPCWSTR KeyName, CLSID* pclsid) +LPWSTR ExtensionFromPidl(PCUIDLIST_RELATIVE pidl) { - HKEY hkeyProgId = OpenKeyFromFileType(pidl, KeyName); + if (!_ILIsValue(pidl)) + { + ERR("Invalid pidl!\n"); + return NULL; + } + + FileStructW* pDataW = _ILGetFileStructW(pidl); + if (!pDataW) + { + ERR("Invalid pidl!\n"); + return NULL; + } + + LPWSTR pExtension = PathFindExtensionW(pDataW->wszName); + if (!pExtension || *pExtension == UNICODE_NULL) + { + WARN("No extension for %S!\n", pDataW->wszName); + return NULL; + } + return pExtension; +} + +HRESULT GetCLSIDForFileTypeFromExtension(LPWSTR pExtension, LPCWSTR KeyName, CLSID* pclsid) +{ + HKEY hkeyProgId = OpenKeyFromFileType(pExtension, KeyName); if (!hkeyProgId) { WARN("OpenKeyFromFileType failed for key %S\n", KeyName); @@ -130,6 +124,15 @@ HRESULT GetCLSIDForFileType(PCUIDLIST_RELATIVE pidl, LPCWSTR KeyName, CLSID* pcl return S_OK; } +HRESULT GetCLSIDForFileType(PCUIDLIST_RELATIVE pidl, LPCWSTR KeyName, CLSID* pclsid) +{ + LPWSTR pExtension = ExtensionFromPidl(pidl); + if (!pExtension) + return S_FALSE; + + return GetCLSIDForFileTypeFromExtension(pExtension, KeyName, pclsid); +} + static HRESULT getDefaultIconLocation(LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT uFlags) { @@ -293,7 +296,8 @@ HRESULT CFSExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, RE } else { - HKEY hkey = OpenKeyFromFileType(pidl, L"DefaultIcon"); + LPWSTR pExtension = ExtensionFromPidl(pidl); + HKEY hkey = pExtension ? OpenKeyFromFileType(pExtension, L"DefaultIcon") : NULL; if (!hkey) WARN("Could not open DefaultIcon key!\n"); @@ -342,98 +346,128 @@ including formatting a drive, reconnecting a network share drive, and requesting be inserted in a removable drive. */ -/*********************************************************************** -* IShellFolder implementation -*/ class CFileSysEnum : public CEnumIDListBase { - private: - public: - CFileSysEnum(); - ~CFileSysEnum(); - HRESULT WINAPI Initialize(LPWSTR sPathTarget, DWORD dwFlags); +private: + HRESULT _AddFindResult(LPWSTR sParentDir, const WIN32_FIND_DATAW& FindData, DWORD dwFlags) + { +#define SUPER_HIDDEN (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM) - BEGIN_COM_MAP(CFileSysEnum) - COM_INTERFACE_ENTRY_IID(IID_IEnumIDList, IEnumIDList) - END_COM_MAP() -}; + // Does it need special handling because it is hidden? + if (FindData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) + { + DWORD dwHidden = FindData.dwFileAttributes & SUPER_HIDDEN; -CFileSysEnum::CFileSysEnum() -{ -} + // Is it hidden, but are we not asked to include hidden? + if (dwHidden == FILE_ATTRIBUTE_HIDDEN && !(dwFlags & SHCONTF_INCLUDEHIDDEN)) + return S_OK; -CFileSysEnum::~CFileSysEnum() -{ -} + // Is it a system file, but are we not asked to include those? + if (dwHidden == SUPER_HIDDEN && !(dwFlags & SHCONTF_INCLUDESUPERHIDDEN)) + return S_OK; + } -HRESULT WINAPI CFileSysEnum::Initialize(LPWSTR lpszPath, DWORD dwFlags) -{ - WIN32_FIND_DATAW stffile; - HANDLE hFile; - WCHAR szPath[MAX_PATH]; - BOOL succeeded = TRUE; - static const WCHAR stars[] = { '*','.','*',0 }; - static const WCHAR dot[] = { '.',0 }; - static const WCHAR dotdot[] = { '.','.',0 }; + BOOL bDirectory = (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; + + LPITEMIDLIST pidl = NULL; + if (bDirectory) + { + if (dwFlags & SHCONTF_FOLDERS) + { + TRACE("(%p)-> (folder=%s)\n", this, debugstr_w(FindData.cFileName)); + pidl = _ILCreateFromFindDataW(&FindData); + } + } + else + { + if (dwFlags & SHCONTF_NONFOLDERS) + { + TRACE("(%p)-> (file =%s)\n", this, debugstr_w(FindData.cFileName)); + pidl = _ILCreateFromFindDataW(&FindData); + } + } + + if (pidl && !AddToEnumList(pidl)) + { + FAILED_UNEXPECTEDLY(E_FAIL); + return E_FAIL; + } - TRACE("(%p)->(path=%s flags=0x%08x)\n", this, debugstr_w(lpszPath), dwFlags); + return S_OK; + } - if(!lpszPath || !lpszPath[0]) return FALSE; +public: + CFileSysEnum() + { - wcscpy(szPath, lpszPath); - PathAddBackslashW(szPath); - wcscat(szPath,stars); + } - hFile = FindFirstFileW(szPath,&stffile); - if ( hFile != INVALID_HANDLE_VALUE ) + ~CFileSysEnum() { - BOOL findFinished = FALSE; + } -#define HIDDEN FILE_ATTRIBUTE_HIDDEN -#define SUPER_HIDDEN (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM) + HRESULT WINAPI Initialize(LPWSTR sPathTarget, DWORD dwFlags) + { + TRACE("(%p)->(path=%s flags=0x%08x)\n", this, debugstr_w(sPathTarget), dwFlags); + + if (!sPathTarget || !sPathTarget[0]) + { + FAILED_UNEXPECTEDLY(E_INVALIDARG); + return E_INVALIDARG; + } + + WCHAR szFindPattern[MAX_PATH]; + HRESULT hr = StringCchCopyW(szFindPattern, _countof(szFindPattern), sPathTarget); + if (FAILED_UNEXPECTEDLY(hr)) + return hr; + + /* FIXME: UNSAFE CRAP */ + PathAddBackslashW(szFindPattern); + + hr = StringCchCatW(szFindPattern, _countof(szFindPattern), L"*.*"); + if (FAILED_UNEXPECTEDLY(hr)) + return hr; + + + WIN32_FIND_DATAW FindData; + HANDLE hFind = FindFirstFileW(szFindPattern, &FindData); + if (hFind == INVALID_HANDLE_VALUE) + return HRESULT_FROM_WIN32(GetLastError()); do { - if ((stffile.dwFileAttributes & HIDDEN) == 0 || - ((dwFlags & SHCONTF_INCLUDEHIDDEN) && - (stffile.dwFileAttributes & SUPER_HIDDEN) == HIDDEN) || - ((dwFlags & SHCONTF_INCLUDESUPERHIDDEN) && - (stffile.dwFileAttributes & SUPER_HIDDEN) == SUPER_HIDDEN)) - { - LPITEMIDLIST pidl = NULL; + hr = _AddFindResult(sPathTarget, FindData, dwFlags); - if ( (stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - dwFlags & SHCONTF_FOLDERS && - strcmpW(stffile.cFileName, dot) && strcmpW(stffile.cFileName, dotdot)) - { - pidl = _ILCreateFromFindDataW(&stffile); - succeeded = succeeded && AddToEnumList(pidl); - } - else if (!(stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - && dwFlags & SHCONTF_NONFOLDERS) - { - pidl = _ILCreateFromFindDataW(&stffile); - succeeded = succeeded && AddToEnumList(pidl); - } - } - if (succeeded) + if (FAILED_UNEXPECTEDLY(hr)) + break; + + } while(FindNextFileW(hFind, &FindData)); + + if (SUCCEEDED(hr)) + { + DWORD dwError = GetLastError(); + if (dwError != ERROR_NO_MORE_FILES) { - if (!FindNextFileW(hFile, &stffile)) - { - if (GetLastError() == ERROR_NO_MORE_FILES) - findFinished = TRUE; - else - succeeded = FALSE; - } + hr = HRESULT_FROM_WIN32(dwError); + FAILED_UNEXPECTEDLY(hr); } - } while (succeeded && !findFinished); - FindClose(hFile); + } + TRACE("(%p)->(hr=0x%08x)\n", this, hr); + FindClose(hFind); + return hr; } - return succeeded; -} + BEGIN_COM_MAP(CFileSysEnum) + COM_INTERFACE_ENTRY_IID(IID_IEnumIDList, IEnumIDList) + END_COM_MAP() +}; + + +/*********************************************************************** + * IShellFolder implementation + */ CFSFolder::CFSFolder() { diff --git a/dll/win32/shell32/folders/CFSFolder.h b/dll/win32/shell32/folders/CFSFolder.h index c5f1d1bf2ae..c88f9f042e8 100644 --- a/dll/win32/shell32/folders/CFSFolder.h +++ b/dll/win32/shell32/folders/CFSFolder.h @@ -1,23 +1,11 @@ /* - * file system folder - * - * Copyright 1997 Marcus Meissner - * Copyright 1998, 1999, 2002 Juergen Schmied - * Copyright 2009 Andrew Hill - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * PROJECT: shell32 + * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) + * PURPOSE: file system folder + * COPYRIGHT: Copyright 1997 Marcus Meissner + * Copyright 1998, 1999, 2002 Juergen Schmied + * Copyright 2009 Andrew Hill + * Copyright 2020 Mark Jansen (mark.jansen(a)reactos.org) */ #ifndef _CFSFOLDER_H_ @@ -111,12 +99,12 @@ class CFSFolder : return S_OK; } - DECLARE_REGISTRY_RESOURCEID(IDR_SHELLFSFOLDER) - DECLARE_NOT_AGGREGATABLE(CFSFolder) + DECLARE_REGISTRY_RESOURCEID(IDR_SHELLFSFOLDER) + DECLARE_NOT_AGGREGATABLE(CFSFolder) - DECLARE_PROTECT_FINAL_CONSTRUCT() + DECLARE_PROTECT_FINAL_CONSTRUCT() - BEGIN_COM_MAP(CFSFolder) + BEGIN_COM_MAP(CFSFolder) COM_INTERFACE_ENTRY_IID(IID_IShellFolder2, IShellFolder2) COM_INTERFACE_ENTRY_IID(IID_IShellFolder, IShellFolder) COM_INTERFACE_ENTRY_IID(IID_IPersistFolder, IPersistFolder) @@ -125,7 +113,7 @@ class CFSFolder : COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersist) COM_INTERFACE_ENTRY_IID(IID_IShellFolderViewCB, IShellFolderViewCB) COM_INTERFACE_ENTRY_IID(IID_IItemNameLimits, IItemNameLimits) - END_COM_MAP() + END_COM_MAP() protected: HRESULT WINAPI GetCustomViewInfo(ULONG unknown, SFVM_CUSTOMVIEWINFO_DATA *data);
4 years, 7 months
1
0
0
0
[reactos] 02/06: [SHLWAPI] Fix SHRegGetCLSIDKeyW
by Mark Jansen
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ac215455bb6a76d2431d4…
commit ac215455bb6a76d2431d42b8ab5d1b78dcd35709 Author: Mark Jansen <mark.jansen(a)reactos.org> AuthorDate: Mon Apr 27 12:53:47 2020 +0200 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sun May 17 17:09:04 2020 +0200 [SHLWAPI] Fix SHRegGetCLSIDKeyW --- dll/win32/shlwapi/reg.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dll/win32/shlwapi/reg.c b/dll/win32/shlwapi/reg.c index a72f4c24e46..5f9c218a545 100644 --- a/dll/win32/shlwapi/reg.c +++ b/dll/win32/shlwapi/reg.c @@ -2422,16 +2422,32 @@ HRESULT WINAPI SHRegGetCLSIDKeyA(REFGUID guid, LPCSTR lpszValue, BOOL bUseHKCU, HRESULT WINAPI SHRegGetCLSIDKeyW(REFGUID guid, LPCWSTR lpszValue, BOOL bUseHKCU, BOOL bCreate, PHKEY phKey) { +#ifndef __REACTOS__ static const WCHAR szClassIdKey[] = { 'S','o','f','t','w','a','r','e','\\', 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\', 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', 'E','x','p','l','o','r','e','r','\\','C','L','S','I','D','\\' }; +#endif #define szClassIdKeyLen (sizeof(szClassIdKey)/sizeof(WCHAR)) WCHAR szKey[MAX_PATH]; DWORD dwRet; HKEY hkey; /* Create the key string */ +#ifdef __REACTOS__ + //
https://www.geoffchappell.com/studies/windows/shell/shlwapi/api/reg/reggetc…
+ WCHAR* ptr; + + wcscpy(szKey, bUseHKCU ? L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\" : L"CLSID\\"); + ptr = szKey + wcslen(szKey); + SHStringFromGUIDW(guid, ptr, 39); /* Append guid */ + if (lpszValue) + { + ptr = szKey + wcslen(szKey); + wcscat(ptr, L"\\"); + wcscat(++ptr, lpszValue); + } +#else memcpy(szKey, szClassIdKey, sizeof(szClassIdKey)); SHStringFromGUIDW(guid, szKey + szClassIdKeyLen, 39); /* Append guid */ @@ -2440,6 +2456,7 @@ HRESULT WINAPI SHRegGetCLSIDKeyW(REFGUID guid, LPCWSTR lpszValue, BOOL bUseHKCU, szKey[szClassIdKeyLen + 39] = '\\'; strcpyW(szKey + szClassIdKeyLen + 40, lpszValue); /* Append value name */ } +#endif hkey = bUseHKCU ? HKEY_CURRENT_USER : HKEY_CLASSES_ROOT;
4 years, 7 months
1
0
0
0
[reactos] 01/06: [PSDK] Add argument names to SHRegGetValue functions
by Mark Jansen
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c6a8a9c1458f7b8c91b29…
commit c6a8a9c1458f7b8c91b29e4a2606f88cd8592260 Author: Mark Jansen <mark.jansen(a)reactos.org> AuthorDate: Mon Apr 27 16:00:20 2020 +0200 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sun May 17 17:08:57 2020 +0200 [PSDK] Add argument names to SHRegGetValue functions --- sdk/include/psdk/shlwapi.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sdk/include/psdk/shlwapi.h b/sdk/include/psdk/shlwapi.h index 65f9db98312..6c796acfc38 100644 --- a/sdk/include/psdk/shlwapi.h +++ b/sdk/include/psdk/shlwapi.h @@ -262,23 +262,23 @@ typedef INT SRRF; LSTATUS WINAPI SHRegGetValueA( - _In_ HKEY, - _In_opt_ LPCSTR, - _In_opt_ LPCSTR, - _In_ SRRF, - _Out_opt_ LPDWORD, - _Out_writes_bytes_to_opt_(*pcbData, *pcbData) LPVOID, + _In_ HKEY hkey, + _In_opt_ LPCSTR pszSubKey, + _In_opt_ LPCSTR pszValue, + _In_ SRRF srrfFlags, + _Out_opt_ LPDWORD pdwType, + _Out_writes_bytes_to_opt_(*pcbData, *pcbData) LPVOID pvData, _Inout_opt_ LPDWORD pcbData); LSTATUS WINAPI SHRegGetValueW( - _In_ HKEY, - _In_opt_ LPCWSTR, - _In_opt_ LPCWSTR, - _In_ SRRF, - _Out_opt_ LPDWORD, - _Out_writes_bytes_to_opt_(*pcbData, *pcbData) LPVOID, + _In_ HKEY hkey, + _In_opt_ LPCWSTR pszSubKey, + _In_opt_ LPCWSTR pszValue, + _In_ SRRF srrfFlags, + _Out_opt_ LPDWORD pdwType, + _Out_writes_bytes_to_opt_(*pcbData, *pcbData) LPVOID pvData, _Inout_opt_ LPDWORD pcbData); #define SHRegGetValue WINELIB_NAME_AW(SHRegGetValue)
4 years, 7 months
1
0
0
0
[reactos] 01/01: [NTOS:SE] Implement job case in PsImpersonateClient. CORE-8787
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=db180c29c7be2794e18d5…
commit db180c29c7be2794e18d5dc0622495e5427bfe94 Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Mon May 11 08:41:38 2020 +0200 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Sun May 17 16:05:00 2020 +0200 [NTOS:SE] Implement job case in PsImpersonateClient. CORE-8787 --- ntoskrnl/ps/security.c | 30 ++++++++++++++++++++++++++++-- sdk/include/ndk/pstypes.h | 8 ++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/ntoskrnl/ps/security.c b/ntoskrnl/ps/security.c index 619ff56d247..0b3f97fbf06 100644 --- a/ntoskrnl/ps/security.c +++ b/ntoskrnl/ps/security.c @@ -615,6 +615,8 @@ PsImpersonateClient(IN PETHREAD Thread, { PPS_IMPERSONATION_INFORMATION Impersonation, OldData; PTOKEN OldToken = NULL; + PEJOB Job; + PAGED_CODE(); PSTRACE(PS_SECURITY_DEBUG, "Thread: %p, Token: %p\n", Thread, Token); @@ -668,8 +670,32 @@ PsImpersonateClient(IN PETHREAD Thread, } } - /* Check if this is a job, which we don't support yet */ - if (Thread->ThreadsProcess->Job) ASSERT(FALSE); + /* FIXME: If the process token can't impersonate, we need to make a copy instead */ + + /* Check if this is a job */ + Job = Thread->ThreadsProcess->Job; + if (Job != NULL) + { + /* No admin allowed in this job */ + if ((Job->SecurityLimitFlags & JOB_OBJECT_SECURITY_NO_ADMIN) && + SeTokenIsAdmin(Token)) + { + return STATUS_ACCESS_DENIED; + } + + /* No restricted tokens allowed in this job */ + if ((Job->SecurityLimitFlags & JOB_OBJECT_SECURITY_RESTRICTED_TOKEN) && + SeTokenIsRestricted(Token)) + { + return STATUS_ACCESS_DENIED; + } + + /* We don't support job filters yet */ + if (Job->Filter != NULL) + { + ASSERT(Job->Filter == NULL); + } + } /* Lock thread security */ PspLockThreadSecurityExclusive(Thread); diff --git a/sdk/include/ndk/pstypes.h b/sdk/include/ndk/pstypes.h index 219b880368f..55839aca37a 100644 --- a/sdk/include/ndk/pstypes.h +++ b/sdk/include/ndk/pstypes.h @@ -216,6 +216,14 @@ extern POBJECT_TYPE NTSYSAPI PsJobType; #define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK 0x1000 #define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x2000 +// +// Job Security Limit Flags +// +#define JOB_OBJECT_SECURITY_NO_ADMIN 0x0001 +#define JOB_OBJECT_SECURITY_RESTRICTED_TOKEN 0x0002 +#define JOB_OBJECT_SECURITY_ONLY_TOKEN 0x0004 +#define JOB_OBJECT_SECURITY_FILTER_TOKENS 0x0008 + // // Cross Thread Flags //
4 years, 7 months
1
0
0
0
[reactos] 01/01: [GITHUB] Enable ccache for GCC builds on GitHub Actions
by Victor Perevertkin
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2d7f71c5b84e16d8fa8ad…
commit 2d7f71c5b84e16d8fa8ad305946114f342e04722 Author: Victor Perevertkin <victor.perevertkin(a)reactos.org> AuthorDate: Sun May 17 13:32:14 2020 +0300 Commit: Victor Perevertkin <victor.perevertkin(a)reactos.org> CommitDate: Sun May 17 13:32:14 2020 +0300 [GITHUB] Enable ccache for GCC builds on GitHub Actions --- .github/workflows/build.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b533cb4f214..b9326331c4e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,13 +11,28 @@ jobs: wget
https://svn.reactos.org/storage/vperevertkin/rosbe-ci.tar.zst
mkdir ${{github.workspace}}/rosbe tar -I zstd -xvf rosbe-ci.tar.zst --directory ${{github.workspace}}/rosbe + - name: Install other packages + run: sudo apt install ccache - uses: actions/checkout@v2 with: path: src + - name: Set up cache for ccache + uses: actions/cache@v1 + with: + path: ccache + key: ccache-gcc-i386-${{github.sha}} + restore-keys: | + ccache-gcc-i386- + - name: Set ccache settings + run: | + echo "::set-env name=CCACHE_BASEDIR::${{github.workspace}}" + echo "::set-env name=CCACHE_DIR::${{github.workspace}}/ccache" + echo "::set-env name=CCACHE_MAXSIZE::2G" + echo "::set-env name=CCACHE_SLOPPINESS::time_macros" - name: Configure run: | mkdir build - echo 'cd ${{github.workspace}}/build && ${{github.workspace}}/src/configure.sh -DENABLE_ROSTESTS=1 -DENABLE_ROSAPPS=1' > commands + echo 'cd ${{github.workspace}}/build && ${{github.workspace}}/src/configure.sh -DENABLE_CCACHE=1 -DENABLE_ROSTESTS=1 -DENABLE_ROSAPPS=1' > commands ${{github.workspace}}/rosbe/RosBE.sh < commands - name: Build run: |
4 years, 7 months
1
0
0
0
[reactos] 01/01: [SERVICES][DCOMLAUNCH] Don't hardcode C: drive (#2779)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fe9838f578ea56cfae512…
commit fe9838f578ea56cfae51286992b4c84238050843 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Sun May 17 17:45:56 2020 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Sun May 17 17:45:56 2020 +0900 [SERVICES][DCOMLAUNCH] Don't hardcode C: drive (#2779) CORE-13235 --- base/services/dcomlaunch/network.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/base/services/dcomlaunch/network.c b/base/services/dcomlaunch/network.c index c6475c85e23..b978e9faee4 100644 --- a/base/services/dcomlaunch/network.c +++ b/base/services/dcomlaunch/network.c @@ -44,7 +44,8 @@ CookupNodeId(UCHAR * NodeId) DWORD dwValue; MEMORYSTATUS MemoryStatus; LUID Luid; - DWORD SectorsPerCluster, BytesPerSector, NumberOfFreeClusters, TotalNumberOfClusters; + WCHAR szSystem[MAX_PATH]; + ULARGE_INTEGER FreeBytesToCaller, TotalBytes, TotalFreeBytes; /* Initialize node id */ memset(NodeId, 0x11, SEED_BUFFER_SIZE * sizeof(UCHAR)); @@ -104,11 +105,16 @@ CookupNodeId(UCHAR * NodeId) *NodeMiddle = *NodeMiddle ^ Luid.HighPart; } + /* Get system directory */ + GetSystemDirectoryW(szSystem, ARRAYSIZE(szSystem)); + /* And finally with free disk space */ - if (GetDiskFreeSpaceA("c:\\", &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters)) + if (GetDiskFreeSpaceExW(szSystem, &FreeBytesToCaller, &TotalBytes, &TotalFreeBytes)) { - *NodeMiddle = *NodeMiddle ^ TotalNumberOfClusters * BytesPerSector * SectorsPerCluster; - *NodeBegin = *NodeBegin ^ NumberOfFreeClusters * BytesPerSector * SectorsPerCluster; + *NodeMiddle ^= FreeBytesToCaller.LowPart ^ TotalFreeBytes.HighPart; + *NodeMiddle ^= FreeBytesToCaller.HighPart ^ TotalFreeBytes.LowPart; + *NodeBegin ^= TotalBytes.LowPart ^ TotalFreeBytes.LowPart; + *NodeBegin ^= TotalBytes.HighPart ^ TotalFreeBytes.HighPart; } /*
4 years, 7 months
1
0
0
0
[reactos] 01/01: [ISAPNP] Mark read data port as started, even if no ISAPNP card is present
by Hervé Poussineau
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e246b9947ebedeb87587f…
commit e246b9947ebedeb87587fa6f0bf8bd1384e3d1ec Author: Hervé Poussineau <hpoussin(a)reactos.org> AuthorDate: Sat May 16 23:17:19 2020 +0200 Commit: Hervé Poussineau <hpoussin(a)reactos.org> CommitDate: Sat May 16 23:20:38 2020 +0200 [ISAPNP] Mark read data port as started, even if no ISAPNP card is present CORE-17056 --- drivers/bus/isapnp/pdo.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/bus/isapnp/pdo.c b/drivers/bus/isapnp/pdo.c index 4a9f28ff481..36ba611e131 100644 --- a/drivers/bus/isapnp/pdo.c +++ b/drivers/bus/isapnp/pdo.c @@ -191,7 +191,7 @@ IsaPdoStartReadPort( IN PIO_STACK_LOCATION IrpSp) { PCM_RESOURCE_LIST ResourceList = IrpSp->Parameters.StartDevice.AllocatedResources; - NTSTATUS Status = STATUS_INVALID_PARAMETER; + NTSTATUS Status = STATUS_INSUFFICIENT_RESOURCES; KIRQL OldIrql; ULONG i; @@ -209,11 +209,12 @@ IsaPdoStartReadPort( for (i = 0; i < ResourceList->List[0].PartialResourceList.Count; i++) { PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[i]; - if (PartialDescriptor->Type == CmResourceTypePort) + if (PartialDescriptor->Type == CmResourceTypePort && PartialDescriptor->u.Port.Length > 1 && !FdoExt->ReadDataPort) { PUCHAR ReadDataPort = ULongToPtr(PartialDescriptor->u.Port.Start.u.LowPart + 3); - if (PartialDescriptor->u.Port.Length > 1 && !FdoExt->ReadDataPort && NT_SUCCESS(IsaHwTryReadDataPort(ReadDataPort))) + if (NT_SUCCESS(IsaHwTryReadDataPort(ReadDataPort))) { + /* we detected some ISAPNP cards */ FdoExt->ReadDataPort = ReadDataPort; KeAcquireSpinLock(&FdoExt->Lock, &OldIrql); Status = IsaHwFillDeviceList(FdoExt); @@ -224,6 +225,11 @@ IsaPdoStartReadPort( IoInvalidateDeviceRelations(FdoExt->DataPortPdo, RemovalRelations); } } + else + { + /* mark read data port as started, even if no card has been detected */ + Status = STATUS_SUCCESS; + } } } return Status;
4 years, 7 months
1
0
0
0
[reactos] 01/01: [HOST-TOOLS] Fix the build from IDE for visual studio 2019 CE CORE-16904
by Mark Jansen
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f454f4dc21487e0d8b80c…
commit f454f4dc21487e0d8b80c70fd5419e4b706feb6c Author: Mark Jansen <mark.jansen(a)reactos.org> AuthorDate: Sat May 16 18:19:31 2020 +0200 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sat May 16 20:17:43 2020 +0200 [HOST-TOOLS] Fix the build from IDE for visual studio 2019 CE CORE-16904 --- sdk/tools/cabman/cabinet.h | 1 + sdk/tools/hhpcomp/utils.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/sdk/tools/cabman/cabinet.h b/sdk/tools/cabman/cabinet.h index 02d23d398e2..3bf6ba6edad 100644 --- a/sdk/tools/cabman/cabinet.h +++ b/sdk/tools/cabman/cabinet.h @@ -9,6 +9,7 @@ #if defined(_WIN32) #define WIN32_LEAN_AND_MEAN + #include <intrin.h> #include <windows.h> #else #include <typedefs.h> diff --git a/sdk/tools/hhpcomp/utils.cpp b/sdk/tools/hhpcomp/utils.cpp index c2c8dae8d17..ea62013b46c 100644 --- a/sdk/tools/hhpcomp/utils.cpp +++ b/sdk/tools/hhpcomp/utils.cpp @@ -23,6 +23,7 @@ #if defined(_WIN32) #define WIN32_LEAN_AND_MEAN + #include <intrin.h> #include <windows.h> // for GetFullPathNameA #else #include <unistd.h>
4 years, 7 months
1
0
0
0
[reactos] 01/01: [REGEDIT] Fix and improvement in TreeView (Null handle check, incorrect display after edit, WM_NOTIFY refactor) (#2733)
by Kyle Katarn
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4d1cd723175c25a76c17f…
commit 4d1cd723175c25a76c17f58cb93f4e83dfd8881c Author: Kyle Katarn <contact(a)kcsoftwares.com> AuthorDate: Sat May 16 14:23:20 2020 +0200 Commit: GitHub <noreply(a)github.com> CommitDate: Sat May 16 21:23:20 2020 +0900 [REGEDIT] Fix and improvement in TreeView (Null handle check, incorrect display after edit, WM_NOTIFY refactor) (#2733) * - Fix of missing invalid handle check - Fix of Address & status bar incorrect display after rename - Refactoring of Treeview WM_NOTIFY code, for better consistency with WM_NOTIFY management for ListView * Fix following review (space in #define) * Cleanup following review * fix following review * Fix of round 3 of review comments * UpdateAdress kept in its original location * fix * fix (extern missing) * both extern removed * Review comments Error message being added in order to support CORE-17048 --- base/applications/regedit/childwnd.c | 138 ++++++++--------------------------- base/applications/regedit/listview.c | 2 +- base/applications/regedit/main.h | 6 +- base/applications/regedit/treeview.c | 106 +++++++++++++++++++++++++++ 4 files changed, 143 insertions(+), 109 deletions(-) diff --git a/base/applications/regedit/childwnd.c b/base/applications/regedit/childwnd.c index e5c2788da15..a10f11ea96d 100644 --- a/base/applications/regedit/childwnd.c +++ b/base/applications/regedit/childwnd.c @@ -228,11 +228,12 @@ LRESULT CALLBACK AddressBarProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar return CallWindowProcW(oldwndproc, hwnd, uMsg, wParam, lParam); } -static VOID +VOID UpdateAddress(HTREEITEM hItem, HKEY hRootKey, LPCWSTR pszPath) { LPCWSTR keyPath, rootName; LPWSTR fullPath; + DWORD cbFullPath; /* Wipe the listview, the status bar and the address bar if the root key was selected */ if (TreeView_GetParent(g_pChildWnd->hTreeWnd, hItem) == NULL) @@ -252,33 +253,36 @@ UpdateAddress(HTREEITEM hItem, HKEY hRootKey, LPCWSTR pszPath) { RefreshListView(g_pChildWnd->hListWnd, hRootKey, keyPath); rootName = get_root_key_name(hRootKey); - fullPath = HeapAlloc(GetProcessHeap(), 0, (wcslen(rootName) + 1 + wcslen(keyPath) + 1) * sizeof(WCHAR)); + cbFullPath = (wcslen(rootName) + 1 + wcslen(keyPath) + 1) * sizeof(WCHAR); + fullPath = HeapAlloc(GetProcessHeap(), 0, cbFullPath); if (fullPath) { /* set (correct) the address bar text */ if (keyPath[0] != L'\0') - swprintf(fullPath, L"%s\\%s", rootName, keyPath); + swprintf(fullPath, L"%s%s%s", rootName, keyPath[0]==L'\\'?L"":L"\\", keyPath); else fullPath = wcscpy(fullPath, rootName); + SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)fullPath); SendMessageW(g_pChildWnd->hAddressBarWnd, WM_SETTEXT, 0, (LPARAM)fullPath); HeapFree(GetProcessHeap(), 0, fullPath); + /* disable hive manipulation items temporarily (enable only if necessary) */ - EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_GRAYED); + EnableMenuItem(hMenuFrame, ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_GRAYED); + EnableMenuItem(hMenuFrame, ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_GRAYED); /* compare the strings to see if we should enable/disable the "Load Hive" menus accordingly */ - if (!(_wcsicmp(rootName, L"HKEY_LOCAL_MACHINE") && - _wcsicmp(rootName, L"HKEY_USERS"))) + if (_wcsicmp(rootName, L"HKEY_LOCAL_MACHINE") != 0 || + _wcsicmp(rootName, L"HKEY_USERS") != 0) { /* * enable the unload menu item if at the root, otherwise * enable the load menu item if there is no slash in * keyPath (ie. immediate child selected) */ - if(keyPath[0] == L'\0') - EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_ENABLED); - else if(!wcschr(keyPath, L'\\')) - EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_ENABLED); + if (keyPath[0] == UNICODE_NULL) + EnableMenuItem(hMenuFrame, ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_ENABLED); + else if (!wcschr(keyPath, L'\\')) + EnableMenuItem(hMenuFrame, ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_ENABLED); } } } @@ -472,111 +476,33 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa break; case WM_NOTIFY: - if ((int)wParam == TREE_WINDOW && g_pChildWnd != NULL) + if (g_pChildWnd == NULL) break; + + if (((LPNMHDR)lParam)->idFrom == TREE_WINDOW) { - switch (((LPNMHDR)lParam)->code) - { - case TVN_ITEMEXPANDING: - return !OnTreeExpanding(g_pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam); - case TVN_SELCHANGED: - { - NMTREEVIEW* pnmtv = (NMTREEVIEW*)lParam; - /* Get the parent of the current item */ - HTREEITEM hParentItem = TreeView_GetParent(g_pChildWnd->hTreeWnd, pnmtv->itemNew.hItem); - - UpdateAddress(pnmtv->itemNew.hItem, NULL, NULL); - - /* Disable the Permissions menu item for 'My Computer' */ - EnableMenuItem(hMenuFrame , ID_EDIT_PERMISSIONS, MF_BYCOMMAND | ((hParentItem == NULL) ? MF_GRAYED : MF_ENABLED)); - - /* - * Disable Delete/Rename menu options for 'My Computer' (first item so doesn't have any parent) - * and HKEY_* keys (their parent is 'My Computer' and the previous remark applies). - */ - if (!hParentItem || !TreeView_GetParent(g_pChildWnd->hTreeWnd, hParentItem)) - { - EnableMenuItem(hMenuFrame , ID_EDIT_DELETE, MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(hMenuFrame , ID_EDIT_RENAME, MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(hPopupMenus, ID_TREE_DELETE, MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(hPopupMenus, ID_TREE_RENAME, MF_BYCOMMAND | MF_GRAYED); - } - else - { - EnableMenuItem(hMenuFrame , ID_EDIT_DELETE, MF_BYCOMMAND | MF_ENABLED); - EnableMenuItem(hMenuFrame , ID_EDIT_RENAME, MF_BYCOMMAND | MF_ENABLED); - EnableMenuItem(hPopupMenus, ID_TREE_DELETE, MF_BYCOMMAND | MF_ENABLED); - EnableMenuItem(hPopupMenus, ID_TREE_RENAME, MF_BYCOMMAND | MF_ENABLED); - } - - break; - } - case NM_SETFOCUS: - g_pChildWnd->nFocusPanel = 0; - break; - case TVN_BEGINLABELEDIT: + if (!TreeWndNotifyProc(g_pChildWnd->hListWnd, wParam, lParam, &Result)) { - LPNMTVDISPINFO ptvdi; - /* cancel label edit for rootkeys */ - ptvdi = (LPNMTVDISPINFO) lParam; - if (!TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem) || - !TreeView_GetParent(g_pChildWnd->hTreeWnd, TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem))) - return TRUE; - break; - } - case TVN_ENDLABELEDIT: - { - LPCWSTR keyPath; - HKEY hRootKey; - HKEY hKey = NULL; - LPNMTVDISPINFO ptvdi; - LONG lResult = TRUE; - WCHAR szBuffer[MAX_PATH]; - - ptvdi = (LPNMTVDISPINFO) lParam; - if (ptvdi->item.pszText) - { - keyPath = GetItemPath(g_pChildWnd->hTreeWnd, TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem), &hRootKey); - _snwprintf(szBuffer, COUNT_OF(szBuffer), L"%s\\%s", keyPath, ptvdi->item.pszText); - keyPath = GetItemPath(g_pChildWnd->hTreeWnd, ptvdi->item.hItem, &hRootKey); - if (RegOpenKeyExW(hRootKey, szBuffer, 0, KEY_READ, &hKey) == ERROR_SUCCESS) - { - lResult = FALSE; - RegCloseKey(hKey); - TreeView_EditLabel(g_pChildWnd->hTreeWnd, ptvdi->item.hItem); - } - else - { - if (RenameKey(hRootKey, keyPath, ptvdi->item.pszText) != ERROR_SUCCESS) - lResult = FALSE; - else - UpdateAddress(ptvdi->item.hItem, hRootKey, szBuffer); - } - return lResult; - } - } - default: - return 0; + goto def; } + + return Result; } else { - if ((int)wParam == LIST_WINDOW && g_pChildWnd != NULL) + if (((LPNMHDR)lParam)->idFrom == LIST_WINDOW) { - switch (((LPNMHDR)lParam)->code) + if (!ListWndNotifyProc(g_pChildWnd->hListWnd, wParam, lParam, &Result)) { - case NM_SETFOCUS: - g_pChildWnd->nFocusPanel = 1; - break; - default: - if(!ListWndNotifyProc(g_pChildWnd->hListWnd, wParam, lParam, &Result)) - { - goto def; - } - return Result; - break; + goto def; } + + return Result; } - } + else + { + goto def; + } + } break; case WM_CONTEXTMENU: diff --git a/base/applications/regedit/listview.c b/base/applications/regedit/listview.c index 04ed77ffc59..d7fa0a14f7f 100644 --- a/base/applications/regedit/listview.c +++ b/base/applications/regedit/listview.c @@ -563,7 +563,7 @@ BOOL ListWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result) } return TRUE; case NM_SETFOCUS: - g_pChildWnd->nFocusPanel = 0; + g_pChildWnd->nFocusPanel = 1; break; case LVN_BEGINLABELEDIT: Info = (NMLVDISPINFO*)lParam; diff --git a/base/applications/regedit/main.h b/base/applications/regedit/main.h index 12ae68cfa3e..01b7541434a 100644 --- a/base/applications/regedit/main.h +++ b/base/applications/regedit/main.h @@ -27,8 +27,8 @@ #define TREE_WINDOW 2002 #define LIST_WINDOW 2003 -#define SPLIT_WIDTH 5 -#define SPLIT_MIN 30 +#define SPLIT_WIDTH 5 +#define SPLIT_MIN 30 #define COUNT_OF(a) (sizeof(a)/sizeof(a[0])) @@ -94,6 +94,7 @@ extern void ShowAboutBox(HWND hWnd); extern LRESULT CALLBACK ChildWndProc(HWND, UINT, WPARAM, LPARAM); extern void ResizeWnd(int cx, int cy); extern LPCWSTR get_root_key_name(HKEY hRootKey); +VOID UpdateAddress(HTREEITEM hItem, HKEY hRootKey, LPCWSTR pszPath); /* error.c */ extern int ErrorMessageBox(HWND hWnd, LPCWSTR lpTitle, DWORD dwErrorCode, ...); @@ -115,6 +116,7 @@ extern HWND CreateListView(HWND hwndParent, HMENU id, INT cx); extern BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath); extern LPCWSTR GetValueName(HWND hwndLV, int iStartAt); extern BOOL ListWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result); +extern BOOL TreeWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result); extern BOOL IsDefaultValue(HWND hwndLV, int i); /* regedit.c */ diff --git a/base/applications/regedit/treeview.c b/base/applications/regedit/treeview.c index 0f1a7706839..b7b45635b74 100644 --- a/base/applications/regedit/treeview.c +++ b/base/applications/regedit/treeview.c @@ -625,6 +625,110 @@ done: return bSuccess; } +BOOL TreeWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result) +{ + UNREFERENCED_PARAMETER(wParam); + *Result = TRUE; + + switch (((LPNMHDR)lParam)->code) + { + case TVN_ITEMEXPANDING: + *Result = !OnTreeExpanding(g_pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam); + return TRUE; + case TVN_SELCHANGED: + { + NMTREEVIEW* pnmtv = (NMTREEVIEW*)lParam; + /* Get the parent of the current item */ + HTREEITEM hParentItem = TreeView_GetParent(g_pChildWnd->hTreeWnd, pnmtv->itemNew.hItem); + + UpdateAddress(pnmtv->itemNew.hItem, NULL, NULL); + + /* Disable the Permissions menu item for 'My Computer' */ + EnableMenuItem(hMenuFrame, ID_EDIT_PERMISSIONS, MF_BYCOMMAND | (hParentItem ? MF_ENABLED : MF_GRAYED)); + + /* + * Disable Delete/Rename menu options for 'My Computer' (first item so doesn't have any parent) + * and HKEY_* keys (their parent is 'My Computer' and the previous remark applies). + */ + if (!hParentItem || !TreeView_GetParent(g_pChildWnd->hTreeWnd, hParentItem)) + { + EnableMenuItem(hMenuFrame , ID_EDIT_DELETE, MF_BYCOMMAND | MF_GRAYED); + EnableMenuItem(hMenuFrame , ID_EDIT_RENAME, MF_BYCOMMAND | MF_GRAYED); + EnableMenuItem(hPopupMenus, ID_TREE_DELETE, MF_BYCOMMAND | MF_GRAYED); + EnableMenuItem(hPopupMenus, ID_TREE_RENAME, MF_BYCOMMAND | MF_GRAYED); + } + else + { + EnableMenuItem(hMenuFrame , ID_EDIT_DELETE, MF_BYCOMMAND | MF_ENABLED); + EnableMenuItem(hMenuFrame , ID_EDIT_RENAME, MF_BYCOMMAND | MF_ENABLED); + EnableMenuItem(hPopupMenus, ID_TREE_DELETE, MF_BYCOMMAND | MF_ENABLED); + EnableMenuItem(hPopupMenus, ID_TREE_RENAME, MF_BYCOMMAND | MF_ENABLED); + } + + return TRUE; + } + case NM_SETFOCUS: + g_pChildWnd->nFocusPanel = 0; + break; + case TVN_BEGINLABELEDIT: + { + LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO) lParam; + /* cancel label edit for rootkeys */ + if (!TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem) || + !TreeView_GetParent(g_pChildWnd->hTreeWnd, TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem))) + { + *Result = TRUE; + } + else + { + *Result = FALSE; + } + return TRUE; + } + case TVN_ENDLABELEDIT: + { + LPCWSTR keyPath; + HKEY hRootKey; + HKEY hKey = NULL; + LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO) lParam; + LONG nRenResult; + LONG lResult = TRUE; + WCHAR szBuffer[MAX_PATH]; + WCHAR Caption[128]; + + if (ptvdi->item.pszText) + { + keyPath = GetItemPath(g_pChildWnd->hTreeWnd, TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem), &hRootKey); + if (wcslen(keyPath)) + _snwprintf(szBuffer, COUNT_OF(szBuffer), L"%s\\%s", keyPath, ptvdi->item.pszText); + else + _snwprintf(szBuffer, COUNT_OF(szBuffer), L"%s", ptvdi->item.pszText); + keyPath = GetItemPath(g_pChildWnd->hTreeWnd, ptvdi->item.hItem, &hRootKey); + if (RegOpenKeyExW(hRootKey, szBuffer, 0, KEY_READ, &hKey) == ERROR_SUCCESS) + { + lResult = FALSE; + RegCloseKey(hKey); + TreeView_EditLabel(g_pChildWnd->hTreeWnd, ptvdi->item.hItem); + } + else + { + nRenResult = RenameKey(hRootKey, keyPath, ptvdi->item.pszText); + if (nRenResult != ERROR_SUCCESS) + { + LoadStringW(hInst, IDS_ERROR, Caption, COUNT_OF(Caption)); + ErrorMessageBox(hWnd, Caption, nRenResult); + lResult = FALSE; + } + else + UpdateAddress(ptvdi->item.hItem, hRootKey, szBuffer); + } + *Result = lResult; + } + return TRUE; + } + } + return FALSE; +} /* * CreateTreeView - creates a tree view control. @@ -642,6 +746,8 @@ HWND CreateTreeView(HWND hwndParent, LPWSTR pHostName, HMENU id) WS_VISIBLE | WS_CHILD | WS_TABSTOP | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_EDITLABELS | TVS_SHOWSELALWAYS, 0, 0, rcClient.right, rcClient.bottom, hwndParent, id, hInst, NULL); + if (!hwndTV) return NULL; + /* Initialize the image list, and add items to the control. */ if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV, pHostName)) {
4 years, 7 months
1
0
0
0
[reactos] 01/01: [CPORTLIB] Fix MSVC build for PC-98 target
by Dmitry Borisov
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3fd6dbd9438324eb99982…
commit 3fd6dbd9438324eb999825dfa731a3b0243f87f0 Author: Dmitry Borisov <di.sean(a)protonmail.com> AuthorDate: Sat May 16 02:09:01 2020 +0600 Commit: Stanislav Motylkov <x86corez(a)gmail.com> CommitDate: Sat May 16 15:23:00 2020 +0300 [CPORTLIB] Fix MSVC build for PC-98 target --- sdk/lib/cportlib/cport_pc98.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/lib/cportlib/cport_pc98.c b/sdk/lib/cportlib/cport_pc98.c index 0714fd2bccf..5973e71f9a7 100644 --- a/sdk/lib/cportlib/cport_pc98.c +++ b/sdk/lib/cportlib/cport_pc98.c @@ -45,8 +45,8 @@ static BOOLEAN IsNekoProject = FALSE; static BOOLEAN CpIsNekoProject(VOID) { - UCHAR Input[3] = "NP2"; - UCHAR Output[3]; + UCHAR Input[4] = "NP2"; + UCHAR Output[4] = {0}; UCHAR i; for (i = 0; i < 3; i++) @@ -55,7 +55,7 @@ CpIsNekoProject(VOID) for (i = 0; i < 3; i++) Output[i] = READ_PORT_UCHAR((PUCHAR)0x7EF); - return (memcmp(Input, Output, 3) == 0); + return (*(PULONG)Input == *(PULONG)Output); } static VOID
4 years, 7 months
1
0
0
0
← Newer
1
...
5
6
7
8
9
10
11
...
20
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Results per page:
10
25
50
100
200