Re: Help understanding how winapi works
- From: "Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx>
- Date: Tue, 13 May 2008 14:57:21 -0500
ceh wrote:
OK, that helps.
So a given process does all it needs via user mode and kernel mode.
When it needs lower level work done, it does so in kernel mode (same
process)
Now if it needs memory allocated this happens in kernel mode (same
process)
But I thought that the memory manager was part of the running os
process (System or System Idle Process)
How does the memory allocation in my process in kernel mode talk the
the OS memory manager to actually get x new bytes allocated?
How can one process ask another process to do something by just using
some interrupt
The memory manager isn't in another process, it's a kernel mode data
structure and kernel mode code for changing it.
The data structure is in protected memory, so your app can't corrupt it.
The only way to modify it is to switch to ring 0, you can't do this without
jumping to kernel code at the same time, this way your application can never
perform a privileged instruction, but makes requests to the kernel code.
So your application executes a software interrupt, the CPU jumps into ring 0
and to the interrupt handler, which checks which OS service was requested,
looks up the code in the service vector and jumps to it. Since you asked
for the VirtualAlloc service, it will find a free virtual memory area,
allocate it, commit physical memory (if requested), set up the page tables,
store the resulting address and return from interrupt, at which time your
user-mode application continues running.
Thanks again. If I could just get 1 complete explanation of how this
works top to bottom, I'd be psyched.
And thanks again
.
- References:
- Help understanding how winapi works
- From: ceh
- Re: Help understanding how winapi works
- From: Jeroen Mostert
- Re: Help understanding how winapi works
- From: ceh
- Help understanding how winapi works
- Prev by Date: Re: Help understanding how winapi works
- Next by Date: Re: Help understanding how winapi works
- Previous by thread: Re: Help understanding how winapi works
- Next by thread: Re: Help understanding how winapi works
- Index(es):
Relevant Pages
|