Udostępnij przez


Uzyskiwanie możliwości iniekcji błędów

Uwaga

Interfejs iniekcji błędu WHEA wymaga albo komputera z tabelą EINJ ACPI, albo PSHED Plug-In, który implementuje obszar funkcjonalny iniekcji błędu . Większość systemów konsumenckich nie obejmuje wdrożenia EINJ, a system Windows nie ma wbudowanego PSHED Plug-In do aktywacji iniekcji błędów. W przypadku braku tych elementów interfejsy iniekcji błędów zwracają błąd.

Aplikacja trybu użytkownika może uzyskać informacje o możliwościach wstrzykiwania błędów platformy sprzętowej przez wywołanie metody WHEAErrorInjectionMethods::GetErrorInjectionCapabilitiesRtn. Ta metoda zwraca strukturę WHEA_ERROR_INJECTION_CAPABILITIES opisującą możliwości wstrzykiwania błędów obsługiwane przez platformę sprzętową.

Poniższy przykład kodu pokazuje, jak pobrać informacje o możliwościach iniekcji błędów.

IWbemServices *pIWbemServices;
BSTR ClassName;
BSTR MethodName;
HRESULT Result;
IWbemClassObject *pOutParameters;
VARIANT Parameter;
ULONG Status;
WHEA_ERROR_INJECTION_CAPABILITIES ErrorInjectionCapabilities;

// The following example assumes that the application
// has previously connected to WMI on the local machine
// and that the pIWbemServices variable contains the
// pointer that was returned from the call to the
// IWbemLocator::ConnectServer method.

// Specify the class and method to execute
ClassName = SysAllocString(L"WHEAErrorInjectionMethods");
MethodName = SysAllocString(L"GetErrorInjectionCapabilitiesRtn");

// Call the GetErrorInjectionCapabilitiesRtn method indirectly
// by calling the IWbemServices::ExecMethod method.
Result =
  pIWbemServices->ExecMethod(
    ClassName,
    MethodName,
    0,
    NULL,
    NULL,
    &pOutParameters,
    NULL
    );

// Get the status from the output parameters object
Result =
  pOutParameters->Get(
    L"Status",
    0,
    &Parameter,
    NULL,
    NULL
    );
Status = Parameter.ulVal;
VariantClear(&Parameter);

// Get the capabilities from the output parameters object
Result =
  pOutParameters->Get(
    L"Capabilities",
    0,
    &Parameter,
    NULL,
    NULL
    );
ErrorInjectionCapabilities.AsULONG = Parameter.ulVal;
VariantClear(&Parameter);

// Process the error injection capabilities data
...

// Free up resources
SysFreeString(ClassName);
SysFreeString(MethodName);
pOutParameters->Release();