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. VC++ gives Invalid function reference

VC++ gives Invalid function reference

Scheduled Pinned Locked Moved C / C++ / MFC
c++debuggingperformancehelptutorial
6 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
    Aidman
    wrote on last edited by
    #1

    Hi, all :) I am trying to write a little experiment program where it is supposed to copy a function (the bytecode) during runtime. But I have encountered a problem, which seems to be VC++ fault (at least in debug mode). Whenever you want a function reference, VC++ gives you a different memory location than the where actual function is located. VC++ gives you a location of a jump instruction, which jumps to the actual function. But because I want the exact functions location in memory I am experiencing a problem. I hope you understood my problem (if not please reply, so I can clarify my self). Any ideas on how to avoid the problem with getting the wrong location? Thanks in Advance Aidman » over and out We haven't inherited Earth from our parents, instead we have borrowed her from our children; an old Indian saying.

    J C 2 Replies Last reply
    0
    • A Aidman

      Hi, all :) I am trying to write a little experiment program where it is supposed to copy a function (the bytecode) during runtime. But I have encountered a problem, which seems to be VC++ fault (at least in debug mode). Whenever you want a function reference, VC++ gives you a different memory location than the where actual function is located. VC++ gives you a location of a jump instruction, which jumps to the actual function. But because I want the exact functions location in memory I am experiencing a problem. I hope you understood my problem (if not please reply, so I can clarify my self). Any ideas on how to avoid the problem with getting the wrong location? Thanks in Advance Aidman » over and out We haven't inherited Earth from our parents, instead we have borrowed her from our children; an old Indian saying.

      J Offline
      J Offline
      John M Drescher
      wrote on last edited by
      #2

      Is the function you are copying inside a DLL? John

      A 1 Reply Last reply
      0
      • J John M Drescher

        Is the function you are copying inside a DLL? John

        A Offline
        A Offline
        Aidman
        wrote on last edited by
        #3

        nop, a regular exe Aidman » over and out We haven't inherited Earth from our parents, instead we have borrowed her from our children; an old Indian saying.

        J 1 Reply Last reply
        0
        • A Aidman

          Hi, all :) I am trying to write a little experiment program where it is supposed to copy a function (the bytecode) during runtime. But I have encountered a problem, which seems to be VC++ fault (at least in debug mode). Whenever you want a function reference, VC++ gives you a different memory location than the where actual function is located. VC++ gives you a location of a jump instruction, which jumps to the actual function. But because I want the exact functions location in memory I am experiencing a problem. I hope you understood my problem (if not please reply, so I can clarify my self). Any ideas on how to avoid the problem with getting the wrong location? Thanks in Advance Aidman » over and out We haven't inherited Earth from our parents, instead we have borrowed her from our children; an old Indian saying.

          C Offline
          C Offline
          Chris Richardson
          wrote on last edited by
          #4

          Not sure if this will disable it in Debug mode, but you can try turning off the "Link incrementally" option on the Linker tab of the project settings. However, it may be that in debug mode it always uses the jmp instruction, regardless of the setting, so it can link faster. Chris Richardson
          Terrain Software

          A 1 Reply Last reply
          0
          • A Aidman

            nop, a regular exe Aidman » over and out We haven't inherited Earth from our parents, instead we have borrowed her from our children; an old Indian saying.

            J Offline
            J Offline
            John M Drescher
            wrote on last edited by
            #5

            I brought this up because I know dlls use a lot of JMP instructions into the actual code. The thing is that this is perfectly legal but not what you would expect. You may have to play with the compiler settings to turn off that feature. John

            1 Reply Last reply
            0
            • C Chris Richardson

              Not sure if this will disable it in Debug mode, but you can try turning off the "Link incrementally" option on the Linker tab of the project settings. However, it may be that in debug mode it always uses the jmp instruction, regardless of the setting, so it can link faster. Chris Richardson
              Terrain Software

              A Offline
              A Offline
              Aidman
              wrote on last edited by
              #6

              Thanks man! That did the trick :-D Aidman » over and out We haven't inherited Earth from our parents, instead we have borrowed her from our children; an old Indian saying.

              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