📄 ctxmenu.cpp
字号:
case 4:
strcpy(msg,
"Secure wipe this file.");
break;
}
}
ODS(msg);
ODS("\r\n");
// return the help string
// get OS type
Version.dwOSVersionInfoSize = (DWORD)(sizeof Version);
GetVersionEx(&Version);
if (Version.dwPlatformId == VER_PLATFORM_WIN32_NT) // if WIN NT
{
// first set empty string
MultiByteToWideChar(CP_ACP, 0, "", -1,
(LPWSTR)pszName, cchMax / 2);
// then convert string
if (cchMax / 2 > strlen(msg)) // if room for message
{
if (!(MultiByteToWideChar(CP_ACP, 0, msg, -1,
(LPWSTR)pszName, cchMax / 2)))
{
#ifdef _DEBUG
char buf1[40];
#endif
ODS("MultiByteToWideChar() failed.\r\n");
ODS("Error Code is: ");
ODS(_ltoa(GetLastError(), buf1, 10));
ODS("\r\n");
}
}
else
ODS("Buffer is not large enough for message.\r\n");
#ifdef _DEBUG
WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)pszName,
-1, msg, sizeof msg, NULL, NULL);
ODS(msg);
ODS("\r\n");
#endif
}
else // WIN 95
{
// make sure the help string isn't too long
// first set empty string
strcpy(pszName, "");
// then copy string if there's room
if (cchMax > strlen(msg)) // if buffer larger than string
strcpy(pszName, msg);
else
ODS("Buffer is not large enough for message.\r\n");
ODS(pszName);
ODS("\r\n");
}
return NOERROR;
}
void CShellExt::CreateEncryptedMenu(UINT idCmdFirst)
{
MENUITEMINFO ItemInfo;
char MText[64];
ItemInfo.cbSize = sizeof ItemInfo;
ItemInfo.fMask = MIIM_TYPE | MIIM_ID;
ItemInfo.fType = MFT_STRING;
ItemInfo.wID = idCmdFirst;
ItemInfo.hSubMenu = NULL;
ItemInfo.hbmpChecked = NULL;
ItemInfo.hbmpUnchecked = NULL;
ItemInfo.dwItemData = 0;
ItemInfo.dwTypeData = MText;
ItemInfo.cch = 0;
strcpy(SubMenuType, "Encrypted");
hSubMenu = CreatePopupMenu();
/*
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE;
ItemInfo.fState = MF_DISABLED; // for title line
strcpy(MText, "Pretty Good Privacy");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_SEPARATOR;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
*/
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID;
ItemInfo.fState = MFS_ENABLED; // for command lines
++ItemInfo.wID;
strcpy(MText, "&Decrypt && Verify");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType=MFT_SEPARATOR ;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_STRING;
++ItemInfo.wID;
strcpy(MText, "&Wipe");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
/*
++ItemInfo.wID;
strcpy(MText, "&Verify");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
*/
SubMenuItems = 3;
}
void CShellExt::CreateVerifyMenu(UINT idCmdFirst)
{
MENUITEMINFO ItemInfo;
char MText[64];
ItemInfo.cbSize = sizeof ItemInfo;
ItemInfo.wID = idCmdFirst;
ItemInfo.hSubMenu = NULL;
ItemInfo.hbmpChecked = NULL;
ItemInfo.hbmpUnchecked = NULL;
ItemInfo.dwItemData = 0;
ItemInfo.dwTypeData = MText;
ItemInfo.cch = 0;
strcpy(SubMenuType, "Verify");
hSubMenu = CreatePopupMenu();
/*
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE;
ItemInfo.fState = MF_DISABLED; // for title line
strcpy(MText, "Pretty Good Privacy");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_SEPARATOR;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
*/
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID;
ItemInfo.fState = MFS_ENABLED; // for command lines
++ItemInfo.wID;
strcpy(MText, "&Verify Signature");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType=MFT_SEPARATOR ;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_STRING;
++ItemInfo.wID;
strcpy(MText, "&Wipe");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
SubMenuItems = 3;
}
void CShellExt::CreateKeyfileMenu(UINT idCmdFirst)
{
MENUITEMINFO ItemInfo;
char MText[64];
ItemInfo.cbSize = sizeof ItemInfo;
ItemInfo.wID = idCmdFirst;
ItemInfo.hSubMenu = NULL;
ItemInfo.hbmpChecked = NULL;
ItemInfo.hbmpUnchecked = NULL;
ItemInfo.dwItemData = 0;
ItemInfo.dwTypeData = MText;
ItemInfo.cch = 0;
strcpy(SubMenuType, "Keyfile");
hSubMenu = CreatePopupMenu();
/*
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE;
ItemInfo.fState = MF_DISABLED; // for title line
strcpy(MText, "Pretty Good Privacy");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_SEPARATOR;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
*/
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID;
ItemInfo.fState = MFS_ENABLED; // for command lines
++ItemInfo.wID;
strcpy(MText, "&Add Keys to Keyring");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType=MFT_SEPARATOR ;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_STRING;
++ItemInfo.wID;
strcpy(MText, "&Wipe");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
SubMenuItems = 3;
}
void CShellExt::CreateViewKeyringMenu(UINT idCmdFirst)
{
MENUITEMINFO ItemInfo;
char MText[64];
ItemInfo.cbSize = sizeof ItemInfo;
ItemInfo.wID = idCmdFirst;
ItemInfo.hSubMenu = NULL;
ItemInfo.hbmpChecked = NULL;
ItemInfo.hbmpUnchecked = NULL;
ItemInfo.dwItemData = 0;
ItemInfo.dwTypeData = MText;
ItemInfo.cch = 0;
strcpy(SubMenuType, "AddKeys");
hSubMenu = CreatePopupMenu();
/*
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE;
ItemInfo.fState = MF_DISABLED; // for title line
strcpy(MText, "Pretty Good Privacy");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_SEPARATOR;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
*/
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID;
ItemInfo.fState = MFS_ENABLED; // for command lines
++ItemInfo.wID;
strcpy(MText, "&Add Keys to Keyring");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType=MFT_SEPARATOR ;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_STRING;
++ItemInfo.wID;
strcpy(MText, "&Wipe");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
SubMenuItems = 3;
}
void CShellExt::CreateDirectoryMenu(UINT idCmdFirst)
{
MENUITEMINFO ItemInfo;
char MText[64];
ItemInfo.cbSize = sizeof ItemInfo;
ItemInfo.wID = idCmdFirst;
ItemInfo.hSubMenu = NULL;
ItemInfo.hbmpChecked = NULL;
ItemInfo.hbmpUnchecked = NULL;
ItemInfo.dwItemData = 0;
ItemInfo.dwTypeData = MText;
ItemInfo.cch = 0;
strcpy(SubMenuType, "Directory");
hSubMenu = CreatePopupMenu();
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID;
ItemInfo.fState = MFS_ENABLED; // for command lines
++ItemInfo.wID;
strcpy(MText, "&Encrypt");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
++ItemInfo.wID;
strcpy(MText, "&Sign");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
++ItemInfo.wID;
strcpy(MText, "E&ncrypt && Sign");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType=MFT_SEPARATOR ;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_STRING;
++ItemInfo.wID;
strcpy(MText, "D&ecrypt && Verify");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType=MFT_SEPARATOR ;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_STRING;
++ItemInfo.wID;
strcpy(MText, "&Wipe");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
SubMenuItems = 6;
}
void CShellExt::CreatePlaintextMenu(UINT idCmdFirst)
{
MENUITEMINFO ItemInfo;
char MText[64];
ItemInfo.cbSize = sizeof ItemInfo;
ItemInfo.wID = idCmdFirst;
ItemInfo.hSubMenu = NULL;
ItemInfo.hbmpChecked = NULL;
ItemInfo.hbmpUnchecked = NULL;
ItemInfo.dwItemData = 0;
ItemInfo.dwTypeData = MText;
ItemInfo.cch = 0;
strcpy(SubMenuType, "Plaintext");
hSubMenu = CreatePopupMenu();
ItemInfo.fType = MFT_STRING;
ItemInfo.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID;
ItemInfo.fState = MFS_ENABLED; // for command lines
++ItemInfo.wID;
strcpy(MText, "&Encrypt");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
++ItemInfo.wID;
strcpy(MText, "&Sign");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
++ItemInfo.wID;
strcpy(MText, "E&ncrypt && Sign");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType=MFT_SEPARATOR ;
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
ItemInfo.fType = MFT_STRING;
++ItemInfo.wID;
strcpy(MText, "&Wipe");
InsertMenuItem(hSubMenu, 0xffffffff, TRUE, &ItemInfo);
SubMenuItems = 5;
}
LRESULT CALLBACK ShellProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
// See if user deselects caching via prefs
CheckForPurge(msg,wParam);
switch(msg)
{
case WM_CREATE:
{
ShowWindow(hwnd, SW_HIDE);
return 0;
}
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
#define szAppName "PGPshell_HiddenWindow"
HWND ShellWindow(void)
{
HWND hwnd;
WNDCLASS wc;
// Register the Server Window Class
wc.style = 0;
wc.lpfnWndProc = ShellProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = g_hmodThisDll;
wc.hIcon = 0;
wc.hCursor = 0;
wc.hbrBackground = 0;
wc.lpszMenuName = 0;
wc.lpszClassName = szAppName;
RegisterClass(&wc);
hwnd = CreateWindow(
szAppName, szAppName, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, NULL, NULL, g_hmodThisDll, NULL );
return hwnd;
}
HRESULT CallPGP(STGMEDIUM *pMedium, UINT ActionCode)
{
int i;
UINT ReturnCode;
HWND hwnd;
int NumFiles;
BOOL bEncrypt,bSign;
char szFile[MAX_PATH+1];
FILELIST *ListHead;
strcpy(szApp,"PGPshell");
ReturnCode=TRUE;
if(PGPsc==0)
{
if(!InitPGPsc(NULL,&PGPsc,&PGPtls))
return(ReturnCode);
// For getting global windows messages
g_hwndShell=ShellWindow();
}
hwnd = GetForegroundWindow();
NumFiles = DragQueryFile((HDROP) pMedium->hGlobal, (UINT)-1, 0, 0);
if(NumFiles==0)
return(ReturnCode);
ReturnCode=TRUE;
bEncrypt=bSign=FALSE;
if(ActionCode==PGP_CODE_ENCRYPT)
bEncrypt = TRUE;
if(ActionCode==PGP_CODE_SIGN)
bSign = TRUE;
if(ActionCode==PGP_CODE_ENCRYPT_SIGN)
bEncrypt = bSign = TRUE;
if ((ActionCode==PGP_CODE_ENCRYPT)||
(ActionCode==PGP_CODE_SIGN) ||
(ActionCode==PGP_CODE_ENCRYPT_SIGN))
{
ListHead=0;
for(i=0;i<NumFiles && ReturnCode == TRUE;i++)
{
DragQueryFile((HDROP) pMedium->hGlobal,
i,szFile,MAX_PATH);
AddToFileList(&ListHead,szFile,NULL);
}
ReturnCode = EncryptFileList(hwnd,szApp,PGPsc,PGPtls,
ListHead,
bEncrypt,
bSign);
}
if((ActionCode==PGP_CODE_DECRYPT)||
(ActionCode==PGP_CODE_VERIFY_SIG)||
(ActionCode==PGP_CODE_VERIFY))
{
ListHead=0;
for(i=0;i<NumFiles && ReturnCode == TRUE;i++)
{
DragQueryFile((HDROP) pMedium->hGlobal,
i,szFile,MAX_PATH);
AddToFileList(&ListHead,szFile,NULL);
}
ReturnCode = DecryptFileList(hwnd,szApp,PGPsc,PGPtls,
ListHead);
}
if(ActionCode==PGP_CODE_WIPE)
{
DWORD FileAttr;
ListHead=0;
for(i=0;i<NumFiles && ReturnCode == TRUE;i++)
{
DragQueryFile((HDROP) pMedium->hGlobal,
i,szFile,MAX_PATH);
FileAttr = GetFileAttributes(szFile);
if (FileAttr == 0xFFFFFFFF)
;
else if (FileAttr & FILE_ATTRIBUTE_SYSTEM)
;
else if (FileAttr & FILE_ATTRIBUTE_READONLY)
;
else
AddToFileList(&ListHead,szFile,NULL);
}
ReturnCode = WipeFileList(hwnd,PGPsc,
ListHead,TRUE);
}
ReleaseStgMedium(pMedium);
return ReturnCode;
}
BOOL CShellExt::AddMenuSeparator(HMENU hMenu, int iPosition)
{
MENUITEMINFO MenuItemInfo;
BOOL bRC;
MenuItemInfo.cbSize = sizeof(MENUITEMINFO);
MenuItemInfo.fMask = MIIM_TYPE;
MenuItemInfo.fType = MFT_SEPARATOR;
bRC = InsertMenuItem(hMenu,
iPosition,
TRUE,
&MenuItemInfo);
if (!bRC) {
// wow, we couldn't add the separator after Send To...
ODS("Insert Separator failed...\r\n");
return FALSE;
}
return TRUE;
}
LRESULT CALLBACK InvisiProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
{
return 0;
}
case WM_QUERYOPEN:
{
return 0;
}
#if 0
case WM_CLOSE:
{
PostQuitMessage(0);
return 0;
}
#endif
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
/*__Editor_settings____
Local Variables:
tab-width: 4
End:
vi: ts=4 sw=4
vim: si
_____________________*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -