Commit c749433e authored by Alexandre Julliard's avatar Alexandre Julliard

Create the system heap event before the shared mapping to avoid a race

condition.
parent 0f6af2ce
...@@ -85,8 +85,9 @@ inline static HANDLE HEAP_CreateSystemHeap(void) ...@@ -85,8 +85,9 @@ inline static HANDLE HEAP_CreateSystemHeap(void)
int created; int created;
void *base; void *base;
HANDLE map, event; HANDLE map, event;
UNICODE_STRING event_name;
OBJECT_ATTRIBUTES event_attr; /* create the system heap event first */
event = CreateEventA( NULL, TRUE, FALSE, "__SystemHeapEvent" );
if (!(map = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, SEC_COMMIT | PAGE_READWRITE, if (!(map = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, SEC_COMMIT | PAGE_READWRITE,
0, SYSTEM_HEAP_SIZE, "__SystemHeap" ))) return 0; 0, SYSTEM_HEAP_SIZE, "__SystemHeap" ))) return 0;
...@@ -99,21 +100,11 @@ inline static HANDLE HEAP_CreateSystemHeap(void) ...@@ -99,21 +100,11 @@ inline static HANDLE HEAP_CreateSystemHeap(void)
return 0; return 0;
} }
/* create the system heap event */
RtlCreateUnicodeStringFromAsciiz( &event_name, "__SystemHeapEvent" );
event_attr.Length = sizeof(event_attr);
event_attr.RootDirectory = 0;
event_attr.ObjectName = &event_name;
event_attr.Attributes = 0;
event_attr.SecurityDescriptor = NULL;
event_attr.SecurityQualityOfService = NULL;
NtCreateEvent( &event, EVENT_ALL_ACCESS, &event_attr, TRUE, FALSE );
if (created) /* newly created heap */ if (created) /* newly created heap */
{ {
systemHeap = RtlCreateHeap( HEAP_SHARED, base, SYSTEM_HEAP_SIZE, systemHeap = RtlCreateHeap( HEAP_SHARED, base, SYSTEM_HEAP_SIZE,
SYSTEM_HEAP_SIZE, NULL, NULL ); SYSTEM_HEAP_SIZE, NULL, NULL );
NtSetEvent( event, NULL ); SetEvent( event );
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment