Changeset 716
- Timestamp:
- 12/5/2008 12:58:12 PM (4 years ago)
- Location:
- branches/eraser6/ShellExt
- Files:
-
- 2 edited
-
CtxMenu.cpp (modified) (11 diffs)
-
CtxMenu.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/ShellExt/CtxMenu.cpp
r715 r716 46 46 }; 47 47 48 struct KEY_NODE_INFORMATION 49 { 50 LARGE_INTEGER LastWriteTime; 51 ULONG TitleIndex; 52 ULONG ClassOffset; 53 ULONG ClassLength; 54 ULONG NameLength; 55 WCHAR Name[1]; 56 }; 57 48 58 typedef NTSTATUS (*pZwQueryKey)(HANDLE KeyHandle, KEY_INFORMATION_CLASS KeyInformationClass, 49 59 PVOID KeyInformation, ULONG Length, PULONG ResultLength); … … 116 126 if (FAILED(pDataObj->GetData(&fmt, &stg))) 117 127 //Nope! Return an "invalid argument" error back to Explorer. 118 return S_OK;128 return E_INVALIDARG; 119 129 120 130 //Get a pointer to the actual data. … … 166 176 //Create the submenu, following the order defined in the CEraserLPVERB enum, creating 167 177 //only items which are applicable. 168 CEraserLPVERBS applicableVerbs = GetApplicableActions();178 Actions applicableActions = GetApplicableActions(); 169 179 VerbMenuIndices.clear(); 170 if (applicable Verbs & CERASER_ERASE)171 { 172 InsertMenu (hSubmenu, CERASER_ERASE, MF_BYPOSITION, uID++, _T("&Erase"));173 VerbMenuIndices.push_back( CERASER_ERASE);174 } 175 if (applicable Verbs & CERASER_ERASE_ON_RESTART)176 { 177 InsertMenu (hSubmenu, CERASER_ERASE_ON_RESTART, MF_BYPOSITION, uID++, _T("Erase on &Restart"));178 VerbMenuIndices.push_back( CERASER_ERASE_ON_RESTART);179 } 180 if (applicable Verbs & CERASER_ERASE_UNUSED_SPACE)181 { 182 InsertMenu (hSubmenu, CERASER_ERASE_UNUSED_SPACE, MF_BYPOSITION, uID++, _T("Erase &Unused Space"));183 VerbMenuIndices.push_back( CERASER_ERASE_UNUSED_SPACE);180 if (applicableActions & ACTION_ERASE) 181 { 182 InsertMenu (hSubmenu, ACTION_ERASE, MF_BYPOSITION, uID++, _T("&Erase")); 183 VerbMenuIndices.push_back(ACTION_ERASE); 184 } 185 if (applicableActions & ACTION_ERASE_ON_RESTART) 186 { 187 InsertMenu (hSubmenu, ACTION_ERASE_ON_RESTART, MF_BYPOSITION, uID++, _T("Erase on &Restart")); 188 VerbMenuIndices.push_back(ACTION_ERASE_ON_RESTART); 189 } 190 if (applicableActions & ACTION_ERASE_UNUSED_SPACE) 191 { 192 InsertMenu (hSubmenu, ACTION_ERASE_UNUSED_SPACE, MF_BYPOSITION, uID++, _T("Erase &Unused Space")); 193 VerbMenuIndices.push_back(ACTION_ERASE_UNUSED_SPACE); 184 194 } 185 195 //------------------------------------------------------------------------- 186 if (applicable Verbs & CERASER_SECURE_MOVE)196 if (applicableActions & ACTION_SECURE_MOVE) 187 197 { 188 198 if (uID - uidFirstCmd > 0) 189 InsertMenuItem(hSubmenu, CERASER_SEPERATOR_1, TRUE, GetSeparator());190 InsertMenu (hSubmenu, CERASER_SECURE_MOVE, MF_BYPOSITION, uID++, _T("Secure &Move"));191 VerbMenuIndices.push_back( CERASER_SECURE_MOVE);199 InsertMenuItem(hSubmenu, 0, FALSE, GetSeparator()); 200 InsertMenu (hSubmenu, ACTION_SECURE_MOVE, MF_BYPOSITION, uID++, _T("Secure &Move")); 201 VerbMenuIndices.push_back(ACTION_SECURE_MOVE); 192 202 } 193 203 … … 319 329 return false; 320 330 321 /*Handle<HFONT> font = CreateFontIndirect(&logFont);322 SelectObject(hdc, font);*/323 331 SIZE textSize; 324 332 if (!GetTextExtentPoint32(hdc, m_szMenuTitle, static_cast<DWORD>(wcslen(m_szMenuTitle)), &textSize)) … … 342 350 343 351 //Check idCmd, it must be 0 or 1 since we have two menu items. 344 if ( idCmd > 2)352 if (idCmd > 2) 345 353 return E_INVALIDARG; 346 354 … … 413 421 switch (VerbMenuIndices[LOWORD(pCmdInfo->lpVerb)]) 414 422 { 415 case CERASER_ERASE:423 case ACTION_ERASE: 416 424 { 417 425 //Add Task command. … … 446 454 } 447 455 // NOT IMPLEMENTED METHODS 448 case CERASER_ERASE_ON_RESTART:456 case ACTION_ERASE_ON_RESTART: 449 457 { 450 458 MessageBox (pCmdInfo->hwnd, szMsg, _T("Eraser v6 - Shell Extention Query"), MB_ICONINFORMATION ); … … 534 542 } 535 543 536 CCtxMenu::CEraserLPVERBS CCtxMenu::GetApplicableActions() 537 { 538 unsigned result = CERASER_ERASE | CERASER_ERASE_ON_RESTART | CERASER_SECURE_MOVE | 539 CERASER_ERASE_UNUSED_SPACE; 540 541 //Check if this is a context menu (as in, user-invoked) or a drag-and-drop 542 //operation. The latter only allows for Secure Move. 543 if (!m_szDestinationDirectory.empty()) 544 result = CERASER_SECURE_MOVE; 545 544 CCtxMenu::Actions CCtxMenu::GetApplicableActions() 545 { 546 unsigned result = 0; 547 548 //First decide the actions which are applicable to the current invocation 549 //reason. 550 switch (InvokeReason) 551 { 552 case INVOKEREASON_RECYCLEBIN: 553 result |= ACTION_ERASE | ACTION_ERASE_ON_RESTART; 554 break; 555 case INVOKEREASON_FILEFOLDER: 556 result |= ACTION_ERASE | ACTION_ERASE_ON_RESTART | ACTION_ERASE_UNUSED_SPACE; 557 case INVOKEREASON_DRAGDROP: 558 result |= ACTION_SECURE_MOVE; 559 } 560 561 //Remove actions that don't apply to the current invocation reason. 546 562 for (std::list<std::wstring>::const_iterator i = m_szSelectedFiles.begin(); 547 563 i != m_szSelectedFiles.end(); ++i) … … 556 572 sizeof(volumeName) / sizeof(volumeName[0]))) 557 573 { 558 result &= ~ CERASER_ERASE_UNUSED_SPACE;559 } 560 } 561 562 return static_cast< CEraserLPVERBS>(result);574 result &= ~ACTION_ERASE_UNUSED_SPACE; 575 } 576 } 577 578 return static_cast<Actions>(result); 563 579 } 564 580 … … 567 583 ZwQueryKey = reinterpret_cast<pZwQueryKey>(GetProcAddress( 568 584 LoadLibrary(L"Ntdll.dll"), "ZwQueryKey")); 569 ULONG keyInfoSize = sizeof(KEY_ BASIC_INFORMATION);570 KEY_ BASIC_INFORMATION* keyInfo = NULL;585 ULONG keyInfoSize = sizeof(KEY_NODE_INFORMATION); 586 KEY_NODE_INFORMATION* keyInfo = NULL; 571 587 NTSTATUS queryResult = ERROR_MORE_DATA; 572 588 … … 574 590 { 575 591 delete[] keyInfo; 576 keyInfo = reinterpret_cast<KEY_ BASIC_INFORMATION*>(592 keyInfo = reinterpret_cast<KEY_NODE_INFORMATION*>( 577 593 new char[keyInfoSize += 512]); 578 594 ::ZeroMemory(keyInfo, keyInfoSize); 579 queryResult = ZwQueryKey(handle, Key BasicInformation, keyInfo,595 queryResult = ZwQueryKey(handle, KeyNodeInformation, keyInfo, 580 596 keyInfoSize, &keyInfoSize); 581 597 } 582 598 583 std::wstring result(keyInfo->Name, keyInfoSize - 584 sizeof(KEY_BASIC_INFORMATION) + 1); 599 std::wstring result(keyInfo->Name); 585 600 delete[] keyInfo; 586 601 return result; -
branches/eraser6/ShellExt/CtxMenu.h
r715 r716 57 57 }; 58 58 59 enum CEraserLPVERBS59 enum Actions 60 60 { 61 CERASER_ERASE = 1 << 0,62 CERASER_ERASE_ON_RESTART= 1 << 1,63 CERASER_ERASE_UNUSED_SPACE = 1 << 2,64 CERASER_SEPERATOR_1,65 CERASER_SECURE_MOVE = 1 << 3,61 ACTION_ERASE = 1 << 0, 62 ACTION_ERASE_ON_RESTART = 1 << 1, 63 ACTION_ERASE_UNUSED_SPACE = 1 << 2, 64 ACTION_SEPERATOR_1, 65 ACTION_SECURE_MOVE = 1 << 3, 66 66 }; 67 67 … … 81 81 bool OnDrawItem(HDC hdc, RECT rect, UINT action, UINT state); 82 82 83 CEraserLPVERBSGetApplicableActions();83 Actions GetApplicableActions(); 84 84 85 85 static std::wstring GetHKeyPath(HKEY handle); … … 95 95 string_list m_szSelectedFiles; 96 96 string_type m_szDestinationDirectory; 97 std::vector< CEraserLPVERBS> VerbMenuIndices;97 std::vector<Actions> VerbMenuIndices; 98 98 99 99 static const wchar_t* m_szMenuTitle;
Note: See TracChangeset
for help on using the changeset viewer.
