minor fixes

svn path=/trunk/; revision=11415
This commit is contained in:
Thomas Bluemel 2004-10-24 12:55:19 +00:00
parent 6003c5cb06
commit cb1bf2ae32
2 changed files with 47 additions and 32 deletions

View file

@ -1,4 +1,4 @@
/* $Id: resnotify.c,v 1.1 2004/09/21 19:17:26 weiden Exp $
/* $Id: resnotify.c,v 1.2 2004/10/24 12:55:19 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -45,12 +45,11 @@ CreateMemoryResourceNotification(
return NULL;
}
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = hBaseDir;
ObjectAttributes.ObjectName = &EventName;
ObjectAttributes.Attributes = 0;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL;
InitializeObjectAttributes(&ObjectAttributes,
&EventName,
0,
hBaseDir,
NULL);
Status = NtOpenEvent(&hEvent,
EVENT_QUERY_STATE | SYNCHRONIZE,
@ -76,7 +75,6 @@ QueryMemoryResourceNotification(
)
{
EVENT_BASIC_INFORMATION ebi;
ULONG RetLen;
NTSTATUS Status;
if(ResourceState != NULL)
@ -85,7 +83,7 @@ QueryMemoryResourceNotification(
EventBasicInformation,
&ebi,
sizeof(ebi),
&RetLen);
NULL);
if(NT_SUCCESS(Status))
{
*ResourceState = ebi.EventState;

View file

@ -1,4 +1,4 @@
/* $Id: section.c,v 1.26 2004/08/28 22:16:27 navaraf Exp $
/* $Id: section.c,v 1.27 2004/10/24 12:55:19 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -64,24 +64,34 @@ CreateFileMappingA(HANDLE hFile,
MaximumSize.u.HighPart = dwMaximumSizeHigh;
MaximumSizePointer = &MaximumSize;
}
RtlInitAnsiString(&AnsiName,
(LPSTR)lpName);
RtlAnsiStringToUnicodeString(&UnicodeName,
&AnsiName,
TRUE);
if (lpName != NULL)
{
RtlInitAnsiString(&AnsiName,
(LPSTR)lpName);
RtlAnsiStringToUnicodeString(&UnicodeName,
&AnsiName,
TRUE);
}
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeName,
(lpName ? &UnicodeName : NULL),
0,
hBaseDir,
SecurityDescriptor);
Status = NtCreateSection(&SectionHandle,
SECTION_ALL_ACCESS,
&ObjectAttributes,
MaximumSizePointer,
flProtect & MASK_PAGE_FLAGS,
flProtect & MASK_SEC_FLAGS,
hFile==INVALID_HANDLE_VALUE ? NULL : hFile);
RtlFreeUnicodeString(&UnicodeName);
((hFile != INVALID_HANDLE_VALUE) ? hFile : NULL));
if (lpName != NULL)
{
RtlFreeUnicodeString(&UnicodeName);
}
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
@ -135,20 +145,26 @@ CreateFileMappingW(HANDLE hFile,
MaximumSize.u.HighPart = dwMaximumSizeHigh;
MaximumSizePointer = &MaximumSize;
}
RtlInitUnicodeString(&UnicodeName,
lpName);
if (lpName != NULL)
{
RtlInitUnicodeString(&UnicodeName,
lpName);
}
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeName,
(lpName ? &UnicodeName : NULL),
0,
hBaseDir,
SecurityDescriptor);
Status = NtCreateSection(&SectionHandle,
SECTION_ALL_ACCESS,
&ObjectAttributes,
MaximumSizePointer,
flProtect & MASK_PAGE_FLAGS,
flProtect & MASK_SEC_FLAGS,
hFile==INVALID_HANDLE_VALUE ? NULL : hFile);
((hFile != INVALID_HANDLE_VALUE) ? hFile : NULL));
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
@ -270,12 +286,11 @@ OpenFileMappingA(DWORD dwDesiredAccess,
OBJECT_ATTRIBUTES ObjectAttributes;
ANSI_STRING AnsiName;
UNICODE_STRING UnicodeName;
ULONG Attributes = 0;
if (bInheritHandle)
if (lpName == NULL)
{
Attributes = OBJ_INHERIT;
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
RtlInitAnsiString(&AnsiName,
@ -286,7 +301,7 @@ OpenFileMappingA(DWORD dwDesiredAccess,
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeName,
Attributes,
(bInheritHandle ? OBJ_INHERIT : 0),
hBaseDir,
NULL);
Status = NtOpenSection(&SectionHandle,
@ -298,6 +313,7 @@ OpenFileMappingA(DWORD dwDesiredAccess,
SetLastErrorByStatus (Status);
return NULL;
}
return SectionHandle;
}
@ -314,18 +330,18 @@ OpenFileMappingW(DWORD dwDesiredAccess,
HANDLE SectionHandle;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING UnicodeName;
ULONG Attributes = 0;
if (bInheritHandle)
if (lpName == NULL)
{
Attributes = OBJ_INHERIT;
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
RtlInitUnicodeString(&UnicodeName,
lpName);
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeName,
Attributes,
(bInheritHandle ? OBJ_INHERIT : 0),
hBaseDir,
NULL);
Status = ZwOpenSection(&SectionHandle,
@ -336,6 +352,7 @@ OpenFileMappingW(DWORD dwDesiredAccess,
SetLastErrorByStatus(Status);
return NULL;
}
return SectionHandle;
}