Giter VIP home page Giter VIP logo

Comments (3)

Helyos96 avatar Helyos96 commented on July 29, 2024

Nevermind, I hadn't looked close enough at the PPtr class and borrowed code from there to resolve an object from file_id+path_id.

from unitypy.

K0lb3 avatar K0lb3 commented on July 29, 2024

I'm not sure if you already figured it out completely or not,
so I will simply explain some points.

The objects are stored inside of the SerializedFiles, which in turn are usually stored within BundleFiles.
The path_id is the unique identifier of an object within a SerializedFile. In BundleFiles with multiple SerializedFiles it can happen, that multiple of those SerializesFiles use the same path_id, but each for different objects.
So to find a specific object via the path_id you will also have to know the name of its SerializedFile.
Then you can simply search through env.files..files until you reach a SerializedFIle and then check its name and if it contains an object with the specific id.

The pointers themself usually only refer to objects within the same SerializedFile as the object that uses them.
If this isn't the case, then the reference uses the external list of the parent(SerializedFile) of the object and find the specified SerializedFile that way.

from unitypy.

Helyos96 avatar Helyos96 commented on July 29, 2024

Thanks for the additional info! What I ended up doing is something like this:

def get_obj_pptr(env, objref, file_id : int, path_id : int):
	if path_id == 0:
		return None

	manager = None
	if file_id == 0:
		manager = objref.assets_file
	elif file_id > 0 and file_id - 1 < len(objref.assets_file.externals):
		external_name = objref.assets_file.externals[file_id - 1].name
		parent = objref.assets_file.parent
		if parent is not None:
			if external_name not in parent.files:
				external_name = external_name.upper()
			if external_name in parent.files:
				manager = parent.files[external_name]
		else:
			if external_name not in env.files:
				typ, reader = ImportHelper.check_file_type(external_name)
				if typ == FileType.AssetsFile:
					env.files[external_name] = files.SerializedFile(reader)
			if external_name in env.files:
				manager = env.files[external_name]

	if manager and path_id in manager.objects:
		return manager.objects[path_id]
	return None

So pretty much what the PPtr class does but from a setting outside of UnityPy.

from unitypy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.