Handles and Pointers
-
- 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.
-
- 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.
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
-
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
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.
-
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.
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
-
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
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.
-
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.
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
-
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
-
You're probably right. It does seem a bit far-fetched that another EXE can change your variable.
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