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. Handles and Pointers

Handles and Pointers

Scheduled Pinned Locked Moved C / C++ / MFC
questionperformanceannouncement
8 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.
  • T Offline
    T Offline
    tom groezer
    wrote on last edited by
    #1
    1. What is the difference between handle and pointer in terms of memory. Can my other process(non releated) see a handle/pointer. Lets say if my application has a pointer pointing to some data at at that memory location. Will it be possible for the other application to access that data? How? 2) What will one try to use LoadLibrary which shall load a exe and not execute it? 3) The return value from WinExec, which is a stripped-down version of CreateProcess, is a handle to a Windows NT executive object, whereas an instance handle, the value returned from LoadLibrary, is a virtual pointer.
    M 1 Reply Last reply
    0
    • T tom groezer
      1. What is the difference between handle and pointer in terms of memory. Can my other process(non releated) see a handle/pointer. Lets say if my application has a pointer pointing to some data at at that memory location. Will it be possible for the other application to access that data? How? 2) What will one try to use LoadLibrary which shall load a exe and not execute it? 3) The return value from WinExec, which is a stripped-down version of CreateProcess, is a handle to a Windows NT executive object, whereas an instance handle, the value returned from LoadLibrary, is a virtual pointer.
      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      tom groezer wrote:

      What is the difference between handle and pointer in terms of memory.

      A handle is an "opaque" data type. You can't make any assumptions about what it is and the implementation can be changed (in future versions) at any time. A handle could be a pointer, an index, an atom, etc. A handle is NOT always a pointer.

      tom groezer wrote:

      Can my other process(non releated) see a handle/pointer. Lets say if my application has a pointer pointing to some data at at that memory location. Will it be possible for the other application to access that data?

      Each process has its own address space. You could pass a pointer to another process but the pointer would be useless to the other process. To share memory between processes you could use something like GlobalAlloc, which allocates memory on the global heap.

      tom groezer wrote:

      The return value from WinExec, which is a stripped-down version of CreateProcess, is a handle to a Windows NT executive object, whereas an instance handle, the value returned from LoadLibrary, is a virtual pointer.

      You seem to know alot about internal details like that :) Who cares, both functions are holdovers from 16-bit Windows. Mark

      Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the letter Z

      T I 2 Replies Last reply
      0
      • M Mark Salsbery

        tom groezer wrote:

        What is the difference between handle and pointer in terms of memory.

        A handle is an "opaque" data type. You can't make any assumptions about what it is and the implementation can be changed (in future versions) at any time. A handle could be a pointer, an index, an atom, etc. A handle is NOT always a pointer.

        tom groezer wrote:

        Can my other process(non releated) see a handle/pointer. Lets say if my application has a pointer pointing to some data at at that memory location. Will it be possible for the other application to access that data?

        Each process has its own address space. You could pass a pointer to another process but the pointer would be useless to the other process. To share memory between processes you could use something like GlobalAlloc, which allocates memory on the global heap.

        tom groezer wrote:

        The return value from WinExec, which is a stripped-down version of CreateProcess, is a handle to a Windows NT executive object, whereas an instance handle, the value returned from LoadLibrary, is a virtual pointer.

        You seem to know alot about internal details like that :) Who cares, both functions are holdovers from 16-bit Windows. Mark

        Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the letter Z

        T Offline
        T Offline
        tom groezer
        wrote on last edited by
        #3

        Is GlobalAlloc still valid in 32 bit systems. Also what is the transition of heap from 16 bit to 32 bits systems done to get rid of a global heap. Another offshoot of this question is where do the global objects and staic objects kept. Is it kept in a special area in memory. The question was what is meant by a virtual pointer.

        M 1 Reply Last reply
        0
        • T tom groezer

          Is GlobalAlloc still valid in 32 bit systems. Also what is the transition of heap from 16 bit to 32 bits systems done to get rid of a global heap. Another offshoot of this question is where do the global objects and staic objects kept. Is it kept in a special area in memory. The question was what is meant by a virtual pointer.

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          tom groezer wrote:

          The question was what is meant by a virtual pointer.

          tom groezer wrote:

          whereas an instance handle, the value returned from LoadLibrary, is a virtual pointer

          I thought LoadLibrary returned a handle. That's why I stated you seem to know the internals :) Maybe the first few sentences at this link explain it? Virtual Address Space[^] And more on global/local 16/32-bit... Global and Local Functions[^]

          tom groezer wrote:

          where do the global objects and staic objects kept.

          In the object files? The EXE file? in memory when the process is created and the exe is loaded? More great reading :) Peering Inside the PE: A Tour of the Win32 Portable Executable File Format[^]

          Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the number 3

          1 Reply Last reply
          0
          • M Mark Salsbery

            tom groezer wrote:

            What is the difference between handle and pointer in terms of memory.

            A handle is an "opaque" data type. You can't make any assumptions about what it is and the implementation can be changed (in future versions) at any time. A handle could be a pointer, an index, an atom, etc. A handle is NOT always a pointer.

            tom groezer wrote:

            Can my other process(non releated) see a handle/pointer. Lets say if my application has a pointer pointing to some data at at that memory location. Will it be possible for the other application to access that data?

            Each process has its own address space. You could pass a pointer to another process but the pointer would be useless to the other process. To share memory between processes you could use something like GlobalAlloc, which allocates memory on the global heap.

            tom groezer wrote:

            The return value from WinExec, which is a stripped-down version of CreateProcess, is a handle to a Windows NT executive object, whereas an instance handle, the value returned from LoadLibrary, is a virtual pointer.

            You seem to know alot about internal details like that :) Who cares, both functions are holdovers from 16-bit Windows. Mark

            Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the letter Z

            I Offline
            I Offline
            InOut NET
            wrote on last edited by
            #5

            Volatile type qualifier. The keyword declares a variable that's accessible by other processes. I don't know much about the subject and not many books talk about it. I think theres reason for it being a discreet matter:suss:. Check out http://msdn2.microsoft.com/en-us/library/888bfst6(VS.80).aspx it gives an overview:^) - you need to dig more for implantation examples. Hope it helps.

            M 1 Reply Last reply
            0
            • I InOut NET

              Volatile type qualifier. The keyword declares a variable that's accessible by other processes. I don't know much about the subject and not many books talk about it. I think theres reason for it being a discreet matter:suss:. Check out http://msdn2.microsoft.com/en-us/library/888bfst6(VS.80).aspx it gives an overview:^) - you need to dig more for implantation examples. Hope it helps.

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              InOut.NET wrote:

              The keyword declares a variable that's accessible by other processes

              I'm going to respectfully disagree. While volatile tells the compiler that variable may be changed by an external "process" (something going on outside the scope of the variable like another thread, etc.) I don't believe it makes a variable accessible by other executing processes. Mark

              Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the number 3

              I 1 Reply Last reply
              0
              • M Mark Salsbery

                InOut.NET wrote:

                The keyword declares a variable that's accessible by other processes

                I'm going to respectfully disagree. While volatile tells the compiler that variable may be changed by an external "process" (something going on outside the scope of the variable like another thread, etc.) I don't believe it makes a variable accessible by other executing processes. Mark

                Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the number 3

                I Offline
                I Offline
                InOut NET
                wrote on last edited by
                #7

                You're probably right. It does seem a bit far-fetched that another EXE can change your variable.

                M 1 Reply Last reply
                0
                • I InOut NET

                  You're probably right. It does seem a bit far-fetched that another EXE can change your variable.

                  M Offline
                  M Offline
                  Mark Salsbery
                  wrote on last edited by
                  #8

                  InOut.NET wrote:

                  It does seem a bit far-fetched that another EXE can change your variable.

                  In Windows, yes. On other systems it's entirely possible :) Mark

                  Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the number 3

                  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