mirror of
https://github.com/reactos/reactos.git
synced 2024-06-30 01:42:30 +00:00
- Add check of params for VirtualAllocEx and VirtualFreeEx
- Implement GetWriteWatch (based on Wine) - Fix VirtualQueryEx svn path=/trunk/; revision=38421
This commit is contained in:
parent
c3963a9ccd
commit
3c0e179f92
|
@ -28,6 +28,12 @@ VirtualAllocEx(IN HANDLE hProcess,
|
|||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
if (lpAddress != NULL)
|
||||
{
|
||||
SetLastErrorByStatus(STATUS_INVALID_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Allocate the memory */
|
||||
Status = NtAllocateVirtualMemory(hProcess,
|
||||
(PVOID *)&lpAddress,
|
||||
|
@ -76,20 +82,26 @@ VirtualFreeEx(IN HANDLE hProcess,
|
|||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
/* Free the memory */
|
||||
Status = NtFreeVirtualMemory(hProcess,
|
||||
(PVOID *)&lpAddress,
|
||||
(PULONG)&dwSize,
|
||||
dwFreeType);
|
||||
if (!NT_SUCCESS(Status))
|
||||
if (dwSize == 0 || !(dwFreeType & MEM_RELEASE))
|
||||
{
|
||||
/* We failed */
|
||||
SetLastErrorByStatus(Status);
|
||||
return FALSE;
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/* Return success */
|
||||
return TRUE;
|
||||
SetLastErrorByStatus(STATUS_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -217,7 +229,7 @@ VirtualQueryEx(IN HANDLE hProcess,
|
|||
(LPVOID)lpAddress,
|
||||
MemoryBasicInformation,
|
||||
lpBuffer,
|
||||
sizeof(MEMORY_BASIC_INFORMATION),
|
||||
dwLength,
|
||||
&ResultLength);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -257,4 +269,37 @@ VirtualUnlock(IN LPVOID lpAddress,
|
|||
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 */
|
||||
|
|
Loading…
Reference in a new issue