how to (programatically) open a partition within a disk image

2014-07-22
2014-07-23
  • erwan labalec
    erwan labalec
    2014-07-22

    Hi,

    I am a delphi developper and using 7-zip from within delphi.
    I use this unit : https://code.google.com/p/d7zip/source/browse/sevenzip.pas .

    Works nicely as I can open and extract most containers (zip,7z,etc..).

    I can also open logical/partition image fine usingt he ntfs GUID.

    Now here comes my problem, I would like to open a physical/disk image containing one or more partitions.
    This I can do as I see my partitions but I would like to open these within my disk image just like one would open a zip file within a zip file.

    Here below my (delphi) code.
    Note that I have also tried opened my disk image as a filestream, position me (seek) onto the right (partition) offset but no success as well.

    Any hint, pointer, suggestion welcome ...

    procedure TForm1.Button2Click(Sender: TObject);
    var
    i:integer;
    arch:i7zInArchive;
    li:tlistitem;
    begin
    ListView1.Clear ;
    //guid:=CLSID_CFormatMbr;
    arch:=CreateInArchive(guid );
    with arch do
    begin
    OpenFile(filename);
    showmessage(inttostr(NumberOfItems));
    for i := 0 to NumberOfItems - 1 do
    if not ItemIsFolder[i] then
    begin
    li:=ListView1.Items.Add ;
    li.Caption :=inttostr(i);
    li.SubItems.Add(Itempath[i])
    end;
    end;
    arch.Close ;
    end;

    Thanks,
    Erwan.

     
  • Igor Pavlov
    Igor Pavlov
    2014-07-23

    Do you have some file c:\a.img and you want to open it?
    Can 7-Zip open that file?

     
  • erwan labalec
    erwan labalec
    2014-07-23

    Hi Igor,
    Yes, 7-zip open my disk image just fine.
    If that disk image contains one partition, it will open this partition bu default.
    If that disk image contains several partitions, it will list all partitions (0.ntfs, 1.ntfs, etc...) and I can then enter the one of my choice.

    In short, I want to do the same by code : open a disk image as guid mbr, enumerate partitions in there (this i can), open on these as ntfs guid (within the disk image), enumerate files in there.

    Thanks for your feedback, much appreciated.

    Regards,
    Erwan

     
  • Igor Pavlov
    Igor Pavlov
    2014-07-23

    Check that you use same version of code (7z.dll).
    If 7-Zip can open file via that 7z.dll, then you also can open that file with same 7z.dll. I don't know about delphi wrapper things.

     
  • erwan labalec
    erwan labalec
    2014-07-23

    I took the 7z.dll from version 7-zip 9.25, the same 7-zip GUI version I use to open my disk image.

    Would you have an example / piece of code (does not have to be working or complete) to illustrate what I am looking for?

    This is the method I dont get.
    The code I can work my way thru.

    Thanks :)

    /Erwan

     
  • Igor Pavlov
    Igor Pavlov
    2014-07-23

    You say that you can open most containers:
    (zip,7z,etc..).
    So try another formats, including ntfs, fat, mbr and so on.
    You can extract fat examples with 7-Zip.
    And write exact list:
    ZIP - OK
    7z- OK
    mbr- ERROR
    ....

     
    Last edit: Igor Pavlov 2014-07-23