5

I'm currently working on a tool that allows me to change C++-code on the fly. Changed files are compiled in the background, loaded from the .obj, relocated & linked, and patched into the running process. This works fine so far.

However, I have been unable to load symbols for the new functions so that they are visible by the debugger. I have tried creating a virtual module using SymLoadModuleEx and adding symbols via SymAddSymbol, but that didn't work.

Ultimately, I would like to be able to add symbols and line information for the new functions. I could do that from either a .pdb file or the COFF info stored in the .obj (I have both), but I seem to be missing the crucial part that informs the debugger.

Is there a function for this that I simply missed? Or an undocumented code for RaiseException that is understood by the debugger (similar to naming a thread)?

I use Visual Studio, but any help in getting this to work in either the VS debugger or WinDBG is greatly appreciated.

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
  • Which debugger? WinDbg? – rustyx Sep 05 '16 at 07:41
  • I think you should not normally add new functions while hot patching. Instead you could compile them in and link them in before the hot-patching which just adds the calls. But that is not guaranteed to work either (hence this is just a comment) – Paul Stelian Sep 05 '16 at 07:42
  • @RustyX Visual Studio, but WinDbg is also fine. – Stefan Reinalter Sep 05 '16 at 09:32
  • 1
    @PaulStelian Adding new functions is not a problem, and needs to be supported. Imagine patching a function A that now calls a function B from the same translation unit. It's the debugging information that's missing, hence you cannot step into the code, use breakpoints, etc. which is crucial. – Stefan Reinalter Sep 05 '16 at 09:34

0 Answers0