c# - Is it possible to get information which drives encrypted by TrueCrypt? -
is there chance c# application information drives encrypted truecrypt application. other options helpful.
thank in advance.
yes. when using code (based on code found @ 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); }
the variable targetpath in scenario contains value \device\truecryptvolumen.
when passing c:\ in path, value of targetpath \device\harddiskvolume1.
Comments
Post a Comment