dfhack icon indicating copy to clipboard operation
dfhack copied to clipboard

Expose winapi heap debugging tools to lua

Open 20k opened this issue 3 years ago • 0 comments

_msize returns the real allocation size of a pointer by using windows heap black magic. This function is significantly more useful than the equivalent on linux (which seems to have no equivalent), which only returns the block size - and so cannot really be used for what we need it for. Eg running it on a unit pointer returns 5136 , whereas on linux it'd probably return something much more block-sized

This would have detected more than one misalignment as well (aliased pointers) and is how I found that vision_cone was misaligned, and would very likely be useful to integrate into gm-edit

I don't have a wine install, but its absolutely worth checking the behaviour there, as this is one of the things that will likely diverge

Edit:

This PR now contains a reasonably complete set of tools for debugging the heap. I'm going to file a PR to update sizecheck for both dangling pointers (which can now detect the zone bug!), and memory misalignments

20k avatar Jan 25 '23 18:01 20k