Hello
I want to write a C# (or VB.NET) program which reads the structure of
a PE (odinary win32 executable) file. These files have a long header
(512 bytes or so). The definition of the header exists in WINNT.h file
(you can see many "struct"s there).
Here comes my problem: how can I read a file and "fill" the structs?
Note that a method such as FileStream.Read can only fill an array not
a struct:
public override int Read(
in byte[] array,
int offset,
int count
);
The conversion from an array to those structs is really cumbersome. In
an unmanaged language, I could use pointers to have the array and the
struct share the same memory, thus filling the struct members with
array's values. But, in this managed context, that's not the case.
Any help is appreciated.
PS: If possible, I want to write a program without "unsafe" blocks or
Windows API functions.
thnx in advance,
MSD.