mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 17:52:56 +00:00
* Took an intelligent guess at NtLockVirtualMemory and NtUnlockVirtualMemory and attempted to implement them, but they're most likely *wrong*. Shouldn't break anything already though.
svn path=/trunk/; revision=5698
This commit is contained in:
parent
bcefe84d60
commit
1dbf9b9981
1 changed files with 75 additions and 4 deletions
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: virtual.c,v 1.69 2003/08/14 10:40:51 ekohl Exp $
|
/* $Id: virtual.c,v 1.70 2003/08/20 10:37:33 silverblade Exp $
|
||||||
*
|
*
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/mm/virtual.c
|
* FILE: ntoskrnl/mm/virtual.c
|
||||||
|
@ -62,9 +62,43 @@ NTSTATUS STDCALL
|
||||||
NtLockVirtualMemory(HANDLE ProcessHandle,
|
NtLockVirtualMemory(HANDLE ProcessHandle,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
ULONG NumberOfBytesToLock,
|
ULONG NumberOfBytesToLock,
|
||||||
PULONG NumberOfBytesLocked)
|
PULONG NumberOfBytesLocked) // ULONG LockOption?
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
// AG [08-20-03] : I have *no* idea if this is correct, I just used the
|
||||||
|
// other functions as a template and made a few intelligent guesses...
|
||||||
|
|
||||||
|
NTSTATUS Status;
|
||||||
|
PMDL Mdl;
|
||||||
|
PEPROCESS Process;
|
||||||
|
|
||||||
|
DPRINT("NtLockVirtualMemory(ProcessHandle %x, BaseAddress %x, "
|
||||||
|
"NumberOfBytesToLock %d), NumberOfBytesLocked %x\n",ProcessHandle,BaseAddress,
|
||||||
|
NumberOfBytesToLock, NumberOfBytesLocked);
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
|
PROCESS_VM_WRITE,
|
||||||
|
NULL,
|
||||||
|
UserMode,
|
||||||
|
(PVOID*)(&Process),
|
||||||
|
NULL);
|
||||||
|
if (Status != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
Mdl = MmCreateMdl(NULL,
|
||||||
|
BaseAddress,
|
||||||
|
NumberOfBytesToLock);
|
||||||
|
MmProbeAndLockPages(Mdl,
|
||||||
|
UserMode,
|
||||||
|
IoWriteAccess);
|
||||||
|
|
||||||
|
ExFreePool(Mdl); // Are we supposed to do this here?
|
||||||
|
|
||||||
|
ObDereferenceObject(Process);
|
||||||
|
|
||||||
|
*NumberOfBytesLocked = NumberOfBytesToLock;
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
|
@ -285,7 +319,44 @@ NtUnlockVirtualMemory(HANDLE ProcessHandle,
|
||||||
ULONG NumberOfBytesToUnlock,
|
ULONG NumberOfBytesToUnlock,
|
||||||
PULONG NumberOfBytesUnlocked OPTIONAL)
|
PULONG NumberOfBytesUnlocked OPTIONAL)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
// AG [08-20-03] : I have *no* idea if this is correct, I just used the
|
||||||
|
// other functions as a template and made a few intelligent guesses...
|
||||||
|
|
||||||
|
NTSTATUS Status;
|
||||||
|
PMDL Mdl;
|
||||||
|
PEPROCESS Process;
|
||||||
|
|
||||||
|
DPRINT("NtUnlockVirtualMemory(ProcessHandle %x, BaseAddress %x, "
|
||||||
|
"NumberOfBytesToUnlock %d), NumberOfBytesUnlocked %x\n",ProcessHandle,BaseAddress,
|
||||||
|
NumberOfBytesToUnlock, NumberOfBytesUnlocked);
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
|
PROCESS_VM_WRITE,
|
||||||
|
NULL,
|
||||||
|
UserMode,
|
||||||
|
(PVOID*)(&Process),
|
||||||
|
NULL);
|
||||||
|
if (Status != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
Mdl = MmCreateMdl(NULL,
|
||||||
|
BaseAddress,
|
||||||
|
NumberOfBytesToUnlock);
|
||||||
|
|
||||||
|
ObDereferenceObject(Process);
|
||||||
|
|
||||||
|
if (Mdl->MappedSystemVa != NULL)
|
||||||
|
{
|
||||||
|
MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);
|
||||||
|
}
|
||||||
|
MmUnlockPages(Mdl);
|
||||||
|
ExFreePool(Mdl);
|
||||||
|
|
||||||
|
*NumberOfBytesUnlocked = NumberOfBytesToUnlock;
|
||||||
|
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue