Fix run dialog skipping MRU strings in some cases
@@ -466,7 +466,6 @@ static VOID PhpAddProgramsToComboBox(
_In_ HWND ComboBoxHandle
)
{
- static PH_STRINGREF prefixSr = PH_STRINGREF_INIT(L"\\1");
HANDLE listHandle;
INT listCount;
@@ -484,33 +483,27 @@ static VOID PhpAddProgramsToComboBox(
for (INT i = 0; i < listCount; i++)
{
- PPH_STRING programName;
- PH_STRINGREF nameSr;
- PH_STRINGREF firstPart;
- PH_STRINGREF remainingPart;
- WCHAR entry[MAX_PATH] = L"";
+ INT returnLength;
+ WCHAR buffer[MAX_PATH] = L"";
- if (!EnumMRUList_I(
+ returnLength = EnumMRUList_I(
listHandle,
i,
- entry,
- RTL_NUMBER_OF(entry)
- ))
- {
- break;
- }
-
- PhInitializeStringRefLongHint(&nameSr, entry);
+ buffer,
+ RTL_NUMBER_OF(buffer)
+ );
- if (!PhSplitStringRefAtString(&nameSr, &prefixSr, TRUE, &firstPart, &remainingPart))
- {
- ComboBox_AddString(ComboBoxHandle, entry);
+ if (returnLength >= RTL_NUMBER_OF(buffer))
continue;
- }
+ if (returnLength < sizeof(UNICODE_NULL))
+ continue;
+
+ buffer[returnLength] = UNICODE_NULL;
+
+ if (buffer[returnLength - 1] == L'1' && buffer[returnLength - 2] == L'\\')
+ buffer[returnLength - 2] = UNICODE_NULL; // trim \\1 (dmex)
- programName = PhCreateString2(&firstPart);
- ComboBox_AddString(ComboBoxHandle, PhGetString(programName));
- PhDereferenceObject(programName);
+ ComboBox_AddString(ComboBoxHandle, buffer);
}
FreeMRUList_I(listHandle);
