x64 XP BSOD on read of statics on driver enable/disable/enable

Discussion in 'Windows Vista Drivers' started by dhmot, Aug 21, 2009.

  1. dhmot

    dhmot Guest

    Hi all,

    I'm porting an NDIS 5.1 miniport driver from x86 XP to x64 xp under Visual
    Studio 2008/WinDDK 6001.18001 and am running into a very odd issue. A static
    MP_REG_ENTRY structure (see e100bex/5x/mp_init.c sample) is declared:

    -------------------------------------------------
    static MP_REG_ENTRY CardRegistryEntries[] =
    {
    { NDIS_STRING_CONST("LogFile"), NdisParameterString, FALSE, 0, 0,
    0xFFFFFFFF, CARD_OFFSET(LogFileName), DRIVER_FILENAME_SIZE }
    };
    -------------------------------------------------

    When the NDIS driver is first enabled, all goes well. However, if the
    driver is disabled then re-enabled, an IRQL_NOT_LESS_OR_EQUAL BSOD occurs,
    with the IRQL = 2 and with the offending instruction attempting to read the
    Unicode buffer (per WinDBG, it is a read fault):

    -------------------------------------------------

    299: }
    -------------------------------------------------

    The call time of this is in InitializeHandler, the NDIS initialization
    handler:

    -------------------------------------------------
    MpDbgPrintUnicodeString <-- Faulting routine
    MpReadRegParameters
    CardAttach
    NICInitializeAdapter
    MPInitialize
    ndisMInitializeAdapter
    .... (more above)
    -------------------------------------------------

    I inserted KeGetCurrentIrql() debug statements all around and commented out
    the offending code. At no point in my code did the IRQL leave zero. I
    restored the code then modified the CardRegistryEntries[] structure a bit:

    -------------------------------------------------
    #define LOGFILENAME L"LogFile"
    static WCHAR logFileName[] = LOGFILENAME;

    static MP_REG_ENTRY CardRegistryEntries[] =
    {
    { {sizeof(LOGFILENAME)-2, sizeof(LOGFILENAME), logFileName},
    NdisParameterString, FALSE, 0, 0,
    0xFFFFFFFF, CARD_OFFSET(LogFileName), DRIVER_FILENAME_SIZE }
    };
    -------------------------------------------------

    The only real difference between the above and the NDIS_STRING_CONST() macro
    is the use of a pointer to the buffer rather than having the compiler create
    one somewhere. With this change, I no longer get a BSOD.

    I've played with the /GL flag on the compier, but that made no difference.
    Also, I have a much larger MP_REG_ENTRY structure in another file that is
    accessed just prior that is not causing any problems.

    What would cause this problem? I do not like making this "fix" (not really
    a fix IMO) without understanding why.

    Thanks,
    Michael
     
    dhmot, Aug 21, 2009
    #1
    1. Advertisements

  2. dhmot

    dhmot Guest

    Ignore this - out of range pointer again.

    Michael

     
    dhmot, Aug 21, 2009
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.