korcankaraokcu / PINCE

Reverse engineering tool for linux games
Other
2.11k stars 149 forks source link

Struct data type support #145

Open jaredballou opened 2 years ago

jaredballou commented 2 years ago

Hi all,

I'm regularly running into issues which would be much easier to deal with if there were a struct data type. For example, when handling inventory in a game, each item has two int8 values for item id and count, an int32 for experience, and a float for durability. When I have to enter the same four fields over and over (and do the hex math in my head) for the 24 item slots, I make mistakes all the time because I have to hand-edit all the addresses and descriptions one by one.

I would really like to be able to define "inventory item" as a type, with those 4 fields referenced by offsets, and then I just need to point the main item at the base address to wire it up.

I was going to take a crack at adding the type myself, but I'm not quite advanced enough to figure out the type management code in PINCE. That said, if someone wants to add the bare bones for the type, I'd be glad to handle adding in the UI elements.

As a "nice to have" I'd love to be able to define an array of other types, so I can point at the base inventory item and say "create 24 of these X byte structs starting at Y and increment each new item to the correct offset".

korcankaraokcu commented 2 years ago

This will be also required for automatic analysis of data chunks. CE already has data chunk comparison to identify similar objects, so yeah, good feature. Leaving this issue open for further discussion

jaredballou commented 2 years ago

The automatic analysis would be excellent, but I'd be happy taking the smaller step of being able to create an assembly of other data types into a struct. Even better would be the ability to nest data types (i.e. for Persona 5, having a "Persona" data type with id/traits/skills/xp, and then being able to add that as a sub-item on "Player" and "Party member" objects, because while the Player and Party Member contain a lot of different fields, the Persona contained within their data is consistent.

As with the other issue, I can do some mock ups and examples if it'd help, but I get the impression that we'd need to make some pretty significant changes to the data type system to allow this to work, so I am not much help with regards to actually implementing the feature.