Justin.V


Hello,

I would like to create a new driver to enable a device which supports sockets. Unfortunately, as I have no experience whats so ever in writing drivers I'm completely lost.. I've downloaded the DDK and looked into the Sideshow driver sample but none of it makes sense to me. I'm fairly confident that once I got the driver up and running the client side should be fairly easy, but first I need some help.

I've found various links on using sockets in driver development but I don't even know where to start in this driver. Could anyone point me out in what functions would need to be changed Or even better, if anyone has written a driver which already uses sockets post the code so I (and others) can learn from it

Thanks,

Justin



Re: Creating a driver which sends/receives over sockets

Teague Mapes - MSFT


Hi Justin,

I have written two Bluetooth SideShow drivers that use the sockets APIs. Because SideShow drivers are UMDF drivers, the use of sockets within the drivers is no different than using them within any normal application, so as long as you are familiar with socket code, you shouldn't have a problem. The part that will be the more difficult for you will probably be getting your driver framwork up and going. Luckily, there is a sample SideShow driver in the DDK that you can use. You should be able to start with this sample and add your socket code to it.

Link to documentation on writing a Windows SideShow UMDF driver:

http://msdn2.microsoft.com/en-us/library/aa973528.aspx

If you have installed the DDK, you can find the SideShow driver sample located at:

\winddkk\6000\src\umdf\sideshow






Re: Creating a driver which sends/receives over sockets

Brian Cheek - MSFT

The sample SideShow driver is called "NoDevice" as it doesn't actually send data to any device, but the source code contains stubs for you to send the data to the device of your choosing. I recommend creating a new subdirectory in the sideshow directory for your device. Copy all the files from the NoDevice subdirectory to your new subdirectory and start coding from this new subdirectory. Note: All the files in the sideshow directory could be considered common files that could be used with all WDK-based drivers, but you are free to modify any of these files to further customize your driver.

The first file you'll want to experiment with is DeviceSpecific.cpp

A few tips: In DeviceSpecific.cpp, change all five instances of E_NOTIMPL to S_OK. Otherwise, the resulting driver will "Code 10" when it runs.

Here's some sample code for handling button callbacks from your device - this would exist in DeviceSpecific.cpp:

// Tip: In your code that handles button callbacks, you can map a button event to

// change to the next gadget or previous gadget.

//

// To have it call the previous gadget, call

// g_Device.HandleDeviceEvent(CDevice::ButtonPrevious);

// To have it call the next gadget, call

// g_Device.HandleDeviceEvent(CDevice::ButtonNext);

// To have it re-render the existing page, call

// g_Device.HandleDeviceEvent(CDevice::RenderAgain);

//

// (This code snippet assumes you have the line "extern CDevice g_Device;"

// somewhere in this file.)

Finally, before releasing your driver you'll want to change the following things in your driver's subdirectory in order to make your driver unique and not overlap the NoDevice driver.

Things you must change:
-----------------------

  • Driver.idl line 4: You must change the GUID in the uuid() line.
  • Driver.idl line 12: You must change the GUID in the uuid() line. This GUID must be the same as the GUID in WindowsSideShowBasicDriver.inf line 56 (DriverCLSID).
  • WindowsSideShowBasicDriver.inf line 56: You need to have the same GUID here as you used in line 12 of Driver.idl.


Things you can optionally change (but are highly recommended):
--------------------------------------------------------------

  • DeviceSpecific.cpp line 56: In the SetDeviceCaps call, you may want to change the device capabilities, possibly including polling the device for the capabilities instead of hard-coding them in the driver.
  • DeviceSpecific.cpp line 66: In the SetRendererCaps call, you may want to change the renderer capabilities, possibly including polling the device for the capabilities instead of hard-coding them in the driver.
  • Driver.idl line 6: You can optionally change the helpstring text.
  • Driver.idl line 13: You can optionally change the helpstring text.
  • Driver.rc line 6, 7, and 8: You can optionally change the strings for VER_FILEDESCRIPTION_STR, VER_INTERNALNAME_STR, and VER_ORIGINALFILENAME_STR.
  • sources line 1: You can change the TARGETNAME. This is the resulting name of the DLL. If you change this, then you will need to change all references to the .dll name in WindowsSideShowBasicDriver.inf.
  • sources line 38: If you wish to change the filename of the inf file (currently WindowsSideShowBasicDriver.inf), you can do so, and change this line to reflect that new filename.
  • WindowsSideShowBasicDriver.inf: If you change the filename of this inf file, it is best to change all occurrences of that base name (not including the .inf part) in this file. This includes line 2, 10, 36 (both instances), 37, 46, 53, 55, 59, and 65.
  • WindowsSideShowBasicDriver.inf line 9: Always update the driver version number and date with each drop for proper versioning control.
  • WindowsSideShowBasicDriver.inf line 15: You can change the keyword "MicrosoftBasicDisplays" to something else. If you do so, also replace the keyword used in lines 17, 20, 23 and any other instance.
  • WindowsSideShowBasicDriver.inf line 18: You can change the keyword "NoDevice.DeviceDesc" to something else. If you do so, also replace the keyword used in lines 21, 24, 85, and any other instance.
  • WindowsSideShowBasicDriver.inf line 18: You can change the keyword "NoDevice_Install" to something else. If you do so, also replace the keyword used in lines 21, 24, 28, 32, 35, 40, and any other instance.
  • WindowsSideShowBasicDriver.inf line 18: You can change the keyword "WindowsSideShowNoDevice" to something else. If you do so, also replace the keyword used in lines 21, 24, and any other instance.
  • WindowsSideShowBasicDriver.inf lines 84 and 85: You can change the strings for MediaDescription and NoDevice.DeviceDesc to anything you want.

Thanks,

Brian






Re: Creating a driver which sends/receives over sockets

Nike






databaseforum