static VOID VifDisable( IN PXENVIF_VIF_CONTEXT Context ) { PXENVIF_FRONTEND Frontend = PdoGetFrontend(Context->Pdo); KIRQL Irql; PKEVENT Event; Trace("====>\n"); AcquireMrswLockExclusive(&Context->Lock, &Irql); if (!Context->Enabled) { ReleaseMrswLockExclusive(&Context->Lock, Irql, FALSE); goto done; } Context->Enabled = FALSE; Event = MacGetEvent(FrontendGetMac(Frontend)); KeSetEvent(Event, IO_NO_INCREMENT, FALSE); SUSPEND(Deregister, Context->SuspendInterface, Context->SuspendCallbackLate); Context->SuspendCallbackLate = NULL; SUSPEND(Release, Context->SuspendInterface); Context->SuspendInterface = NULL; (VOID) FrontendSetState(Frontend, FRONTEND_CONNECTED); ReleaseMrswLockExclusive(&Context->Lock, Irql, TRUE); ReceiverWaitForPackets(FrontendGetReceiver(Frontend)); TransmitterAbortPackets(FrontendGetTransmitter(Frontend)); KeClearEvent(&Context->MonitorEvent); ThreadWake(Context->MonitorThread); Trace("waiting for monitor thread\n"); (VOID) KeWaitForSingleObject(&Context->MonitorEvent, Executive, KernelMode, FALSE, NULL); RtlZeroMemory(&Context->Callback, sizeof (VIF_CALLBACK)); ReleaseMrswLockShared(&Context->Lock); done: Trace("<====\n"); }
/* * Suspend a service */ void svc_suspend( struct service *sp ) { const char *func = "svc_suspend" ; if ( ! SVC_IS_ACTIVE( sp ) ) { msg( LOG_ERR, func, "service %s is not active", SVC_ID( sp ) ) ; return ; } FD_CLR( SVC_FD( sp ), &ps.rws.socket_mask ) ; ps.rws.active_services-- ; if ( debug.on ) msg( LOG_DEBUG, func, "Suspended service %s", SVC_ID( sp ) ) ; SUSPEND( sp ) ; }
struct suspend_error_type checksuspend(PROCESS_ID_TYPE id, RETURN_CODE_TYPE code){ struct suspend_error_type s_e; RETURN_CODE_TYPE retCode; PROCESS_STATUS_TYPE status; s_e = initStruct(); SUSPEND(id, &retCode); if (code!=retCode){ s_e.test_code_suspend = TRUE; }else{ GET_PROCESS_STATUS(id, &status, &retCode); if (retCode!=code){ s_e.test_code_get = TRUE; } if (status.PROCESS_STATE != WAITING){ s_e.test_status = TRUE; } } return s_e; }
static NTSTATUS VifEnable( IN PXENVIF_VIF_CONTEXT Context, IN VOID (*Function)(PVOID, XENVIF_CALLBACK_TYPE, ...), IN PVOID Argument ) { PXENVIF_FRONTEND Frontend = PdoGetFrontend(Context->Pdo); KIRQL Irql; PVIF_CALLBACK Callback; PKEVENT Event; NTSTATUS status; Trace("====>\n"); AcquireMrswLockExclusive(&Context->Lock, &Irql); if (Context->Enabled) goto done; Callback = &Context->Callback; Callback->Function = Function; Callback->Argument = Argument; status = FrontendSetState(Frontend, FRONTEND_ENABLED); if (!NT_SUCCESS(status)) goto fail1; Context->SuspendInterface = FrontendGetSuspendInterface(Frontend); SUSPEND(Acquire, Context->SuspendInterface); status = SUSPEND(Register, Context->SuspendInterface, SUSPEND_CALLBACK_LATE, VifSuspendCallbackLate, Context, &Context->SuspendCallbackLate); if (!NT_SUCCESS(status)) goto fail2; Context->Enabled = TRUE; Event = MacGetEvent(FrontendGetMac(Frontend)); KeSetEvent(Event, IO_NO_INCREMENT, FALSE); done: ReleaseMrswLockExclusive(&Context->Lock, Irql, FALSE); Trace("<====\n"); return STATUS_SUCCESS; fail2: Error("fail2\n"); SUSPEND(Release, Context->SuspendInterface); Context->SuspendInterface = NULL; fail1: Error("fail1 (%08x)\n", status); RtlZeroMemory(&Context->Callback, sizeof (VIF_CALLBACK)); ReleaseMrswLockExclusive(&Context->Lock, Irql, FALSE); return status; }