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 2024
----- 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
22 participants
103 discussions
Start a n
N
ew thread
[reactos] 01/01: [SETUPLIB] Use proper SEH instead of nasty hacks
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=31334ebcfefc818cd04ff…
commit 31334ebcfefc818cd04ff7c890bd116cbc5f5099 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Sun Oct 13 19:10:22 2024 +0300 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Mon Nov 18 10:23:50 2024 +0200 [SETUPLIB] Use proper SEH instead of nasty hacks Addendum to commit 2268b3d --- base/setup/lib/CMakeLists.txt | 1 + base/setup/lib/utils/filesup.c | 9 +-------- base/setup/reactos/CMakeLists.txt | 2 +- base/setup/usetup/CMakeLists.txt | 2 +- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/base/setup/lib/CMakeLists.txt b/base/setup/lib/CMakeLists.txt index 836c9ef5967..34b43018c23 100644 --- a/base/setup/lib/CMakeLists.txt +++ b/base/setup/lib/CMakeLists.txt @@ -5,6 +5,7 @@ if(_WINKD_) endif() include_directories(spapisup utils) +include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/pseh/include) list(APPEND SOURCE spapisup/fileqsup.c diff --git a/base/setup/lib/utils/filesup.c b/base/setup/lib/utils/filesup.c index 81da91faa12..9c00675c59c 100644 --- a/base/setup/lib/utils/filesup.c +++ b/base/setup/lib/utils/filesup.c @@ -10,18 +10,11 @@ #include "precomp.h" #include "filesup.h" +#include <pseh/pseh2.h> #define NDEBUG #include <debug.h> - -// ACHTUNG! HAXX FIXME!! -#define _SEH2_TRY -#define _SEH2_LEAVE goto __SEH2_FINALLY__label; -#define _SEH2_FINALLY __SEH2_FINALLY__label: -#define _SEH2_END - - /* FUNCTIONS ****************************************************************/ static diff --git a/base/setup/reactos/CMakeLists.txt b/base/setup/reactos/CMakeLists.txt index 6516663e7fb..23adc345081 100644 --- a/base/setup/reactos/CMakeLists.txt +++ b/base/setup/reactos/CMakeLists.txt @@ -19,7 +19,7 @@ add_rc_deps(reactos.rc ${reactos_rc_deps}) add_executable(reactos ${SOURCE} reactos.rc) add_pch(reactos reactos.h SOURCE) set_module_type(reactos win32gui UNICODE) -target_link_libraries(reactos uuid setuplib ext2lib vfatlib btrfslib) +target_link_libraries(reactos uuid setuplib ext2lib vfatlib btrfslib ${PSEH_LIB}) target_link_libraries(reactos zlib_solo) ## We use USETUP's cabinet implementation add_importlibs(reactos advapi32 gdi32 user32 comctl32 shlwapi setupapi msvcrt kernel32 ntdll) add_cd_file(TARGET reactos DESTINATION reactos NO_CAB FOR bootcd) diff --git a/base/setup/usetup/CMakeLists.txt b/base/setup/usetup/CMakeLists.txt index 94ef7cffd14..21d2bdcf646 100644 --- a/base/setup/usetup/CMakeLists.txt +++ b/base/setup/usetup/CMakeLists.txt @@ -35,6 +35,6 @@ endif() add_pch(usetup usetup.h SOURCE) set_module_type(usetup nativecui) -target_link_libraries(usetup inflib setuplib zlib_solo ext2lib vfatlib btrfslib chkstk) +target_link_libraries(usetup inflib setuplib zlib_solo ext2lib vfatlib btrfslib chkstk ${PSEH_LIB}) add_importlibs(usetup ntdll) add_cd_file(TARGET usetup DESTINATION reactos/system32 NO_CAB NAME_ON_CD smss.exe FOR bootcd regtest)
1 month
1
0
0
0
[reactos] 01/01: [SHELL32][SHELL32_APITEST] Consolidate file type description handling (#7485)
by Whindmar Saksit
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8107ff86368259fd53582…
commit 8107ff86368259fd5358287d8e39c5e7180946e1 Author: Whindmar Saksit <whindsaks(a)proton.me> AuthorDate: Sun Nov 17 20:13:05 2024 +0100 Commit: GitHub <noreply(a)github.com> CommitDate: Sun Nov 17 20:13:05 2024 +0100 [SHELL32][SHELL32_APITEST] Consolidate file type description handling (#7485) - Fixes the case where an extension exists in HKCR but has no ProgId (half of CORE-19355) - Fixes some cases where Wine hardcoded "File and "... file" strings are used instead of localized strings in SHGetFileInfo. --- dll/win32/shell32/CQueryAssociations.cpp | 50 ++++++++ dll/win32/shell32/dialogs/filetypes.cpp | 13 -- dll/win32/shell32/folders/CFSFolder.cpp | 35 +++++- dll/win32/shell32/wine/classes.c | 51 +++++--- dll/win32/shell32/wine/pidl.c | 61 ++------- dll/win32/shell32/wine/pidl.h | 2 +- dll/win32/shell32/wine/shell32_main.c | 150 +++++++++++------------ dll/win32/shell32/wine/shell32_main.h | 7 ++ modules/rostests/apitests/shell32/CMakeLists.txt | 1 + modules/rostests/apitests/shell32/ItemIDList.cpp | 6 + modules/rostests/apitests/shell32/ShellInfo.cpp | 76 ++++++++++++ modules/rostests/apitests/shell32/testlist.c | 2 + 12 files changed, 288 insertions(+), 166 deletions(-) diff --git a/dll/win32/shell32/CQueryAssociations.cpp b/dll/win32/shell32/CQueryAssociations.cpp index a21e49625f8..14a618b9611 100644 --- a/dll/win32/shell32/CQueryAssociations.cpp +++ b/dll/win32/shell32/CQueryAssociations.cpp @@ -22,6 +22,56 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell); +EXTERN_C HRESULT SHELL32_AssocGetFSDirectoryDescription(PWSTR Buf, UINT cchBuf) +{ + static WCHAR cache[33] = {}; + if (!*cache) + LoadStringW(shell32_hInstance, IDS_DIRECTORY, cache, _countof(cache)); + return StringCchCopyW(Buf, cchBuf, cache); +} + +static HRESULT GetExtensionDefaultDescription(PCWSTR DotExt, PWSTR Buf, UINT cchBuf) +{ + static WCHAR fmt[33] = {}; + if (!*fmt) + LoadStringW(shell32_hInstance, IDS_ANY_FILE, fmt, _countof(fmt)); + return StringCchPrintfW(Buf, cchBuf, fmt, DotExt); +} + +static HRESULT SHELL32_AssocGetExtensionDescription(PCWSTR DotExt, PWSTR Buf, UINT cchBuf) +{ + HRESULT hr; + if (!DotExt[0] || (!DotExt[1] && DotExt[0] == '.')) + { + if (SUCCEEDED(hr = GetExtensionDefaultDescription(L"", Buf, cchBuf))) + StrTrimW(Buf, L" -"); // Remove the empty %s so we are left with "File" + return hr; + } + HKEY hKey; + if (SUCCEEDED(hr = HCR_GetProgIdKeyOfExtension(DotExt, &hKey, TRUE))) + { + DWORD err = RegLoadMUIStringW(hKey, L"FriendlyTypeName", Buf, cchBuf, NULL, 0, NULL); + if (err && hr == S_OK) // ProgId default value fallback (but not if we only have a .ext key) + { + DWORD cb = cchBuf * sizeof(*Buf); + err = RegGetValueW(hKey, NULL, NULL, RRF_RT_REG_SZ, NULL, Buf, &cb); + } + RegCloseKey(hKey); + if (!err) + return err; + } + // No information in the registry, default to "UPPERCASEEXT File" + WCHAR ext[MAX_PATH + 33]; + if (LCMapStringW(LOCALE_USER_DEFAULT, LCMAP_UPPERCASE, ++DotExt, -1, ext, _countof(ext))) + DotExt = ext; + return GetExtensionDefaultDescription(DotExt, Buf, cchBuf); +} + +EXTERN_C HRESULT SHELL32_AssocGetFileDescription(PCWSTR Name, PWSTR Buf, UINT cchBuf) +{ + return SHELL32_AssocGetExtensionDescription(PathFindExtensionW(Name), Buf, cchBuf); +} + /************************************************************************** * IQueryAssociations * diff --git a/dll/win32/shell32/dialogs/filetypes.cpp b/dll/win32/shell32/dialogs/filetypes.cpp index c10c62573eb..a2206ad9fe9 100644 --- a/dll/win32/shell32/dialogs/filetypes.cpp +++ b/dll/win32/shell32/dialogs/filetypes.cpp @@ -89,7 +89,6 @@ typedef struct _FILE_TYPE_GLOBALS HICON hDefExtIconSmall; HBITMAP hOpenWithImage; HANDLE hHeap; - WCHAR DefExtTypeNameFmt[TYPENAME_CCHMAX]; WCHAR NoneString[42]; INT8 SortCol, SortReverse; UINT Restricted; @@ -298,12 +297,6 @@ GetTypeName(PFILE_TYPE_ENTRY Entry, PFILE_TYPE_GLOBALS pG) { StringCchCopyW(Entry->FileDescription, _countof(Entry->FileDescription), fi.szTypeName); } - else - { - // FIXME: Remove this hack when SHGetFileInfo is able to handle extensions without a ProgId (.ASM etc) - StringCchPrintfW(Entry->FileDescription, _countof(Entry->FileDescription), - pG->DefExtTypeNameFmt, &Entry->FileExtension[1]); - } } else { @@ -1773,12 +1766,6 @@ FileTypesDlg_Initialize(HWND hwndDlg) pG->himlSmall = ImageList_Create(pG->IconSize, pG->IconSize, ILC_COLOR32 | ILC_MASK, 256, 20); pG->hHeap = GetProcessHeap(); - if (!LoadStringW(shell32_hInstance, IDS_ANY_FILE, - pG->DefExtTypeNameFmt, _countof(pG->DefExtTypeNameFmt))) - { - LPCWSTR fallback = L"%s File"; // Default to English - StringCchCopyW(pG->DefExtTypeNameFmt, _countof(pG->DefExtTypeNameFmt), fallback); - } pG->NoneString[0] = UNICODE_NULL; LoadStringW(shell32_hInstance, IDS_NONE, pG->NoneString, _countof(pG->NoneString)); diff --git a/dll/win32/shell32/folders/CFSFolder.cpp b/dll/win32/shell32/folders/CFSFolder.cpp index 8ff94898d81..bb73ec85407 100644 --- a/dll/win32/shell32/folders/CFSFolder.cpp +++ b/dll/win32/shell32/folders/CFSFolder.cpp @@ -14,6 +14,13 @@ WINE_DEFAULT_DEBUG_CHANNEL (shell); static HRESULT SHELL32_GetCLSIDForDirectory(LPCWSTR pwszDir, LPCWSTR KeyName, CLSID* pclsidFolder); +static BOOL ItemIsFolder(PCUITEMID_CHILD pidl) +{ + const BYTE mask = PT_FS | PT_FS_FOLDER_FLAG | PT_FS_FILE_FLAG; + const BYTE type = _ILGetType(pidl); + return (type & mask) == (PT_FS | PT_FS_FOLDER_FLAG) || (type == PT_FS && ILGetNext(pidl)); +} + static LPCWSTR GetItemFileName(PCUITEMID_CHILD pidl, LPWSTR Buf, UINT cchMax) { FileStructW* pDataW = _ILGetFileStructW(pidl); @@ -34,6 +41,23 @@ static BOOL IsRealItem(const ITEMIDLIST &idl) return fsitem.dwFileSize | fsitem.uFileDate; } +static void GetItemDescription(PCUITEMID_CHILD pidl, LPWSTR Buf, UINT cchMax) +{ + HRESULT hr = E_FAIL; + if (ItemIsFolder(pidl)) + { + hr = SHELL32_AssocGetFSDirectoryDescription(Buf, cchMax); + } + else + { + WCHAR temp[MAX_PATH]; + LPCWSTR name = GetItemFileName(pidl, temp, _countof(temp)); + hr = SHELL32_AssocGetFileDescription(name ? name : L"", Buf, cchMax); + } + if (FAILED(hr) && cchMax) + Buf[0] = UNICODE_NULL; +} + static HKEY OpenKeyFromFileType(LPCWSTR pExtension, LPCWSTR KeyName) { HKEY hkey; @@ -1640,18 +1664,23 @@ HRESULT WINAPI CFSFolder::GetDetailsOf(PCUITEMID_CHILD pidl, { hr = S_OK; psd->str.uType = STRRET_WSTR; - psd->str.pOleStr = (LPWSTR)CoTaskMemAlloc(MAX_PATH * sizeof(WCHAR)); + if (iColumn != SHFSF_COL_NAME) + { + psd->str.pOleStr = (LPWSTR)CoTaskMemAlloc(MAX_PATH * sizeof(WCHAR)); + if (!psd->str.pOleStr) + return E_OUTOFMEMORY; + } /* the data from the pidl */ switch (iColumn) { case SHFSF_COL_NAME: - hr = GetDisplayNameOf (pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str); + hr = GetDisplayNameOf(pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str); break; case SHFSF_COL_SIZE: _ILGetFileSize(pidl, psd->str.pOleStr, MAX_PATH); break; case SHFSF_COL_TYPE: - _ILGetFileType(pidl, psd->str.pOleStr, MAX_PATH); + GetItemDescription(pidl, psd->str.pOleStr, MAX_PATH); break; case SHFSF_COL_MDATE: _ILGetFileDate(pidl, psd->str.pOleStr, MAX_PATH); diff --git a/dll/win32/shell32/wine/classes.c b/dll/win32/shell32/wine/classes.c index 12571e14c58..6138fdac267 100644 --- a/dll/win32/shell32/wine/classes.c +++ b/dll/win32/shell32/wine/classes.c @@ -44,7 +44,40 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell); -#define MAX_EXTENSION_LENGTH 20 +#define MAX_EXTENSION_LENGTH 20 // FIXME: The limit is 254? + +static LONG GetRegString(HKEY hKey, PCWSTR SubKey, PCWSTR Name, PWSTR Buffer, UINT cchBuf) +{ + DWORD cb = sizeof(*Buffer) * cchBuf; + return RegGetValueW(hKey, SubKey, Name, RRF_RT_REG_SZ, NULL, Buffer, &cb); +} + +HRESULT HCR_GetProgIdKeyOfExtension(PCWSTR szExtension, PHKEY phKey, BOOL AllowFallback) +{ + LONG err; + WCHAR ext[max(1 + MAX_EXTENSION_LENGTH + 1, MAX_PATH)]; + WCHAR progid[MAX_PATH]; + if (szExtension[0] != '.') + { + ext[0] = '.'; + lstrcpynW(ext + 1, szExtension, _countof(ext) - 1); + szExtension = ext; + } + err = GetRegString(HKEY_CLASSES_ROOT, szExtension, NULL, progid, _countof(progid)); + if (!err && progid[0] != UNICODE_NULL) + { + err = RegOpenKeyExW(HKEY_CLASSES_ROOT, progid, 0, KEY_READ, phKey); + if (!err) + return err; /* A real ProgId key, return S_OK */ + } + if (AllowFallback) + { + err = RegOpenKeyExW(HKEY_CLASSES_ROOT, szExtension, 0, KEY_READ, phKey); + if (!err) + return S_FALSE; + } + return HRESULT_FROM_WIN32(err); +} BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, LONG len, BOOL bPrependDot) { @@ -67,14 +100,6 @@ BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, LONG len, BOOL return FALSE; } -#ifdef __REACTOS__ - if (!RegLoadMUIStringW(hkey, L"FriendlyTypeName", szFileType, len, NULL, 0, NULL)) - { - RegCloseKey(hkey); - return TRUE; - } -#endif - if (RegQueryValueW(hkey, NULL, szFileType, &len)) { RegCloseKey(hkey); @@ -109,14 +134,6 @@ BOOL HCR_MapTypeToValueA(LPCSTR szExtension, LPSTR szFileType, LONG len, BOOL bP return FALSE; } -#ifdef __REACTOS__ - if (!RegLoadMUIStringA(hkey, "FriendlyTypeName", szFileType, len, NULL, 0, NULL)) - { - RegCloseKey(hkey); - return TRUE; - } -#endif - if (RegQueryValueA(hkey, NULL, szFileType, &len)) { RegCloseKey(hkey); diff --git a/dll/win32/shell32/wine/pidl.c b/dll/win32/shell32/wine/pidl.c index f6058d04ee5..de484982b15 100644 --- a/dll/win32/shell32/wine/pidl.c +++ b/dll/win32/shell32/wine/pidl.c @@ -1183,6 +1183,14 @@ static HRESULT _ILParsePathW(LPCWSTR path, LPWIN32_FIND_DATAW lpFindFile, return ret; } +LPITEMIDLIST SHELL32_CreateSimpleIDListFromPath(LPCWSTR pszPath, DWORD dwAttributes) +{ + WIN32_FIND_DATAW data = { dwAttributes }; + LPITEMIDLIST pidl = NULL; + _ILParsePathW(pszPath, &data, TRUE, &pidl, NULL); + return pidl; +} + /************************************************************************* * SHSimpleIDListFromPath [SHELL32.162] * @@ -2583,59 +2591,6 @@ BOOL _ILGetExtension(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize) return TRUE; } -/************************************************************************* - * _ILGetFileType - * - * Given the ItemIdList, get the file type description - * - * PARAMS - * pidl [I] The ItemIDList (simple) - * pOut [I] The buffer to save the result - * uOutsize [I] The size of the buffer - * - * RETURNS - * nothing - * - * NOTES - * This function copies as much as possible into the buffer. - */ -void _ILGetFileType(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize) -{ - WCHAR sType[64], sTemp[64]; - - if(_ILIsValue(pidl)) - { - if(uOutSize > 0) - pOut[0] = 0; - if (_ILGetExtension(pidl, sType, _countof(sType))) - { - if (HCR_MapTypeToValueW(sType, sTemp, _countof(sTemp), TRUE)) - { - /* retrieve description */ - if (HCR_MapTypeToValueW(sTemp, pOut, uOutSize, FALSE)) - return; - } - - /* display Ext-file as description */ - CharUpperW(sType); - /* load localized file string */ - sTemp[0] = UNICODE_NULL; - if (LoadStringW(shell32_hInstance, IDS_ANY_FILE, sTemp, _countof(sTemp))) - { - sTemp[_countof(sTemp) - 1] = UNICODE_NULL; - StringCchPrintfW(pOut, uOutSize, sTemp, sType); - } - } - } - else - { - pOut[0] = UNICODE_NULL; - LoadStringW(shell32_hInstance, IDS_DIRECTORY, pOut, uOutSize); - /* make sure its null terminated */ - pOut[uOutSize - 1] = UNICODE_NULL; - } -} - /************************************************************************* * _ILGetFileAttributes * diff --git a/dll/win32/shell32/wine/pidl.h b/dll/win32/shell32/wine/pidl.h index ef0002941f7..28fff42feb4 100644 --- a/dll/win32/shell32/wine/pidl.h +++ b/dll/win32/shell32/wine/pidl.h @@ -246,7 +246,6 @@ DWORD _ILSimpleGetTextW (LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize) DEC BOOL _ILGetFileDate (LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize) DECLSPEC_HIDDEN; DWORD _ILGetFileSize (LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize) DECLSPEC_HIDDEN; BOOL _ILGetExtension (LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize) DECLSPEC_HIDDEN; -void _ILGetFileType (LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize) DECLSPEC_HIDDEN; DWORD _ILGetFileAttributes(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize) DECLSPEC_HIDDEN; BOOL _ILGetFileDateTime (LPCITEMIDLIST pidl, FILETIME *ft) DECLSPEC_HIDDEN; DWORD _ILGetDrive (LPCITEMIDLIST, LPWSTR, UINT) DECLSPEC_HIDDEN; @@ -291,6 +290,7 @@ LPITEMIDLIST _ILCreateGuidFromStrW(LPCWSTR szGUID) DECLSPEC_HIDDEN; LPITEMIDLIST _ILCreateDesktop (void) DECLSPEC_HIDDEN; LPITEMIDLIST _ILCreateFromFindDataW(const WIN32_FIND_DATAW *stffile) DECLSPEC_HIDDEN; HRESULT _ILCreateFromPathW (LPCWSTR szPath, LPITEMIDLIST* ppidl) DECLSPEC_HIDDEN; +LPITEMIDLIST SHELL32_CreateSimpleIDListFromPath(LPCWSTR pszPath, DWORD dwAttributes); /* Other helpers */ LPITEMIDLIST _ILCreateMyComputer (void) DECLSPEC_HIDDEN; diff --git a/dll/win32/shell32/wine/shell32_main.c b/dll/win32/shell32/wine/shell32_main.c index e6dc9810c79..04967da66d1 100644 --- a/dll/win32/shell32/wine/shell32_main.c +++ b/dll/win32/shell32/wine/shell32_main.c @@ -310,6 +310,28 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs) return argv; } +static HRESULT SHELL_GetDetailsOfToBuffer(IShellFolder *psf, PCUITEMID_CHILD pidl, + UINT col, LPWSTR Buf, UINT cchBuf) +{ + IShellFolder2 *psf2; + IShellDetails *psd; + SHELLDETAILS details; + HRESULT hr = IShellFolder_QueryInterface(psf, &IID_IShellFolder2, (void**)&psf2); + if (SUCCEEDED(hr)) + { + hr = IShellFolder2_GetDetailsOf(psf2, pidl, col, &details); + IShellFolder2_Release(psf2); + } + else if (SUCCEEDED(hr = IShellFolder_QueryInterface(psf, &IID_IShellDetails, (void**)&psd))) + { + hr = IShellDetails_GetDetailsOf(psd, pidl, col, &details); + IShellDetails_Release(psd); + } + if (SUCCEEDED(hr)) + hr = StrRetToStrNW(Buf, cchBuf, &details.str, pidl) ? S_OK : E_FAIL; + return hr; +} + static DWORD shgfi_get_exe_type(LPCWSTR szFullPath) { BOOL status = FALSE; @@ -386,17 +408,11 @@ BOOL SHELL_IsShortcut(LPCITEMIDLIST pidlLast) BOOL ret = FALSE; if (_ILGetExtension(pidlLast, szTemp, _countof(szTemp)) && - HCR_MapTypeToValueW(szTemp, szTemp, _countof(szTemp), TRUE)) + SUCCEEDED(HCR_GetProgIdKeyOfExtension(szTemp, &keyCls, FALSE))) { - if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CLASSES_ROOT, szTemp, 0, KEY_QUERY_VALUE, &keyCls)) - { - if (ERROR_SUCCESS == RegQueryValueExW(keyCls, L"IsShortcut", NULL, NULL, NULL, NULL)) - ret = TRUE; - - RegCloseKey(keyCls); - } + ret = RegQueryValueExW(keyCls, L"IsShortcut", NULL, NULL, NULL, NULL) == ERROR_SUCCESS; + RegCloseKey(keyCls); } - return ret; } @@ -420,7 +436,7 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, DWORD dwAttributes = 0; IShellFolder * psfParent = NULL; IExtractIconW * pei = NULL; - LPITEMIDLIST pidlLast = NULL, pidl = NULL; + LPITEMIDLIST pidlLast = NULL, pidl = NULL, pidlFree = NULL; HRESULT hr = S_OK; BOOL IconNotYetLoaded=TRUE; UINT uGilFlags = 0; @@ -453,6 +469,27 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, { lstrcpynW(szFullPath, path, MAX_PATH); } + + if ((flags & SHGFI_TYPENAME) && !PathIsRootW(szFullPath)) + { + HRESULT hr2; + if (!(flags & SHGFI_USEFILEATTRIBUTES)) + { + dwFileAttributes = GetFileAttributesW(szFullPath); + if (dwFileAttributes == INVALID_FILE_ATTRIBUTES) + dwFileAttributes = 0; + } + if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + hr2 = SHELL32_AssocGetFSDirectoryDescription(psfi->szTypeName, _countof(psfi->szTypeName)); + else + hr2 = SHELL32_AssocGetFileDescription(path, psfi->szTypeName, _countof(psfi->szTypeName)); + if (SUCCEEDED(hr2)) + { + flags &= ~SHGFI_TYPENAME; + if (!(flags & ~SHGFI_USEFILEATTRIBUTES)) + return ret; /* Bail out early if this was our only operation */ + } + } } else { @@ -489,31 +526,26 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, if (flags & SHGFI_PIDL) { - pidl = ILClone((LPCITEMIDLIST)path); - } - else if (!(flags & SHGFI_USEFILEATTRIBUTES)) - { - hr = SHILCreateFromPathW(szFullPath, &pidl, &dwAttributes); + pidl = (LPITEMIDLIST)path; + hr = pidl ? S_OK : E_FAIL; } - - if ((flags & SHGFI_PIDL) || !(flags & SHGFI_USEFILEATTRIBUTES)) + else { - /* get the parent shellfolder */ - if (pidl) + if (flags & SHGFI_USEFILEATTRIBUTES) { - hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, - (LPCITEMIDLIST*)&pidlLast ); - if (SUCCEEDED(hr)) - pidlLast = ILClone(pidlLast); - else - hr = S_OK; - ILFree(pidl); + pidl = SHELL32_CreateSimpleIDListFromPath(szFullPath, dwFileAttributes); + hr = pidl ? S_OK : E_FAIL; } else { - ERR("pidl is null!\n"); - return FALSE; + hr = SHILCreateFromPathW(szFullPath, &pidl, &dwAttributes); } + pidlFree = pidl; + } + + if (SUCCEEDED(hr)) + { + hr = SHBindToParent(pidl, &IID_IShellFolder, (void**)&psfParent, (LPCITEMIDLIST*)&pidlLast); } /* get the attributes of the child */ @@ -523,11 +555,7 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, { psfi->dwAttributes = 0xffffffff; } - if (psfParent) - { - IShellFolder_GetAttributesOf(psfParent, 1, (LPCITEMIDLIST*)&pidlLast, - &(psfi->dwAttributes)); - } + hr = IShellFolder_GetAttributesOf(psfParent, 1, (LPCITEMIDLIST*)&pidlLast, &psfi->dwAttributes); } if (flags & SHGFI_USEFILEATTRIBUTES) @@ -541,55 +569,20 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, /* get the displayname */ if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME)) { - if (flags & SHGFI_USEFILEATTRIBUTES && !(flags & SHGFI_PIDL)) - { - lstrcpyW (psfi->szDisplayName, PathFindFileNameW(szFullPath)); - } - else if (psfParent) - { - STRRET str; - hr = IShellFolder_GetDisplayNameOf( psfParent, pidlLast, - SHGDN_INFOLDER, &str); - StrRetToStrNW (psfi->szDisplayName, MAX_PATH, &str, pidlLast); - } + STRRET str; + psfi->szDisplayName[0] = UNICODE_NULL; + hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &str); + if (SUCCEEDED(hr)) + StrRetToStrNW(psfi->szDisplayName, _countof(psfi->szDisplayName), &str, pidlLast); } /* get the type name */ if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME)) { - if (!(flags & SHGFI_USEFILEATTRIBUTES) || (flags & SHGFI_PIDL)) - { - _ILGetFileType(pidlLast, psfi->szTypeName, _countof(psfi->szTypeName)); - } - else - { - if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - strcatW (psfi->szTypeName, L"Folder"); - else - { - WCHAR sTemp[64]; - - lstrcpyW(sTemp,PathFindExtensionW(szFullPath)); - if (sTemp[0] == 0 || (sTemp[0] == '.' && sTemp[1] == 0)) - { - /* "name" or "name." => "File" */ - lstrcpynW (psfi->szTypeName, L"File", 64); - } - else if (!( HCR_MapTypeToValueW(sTemp, sTemp, 64, TRUE) && - HCR_MapTypeToValueW(sTemp, psfi->szTypeName, 80, FALSE ))) - { - if (sTemp[0]) - { - lstrcpynW (psfi->szTypeName, sTemp, 64); - strcatW (psfi->szTypeName, L" file"); - } - else - { - lstrcpynW (psfi->szTypeName, L"File", 64); - } - } - } - } + /* FIXME: Use IShellFolder2::GetDetailsEx */ + UINT col = _ILIsDrive(pidlLast) ? 1 : 2; /* SHFSF_COL_TYPE */ + psfi->szTypeName[0] = UNICODE_NULL; + hr = SHELL_GetDetailsOfToBuffer(psfParent, pidlLast, col, psfi->szTypeName, _countof(psfi->szTypeName)); } /* ### icons ###*/ @@ -757,12 +750,11 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, if (psfParent) IShellFolder_Release(psfParent); + SHFree(pidlFree); if (hr != S_OK) ret = FALSE; - SHFree(pidlLast); - TRACE ("icon=%p index=0x%08x attr=0x%08x name=%s type=%s ret=0x%08lx\n", psfi->hIcon, psfi->iIcon, psfi->dwAttributes, debugstr_w(psfi->szDisplayName), debugstr_w(psfi->szTypeName), ret); diff --git a/dll/win32/shell32/wine/shell32_main.h b/dll/win32/shell32/wine/shell32_main.h index 73bebc71d3b..4392a50659a 100644 --- a/dll/win32/shell32/wine/shell32_main.h +++ b/dll/win32/shell32/wine/shell32_main.h @@ -46,6 +46,7 @@ BOOL PidlToSicIndex (IShellFolder * sh, LPCITEMIDLIST pidl, BOOL bBigIcon, UINT INT SIC_GetIconIndex (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags ) DECLSPEC_HIDDEN; /* Classes Root */ +HRESULT HCR_GetProgIdKeyOfExtension(PCWSTR szExtension, PHKEY phKey, BOOL AllowFallback); BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, LONG len, BOOL bPrependDot) DECLSPEC_HIDDEN; BOOL HCR_GetDefaultVerbW( HKEY hkeyClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len ) DECLSPEC_HIDDEN; BOOL HCR_GetExecuteCommandW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len ) DECLSPEC_HIDDEN; @@ -67,6 +68,12 @@ BOOL HCR_GetClassNameA(REFIID riid, LPSTR szDest, DWORD len) DECLSPEC_HIDDEN; BOOL HCR_GetFolderAttributes(LPCITEMIDLIST pidlFolder, LPDWORD dwAttributes) DECLSPEC_HIDDEN; +/* File associations */ +#define SHELL32_AssocGetFolderDescription SHELL32_AssocGetFSDirectoryDescription +HRESULT SHELL32_AssocGetFSDirectoryDescription(PWSTR Buf, UINT cchBuf); +HRESULT SHELL32_AssocGetFileDescription(PCWSTR Name, PWSTR Buf, UINT cchBuf); + + DWORD WINAPI ParseFieldA(LPCSTR src, DWORD nField, LPSTR dst, DWORD len) DECLSPEC_HIDDEN; DWORD WINAPI ParseFieldW(LPCWSTR src, DWORD nField, LPWSTR dst, DWORD len) DECLSPEC_HIDDEN; diff --git a/modules/rostests/apitests/shell32/CMakeLists.txt b/modules/rostests/apitests/shell32/CMakeLists.txt index c0a6686eecf..2a90a0e009d 100644 --- a/modules/rostests/apitests/shell32/CMakeLists.txt +++ b/modules/rostests/apitests/shell32/CMakeLists.txt @@ -38,6 +38,7 @@ list(APPEND SOURCE ShellExecuteEx.cpp ShellExecuteW.cpp ShellHook.cpp + ShellInfo.cpp ShellState.cpp SHGetAttributesFromDataObject.cpp SHLimitInputEdit.cpp diff --git a/modules/rostests/apitests/shell32/ItemIDList.cpp b/modules/rostests/apitests/shell32/ItemIDList.cpp index 9665dede641..02c4e694bd6 100644 --- a/modules/rostests/apitests/shell32/ItemIDList.cpp +++ b/modules/rostests/apitests/shell32/ItemIDList.cpp @@ -148,6 +148,12 @@ START_TEST(SHSimpleIDListFromPath) ok_long(item->mkid.abID[0] & 0x70, 0x20); // Something in My Computer ok_char(item->mkid.abID[1] | 32, 'x' | 32); // x: } + + LPITEMIDLIST pidl; + ok_int((pidl = SHSimpleIDListFromPath(L"c:")) != NULL, TRUE); + ILFree(pidl); + ok_int((pidl = SHSimpleIDListFromPath(L"c:\\")) != NULL, TRUE); + ILFree(pidl); } START_TEST(ILCreateFromPath) diff --git a/modules/rostests/apitests/shell32/ShellInfo.cpp b/modules/rostests/apitests/shell32/ShellInfo.cpp new file mode 100644 index 00000000000..13921611667 --- /dev/null +++ b/modules/rostests/apitests/shell32/ShellInfo.cpp @@ -0,0 +1,76 @@ +/* + * PROJECT: ReactOS API tests + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) + * PURPOSE: Test for SHGetFileInfo + * COPYRIGHT: Copyright 2024 Whindmar Saksit <whindsaks(a)proton.me> + */ + +#include "shelltest.h" +#include <shellutils.h> + +#define UNIQUEEXT L"ABC123XYZ" +#define my_ok_all_flags(val, flags) ok_eq_hex((val) & (flags), (flags)) + +static DWORD_PTR SHGFI(PCWSTR Path, SHFILEINFOW &Info, UINT Flags, UINT Attributes = 0) +{ + return SHGetFileInfoW(Path, Attributes, &Info, sizeof(Info), Flags); +} + +static DWORD_PTR SHGFI(LPCITEMIDLIST Pidl, SHFILEINFOW &Info, UINT Flags, UINT Attributes = 0) +{ + return SHGFI((PCWSTR)Pidl, Info, Flags | SHGFI_PIDL, Attributes); +} + +START_TEST(SHGetFileInfo) +{ + CCoInit ComInit; + LPITEMIDLIST pidl; + SHFILEINFOW info; + UINT flags; + WCHAR buf[MAX_PATH]; + + ok_int(SHGFI((PCWSTR)NULL, info, 0), FALSE); + ok_int(SHGFI((PCWSTR)NULL, info, SHGFI_DISPLAYNAME), FALSE); + ok_int(SHGFI((PCWSTR)NULL, info, SHGFI_TYPENAME), FALSE); + ok_int(SHGFI((PCWSTR)NULL, info, SHGFI_ICONLOCATION), FALSE); + ok_int(SHGFI((PCWSTR)NULL, info, SHGFI_SYSICONINDEX), FALSE); + ok_int(SHGFI(UNIQUEEXT, info, SHGFI_USEFILEATTRIBUTES), TRUE); // Success when asking for no info + ok_int(SHGetFileInfoW(UNIQUEEXT, 0, NULL, 0, SHGFI_DISPLAYNAME | SHGFI_USEFILEATTRIBUTES), FALSE); // NULL pointer + ok_int(SHGFI(UNIQUEEXT, info, SHGFI_EXETYPE | SHGFI_USEFILEATTRIBUTES), TRUE); // Invalid combination, returns TRUE! + + GetModuleFileNameW(NULL, buf, _countof(buf)); + ok_int(LOWORD(SHGFI(buf, info, SHGFI_EXETYPE)), 0x4550); // 'PE' + + flags = SHGFI_TYPENAME | SHGFI_USEFILEATTRIBUTES | SHGFI_ATTRIBUTES; + ZeroMemory(&info, sizeof(info)); + info.dwAttributes = ~SFGAO_VALIDATE; + ok_int(SHGFI(UNIQUEEXT, info, flags | SHGFI_ATTR_SPECIFIED), TRUE); + ok_ptr(StrStrIW(info.szTypeName, UNIQUEEXT), NULL); // A file without extension (not "EXT File") + my_ok_all_flags(info.dwAttributes, SFGAO_FILESYSTEM | SFGAO_STREAM); + + ZeroMemory(&info, sizeof(info)); + info.dwAttributes = ~SFGAO_VALIDATE; + ok_int(SHGFI(UNIQUEEXT, info, flags | SHGFI_ATTR_SPECIFIED, FILE_ATTRIBUTE_DIRECTORY), TRUE); + ok_ptr(StrStrIW(info.szTypeName, UNIQUEEXT), NULL); // A directory (not "EXT File") + my_ok_all_flags(info.dwAttributes, SFGAO_FILESYSTEM | SFGAO_FOLDER); + + ZeroMemory(&info, sizeof(info)); + info.dwAttributes = ~SFGAO_VALIDATE; + ok_int(SHGFI(L"." UNIQUEEXT, info, flags | SHGFI_ATTR_SPECIFIED), TRUE); + ok_bool_true(StrStrIW(info.szTypeName, UNIQUEEXT) != NULL, ".ext is treated as extension"); + my_ok_all_flags(info.dwAttributes, SFGAO_FILESYSTEM | SFGAO_STREAM); + + info.dwAttributes = ~SFGAO_VALIDATE; + ok_int(SHGFI(L"c:", info, flags | SHGFI_ATTR_SPECIFIED), TRUE); // ROS fails this, a parsing bug in CDrivesFolder? + my_ok_all_flags(info.dwAttributes, SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR); + + info.dwAttributes = ~SFGAO_VALIDATE; + ok_int(SHGFI(L"c:\\", info, flags | SHGFI_ATTR_SPECIFIED), TRUE); + my_ok_all_flags(info.dwAttributes, SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR); + + pidl = SHSimpleIDListFromPath(L"c:\\foo"); + info.iIcon = -1; + ok_int(SHGFI(pidl, info, SHGFI_SYSICONINDEX) > TRUE, TRUE); + ok_int(info.iIcon != -1, TRUE); + ILFree(pidl); +} diff --git a/modules/rostests/apitests/shell32/testlist.c b/modules/rostests/apitests/shell32/testlist.c index 4b16a6dd4d5..ff06c5a5dc6 100644 --- a/modules/rostests/apitests/shell32/testlist.c +++ b/modules/rostests/apitests/shell32/testlist.c @@ -41,6 +41,7 @@ extern void func_ShellExecuteW(void); extern void func_ShellHook(void); extern void func_ShellState(void); extern void func_SHGetAttributesFromDataObject(void); +extern void func_SHGetFileInfo(void); extern void func_SHLimitInputEdit(void); extern void func_SHParseDisplayName(void); extern void func_SHSimpleIDListFromPath(void); @@ -86,6 +87,7 @@ const struct test winetest_testlist[] = { "ShellHook", func_ShellHook }, { "ShellState", func_ShellState }, { "SHGetAttributesFromDataObject", func_SHGetAttributesFromDataObject }, + { "SHGetFileInfo", func_SHGetFileInfo }, { "SHLimitInputEdit", func_SHLimitInputEdit }, { "SHParseDisplayName", func_SHParseDisplayName }, { "SHSimpleIDListFromPath", func_SHSimpleIDListFromPath },
1 month
1
0
0
0
[reactos] 01/01: [BATTC] Fix comparisons when choosing to complete the status IRP
by Hervé Poussineau
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=997b1797f4a90360f6113…
commit 997b1797f4a90360f6113265701245814bf3f934 Author: Hervé Poussineau <hpoussin(a)reactos.org> AuthorDate: Sat Nov 16 23:26:51 2024 +0100 Commit: Hervé Poussineau <hpoussin(a)reactos.org> CommitDate: Sat Nov 16 23:33:41 2024 +0100 [BATTC] Fix comparisons when choosing to complete the status IRP They were reversed, which meant to immediately complete the IRP if conditions were NOT satisfied. Remove a now useless/invalid call to QueryStatus, to return the status which lead to IRP completion. --- drivers/battery/battc/battc.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/drivers/battery/battc/battc.c b/drivers/battery/battc/battc.c index 8ddacd64359..dd08a9cd956 100644 --- a/drivers/battery/battc/battc.c +++ b/drivers/battery/battc/battc.c @@ -112,9 +112,9 @@ BatteryClassStatusNotify(PVOID ClassData) ExAcquireFastMutex(&BattClass->Mutex); - if (!(BattWait->PowerState & BattStatus.PowerState) || - (BattWait->HighCapacity > BattStatus.Capacity) || - (BattWait->LowCapacity < BattStatus.Capacity)) + if (BattWait->PowerState != BattStatus.PowerState || + BattWait->HighCapacity < BattStatus.Capacity || + BattWait->LowCapacity > BattStatus.Capacity) { KeSetEvent(&BattClass->WaitEvent, IO_NO_INCREMENT, FALSE); } @@ -274,16 +274,15 @@ BatteryClassIoctl(PVOID ClassData, Timeout.QuadPart = Int32x32To64(BattWait.Timeout, -1000); + BattStatus = Irp->AssociatedIrp.SystemBuffer; Status = BattClass->MiniportInfo.QueryStatus(BattClass->MiniportInfo.Context, BattWait.BatteryTag, - (PBATTERY_STATUS)Irp->AssociatedIrp.SystemBuffer); - - BattStatus = Irp->AssociatedIrp.SystemBuffer; + BattStatus); if (!NT_SUCCESS(Status) || - ((BattWait.PowerState & BattStatus->PowerState) && - (BattWait.HighCapacity <= BattStatus->Capacity) && - (BattWait.LowCapacity >= BattStatus->Capacity))) + (BattWait.PowerState == BattStatus->PowerState && + BattWait.HighCapacity >= BattStatus->Capacity && + BattWait.LowCapacity <= BattStatus->Capacity)) { BattNotify.PowerState = BattWait.PowerState; BattNotify.HighCapacity = BattWait.HighCapacity; @@ -304,25 +303,14 @@ BatteryClassIoctl(PVOID ClassData, KernelMode, FALSE, BattWait.Timeout != -1 ? &Timeout : NULL); + if (Status == STATUS_TIMEOUT) + Status = STATUS_SUCCESS; ExAcquireFastMutex(&BattClass->Mutex); BattClass->Waiting = FALSE; ExReleaseFastMutex(&BattClass->Mutex); BattClass->MiniportInfo.DisableStatusNotify(BattClass->MiniportInfo.Context); - - if (Status == STATUS_SUCCESS) - { - Status = BattClass->MiniportInfo.QueryStatus(BattClass->MiniportInfo.Context, - BattWait.BatteryTag, - (PBATTERY_STATUS)Irp->AssociatedIrp.SystemBuffer); - if (NT_SUCCESS(Status)) - Irp->IoStatus.Information = sizeof(ULONG); - } - else - { - Status = STATUS_NO_SUCH_DEVICE; - } } else {
1 month, 1 week
1
0
0
0
[reactos] 10/10: [VCRUNTIME][CRT] Change WCHAR_MIN/WCHAR_MAX to match native headers
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9dedcb67e958078f380f9…
commit 9dedcb67e958078f380f9fd8beac0e05486055b1 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Fri Oct 11 18:43:07 2024 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Sat Nov 16 20:01:49 2024 +0200 [VCRUNTIME][CRT] Change WCHAR_MIN/WCHAR_MAX to match native headers This avoids conflicting definitions with MS CRT headers. --- sdk/include/crt/wchar.h | 4 ++-- sdk/include/vcruntime/stdint.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/include/crt/wchar.h b/sdk/include/crt/wchar.h index c558279ed47..b4930959ce6 100644 --- a/sdk/include/crt/wchar.h +++ b/sdk/include/crt/wchar.h @@ -25,10 +25,10 @@ extern "C" { #endif #ifndef WCHAR_MIN -#define WCHAR_MIN 0 +#define WCHAR_MIN 0x0000 #endif #ifndef WCHAR_MAX -#define WCHAR_MAX ((wchar_t)-1) /* UINT16_MAX */ +#define WCHAR_MAX 0xffff /* UINT16_MAX */ #endif #ifndef WEOF diff --git a/sdk/include/vcruntime/stdint.h b/sdk/include/vcruntime/stdint.h index a73ded330a8..1c3a0507706 100644 --- a/sdk/include/vcruntime/stdint.h +++ b/sdk/include/vcruntime/stdint.h @@ -158,10 +158,10 @@ __MINGW_EXTENSION typedef unsigned long long uintmax_t; #endif #ifndef WCHAR_MIN /* also in wchar.h */ -#define WCHAR_MIN 0 +#define WCHAR_MIN 0x0000 #endif #ifndef WCHAR_MAX -#define WCHAR_MAX ((wchar_t)-1) /* UINT16_MAX */ +#define WCHAR_MAX 0xffff /* UINT16_MAX */ #endif /*
1 month, 1 week
1
0
0
0
[reactos] 09/10: [VCRUNTIME] stdint.h: Update include guard for MIN/MAX macros
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=53d3cc5f3fda8ab39c1ca…
commit 53d3cc5f3fda8ab39c1ca6e12a1fecd2acacb224 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Fri Oct 11 14:53:52 2024 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Sat Nov 16 20:01:49 2024 +0200 [VCRUNTIME] stdint.h: Update include guard for MIN/MAX macros Include MIN/MAX macros for C++11 and above without the need to define __STDC_LIMIT_MACROS. This is what mingw uses. --- sdk/include/vcruntime/stdint.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/include/vcruntime/stdint.h b/sdk/include/vcruntime/stdint.h index 3246acf00bf..a73ded330a8 100644 --- a/sdk/include/vcruntime/stdint.h +++ b/sdk/include/vcruntime/stdint.h @@ -69,7 +69,8 @@ __MINGW_EXTENSION typedef long long intmax_t; __MINGW_EXTENSION typedef unsigned long long uintmax_t; /* 7.18.2 Limits of specified-width integer types */ -#if !defined ( __cplusplus) || defined (__STDC_LIMIT_MACROS) +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) || \ + defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L /* 7.18.2.1 Limits of exact-width integer types */ #define INT8_MIN (-128)
1 month, 1 week
1
0
0
0
[reactos] 08/10: [VCRUNTIME] Add missing definitions
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e5633f656f2ff989e928d…
commit e5633f656f2ff989e928d38dd38eee81e8722966 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Sun Oct 13 19:13:36 2024 +0300 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Sat Nov 16 20:01:49 2024 +0200 [VCRUNTIME] Add missing definitions --- sdk/include/vcruntime/eh.h | 4 ++++ sdk/include/vcruntime/vcruntime.h | 14 ++++++++++++++ sdk/include/vcruntime/vcruntime_startup.h | 15 +++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/sdk/include/vcruntime/eh.h b/sdk/include/vcruntime/eh.h index d37f86e81a0..307822930d3 100644 --- a/sdk/include/vcruntime/eh.h +++ b/sdk/include/vcruntime/eh.h @@ -16,6 +16,10 @@ #error eh.h is only for C++! #endif +extern "C++" { + _VCRT_EXPORT_STD class type_info; +} + typedef void (__cdecl *terminate_function)(void); typedef void (__cdecl *terminate_handler)(void); typedef void (__cdecl *unexpected_function)(void); diff --git a/sdk/include/vcruntime/vcruntime.h b/sdk/include/vcruntime/vcruntime.h index 3344cec75ee..cd7d5913407 100644 --- a/sdk/include/vcruntime/vcruntime.h +++ b/sdk/include/vcruntime/vcruntime.h @@ -1,6 +1,14 @@ +/* + * PROJECT: ReactOS SDK + * LICENSE: MIT (
https://spdx.org/licenses/MIT
) + * PURPOSE: Common definitions + * COPYRIGHT: Copyright 2024 Timo Kreuzer (timo.kreuzer(a)reactos.org) + */ #pragma once +#define _VCRUNTIME_H + #include <_mingw.h> #include <sal.h> #include <vadefs.h> @@ -70,6 +78,12 @@ _CRT_BEGIN_C_HEADER #endif #endif +#ifdef _BUILD_STD_MODULE + #define _VCRT_EXPORT_STD export +#else + #define _VCRT_EXPORT_STD +#endif + #ifdef __GNUC__ #define _CRT_DEPRECATE_TEXT(_Text) __attribute__ ((deprecated)) #elif defined(_MSC_VER) diff --git a/sdk/include/vcruntime/vcruntime_startup.h b/sdk/include/vcruntime/vcruntime_startup.h index f84012e542e..77d53acd474 100644 --- a/sdk/include/vcruntime/vcruntime_startup.h +++ b/sdk/include/vcruntime/vcruntime_startup.h @@ -1,6 +1,16 @@ +/* + * PROJECT: ReactOS SDK + * LICENSE: MIT (
https://spdx.org/licenses/MIT
) + * PURPOSE: Definitions for CRT startup functionality + * COPYRIGHT: Copyright 2024 Timo Kreuzer (timo.kreuzer(a)reactos.org) + */ #pragma once +#include <vcruntime.h> + +_CRT_BEGIN_C_HEADER + typedef enum _crt_argv_mode { _crt_argv_no_arguments, @@ -21,4 +31,9 @@ typedef enum _crt_exit_return_mode _crt_exit_return_to_caller } _crt_exit_return_mode; +__vcrt_bool __cdecl __vcrt_initialize(void); __vcrt_bool __cdecl __vcrt_uninitialize(_In_ __vcrt_bool _Terminating); + +int __cdecl __isa_available_init(void); + +_CRT_END_C_HEADER
1 month, 1 week
1
0
0
0
[reactos] 07/10: [VCRUNTIME] Allow disabling GCC attributes for SAL
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e2024204563b1a8c6d8c2…
commit e2024204563b1a8c6d8c216daff1355b5bae519d Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Sun Oct 13 10:31:24 2024 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Sat Nov 16 20:01:49 2024 +0200 [VCRUNTIME] Allow disabling GCC attributes for SAL --- sdk/include/vcruntime/gcc_sal.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/include/vcruntime/gcc_sal.h b/sdk/include/vcruntime/gcc_sal.h index 421e4e18e16..2373a50c805 100644 --- a/sdk/include/vcruntime/gcc_sal.h +++ b/sdk/include/vcruntime/gcc_sal.h @@ -16,6 +16,7 @@ #define __has_attribute(__x) 0 #endif +#ifndef _GCC_NO_SAL_ATTRIIBUTES #if __has_attribute(warn_unused_result) # undef _Must_inspect_result_ /* FIXME: Not really equivalent */ @@ -24,3 +25,4 @@ /* This one is 1:1 equivalent */ # define _Check_return_ __attribute__((__warn_unused_result__)) #endif +#endif // _GCC_NO_SAL_ATTRIIBUTES
1 month, 1 week
1
0
0
0
[reactos] 06/10: [VCRUNTIME] Add pmmintrin.h
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=764cb5b8a5736f934fcf8…
commit 764cb5b8a5736f934fcf82aa0ca7bff5c4b9bf4b Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Mon Oct 28 19:10:25 2024 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Sat Nov 16 20:01:49 2024 +0200 [VCRUNTIME] Add pmmintrin.h --- sdk/include/vcruntime/pmmintrin.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sdk/include/vcruntime/pmmintrin.h b/sdk/include/vcruntime/pmmintrin.h new file mode 100644 index 00000000000..012db450ec6 --- /dev/null +++ b/sdk/include/vcruntime/pmmintrin.h @@ -0,0 +1,16 @@ +/* + * PROJECT: ReactOS SDK + * LICENSE: MIT (
https://spdx.org/licenses/MIT
) + * PURPOSE: Intrinsics for the SSE3 instruction set + * COPYRIGHT: Copyright 2024 Timo Kreuzer (timo.kreuzer(a)reactos.org) + */ + +#pragma once + +#define _INCLUDED_PMM + +#include <emmintrin.h> + +#define _MM_DENORMALS_ZERO_MASK 0x0040 +#define _MM_DENORMALS_ZERO_ON 0x0040 +#define _MM_DENORMALS_ZERO_OFF 0x0000
1 month, 1 week
1
0
0
0
[reactos] 05/10: [VCRUNTIME] Fix emmintrin.h
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a67f36888c6e371a88fe0…
commit a67f36888c6e371a88fe0c31f661e2187141a862 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Fri Oct 11 17:07:58 2024 +0300 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Sat Nov 16 20:01:49 2024 +0200 [VCRUNTIME] Fix emmintrin.h --- sdk/include/vcruntime/emmintrin.h | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/sdk/include/vcruntime/emmintrin.h b/sdk/include/vcruntime/emmintrin.h index 2fbb5bd0c9f..2c053599e0d 100644 --- a/sdk/include/vcruntime/emmintrin.h +++ b/sdk/include/vcruntime/emmintrin.h @@ -63,13 +63,20 @@ typedef signed char __v16qs __attribute__((__vector_size__(16))); #ifdef __clang__ #define __ATTRIBUTE_SSE2__ __attribute__((__target__("sse2"),__min_vector_width__(128))) +#define __ATTRIBUTE_MMXSSE2__ __attribute__((__target__("mmx,sse2"),__min_vector_width__(128))) #else #define __ATTRIBUTE_SSE2__ __attribute__((__target__("sse2"))) +#define __ATTRIBUTE_MMXSSE2__ __attribute__((__target__("mmx,sse2"))) #endif #define __INTRIN_INLINE_SSE2 __INTRIN_INLINE __ATTRIBUTE_SSE2__ +#define __INTRIN_INLINE_MMXSSE2 __INTRIN_INLINE __ATTRIBUTE_MMXSSE2__ #endif /* _MSC_VER */ +#ifdef __cplusplus +extern "C" { +#endif + extern __m128d _mm_add_sd(__m128d a, __m128d b); extern __m128d _mm_add_pd(__m128d a, __m128d b); extern __m128d _mm_sub_sd(__m128d a, __m128d b); @@ -495,12 +502,12 @@ void _mm_pause(void); #pragma intrinsic(_mm_loadu_si128) #pragma intrinsic(_mm_loadl_epi64) //#pragma intrinsic(_mm_undefined_si128) -#pragma intrinsic(_mm_set_epi64x) +//#pragma intrinsic(_mm_set_epi64x) //#pragma intrinsic(_mm_set_epi64) #pragma intrinsic(_mm_set_epi32) #pragma intrinsic(_mm_set_epi16) #pragma intrinsic(_mm_set_epi8) -#pragma intrinsic(_mm_set1_epi64x) +//#pragma intrinsic(_mm_set1_epi64x) //#pragma intrinsic(_mm_set1_epi64) #pragma intrinsic(_mm_set1_epi32) #pragma intrinsic(_mm_set1_epi16) @@ -904,17 +911,17 @@ __INTRIN_INLINE_SSE2 int _mm_cvttsd_si32(__m128d a) return __builtin_ia32_cvttsd2si((__v2df)a); } -__INTRIN_INLINE_MMX __m64 _mm_cvtpd_pi32(__m128d a) +__INTRIN_INLINE_MMXSSE2 __m64 _mm_cvtpd_pi32(__m128d a) { return (__m64)__builtin_ia32_cvtpd2pi((__v2df)a); } -__INTRIN_INLINE_MMX __m64 _mm_cvttpd_pi32(__m128d a) +__INTRIN_INLINE_MMXSSE2 __m64 _mm_cvttpd_pi32(__m128d a) { return (__m64)__builtin_ia32_cvttpd2pi((__v2df)a); } -__INTRIN_INLINE_SSE __m128d _mm_cvtpi32_pd(__m64 a) +__INTRIN_INLINE_MMXSSE2 __m128d _mm_cvtpi32_pd(__m64 a) { return __builtin_ia32_cvtpi2pd((__v2si)a); } @@ -1130,7 +1137,7 @@ __INTRIN_INLINE_SSE2 __m128i _mm_add_epi32(__m128i a, __m128i b) return (__m128i)((__v4su)a + (__v4su)b); } -__INTRIN_INLINE_MMX __m64 _mm_add_si64(__m64 a, __m64 b) +__INTRIN_INLINE_MMXSSE2 __m64 _mm_add_si64(__m64 a, __m64 b) { return (__m64)__builtin_ia32_paddq((__v1di)a, (__v1di)b); } @@ -1242,7 +1249,7 @@ __INTRIN_INLINE_SSE2 __m128i _mm_mullo_epi16(__m128i a, __m128i b) return (__m128i)((__v8hu)a * (__v8hu)b); } -__INTRIN_INLINE_MMX __m64 _mm_mul_su32(__m64 a, __m64 b) +__INTRIN_INLINE_MMXSSE2 __m64 _mm_mul_su32(__m64 a, __m64 b) { return (__m64)__builtin_ia32_pmuludq((__v2si)a, (__v2si)b); } @@ -1272,7 +1279,7 @@ __INTRIN_INLINE_SSE2 __m128i _mm_sub_epi32(__m128i a, __m128i b) return (__m128i)((__v4su)a - (__v4su)b); } -__INTRIN_INLINE_MMX __m64 _mm_sub_si64(__m64 a, __m64 b) +__INTRIN_INLINE_MMXSSE2 __m64 _mm_sub_si64(__m64 a, __m64 b) { return (__m64)__builtin_ia32_psubq((__v1di)a, (__v1di)b); } @@ -1936,6 +1943,8 @@ void _mm_pause(void); #endif /* _MSC_VER */ - +#ifdef __cplusplus +} // extern "C" +#endif #endif /* _INCLUDED_EMM */
1 month, 1 week
1
0
0
0
[reactos] 04/10: [VCRUNTIME] Add immintrin.h
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f4936069993e67e2ee9fc…
commit f4936069993e67e2ee9fc09b3ecfa3e7ebff5608 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Fri Oct 11 16:35:51 2024 +0300 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Sat Nov 16 20:01:49 2024 +0200 [VCRUNTIME] Add immintrin.h --- sdk/include/vcruntime/immintrin.h | 171 ++++++++++++++++++++++++++++++++++++++ sdk/include/vcruntime/intrin.h | 2 +- 2 files changed, 172 insertions(+), 1 deletion(-) diff --git a/sdk/include/vcruntime/immintrin.h b/sdk/include/vcruntime/immintrin.h new file mode 100644 index 00000000000..a819cfee33d --- /dev/null +++ b/sdk/include/vcruntime/immintrin.h @@ -0,0 +1,171 @@ +/* + * PROJECT: ReactOS SDK + * LICENSE: MIT (
https://spdx.org/licenses/MIT
) + * PURPOSE: Intrinsics for the SSE2 instruction set + * COPYRIGHT: Copyright 2024 Timo Kreuzer (timo.kreuzer(a)reactos.org) + */ + +#pragma once + +#define _INCLUDED_IMM + +//#include <wmmintrin.h> +#include <emmintrin.h> + +#if defined(_MSC_VER) && !defined(__clang__) + +typedef union _DECLSPEC_INTRIN_TYPE _CRT_ALIGN(32) __m256i +{ + __int8 m256i_i8[32]; + __int16 m256i_i16[16]; + __int32 m256i_i32[8]; + __int64 m256i_i64[4]; + unsigned __int8 m256i_u8[32]; + unsigned __int16 m256i_u16[16]; + unsigned __int32 m256i_u32[8]; + unsigned __int64 m256i_u64[4]; +} __m256i; + +#else /* _MSC_VER */ + +typedef char __v32qi __attribute__ ((__vector_size__ (32))); +typedef short __v16hi __attribute__ ((__vector_size__ (32))); +typedef long long __v4di __attribute__ ((__vector_size__ (32))); + +typedef long long __m256i __attribute__((__vector_size__(32), __may_alias__)); + +#endif /* _MSC_VER */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern __m256i __cdecl _mm256_cmpeq_epi8(__m256i, __m256i); +extern __m256i __cdecl _mm256_cmpeq_epi16(__m256i, __m256i); +extern int __cdecl _mm256_movemask_epi8(__m256i); +extern __m256i __cdecl _mm256_setzero_si256(void); +extern void __cdecl _mm256_zeroupper(void); + +extern int __cdecl _rdrand16_step(unsigned short *random_val); +extern int __cdecl _rdrand32_step(unsigned int *random_val); +#if defined(_M_X64) +extern int __cdecl _rdrand64_step(unsigned __int64 *random_val); +#endif + +extern int __cdecl _rdseed16_step(unsigned short *random_val); +extern int __cdecl _rdseed32_step(unsigned int *random_val); +#if defined(_M_X64) +extern int __cdecl _rdseed64_step(unsigned __int64 *random_val); +#endif + + +#if defined(_MSC_VER) && !defined(__clang__) + +#pragma intrinsic(_mm256_cmpeq_epi8) +#pragma intrinsic(_mm256_cmpeq_epi16) +#pragma intrinsic(_mm256_movemask_epi8) +#pragma intrinsic(_mm256_setzero_si256) +#pragma intrinsic(_mm256_zeroupper) + +#pragma intrinsic(_rdrand16_step) +#pragma intrinsic(_rdrand32_step) +#if defined(_M_X64) +#pragma intrinsic(_rdrand64_step) +#endif +#pragma intrinsic(_rdseed16_step) +#pragma intrinsic(_rdseed32_step) +#if defined(_M_X64) +#pragma intrinsic(_rdseed64_step) +#endif + +#else /* _MSC_VER */ + +#ifdef __clang__ +#define __ATTRIBUTE_SSE2__ __attribute__((__target__("sse2"),__min_vector_width__(128))) +#define __ATTRIBUTE_AVX__ __attribute__((__target__("avx"),__min_vector_width__(256))) +#define __ATTRIBUTE_AVX2__ __attribute__((__target__("avx2"),__min_vector_width__(256))) +#else +#define __ATTRIBUTE_SSE2__ __attribute__((__target__("sse2"))) +#define __ATTRIBUTE_AVX__ __attribute__((__target__("avx"))) +#define __ATTRIBUTE_AVX2__ __attribute__((__target__("avx2"))) +#endif +#define __INTRIN_INLINE_SSE2 __INTRIN_INLINE __ATTRIBUTE_SSE2__ +#define __INTRIN_INLINE_AVX __INTRIN_INLINE __ATTRIBUTE_AVX__ +#define __INTRIN_INLINE_AVX2 __INTRIN_INLINE __ATTRIBUTE_AVX2__ + +__INTRIN_INLINE_AVX __m256i __cdecl _mm256_cmpeq_epi8(__m256i __A, __m256i __B) +{ + return (__m256i)((__v32qi)__A == (__v32qi)__B); +} + +__INTRIN_INLINE_AVX __m256i __cdecl _mm256_cmpeq_epi16(__m256i __A, __m256i __B) +{ + return (__m256i)((__v16hi)__A == (__v16hi)__B); +} + +__INTRIN_INLINE_AVX2 int __cdecl _mm256_movemask_epi8(__m256i __A) +{ + return __builtin_ia32_pmovmskb256((__v32qi)__A); +} + +__INTRIN_INLINE_AVX __m256i __cdecl _mm256_setzero_si256(void) +{ + return __extension__ (__m256i)(__v4di){ 0, 0, 0, 0 }; +} + +__INTRIN_INLINE void __cdecl _mm256_zeroupper(void) +{ + __asm__ __volatile__("vzeroupper"); +} + +__INTRIN_INLINE int _rdrand16_step(unsigned short* random_val) +{ + unsigned char ok; + __asm__ __volatile__("rdrand %0; setc %1" : "=r"(*random_val), "=qm"(ok)); + return (int)ok; +} + +__INTRIN_INLINE int _rdrand32_step(unsigned int* random_val) +{ + unsigned char ok; + __asm__ __volatile__("rdrand %0; setc %1" : "=r"(*random_val), "=qm"(ok)); + return (int)ok; +} + +#if defined(__x86_64__) +__INTRIN_INLINE int _rdrand64_step(unsigned __int64* random_val) +{ + unsigned char ok; + __asm__ __volatile__("rdrand %0; setc %1" : "=r"(*random_val), "=qm"(ok)); + return (int)ok; +} +#endif // __x86_64__ + +__INTRIN_INLINE int _rdseed16_step(unsigned short* random_val) +{ + unsigned char ok; + __asm__ __volatile__("rdseed %0; setc %1" : "=r"(*random_val), "=qm"(ok)); + return (int)ok; +} + +__INTRIN_INLINE int _rdseed32_step(unsigned int* random_val) +{ + unsigned char ok; + __asm__ __volatile__("rdseed %0; setc %1" : "=r"(*random_val), "=qm"(ok)); + return (int)ok; +} + +#if defined(__x86_64__) +__INTRIN_INLINE int _rdseed64_step(unsigned __int64* random_val) +{ + unsigned char ok; + __asm__ __volatile__("rdseed %0; setc %1" : "=r"(*random_val), "=qm"(ok)); + return (int)ok; +} +#endif // __x86_64__ + +#endif /* _MSC_VER */ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/sdk/include/vcruntime/intrin.h b/sdk/include/vcruntime/intrin.h index 513c2667786..fda1dc4c8e9 100644 --- a/sdk/include/vcruntime/intrin.h +++ b/sdk/include/vcruntime/intrin.h @@ -9,7 +9,7 @@ #include <stddef.h> #if defined(_M_IX86) || defined(_M_X64) -//#include <immintrin.h> +#include <immintrin.h> //#include <ammintrin.h> #include <xmmintrin.h> // native headers: immintrin.h -> wmmintrin.h -> nmmintrin.h -> smmintrin.h -> tmmintrin.h -> pmmintrin.h -> emmintrin.h #endif /* _M_IX86 || _M_X64 */
1 month, 1 week
1
0
0
0
← Newer
1
2
3
4
5
6
7
...
11
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
Results per page:
10
25
50
100
200