Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Solution Needed Please

Solution Needed Please

Scheduled Pinned Locked Moved C / C++ / MFC
helpalgorithmsdata-structuresregexperformance
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Abin
    wrote on last edited by
    #1

    I'm currently on a project which needs to exam memory contents of an other process, basically, it searchs for certain pattern in the target process's page memorys, if pattern found then do some further examination, else keeps searching for same pattern. I did it by this way: First, I use ::VirtualQueryEx to obtain all pages of the target process and store those page information(base address and page size) in an array. This step completes in no time. Second, I use ::ReadProcessMemory to read the memory from each page(bytes by bytes) and compare the bytes with my predefined pattern, which are an array of bytes, using memcmp. I will finally find the memory address that I want for sure, but the problem is that it's slow, very slow. The target process has over 500 pages and total size of which are over 70MB, it takes like 50 seconds to finish the searching, and that makes my application completely useless. Now since you guys are all gurus out here, I think there must be something to do to shorten the search time, please help and thanks in advance.

    W D 2 Replies Last reply
    0
    • A Abin

      I'm currently on a project which needs to exam memory contents of an other process, basically, it searchs for certain pattern in the target process's page memorys, if pattern found then do some further examination, else keeps searching for same pattern. I did it by this way: First, I use ::VirtualQueryEx to obtain all pages of the target process and store those page information(base address and page size) in an array. This step completes in no time. Second, I use ::ReadProcessMemory to read the memory from each page(bytes by bytes) and compare the bytes with my predefined pattern, which are an array of bytes, using memcmp. I will finally find the memory address that I want for sure, but the problem is that it's slow, very slow. The target process has over 500 pages and total size of which are over 70MB, it takes like 50 seconds to finish the searching, and that makes my application completely useless. Now since you guys are all gurus out here, I think there must be something to do to shorten the search time, please help and thanks in advance.

      W Offline
      W Offline
      wb
      wrote on last edited by
      #2

      the only thing i can think of, is writing some own memcmp function based on KnuthMorrisPrat or BoyreMoore algorithms... I actualy dont know how the standard memcmp behaves but I imagine it has a O(nm) runtime, so if your pattern is relativly long, you can speedup your app a lot. (I GUESS)

      1 Reply Last reply
      0
      • A Abin

        I'm currently on a project which needs to exam memory contents of an other process, basically, it searchs for certain pattern in the target process's page memorys, if pattern found then do some further examination, else keeps searching for same pattern. I did it by this way: First, I use ::VirtualQueryEx to obtain all pages of the target process and store those page information(base address and page size) in an array. This step completes in no time. Second, I use ::ReadProcessMemory to read the memory from each page(bytes by bytes) and compare the bytes with my predefined pattern, which are an array of bytes, using memcmp. I will finally find the memory address that I want for sure, but the problem is that it's slow, very slow. The target process has over 500 pages and total size of which are over 70MB, it takes like 50 seconds to finish the searching, and that makes my application completely useless. Now since you guys are all gurus out here, I think there must be something to do to shorten the search time, please help and thanks in advance.

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        =[ Abin ]= wrote: it takes like 50 seconds to finish the searching, and that makes my application completely useless. If by "useless" you mean nonresponsive, then I suggest you put the processing code in a separate thread. That way, your UI remains responsive. See this article for more.


        "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups