Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8823793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:26:49+00:00 2026-06-14T06:26:49+00:00

I can easily read an entire executable file, or however many bytes I’d like

  • 0

I can easily read an entire executable file, or however many bytes I’d like to read via defining the size but what about if I want to read it from the beginning up until the next “MZ” ? if 2 files are binded together and I want to grab the first half only, not knowing the size of it.

mz binary stuff 1 – the one i want
mz binary stuff 2

0x77, 0x90 == MZ

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:26:50+00:00Added an answer on June 14, 2026 at 6:26 am

    You need to take SizeOfRawData for each IMAGE_SECTION_HEADER (pinvoke) structure and append SizeOfHeaders from IMAGE_NT_HEADERS32/64 structure.

    First you will need to take IMAGE_DOS_HEADER structure from PE/PE+ file

    After that, e_lfanew field will points you to IMAGE_NT_HEADERS32/64 structure. (If Magic == 0x10b -> PE. If Magic = 0x20b -> PE+ file)

    Count of sectionHeadersCount you can get from IMAGE_FILE_HEADER structure.

    UInt32 startAddress = IMAGE_DOS_HEADER.e_lfanew + 4 + Marshal.SizeOf(typeof(IMAGE_FILE_HEADER)) + [IMAGE_FILE_HEADER][6].SizeOfOptionalHeader 
    
    for(UInt32 loop = 0;loop < sectionHeadersCount;loop++)
    {
        IMAGE_SECTION_HEADER section = /*Map offset to IMAGE_SECTION_HEADER structure Method*/(startAddress);
        startAddress += Marshal.SizeOf(typeof(IMAGE_SECTION_HEADER));//Offset to next section
    }
    
    // Example of Mapping function:
    public T PtrToStructure<T>(UInt32 offset) where T : struct
    {
        Byte[] bytes = this.ReadBytes(offset, (UInt32)Marshal.SizeOf(typeof(T)));
    
        GCHandle handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
        try
        {
             T result = (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T));
             return result;
        } finally
        {
             handle.Free();
        }
    }
    

    Detailed PE/PE+ description

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[using VB.NET, but I can easily read C# code in responses] I have a
I'd like to save an array to disk so that I can easily read
In C# you can easily read all classes from a given assembly. I'm looking
I can easily check IP addresses programmatically, but is there any way to set
In Bash I can easily do something like command1 && command2 || command3 which
I can easily write a string to a connection using io.WriteString. However, I can't
I read Objective–C can easily lead to name collisions due it's nature, so it
I've written a Brainfuck implementation (C++) that works like this: Read input brainfuck file
Can anoyne recommend a good library that will let me easily read/write private member
I need to read large xml using .net files which can easily be several

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.