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. Finding the memory address of a function [modified]

Finding the memory address of a function [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
algorithmsjsonperformancequestion
7 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.
  • H Offline
    H Offline
    hxhl95
    wrote on last edited by
    #1

    Hiya everyone, I was searching for some way to find the memory address of a function such as TerminateProcess. Is there a way to do this? I've read something about the VirtualQuery function, but I don't exactly understand how that can be applied. Could anyone give me a few pointers? (and maybe somewhere I can learn some more about windows memory management.) Thanks. :) EDIT: this is what I'm reading right now.

    modified on Thursday, September 24, 2009 2:23 PM

    D S C 3 Replies Last reply
    0
    • H hxhl95

      Hiya everyone, I was searching for some way to find the memory address of a function such as TerminateProcess. Is there a way to do this? I've read something about the VirtualQuery function, but I don't exactly understand how that can be applied. Could anyone give me a few pointers? (and maybe somewhere I can learn some more about windows memory management.) Thanks. :) EDIT: this is what I'm reading right now.

      modified on Thursday, September 24, 2009 2:23 PM

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

      hxhl95 wrote:

      I was searching for some way to find the memory address of a function such as TerminateProcess.

      Something like:

      HMODULE hModule = LoadLibrary(_T("kernel32.dll"));
      typedef BOOL (*PROC)(HANDLE, UINT);
      PROC proc = (PROC) GetProcAddress(hModule, "TerminateProcess");

      is much less succinct than Stuart's answer.

      "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      modified on Thursday, September 24, 2009 4:58 PM

      1 Reply Last reply
      0
      • H hxhl95

        Hiya everyone, I was searching for some way to find the memory address of a function such as TerminateProcess. Is there a way to do this? I've read something about the VirtualQuery function, but I don't exactly understand how that can be applied. Could anyone give me a few pointers? (and maybe somewhere I can learn some more about windows memory management.) Thanks. :) EDIT: this is what I'm reading right now.

        modified on Thursday, September 24, 2009 2:23 PM

        S Offline
        S Offline
        Stuart Dootson
        wrote on last edited by
        #3

        If you have (for example) TerminateProcess's definition pulled in via a header, then &TerminateProcess is sufficient...

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

        H 1 Reply Last reply
        0
        • H hxhl95

          Hiya everyone, I was searching for some way to find the memory address of a function such as TerminateProcess. Is there a way to do this? I've read something about the VirtualQuery function, but I don't exactly understand how that can be applied. Could anyone give me a few pointers? (and maybe somewhere I can learn some more about windows memory management.) Thanks. :) EDIT: this is what I'm reading right now.

          modified on Thursday, September 24, 2009 2:23 PM

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          hxhl95 wrote:

          I was searching for some way to find the memory address of a function

          hxhl95 wrote:

          Could anyone give me a few pointers?

          :-D

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          H 1 Reply Last reply
          0
          • C CPallini

            hxhl95 wrote:

            I was searching for some way to find the memory address of a function

            hxhl95 wrote:

            Could anyone give me a few pointers?

            :-D

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            H Offline
            H Offline
            hxhl95
            wrote on last edited by
            #5

            I knew someone was gonna say that sooner or later. :laugh:

            1 Reply Last reply
            0
            • S Stuart Dootson

              If you have (for example) TerminateProcess's definition pulled in via a header, then &TerminateProcess is sufficient...

              Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

              H Offline
              H Offline
              hxhl95
              wrote on last edited by
              #6

              Thanks (to both you and DavidCrow, but I can't reply to two threads with a single reply...), I'll try that. Can't believe I didn't think of that... :doh: EDIT: Okay. So now if I hook TerminateProcess with my own dll, shouldn't the value of &TerminateProcess differ from the address of TerminateProcess in the kernel32.dll? I don't see any difference in the two addresses right now..:confused:

              modified on Thursday, September 24, 2009 6:08 PM

              C 1 Reply Last reply
              0
              • H hxhl95

                Thanks (to both you and DavidCrow, but I can't reply to two threads with a single reply...), I'll try that. Can't believe I didn't think of that... :doh: EDIT: Okay. So now if I hook TerminateProcess with my own dll, shouldn't the value of &TerminateProcess differ from the address of TerminateProcess in the kernel32.dll? I don't see any difference in the two addresses right now..:confused:

                modified on Thursday, September 24, 2009 6:08 PM

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

                hxhl95 wrote:

                but I can't reply to two threads with a single reply..

                You can make a reply pointing to the other one's address... (sorry for the bad pun) :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                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