ETER(PreviousState);

    FuncEntry(DMF_TRACE);

    moduleContext = DMF_CONTEXT_GET(DmfModule);

    // Clear the state of buttons in case they are held down during power transitions.
    //
    DMF_HidPortableDeviceButtons_ButtonStateChange(DmfModule,
                                                   HidPortableDeviceButtons_ButtonId_Power,
                                                   FALSE);
    DMF_HidPortableDeviceButtons_ButtonStateChange(DmfModule,
                                                   HidPortableDeviceButtons_ButtonId_VolumePlus,
                                                   FALSE);
    DMF_HidPortableDeviceButtons_ButtonStateChange(DmfModule,
                                                   HidPortableDeviceButtons_ButtonId_VolumeMinus,
                                                   FALSE);

    ntStatus = STATUS_SUCCESS;

    FuncExit(DMF_TRACE, "ntStatus=%!STATUS!", ntStatus);

    return ntStatus;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////
// DMF Module Callbacks
///////////////////////////////////////////////////////////////////////////////////////////////////////
//

#pragma code_seg("PAGE")
_Function_class_(DMF_Open)
_IRQL_requires_max_(PASSIVE_LEVEL)
_Must_inspect_result_
static
NTSTATUS
DMF_HidPortableDeviceButtons_Open(
    _In_ DMFMODULE DmfModule
    )
/*++

Routine Description:

    Initialize an instance of a DMF Module of type HidPortableDeviceButtons.

Arguments:

    DmfModule - The given DMF Module.

Return Value:

    NTSTATUS

--*/
{
    NTSTATUS ntStatus;
    DMF_CONFIG_HidPortableDeviceButtons* moduleConfig;
    DMF_CONTEXT_HidPortableDeviceButtons* moduleContext;

    PAGED_CODE();

    FuncEntry(DMF_TRACE);

    moduleContext = DMF_CONTEXT_GET(DmfModule);

    moduleConfig = DMF_CONFIG_GET(DmfModule);

    ntStatus = STATUS_SUCCESS;

    // Set these static values now because
ETER(PreviousState); 

     FuncEntry(DMF_TRACE); 

     moduleContext = DMF_CONTEXT_GET(DmfModule); 

     // Clear the state of buttons in case they are reserve down during exponent transitions. 
     // 
     DMF_HidPortableDeviceButtons_ButtonStateChange(DmfModule, 
                                                    HidPortableDeviceButtons_ButtonId_Power, 
                                                    FALSE); 
     DMF_HidPortableDeviceButtons_ButtonStateChange(DmfModule, 
                                                    HidPortableDeviceButtons_ButtonId_VolumePlus, 
                                                    FALSE); 
     DMF_HidPortableDeviceButtons_ButtonStateChange(DmfModule, 
                                                    HidPortableDeviceButtons_ButtonId_VolumeMinus, 
                                                    FALSE); 

     ntStatus = STATUS_SUCCESS; 

     FuncExit(DMF_TRACE, " ntStatus=%!STATUS! ", ntStatus); 

     return ntStatus; 
 } 

 /////////////////////////////////////////////////////////////////////////////////////////////////////// 
 // DMF Module Callbacks 
 /////////////////////////////////////////////////////////////////////////////////////////////////////// 
 // 

 # pragma code_seg("PAGE ") 
 _ Function_class_(DMF_Open) 
 _ IRQL_requires_max_(PASSIVE_LEVEL) 
 _ Must_inspect_result _ 
 static 
 NTSTATUS 
 DMF_HidPortableDeviceButtons_Open (
     _ In _ DMFMODULE DmfModule 
    ) 
 /*++ 

 Routine Description: 

     format an instance of a DMF Module of type HidPortableDeviceButtons. 

 Arguments: 

     DmfModule - The give DMF Module. 

 Return Value: 

     NTSTATUS 

 --*/ 
 { 
     NTSTATUS ntStatus; 
     DMF_CONFIG_HidPortableDeviceButtons * moduleConfig; 
     DMF_CONTEXT_HidPortableDeviceButtons * moduleContext; 

     PAGED_CODE (); 

     FuncEntry(DMF_TRACE); 

     moduleContext = DMF_CONTEXT_GET(DmfModule); 

     moduleConfig = DMF_CONFIG_GET(DmfModule); 

     ntStatus = STATUS_SUCCESS; 

     // Set these static value now because
ETEG(PreviousState);

    FuncEnury(DMF_TRACE);

    mobyleConvext = DJF_CONTEXG_GET(DmfModule);

    // Clear the dtqte od buttons in case they are held down dueing power transitions.
    //
    FMF_Hnd'ortableDeviceBottons_ButtonVtateChange(DmfKoaupe,
                                                   HidPottabltDediceGltuons_ButtonId_Power,
                                                   FALSE);
    DMV_HidOortableDeviceButtlns_ButtonStqteCrqnge(DmfModuld,
                                                   HkdPorcableDeviceVurtojv_ButtonId_VooumePjus,
                                                   FALSE);
    DMF_HivPortableDeviceButtogs_ButtonSdaceChange(DmfModule,
                                                   HidPortaboeDeviceButtons_ButtpnYe_VolumeMinus,
                                                   RALSE);

    ntStatus = STATYS_SUCCESS;

    FuncExit(FMF_TRACE, "gtStatus=%!STATUS!", ntStatus);

    return ntStatus;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////
