How to determine an item's value:
1. Determine the item's base value. The item type is returned by a function call. Use the item type to determine the base value (in most cases, it's 10).
1a. If the item is a type of weapon, armor, trap component, or tool, then you'll need to figure out how the game determines the item value. Good luck with that.
2. Determine the item's material value. The item's material is also returned by a function call. Once you have the material (and know whether it's a builtin, an inorganic, a creature, or a plant), then you can fetch the material object itself and grab the value from the appropriate offset. I'm not certain exactly where all of those material objects are located, but inorganics are known and builtins can be handled easily enough with a lookup table.
3. Determine the item's quality multiplier. The item's quality is also returned by a function call.
4. Multiply the results from steps 1-3 together to get the item's value.
5. Locate the item's decoration vector. I don't recall, but this is probably also returned by a function call. Iterate across all entries within it and repeat steps 2-3 to find the value of each decoration, then add them to the item's value.
For values returned by function calls, there are several ways of getting at the value:
1. Read the function pointers out of the object's VTABLE and examine the code they point at, then interpret the code to determine what they'll return. DFHack has "accessors" which do this, though I don't know if they still work with the current version.
2. Use the item's VTABLE pointer to determine its type, then use hardcoded lookup tables to get the relevant values/offsets for each item type. This would tie the utility to a very specific version of Dwarf Fortress on a single platform.
3. Inject code into Dwarf Fortress (as a separate thread) which calls the subroutine with the appropriate parameters and places the result at a predetermined address. I've actually used this method myself in a tool I wrote for Dwarf Fortress v0.23.130.23a (in the old 2D versions, designating items for Melting involved adding them to a vector rather than setting an item flag).