Follow the tenth law of Greenspun, and you're good to go: just implement the special, informally indicated, error-loaded, slow implementation of half of Common Lisp. Choose the half that supports reflection implementation. :)
Or, here's the idea:
Include map files (and possibly assembly) in your assembly. Implement an application that generates code to create a dynamic library. You should be able to get all the static information (method names, parameters, types, etc.) About classes from the source or one of the assembly artifacts. Using a map or assembly, you can find addresses of functions, offsets of pointers to virtual functions, addresses of global variables, offsets of variables, stack information and register distributed variables, etc. Etc. From this information, create a library containing calls to get all this information by passing type names, pointers, function names, etc.
Now, in C ++, write a library containing functions and macros that will allow you to put a unique identifier that will be compiled into code to identify the start of the function, all reflection calls, EIP offsets on reflection calls, etc. Use the built-in assembly macros in appropriate places where, if necessary, the NOP needs to leave a few instructions, usually immediately after the ID. In addition, provide bridge library functions that allow reflection functionality or process what it can embed (for example, get the address of a function) and make calls to a dynamic library built at the post-build stage.
Finally, write a post-post build reflection linker. I suggest "kniltsoPostlink", but it is up to you. At this step, find your unique identifiers (I mentioned to make it easier for you, maybe you should make ID identifiers so that you can look for them in binary format?), And wherever the identifier marks a function reflection call, or class definition, etc. .d., place enough data there (in a format that you can easily determine exactly in time when you write the reflector library), and then in the identifier before calling the reflector library, rewrite the call so that it extracts the parameter it needs s of these data bits or just puts data bits there, if applicable, I canโt know in advance, but as you write it, these little details will just pop up on you.
In any case, I know that I did not get a lot of code, and in fact I intend to start a project on this subject when I have enough free time. I mean that each small part should be very simple, since you are doing it gradually, each small part should become clear if you follow the instructions outlined here. It is possible that some of them will actually be even simpler than I described here, because it was the worst case scenario. You can even leave without even rewriting the code for the reflector; simply placing data at appropriate points may allow the library to draw these bits as needed without additional information.
I am very glad you asked; I'm very busy right now, but if you get the night for free, I think it will be a good start in the first version, and I will be glad if I can.
;)