Fonction UMDEtwRegister (umdprovider.h)

Inscrit le fournisseur de traces d’événements. Le pilote doit appeler cette fonction avant d’effectuer des appels pour journaliser des événements.

Syntaxe

void UMDEtwRegister(
  PFNUMDETW_RUNDOWN CbRundown
);

Paramètres

CbRundown

Pointeur vers une fonction de rappel qui retourne des informations sur l’état actuel du pilote en mode utilisateur.

Cette fonction de rappel doit appeler la fonction UMDEtwLogMapAllocation pour chaque mappage d’allocation actuel.

Valeur de retour

None

Remarques

Le type de données du paramètre CbRundown est défini comme suit :

typedef void (*PFNUMDETW_RUNDOWN)();

UMDEtwRegister est défini inline dans Umdprovider.h comme suit :

// GUID for UMD ETW provider
// {A688EE40-D8D9-4736-B6F9-6B74935BA3B1}
static const GUID UMDEtwProviderId = 
{ 0xa688ee40, 0xd8d9, 0x4736, { 0xb6, 0xf9, 0x6b, 0x74, 0x93, 0x5b, 0xa3, 0xb1 } };

// Registration handle, returned by EventRegister and passed to EventUnregister
__declspec(selectany) REGHANDLE RegHandle = NULL;

// Whether any level of logging is enabled.
__declspec(selectany) BOOLEAN Enabled = FALSE;

// Whether we are currently in a rundown
__declspec(selectany) BOOLEAN InRundown = FALSE;

// Callback to the driver when a rundown is needed
__declspec(selectany) PFNUMDETW_RUNDOWN Rundown = NULL;

FORCEINLINE void NTAPI EnableCallback(
  __in      LPCGUID SourceId,
  __in      ULONG IsEnabled,
  __in      UCHAR Level,
  __in      ULONGLONG MatchAnyKeyword,
  __in      ULONGLONG MatchAllKeywords,
  __in_opt  PEVENT_FILTER_DESCRIPTOR FilterData,
  __in_opt  PVOID CallbackContext
)
{
    switch (IsEnabled)
    {
        case EVENT_CONTROL_CODE_DISABLE_PROVIDER:
            Enabled = FALSE;
            break;
        case EVENT_CONTROL_CODE_ENABLE_PROVIDER:
            Enabled = TRUE;
            break;
        case EVENT_CONTROL_CODE_CAPTURE_STATE:
            // Temporarily enable logging during the rundown
            BOOLEAN OldEnabled = Enabled;
            Enabled = TRUE;
            
            InRundown = TRUE;
            Rundown();
            InRundown = FALSE;

            // Restore Enabled to its original state
            Enabled = OldEnabled;
            
            break;
    }
}

FORCEINLINE void UMDEtwRegister(PFNUMDETW_RUNDOWN RundownCb)
{
    Rundown = RundownCb;

    // Register the provider
    EventRegister(&UMDEtwProviderId,
                  EnableCallback,
                  NULL,
                  &RegHandle);
}

La fonction EventRegister et les valeurs EVENT_CONTROL_CODE_XXX sont décrites dans la documentation événements Windows .

Configuration requise

Condition requise Valeur
Client minimal pris en charge Windows 8
Serveur minimal pris en charge Windows Server 2012
Plateforme cible Desktop (Expérience utilisateur)
En-tête umdprovider.h (include Umdprovider.h)

Voir aussi

UMDEtwLogMapAllocation

UMDEtwUnregister