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. Hooking to process memory - where to start?

Hooking to process memory - where to start?

Scheduled Pinned Locked Moved C / C++ / MFC
performancetutorialquestion
8 Posts 4 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.
  • G Offline
    G Offline
    generic_user_id
    wrote on last edited by
    #1

    Many debuggers can hook to a program and read its memory. Even if it's protected/private. I'm thinking about writing a simple debugging tool, but I don't know how to read process memory. Should I use SetWindowsHookEx? Some advice would be greatly appriciated Regards, Griffith


    Everything you say will be misquoted, ripped out of context and used against you.

    D 1 Reply Last reply
    0
    • G generic_user_id

      Many debuggers can hook to a program and read its memory. Even if it's protected/private. I'm thinking about writing a simple debugging tool, but I don't know how to read process memory. Should I use SetWindowsHookEx? Some advice would be greatly appriciated Regards, Griffith


      Everything you say will be misquoted, ripped out of context and used against you.

      D Offline
      D Offline
      Dave Bryant
      wrote on last edited by
      #2

      Try ReadProcessMemory() Dave

      C G 2 Replies Last reply
      0
      • D Dave Bryant

        Try ReadProcessMemory() Dave

        C Offline
        C Offline
        carrie
        wrote on last edited by
        #3

        I've been doing a fair amount of work on something pretty similar, I've been interested in debuggers and how programs work at the lowest levels for a while now after starting off as a bit of a coding idiot :) The best places I can recommend to start is if you can afford it, buy John Robbin's "Debugging Windows Applications" because he truely is the king of all things debugger. His Bugslayer articles in MSDN give good ideas too and there are a couple of articles here on CP that can help, search for APIHijack because that gives a good idea of how to get started. John Robbins really is the king though, just had to say that again :)

        G 1 Reply Last reply
        0
        • D Dave Bryant

          Try ReadProcessMemory() Dave

          G Offline
          G Offline
          generic_user_id
          wrote on last edited by
          #4

          Thanks for the suggestion, but this is what I read on MSDN

          ReadProcessMemory copies the data in the specified
          address range from the address space of the specified process into
          the specified buffer of the current process. Any process that has a
          handle with PROCESS_VM_READ access can call the function. The process
          whose address space is read is typically, but not necessarily, being
          debugged.

          The entire area to be read must be accessible. If it is not, the
          function fails as noted previously.

          Regular processes don't have PROCESS_VM_READ... I doubt windows has a simple api that allows one process to read and modify the memory of another one. (What would be the use of Protected memory then?) Or is there a way to make ReadProcessMemory work? Kind regards, Griffith


          Everything you say will be misquoted, ripped out of context and used against you.

          J 1 Reply Last reply
          0
          • G generic_user_id

            Thanks for the suggestion, but this is what I read on MSDN

            ReadProcessMemory copies the data in the specified
            address range from the address space of the specified process into
            the specified buffer of the current process. Any process that has a
            handle with PROCESS_VM_READ access can call the function. The process
            whose address space is read is typically, but not necessarily, being
            debugged.

            The entire area to be read must be accessible. If it is not, the
            function fails as noted previously.

            Regular processes don't have PROCESS_VM_READ... I doubt windows has a simple api that allows one process to read and modify the memory of another one. (What would be the use of Protected memory then?) Or is there a way to make ReadProcessMemory work? Kind regards, Griffith


            Everything you say will be misquoted, ripped out of context and used against you.

            J Offline
            J Offline
            jmkhael
            wrote on last edited by
            #5

            easy way out: u gotta Create the process u wanna read urself, then open it using PROCESS_ALL_ACCESS, than read the memory Papa while (TRUE) Papa.WillLove ( Bebe ) ;

            C 1 Reply Last reply
            0
            • C carrie

              I've been doing a fair amount of work on something pretty similar, I've been interested in debuggers and how programs work at the lowest levels for a while now after starting off as a bit of a coding idiot :) The best places I can recommend to start is if you can afford it, buy John Robbin's "Debugging Windows Applications" because he truely is the king of all things debugger. His Bugslayer articles in MSDN give good ideas too and there are a couple of articles here on CP that can help, search for APIHijack because that gives a good idea of how to get started. John Robbins really is the king though, just had to say that again :)

              G Offline
              G Offline
              generic_user_id
              wrote on last edited by
              #6

              Thanks carrie The book looks promissing, but it's 45 bucks on amazon :( APIHijack's nice, I'll check out its sourcecode. Kind regards, Griffith


              Everything you say will be misquoted, ripped out of context and used against you.

              1 Reply Last reply
              0
              • J jmkhael

                easy way out: u gotta Create the process u wanna read urself, then open it using PROCESS_ALL_ACCESS, than read the memory Papa while (TRUE) Papa.WillLove ( Bebe ) ;

                C Offline
                C Offline
                carrie
                wrote on last edited by
                #7

                exactly like that, if you use CreateProcess and supply the flag to show that the program you're writing is debugging the one you are wanting to debug, you can get access to read into its memory space. Just forked out for that book myself about a month ago, its full of amazing code so I'm more than happy to have paid so much for it. Can't live without it now :)

                G 1 Reply Last reply
                0
                • C carrie

                  exactly like that, if you use CreateProcess and supply the flag to show that the program you're writing is debugging the one you are wanting to debug, you can get access to read into its memory space. Just forked out for that book myself about a month ago, its full of amazing code so I'm more than happy to have paid so much for it. Can't live without it now :)

                  G Offline
                  G Offline
                  generic_user_id
                  wrote on last edited by
                  #8

                  Okay, I'll try that then. I know for sure it's possible to read the memory of existing processes though. Thanks a lot guys Griffith


                  Everything you say will be misquoted, ripped out of context and used against you.

                  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