x
This website is using cookies. We use cookies to ensure that we give you the best experience on our website. More info. That's Fine
HPC:Factor Logo 
 
Latest Forum Activity

wcecabinfo - Tool to extract info from cab files

1 2 3 4
Karpour Page Icon Posted 2022-01-17 8:46 PM
#
Avatar image of Karpour
Subscribers
H/PC Philosopher

Posts:
439
Location:
Austria
Status:
Voila! here's some example output

I pieced together the formatting of .reg files by making exports myself. Luckily 000 files can only contain 4 types of data types, SZ, MULTI_SZ, DWORD and BINARY

$ ./wcecabinfo -r ./HPCPRO~1.000

REGEDIT4 

[HKEY_CLASSES_ROOT\ieceimage\Shell\Open\Command]
@="%InstallDir%\Image Expert CE.exe %1"

[HKEY_CLASSES_ROOT\ieceimage\DefaultIcon]
@="%InstallDir%\Image Expert CE.exe,-133"

[HKEY_CLASSES_ROOT\.jpg]
@="ieceimage"

[HKEY_CLASSES_ROOT\.jpeg]
@="ieceimage"

[HKEY_CURRENT_USER\Software\Sierra Imaging\Image Expert CE]
@="Image Expert CE"

[HKEY_CURRENT_USER\Software\Sierra Imaging\Image Expert CE\Install]
"Init"=dword:00000000
"UseSysParams"=dword:00000001
"Dev"="HP, Jornada;HP,Jornada"
"oemdemo"=dword:00000001

[HKEY_CURRENT_USER\Software\Sierra Imaging\Image Expert CE\State]
"Path"="My Documents\images\Samples"
 Top of the page
C:Amie Page Icon Posted 2022-01-17 9:11 PM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
17,983
Location:
United Kingdom
Status:
Most excellent. Great job!
 Top of the page
Karpour Page Icon Posted 2022-01-18 3:26 PM
#
Avatar image of Karpour
Subscribers
H/PC Philosopher

Posts:
439
Location:
Austria
Status:
Almost ready for release!

