Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2005

Tip: Looking for answers? Try searching our database.

[C++/CLI] Determine struct layout from header file - reflection?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jack Ukleja - 28 Oct 2005 02:13 GMT
Hi guys,

I'm trying to figure out a way to do reflection on structs which are in a
legacy c++ header file. Basically I want to write a C++/CLI program that lets
me edit the binary data in the structs, but there are many of these structs
so it has to be automated. Also I do not want to have to modify the legacy
struct definitions.

Firstly if I simply include the .h file then none of the structs appear in
the assembly. So I guess first of all I must do a hack where an instance of
each of the structs in created so that it appears in the assembly.

Unfortunately when I look using reflector I see that the assembly still
dosnt really 'know' anything about these structs. The offsets for the fields
are basically hard coded into the accessing code. There is no struct with
named fields accessble for reflection in the assembly.

Can anyone give me some ideas on how to accomplish what im trying to do?
(find out layout of legacy c++ structs without modifying the source file).

Thanks
Marcus Heege - 29 Oct 2005 17:40 GMT
C++/CLI is not able to do what you want.

C++/CLI does not create metadata for native classes and structs (with one
exception that is not relevant here.)
The only option I see is parsing the .h file to get the metadata for the
native types.

Marcus Heege

> Hi guys,
>
[quoted text clipped - 21 lines]
>
> Thanks
Jack Ukleja - 31 Oct 2005 10:51 GMT
What is the exception?

Is the C++ Code DOM going to help me much in this case? It wouldnt
understand much about the struct layouts would it?

I remember there is an API for examining some of the output files of the cpp
compiler that contains all the struct layout info in it, but I cannot
remember what is it called. Its quite old I think.

> C++/CLI is not able to do what you want.
>
[quoted text clipped - 30 lines]
> >
> > Thanks

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.