mirror of
https://github.com/reactos/reactos.git
synced 2024-09-30 22:47:28 +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;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
if (lpAddress != NULL)
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(STATUS_INVALID_PARAMETER);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocate the memory */
|
/* Allocate the memory */
|
||||||
Status = NtAllocateVirtualMemory(hProcess,
|
Status = NtAllocateVirtualMemory(hProcess,
|
||||||
(PVOID *)&lpAddress,
|
(PVOID *)&lpAddress,
|
||||||
|
@ -76,20 +82,26 @@ VirtualFreeEx(IN HANDLE hProcess,
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
/* Free the memory */
|
if (dwSize == 0 || !(dwFreeType & MEM_RELEASE))
|
||||||
Status = NtFreeVirtualMemory(hProcess,
|
|
||||||
(PVOID *)&lpAddress,
|
|
||||||
(PULONG)&dwSize,
|
|
||||||
dwFreeType);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
/* We failed */
|
/* Free the memory */
|
||||||
SetLastErrorByStatus(Status);
|
Status = NtFreeVirtualMemory(hProcess,
|
||||||
return FALSE;
|
(PVOID *)&lpAddress,
|
||||||
|
(PULONG)&dwSize,
|
||||||
|
dwFreeType);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* We failed */
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return success */
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return success */
|
SetLastErrorByStatus(STATUS_INVALID_PARAMETER);
|
||||||
return TRUE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -217,7 +229,7 @@ VirtualQueryEx(IN HANDLE hProcess,
|
||||||
(LPVOID)lpAddress,
|
(LPVOID)lpAddress,
|
||||||
MemoryBasicInformation,
|
MemoryBasicInformation,
|
||||||
lpBuffer,
|
lpBuffer,
|
||||||
sizeof(MEMORY_BASIC_INFORMATION),
|
dwLength,
|
||||||
&ResultLength);
|
&ResultLength);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -257,4 +269,37 @@ VirtualUnlock(IN LPVOID lpAddress,
|
||||||
return TRUE;
|
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 */
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue