MinshuG / pyUE4Parse

ue4 asset parser/reader
MIT License
47 stars 15 forks source link

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

Open UserUnknownFactor opened 1 year ago

UserUnknownFactor commented 1 year ago

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))
MinshuG commented 1 year ago

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

UserUnknownFactor commented 1 year ago

@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.

MinshuG commented 1 year ago

offset?

UserUnknownFactor commented 1 year ago

0x4C1C in .uexp