4 * Copyright 1996 Alexandre Julliard
5 * Copyright 1998 Ulrich Weigand
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #define NONAMELESSUNION
30 #define NONAMELESSSTRUCT
32 #include "wine/winbase16.h"
36 #include "wine/unicode.h"
37 #include "selectors.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(heap
);
45 /* address where we try to map the system heap */
46 #define SYSTEM_HEAP_BASE ((void*)0x65430000)
47 #define SYSTEM_HEAP_SIZE 0x100000 /* Default heap size = 1Mb */
50 #define HTABLE_SIZE 0x10000
51 #define HTABLE_PAGESIZE 0x1000
52 #define HTABLE_NPAGES (HTABLE_SIZE / HTABLE_PAGESIZE)
55 typedef struct _LOCAL32HEADER
57 WORD freeListFirst
[HTABLE_NPAGES
];
58 WORD freeListSize
[HTABLE_NPAGES
];
59 WORD freeListLast
[HTABLE_NPAGES
];
61 DWORD selectorTableOffset
;
62 WORD selectorTableSize
;
77 #define LOCAL32_MAGIC ((DWORD)('L' | ('H'<<8) | ('3'<<16) | ('2'<<24)))
79 static HANDLE systemHeap
; /* globally shared heap */
81 /***********************************************************************
82 * HEAP_CreateSystemHeap
84 * Create the system heap.
86 inline static HANDLE
HEAP_CreateSystemHeap(void)
91 UNICODE_STRING event_name
;
92 OBJECT_ATTRIBUTES event_attr
;
94 if (!(map
= CreateFileMappingA( INVALID_HANDLE_VALUE
, NULL
, SEC_COMMIT
| PAGE_READWRITE
,
95 0, SYSTEM_HEAP_SIZE
, "__SystemHeap" ))) return 0;
96 created
= (GetLastError() != ERROR_ALREADY_EXISTS
);
98 if (!(base
= MapViewOfFileEx( map
, FILE_MAP_ALL_ACCESS
, 0, 0, 0, SYSTEM_HEAP_BASE
)))
100 /* pre-defined address not available */
101 ERR( "system heap base address %p not available\n", SYSTEM_HEAP_BASE
);
105 /* create the system heap event */
106 RtlCreateUnicodeStringFromAsciiz( &event_name
, "__SystemHeapEvent" );
107 event_attr
.Length
= sizeof(event_attr
);
108 event_attr
.RootDirectory
= 0;
109 event_attr
.ObjectName
= &event_name
;
110 event_attr
.Attributes
= 0;
111 event_attr
.SecurityDescriptor
= NULL
;
112 event_attr
.SecurityQualityOfService
= NULL
;
113 NtCreateEvent( &event
, EVENT_ALL_ACCESS
, &event_attr
, TRUE
, FALSE
);
115 if (created
) /* newly created heap */
117 systemHeap
= RtlCreateHeap( HEAP_SHARED
, base
, SYSTEM_HEAP_SIZE
,
118 SYSTEM_HEAP_SIZE
, NULL
, NULL
);
119 NtSetEvent( event
, NULL
);
123 /* wait for the heap to be initialized */
124 WaitForSingleObject( event
, INFINITE
);
125 systemHeap
= (HANDLE
)base
;
132 /***********************************************************************
133 * HeapCreate (KERNEL32.@)
135 * Handle of heap: Success
138 HANDLE WINAPI
HeapCreate(
139 DWORD flags
, /* [in] Heap allocation flag */
140 SIZE_T initialSize
, /* [in] Initial heap size */
141 SIZE_T maxSize
/* [in] Maximum heap size */
145 if ( flags
& HEAP_SHARED
)
147 if (!systemHeap
) HEAP_CreateSystemHeap();
148 else WARN( "Shared Heap requested, returning system heap.\n" );
153 ret
= RtlCreateHeap( flags
, NULL
, maxSize
, initialSize
, NULL
, NULL
);
154 if (!ret
) SetLastError( ERROR_NOT_ENOUGH_MEMORY
);
159 /***********************************************************************
160 * HeapDestroy (KERNEL32.@)
165 BOOL WINAPI
HeapDestroy( HANDLE heap
/* [in] Handle of heap */ )
167 if (heap
== systemHeap
)
169 WARN( "attempt to destroy system heap, returning TRUE!\n" );
172 if (!RtlDestroyHeap( heap
)) return TRUE
;
173 SetLastError( ERROR_INVALID_HANDLE
);
178 /***********************************************************************
179 * HeapCompact (KERNEL32.@)
181 SIZE_T WINAPI
HeapCompact( HANDLE heap
, DWORD flags
)
183 return RtlCompactHeap( heap
, flags
);
187 /***********************************************************************
188 * HeapLock (KERNEL32.@)
189 * Attempts to acquire the critical section object for a specified heap.
195 BOOL WINAPI
HeapLock(
196 HANDLE heap
/* [in] Handle of heap to lock for exclusive access */
198 return RtlLockHeap( heap
);
202 /***********************************************************************
203 * HeapUnlock (KERNEL32.@)
204 * Releases ownership of the critical section object.
210 BOOL WINAPI
HeapUnlock(
211 HANDLE heap
/* [in] Handle to the heap to unlock */
213 return RtlUnlockHeap( heap
);
217 /***********************************************************************
218 * HeapValidate (KERNEL32.@)
219 * Validates a specified heap.
228 BOOL WINAPI
HeapValidate(
229 HANDLE heap
, /* [in] Handle to the heap */
230 DWORD flags
, /* [in] Bit flags that control access during operation */
231 LPCVOID block
/* [in] Optional pointer to memory block to validate */
233 return RtlValidateHeap( heap
, flags
, block
);
237 /***********************************************************************
238 * HeapWalk (KERNEL32.@)
239 * Enumerates the memory blocks in a specified heap.
242 * - handling of PROCESS_HEAP_ENTRY_MOVEABLE and
243 * PROCESS_HEAP_ENTRY_DDESHARE (needs heap.c support)
249 BOOL WINAPI
HeapWalk(
250 HANDLE heap
, /* [in] Handle to heap to enumerate */
251 LPPROCESS_HEAP_ENTRY entry
/* [out] Pointer to structure of enumeration info */
253 NTSTATUS ret
= RtlWalkHeap( heap
, entry
);
254 if (ret
) SetLastError( RtlNtStatusToDosError(ret
) );
259 /***********************************************************************
260 * GetProcessHeap (KERNEL32.@)
262 HANDLE WINAPI
GetProcessHeap(void)
264 HANDLE
*pdb
= (HANDLE
*)NtCurrentTeb()->process
;
265 return pdb
[0x18 / sizeof(HANDLE
)]; /* get dword at offset 0x18 in pdb */
269 /***********************************************************************
270 * GetProcessHeaps (KERNEL32.@)
272 DWORD WINAPI
GetProcessHeaps( DWORD count
, HANDLE
*heaps
)
274 return RtlGetProcessHeaps( count
, heaps
);
278 /***********************************************************************
279 * 32-bit local heap functions (Win95; undocumented)
282 /***********************************************************************
285 HANDLE WINAPI
Local32Init16( WORD segment
, DWORD tableSize
,
286 DWORD heapSize
, DWORD flags
)
288 DWORD totSize
, segSize
= 0;
290 LOCAL32HEADER
*header
;
293 WORD selectorEven
, selectorOdd
;
296 /* Determine new heap size */
300 if ( (segSize
= GetSelectorLimit16( segment
)) == 0 )
306 if ( heapSize
== -1L )
307 heapSize
= 1024L*1024L; /* FIXME */
309 heapSize
= (heapSize
+ 0xffff) & 0xffff0000;
310 segSize
= (segSize
+ 0x0fff) & 0xfffff000;
311 totSize
= segSize
+ HTABLE_SIZE
+ heapSize
;
314 /* Allocate memory and initialize heap */
316 if ( !(base
= VirtualAlloc( NULL
, totSize
, MEM_RESERVE
, PAGE_READWRITE
)) )
319 if ( !VirtualAlloc( base
, segSize
+ HTABLE_PAGESIZE
,
320 MEM_COMMIT
, PAGE_READWRITE
) )
322 VirtualFree( base
, 0, MEM_RELEASE
);
326 if (!(heap
= RtlCreateHeap( 0, base
+ segSize
+ HTABLE_SIZE
, heapSize
, 0x10000, NULL
, NULL
)))
328 VirtualFree( base
, 0, MEM_RELEASE
);
333 /* Set up header and handle table */
335 header
= (LOCAL32HEADER
*)(base
+ segSize
);
337 header
->limit
= HTABLE_PAGESIZE
-1;
339 header
->magic
= LOCAL32_MAGIC
;
342 header
->freeListFirst
[0] = sizeof(LOCAL32HEADER
);
343 header
->freeListLast
[0] = HTABLE_PAGESIZE
- 4;
344 header
->freeListSize
[0] = (HTABLE_PAGESIZE
- sizeof(LOCAL32HEADER
)) / 4;
346 for (i
= header
->freeListFirst
[0]; i
< header
->freeListLast
[0]; i
+= 4)
347 *(DWORD
*)((LPBYTE
)header
+ i
) = i
+4;
349 header
->freeListFirst
[1] = 0xffff;
352 /* Set up selector table */
354 nrBlocks
= (totSize
+ 0x7fff) >> 15;
355 selectorTable
= (LPWORD
) HeapAlloc( header
->heap
, 0, nrBlocks
* 2 );
356 selectorEven
= SELECTOR_AllocBlock( base
, totSize
, WINE_LDT_FLAGS_DATA
);
357 selectorOdd
= SELECTOR_AllocBlock( base
+ 0x8000, totSize
- 0x8000, WINE_LDT_FLAGS_DATA
);
358 if ( !selectorTable
|| !selectorEven
|| !selectorOdd
)
360 if ( selectorTable
) HeapFree( header
->heap
, 0, selectorTable
);
361 if ( selectorEven
) SELECTOR_FreeBlock( selectorEven
);
362 if ( selectorOdd
) SELECTOR_FreeBlock( selectorOdd
);
363 HeapDestroy( header
->heap
);
364 VirtualFree( base
, 0, MEM_RELEASE
);
368 header
->selectorTableOffset
= (LPBYTE
)selectorTable
- header
->base
;
369 header
->selectorTableSize
= nrBlocks
* 4; /* ??? Win95 does it this way! */
370 header
->selectorDelta
= selectorEven
- selectorOdd
;
371 header
->segment
= segment
? segment
: selectorEven
;
373 for (i
= 0; i
< nrBlocks
; i
++)
374 selectorTable
[i
] = (i
& 1)? selectorOdd
+ ((i
>> 1) << __AHSHIFT
)
375 : selectorEven
+ ((i
>> 1) << __AHSHIFT
);
377 /* Move old segment */
381 /* FIXME: This is somewhat ugly and relies on implementation
382 details about 16-bit global memory handles ... */
384 LPBYTE oldBase
= (LPBYTE
)GetSelectorBase( segment
);
385 memcpy( base
, oldBase
, segSize
);
386 GLOBAL_MoveBlock( segment
, base
, totSize
);
387 HeapFree( GetProcessHeap(), 0, oldBase
);
390 return (HANDLE
)header
;
393 /***********************************************************************
394 * Local32_SearchHandle
396 static LPDWORD
Local32_SearchHandle( LOCAL32HEADER
*header
, DWORD addr
)
400 for ( handle
= (LPDWORD
)((LPBYTE
)header
+ sizeof(LOCAL32HEADER
));
401 handle
< (LPDWORD
)((LPBYTE
)header
+ header
->limit
);
411 /***********************************************************************
414 static VOID
Local32_ToHandle( LOCAL32HEADER
*header
, INT16 type
,
415 DWORD addr
, LPDWORD
*handle
, LPBYTE
*ptr
)
422 case -2: /* 16:16 pointer, no handles */
423 *ptr
= MapSL( addr
);
424 *handle
= (LPDWORD
)*ptr
;
427 case -1: /* 32-bit offset, no handles */
428 *ptr
= header
->base
+ addr
;
429 *handle
= (LPDWORD
)*ptr
;
433 if ( addr
>= sizeof(LOCAL32HEADER
)
434 && addr
< header
->limit
&& !(addr
& 3)
435 && *(LPDWORD
)((LPBYTE
)header
+ addr
) >= HTABLE_SIZE
)
437 *handle
= (LPDWORD
)((LPBYTE
)header
+ addr
);
438 *ptr
= header
->base
+ **handle
;
442 case 1: /* 16:16 pointer */
443 *ptr
= MapSL( addr
);
444 *handle
= Local32_SearchHandle( header
, *ptr
- header
->base
);
447 case 2: /* 32-bit offset */
448 *ptr
= header
->base
+ addr
;
449 *handle
= Local32_SearchHandle( header
, *ptr
- header
->base
);
454 /***********************************************************************
457 static VOID
Local32_FromHandle( LOCAL32HEADER
*header
, INT16 type
,
458 DWORD
*addr
, LPDWORD handle
, LPBYTE ptr
)
462 case -2: /* 16:16 pointer */
465 WORD
*selTable
= (LPWORD
)(header
->base
+ header
->selectorTableOffset
);
466 DWORD offset
= (LPBYTE
)ptr
- header
->base
;
467 *addr
= MAKELONG( offset
& 0x7fff, selTable
[offset
>> 15] );
471 case -1: /* 32-bit offset */
473 *addr
= ptr
- header
->base
;
477 *addr
= (LPBYTE
)handle
- (LPBYTE
)header
;
482 /***********************************************************************
485 DWORD WINAPI
Local32Alloc16( HANDLE heap
, DWORD size
, INT16 type
, DWORD flags
)
487 LOCAL32HEADER
*header
= (LOCAL32HEADER
*)heap
;
492 /* Allocate memory */
493 ptr
= HeapAlloc( header
->heap
,
494 (flags
& LMEM_MOVEABLE
)? HEAP_ZERO_MEMORY
: 0, size
);
498 /* Allocate handle if requested */
503 /* Find first page of handle table with free slots */
504 for (page
= 0; page
< HTABLE_NPAGES
; page
++)
505 if (header
->freeListFirst
[page
] != 0)
507 if (page
== HTABLE_NPAGES
)
509 WARN("Out of handles!\n" );
510 HeapFree( header
->heap
, 0, ptr
);
514 /* If virgin page, initialize it */
515 if (header
->freeListFirst
[page
] == 0xffff)
517 if ( !VirtualAlloc( (LPBYTE
)header
+ (page
<< 12),
518 0x1000, MEM_COMMIT
, PAGE_READWRITE
) )
520 WARN("Cannot grow handle table!\n" );
521 HeapFree( header
->heap
, 0, ptr
);
525 header
->limit
+= HTABLE_PAGESIZE
;
527 header
->freeListFirst
[page
] = 0;
528 header
->freeListLast
[page
] = HTABLE_PAGESIZE
- 4;
529 header
->freeListSize
[page
] = HTABLE_PAGESIZE
/ 4;
531 for (i
= 0; i
< HTABLE_PAGESIZE
; i
+= 4)
532 *(DWORD
*)((LPBYTE
)header
+ i
) = i
+4;
534 if (page
< HTABLE_NPAGES
-1)
535 header
->freeListFirst
[page
+1] = 0xffff;
538 /* Allocate handle slot from page */
539 handle
= (LPDWORD
)((LPBYTE
)header
+ header
->freeListFirst
[page
]);
540 if (--header
->freeListSize
[page
] == 0)
541 header
->freeListFirst
[page
] = header
->freeListLast
[page
] = 0;
543 header
->freeListFirst
[page
] = *handle
;
545 /* Store 32-bit offset in handle slot */
546 *handle
= ptr
- header
->base
;
550 handle
= (LPDWORD
)ptr
;
555 /* Convert handle to requested output type */
556 Local32_FromHandle( header
, type
, &addr
, handle
, ptr
);
560 /***********************************************************************
563 DWORD WINAPI
Local32ReAlloc16( HANDLE heap
, DWORD addr
, INT16 type
,
564 DWORD size
, DWORD flags
)
566 LOCAL32HEADER
*header
= (LOCAL32HEADER
*)heap
;
571 return Local32Alloc16( heap
, size
, type
, flags
);
573 /* Retrieve handle and pointer */
574 Local32_ToHandle( header
, type
, addr
, &handle
, &ptr
);
575 if (!handle
) return FALSE
;
577 /* Reallocate memory block */
578 ptr
= HeapReAlloc( header
->heap
,
579 (flags
& LMEM_MOVEABLE
)? HEAP_ZERO_MEMORY
: 0,
585 *handle
= ptr
- header
->base
;
587 handle
= (LPDWORD
)ptr
;
589 /* Convert handle to requested output type */
590 Local32_FromHandle( header
, type
, &addr
, handle
, ptr
);
594 /***********************************************************************
597 BOOL WINAPI
Local32Free16( HANDLE heap
, DWORD addr
, INT16 type
)
599 LOCAL32HEADER
*header
= (LOCAL32HEADER
*)heap
;
603 /* Retrieve handle and pointer */
604 Local32_ToHandle( header
, type
, addr
, &handle
, &ptr
);
605 if (!handle
) return FALSE
;
607 /* Free handle if necessary */
610 int offset
= (LPBYTE
)handle
- (LPBYTE
)header
;
611 int page
= offset
>> 12;
613 /* Return handle slot to page free list */
614 if (header
->freeListSize
[page
]++ == 0)
615 header
->freeListFirst
[page
] = header
->freeListLast
[page
] = offset
;
617 *(LPDWORD
)((LPBYTE
)header
+ header
->freeListLast
[page
]) = offset
,
618 header
->freeListLast
[page
] = offset
;
622 /* Shrink handle table when possible */
623 while (page
> 0 && header
->freeListSize
[page
] == HTABLE_PAGESIZE
/ 4)
625 if ( VirtualFree( (LPBYTE
)header
+
626 (header
->limit
& ~(HTABLE_PAGESIZE
-1)),
627 HTABLE_PAGESIZE
, MEM_DECOMMIT
) )
630 header
->limit
-= HTABLE_PAGESIZE
;
631 header
->freeListFirst
[page
] = 0xffff;
637 return HeapFree( header
->heap
, 0, ptr
);
640 /***********************************************************************
643 DWORD WINAPI
Local32Translate16( HANDLE heap
, DWORD addr
, INT16 type1
, INT16 type2
)
645 LOCAL32HEADER
*header
= (LOCAL32HEADER
*)heap
;
649 Local32_ToHandle( header
, type1
, addr
, &handle
, &ptr
);
650 if (!handle
) return 0;
652 Local32_FromHandle( header
, type2
, &addr
, handle
, ptr
);
656 /***********************************************************************
659 DWORD WINAPI
Local32Size16( HANDLE heap
, DWORD addr
, INT16 type
)
661 LOCAL32HEADER
*header
= (LOCAL32HEADER
*)heap
;
665 Local32_ToHandle( header
, type
, addr
, &handle
, &ptr
);
666 if (!handle
) return 0;
668 return HeapSize( header
->heap
, 0, ptr
);
671 /***********************************************************************
674 BOOL WINAPI
Local32ValidHandle16( HANDLE heap
, WORD addr
)
676 LOCAL32HEADER
*header
= (LOCAL32HEADER
*)heap
;
680 Local32_ToHandle( header
, 0, addr
, &handle
, &ptr
);
681 return handle
!= NULL
;
684 /***********************************************************************
687 WORD WINAPI
Local32GetSegment16( HANDLE heap
)
689 LOCAL32HEADER
*header
= (LOCAL32HEADER
*)heap
;
690 return header
->segment
;
693 /***********************************************************************
696 static LOCAL32HEADER
*Local32_GetHeap( HGLOBAL16 handle
)
698 WORD selector
= GlobalHandleToSel16( handle
);
699 DWORD base
= GetSelectorBase( selector
);
700 DWORD limit
= GetSelectorLimit16( selector
);
702 /* Hmmm. This is a somewhat stupid heuristic, but Windows 95 does
705 if ( limit
> 0x10000 && ((LOCAL32HEADER
*)base
)->magic
== LOCAL32_MAGIC
)
706 return (LOCAL32HEADER
*)base
;
711 if ( limit
> 0x10000 && ((LOCAL32HEADER
*)base
)->magic
== LOCAL32_MAGIC
)
712 return (LOCAL32HEADER
*)base
;
717 /***********************************************************************
718 * Local32Info (KERNEL.444)
719 * Local32Info (TOOLHELP.84)
721 BOOL16 WINAPI
Local32Info16( LOCAL32INFO
*pLocal32Info
, HGLOBAL16 handle
)
723 PROCESS_HEAP_ENTRY entry
;
726 LOCAL32HEADER
*header
= Local32_GetHeap( handle
);
727 if ( !header
) return FALSE
;
729 if ( !pLocal32Info
|| pLocal32Info
->dwSize
< sizeof(LOCAL32INFO
) )
732 pLocal32Info
->dwMemReserved
= 0;
733 pLocal32Info
->dwMemCommitted
= 0;
734 pLocal32Info
->dwTotalFree
= 0;
735 pLocal32Info
->dwLargestFreeBlock
= 0;
737 while (HeapWalk( header
->heap
, &entry
))
739 if (entry
.wFlags
& PROCESS_HEAP_REGION
)
741 pLocal32Info
->dwMemReserved
+= entry
.u
.Region
.dwCommittedSize
742 + entry
.u
.Region
.dwUnCommittedSize
;
743 pLocal32Info
->dwMemCommitted
= entry
.u
.Region
.dwCommittedSize
;
745 else if (!(entry
.wFlags
& PROCESS_HEAP_ENTRY_BUSY
))
747 DWORD size
= entry
.cbData
+ entry
.cbOverhead
;
748 pLocal32Info
->dwTotalFree
+= size
;
749 if (size
> pLocal32Info
->dwLargestFreeBlock
) pLocal32Info
->dwLargestFreeBlock
= size
;
753 pLocal32Info
->dwcFreeHandles
= 0;
754 for ( i
= 0; i
< HTABLE_NPAGES
; i
++ )
756 if ( header
->freeListFirst
[i
] == 0xffff ) break;
757 pLocal32Info
->dwcFreeHandles
+= header
->freeListSize
[i
];
759 pLocal32Info
->dwcFreeHandles
+= (HTABLE_NPAGES
- i
) * HTABLE_PAGESIZE
/4;
764 /***********************************************************************
765 * Local32First (KERNEL.445)
766 * Local32First (TOOLHELP.85)
768 BOOL16 WINAPI
Local32First16( LOCAL32ENTRY
*pLocal32Entry
, HGLOBAL16 handle
)
770 FIXME("(%p, %04X): stub!\n", pLocal32Entry
, handle
);
774 /***********************************************************************
775 * Local32Next (KERNEL.446)
776 * Local32Next (TOOLHELP.86)
778 BOOL16 WINAPI
Local32Next16( LOCAL32ENTRY
*pLocal32Entry
)
780 FIXME("(%p): stub!\n", pLocal32Entry
);
785 /* FIXME: these functions are needed for dlls that aren't properly separated yet */
787 LPVOID WINAPI
HeapAlloc( HANDLE heap
, DWORD flags
, SIZE_T size
)
789 return RtlAllocateHeap( heap
, flags
, size
);
792 BOOL WINAPI
HeapFree( HANDLE heap
, DWORD flags
, LPVOID ptr
)
794 return RtlFreeHeap( heap
, flags
, ptr
);
797 LPVOID WINAPI
HeapReAlloc( HANDLE heap
, DWORD flags
, LPVOID ptr
, SIZE_T size
)
799 return RtlReAllocateHeap( heap
, flags
, ptr
, size
);
802 SIZE_T WINAPI
HeapSize( HANDLE heap
, DWORD flags
, LPVOID ptr
)
804 return RtlSizeHeap( heap
, flags
, ptr
);
807 void WINAPI
EnterCriticalSection( CRITICAL_SECTION
*crit
)
809 RtlEnterCriticalSection( crit
);
812 BOOL WINAPI
TryEnterCriticalSection( CRITICAL_SECTION
*crit
)
814 return RtlTryEnterCriticalSection( crit
);
817 void WINAPI
DeleteCriticalSection( CRITICAL_SECTION
*crit
)
819 RtlDeleteCriticalSection( crit
);
822 void WINAPI
LeaveCriticalSection( CRITICAL_SECTION
*crit
)
824 RtlLeaveCriticalSection( crit
);