Using Iso7z From command line

alec100_94

New member
I am writing a program that will parse filenames from disc images in a multitude of different formats, and Iso7z works really well for me (and all the formats I need), but I am unable to get it to work in a sensible way from the command line (which I would need to include it in my program). The problem isn't being able to use the plugin but more how it exposes the contents of each container format as an iso file. I want to essentially "peek" inside this iso file without a full extraction and list the file names within it, the problem is the 7zip command line won't let me because the iso file itself is within an archive (listing contents of the container just gives me the iso file). In the GUI (7zFM) I can do this very easily, I can just open the file (double click or enter) in place and it shows me the contents without attempting to do a full extraction, but have not found a similar way of doing this from the command line (which I need for my application). Hopefully someone here can help me with a workaround for this issue. Thanks in Advance.
 

alec100_94

New member
I'm going to add a little more information here. I've done some research, and am currently trying to make a C++ command line app myself that uses 7z.dll. I am a bit lost on how to allow that to work with Iso7z's formats, I am using the Proxy7z library, but am not sure how to it to extract a file using one of the Iso7z formats. My end goal is to basically have a command line application that you can pass a disc image of any type to and it will give you a list of files and directories on the root of that image. A lack of source code and/or extended documentation for Iso7z and Proxy7z has left me a bit stumped. Hopefully someone here is more familiar with the make up of them, and how to utilise them properly. Am also more than happy to purchase TC4Shell (even know this isn't directly related) if I can get this issue sorted out.
 
Last edited:

alec100_94

New member
So what I am actually trying to do is Identify Playstation 2 format disc images. Each disc image with have a file on the root named SXXS_XXX.XX which indicates its game id which I can then lookup to identify what the game is.
 

Dec

Administrator
Staff member
PS2 disc has SYSTEM.CNF and SXXS_XXX.XX files. SYSTEM.CNF has line

BOOT = cdrom:\SXXS_XXX.XX;1

And only in this case disc is PS2 disc. Is it correct?
 

alec100_94

New member
That is correct. PS1 disc's have pretty much the same system too, but I will only be utilising this for PS2 disc's. I am basically developing a frontend for the PS2 emulator (PCSX2) and need a quick way of identifying a disc image when a user adds it to my frontend, supporting all the formats supported by PCSX2 (including CSO). I currently have a partial solution using CDEMU's libmirage library with the caveat it is on linux, and I need something that runs on windows. Iso7z has this functionality from a visual perspective but not in a way that another program can really make use of (like standard output).
 

Dec

Administrator
Staff member
I can add additional function in dll. Something like

GetPS2BootFileName(in DiscFileName: string; out BootFileName: string).

Where can I read about PS1 disc specific?
 

Dec

Administrator
Staff member
I have updated the plugin. Now it show PS specific info in properties dialog:

Capture.PNG

Could you test the plugin with your files? If everything is ok I will add additional function into dll.
 

alec100_94

New member
Cool, I just sent you a message with some links. A simplified way of looking at it could be that it will apply to anything that already displays "Host OS" as "PLAYSTATION".
 
Last edited:

Dec

Administrator
Staff member
Updated again. For simple iso files 7-Zip will not show any additional info because simple iso files are processed by 7-Zip itself without using Iso7z.
 

alec100_94

New member
That seems to be working now and that's what I thought and makes sense, and it's not really a problem either as I can use plain 7-Zip to get the info I need out of those. Now I just need the function added, Thanks for the help.
 
Last edited:

Dec

Administrator
Staff member
How to use:

Code:
type
  TdecPSInfo = record
    Size: Cardinal;
    BootName: PWideChar;
    BootComment: PWideChar;
    PEType: Cardinal; // 0 - Not detected; 1 - PS-X EXE; 2 - ELF
  end;
  PdecPSInfo = ^TdecPSInfo;

  TPS_CreateInfo = function(AFileName: PWideChar; out AInfo: PdecPSInfo): HRESULT; stdcall;
  TPS_DestroyInfo = procedure(AInfo: PdecPSInfo); stdcall;

