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 8164697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:22:31+00:00 2026-06-06T19:22:31+00:00

I am reading addresses in memory with the below code. It occurred to me

  • 0

I am reading addresses in memory with the below code. It occurred to me that I may be doing this very inefficiently as I am making individual calls for every address despite all of the addresses being neighbours to each other (1 byte along).

    [DllImport("kernel32", EntryPoint = "ReadProcessMemory")]
    private static extern byte ReadProcessMemoryByte(int Handle, int Address, ref byte Value, int Size, ref int BytesRead);

The function looks something like:

pseudo: 
       For loop: 
       read memory address (base address offset)
       add result to array
       addressoffset++

So say I have 3 addresses, I would be making 3 separate calls. Is there a way to make just 1 call and then do so internal logic to split the result into 3 separate data segments, if you know what I mean? Like instead of reading byte by byte, read 4 bytes at once then split them up before adding to the array?

The reason I am asking this is that my program takes forever to go through the iterations, sometimes having to read up to 40,000 addresses which takes 3 minutes. If I could do what I am asking, then maybe I could cut it down under a minute?

  • 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-06T19:22:32+00:00Added an answer on June 6, 2026 at 7:22 pm

    From http://www.pinvoke.net/default.aspx/kernel32.readprocessmemory, the method signature should be like:

      [DllImport("kernel32.dll", SetLastError = true)]
      static extern bool ReadProcessMemory( 
        IntPtr hProcess, 
        IntPtr lpBaseAddress,
        [Out] byte[] lpBuffer, 
        int dwSize, 
        out int lpNumberOfBytesRead
       );
    

    Currently, since you only have a single byte for lpBuffer/Value, you are only reading one byte at a time. You can read many more (maybe all of the bytes you intend to read, or broken up into, say, 1024 byte chunks) by making that a byte[] and passing a Size larger than 1.

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

Sidebar

Related Questions

I'm reading Understanding Linux Kernel. This is the snippet that explains how Linux uses
I was reading up on Virtual Memory and from what I understand is that
I am reading some C++ text and got the following code: From that code,
I was reading about how to implement a DPDA and found this code in
I was reading this question , I wanted to ask more about the code
After reading a description about swapping pointer addresses on Stackoverflow, I have a question
Reading the Scala by Example book and there is this example when Martin explains
Reading through this excellent article about safe construction techniques by Brain Goetz, I got
I was reading http://duartes.org/gustavo/blog/post/motherboard-chipsets-memory-map and in specific, the following section: In a motherboard the
I am working with a binary file structure. The code example for reading the

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.