Skip to content

(Feature Request) Unreal: Listing or iterating through all fields In a UObject #113

@PARTYMANX

Description

@PARTYMANX

While working on the THPS 1+2/3+4 autosplitter, when starting to adopt UObject field names to find offsets (and more directly, #112), but found it difficult to actually figure out what I was looking for. It was useful to modify the asr crate to list all fields in a given UObject for me.

For example, to UObject, I added the following:

pub fn list_fields(&self, process: &Process, module: &Module) {
    let name = self.get_fname::<CSTR>(process, module).unwrap().validate_utf8().unwrap().to_string();
    crate::print_message(&format!("Fields for UObject {}:", name));

    self.get_uclass(process, module)
        .unwrap()
        .list_fields(process, module);

    crate::print_message(&format!(""));
}

and to UClass,

fn list_fields(
    &self,
    process: &Process,
    module: &Module,
) {
    for field in self.properties(process, module) {
        let name = field.get_fname::<CSTR>(process, module).unwrap().validate_utf8().unwrap().to_string();
        let offset = field.get_offset(process, module).unwrap();

        crate::print_message(&format!("{}: offset {:#018x}", name, offset));
    }
}

Obviously this solution isn't great as it relies upon alloc. I think the ideal solution is to expose the iterator and allow the user to do anything for each entry. I don't really have the time to iterate upon it right now to make a proper pull request so I'm making this issue to present the idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions