Elex

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
Lord Vaako
Posts: 26
Joined: Tue Oct 17, 2017 7:36 pm

Re: Elex

Post by Lord Vaako »

Thanks a lot NicoDE but could you elaborate a bit more how to calculate these hashes? Algorithm, etc.
hhrhhr
Posts: 36
Joined: Sun Jan 18, 2015 11:22 pm

Re: Elex

Post by hhrhhr »

djb2

Code: Select all

    unsigned long
    hash(unsigned char *str)
    {
        unsigned long hash = 5381;
        int c;

        while (c = *str++)
            hash = ((hash << 5) + hash) + c; /* hash * 33 + c */

        return hash;
    }


p.s.
Lua playground - https://www.lua.org/cgi-bin/demo
paste this:

Code: Select all

local str = {
"demo1",
"demo2",
"demo3"
}
local hash = 5381
for i = 1, #str do
    local s = str[i]
    for j = 1, #s do
        hash = (((hash << 5) + hash) + s:byte(i)) & 0xffffffff
    end
    print(("[0x%08X] = '%s'"):format(hash, s))
end

and run :)
Lord Vaako
Posts: 26
Joined: Tue Oct 17, 2017 7:36 pm

Re: Elex

Post by Lord Vaako »

it's not my day :/

Code: Select all

local str = {
"FO_It_Misc_BartoxHead_Arx",
"ITEMDESC_It_Misc_BartoxHead_Arx",
"fo_it_misc_bartoxhead_arx",
"itemdesc_it_misc_bartoxhead_arx",
}
local hash = 5381
for i = 1, #str do
    local s = str[i]
    for j = 1, #s do
        hash = (((hash << 5) + hash) + s:byte(i)) & 0xffffffff
    end
    print(("[0x%08X] = '%s'"):format(hash, s))
end


gives

Code: Select all

[0x1B7B1C7B] = 'FO_It_Misc_BartoxHead_Arx'
[0x009A71C7] = 'ITEMDESC_It_Misc_BartoxHead_Arx'
[0x9AD3D36E] = 'fo_it_misc_bartoxhead_arx'
[0xA7362E81] = 'itemdesc_it_misc_bartoxhead_arx'


and I was expecting:

b430f5ac
9affe4a5

What am I doing wrong? :(
NicoDE
Posts: 10
Joined: Fri Oct 20, 2017 9:53 am

Re: Elex

Post by NicoDE »

Lord Vaako wrote:What am I doing wrong? :(

Nothing, the code is buggy :)
(the hash has to be reset/initialized for every string and the character index is j, not i)

Code: Select all

local str = {
  "fo_it_misc_bartoxhead_arx",
  "item_it_misc_bartoxhead_arx",
  "itemdesc_it_misc_bartoxhead_arx"
}
for i = 1, #str do
  local s = str[i]
  local h = 5381
  for j = 1, #s do
    local c = s:byte(j)
    h = (((h << 5) + h) + c) & 0xffffffff
  end
  print(("[0x%08x] = '%s'"):format(h, s))
end
hhrhhr
Posts: 36
Joined: Sun Jan 18, 2015 11:22 pm

Re: Elex

Post by hhrhhr »

NicoDE wrote:code is buggy

:oops: :oops: :oops:

p.s.
to justify add one more patch so that you do not manually lowercase it:

Code: Select all

- local s = str[i]
+ local s = str[i]:lower()


2NicoDE:
can you see what's wrong with the localization file? r3l10n.exe w_strings.bin, ID 0x79cc7643 have something wrong:
Image
NicoDE
Posts: 10
Joined: Fri Oct 20, 2017 9:53 am

Re: Elex

Post by NicoDE »

hhrhhr wrote:can you see what's wrong with the localization file?

Maybe it's an error in the localization file (I expect the CSV line to be longer than ~16K characters and the engine's string table compiler might have problems with it).
Try to find Kral's second diary in the game, switch to Russian text in the config, and have a look at it in the game...

ps: there is another entry (0xd2881298) that is broken after ~16K characters (only patch 1.1, in Czech_Text entry)
pps: the identifier for the hash 79cc7643 is "LETTER_WEIDMANNX6_2015-04-01_12-56-20_00", referenced in It_Wri_Book_KralsSecondDiary
Lord Vaako
Posts: 26
Joined: Tue Oct 17, 2017 7:36 pm

Re: Elex

Post by Lord Vaako »

Thnx for your help :-)
Lord Vaako
Posts: 26
Joined: Tue Oct 17, 2017 7:36 pm

Re: Elex

Post by Lord Vaako »

Right now I'm looking for Elex icons, etc :-)
I'm almost sure they are inside attached file but I don't know how to open this file.
It looks like some kind of flash file but I'm not able to open it with any of my tools, for example JPEXS Flash Decompiler - can't find swf file header.
So I'm looking for some hints how to open/convert it :-)
mirage
Posts: 1
Joined: Sun Oct 29, 2017 1:39 pm

Re: Elex

Post by mirage »

Try to unpack it with Lua utils for ELEX
https://github.com/hhrhhr/LuaELEX

As I see there, author unpack resourses from game, and make interactive game map
Also he can unpack .rom files
hhrhhr
Posts: 36
Joined: Sun Jan 18, 2015 11:22 pm

Re: Elex

Post by hhrhhr »

i can inspect, not unpack ;) these files (.rom-files with GAR5 magic) are mostly containers, not archives.

if this file of icons is called w_fll_0_na_7c98572e.rom, then I still did not understand its format.
ponaromixxx
Posts: 176
Joined: Tue Sep 30, 2014 5:59 pm

Re: Elex

Post by ponaromixxx »

hhrhhr wrote:i can inspect, not unpack ;) these files (.rom-files with GAR5 magic) are mostly containers, not archives.

if this file of icons is called w_fll_0_na_7c98572e.rom, then I still did not understand its format.


rom audio tools ????
Lord Vaako
Posts: 26
Joined: Tue Oct 17, 2017 7:36 pm

Re: Elex

Post by Lord Vaako »

hhrhhr wrote:i can inspect, not unpack ;) these files (.rom-files with GAR5 magic) are mostly containers, not archives.

if this file of icons is called w_fll_0_na_7c98572e.rom, then I still did not understand its format.


1. yup, this is the file with unknown "inner" header and format :(

2. As I can see in your scripts, you look for weapons, etc. but I don't see any of them on your map. do you know why you couldn't find any? :-)
hhrhhr
Posts: 36
Joined: Sun Jan 18, 2015 11:22 pm

Re: Elex

Post by hhrhhr »

weapons, etc, there are too many for one small map ;) now on the map about 600 points. on two or three thousand the map starts to slow down even on not the weakest computer, and I found nearly 14 thousand of all freely lying objects...

need to rework the display algorithm, use clusters of objects, but there is simply no time for this. especially since there is already such a map — https://elex-map.eu
NicoDE
Posts: 10
Joined: Fri Oct 20, 2017 9:53 am

Re: Elex

Post by NicoDE »

The Risen 3 string table [un]packer can be used for Elex, but note that:
  • the STB file version has been changed from 6 to 7 with a patch
  • there is no identifier hash map for Elex, yet (ask Piranha Bytes or create one)

see viewtopic.php?p=32088#p32088