Можно ли получить информацию о том, какие диски зашифрованы TrueCrypt?

Есть ли возможность получить из приложения C# информацию о том, какие диски были зашифрованы приложением TrueCrypt. Другие варианты также были бы очень полезны.

Заранее большое спасибо.


person user1285993    schedule 29.04.2015    source источник
comment
TrueCrypt разработан таким образом, что невозможно определить, является ли устройство или файл контейнером TrueCrypt.   -  person Dirk    schedule 29.04.2015
comment
Только для уже смонтированных томов? вы можете попробовать API TrueCrypt GetMountedVolume   -  person James Barrass    schedule 29.04.2015


Ответы (1)


да. При использовании этого кода (на основе кода, найденного по адресу https://social.msdn.microsoft.com/Forums/en-US/e43cc927-4bcc-42d7-9630-f5fdfdb4a1fa/get-absolute-path-of-drive-mapped-to-local-folder?forum=netfxnetcom):

[DllImport("kernel32.dll")]
private static extern uint QueryDosDevice(string lpDeviceName, StringBuilder lpTargetPath, int ucchMax);

public static bool IsTrueCryptVolume(string path, out StringBuilder lpTargetPath)
{
    bool isTrueCryptVolume = false;
    if (String.IsNullOrWhiteSpace(path))
    {
        throw new ArgumentException("path");
    }

    string pathRoot = Path.GetPathRoot(path);
    if (String.IsNullOrWhiteSpace(pathRoot))
    {
        throw new ArgumentException("path");
    }

    string lpDeviceName = pathRoot.Replace("\\", String.Empty);
    lpTargetPath = new StringBuilder(260);
    if (0 != QueryDosDevice(lpDeviceName, lpTargetPath, lpTargetPath.Capacity))
    {
        isTrueCryptVolume = lpTargetPath.ToString().ToLower().Contains("truecrypt");
    }

    return isTrueCryptVolume;
}

static void Main(string[] args)
{
    StringBuilder targetPath;
    var isTrueCryptVolume = IsTrueCryptVolume("N:\\", out targetPath);
}

Переменная targetPath в этом сценарии содержит значение \Device\TrueCryptVolumeN.

При передаче C:\ в качестве пути значение targetPath равно \Device\HarddiskVolume1.

person Pharmakon    schedule 28.05.2015
comment
Лучший ответ можно найти здесь: stackoverflow.com/questions/16753345/ - person Pharmakon; 28.05.2015