pyUE4Parse icon indicating copy to clipboard operation
pyUE4Parse copied to clipboard

Can't extract string literals from .uasset/.uexp files

Open UserUnknownFactor opened this issue 1 year ago • 4 comments

I try to extract strings from an asset files but only some show in the resulting dumps while many of them don't. For example string with Key 419719443B6B978C3A4D6B35AC51928 in the attached dump is nowhere to be seen. Is it a parsing bug or am I doing it wrong?

Here's the code and the sample files I used:

from UE4Parse.Assets.PackageReader import LegacyPackageReader
from UE4Parse.Provider import DefaultFileProvider
from UE4Parse.Versions import EUEVersion, VersionContainer
from UE4Parse.BinaryReader import BinaryStream

import os, json
path0 = r"FilePath.uasset" 
path1 = r"FilePath.uexp" 

provider = DefaultFileProvider(os.path.dirname(path0), VersionContainer(EUEVersion.LATEST))
provider.initialize()
pack = LegacyPackageReader(BinaryStream(path0), BinaryStream(path1), provider=provider)
if pack is not None:
    package_dict = pack.get_dict()
    with open(path0 + ".txt", "w", encoding="utf-8") as f:
        f.write(json.dumps(package_dict, ensure_ascii=False, indent=4))

UserUnknownFactor avatar Aug 05 '23 19:08 UserUnknownFactor

how do you know that string is there in the asset?

MinshuG avatar Aug 07 '23 12:08 MinshuG

@MinshuG: by using binary search of its UTF-16 bytes. Both the Key field and the corresponding text present in the .uexp file if you look at its binary dump in ASCII/UTF-16 mode.

UserUnknownFactor avatar Aug 07 '23 14:08 UserUnknownFactor

offset?

MinshuG avatar Aug 12 '23 15:08 MinshuG

0x4C1C in .uexp

UserUnknownFactor avatar Aug 16 '23 09:08 UserUnknownFactor