Re: about CeSafeCopyMemory in CE 6

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



I believe (without checking) that this just wraps the copy with a try/except
handler. It does not do memory marshalling.

If the call is being done synchronously, the kernel already can access the
address in user memory (assuming it is a validly mapped address). In this
particular scenario the marshalling APIs just give you the ability to verify
the pointer, and give you the option to copy it to your own buffer if you
like.

If you'll be accessing the pointer asynchronously (on another thread) then
you have to marshall in order to get your own copy of the pointer that will
still be valid after a process switch.

The kernel operates in the upper 2G of address space. The user process is
in the lower 2G. When a kernel thread is running, the user space in the
lower 2G is still valid so a user mode pointer coming from that space is
still accessible. This works because the kernel mode thread is allowed to
access the user mode space. The reverse is not true, the user mode thread
can't access the kernel mode space even though it is mapped in.

--
Dean Ramsier - eMVP
BSQUARE Corporation


<ctbpl.xiayi@xxxxxxxxx> wrote in message
news:1189405411.889811.104780@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi All,

Will CeSafeCopyMemory do the memory marshalling when I call it in my
kernel mode driver to access memory pointed by a embedded user space
pointer?

What's the biggest downside if I directly access the memory pointed by
an user space pointer except the security problem? Will the kernel
help to do the memory mapping(page table setup to access the same
physical memory) or copy it into kernel space memory when a user
space' pointer parameter is passed into kernel space?

When process switch to kernel mode , is the page table of user space's
current application will be copied into the kernel mode process's page
table?

I searched CeSafeCopyMemory in google, and found very few matches. Can
anyone give me some instructions?

Max.



.



Relevant Pages

  • Re: NativeOverlapped, does it work??
    ... You need to keep that fixed in memory, and if you are using a fixed statement the memory location of the structure is subject to change. ... Instead, I would pin the structure (and then get the unsafe pointer to the structure), or marshal it to unmanaged memory, where you can hold onto the pointer for the life of the call. ... I'm trying to read some messages from a kernel mode mini-filter driver. ...
    (microsoft.public.dotnet.languages.csharp)
  • about CeSafeCopyMemory in CE 6
    ... Will CeSafeCopyMemory do the memory marshalling when I call it in my ... kernel mode driver to access memory pointed by a embedded user space ... an user space pointer except the security problem? ... When process switch to kernel mode, is the page table of user space's ...
    (microsoft.public.windowsce.platbuilder)
  • Re: How to map user spaces virtual memory into kernel logical address space
    ... It passes this pointer to the kernel (device driver) via an custom ... Is there a way to map a user space's virtual memory range into the ...
    (Linux-Kernel)
  • Re: Why system call need to copy the date from the userspace before using it
    ... > user space to kernel space before using it. ... to access user memory using specific accessors, like copy_to/from_user, ... - Userland can give you a bogus pointer. ...
    (Linux-Kernel)
  • Re: Win2K Server and 4GB memory
    ... Umm - the amount of RAM used by the kernel/shared memory will not be 2GB. ... GB of the 4 GB Virtual Address Space is used for pageable kernel and shared ... > shift 1 GB from Kernel mode and make it avaiable to the user mode. ...
    (microsoft.public.win2000.general)