Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- public unsafe struct _IMAGE_DOS_HEADER { // DOS .EXE header
- public WORD e_magic; // Magic number
- public WORD e_cblp; // Bytes on last page of file
- public WORD e_cp; // Pages in file
- public WORD e_crlc; // Relocations
- public WORD e_cparhdr; // Size of header in paragraphs
- public WORD e_minalloc; // Minimum extra paragraphs needed
- public WORD e_maxalloc; // Maximum extra paragraphs needed
- public WORD e_ss; // Initial (relative) SS value
- public WORD e_sp; // Initial SP value
- public WORD e_csum; // Checksum
- public WORD e_ip; // Initial IP value
- public WORD e_cs; // Initial (relative) CS value
- public WORD e_lfarlc; // File address of relocation table
- public WORD e_ovno; // Overlay number
- [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 4, ArraySubType = System.Runtime.InteropServices.UnmanagedType.I2)]
- public WORD[] e_res; // Reserved words
- public WORD e_oemid; // OEM identifier (for e_oeminfo)
- public WORD e_oeminfo; // OEM information; e_oemid specific
- [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 10, ArraySubType = System.Runtime.InteropServices.UnmanagedType.I2)]
- public WORD[] e_res2; // Reserved words
- public LONG e_lfanew; // File address of new exe header
- //
- public _IMAGE_DOS_HEADER(int nFakeArgs) {
- this.e_cblp = this.e_cp = this.e_cparhdr = this.e_crlc = 0;
- this.e_cs = this.e_csum = this.e_ip = this.e_lfarlc = 0;
- this.e_magic = this.e_maxalloc = this.e_minalloc = this.e_oemid = 0;
- this.e_oeminfo = this.e_ovno = this.e_sp = this.e_ss = 0;
- this.e_lfanew = 0;
- this.e_res = new WORD[4];
- this.e_res2 = new WORD[10];
- }
- public _IMAGE_DOS_HEADER(byte[] data)
- : this(0) {
- unsafe {
- GCHandle hImgDosHdr = GCHandle.Alloc(data, GCHandleType.Pinned);
- IntPtr pImgDosHdr = hImgDosHdr.AddrOfPinnedObject();
- this = (_IMAGE_DOS_HEADER)Marshal.PtrToStructure(pImgDosHdr, this.GetType());
- hImgDosHdr.Free();
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement