USB driver development

Work in progress. Currently doesnt work and dunno if it will, might be too ambitious.

Aim is to create a minimal WDM driver for an Xbox 360 Controller so it’s usable as a joystick in Windows 98 SE.

Tools required:

  • Windows 98 SE CD
  • VC++ 5.0 with Service Pack 3
  • Microsoft Platform SDK (I used the August 1999 edition, installed to C:\MSSDK)
  • Windows 98 DDK (installed to C:\98DDK)
  • ??

When installing VC++ 5.0 make sure it’s a full install. Same for SDK.

The DDK should only be installed AFTER installing VC++ otherwise your paths will be messed up.

Producing:

  • A basic installer/uninstaller (if I can be bothered)
  • An inf file which correctly matches the VID/PID and copies relevant files.
  • A sys file containing the driver.

Although you do need MSVC installed (I used VC++ 6.0) I find it easier to just use Textpad or something for driver development. Might just be my dislike of IDEs…

usbview.exe output from Windows 98 SE CD (tools\reskit\diagnose\usbview.exe):

Device Descriptor:
bcdUSB:             0x0200
bDeviceClass:         0xFF
bDeviceSubClass:      0xFF
bDeviceProtocol:      0xFF
bMaxPacketSize0:      0x08 (8)
idVendor:           0x045E (Microsoft)
idProduct:          0x028E
bcdDevice:          0x0110
iManufacturer:        0x01
iProduct:             0x02
iSerialNumber:        0x03
bNumConfigurations:   0x01

ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed:     Full
Device Address:       0x03
Open Pipes:              7

Endpoint Descriptor:
bEndpointAddress:     0x81
Transfer Type:   Interrupt
wMaxPacketSize:     0x0020 (32)
bInterval:            0x04

Endpoint Descriptor:
bEndpointAddress:     0x00
Transfer Type:     Control
wMaxPacketSize:     0x0507 (1287)
wInterval:          0x0302
bSyncAddress:         0x20

Endpoint Descriptor:
bEndpointAddress:     0x00
Transfer Type:     Control
wMaxPacketSize:     0x0002 (2)
wInterval:          0x0000
bSyncAddress:         0x07

Endpoint Descriptor:
bEndpointAddress:     0x05
Transfer Type:   Interrupt
wMaxPacketSize:     0x2003 (8195)
wInterval:          0x0200
bSyncAddress:         0x00

Endpoint Descriptor:
bEndpointAddress:     0x00
Transfer Type:     Control
wMaxPacketSize:     0x0700 (1792)
wInterval:          0x0405
bSyncAddress:         0x03

Endpoint Descriptor:
bEndpointAddress:     0x20
Transfer Type:     Control
wMaxPacketSize:     0x0304 (772)
wInterval:          0x0000
bSyncAddress:         0x00

Endpoint Descriptor:
bEndpointAddress:     0x07
Transfer Type: Isochronous
wMaxPacketSize:     0x0385 (901)
wInterval:          0x0020
bSyncAddress:         0x40

Two main things we’ll need to start off are:

idVendor:           0x045E (Microsoft)
idProduct:          0x028E

Use these to identify the device.

First we’ll just make a minimal dummy driver to make sure compiling from the DDK works, and we’re able to detect the device and so on.

Windows development is confusing to me in general, but it seems like the intent of the 98 DDK is that you create your drivers inside it, maybe there’s a better way of doing this, but it’s what the documentation seems to imply.

So make a new directory in the 98 DDK to contain our new driver:

C:\98DDK\SRC\USB\360USB

Inside here we need to create a few files:

MAKEFILE containing:

!INCLUDE $(NTMAKEENV)\makefile.def

SOURCES containing:

TARGETNAME=360usb
TARGETTYPE=DRIVER
TARGETPATH=bin
DRIVERTYPE=WDM
SOURCES=360usb.c

360usb.c containing:

#include <wdm.h>

NTSTATUS DriverEntry(PDRIVER_OBJECT driverObject, PUNICODE_STRING regPath) {
  DbgPrint("Hello World!\r\n");

  return STATUS_UNSUCCESSFUL;
}

360usb.inf containing (this is where idVendor and idProduct are used:

[Version]
Signature = "$Chicago$"
Provider = %Provider%
DriverVer = 29/01/2026,1.0.0000.0000
LayoutFile = layout.inf, layout1.inf, layout2.inf

[DestinationDirs]
360USB.CopyFiles = 10,System32\Drivers

[Manufacturer]
%Vendor% = Microsoft

[Microsoft]
%Product% = 360USB,USB\VID_045E&PID_028E

[360USB]
AddReg = 360USB.AddReg
CopyFiles = 360USB.CopyFiles

[360USB.AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,360usb.sys

[360USB.CopyFiles]
360usb.sys

[Strings]
Provider = "Moyashi"
Vendor = "Microsoft"
Product = "Xbox 360 Controller"

MAYBE? Need to modify setenv.bat in the ddk to include call C:\MSSDK\setenv.bat C:\MSSDK in :setenv section? dunno

Now you should be able to open the “Free Build Environment” of the 98 DDK (if it wasn’t already) and compile the driver:

cd C:\98ddk\src\usb\360usb
build -bcv
[Version]
Signature="$CHICAGO$"
Class=HIDClass
ClassGuid={745A17A0-74D3-11D0-B6FE-00A0C90F57DA}
Provider=%Provider%
DriverVer=01/29/2026,1.0.0.0

[Manufacturer]
%Vendor%=Models

[Models]
%Product%=Install,USB\VID_045E&PID_028E

[Install.NT]
CopyFiles=CopyFilesSection
AddReg=AddRegSection

[DestinationDirs]
CopyFilesSection=10,System32\Drivers

[SourceDisksNames]
1=%DiskName%,,,

[SourceDisksFiles]
360usb.sys=1

[CopyFilesSection]
360usb.sys,,,2

[AddRegSection]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,360usb.sys

[Strings]
Provider="Dummy Provider"
Vendor="Microsoft (Dummy)"
Product="Xbox 360 Controller Dummy"
DiskName="Dummy Folder"