1.0.21
This commit is contained in:
parent
a35ade29c0
commit
c23584b0ca
|
@ -22,7 +22,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||
|
||||
### Fixed
|
||||
- fixed issue when running a firefox/chrome built with mingw [#538](https://github.com/sandboxie-plus/Sandboxie/issues/538)
|
||||
|
||||
- fixed issues with folder recovery using the sandman ui [#1840](https://github.com/sandboxie-plus/Sandboxie/issues/1840) [#1380](https://github.com/sandboxie-plus/Sandboxie/issues/1380)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -869,6 +869,43 @@ ULONG CSbieAPI__GetVolumeSN(wchar_t* path)
|
|||
return sn;
|
||||
}
|
||||
|
||||
QString CSbieAPI::ResolveAbsolutePath(const QString& Path)
|
||||
{
|
||||
wstring path = Path.toStdWString();
|
||||
UNICODE_STRING uni;
|
||||
RtlInitUnicodeString(&uni, path.c_str());
|
||||
OBJECT_ATTRIBUTES objattrs;
|
||||
InitializeObjectAttributes(&objattrs, &uni, OBJ_CASE_INSENSITIVE, NULL, NULL);
|
||||
|
||||
HANDLE FileHandle;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
NTSTATUS status = NtCreateFile(&FileHandle, FILE_READ_ATTRIBUTES | SYNCHRONIZE, &objattrs, &IoStatusBlock, NULL, 0,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_OPEN, FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT,NULL, 0);
|
||||
|
||||
if (NT_SUCCESS(status)) {
|
||||
|
||||
const ULONG NameLen = 4096;
|
||||
WCHAR NameBuf[NameLen];
|
||||
|
||||
__declspec(align(8)) ULONG64 parms[API_NUM_ARGS];
|
||||
API_GET_FILE_NAME_ARGS *args = (API_GET_FILE_NAME_ARGS *)parms;
|
||||
|
||||
memset(parms, 0, sizeof(parms));
|
||||
args->func_code = API_GET_FILE_NAME;
|
||||
args->handle.val64 = (ULONG64)(ULONG_PTR)FileHandle;
|
||||
args->name_len.val64 = (ULONG64)(ULONG_PTR)(NameLen * sizeof(WCHAR));
|
||||
args->name_buf.val64 = (ULONG64)(ULONG_PTR)NameBuf;
|
||||
status = m->IoControl(parms);
|
||||
|
||||
NtClose(FileHandle);
|
||||
|
||||
if (NT_SUCCESS(status))
|
||||
return QString::fromWCharArray(NameBuf);
|
||||
}
|
||||
|
||||
return Path;
|
||||
}
|
||||
|
||||
void CSbieAPI::UpdateDriveLetters()
|
||||
{
|
||||
QWriteLocker Lock(&m_DriveLettersMutex);
|
||||
|
|
|
@ -52,6 +52,8 @@ public:
|
|||
virtual QString GetSbiePath() const { return m_SbiePath; }
|
||||
virtual QString GetIniPath() const { return m_IniPath; }
|
||||
|
||||
virtual QString ResolveAbsolutePath(const QString& Path);
|
||||
|
||||
virtual void UpdateDriveLetters();
|
||||
virtual QString Nt2DosPath(QString NtPath, bool* pOk = NULL) const;
|
||||
|
||||
|
|
|
@ -117,12 +117,14 @@ CRecoveryWindow::CRecoveryWindow(const CSandBoxPtr& pBox, QWidget *parent)
|
|||
|
||||
foreach(const QString& NtFolder, m_pBox->GetTextList("RecoverFolder", true, true))
|
||||
{
|
||||
QString RecFolder = theAPI->ResolveAbsolutePath(NtFolder);
|
||||
|
||||
bool bOk;
|
||||
QString Folder = theAPI->Nt2DosPath(NtFolder, &bOk);
|
||||
QString Folder = theAPI->Nt2DosPath(RecFolder, &bOk);
|
||||
if(bOk)
|
||||
m_RecoveryFolders.append(Folder);
|
||||
else if(NtFolder.left(11) == "\\Device\\Mup")
|
||||
m_RecoveryFolders.append("\\" + NtFolder.mid(11));
|
||||
else if(RecFolder.left(11) == "\\Device\\Mup")
|
||||
m_RecoveryFolders.append("\\" + RecFolder.mid(11));
|
||||
}
|
||||
|
||||
ui.cmbRecover->addItem(tr("Original location"), 0);
|
||||
|
@ -383,7 +385,11 @@ QPair<int, quint64> CRecoveryWindow::FindFiles(const QString& BoxedFolder, const
|
|||
void CRecoveryWindow::RecoverFiles(bool bBrowse, QString RecoveryFolder)
|
||||
{
|
||||
//bool HasShare = false;
|
||||
QMap<QString, QString> FileMap;
|
||||
struct SRecItem {
|
||||
QString FullPath;
|
||||
QString RelPath;
|
||||
};
|
||||
QMap<QString, SRecItem> FileMap;
|
||||
foreach(const QModelIndex& Index, ui.treeFiles->selectionModel()->selectedIndexes())
|
||||
{
|
||||
QModelIndex ModelIndex = m_pSortProxy->mapToSource(Index);
|
||||
|
@ -398,10 +404,16 @@ void CRecoveryWindow::RecoverFiles(bool bBrowse, QString RecoveryFolder)
|
|||
{
|
||||
//if (File["DiskPath"].toString().indexOf("\\device\\mup", 0, Qt::CaseInsensitive) == 0)
|
||||
// HasShare = true;
|
||||
FileMap[File["BoxPath"].toString()] = File["DiskPath"].toString();
|
||||
QString CurPath = File["DiskPath"].toString();;
|
||||
FileMap[File["BoxPath"].toString()].FullPath = CurPath;
|
||||
FileMap[File["BoxPath"].toString()].RelPath = CurPath.mid(CurPath.lastIndexOf("\\"));
|
||||
}
|
||||
else
|
||||
{
|
||||
QString DirPath = File["DiskPath"].toString();
|
||||
//if(ModelIndex.parent().isValid())
|
||||
// DirPath = Split2(DirPath, "\\", true).first;
|
||||
|
||||
QList<QModelIndex> Folders;
|
||||
Folders.append(ModelIndex);
|
||||
do
|
||||
|
@ -420,7 +432,12 @@ void CRecoveryWindow::RecoverFiles(bool bBrowse, QString RecoveryFolder)
|
|||
{
|
||||
//if (File["DiskPath"].toString().indexOf("\\device\\mup") == 0)
|
||||
// HasShare = true;
|
||||
FileMap[File["BoxPath"].toString()] = File["DiskPath"].toString();
|
||||
QString CurPath = File["DiskPath"].toString();
|
||||
FileMap[File["BoxPath"].toString()].FullPath = CurPath;
|
||||
|
||||
QString RelPath = CurPath.mid(DirPath.length());
|
||||
if (RelPath.length() > FileMap[File["BoxPath"].toString()].RelPath.length())
|
||||
FileMap[File["BoxPath"].toString()].RelPath = RelPath;
|
||||
}
|
||||
else
|
||||
Folders.append(ChildIndex);
|
||||
|
@ -448,14 +465,15 @@ void CRecoveryWindow::RecoverFiles(bool bBrowse, QString RecoveryFolder)
|
|||
|
||||
|
||||
QList<QPair<QString, QString>> FileList;
|
||||
for(QMap<QString, QString>::const_iterator I = FileMap.begin(); I != FileMap.end(); ++I)
|
||||
for(QMap<QString, SRecItem>::const_iterator I = FileMap.begin(); I != FileMap.end(); ++I)
|
||||
{
|
||||
QString BoxedFilePath = I.key();
|
||||
QString RecoveryPath = I.value();
|
||||
QString RecoveryPath = I.value().FullPath;
|
||||
if (!RecoveryFolder.isEmpty())
|
||||
{
|
||||
QString FileName = RecoveryPath.mid(RecoveryPath.lastIndexOf("\\") + 1);
|
||||
RecoveryPath = RecoveryFolder + "\\" + FileName;
|
||||
//QString FileName = RecoveryPath.mid(RecoveryPath.lastIndexOf("\\") + 1);
|
||||
//RecoveryPath = RecoveryFolder + "\\" + FileName;
|
||||
RecoveryPath = RecoveryFolder + I.value().RelPath;
|
||||
}
|
||||
|
||||
FileList.append(qMakePair(BoxedFilePath, RecoveryPath));
|
||||
|
|
Loading…
Reference in New Issue