Sorry i can't make C# code for this, which is exactly my question.

Can you give me C# code that reads the THF file and prints the same as the 
screenshot ?

--
Lisa



31 jul 2024 23:03 van freedos-devel@lists.sourceforge.net:

>
> Hi Lisa!
>
>> I need a C# program that can read the THF file: it must just tell me the 
>> information of the screenshot
>>
>> Here you find the needed files and all source code, including screenshot 
>> (see last post)
>>
>> https://csharpforums.net/threads/read-bytes-from-binary-file.9764/page-2#post-40107
>>
>> I already have all decryption functions in C# working!
>>
>
> Sounds like you will already figure it out yourself :-)
>
>> There is no forum or anything where a living soul still can read this code :)
>> You're reading this problably one of my last hope out there
>>
>
> I suggest to ask more specific questions about specific code snippets,
> because you can find most of the solution without help, I believe.
>
> https://gitlab.com/twilight-cd.com/sourcecode-menu-twilight-9
>
>> I want to make C# code that takes a THF file and extracts all TVF and ZIP 
>> files from it
>>
>
> You probably have questions about THF.C, THF.H and THFTOOL.C?
> THF seems to be an archive format with TVF docs and ZIP blobs
> inside. You write that you already know how to open the ZIPs.
>
> According to THF.H, the structure of THF is relatively simple:
>
> https://stackoverflow.com/questions/71270954/how-to-properly-use-typedef-for-structs-in-c
>
> https://en.cppreference.com/w/c/language/struct
>
> The THF.H comments do not fully match THF.C, so:
>
> 4 bytes ID string
> 16-bit int (actually 2 bytes) version (of file format)
> 256 padding bytes (or rather 256-6 bytes, see THF.C!)
>
> 1 byte of "add"
> 64 bytes of key (more likely 64-1 bytes, see THF.C!)
> ("add" and "key" are scrambled, see thfOpenMainFile, a
> loop does "subtract 82, then xor by 108" for each byte)
>
> content is here, followed by a directory of 1 or more [items]:
>
> [
> 13 bytes of file name (probably 12345678.abc plus a NULL byte)
> 32-bit long int offset (of content in THF, I guess)
> 32-bit long int size (of content)
> ]
> (each [item] is scrambled by xor with a string, see THF.C)
>
> and finally:
>
> 32-bit long int offset where the directory starts
> (scrambled with xor 0x2b46c748 according to THF.C)
> 16-bit int number of directory items (not according to THF.H)
> (scrambled with xor 0x2b46 according to THF.C)
>
> So you have to read the LAST 6 (or 4?) bytes of the THF files to
> know where the directory entries start and then each entry tells
> you where in the THF you will find how many bytes of content for
> one embedded file, for which also some file name is known. There
> are no details about timestamps of the embedded files and there
> are no subdirectories inside the THF. Pretty straightforward?
>
> This is more or less what thfOpenMainFile and thfReadDirectory
> are doing. Note that there is some descrambling added by THF.C!
>
> The THFTOOL.C just wraps everything into some more or less
> user-friendly command line tool, with wildcard matching.
>
> For your project, you can probably ignore it (apart from some
> small 0x3c 0xb1 0x43 trick thing) and only read THF.C, which
> implements a number of basic functions to read from THF files.
>
> You say you already figured out the other obfuscation code,
> so you apparently have already translated parts of THF.C :-)
>
> I suggest to print intermediate results and add plausibility
> checks, to avoid crashes if you made mistakes in descrambling
> and end up with offsets or sizes which do not make sense.
>
> Cheers, Eric
>
> PS: THF.C and THFTOOL.C probably crash if a THF contains or
> claims to contain more than 200 embedded files :-p
>
>
>
>
> _______________________________________________
> Freedos-devel mailing list
> Freedos-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/freedos-devel
>
_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to