uniref.platforms

This module holds the uniref top-level classes for all supported platforms

class uniref.platforms._UniRef
find_class_in_image(image_name: str, class_path: str) Optional[MonoClass]

Find the class in the image.

Probably the most commonly used method. This method looks up class reflection information through the given image name and class full path ([namespace].[class name]).

This method supports resolving the classpath shown in Cheat Engine. For inner classes, you can concatenate the class names by + or /.

Examples:

>>> ref.find_class_in_image("Assembly-CSharp", "PlayerStats")
<uniref.mono.component.MonoClass object at 0x0000022F53050CF8>
>>> ref.find_class_in_image("Assembly-CSharp", "Rewired.UI.ControlMapper.Window+Timer")
<uniref.mono.component.MonoClass object at 0x0000022F53050C50>
>>> ref.find_class_in_image("Assembly-CSharp", "MyClass") is None
True
Returns

MonoClass instance if class is found, else None.

find_field_in_class(klass: MonoClass, field_name: str) Optional[MonoField]

Find the field by its name.

Returns

MonoField instance if field is found, else None.

find_image_by_name(image_name: str) Optional[MonoImage]

Find the image by image name.

Returns

MonoImage instance if image is found, else None.

find_method_in_class(klass: MonoClass, method_name: str, param_count: int = -1) Optional[MonoMethod]

Find the method in the class.

If there are different overloads of a method in the same class, you can distinguish them by the number of parameters. This is what the param_count means.

Returns

MonoMethod instance if method is found, else None.

get_assembly_image(assembly: MonoAssembly) MonoImage

Get the image of the specified assembly.

property injector: WinMonoInjector

target process injector

list_assemblies() List[MonoAssembly]

List all assemblies in the application.

list_classes_in_image(image: MonoImage) List[MonoClass]

List all classes in the image.

list_fields_in_class(klass: MonoClass) List[MonoField]

List all fields in the class.

list_images() List[MonoImage]

List all images in the application.

list_methods_in_class(klass: MonoClass) List[MonoMethod]

List all methods in the class.

property mono_module_handle: int

target process mono / il2cpp module handle

property pid: int

target process id

property root_domain: int

target process root application domain

use_il2cpp() bool

Check if target process uses the IL2CPP scripting backend.

Returns

False if target process uses the Mono scripting backend, else True.

class uniref.platforms.AndroidUniRef(process_name: Optional[str] = None, package_name: Optional[str] = None, device_id: Optional[str] = None, spawn: bool = True)

Bases: _UniRef

The uniref top-level class for Android.

Parameters
  • process_name – the process name of the target application, you can get it by frida-ps

  • package_name – the package name of the target application

  • device_id – specify the device id, you can get it by adb devices

  • spawn – decide whether to create or attach a process when package_name is given, True by default

Examples:

# automatically attach the frontmost application & device
ref = AndroidUniRef()

# attach the application by its process name (automatically select device)
ref = AndroidUniRef(process_name="My App")

# spawn the application by its package name (automatically select device)
ref = AndroidUniRef(package_name="com.test.my_app")

# attach the application by its package name (automatically select device)
ref = AndroidUniRef(package_name="com.test.my_app", spawn=False)

# attach the application on the specified device
ref = AndroidUniRef(device_id="12a34b5")
ref = AndroidUniRef(process_name="My App", device_id="12a34b5")
ref = AndroidUniRef(package_name="com.test.my_app", device_id="12a34b5")
execute_js(js_code: str, on_message_callback: Optional[Callable] = None) frida.core.Script

inject javascript through Frida.

Parameters
  • js_code – javascript code

  • on_message_callback – callback in the form of on_message(message, data)

Returns

frida.core.Script instance

class uniref.platforms.WinUniRef(exe_filename: str = '', process_id: int = 0)

Bases: _UniRef

The uniref top-level class for Windows.

Parameters
  • exe_filename – target application exe filename

  • process_id – process id

Examples:

>>> ref = WinUniRef("TheForest.exe")
>>> ref = WinUniRef(process_id=1234)
property process_handle: int

target process handle