Смекни!
smekni.com

Комбинированное звуковое USB-устройство с функциями автономного MP3-плеера и поддержкой Bluetooth (стр. 17 из 17)

ULONG dwTotalSize = I.ReadSize(CURRENT); // Requested read size

ULONG dwBytesRead = 0; // Count of bytes read

I.Information() = dwBytesRead;

return I.PnpComplete(this, status);}

NTSTATUS AT91UsbMassStorageDevice::Write(KIrp I){

t << "Entering AT91UsbMassStorageDevice::Write, " << I << EOL;

if (FALSE){

// Invalid parameter in the Write request

I.Information() = 0;

return I.PnpComplete(this, STATUS_INVALID_PARAMETER);}

// Always ok to write 0 elements.

if (I.WriteSize() == 0){

I.Information() = 0;

return I.PnpComplete(this, STATUS_SUCCESS);}

NTSTATUS status = STATUS_SUCCESS;

KMemory Mem(I.Mdl()); // Declare a memory object

// Use the memory object to create a pointer to the caller's buffer

PUCHAR pBuffer = (PUCHAR) Mem.VirtualAddress();

ULONG dwTotalSize = I.WriteSize(CURRENT);

ULONG dwBytesSent = 0;

I.Information() = dwBytesSent;

return I.PnpComplete(this, status);}

NTSTATUS AT91UsbMassStorageDevice::DeviceControl(KIrp I){

NTSTATUS status;

t << "Entering AT91UsbMassStorageDevice::Device Control, " << I << EOL;

switch (I.IoctlCode()){

default:

// Unrecognized IOCTL request

status = STATUS_INVALID_PARAMETER;

break;}

if (status == STATUS_PENDING){return status;}

else{return I.PnpComplete(this, status);}}

AT91UsbMassStorageDevice.h

// AT91UsbMassStorageDevice.h

// Generated by DriverWizard version DriverStudio 2.0.0 (Build 526)

// Requires Compuware's DriverWorks classes

#ifndef __AT91UsbMassStorageDevice_h__

#define __AT91UsbMassStorageDevice_h__

class AT91UsbMassStorageDevice : public KPnpDevice

{// Constructors

public:

SAFE_DESTRUCTORS;

AT91UsbMassStorageDevice(PDEVICE_OBJECT Pdo, ULONG Unit);

~AT91UsbMassStorageDevice();

// Member Functions

public:

DEVMEMBER_DISPATCHERS

virtual NTSTATUS OnStartDevice(KIrp I);

virtual NTSTATUS OnStopDevice(KIrp I);

virtual NTSTATUS OnRemoveDevice(KIrp I);

virtual NTSTATUS DefaultPnp(KIrp I);

virtual NTSTATUS DefaultPower(KIrp I);

#ifdef _COMMENT_ONLY

virtual NTSTATUS CleanUp(KIrp I); // COMMENT_ONLY

virtual NTSTATUS Create(KIrp I); // COMMENT_ONLY

virtual NTSTATUS Close(KIrp I); // COMMENT_ONLY

virtual NTSTATUS DeviceControl(KIrp I); // COMMENT_ONLY

virtual NTSTATUS SystemControl(KIrp I); // COMMENT_ONLY

virtual NTSTATUS Read(KIrp I); // COMMENT_ONLY

virtual NTSTATUS Write(KIrp I); // COMMENT_ONLY

#endif

// Member Data

protected:

ULONG m_Unit;

KUsbLowerDevice m_Lower;

KUsbInterface m_Interface;};

#endif

interface.h

// interface.h - device interface classes for AT91UsbMassStorage

#define AT91UsbMassStorageDevice_CLASS_GUID &bsol;

{ 0x636be6b4, 0x408c, 0x4b38, { 0x93, 0x4e, 0xac, 0xf3, 0x75, 0x71, 0xff, 0x9d } }

function.h

// function.h // This file controls which driver functions are enabled.

#ifndef __function_h__

#define __function_h__

#define DRIVER_FUNCTION_CREATE

#define DRIVER_FUNCTION_CLOSE

#define DRIVER_FUNCTION_DEVICE_CONTROL

#define DRIVER_FUNCTION_READ

#define DRIVER_FUNCTION_WRITE

#define DRIVER_FUNCTION_ADD_DEVICE

#define DRIVER_FUNCTION_PNP

#define DRIVER_FUNCTION_POWER

#define DRIVER_FUNCTION_SYSTEM_CONTROL

#define DRIVER_FUNCTION_UNLOAD

#define DRIVER_FUNCTION_CLEANUP

#endif

AT91UsbMassStorage.inf

;--------- Version Section ---------------------------------------------------

[Version]

Signature="$Windows 95$"

Provider=%ProviderName%

Class=NewDeviceClass

ClassGUID={ff646f80-8def-11d2-9449-00105a075f6b}

; 9X Style

[ClassInstall]

Addreg=Class_AddReg

; NT Style

[ClassInstall32]

Addreg=Class_AddReg

[Class_AddReg]

HKR,,,,%DeviceClassName%

HKR,,Icon,,"-18"

;--------- DestinationDirs Section -------------------------------------------

[DestinationDirs]

AT91UsbMassStorage_Files_Driver = 10,System32&bsol;Drivers

;--------- Manufacturer and Models Sections ----------------------------------

[Manufacturer]

%MfgName%=Mfg0

[Mfg0]

%DeviceDesc%=AT91UsbMassStorage_DDI, USB&bsol;VID_FFF2&PID_FFF1

;---------- DDInstall Sections -----------------------------------------------

; --------- Windows 9X -----------------

; Experimentation has shown that DDInstall root names greater than 19 characters

; cause problems in Windows 98

[AT91UsbMassStorage_DDI]

CopyFiles=AT91UsbMassStorage_Files_Driver

AddReg=AT91UsbMassStorage_9X_AddReg

[AT91UsbMassStorage_9X_AddReg]

HKR,,DevLoader,,*ntkern

HKR,,NTMPDriver,,AT91UsbMassStorage.sys

HKR, "Parameters", "BreakOnEntry", 0x00010001, 0

; --------- Windows NT -----------------

[AT91UsbMassStorage_DDI.NT]

CopyFiles=AT91UsbMassStorage_Files_Driver

AddReg=AT91UsbMassStorage_NT_AddReg

[AT91UsbMassStorage_DDI.NT.Services]

Addservice = AT91UsbMassStorage, 0x00000002, AT91UsbMassStorage_AddService

[AT91UsbMassStorage_AddService]

DisplayName = %SvcDesc%

ServiceType = 1 ; SERVICE_KERNEL_DRIVER

StartType = 3 ; SERVICE_DEMAND_START

ErrorControl = 1 ; SERVICE_ERROR_NORMAL

ServiceBinary = %10%&bsol;System32&bsol;Drivers&bsol;AT91UsbMassStorage.sys

[AT91UsbMassStorage_NT_AddReg]

HKLM, "System&bsol;CurrentControlSet&bsol;Services&bsol;AT91UsbMassStorage&bsol;Parameters",&bsol;

"BreakOnEntry", 0x00010001, 0

; --------- Files (common) -------------

[AT91UsbMassStorage_Files_Driver]

AT91UsbMassStorage.sys

;--------- Strings Section ---------------------------------------------------

[Strings]

ProviderName="Your Company Name here"

MfgName="Name of HW Manufacturer here"

DeviceDesc="Description of Device here"

DeviceClassName="Description of Device class here"

SvcDesc="Description of NT service here"