1.TrueCrypt Mount更改加密卷密码
TrueCrypt项目中ChangePwd具体参数:
int ChangePwd (char *lpszVolume,
Password *oldPassword,
Password *newPassword,
int pkcs5,
HWND hwndDlg);
参数 | 类型 | 含义 | 示例 |
lpszVolume | char * | 加密卷文件 | NULL |
oldPassword | Password | 原密码 | |
newPassword | Password | 新密码 | |
pkcs5 | int | 哈希算法 | 0 |
hwndDlg | HWND | 传入的窗口句柄 | NULL |
2.实际调用
extern "C" __declspec(dllexport) int ChangePasswordC(char* szFile, char* szoldPassword, char* sznewPassowrd, HWND hwndDlg)
{
char szFileName[TC_MAX_PATH+1];
int nStatus;
Password oldPassword;
Password newPassword;
int pkcs5;
strcpy(szFileName, szFile);
szFileName[strlen(szFile)] = 0;
strcpy((char *)oldPassword.Text, szoldPassword);
oldPassword.Length = strlen ((char *)oldPassword.Text);
strcpy((char *)newPassword.Text, sznewPassowrd);
newPassword.Length = strlen ((char *)newPassword.Text);
pkcs5 = 0;
nStatus = ChangePwd (szFileName, &oldPassword, &newPassword, pkcs5, hwndDlg);
if (nStatus == ERR_OS_ERROR
&& GetLastError () == ERROR_ACCESS_DENIED
&& IsUacSupported ()
&& IsVolumeDeviceHosted (szFileName))
{
WaitCursor ();
nStatus = UacChangePwd (szFileName, &oldPassword, &newPassword, pkcs5, hwndDlg);
NormalCursor ();
}
burn (&oldPassword, sizeof (oldPassword));
burn (&newPassword, sizeof (newPassword));
if (nStatus == 0)
{
return 1;
}
return 0;
}