| 3444 | } |
| 3445 | |
| 3446 | NTSTATUS |
| 3447 | Ext2StartReaper(PEXT2_REAPER Reaper, EXT2_REAPER_RELEASE Free) |
| 3448 | { |
| 3449 | NTSTATUS status = STATUS_SUCCESS; |
| 3450 | OBJECT_ATTRIBUTES oa; |
| 3451 | HANDLE handle = 0; |
| 3452 | LARGE_INTEGER timeout; |
| 3453 | |
| 3454 | Reaper->Free = Free; |
| 3455 | |
| 3456 | /* initialize wait event */ |
| 3457 | KeInitializeEvent( |
| 3458 | &Reaper->Wait, |
| 3459 | SynchronizationEvent, FALSE |
| 3460 | ); |
| 3461 | |
| 3462 | /* Reaper thread engine event */ |
| 3463 | KeInitializeEvent( |
| 3464 | &Reaper->Engine, |
| 3465 | SynchronizationEvent, FALSE |
| 3466 | ); |
| 3467 | |
| 3468 | /* initialize oa */ |
| 3469 | InitializeObjectAttributes( |
| 3470 | &oa, |
| 3471 | NULL, |
| 3472 | OBJ_CASE_INSENSITIVE | |
| 3473 | OBJ_KERNEL_HANDLE, |
| 3474 | NULL, |
| 3475 | NULL |
| 3476 | ); |
| 3477 | |
| 3478 | /* start a new system thread */ |
| 3479 | status = PsCreateSystemThread( |
| 3480 | &handle, |
| 3481 | 0, |
| 3482 | &oa, |
| 3483 | NULL, |
| 3484 | NULL, |
| 3485 | Free, |
| 3486 | (PVOID)Reaper |
| 3487 | ); |
| 3488 | |
| 3489 | if (NT_SUCCESS(status)) { |
| 3490 | ZwClose(handle); |
| 3491 | |
| 3492 | /* make sure Reaperthread is started */ |
| 3493 | timeout.QuadPart = (LONGLONG)-10*1000*1000*2; /* 2 seconds */ |
| 3494 | status = KeWaitForSingleObject( |
| 3495 | &Reaper->Engine, |
| 3496 | Executive, |
| 3497 | KernelMode, |
| 3498 | FALSE, |
| 3499 | &timeout |
| 3500 | ); |
| 3501 | if (status != STATUS_SUCCESS) { |
| 3502 | status = STATUS_INSUFFICIENT_RESOURCES; |
| 3503 | } |