-
Notifications
You must be signed in to change notification settings - Fork 808
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
[Debug Only] add logs to the files explorer integration DLL #6557
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/** | ||
Check notice on line 1 in shell_integration/windows/NCContextMenu/NCContextMenu.cpp GitHub Actions / buildRun clang-format on shell_integration/windows/NCContextMenu/NCContextMenu.cpp
|
||
* Copyright (c) 2015 Daniel Molkentin <[email protected]>. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under | ||
|
@@ -21,16 +21,22 @@ | |
#include <StringUtil.h> | ||
#include <strsafe.h> | ||
|
||
#include <iostream> | ||
#include <fstream> | ||
|
||
extern long g_cDllRef; | ||
Check warning on line 27 in shell_integration/windows/NCContextMenu/NCContextMenu.cpp GitHub Actions / buildshell_integration/windows/NCContextMenu/NCContextMenu.cpp:27:13 [cppcoreguidelines-avoid-non-const-global-variables]
|
||
|
||
NCContextMenu::NCContextMenu(void) | ||
: m_cRef(1) | ||
{ | ||
InterlockedIncrement(&g_cDllRef); | ||
m_logger.open("c:\\test.log"); | ||
m_logger << "hello world" << std::endl; | ||
} | ||
|
||
NCContextMenu::~NCContextMenu(void) | ||
{ | ||
m_logger << "NCContextMenu::~NCContextMenu" << std::endl; | ||
InterlockedDecrement(&g_cDllRef); | ||
} | ||
|
||
|
@@ -39,6 +45,7 @@ | |
// Query to the interface the component supported. | ||
IFACEMETHODIMP NCContextMenu::QueryInterface(REFIID riid, void **ppv) | ||
{ | ||
m_logger << "NCContextMenu::QueryInterface" << std::endl; | ||
static const QITAB qit[] = | ||
{ | ||
QITABENT(NCContextMenu, IContextMenu), | ||
|
@@ -51,12 +58,14 @@ | |
// Increase the reference count for an interface on an object. | ||
IFACEMETHODIMP_(ULONG) NCContextMenu::AddRef() | ||
{ | ||
m_logger << "NCContextMenu::AddRef" << std::endl; | ||
return InterlockedIncrement(&m_cRef); | ||
} | ||
|
||
// Decrease the reference count for an interface on an object. | ||
IFACEMETHODIMP_(ULONG) NCContextMenu::Release() | ||
{ | ||
m_logger << "NCContextMenu::Release" << std::endl; | ||
ULONG cRef = InterlockedDecrement(&m_cRef); | ||
if (0 == cRef) { | ||
delete this; | ||
|
@@ -74,6 +83,7 @@ | |
IFACEMETHODIMP NCContextMenu::Initialize( | ||
LPCITEMIDLIST, LPDATAOBJECT pDataObj, HKEY) | ||
{ | ||
m_logger << "NCContextMenu::Initialize" << std::endl; | ||
m_selectedFiles.clear(); | ||
|
||
if (!pDataObj) { | ||
|
@@ -129,17 +139,20 @@ | |
|
||
IFACEMETHODIMP NCContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) | ||
{ | ||
m_logger << "NCContextMenu::QueryContextMenu" << std::endl; | ||
// If uFlags include CMF_DEFAULTONLY then we should not do anything. | ||
if (CMF_DEFAULTONLY & uFlags) | ||
{ | ||
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0)); | ||
} | ||
|
||
m_info = NCClientInterface::FetchInfo(m_selectedFiles); | ||
m_info = NCClientInterface::FetchInfo(m_selectedFiles, m_logger); | ||
if (m_info.menuItems.empty()) { | ||
m_logger << "NCContextMenu::QueryContextMenu " << "empty info" << std::endl; | ||
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0)); | ||
} | ||
|
||
m_logger << "NCContextMenu::QueryContextMenu" << "insert separator" << std::endl; | ||
InsertSeperator(hMenu, indexMenu++); | ||
|
||
HMENU hSubmenu = CreateMenu(); | ||
|
@@ -153,6 +166,7 @@ | |
if (!InsertMenuItem(hMenu, indexMenu++, TRUE, &mii)) | ||
return HRESULT_FROM_WIN32(GetLastError()); | ||
} | ||
m_logger << "NCContextMenu::QueryContextMenu" << "insert separator" << std::endl; | ||
InsertSeperator(hMenu, indexMenu++); | ||
|
||
UINT indexSubMenu = 0; | ||
|
@@ -179,6 +193,7 @@ | |
|
||
IFACEMETHODIMP NCContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO pici) | ||
{ | ||
m_logger << "NCContextMenu::InvokeCommand" << std::endl; | ||
std::wstring command; | ||
|
||
CMINVOKECOMMANDINFOEX *piciEx = nullptr; | ||
|
@@ -215,13 +230,14 @@ | |
return E_FAIL; | ||
} | ||
|
||
NCClientInterface::SendRequest(command.data(), m_selectedFiles); | ||
NCClientInterface::SendRequest(command.data(), m_selectedFiles, m_logger); | ||
return S_OK; | ||
} | ||
|
||
IFACEMETHODIMP NCContextMenu::GetCommandString(UINT_PTR idCommand, | ||
UINT uFlags, UINT *pwReserved, LPSTR pszName, UINT cchMax) | ||
{ | ||
m_logger << "NCContextMenu::GetCommandString" << std::endl; | ||
if (idCommand < m_info.menuItems.size() && uFlags == GCS_VERBW) { | ||
return StringCchCopyW(reinterpret_cast<PWSTR>(pszName), cchMax, | ||
m_info.menuItems[idCommand].command.data()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,13 @@ | |
#define NCCONTEXTMENU_H | ||
|
||
#pragma once | ||
#include "NCClientInterface.h" | ||
|
||
#include <shlobj.h> // For IShellExtInit and IContextMenu | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
#include <string> | ||
#include "NCClientInterface.h" | ||
#include <fstream> | ||
#include <iostream> | ||
|
||
class NCContextMenu : public IShellExtInit, public IContextMenu | ||
{ | ||
|
@@ -48,6 +52,8 @@ class NCContextMenu : public IShellExtInit, public IContextMenu | |
// The name of the selected files (separated by '\x1e') | ||
std::wstring m_selectedFiles; | ||
NCClientInterface::ContextMenuInfo m_info; | ||
|
||
std::ofstream m_logger; | ||
}; | ||
|
||
#endif //NCCONTEXTMENU_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,13 +17,14 @@ | |
|
||
#pragma once | ||
|
||
#include <shlobj.h> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
#include <fstream> | ||
|
||
class NCOverlay : public IShellIconOverlayIdentifier | ||
|
||
{ | ||
public: | ||
NCOverlay(int state); | ||
explicit NCOverlay(int state); | ||
|
||
IFACEMETHODIMP_(ULONG) AddRef(); | ||
IFACEMETHODIMP GetOverlayInfo(PWSTR pwszIconFile, int cchMax, int *pIndex, DWORD *pdwFlags); | ||
|
@@ -38,6 +39,7 @@ | |
private: | ||
long _referenceCount; | ||
int _state; | ||
std::ofstream m_logger; | ||
}; | ||
|
||
#endif | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/** | ||
Check notice on line 1 in shell_integration/windows/NCUtil/CommunicationSocket.h GitHub Actions / buildRun clang-format on shell_integration/windows/NCUtil/CommunicationSocket.h
|
||
* Copyright (c) 2000-2013 Liferay, Inc. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under | ||
|
@@ -19,8 +19,9 @@ | |
|
||
#pragma warning (disable : 4251) | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <fstream> | ||
#include <WinSock2.h> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
class __declspec(dllexport) CommunicationSocket | ||
|
@@ -34,7 +35,7 @@ | |
bool Connect(const std::wstring& pipename); | ||
bool Close(); | ||
|
||
bool SendMsg(const wchar_t*) const; | ||
bool SendMsg(const wchar_t*, std::ofstream &logger) const; | ||
bool ReadLine(std::wstring*); | ||
|
||
HANDLE Event() { return _pipe; } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
#ifndef PATHCHECKER_H | ||
#define PATHCHECKER_H | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <unordered_map> | ||
#include <queue> | ||
|
@@ -22,6 +22,7 @@ | |
#include <memory> | ||
#include <mutex> | ||
#include <atomic> | ||
#include <fstream> | ||
#include <condition_variable> | ||
|
||
#pragma once | ||
|
@@ -36,7 +37,7 @@ | |
StateWarning, | ||
StateNone | ||
}; | ||
RemotePathChecker(); | ||
explicit RemotePathChecker(std::ofstream &logger); | ||
~RemotePathChecker(); | ||
std::shared_ptr<const std::vector<std::wstring>> WatchedDirectories() const; | ||
bool IsMonitoredPath(const wchar_t* filePath, int* state); | ||
|
@@ -64,7 +65,7 @@ | |
HANDLE _newQueries; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
std::thread _thread; | ||
void workerThreadLoop(); | ||
void workerThreadLoop(std::ofstream &logger); | ||
}; | ||
|
||
#endif | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shlobj.h
file not found