-/* $Id: heap.c,v 1.17 2001/02/17 00:01:26 ekohl Exp $
+/* $Id: heap.c,v 1.18 2001/02/17 17:42:46 ekohl Exp $
*
* kernel/heap.c
* Copyright (C) 1996, Onno Hovers, All rights reserved
/********************************************************************
* GetProcessHeaps -- KERNEL32 *
-* *
-* NOTE in Win95 this function is not implemented and just returns *
-* ERROR_CALL_NOT_IMPLEMENTED *
********************************************************************/
DWORD WINAPI GetProcessHeaps(DWORD maxheaps, PHANDLE phandles )
{
- UNIMPLEMENTED;
- return(ERROR_CALL_NOT_IMPLEMENTED);
+ return(RtlGetProcessHeaps(maxheaps, phandles));
}
/*********************************************************************
* NT uses this function to compact moveable blocks and other things *
* Here it does not compact, but it finds the largest free region *
*********************************************************************/
-UINT STDCALL
-HeapCompact(HANDLE hheap,
- DWORD flags)
+UINT WINAPI HeapCompact(HANDLE hheap, DWORD flags)
{
return RtlCompactHeap(hheap, flags);
}
/*********************************************************************
* HeapValidate -- KERNEL32 *
-* *
-* NOTE: only implemented in NT *
*********************************************************************/
BOOL WINAPI HeapValidate(HANDLE hheap, DWORD flags, LPCVOID pmem)
{
-/* $Id: section.c,v 1.12 2000/07/01 17:07:00 ea Exp $
+/* $Id: section.c,v 1.13 2001/02/17 17:42:46 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#include <kernel32/error.h>
#include <windows.h>
+#include <kernel32/kernel32.h>
+
/* FUNCTIONS *****************************************************************/
-HANDLE STDCALL CreateFileMappingA (
- HANDLE hFile,
- LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
- DWORD flProtect,
- DWORD dwMaximumSizeHigh,
- DWORD dwMaximumSizeLow,
- LPCSTR lpName
- )
+HANDLE STDCALL
+CreateFileMappingA(HANDLE hFile,
+ LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
+ DWORD flProtect,
+ DWORD dwMaximumSizeHigh,
+ DWORD dwMaximumSizeLow,
+ LPCSTR lpName)
{
NTSTATUS Status;
HANDLE SectionHandle;
MaximumSize.u.LowPart = dwMaximumSizeLow;
MaximumSize.u.HighPart = dwMaximumSizeHigh;
- RtlInitAnsiString(&AnsiName, (LPSTR)lpName);
- RtlAnsiStringToUnicodeString(&UnicodeName, &AnsiName, TRUE);
+ RtlInitAnsiString(&AnsiName,
+ (LPSTR)lpName);
+ RtlAnsiStringToUnicodeString(&UnicodeName,
+ &AnsiName,
+ TRUE);
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeName,
0,
- NULL,
+ hBaseDir,
SecurityDescriptor);
Status = NtCreateSection(&SectionHandle,
SECTION_ALL_ACCESS,
flProtect,
0,
hFile);
- RtlFreeUnicodeString (&UnicodeName);
+ RtlFreeUnicodeString(&UnicodeName);
if (!NT_SUCCESS(Status))
{
- SetLastErrorByStatus (Status);
+ SetLastErrorByStatus(Status);
return NULL;
}
-
return SectionHandle;
}
-HANDLE
-STDCALL
-CreateFileMappingW (
- HANDLE hFile,
- LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
- DWORD flProtect,
- DWORD dwMaximumSizeHigh,
- DWORD dwMaximumSizeLow,
- LPCWSTR lpName
- )
+HANDLE STDCALL
+CreateFileMappingW(HANDLE hFile,
+ LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
+ DWORD flProtect,
+ DWORD dwMaximumSizeHigh,
+ DWORD dwMaximumSizeLow,
+ LPCWSTR lpName)
{
NTSTATUS Status;
HANDLE SectionHandle;
MaximumSize.u.LowPart = dwMaximumSizeLow;
MaximumSize.u.HighPart = dwMaximumSizeHigh;
- RtlInitUnicodeString(&UnicodeName, lpName);
+ RtlInitUnicodeString(&UnicodeName,
+ lpName);
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeName,
0,
- NULL,
+ hBaseDir,
SecurityDescriptor);
Status = NtCreateSection(&SectionHandle,
SECTION_ALL_ACCESS,
hFile);
if (!NT_SUCCESS(Status))
{
- SetLastErrorByStatus (Status);
+ SetLastErrorByStatus(Status);
return NULL;
}
-
return SectionHandle;
}
-LPVOID STDCALL MapViewOfFileEx(HANDLE hFileMappingObject,
- DWORD dwDesiredAccess,
- DWORD dwFileOffsetHigh,
- DWORD dwFileOffsetLow,
- DWORD dwNumberOfBytesToMap,
- LPVOID lpBaseAddress)
+LPVOID STDCALL
+MapViewOfFileEx(HANDLE hFileMappingObject,
+ DWORD dwDesiredAccess,
+ DWORD dwFileOffsetHigh,
+ DWORD dwFileOffsetLow,
+ DWORD dwNumberOfBytesToMap,
+ LPVOID lpBaseAddress)
{
NTSTATUS Status;
LARGE_INTEGER SectionOffset;
}
Status = ZwMapViewOfSection(hFileMappingObject,
- NtCurrentProcess(),
- &BaseAddress,
- 0,
- dwNumberOfBytesToMap,
- &SectionOffset,
- &ViewSize,
- ViewShare,
- 0,
- Protect);
-
- if (!NT_SUCCESS(Status))
- {
- SetLastErrorByStatus (Status);
- return NULL;
- }
-
- return BaseAddress;
+ NtCurrentProcess(),
+ &BaseAddress,
+ 0,
+ dwNumberOfBytesToMap,
+ &SectionOffset,
+ &ViewSize,
+ ViewShare,
+ 0,
+ Protect);
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastErrorByStatus(Status);
+ return NULL;
+ }
+ return BaseAddress;
}
-LPVOID
-STDCALL
-MapViewOfFile (
- HANDLE hFileMappingObject,
- DWORD dwDesiredAccess,
- DWORD dwFileOffsetHigh,
- DWORD dwFileOffsetLow,
- DWORD dwNumberOfBytesToMap
- )
+
+LPVOID STDCALL
+MapViewOfFile(HANDLE hFileMappingObject,
+ DWORD dwDesiredAccess,
+ DWORD dwFileOffsetHigh,
+ DWORD dwFileOffsetLow,
+ DWORD dwNumberOfBytesToMap)
{
- return MapViewOfFileEx(hFileMappingObject,dwDesiredAccess,
- dwFileOffsetHigh, dwFileOffsetLow, dwNumberOfBytesToMap,NULL);
+ return MapViewOfFileEx(hFileMappingObject,
+ dwDesiredAccess,
+ dwFileOffsetHigh,
+ dwFileOffsetLow,
+ dwNumberOfBytesToMap,
+ NULL);
}
-WINBOOL
-STDCALL
-UnmapViewOfFile (
- LPVOID lpBaseAddress
- )
+WINBOOL STDCALL
+UnmapViewOfFile(LPVOID lpBaseAddress)
{
- NTSTATUS Status;
- Status = NtUnmapViewOfSection(NtCurrentProcess(),lpBaseAddress);
-
- if (!NT_SUCCESS(Status))
- {
- SetLastErrorByStatus (Status);
- return FALSE;
- }
-
- return TRUE;
+ NTSTATUS Status;
+
+ Status = NtUnmapViewOfSection(NtCurrentProcess(),
+ lpBaseAddress);
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastErrorByStatus(Status);
+ return FALSE;
+ }
+ return TRUE;
}
-HANDLE
-STDCALL
-OpenFileMappingA (
- DWORD dwDesiredAccess,
- WINBOOL bInheritHandle,
- LPCSTR lpName
- )
+HANDLE STDCALL
+OpenFileMappingA(DWORD dwDesiredAccess,
+ WINBOOL bInheritHandle,
+ LPCSTR lpName)
{
NTSTATUS Status;
HANDLE SectionHandle;
ULONG Attributes = 0;
- if ( bInheritHandle )
- Attributes = OBJ_INHERIT;
+ if (bInheritHandle)
+ {
+ Attributes = OBJ_INHERIT;
+ }
- RtlInitAnsiString(&AnsiName, (LPSTR)lpName);
- RtlAnsiStringToUnicodeString(&UnicodeName, &AnsiName, TRUE);
+ RtlInitAnsiString(&AnsiName,
+ (LPSTR)lpName);
+ RtlAnsiStringToUnicodeString(&UnicodeName,
+ &AnsiName,
+ TRUE);
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeName,
Attributes,
- NULL,
+ hBaseDir,
NULL);
Status = NtOpenSection(&SectionHandle,
SECTION_ALL_ACCESS,
- &ObjectAttributes
- );
- RtlFreeUnicodeString (&UnicodeName);
- if (!NT_SUCCESS(Status))
- {
- SetLastErrorByStatus (Status);
- return NULL;
- }
-
- return SectionHandle;
+ &ObjectAttributes);
+ RtlFreeUnicodeString (&UnicodeName);
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastErrorByStatus (Status);
+ return NULL;
+ }
+ return SectionHandle;
}
-HANDLE
-STDCALL
-OpenFileMappingW (
- DWORD dwDesiredAccess,
- WINBOOL bInheritHandle,
- LPCWSTR lpName
- )
+HANDLE STDCALL
+OpenFileMappingW(DWORD dwDesiredAccess,
+ WINBOOL bInheritHandle,
+ LPCWSTR lpName)
{
NTSTATUS Status;
HANDLE SectionHandle;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING UnicodeName;
-
ULONG Attributes = 0;
- if ( bInheritHandle )
- Attributes = OBJ_INHERIT;
+ if (bInheritHandle)
+ {
+ Attributes = OBJ_INHERIT;
+ }
- RtlInitUnicodeString(&UnicodeName, lpName);
+ RtlInitUnicodeString(&UnicodeName,
+ lpName);
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeName,
Attributes,
- NULL,
+ hBaseDir,
NULL);
Status = ZwOpenSection(&SectionHandle,
SECTION_ALL_ACCESS,
&ObjectAttributes);
- if (!NT_SUCCESS(Status))
- {
- SetLastErrorByStatus (Status);
- return NULL;
- }
-
- return SectionHandle;
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastErrorByStatus(Status);
+ return NULL;
+ }
+ return SectionHandle;
}
-WINBOOL
-STDCALL
-FlushViewOfFile (
- LPCVOID lpBaseAddress,
- DWORD dwNumberOfBytesToFlush
- )
+
+WINBOOL STDCALL
+FlushViewOfFile(LPCVOID lpBaseAddress,
+ DWORD dwNumberOfBytesToFlush)
{
- NTSTATUS Status;
- ULONG NumberOfBytesFlushed;
-
- Status = NtFlushVirtualMemory (NtCurrentProcess (),
- (LPVOID)lpBaseAddress,
- dwNumberOfBytesToFlush,
- &NumberOfBytesFlushed);
-
- if (!NT_SUCCESS(Status))
- {
- SetLastErrorByStatus (Status);
- return FALSE;
- }
- return TRUE;
+ NTSTATUS Status;
+ ULONG NumberOfBytesFlushed;
+
+ Status = NtFlushVirtualMemory(NtCurrentProcess(),
+ (LPVOID)lpBaseAddress,
+ dwNumberOfBytesToFlush,
+ &NumberOfBytesFlushed);
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastErrorByStatus(Status);
+ return FALSE;
+ }
+ return TRUE;
}
/* EOF */