Re: Help understanding how winapi works

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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


.



Relevant Pages

  • Re: Writing and reading from a physical address
    ... If you just return the pointer to the memory you got from ... driver to read or write some registers on the hardware. ... How can I do this through a driver. ... run my complete application in kernel mode. ...
    (microsoft.public.windowsce.app.development)
  • Re: Writing and reading from a physical address
    ... MmMapIoSpaceinto my application memory. ... driver to read or write some registers on the hardware. ... How can I do this through a driver. ... run my complete application in kernel mode. ...
    (microsoft.public.windowsce.app.development)
  • Re: RTOS, Virtualization and Paging
    ... I have got a question about memory protection in kernel mode for x86 ... when paging is enabled the MMU translates every memory access ...
    (comp.arch.embedded)
  • Re: User/Kernel Mode still relevant
    ... CPU mode bit??? ... process can access unauthorised memory region of an other ... The vast majority of what we use kernel mode for could be controlled ... moving things like device drivers to user mode has been ...
    (comp.os.linux.development.system)
  • Re: Problem! Memory mapping in win2k pnp driver
    ... a kernel mode generated pointer is not accessible to a user mode ... Please do not send e-mail directly to this alias. ... > CM_RESOURCE_LIST structure we got the translated base addresses of the ... > memory we are passing the translated base address to MmMapIoSpace ...
    (microsoft.public.win32.programmer.kernel)