Author: dchapyshev
Date: Sun Dec 28 07:03:05 2008
New Revision: 38421
URL:
http://svn.reactos.org/svn/reactos?rev=38421&view=rev
Log:
- Add check of params for VirtualAllocEx and VirtualFreeEx
- Implement GetWriteWatch (based on Wine)
- Fix VirtualQueryEx
Modified:
trunk/reactos/dll/win32/kernel32/mem/virtual.c
Modified: trunk/reactos/dll/win32/kernel32/mem/virtual.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/mem/vir…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/mem/virtual.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/mem/virtual.c [iso-8859-1] Sun Dec 28 07:03:05 2008
@@ -27,6 +27,12 @@
IN DWORD flProtect)
{
NTSTATUS Status;
+
+ if (lpAddress != NULL)
+ {
+ SetLastErrorByStatus(STATUS_INVALID_PARAMETER);
+ return NULL;
+ }
/* Allocate the memory */
Status = NtAllocateVirtualMemory(hProcess,
@@ -76,20 +82,26 @@
{
NTSTATUS Status;
- /* Free the memory */
- Status = NtFreeVirtualMemory(hProcess,
- (PVOID *)&lpAddress,
- (PULONG)&dwSize,
- dwFreeType);
- if (!NT_SUCCESS(Status))
- {
- /* We failed */
- SetLastErrorByStatus(Status);
- return FALSE;
- }
-
- /* Return success */
- return TRUE;
+ if (dwSize == 0 || !(dwFreeType & MEM_RELEASE))
+ {
+ /* Free the memory */
+ Status = NtFreeVirtualMemory(hProcess,
+ (PVOID *)&lpAddress,
+ (PULONG)&dwSize,
+ dwFreeType);
+ if (!NT_SUCCESS(Status))
+ {
+ /* We failed */
+ SetLastErrorByStatus(Status);
+ return FALSE;
+ }
+
+ /* Return success */
+ return TRUE;
+ }
+
+ SetLastErrorByStatus(STATUS_INVALID_PARAMETER);
+ return FALSE;
}
/*
@@ -217,7 +229,7 @@
(LPVOID)lpAddress,
MemoryBasicInformation,
lpBuffer,
- sizeof(MEMORY_BASIC_INFORMATION),
+ dwLength,
&ResultLength);
if (!NT_SUCCESS(Status))
{
@@ -257,4 +269,37 @@
return TRUE;
}
+/*
+ * @implemented
+ */
+UINT
+WINAPI
+GetWriteWatch(
+ DWORD dwFlags,
+ PVOID lpBaseAddress,
+ SIZE_T dwRegionSize,
+ PVOID *lpAddresses,
+ PULONG_PTR lpdwCount,
+ PULONG lpdwGranularity
+ )
+{
+ NTSTATUS Status;
+
+ Status = NtGetWriteWatch(GetCurrentProcess(),
+ dwFlags,
+ lpBaseAddress,
+ dwRegionSize,
+ lpAddresses,
+ lpdwCount,
+ lpdwGranularity);
+
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastError(RtlNtStatusToDosError(Status));
+ return -1;
+ }
+
+ return 0;
+}
+
/* EOF */