function GetBootName(const AFileName: string): string;
var
  Dll: THandle;
  CreateInfo: TPS_CreateInfo;
  DestroyInfo: TPS_DestroyInfo;
  Info: PdecPSInfo;
begin
  Result := '';
  Dll := LoadLibrary('Path\Iso7z.32.dll');
  if Dll = 0 then Exit;

  @CreateInfo := GetProcAddress(Dll, 'PS_CreateInfo');
  @DestroyInfo := GetProcAddress(Dll, 'PS_DestroyInfo');
  if Assigned(CreateInfo) and Assigned(DestroyInfo) then
    begin
      if CreateInfo(PWideChar(AFileName), Info) = S_OK then
        begin
          Result := Info.BootName;
          DestroyInfo(Info);
        end;
    end;
  FreeLibrary(Dll);
end;
 

alec100_94

New member
Not really very familiar with delphi, I have attempted to write up roughly equivalent code in C# (which is what I'll ultimately be using) and it seems to give a zero (success) status code, but my info object doesn't have the values in it (not sure if I'm mapping the types correctly, or perhaps missing something else?).

C#:
using System;
using System.Runtime.InteropServices;

namespace PS2IdentTest
{
    class Program
    {
        [StructLayout(LayoutKind.Sequential)]
        struct Info
        {
            public uint Size;
            public string BootName, BootComment;
            public uint PEType;
        }

        [DllImport("Iso7z.64.dll", CharSet = CharSet.Unicode)]
        extern static int PS_CreateInfo(string fileName, out Info info);

        [DllImport("Iso7z.64.dll")]
        extern static int PS_DestroyInfo(Info info);

        static void Main()
        {
            var filename = Console.ReadLine().Replace("\"","");
            var createInfo = PS_CreateInfo(filename, out var info);
            if(createInfo == 0)
            {
                Console.WriteLine(info.BootName);
                PS_DestroyInfo(info);
            }
        }
    }
}
 

Dec

Administrator
Staff member
I know nothing about C# so cannot check your code. Not sure that "string BootName" is the same as "BootName: PWideChar". PWideChar is simple pointer to memory where name is saved.
 

alec100_94

New member
Figured it out, I was kind of close. The main issue was that I should have been passing a pointer to the function and casting back to the object instead of passing the raw object. Thanks again for all the help, that should be everything I need to carry on with my project (been stuck at this hurdle for a while).

C#:
using System;
using System.Runtime.InteropServices;

namespace PS2IdentTest
{
    class Program
    {
        [StructLayout(LayoutKind.Sequential)]
        struct Info
        {
            public uint Size;
            [MarshalAs(UnmanagedType.LPWStr)] public string BootName, BootComment;
            public uint PEType;
        }

        [DllImport("Iso7z.64.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
        extern static int PS_CreateInfo(string fileName, out IntPtr info);

        [DllImport("Iso7z.64.dll", CallingConvention = CallingConvention.StdCall)]
        extern static int PS_DestroyInfo(IntPtr info);

        static void Main()
        {
            var filename = Console.ReadLine().Replace("\"","");
            var createInfo = PS_CreateInfo(filename, out var infoPtr);
            if(createInfo == 0)
            {
                var info = Marshal.PtrToStructure<Info>(infoPtr);
                Console.WriteLine(info.BootName);
                PS_DestroyInfo(infoPtr);
            }
        }
    }
}
 

alec100_94

New member
This has been working great so far but I have managed to find one disc image that it failed to identify, I don't see any obvious difference between it and the rest.
1594676330527.png
 

Dec

Administrator
Staff member
Are you sure this is valid image? The content of SYSTEM.CNF looks very strange:

Untitled.png

That why the plugin cannot detect correct boot file. Maybe the plugin incorrectly converts this cso into iso. You can convert this cso into iso with any external tool and compare results.

PS. What about
Am also more than happy to purchase TC4Shell
 
Top