0

I would like to determine the type of an object from a memory address, such that I can apply the correct cast in the VS Watch window and view the object.

I am attempting to debug in the disassembly view, as my own code is loaded as a DLL into an existing exe for which I have no source code or pdb.

The existence of typeid and dynamic_cast give me hope that there is some way this could be achieved (perhaps in a limited fashion) without any additional coding.

However I am happy if the solution includes modifying my code, I have access to all the class definitions, although I can't necessarily change the in memory layout of some of them.

I also have an override for the allocation of the objects, so I have the chance to allocate extra memory for my own purposes here, e.g. 4 bytes before the object in which I could put a name tag of some kind.

billw
  • 120
  • 1
  • 9
  • In what way is `typeid` not good enough for you? – Jester Sep 07 '19 at 17:39
  • @Jester It won't work in the watch window – billw Sep 07 '19 at 17:53
  • Here is the error when trying to use typeid in the watch window or my .natvis file: "Error: va_start can appear only in a function with an ellipsis parameter" ZERO hits from google on that one. – billw Sep 07 '19 at 18:07

1 Answers1

0

Answering my own question. I solved this using a system designed for tracking allocations: http://www.almostinfinite.com/memtrack.html It is a drop in replacement for new that will tag all allocations with the type id being allocated (along with other information).

billw
  • 120
  • 1
  • 9