JSON output looks like this (this .000 file doesn't create links, so no links entries), only thing left to do is add formatting for DWORD and hex reg keys in JSON mode.

For convenience you can also directly feed the program .cab files, in this case it will need to have cabextract installed since it uses it to get the .000 file

{ 
        "appName":      "Contact App Addin Dialer", 
"provider": "Microsoft",
"architecture": "MIPS",
"unsupported": ["PALM PC"],
"minCeVersion": {
"minCeVersionMajor": 2,
"minCeVersionMinor": 0,
"minCeVersionString": "2.0"
},
"maxCeVersion": {
"maxCeVersionMajor": 2,
"maxCeVersionMinor": 1,
"maxCeVersionString": "2.1"
},
"directories": [{
"id": 2,
"path": "%CE3%"
}, {
"id": 3,
"path": "%CE2%"
}, {
"id": 1,
"path": "%CE2%"
}],
"files": [{
"id": 1,
"name": "dialer.dll",
"directory": "%CE2%"
}, {
"id": 2,
"name": "dtmf.dll",
"directory": "%CE2%"
}, {
"id": 3,
"name": "dtmf11.dll",
"directory": "%CE2%"
}, {
"id": 4,
"name": "dtmf22.dll",
"directory": "%CE2%"
}],
"registryEntries": [{
"path": "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\PowerToys\\Dialer",
"name": "Version",
"dataType": "REG_DWORD",
"value": "\u0001"
}, {
"path": "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\PimApps\\PimExtensions\\Contacts\\Addins\\Dialer",
"name": "Menu",
"dataType": "REG_SZ",
"value": "&Dial"
}, {
"path": "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\PimApps\\PimExtensions\\Contacts\\Addins\\Dialer",
"name": "Dll",
"dataType": "REG_SZ",
"value": "dialer.dll"
}],
"links": []
}
 Top of the page
Karpour Page Icon Posted 2022-01-19 8:51 PM
#
Avatar image of Karpour
Subscribers
H/PC Philosopher

Posts:
439
Location:
Austria
Status:
I'm happy to announce that I created a release for everyone to try!

The Windows build is here: https://github.com/HPC-Factor/windows-ce-cab-info/releases/download/v0.9.0/wcecabinfo.exe
If you need a Linux build and can't do it yourself please lmk!

Please test it with various cab files and let me know if you find any bugs!

For usage instructions, please refer to the readme file here: https://github.com/HPC-Factor/windows-ce-cab-info/blob/main/README.md

Or type

wcecabinfo.exe -h


[EDIT]

Well now there's an issue! While I can cross-compile for Windows, cabextract isn't available as a native windows build. only for cygwin. I can probably substitute this for 7-zip.

What this means is that for now, this application (on Windows) will only work with .000 files, not .cab files, so you need to extract them first using 7zip or another program that can extract cabs.

Edited by Karpour 2022-01-19 9:27 PM
 Top of the page
C:Amie Page Icon Posted 2022-01-19 10:32 PM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
17,983
Location:
United Kingdom
Status:
There are third party libs you can use to stub it into the executable e.g.
https://www.codeproject.com/Articles/15397/Cabinet-File-CAB-Compression-and-Extraction

or there is (the horror of) good old win32:
https://docs.microsoft.com/en-us/windows/win32/devnotes/extracting-files-from-a-cabinet

Though I'm sure it's cleaner to make an external call to the shell to have an exec do it for you.
 Top of the page
Karpour Page Icon Posted 2022-01-20 12:59 AM
#
Avatar image of Karpour
Subscribers
H/PC Philosopher

Posts:
439
Location:
Austria
Status:
Success! I have now made a Windows build that uses 7zip

Also, 1 hour lost because I had to find out the hard way that you have to set file input streams to binary mode first.

Instructions

Download the binary:
https://github.com/HPC-Factor/windows-ce-cab-info/releases/download/v0.9.0/wcecabinfo.exe

Make sure 7-Zip is installed:
https://www.7-zip.org/

Add the directory that contains 7z.exe (probably C:\Program Files\7-Zip) to your PATH environment variable, here's a guide if you need one

Open the Command prompt, go to where wcecabinfo.exe is and try it on some cabs

wcecabinfo.exe cabfile.CAB

To get registry output:

wcecabinfo.exe -r cabfile.CAB


To get JSON output:

wcecabinfo.exe -j cabfile.CAB


Edited by Karpour 2022-01-20 1:09 AM
 Top of the page
Karpour Page Icon Posted 2022-01-20 8:36 PM
#
Avatar image of Karpour
Subscribers
H/PC Philosopher

Posts:
439
Location:
Austria
Status:
Interesting find! I tried compiling cabextract with mingw64 and it compiles just fine!
Makes me wonder why there are loads of builds available on the cabextract site, but no windows one.

This means that I can use cabextract both on linux and Windows as a way of extracting the .000 files, and possibly even completely do away with the external dependency and include libmspack, which cabextract uses under the hood.
 Top of the page
C:Amie Page Icon Posted 2022-01-20 9:27 PM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
17,983
Location:
United Kingdom
Status:
Why don't you fork a win32 build onto the GitHub? Sounds like a worthy find!
 Top of the page
Karpour Page Icon Posted 2022-01-23 3:43 PM
#
Avatar image of Karpour
Subscribers
H/PC Philosopher

Posts:
439
Location:
Austria
Status:
Well, no need to fork, the regular build builds fine! What we could do is put a win32 build into the SCL though!

In other news, I refactored my program a bit based on recommendations of other people (though to be 100% portable, apparently I can't just map structs into memory regions, oops!)

There's one big annoying issue though: Character encodings.

I ran wcecabinfo on hundreds of cabs, and with a few the output fails because they're Japanese and rather than ASCII, use Shift-IJS for encoding strings.
Ok, easy enough, I could check for each string whether it's using extended ASCII codes and then use iconv to convert it to from SIJS to UTF-8.. But I assume that these strings can also come in Cyrillic, Chinese, etc.
And there is absolutely no flag in the CAB header that would indicate what kind of encoding the strings are in.

If anyone would have pointer as so what kind of different encodings might be used, that would be appreciated!

For now I can set it manually, so the garbled mess:

appName: ???i???????

is output as proper UTF-8:

appName: ??????????

[EDIT] TIL I can't use UTF-8 in CODE blocks in here
[More edit] Apparently also not outside of codeblocks? Any japanese UTF-8 character just gets converted to '?'

Edited by Karpour 2022-01-23 3:46 PM
 Top of the page
stingraze Page Icon Posted 2022-01-24 7:42 AM
#
Avatar image of stingraze
Subscribers
H/PC Vanguard

Posts:
3,679
Location:
Japan
Status:
Yep, Japanese string doesn't get displayed here on the forum, I can verify that.
 Top of the page
C:Amie Page Icon Posted 2022-01-24 10:56 AM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
17,983
Location:
United Kingdom
Status:
I just changed the site encoding from ISO-8859-1 to UTF-8 to see what would happen and it still rendered as ??????????

?????????????????!

Must be the back-end

Edit: It's the database. It's running in SQL_Latin1_General_CP1_CI_AS
 Top of the page
C:Amie Page Icon Posted 2022-03-16 10:28 AM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
17,983
Location:
United Kingdom
Status:
@Karpour,

I got to have a play with it finally. Great work here once again. I do not seem to be able to script it however. All I get back from StdErr is
Input file argument provided while not in a TTY

It runs fine manually from CMD, but will not exec via WScript either stand-alone.

"C:\wcecabinfo.exe" --verbose "{Path}"


Or via a sub-process of a shell:

c:\windows\system32\cmd.exe /c "C:\wcecabinfo.exe" --verbose "{Path}"


Both result in the same error. Any thoughts?

Edit: It does the same if sending it to PowerShell too
 Top of the page
C:Amie Page Icon Posted 2022-03-17 10:26 AM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
17,983
Location:
United Kingdom
Status:
Update: It does it if I feed it .000 files, so it's not 7-zip related. Same if I pipe in a file stream.

I am not quite sure where the error is coming in from though, I couldn't find the string in the MINGW source.
 Top of the page
Karpour Page Icon Posted 2022-03-17 12:10 PM
#
Avatar image of Karpour
Subscribers
H/PC Philosopher

Posts:
439
Location:
Austria
Status:
I think this is due to some code that tries to detect whether it runs in a TTY or whether input is piped in. I think this doesn't really work on Windows (since you can't pipe stuff there anyway)

I'll make it in a way that piped input is disabled by default and can be enabled explicitly with a flag!
 Top of the page
C:Amie Page Icon Posted 2022-03-17 12:32 PM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
17,983
Location:
United Kingdom
Status:
Thanks. Of just set a compiler def to disable it completely on WIN32? Hopefully you won't have to mess with the working POSIX version.
 Top of the page
1 2 3 4
Jump to forum:
Seconds to generate: 0.203 - Cached queries : 73 - Executed queries : 8