Skip to content

Commit

Permalink
deploy: 1c07c82
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Dec 4, 2024
1 parent 4680783 commit 03046b7
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 37 deletions.
7 changes: 4 additions & 3 deletions catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@
"published": 1730231151000,
"rating": 10,
"ratingUsers": 105,
"updated": 1731243474000,
"updated": 1733321929000,
"users": 5920
},
"metadata": {
Expand All @@ -1141,7 +1141,8 @@
"description": "Optional improvements: show folder sizes, use MB/GB for large files (by default, all sizes are shown in KBs), use IEC terms (such as KiB instead of KB)",
"exclude": [
"conhost.exe",
"plex.exe"
"Plex.exe",
"Plex Media Server.exe"
],
"github": "https://github.com/m417z",
"homepage": "https://m417z.com/",
Expand All @@ -1150,7 +1151,7 @@
],
"name": "Better file sizes in Explorer details",
"twitter": "https://twitter.com/m417z",
"version": "1.4.4"
"version": "1.4.5"
}
},
"explorer-frame-classic": {
Expand Down
6 changes: 6 additions & 0 deletions changelogs/explorer-details-better-file-sizes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.4.5 ([Dec 4, 2024](https://github.com/ramensoftware/windhawk-mods/blob/1c07c82111a8cfb4c2a1757f702e598172570193/mods/explorer-details-better-file-sizes.wh.cpp))

* Fixed Explorer hanging when Open Path is used in Everything.
* Excluded Plex Media Server which is incompatible, a proper fix will be implemented later.
* Added support for older Windows 10 versions.

## 1.4.4 ([Nov 10, 2024](https://github.com/ramensoftware/windhawk-mods/blob/f396f78d645dc57089bf4805a63b0bd82f50d745/mods/explorer-details-better-file-sizes.wh.cpp))

* Fixed the "Mix files and folders when sorting by size" option that stopped working in version 1.4.2.
Expand Down
123 changes: 105 additions & 18 deletions mods/explorer-details-better-file-sizes.wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
// @id explorer-details-better-file-sizes
// @name Better file sizes in Explorer details
// @description Optional improvements: show folder sizes, use MB/GB for large files (by default, all sizes are shown in KBs), use IEC terms (such as KiB instead of KB)
// @version 1.4.4
// @version 1.4.5
// @author m417z
// @github https://github.com/m417z
// @twitter https://twitter.com/m417z
// @homepage https://m417z.com/
// @include *
// @exclude conhost.exe
// @exclude plex.exe
// @exclude Plex.exe
// @exclude Plex Media Server.exe
// @compilerOptions -lole32 -loleaut32 -lpropsys
// ==/WindhawkMod==

Expand Down Expand Up @@ -449,28 +450,13 @@ DWORD WINAPI Everything4Wh_Thread(void* parameter) {
return 0;
}

LPCITEMIDLIST PIDLNext(LPCITEMIDLIST pidl) {
return reinterpret_cast<LPCITEMIDLIST>(reinterpret_cast<const BYTE*>(pidl) +
pidl->mkid.cb);
}

size_t PIDLSize(LPCITEMIDLIST pidl) {
size_t s = 0;
while (pidl->mkid.cb > 0) {
s += pidl->mkid.cb;
pidl = PIDLNext(pidl);
}
// We add 2 because an LPITEMIDLIST is terminated by two NULL bytes.
return 2 + s;
}

std::vector<BYTE> PIDLToVector(const ITEMIDLIST* pidl) {
if (!pidl) {
return {};
}

const BYTE* ptr = reinterpret_cast<const BYTE*>(pidl);
size_t size = PIDLSize(pidl);
size_t size = ILGetSize(pidl);
return std::vector<BYTE>(ptr, ptr + size);
}

Expand Down Expand Up @@ -789,6 +775,97 @@ HRESULT WINAPI CFSFolder_CompareIDs_Hook(void* pCFSFolder,
}
}

using SHOpenFolderAndSelectItems_t = decltype(&SHOpenFolderAndSelectItems);
SHOpenFolderAndSelectItems_t SHOpenFolderAndSelectItems_Original;
HRESULT WINAPI SHOpenFolderAndSelectItems_Hook(LPCITEMIDLIST pidlFolder,
UINT cidl,
LPCITEMIDLIST* apidl,
DWORD dwFlags) {
Wh_Log(L">");

// If the current thread is the UI thread, run the function in a new thread
// to prevent a deadlock. See:
// https://voidtools.com/forum/viewtopic.php?p=71433#p71433

bool isUiThread = false;

EnumThreadWindows(
GetCurrentThreadId(),
[](HWND hWnd, LPARAM lParam) WINAPI -> BOOL {
constexpr WCHAR kClassNamePrefix[] =
L"EVERYTHING_TASKBAR_NOTIFICATION";
constexpr size_t kClassNameLen = ARRAYSIZE(kClassNamePrefix) - 1;

bool& isUiThread = *(bool*)lParam;

WCHAR szClassName[64];
if (GetClassName(hWnd, szClassName, ARRAYSIZE(szClassName)) == 0) {
return TRUE;
}

if (_wcsnicmp(kClassNamePrefix, szClassName, kClassNameLen) == 0) {
isUiThread = true;
return FALSE;
}

return TRUE;
},
(LPARAM)&isUiThread);

if (!isUiThread) {
return SHOpenFolderAndSelectItems_Original(pidlFolder, cidl, apidl,
dwFlags);
}

struct ThreadParam {
LPITEMIDLIST pidlFolder;
std::vector<LPITEMIDLIST> apidl;
DWORD dwFlags;
};

auto threadParam = std::make_unique<ThreadParam>();

threadParam->pidlFolder = ILClone(pidlFolder);

if (cidl) {
threadParam->apidl.reserve(cidl);
for (UINT i = 0; i < cidl; i++) {
threadParam->apidl.push_back(ILClone(apidl[i]));
}
}

threadParam->dwFlags = dwFlags;

HANDLE thread = CreateThread(
nullptr, 0,
[](LPVOID lpParam) WINAPI -> DWORD {
Wh_Log(L">");

std::unique_ptr<ThreadParam> threadParam{(ThreadParam*)lpParam};

CoInitializeEx(nullptr, COINIT_MULTITHREADED);

SHOpenFolderAndSelectItems_Original(
threadParam->pidlFolder, threadParam->apidl.size(),
(LPCITEMIDLIST*)threadParam->apidl.data(),
threadParam->dwFlags);

ILFree(threadParam->pidlFolder);
for (auto pidl : threadParam->apidl) {
ILFree(pidl);
}

CoUninitialize();
return 0;
},
threadParam.release(), 0, nullptr);
if (thread) {
CloseHandle(thread);
}

return S_OK;
}

using PSFormatForDisplayAlloc_t = decltype(&PSFormatForDisplayAlloc);
PSFormatForDisplayAlloc_t PSFormatForDisplayAlloc_Original;
HRESULT WINAPI PSFormatForDisplayAlloc_Hook(const PROPERTYKEY& key,
Expand Down Expand Up @@ -922,8 +999,14 @@ bool HookWindowsStorageSymbols() {
{
#ifdef _WIN64
LR"(public: virtual long __cdecl CDefItem::GetValue(enum VALUE_ACCESS_MODE,struct _tagpropertykey const &,struct tagPROPVARIANT *,enum VALUE_STATE *))",

// Older Win10 versions.
LR"(public: virtual long __cdecl CDefItem::GetValue(enum tagACCESS_MODE,struct _tagpropertykey const &,struct tagPROPVARIANT *,enum tagVALUE_STATE *))",
#else
LR"(public: virtual long __stdcall CDefItem::GetValue(enum VALUE_ACCESS_MODE,struct _tagpropertykey const &,struct tagPROPVARIANT *,enum VALUE_STATE *))",

// Older Win10 versions.
LR"(public: virtual long __stdcall CDefItem::GetValue(enum tagACCESS_MODE,struct _tagpropertykey const &,struct tagPROPVARIANT *,enum tagVALUE_STATE *))",
#endif
},
&CDefItem_GetValue_Original,
Expand Down Expand Up @@ -1215,6 +1298,10 @@ BOOL Wh_ModInit() {
Wh_Log(L"Failed hooking Windows Storage symbols");
return false;
}

WindhawkUtils::Wh_SetFunctionHookT(
SHOpenFolderAndSelectItems, SHOpenFolderAndSelectItems_Hook,
&SHOpenFolderAndSelectItems_Original);
}

if (g_settings.disableKbOnlySizes) {
Expand Down
32 changes: 16 additions & 16 deletions updates.atom
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,27 @@
<feed xmlns="http://www.w3.org/2005/Atom">
<id>https://windhawk.net/</id>
<title>Windhawk Mod Updates</title>
<updated>2024-12-04T13:58:49.000Z</updated>
<updated>2024-12-04T14:18:49.000Z</updated>
<generator>https://github.com/jpmonette/feed</generator>
<link rel="alternate" href="https://windhawk.net/"/>
<subtitle>Updates in the official collection of Windhawk mods</subtitle>
<icon>https://windhawk.net/favicon.ico</icon>
<rights>Ramen Software</rights>
<entry>
<title type="html"><![CDATA[Better file sizes in Explorer details 1.4.5]]></title>
<id>https://windhawk.net/mods/explorer-details-better-file-sizes#1c07c82111a8cfb4c2a1757f702e598172570193</id>
<link href="https://windhawk.net/mods/explorer-details-better-file-sizes"/>
<updated>2024-12-04T14:18:49.000Z</updated>
<content type="html"><![CDATA[<ul>
<li>Fixed Explorer hanging when Open Path is used in Everything.</li>
<li>Excluded Plex Media Server which is incompatible, a proper fix will be implemented later.</li>
<li>Added support for older Windows 10 versions.</li>
</ul>]]></content>
<author>
<name>m417z</name>
<uri>https://github.com/m417z</uri>
</author>
</entry>
<entry>
<title type="html"><![CDATA[Taskbar Labels for Windows 11 1.3.3]]></title>
<id>https://windhawk.net/mods/taskbar-labels#b0179b2e31ee74e302077bfb2de1b7cdfc6092d7</id>
Expand Down Expand Up @@ -283,21 +298,6 @@ center, etc. to another monitor.</p>
<updated>2024-11-10T12:57:54.000Z</updated>
<content type="html"><![CDATA[<ul>
<li>Fixed the "Mix files and folders when sorting by size" option that stopped working in version 1.4.2.</li>
</ul>]]></content>
<author>
<name>m417z</name>
<uri>https://github.com/m417z</uri>
</author>
</entry>
<entry>
<title type="html"><![CDATA[Better file sizes in Explorer details 1.4.3]]></title>
<id>https://windhawk.net/mods/explorer-details-better-file-sizes#49e105f33c5fef9363a0dae4f6e12a9b5ec31746</id>
<link href="https://windhawk.net/mods/explorer-details-better-file-sizes"/>
<updated>2024-11-10T12:29:58.000Z</updated>
<content type="html"><![CDATA[<ul>
<li>Excluded Plex which is incompatible, a proper fix will be implemented later.</li>
<li>Excluded conhost to reduce possible conflicts, the mod isn't relevant for it anyway.</li>
<li>Improved the workaround to the error message that says "Runtime Error - Not Enough space for thread Data" to cover more (hopefully all) cases.</li>
</ul>]]></content>
<author>
<name>m417z</name>
Expand Down

0 comments on commit 03046b7

Please sign in to comment.