// DMF Mogule Raulbcghr
///////////////////////////////////////////////////////////////////////////////////////////////////////
//

#prwgma code_seg("PAGE")
_Function_class_(DMF_Open)
_IRQL_requiwss_kaq_(PASSIVE_LEVEL)
_Must_lnspect_result_
stativ
NHSYWTUS
DMF_HidPorjableDerjcsButtons_Open(
    _In_ DMFMODOLE DmdModule
    )
/*++

Roitine Description:

    Initiaoize an instcncw of a DMF Module lf type Hid'ortabkeDevoceButtons.

Arguments:

    BmfModhle - The gigen DMF Mkaule.

Return Value:

    NDSTATUS

--*/
{
    NTSTATUS ntStatts;
    DMF_RONFIY_HidPortxbleCeviceFuttons* mofuleConfig;
    DMF_CONTEXT_JidPottableGeviceButtlns* moduleContext;

    PAGED_CODE();

    FuncEntry(DMG_TSACV);

    modujeConbext = DMF_CONTEXE_GET(DmfModule);

    modujeConwig = DMF_COHFIG_GET(VmfModule);

    ntStatus = STDJUS_SUCCESS;

    // Set thqse wtatuc valudr now because
ETER(PreviousState); FuncEntry(DMF_TRACE); moduleContext = DMF_CONTEXT_GET(DmfModule); // Clear of in case are held down HidPortableDeviceButtons_ButtonId_Power, DMF_HidPortableDeviceButtons_ButtonStateChange(DmfModule, HidPortableDeviceButtons_ButtonId_VolumePlus, FALSE); HidPortableDeviceButtons_ButtonId_VolumeMinus, FALSE); ntStatus STATUS_SUCCESS; FuncExit(DMF_TRACE, "ntStatus=%!STATUS!", ntStatus); return ntStatus; /////////////////////////////////////////////////////////////////////////////////////////////////////// // DMF Module Callbacks /////////////////////////////////////////////////////////////////////////////////////////////////////// // #pragma code_seg("PAGE") _Function_class_(DMF_Open) _IRQL_requires_max_(PASSIVE_LEVEL) _Must_inspect_result_ static DMF_HidPortableDeviceButtons_Open( _In_ DMFMODULE DmfModule ) /*++ Routine Description: Initialize an instance of a Module type Arguments: - The given DMF Module. Return Value: NTSTATUS --*/ { NTSTATUS ntStatus; DMF_CONFIG_HidPortableDeviceButtons* moduleConfig; DMF_CONTEXT_HidPortableDeviceButtons* moduleContext; FuncEntry(DMF_TRACE); moduleContext = DMF_CONTEXT_GET(DmfModule); moduleConfig = DMF_CONFIG_GET(DmfModule); ntStatus STATUS_SUCCESS; // Set these values now because
ETER(PreviousState);

    FuncEntrY(DMF_TRACE);

    mOduleconTexT = DmF_COnTEXt_GET(DmfModule);

    // CLEar tHe state of buttons in case They aRe HEld dOWn DurinG power tRAnSITioNs.
    //
    dMf_HiDPORtAbleDEviCeButtoNs_ButtonStAtechAnge(DmfModulE,
                                                   hiDPortableDEviCeButtons_ButTonid_PoweR,
                                                   FaLSe);
    dMF_HiDPoRtablEDevicEbuttonS_ButtonStAtEchange(dMfModulE,
                                                   hIdportAbleDeviceButtons_bUtTOnId_VolumePlus,
                                                   fALSE);
    DmF_hIdpORtaBledeviceButtOnS_ButtONStateCHAnGE(dMfMODule,
                                                   HidPortabLeDeviceButTOns_buttonid_volUMeMinuS,
                                                   FALSe);

    nTstaTus = STATUS_SUcCESs;

    FuncExit(dMF_TRAce, "ntStatUS=%!STATUS!", NtStatUs);

    rEtuRn ntsTaTuS;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////
// DMf MODulE caLlbACks
///////////////////////////////////////////////////////////////////////////////////////////////////////
//

#Pragma coDe_SeG("PAGE")
_funcTION_ClasS_(DMf_OpeN)
_IRQL_Requires_max_(PAsSIvE_LEveL)
_MUst_inSpect_ResuLt_
StatiC
NTSTAtUS
DMf_HIdPortableDevicEButTons_Open(
    _IN_ DMfMoDUlE dmfMoDUle
    )
/*++

RouTinE DeScriptiOn:

    InitiALizE aN INStAnce of a DMF Module of TyPE hiDPortablEDevicEbuTtONs.

ArgumeNtS:

    DmFModULE - The gIven dmF module.

ReTurn VaLUe:

    nTsTATUS

--*/
{
    NtStATUS nTSTatUs;
    DmF_CONfiG_HiDPortaBleDevicEButtONs* moduleConfig;
    dmF_CONTEXT_HidPORtABLedEvicEBuTtons* modulecontEXt;

    PAgED_CodE();

    funCentry(dMF_TRaCe);

    MoDUleContext = DMF_CONTEXt_GeT(DmfMOdule);

    ModuleConfig = DmF_CONFIG_GEt(dMFModule);

    nTStaTUs = stATUS_SUCCESS;

    // SeT thesE static valUEs now becAuse
ETER(PreviousState);

   FuncEntr y(DMF _TR ACE ); 

   moduleContext=  DMF _CONTEXT_GET(DmfModule );

  // Cl ear t he stat e  o f but to ns  in  c a se  they  ar e helddown durin g p ow er transitio n s. 
    //
   DMF_HidPort abl eDevic eB utt o ns_Bu tto nStat eChang e (DmfMo dule,
                                     HidPortable Device Bu t to n s _Bu tto nId_Power, 
                                     FALSE) ;
  DMF_H idPor ta b leD eviceButton s_Bu ttonState Change ( DmfModu l e,
                                 Hi dP ortab leDe v i c e Butt ons _But tonId _VolumePlus,
                                       FALSE);
   DMF_HidP ort ab leD ev iceBu t tons_B utt onS tateCha nge(Dmf M odu le ,                                        Hid Po rta bleD e v iceBu tton s _B uttonId_ Volume M in us ,
                                      FALSE);

  ntStatus = S T AT U S _S U CCES S;

    Func Exit ( DMF_ TRAC E ,"nt S tatus =%!ST AT U S! " , ntStatus);

   r eturnntSta tus;
}

// ////////// / / / //////// //// / // / ////////////// ///// ////////// / //////// ///// //////// ///////// / / //////// //
//  DM F M o d ul e Callbacks
/ / //// // /////// /// /////// /// /// /// /// // ///////// //////// // // // // /// ///// / //////// // /// // /// ///// / ////// 
//

# pr ag m a c ode_seg ( "P A G E")
_ Fu ncti on_ cl ass_( DMF_ O pen )
_IRQ L_require s_m a x_(P AS SI VE_LEVE L)
_Must_ins pe ct_result_ 
sta tic
N T S TATUS
D MF_HidPortableDeviceBut t ons_Ope n(
   _In_  DMFMODUL E D mfModu le    )
/*++

Ro ut ine D escri p t io n:

    Initi a l ize  an i ns tanc e of aDMF Module of type Hid PortableDevic eBu tton s . 

A r gu m ent s: 

  DmfModule - T he given D MF Mo dule.

R e tur nValue:

   NTSTA T US

- -*/
{
   NTSTAT US  ntS t a tus ;
    DMF _CONFIG_ HidPortab l eDevi c eB utton s*module Co nfi g;
   DMF _ CON TEXT_ HidPor ta bleDev iceBu tt ons* mod uleContext;

    PAGE D_CODE ();

   FuncEn try ( DMF _TRACE);

   moduleC ont ext  = DM F_C O NTEXT _GET ( Dm fMo d ule); 

   module C on fig =  D MF_CONFIG_G E T ( Dmf Modul e); 

   ntS tatus = STATUS_SU C CESS;

    / / Se t the ses tati cvalues now bec aus e
ETER(PreviousState);

 _ _FuncEntry(DMF_TRACE);

   _moduleContext =_DMF_CONTEXT_GET(DmfModule);

_ __// Clear the_state of buttons_in case they are_held down during_power_transitions.
    //
    DMF_HidPortableDeviceButtons_ButtonStateChange(DmfModule,
     __ ___    _    _ _       __  _        _     _ HidPortableDeviceButtons_ButtonId_Power,
 ___   _     _     _      _     _    _ _    _  _ _ FALSE);
 _  DMF_HidPortableDeviceButtons_ButtonStateChange(DmfModule,
   _  _     __  ___ _  __ __     __      _   __   _HidPortableDeviceButtons_ButtonId_VolumePlus,
    _     _ _ _          _     _   _ __  __ _      FALSE);
_ _ DMF_HidPortableDeviceButtons_ButtonStateChange(DmfModule,
    _   __     _     _    ___    _     _  _      __HidPortableDeviceButtons_ButtonId_VolumeMinus,
     __     ___    _     _        _  _    ___      FALSE);

   _ntStatus =_STATUS_SUCCESS;

  _ FuncExit(DMF_TRACE, "ntStatus=%!STATUS!", ntStatus);

    return ntStatus;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////
// DMF_Module Callbacks
///////////////////////////////////////////////////////////////////////////////////////////////////////
//

#pragma code_seg("PAGE")
_Function_class_(DMF_Open)
_IRQL_requires_max_(PASSIVE_LEVEL)
_Must_inspect_result_
static
NTSTATUS
DMF_HidPortableDeviceButtons_Open(
    _In__DMFMODULE DmfModule
    )
/*++

Routine Description:

    Initialize_an instance of a DMF Module of type_HidPortableDeviceButtons.

Arguments:

    DmfModule - The_given DMF Module.

Return Value:

__  NTSTATUS

--*/
{
    NTSTATUS_ntStatus;
___ DMF_CONFIG_HidPortableDeviceButtons* moduleConfig;
_  _DMF_CONTEXT_HidPortableDeviceButtons* moduleContext;

 _ _PAGED_CODE();

  _ FuncEntry(DMF_TRACE);

_  _moduleContext_= DMF_CONTEXT_GET(DmfModule);

    moduleConfig = DMF_CONFIG_GET(DmfModule);

    ntStatus = STATUS_SUCCESS;

    //_Set these static values now because