Skip to content

hashes are not correct #20

@kazonix

Description

@kazonix

When decompiling a Cold War LUA, the hashes are read and shortened incorrectly. The first issue is that the high and low bytes are read the wrong way round, as seen in LuaJitFunctionBOCW.cs:

        {
            var lo = Reader.ReadULEB128();
            var hi = Reader.ReadULEB128();

when it should be:

        {
            var hi = Reader.ReadULEB128();
            var lo = Reader.ReadULEB128();

The second issue is that hashes are shortened one byte too short, as seen in LuaJitFunctionBOCW.cs and Constant.cs where there are only 15 Fs:
var hash = ((hi << 32) | lo) & 0xFFFFFFFFFFFFFFF;

case ValueType.Hash:
return $"0x{Hash & 0xFFFFFFFFFFFFFFF:X}";
when it should be:
var hash = ((hi << 32) | lo) & 0xFFFFFFFFFFFFFFFF;

case ValueType.Hash:
return $"0x{Hash & 0xFFFFFFFFFFFFFFFF:X}";
Once those fixes have been applied, hashes now show up correctly. The DVAR "lobbysearchpingband"'s hash is 3BD37C49236A4C70 and the decompiled output went from Dvar[0x36A4C703BD37C49] to Dvar[0x3BD37C49236A4C70].

So far I have only tested Cold War LUA files, and the issue might also happen to other game LUA files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions