MSC++ and constructors
- kataklinger
- Member
- Posts: 381
- Joined: Fri Nov 04, 2005 12:00 am
- Location: Serbia
MSC++ and constructors
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
RE:MSC++ and constructors
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
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