예제 #1
0
        private void Load(string Path)
        {
            if (string.IsNullOrEmpty(Path))
            {
                throw new ArgumentNullException("Path");
            }

            _length = GetDiskSize.GetDiskLength(@"\\.\PhysicalDrive" + PhysicalDiskId.ToLower().Replace(@"\\.\physicaldrive", ""));
            IntPtr ptr = CreateFile(Path, GENERIC_READ, 0, IntPtr.Zero, OPEN_EXISTING, DEVICE, IntPtr.Zero);

            handleValue = new SafeFileHandle(ptr, true);

            if (handleValue.IsInvalid)
            {
                Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
            }

            uint lpBytesReturned = 0;
            var  result          = DeviceIoControl(handleValue, FSCTL_LOCK_VOLUME, IntPtr.Zero, 0, IntPtr.Zero, 0, ref lpBytesReturned, IntPtr.Zero);

            if (0 == result)
            {
                Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: Seabreg/DumpIt-1
        static void Main(string[] args)
        {
            var ass       = Assembly.GetExecutingAssembly();
            var fvi       = FileVersionInfo.GetVersionInfo(ass.Location);
            var Heading   = new HeadingInfo(fvi.FileDescription, ass.GetName().Version.ToString());
            var Copyright = new CopyrightInfo(fvi.CompanyName, DateTime.Today.Year);

            Parser.Default.ParseArguments <Options>(args).WithParsed(o =>
            {
                Console.WriteLine(Heading.ToString());
                Console.WriteLine(Copyright.ToString());
                Console.WriteLine();

                if (!string.IsNullOrEmpty(o.Excludelist) && File.Exists(o.Excludelist))
                {
                    partitions = new List <string>(File.ReadAllLines(o.Excludelist)).ToArray();
                }

                ulong eMMCDumpSize;
                ulong SectorSize = 0x200;

                if (o.ImgFile.ToLower().Contains(@"\\.\physicaldrive"))
                {
                    Logging.Log("Tool is running in Device Dump mode.");
                    Logging.Log("Gathering disk geometry...");
                    eMMCDumpSize = (ulong)GetDiskSize.GetDiskLength(@"\\.\PhysicalDrive" + o.ImgFile.ToLower().Replace(@"\\.\physicaldrive", ""));
                    SectorSize   = (ulong)GetDiskSize.GetDiskSectorSize(@"\\.\PhysicalDrive" + o.ImgFile.ToLower().Replace(@"\\.\physicaldrive", ""));
                }
                else
                {
                    Logging.Log("Tool is running in Image Dump mode.");
                    Logging.Log("Gathering disk image geometry...");
                    eMMCDumpSize = (ulong)new FileInfo(o.ImgFile).Length;
                }

                Logging.Log("Reported source device eMMC size is: " + eMMCDumpSize + " bytes - " + eMMCDumpSize / 1024 / 1024 + "MB - " + eMMCDumpSize / 1024 / 1024 / 1024 + "GB.");
                Logging.Log("Selected " + SectorSize + "B for the sector size");

                ConvertDD2VHD(o.ImgFile, o.VhdFile, partitions, o.Recovery, (int)SectorSize);
            });
        }