MSC++ and constructors

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
kataklinger
Member
Member
Posts: 381
Joined: Fri Nov 04, 2005 12:00 am
Location: Serbia

MSC++ and constructors

Post by kataklinger »

Does anybody know how I should write code to call constructors and destructors for code compiled with M$ C++. It has something with .text$yc section and .text$yd
VE3MTM

RE:MSC++ and constructors

Post by VE3MTM »

I don't know the details of how MSVC++ implements constructors on global variables, but I assume it's fairly close to how it's done on the GNU compiler GCC. I suggest taking a look at this site: http://www.invalidsoftware.net/os/ . It's made for GCC, but I think you should be able to adapt it. The section names will be different (gcc calls them .ctor and .dtor). Most likely, the sections simply have pointers to the constructor functions, and you can iterate through them to initialize all the variables. I suggest cracking open a binary and taking a look at the contents of the sections.

I just thought of something now. I don't know if you've ever done this, but if you debug your code past the end of your main() function, it goes into the wrapper code Windovs runs, where it sets up the process space and the heap, calls the main() function and cleans up. Take a look at some of that stuff. Chances are that what you need is in there.

Cheers,
Michael
Post Reply