Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


UpperFilter to SBP2PORT.SYS

OSR_Community_UserOSR_Community_User Member Posts: 110,217
Dear Developers,

I want to install an UpperFilter to SBP2PORT.SYS.
How do I install it ? What registry entries are required to accomplish it ?

Thanks and regards,

Venkateswaran Kasirajan,

Comments

  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    Hi,

    To install a filter driver on an already installed driver, follow these
    steps :

    - First write a filter driver INF file (with no reference to the driver to
    filter);
    - Then, write an install application which use SetupAPI to install your INF
    file.

    Join to this Email, you will find the code of my INF file and the source
    code of my installer:

    NB.: - My filter driver's name is 'SlFilter.sys', and the GUID of the
    driver I want to filter
    is {6BDD1FC1-810F-11D0-BEC7-08002BE2092F} (1394 Bus).
    - To install my inf file on Win98, I use this syntax:
    InstallFilter SlFilter.inf SlFilterW98
    {6BDD1FC1-810F-11D0-BEC7-08002BE2092F}
    - To install my inf file on Win2K, I use this syntax:
    InstallFilter SlFilter.inf SlFilterW2K
    {6BDD1FC1-810F-11D0-BEC7-08002BE2092F}

    Hope this helps,

    Regards.

    Serge DE LUCA

    ============ INF FILE CODE ============
    ; ======================
    ; === Header section ===
    ; ======================
    [Version]
    Signature="$CHICAGO$"

    ; ==================================
    ; === Win98 Installation section ===
    ; ==================================
    [SlFilterW98]
    AddReg = SlFilterW98.AddReg

    [SlFilterW98.AddReg]
    HKR,,"UpperFilters",0x00000000,"SlFilter.sys"

    ; ==================================
    ; === Win2K Installation section ===
    ; ==================================
    [SlFilterW2K]
    AddReg = SlFilterW2K.AddReg
    AddService = SlFilter,,SlFilterW2K.Service

    [SlFilterW2K.AddReg]
    HKR,,"UpperFilters",0x00010008,"SlFilter"

    [SlFilterW2K.Service]
    DisplayName = %SlFilter.ServiceDesc%
    ServiceType = 1
    StartType = 3
    ErrorControl = 1
    ServiceBinary = %12%\SlFilter.sys

    ; ====================================
    ; === Common Installation sections ===
    ; ====================================
    [Strings]
    SlFilter.ServiceDesc = 1394 BUS Filter Driver

    ============ INSTALLER SOURCE CODE ============
    #include "stdafx.h"
    #include "stdio.h"
    #include "InitGUID.h"
    #include "DevGUID.h"
    #include "SetupAPI.h"

    /*
    ////////////////////////////////////////////////////////////////////////////
    ////////////////////// IsWin98 */
    BOOL
    IsWin98 ( VOID )
    {
    BOOL lRespBl;
    OSVERSIONINFO lOSVI;

    lOSVI.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    lRespBl = GetVersionEx(&lOSVI) && (lOSVI.dwPlatformId ==
    VER_PLATFORM_WIN32_WINDOWS) &&
    ((lOSVI.dwMajorVersion > 4) ||
    ((lOSVI.dwMajorVersion == 4) && (lOSVI.dwMinorVersion > 0)));

    return lRespBl;
    }

    /*
    ////////////////////////////////////////////////////////////////////////////
    //////////////////// StrToGUID */ BOOL
    StrToGUID ( LPCTSTR aGUIDStrPt, GUID& aDstGUID )
    {
    CHAR lStrPt[37];
    BOOL lRespBl;
    ULONG lBase;
    ULONG lIndex;

    lRespBl = FALSE;
    if (aGUIDStrPt && (strlen(aGUIDStrPt) == 38) &&
    (aGUIDStrPt[0] == '{') && (aGUIDStrPt[37] == '}'))
    {
    CopyMemory(lStrPt,aGUIDStrPt + 1,36);

    if ((lStrPt[8] == '-') && (lStrPt[13] == '-') &&
    (lStrPt[18] == '-') && (lStrPt[23] == '-'))
    {
    lRespBl = TRUE;

    lStrPt[8] =
    lStrPt[13] =
    lStrPt[18] =
    lStrPt[23] =
    lStrPt[36] = '\0';

    aDstGUID.Data1 =
    strtoul(&lStrPt[0],NULL,16);
    aDstGUID.Data2 =
    (USHORT)strtoul(&lStrPt[9],NULL,16);
    aDstGUID.Data3 =
    (USHORT)strtoul(&lStrPt[14],NULL,16);

    for(lIndex=0; lIndex < 8; lIndex++)
    {
    lBase = (lIndex < 2)?19:20;
    lBase += (lIndex * 2);

    lStrPt[0] = lStrPt[lBase + 0];
    lStrPt[1] = lStrPt[lBase + 1];
    lStrPt[2] = '\0';

    aDstGUID.Data4[lIndex] =
    (UCHAR)strtoul(&lStrPt[0],NULL,16);
    }
    }
    }

    return lRespBl;
    }

    /*
    ////////////////////////////////////////////////////////////////////////////
    ////////// InstallFilterDriver */ BOOL
    InstallFilterDriver ( LPCTSTR aInfFileNamePt, LPCTSTR
    aInstallInfSectionNamePt, LPCTSTR aDriverToFilterGUIDPt )
    {
    HINF lInfFileHdl;
    HKEY lRegKeyHdl;
    GUID lClassGUID;
    BOOL lRespBl;

    /*
    * Convert GUID string into GUID object
    */
    lRespBl = StrToGUID(aDriverToFilterGUIDPt,lClassGUID);
    if (lRespBl == TRUE)
    {
    /*
    * Open the filter driver INF file
    */
    lInfFileHdl =
    SetupOpenInfFile(aInfFileNamePt,NULL,INF_STYLE_WIN4,0);
    if (lInfFileHdl != INVALID_HANDLE_VALUE)
    {
    /*
    * Install the filter driver services (only
    for Win2K)
    */
    if (IsWin98() ||
    SetupInstallServicesFromInfSection(lInfFileHdl,aInstallInfSectionNamePt,0))
    {
    /*
    * Open the DriverToFilter's
    registry key
    */
    lRegKeyHdl =
    SetupDiOpenClassRegKey(&aDriverToFilterGUID,KEY_ALL_ACCESS);
    if (lRegKeyHdl !=
    INVALID_HANDLE_VALUE)
    {
    /*
    * Add the filter driver
    into the DriverToFilter's declaration stack
    */
    lRespBl =
    SetupInstallFromInfSection( NULL,

    lInfFileHdl,

    aInstallInfSectionNamePt,

    SPINST_REGISTRY,

    lRegKeyHdl,

    NULL,

    0,

    NULL,

    NULL,

    NULL,

    NULL);

    if (lRespBl == FALSE)
    printf("###[%lu]###
    Can't register filter driver\n",GetLastError());

    RegCloseKey(lRegKeyHdl);
    }
    else
    printf("###[%lu]### Can't
    open Driver's GUID key\n",GetLastError());
    }
    else
    printf("###[%lu]### Can't install
    filter driver services\n",GetLastError());

    SetupCloseInfFile(lInfFileHdl);
    }
    else
    printf("###[%lu]### Can't open INF file
    '%s'\n",GetLastError(),aInfFileNamePt);
    }
    else
    printf("### Invalid GUID format\n");

    return lRespBl;
    }

    /*
    ////////////////////////////////////////////////////////////////////////////
    ///////////////////////// main */
    INT
    main ( INT aArgCount, PCHAR aArgValueArrayPt[] )
    {
    INT lRetVal;

    lRetVal = -1;
    if (aArgCount != 4)
    {
    if
    (InstallFilterDriver(aArgValueArrayPt[1],aArgValueArrayPt[2],aArgValueArrayP
    t[3]) == TRUE)
    lRetVal = 0;
    }
    else
    printf("Usage: InstallFilter <inf_file_name>
    <inf_install_section_name> <Driver_to_filter_GUID>\n");

    return lRetVal;
    }


    -----Original Message-----
    From: Venkateswaran Kasirajan [mailto:[email protected]]
    Sent: Wednesday, August 02, 2000 6:57 AM
    To: NT Developers Interest List
    Subject: [ntdev] UpperFilter to SBP2PORT.SYS


    Dear Developers,

    I want to install an UpperFilter to SBP2PORT.SYS.
    How do I install it ? What registry entries are required to accomplish it ?

    Thanks and regards,

    Venkateswaran Kasirajan,
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 13-17 May 2024 Live, Online
Developing Minifilters 1-5 Apr 2024 Live, Online
Internals & Software Drivers 11-15 Mar 2024 Live, Online
Writing WDF Drivers 20-24 May 2024 Live, Online