Important information: this site is currently scheduled to go offline indefinitely by end of the year.

Deer Hunter Tournament....

The Original Forum. Game archives, full of resources. How to open them? Get help here.
User avatar
aluigi
VVIP member
VVIP member
Posts: 1916
Joined: Thu Dec 08, 2005 12:26 pm
Location: www.ZENHAX.com
Has thanked: 4 times
Been thanked: 664 times
Contact:

Re: Deer Hunter Tournament....

Post by aluigi »

well done bacter.
I have updated my dh2005 script adding a simple scanner for finding the right key of the 4 available (2005, demo, custom and tournament).

so I guess that the only problem remains in those shaders.spk archives of DHT but I don't have one of them at the moment so I can't verify them
bacter
veteran
Posts: 142
Joined: Mon Feb 22, 2010 8:42 pm
Has thanked: 2 times
Been thanked: 83 times

Re: Deer Hunter Tournament....

Post by bacter »

Tip: Try to check the Size and the CRC32 of the Entries:
IF STOREDSIZE=0 AND CRC32=0 ---> good entry, file with zero size
IF STOREDSIZE=0 AND CRC32<>0 ---> BAD ENTRY

Example bad entries from DHT:
(storedsize#flag#originalsize#crc32#unknown#filename)
Data.Shaders.Win32.v1.spk:
00000000#08#00000000#ED030B6F#16CA0B40#fxdata\_def_glossiness.png
00000000#08#00000000#81B267A3#16CA0B40#fxdata\_def_heatgradient.png
00000000#08#00000000#618B2EA4#16CA0B40#fxdata\_def_noise.png

Data.Shaders.Win32.v2.spk:
00000000#08#00000000#ED030B6F#16B697E0#fxdata\_def_glossiness.png
00000000#08#00000000#81B267A3#16C1DC60#fxdata\_def_heatgradient.png
00000000#08#00000000#618B2EA4#16B697E0#fxdata\_def_noise.png



O.K. Here's every important information I collected about the .SPK files:
There are 3 different versions of SPK files, so first always check the Header's version number! (They use different Header size, and different Entry sizes!!!)

If 1 or 2, then no problem, but the 3 contains some more trick, the decoding needs a MASTER_KEY, which is game-dependant. These MASTER_KEYS are derived from some passwords:

Deer Hunter Tournament: (I didn't find demo version of the game, so this is for the full version)
MASTER_KEY=0x48C20726 comes from this: "winmm.lib!ddraw.lib"

Deer Hunter 2005 FULL:
MASTER_KEY=0x32E105A4 comes from this: "dh2005.exe;d3d.dll"

Deer Hunter 2005 DEMO:
MASTER_KEY=0x3CB80690 comes from this: "d3dx.lib;ddraw.dll"

DeerHunter 2005 custom level:
MASTER_KEY=0x18D9042F comes from this: "dh2005custom"

Trophy Hunter 2003 + Deer Hunter 2004 use the v1 or v2 format, so they don't need password or MASTER_KEY

Code: Select all

The .SPK file starts with this header:

Type DeerHuntTour_SPK_HeaderType = Packed Record // 12 or 13 bytes!
       APK_ID : Array[0..2] Of char; // 'APK'
       VersionByte : byte; // (1,2 or 3)
       DirStartPos : dword; // points to the end of the file
       DirOrigSize : dword; // the original, unpacked size of the directory data
       // ----------------------------
       // This, last byte is only if the VersionByte = 3 !!!!!
       MoreCryptFlag : boolean; // 1 byte! Indicates more encryption!
     End;

The file information data is compressed (with zlib) and encrypted.
So first we need do decrypt:
If version=1 or 2 then:
  DeerHunter_Encrypt(Buffer,Hdr.DirStartPos * Hdr.DirOrigSize,FALSE);

If version=3 then:
  you can generate the MASTER_KEY, from the appropriate password:
  MASTER_KEY := DeerHunter_GenerateMasterKey('... place of the password...');
  and then:
  DeerHunter_Encrypt(Buffer,MASTER_KEY Xor Hdr.DirStartPos Xor Hdr.DirOrigSize,Hdr.MoreCryptFlagByte);

If everything is OK, the decoded buffer now contains zlib compressed data.
Unpack it. The unpacked data size must be equal to the value of Hdr.DirOrigSize

Now we can process the Entries (repeat until the end of the buffer):

Type DeerHuntTour_SPK_EntryType = Packed Record
       Name : Array Of char;  // The filename, with a terminating zero character
       StartPos  : dword;     // start of the file data
       StoredSize  : dword;   // the stored size (the compressed size, if compression used, otherwise the original size)
       FlagsByte : byte;      // 00 = stored
                              // 01 = encrypted
                              // 02 = zlib_compressed
                              // 03 = zlib_compressed+encrypted
       OriginalSize  : dword; // the original size
       CRC32  : dword;        // the crc32 value of the original file
       //-----------------------------
       // This, last dword is only if the VersionByte = 2 OR 3 !!!!!
       unknown  : dword;      // absolutely unknown value
     End;

If the file data is encypted ( (Entry.FlagsByte AND 1) = 1) then use the same decryption method as above:
If version=1 or 2 then:
  DeerHunter_Encrypt(DataBuffer,(Entry.OriginalSize * Entry.StartPos) Xor Entry.CRC32  );

If version=3 then:
  // we generated the MASTER_KEY, so we can use it again:
  DeerHunter_Encrypt(DataBuffer,MASTERKEY Xor Entry.OriginalSize Xor Entry.StartPos Xor Entry.CRC32,Header.MoreCryptFlagByte);


Function DeerHunter_GenerateMasterKey(MasterKeyPhrase : PChar) : dword;
// source: Deniz Özmen   http://oezmen.eu/gameresources/
Var I, Temp : dword;
    MasterKey : dword;
Begin {Function DeerHunter_GenerateMasterKey}
  MasterKey := 1;
  For I := 0 To StrLen(MasterKeyPhrase) - 1 Do
    Begin
      Temp := (MasterKey And $0000ffff + Ord(MasterKeyPhrase[I])) Mod $0000fff1;
      Asm
        push ebx
        mov  eax, MasterKey
        sar  eax, 16
        mov  ebx, Temp
        add  eax, ebx
        mov  ecx, $0000fff1
        cdq
        idiv ecx
        shl  edx, 16
        add  edx, ebx
        mov  MasterKey, edx
        pop  ebx
      End;
    End;
  Result := MasterKey;
End;  {Function DeerHunter_GenerateMasterKey}

Procedure DeerHunter_Encrypt(Var Buffer : TArrayOfByte;
                           Key : dword;
                           AdditionalKeyRound : Boolean);
// source: Deniz Özmen   http://oezmen.eu/gameresources/
Var I: Integer;
Begin  {Procedure DeerHunter_Encrypt}
  If AdditionalKeyRound Then // THIS CAN BE ONLY IF THE VERSION=3, OTHERWISE WE SKIP THIS!
    Asm
      mov eax, Key
      mov ecx, Key
      and eax, $0000ffff
      mov edx, $00006054
      mul edx
      sar ecx, 16
      add eax, ecx
      mov Key, eax
    End;

  For I := 0 to High(Buffer) do  // = Length(Buffer) - 1  !!!
    Begin
      Asm
        mov eax, Key
        mov ecx, Key
        and eax, $0000ffff
        mov edx, $00006054
        mul edx
        sar ecx, 16
        add eax, ecx
        mov Key, eax
      End;
      Buffer[I] := Buffer[I] Xor Key;
    End;
End;   {Procedure DeerHunter_Encrypt} 
Unforgiven
n00b
Posts: 12
Joined: Fri Oct 01, 2010 12:23 am

Re: Deer Hunter Tournament....

Post by Unforgiven »

still a no go on packing the resources
Data/Animals which would be Data.009
Data/Globals which would be Data.010
DataInterface which would be Data.011
Data/Weapons which would be Data.012


http://www.deerhunterpatches.com/images/allinone.jpg

Devrim wont share his program and will only let us have it for 50.00 usd he said because of all the new things that will be in dh2004 and dh2005 and his works he saud he used luigi's script for unpacking and denniz's script for packin ive tried everything and nothin happens

DHT is a whole new story we will have to find a s3d imorter/exporter for new models
Unforgiven
n00b
Posts: 12
Joined: Fri Oct 01, 2010 12:23 am

Re: Deer Hunter Tournament....

Post by Unforgiven »

it all works 100% i figured it out

would ya rather have forum name or real name in credits ?
bacter
veteran
Posts: 142
Joined: Mon Feb 22, 2010 8:42 pm
Has thanked: 2 times
Been thanked: 83 times

Re: Deer Hunter Tournament....

Post by bacter »

I updated my program. Little cosmetic changes: If you open or extract a SPK file, the list jumps to the correct game version.

Unforgiven:
#1: What was the solution?
#2: You can mention my forum name (bacter) in your credits if you want.
Last edited by bacter on Thu Jun 23, 2011 6:30 pm, edited 1 time in total.
Unforgiven
n00b
Posts: 12
Joined: Fri Oct 01, 2010 12:23 am

Re: Deer Hunter Tournament....

Post by Unforgiven »

it was simple actually

i was tryin to pack the edited files within the game directory which would pack but wouldnt load up in game.
so them i figured ive tried everything there is so why not try this ( this was the solution)

Right clicked on Desktop created new folder, renamed the folder Game
then inside the game folder i created a data folder

put all of our work inside of it and packed it with ur deer hunter util and it works flawlessy on all games
bacter
veteran
Posts: 142
Joined: Mon Feb 22, 2010 8:42 pm
Has thanked: 2 times
Been thanked: 83 times

Re: Deer Hunter Tournament....

Post by bacter »

aluigi!
Now I solved the script problem with the "Data.Shaders.Win32.v1.spk" and "Data.Shaders.Win32.v2.spk"!
Your script, line 31-32, when you allocate some memory for the dir table decompression:
set OUT_INFO_SIZE long INFO_SIZE
math OUT_INFO_SIZE *= 8 # more than enough

file1: 26,656*8 = 213,248 -> but we need: 228,780
file2: 27,222*8 = 217,776 -> but we need: 228,780

So, we need some more memory, for example:
math OUT_INFO_SIZE *= 10
or, the simple and elegant way (because the header contains the uncompressed size):
set OUT_INFO_SIZE long CRYPT_INIT
User avatar
aluigi
VVIP member
VVIP member
Posts: 1916
Joined: Thu Dec 08, 2005 12:26 pm
Location: www.ZENHAX.com
Has thanked: 4 times
Been thanked: 664 times
Contact:

Re: Deer Hunter Tournament....

Post by aluigi »

corrected, thanx bacter :)
deve
n00b
Posts: 15
Joined: Wed Apr 22, 2009 9:56 am

Re: Deer Hunter Tournament....

Post by deve »

the tool works but have somebugs, like when you pack dh04 files or sometimes it just doesnt pack says only "error:("

anyway I have a question about , dh05 when the data.001 is packed and I make new changes and pack it us data.002 the game reads only the data.001 and not other data.00x , how can we fix this ?
Post Reply