Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FileLocksmith] Fix triggering FileLocksmith unexpectedly #34905

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 40 additions & 33 deletions src/modules/FileLocksmith/FileLocksmithExt/ExplorerCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,51 +166,58 @@ IFACEMETHODIMP ExplorerCommand::QueryContextMenu(HMENU hmenu, UINT indexMenu, UI

IFACEMETHODIMP ExplorerCommand::InvokeCommand(CMINVOKECOMMANDINFO* pici)
{
Trace::Invoked();
ipc::Writer writer;
HRESULT hr = E_FAIL;

if (HRESULT result = writer.start(); FAILED(result))
if (FileLocksmithSettingsInstance().GetEnabled() &&
pici && (IS_INTRESOURCE(pici->lpVerb)) &&
(LOWORD(pici->lpVerb) == 0))
{
Trace::InvokedRet(result);
return result;
}
Trace::Invoked();
ipc::Writer writer;

if (HRESULT result = LaunchUI(pici, &writer); FAILED(result))
{
Trace::InvokedRet(result);
return result;
}
if (HRESULT result = writer.start(); FAILED(result))
{
Trace::InvokedRet(result);
return result;
}

IShellItemArray* shell_item_array;
HRESULT result = SHCreateShellItemArrayFromDataObject(m_data_obj, __uuidof(IShellItemArray), reinterpret_cast<void**>(&shell_item_array));
if (SUCCEEDED(result))
{
DWORD num_items;
shell_item_array->GetCount(&num_items);
for (DWORD i = 0; i < num_items; i++)
if (HRESULT result = LaunchUI(pici, &writer); FAILED(result))
{
Trace::InvokedRet(result);
return result;
}

IShellItemArray* shell_item_array;
hr = SHCreateShellItemArrayFromDataObject(m_data_obj, __uuidof(IShellItemArray), reinterpret_cast<void**>(&shell_item_array));
if (SUCCEEDED(hr))
{
IShellItem* item;
result = shell_item_array->GetItemAt(i, &item);
if (SUCCEEDED(result))
DWORD num_items;
shell_item_array->GetCount(&num_items);
for (DWORD i = 0; i < num_items; i++)
{
LPWSTR file_path;
result = item->GetDisplayName(SIGDN_FILESYSPATH, &file_path);
if (SUCCEEDED(result))
IShellItem* item;
hr = shell_item_array->GetItemAt(i, &item);
if (SUCCEEDED(hr))
{
// TODO Aggregate items and send to UI
writer.add_path(file_path);
CoTaskMemFree(file_path);
LPWSTR file_path;
hr = item->GetDisplayName(SIGDN_FILESYSPATH, &file_path);
if (SUCCEEDED(hr))
{
// TODO Aggregate items and send to UI
writer.add_path(file_path);
CoTaskMemFree(file_path);
}

item->Release();
}

item->Release();
}
}

shell_item_array->Release();
shell_item_array->Release();
}
}

Trace::InvokedRet(S_OK);
return S_OK;
Trace::InvokedRet(hr);
return hr;
}

IFACEMETHODIMP ExplorerCommand::GetCommandString(UINT_PTR idCmd, UINT uType, UINT* pReserved, CHAR* pszName, UINT cchMax)
Expand Down
Loading