none
pointer truncation from PVIOD to PLONG? RRS feed

  • General discussion

  • I am trying to play around with the vhidmini sample for a project but right out of the box I get the following error below after which is listed after the code:

    inputValue = (ULONG)requestParameters.Parameters.DeviceIoControl.Type3InputBuffer;

    Severity

    Code

    Description

    Project

    File

    Line

    Warning

    C4311

    'type cast': pointer truncation from 'PVOID' to 'ULONG'

    vhidmini

    C:\Users\Jeffery\Desktop\vhidmini2\driver\vhidmini.c

    1066

    Its in GetStringId.


    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - Sherlock Holmes. speak softly and carry a big stick - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://www.computerprofessions.us

    Wednesday, December 9, 2015 4:39 PM

All replies

  • That is a pretty old sample, so it is not surprising you may find problems.  In this case you are taking a 64-bit pointer value and truncating it to a 32-bit ULONG, so it is not surprising you get the warning.  Use a ULONG_PTR as the cast to make this work, but since the sample comes from the days of Windows 98 there are probably other problems with 64-bit.  I would get one of the new HID samples and start from there.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Wednesday, December 9, 2015 4:49 PM
  • That is a pretty old sample, so it is not surprising you may find problems.  In this case you are taking a 64-bit pointer value and truncating it to a 32-bit ULONG, so it is not surprising you get the warning.  Use a ULONG_PTR as the cast to make this work, but since the sample comes from the days of Windows 98 there are probably other problems with 64-bit.  I would get one of the new HID samples and start from there.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Whats with this new error now?

    Severity

    Code

    Description

    Project

    File

    Line

    Error

    LNK1181

    cannot open input file 'C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\km\x64\BufferOverflowFastFailK.lib'

    vhidmini

    C:\Users\Jeffery\Desktop\vhidmini2\driver\kmdf\LINK

    1


    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - Sherlock Holmes. speak softly and carry a big stick - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://www.computerprofessions.us

    Wednesday, December 9, 2015 11:21 PM
  • That is a pretty old sample, so it is not surprising you may find problems.  In this case you are taking a 64-bit pointer value and truncating it to a 32-bit ULONG, so it is not surprising you get the warning.  Use a ULONG_PTR as the cast to make this work, but since the sample comes from the days of Windows 98 there are probably other problems with 64-bit.  I would get one of the new HID samples and start from there.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Whats with this new error now?

    Severity

    Code

    Description

    Project

    File

    Line

    Error

    LNK1181

    cannot open input file 'C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\km\x64\BufferOverflowFastFailK.lib'

    vhidmini

    C:\Users\Jeffery\Desktop\vhidmini2\driver\kmdf\LINK

    1


    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - Sherlock Holmes. speak softly and carry a big stick - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://www.computerprofessions.us


    I got the vhidmini sample from windows 8.1 WDK to work but not the windows 10 WDK. Thanks, Don. Any suggestions on where to go with this sample or a better one to use?

    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - Sherlock Holmes. speak softly and carry a big stick - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://www.computerprofessions.us


    • Edited by The Thinker Wednesday, December 9, 2015 11:25 PM
    Wednesday, December 9, 2015 11:22 PM
  • The error is that the library BufferOverflowFastFailK.lib can't be found, the library is present in the Windows 10 WDK so it is probably something to do with the path to the library.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Thursday, December 10, 2015 1:25 AM