Problems Porting WDM to Vista RC1

Discussion in 'Windows Vista Drivers' started by John, Oct 3, 2006.

  1. John

    John Guest

    I'm trying to port my WDM driver to Vista RC1 but it crashes during
    driver initialization.
    Using Windbg, I narrowed it down to a RtlIntegerToUnicode system call.
    This function works perfectly in W2K or XP. Did MS do anything
    different in this function?
    Is this function broken.

    I modified the code where RtlIntegerToUnicode is not used. The driver now
    seems to return to the OS OK after driver init and Start_Device. However,
    Vista just sits there spinning it wheel. When I reboot Vista, I notice this
    warning message being displayed by windbg, "Warning: csc overlaps mydriver".
    What does that mean? This is not the only warning message of this type, there
    are a tone of them. I'm currious to know what thie warning message means.
     
    John, Oct 3, 2006
    #1
    1. Advertisements

  2. I haven't heard of any issues with RtlIntegerToUnicode. What is the error
    returned by this function? Can you show us the code snippet you are using?

    "Warning: csc overlaps mydriver": I have seen this many times in the
    debugger. There is nothing to be concerned about. I usually see when I have
    a dual boot system and I switch from one OS to another. Folks on the windbg
    newsgroup might be able to answer this one.

    -Eliyas
     
    Eliyas Yakub [MSFT], Oct 5, 2006
    #2
    1. Advertisements

  3. John

    John V. Guest

    Here the code snippet.

    UNICODE_STRING DeviceNumber;
    RtlInitUnicodeString(&DeviceNumber,L" ");

    RtlIntegerToUnicodeString( device_list->dev_num,
    10, // base-10 conversion
    &DeviceNumber );

    // device_list->dev_num is defined an unsigned integer and will contain a
    number
    // from 0 thru 7.
    There is no return value from this function because Vista crashes (BSOD).

    When the driver is loaded everything appears ok. The DriverEntry function is
    called and returns a successfully status code. The AddDevice function is
    called successfully. The StartDevice looks goods but when the driver return a
    successful status code (STATUS_SUCCESS), Vista doesn't do anything. No BSOD
    no nothing. I can break into Vista with WinDBG but Vista just never comes up,
    meaning the Desktop is never displayed.

    So now I don't know what to do.

    John V.
     
    John V., Oct 5, 2006
    #3
  4. John

    Pavel A. Guest

    The string for RtlIntegerToUnicodeString must have room for converted
    characters.
    You've initialized it with a too short buffer (actually, empty ).
    So on XP your driver possibly overwrites memory.
    The WDK compiler makes string literals read-only by default.

    An easier function to init unicode strings with a writable buffer
    doesn't seem to exist in WDK, but you could roll your own, like this:

    #define DECLARE_VAR_UNICODE_STRING(_variablename, _maxchars) \
    static WCHAR _variablename ## _buffer[(_maxchars)+1] = {0}; \
    UNICODE_STRING _variablename = { 0, (_maxchars)*2 + 2, &_variablename ##
    _buffer[0] };


    PUNICODE_STRING RtlAllocUnicodeString( INT maxchars )
    {
    PUNICODE_STRING p = (PUNICODE_STRING)ExAllocatePoolWithTag(
    NonPagedPool,
    (maxchars + 1) * 2 + sizeof(UNICODE_STRING),
    (ULONG)'2006'
    );

    if(!p) return NULL;

    p->Length = 0;
    p->MaximumLength = (maxchars + 1) * 2;
    p->Buffer = (PWCHAR)(p + 1);
    *(p->Buffer) = 0;
    return p;
    }


    Regards,
    --PA
     
    Pavel A., Oct 6, 2006
    #4
  5. John

    John V. Guest

    The UNICODE character was initialized to a space character not an empty
    string. However, I will increase it size to see if this works. Also the help
    documentation for the DDK specifies if the buffer is too short,
    STATUS_BUFFER_OVERFLOW is returned. Remember, this code works on XP and 2000.
    It's Vista where this function is crashing.

    I also don't understand about string literals being read only by default.
    I've been initializing unicode string this way since the old NT days and I
    haven't had any problems. I'm not using the WDK, I'm using the Latest DDK
    from MS. Is there a difference?

    --
    John V.



     
    John V., Oct 6, 2006
    #5
    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.