• 大小: 172KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-10
  • 语言: 其他
  • 标签: C#  ext3  

资源简介

读取ext3文件系统里的文件,支持多个磁盘,多个分区,能复制,不能写,暂时不支持ext4(以后会支持),.net4.0环境,win7,vs2010通过。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using Microsoft.Win32.SafeHandles;
using System.ComponentModel;
using System.Windows.Forms;

namespace ExtReader
{
    #region 目录项结构
    internal struct DirEntry 
    {
        public byte file_type; 
        public string file_name; 
        public uint file_inode_num; 
    }
    #endregion
    #region ext分区类
    internal unsafe class ExtPartition
    {
        private const uint Sector_Size = 512; 
        private SafeFileHandle hard_disk_handle = null; //硬盘句柄
        private ulong partition_start_sector = 0; //ext3分区开始扇区
        private uint block_size = 0; //块大小
        private ushort inode_size = 0; //i节点大小
        private uint inodes_per_group = 0;//每块组的i节点数
        private uint group_desc_start = 0;//0号块组中组描述符表的开始块
        private struct inode //i节点结构(只定义了有用的项)
        {
            public ulong size; //文件大小
            public uint block_ptr1; //第一个直接指针
            public uint block_ptr2;
            public uint block_ptr3;
            public uint block_ptr4;
            public uint block_ptr5;
            public uint block_ptr6;
            public uint block_ptr7;
            public uint block_ptr8;
            public uint block_ptr9;
            public uint block_ptr10;
            public uint block_ptr11;
            public uint block_ptr12;
            public uint block_find_ptr; //一级间接指针
            public uint block_sind_ptr; //二级间接指针
            public uint block_tind_ptr; //三级间接指针
        }
        Encoding encoding = Encoding.UTF8;
        private uint ntime = 0;
        internal static BackgroundWorker run_back = new BackgroundWorker(); //后台线程
        public ExtPartition() { }
        public ExtPartition(ulong start_sectorSafeFileHandle hd_disk_handle)
        {
            byte* tmp_buffer = stackalloc byte[1024];
            uint number_of_read = 0;
            hard_disk_handle = hd_disk_handle;//获得磁盘句柄
            HardDisk.set_pointer(start_sector + 2hard_disk_handle);
            FileAPI.ReadFile(hard_disk_handle tmp_buffer 1024 &number_of_read null); //读超级块
            partition_start_sector = start_sector; 
            block_size = (uint)Math.Pow(2 (double)*(uint*)(tmp_buffer + 0x18)) * 1024; 
            inode_size = (ushort)(*(uint*)(tmp_buffer + 0x4C) != 0 ? *(ushort*)(tmp_buffer + 0x58) : 128);
            inodes_per_group = *(uint*)(tmp_buffer + 0x28);
            group_desc_start = (uint)(block_size!=1024 ? 1 : 2);
            run_back.WorkerReportsProgress = true;
            run_back.ProgressChanged +=run_back_ProgressChanged;
            run_back.WorkerSupportsCancellation = true;
            run_back.RunWorkerCompleted += run_back_RunWorkerCompleted;
        }
        private unsafe void read_block(uint block_num byte* dbuffer)//读取块
        {
            uint number_of_read = 0;
            ulong sector_pointer = partition_start_sector + block_n

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1894  2012-03-17 20:31  ExtReader\ExtReader\bin\Debug\ExtReader.application

     文件      28672  2012-03-17 20:31  ExtReader\ExtReader\bin\Debug\ExtReader.exe

     文件       3022  2012-03-17 20:31  ExtReader\ExtReader\bin\Debug\ExtReader.exe.manifest

     文件      93696  2012-03-17 20:31  ExtReader\ExtReader\bin\Debug\ExtReader.pdb

     文件      11600  2012-03-17 20:31  ExtReader\ExtReader\bin\Debug\ExtReader.vshost.exe

     文件       1894  2012-03-17 20:26  ExtReader\ExtReader\bin\Release\ExtReader.application

     文件      27136  2012-03-17 20:26  ExtReader\ExtReader\bin\Release\ExtReader.exe

     文件       3022  2012-03-17 20:26  ExtReader\ExtReader\bin\Release\ExtReader.exe.manifest

     文件      83456  2012-03-17 20:26  ExtReader\ExtReader\bin\Release\ExtReader.pdb

     文件       1894  2012-03-17 20:26  ExtReader\ExtReader\bin\Release\ExtReader.vshost.application

     文件      11600  2012-03-17 20:26  ExtReader\ExtReader\bin\Release\ExtReader.vshost.exe

     文件       3022  2012-03-17 20:26  ExtReader\ExtReader\bin\Release\ExtReader.vshost.exe.manifest

     文件      23863  2012-03-17 20:25  ExtReader\ExtReader\ExtPartition.cs

     文件      14805  2012-03-17 20:24  ExtReader\ExtReader\ExtReader.cs

     文件       6520  2012-03-02 14:05  ExtReader\ExtReader\ExtReader.csproj

     文件        452  2012-02-29 12:14  ExtReader\ExtReader\ExtReader.csproj.user

     文件       9363  2012-03-02 17:14  ExtReader\ExtReader\ExtReader.Designer.cs

     文件       1482  2012-01-01 21:14  ExtReader\ExtReader\ExtReader.idc

     文件       6798  2012-03-02 17:14  ExtReader\ExtReader\ExtReader.resx

     文件       7034  2012-03-17 20:24  ExtReader\ExtReader\FileAPI.cs

     文件       4010  2012-03-17 20:24  ExtReader\ExtReader\HardDisk.cs

     文件       4440  2011-12-25 18:40  ExtReader\ExtReader\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6500  2012-03-17 20:31  ExtReader\ExtReader\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       1894  2012-03-17 20:31  ExtReader\ExtReader\obj\x86\Debug\ExtReader.application

     文件       7174  2012-03-17 20:31  ExtReader\ExtReader\obj\x86\Debug\ExtReader.csproj.FileListAbsolute.txt

     文件      28672  2012-03-17 20:31  ExtReader\ExtReader\obj\x86\Debug\ExtReader.exe

     文件       3022  2012-03-17 20:31  ExtReader\ExtReader\obj\x86\Debug\ExtReader.exe.manifest

     文件        180  2012-03-17 20:31  ExtReader\ExtReader\obj\x86\Debug\ExtReader.ExtReader.resources

     文件      93696  2012-03-17 20:31  ExtReader\ExtReader\obj\x86\Debug\ExtReader.pdb

     文件        180  2012-03-17 20:31  ExtReader\ExtReader\obj\x86\Debug\ExtReader.Properties.Resources.resources

............此处省略43个文件信息

评论

共有 条评论