Index: src/chext/DropMenuExt.cpp =================================================================== diff -u -r3d1de44762647618faf9b5b3a87f89b293899d8d -rc33d4855ebf17772c28012a66c829a1f21d080f5 --- src/chext/DropMenuExt.cpp (.../DropMenuExt.cpp) (revision 3d1de44762647618faf9b5b3a87f89b293899d8d) +++ src/chext/DropMenuExt.cpp (.../DropMenuExt.cpp) (revision c33d4855ebf17772c28012a66c829a1f21d080f5) @@ -119,9 +119,7 @@ TShellMenuItemPtr spRootMenuItem = m_tShellExtMenuConfig.GetCommandRoot(); m_tContextMenuHandler.Init(spRootMenuItem, hMenu, idCmdFirst, indexMenu, m_tShellExtData, m_tShellExtMenuConfig.GetShowShortcutIcons(), bIntercept); - HRESULT hResult = MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, m_tContextMenuHandler.GetLastCommandID() - idCmdFirst + 1); - BOOST_LOG_HRESULT(rLogger, hResult) << L""; - return hResult; + return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, m_tContextMenuHandler.GetLastCommandID() - idCmdFirst + 1); } STDMETHODIMP CDropMenuExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpici) Index: src/chext/HResultFormatter.cpp =================================================================== diff -u -r3d1de44762647618faf9b5b3a87f89b293899d8d -rc33d4855ebf17772c28012a66c829a1f21d080f5 --- src/chext/HResultFormatter.cpp (.../HResultFormatter.cpp) (revision 3d1de44762647618faf9b5b3a87f89b293899d8d) +++ src/chext/HResultFormatter.cpp (.../HResultFormatter.cpp) (revision c33d4855ebf17772c28012a66c829a1f21d080f5) @@ -34,6 +34,10 @@ case S_FALSE: wstr << L" (S_FALSE)"; break; + case E_FAIL: + wstr << L" (E_FAIL)"; + break; + default: { chcore::TString strDesc = chcore::TWin32ErrorFormatter::FormatWin32ErrorCodeWithFallback(hResult, nullptr, false); Index: src/chext/ShellExtControl.cpp =================================================================== diff -u -r3d1de44762647618faf9b5b3a87f89b293899d8d -rc33d4855ebf17772c28012a66c829a1f21d080f5 --- src/chext/ShellExtControl.cpp (.../ShellExtControl.cpp) (revision 3d1de44762647618faf9b5b3a87f89b293899d8d) +++ src/chext/ShellExtControl.cpp (.../ShellExtControl.cpp) (revision c33d4855ebf17772c28012a66c829a1f21d080f5) @@ -53,9 +53,9 @@ DWORD dwLastError = ERROR_SUCCESS; m_hMemory = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(SHELLEXT_DATA), _T("CHShellExtControlData")); // name of map object + dwLastError = GetLastError(); // NOTE: last error is needed also for success case (for already exists status) if(!m_hMemory) { - dwLastError = GetLastError(); BOOST_LOG_HRESULT(rLogger, dwLastError) << L"Cannot create file mapping."; ReleaseMutex(m_hMutex); CloseHandle(m_hMutex); @@ -65,7 +65,9 @@ m_pShellExtData = (SHELLEXT_DATA*)MapViewOfFile(m_hMemory, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0); if(!m_pShellExtData) { - BOOST_LOG_SEV(rLogger, error) << L"Cannot map view of file."; + DWORD dwError = GetLastError(); // NOTE: do not overwrite dwLastError, as the value is needed later + + BOOST_LOG_HRESULT(rLogger, dwError) << L"Cannot map view of file."; ReleaseMutex(m_hMutex); CloseHandle(m_hMutex); CloseHandle(m_hMemory); @@ -75,7 +77,14 @@ if(dwLastError != ERROR_ALREADY_EXISTS) { - BOOST_LOG_SEV(rLogger, debug) << L"Copy Handler is not running. Disabling shell extension."; + if(dwLastError == ERROR_SUCCESS) + { + BOOST_LOG_SEV(rLogger, debug) << L"Copy Handler is not running. Disabling shell extension."; + } + else + { + BOOST_LOG_HRESULT(rLogger, dwLastError) << L"Copy Handler is not running. Disabling shell extension."; + } m_pShellExtData->m_lFlags = 0; m_pShellExtData->m_lID = GetTickCount(); }