Martin,
Of course sorry, I can do that, below is the driver entry and create calls
for the driver we’ve been trying to develop, as well as the inf for loading
this driver (this is derived from an example from the code project at
http://www.codeproject.com/KB/system/WDM_Driver_development.aspx), again
thank you for your help with this. Of note with this posted code is that we
at this point are just trying to get our test suite (written for unix) to
talk to the device, then comes the fun (hard part) of porting the driver
control from unix. If there is another peice of the code you think might be
helpful I can provide that as well, I was trying to keep this down to the
parts which I suspect are causing the problem so as not to send a giant
email.
From the driver:
NTSTATUS
DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
DbgPrint(“In driver entry: begin\n”);
RtlInitUnicodeString(
&Global_sz_Drv_RegInfo,
RegistryPath->Buffer);
// Initialize function pointers
DriverObject->DriverUnload = DriverUnload;
//DriverObject->DriverStartIo = (PVOID)StartIo;
DriverObject->DriverExtension->AddDevice = AddDevice;
DriverObject->MajorFunction[IRP_MJ_CREATE] = PsdoDispatchCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = PsdoDispatchClose;
DriverObject->MajorFunction[IRP_MJ_READ] = PsdoDispatchRead;
DriverObject->MajorFunction[IRP_MJ_WRITE] = PsdoDispatchWrite;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
PsdoDispatchDeviceControl;
DriverObject->MajorFunction[IRP_MJ_POWER] = PsdoDispatchPower;
DriverObject->MajorFunction[IRP_MJ_PNP] = PsdoDispatchPnP;
DbgPrint(“In driver entry: end\n”);
return STATUS_SUCCESS;
}
NTSTATUS
AddDevice(
IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT PhysicalDeviceObject
)
{
ULONG DeviceExtensionSize;
PDEVICE_EXTENSION p_DVCEXT;
PDEVICE_OBJECT ptr_PDO;
NTSTATUS status;
UNICODE_STRING devname;
UNICODE_STRING dosdevname;
ULONG IdxPwrState;
static long lastIndex = -1;
long devIndex = InterlockedIncrement(&lastIndex);
WCHAR name[32];
WCHAR symname[32];
DbgPrint(“*******************************Update 4\n”);
_snwprintf(name, 32, L"\Device\OSEC%d", devIndex);
_snwprintf(symname, 32, L"\DosDevices\OSEC%d", devIndex);
RtlInitUnicodeString(&devname, name);
RtlInitUnicodeString(&dosdevname, symname);
// TODO (pryan) point at actual device location.
DbgPrint(“Loading device in to \Device\OSEC%d file\n”, devIndex);
//Get DEVICE_EXTENSION required memory space
DeviceExtensionSize = sizeof(DEVICE_EXTENSION);
status = IoCreateDevice(
DriverObject,
DeviceExtensionSize,
&devname,
FILE_DEVICE_UNKNOWN,
FILE_DEVICE_SECURE_OPEN,
TRUE,
&ptr_PDO
);
if (NT_SUCCESS(status)) {
ptr_PDO->Flags &= ~DO_DEVICE_INITIALIZING;
ptr_PDO->Flags |= DO_DIRECT_IO;
p_DVCEXT = ptr_PDO->DeviceExtension;
p_DVCEXT->DeviceObject = ptr_PDO;
RtlInitUnicodeString(
&p_DVCEXT->Device_Description,
L"This is a Direct I/O Driver for Pseudo Device\r\n"
L"Created by mjtsai 2003/8/4\r\n");
IoInitializeRemoveLock(
&p_DVCEXT->RemoveLock,
‘KCOL’,
0,
0
);
p_DVCEXT->DataBuffer = ExAllocatePool(
NonPagedPool, 1024);
RtlZeroMemory(
p_DVCEXT->DataBuffer,
1024);
//Initialize driver power state
p_DVCEXT->SysPwrState = PowerSystemWorking;
p_DVCEXT->DevPwrState = PowerDeviceD0;
//Initialize device power information
Global_PowerInfo_Ptr = ExAllocatePool(
NonPagedPool, sizeof(DEVICE_POWER_INFORMATION));
RtlZeroMemory(
Global_PowerInfo_Ptr,
sizeof(DEVICE_POWER_INFORMATION));
Global_PowerInfo_Ptr->SupportQueryCapability = FALSE;
Global_PowerInfo_Ptr->DeviceD1 = 0;
Global_PowerInfo_Ptr->DeviceD2 = 0;
Global_PowerInfo_Ptr->WakeFromD0 = 0;
Global_PowerInfo_Ptr->WakeFromD1 = 0;
Global_PowerInfo_Ptr->WakeFromD2 = 0;
Global_PowerInfo_Ptr->WakeFromD3 = 0;
Global_PowerInfo_Ptr->DeviceWake = 0;
Global_PowerInfo_Ptr->SystemWake = 0;
for (IdxPwrState = 0;
IdxPwrState < PowerSystemMaximum;
IdxPwrState++)
{
Global_PowerInfo_Ptr->DeviceState[IdxPwrState] = 0;
}
//Store next-layered device object
//Attach device object to device stack
p_DVCEXT->NextDeviceObject =
IoAttachDeviceToDeviceStack(ptr_PDO, PhysicalDeviceObject);
}
status = IoCreateSymbolicLink(&dosdevname, &devname);
if (!NT_SUCCESS(status)) {
DbgPrint(“Error creating symlink for device \Device\OSEC%d to
\DosDevices\OSEC%d\n”, devIndex, devIndex);
}
return status;
}
; A:\DevInst.inf
;
; Created by GenINF.
;
;
[Version]
Signature = “$Windows NT$”
Class=System
ClassGUID={4d36e97d-e325-11ce-bfc1-08002be10318}
Provider=%osecrobotics%
CatalogFile=MyCat.cat
DriverVer= 8/4/2003
[DestinationDirs]
DirectIODriver.Files.x86_12 = 12
[SourceDisksNames.x86]
0=%Desc_x860%
[SourceDisksNames.ia64]
[SourceDisksFiles.x86]
DirectDrv.sys=0,
[SourceDisksFiles.ia64]
[Manufacturer]
%osecrobotics%=osecrobotics
[osecrobotics]
%USB\VID_04d8&PID_fe2c.DeviceDesc%=DirectIODriver_Inst,USB\VID_04d8&PID_fe2c
[DirectIODriver_Inst.ntx86]
CopyFiles = DirectIODriver.Files.x86_12
[DirectIODriver_Inst.ntx86.Services]
AddService = DirectDrv,0x00000002,DirectIODriver_Service_Instx86,
[DirectIODriver_Service_Instx86]
ServiceType = %SERVICE_KERNEL_DRIVER%
StartType = %SERVICE_DEMAND_START%
ErrorControl = %SERVICE_ERROR_IGNORE%
ServiceBinary = %12%\DirectDrv.sys
[DirectIODriver.Files.x86_12]
DirectDrv.sys
[DirectIODriver_EventLog_Inst]
AddReg = DirectIODriver_EventLog_Inst.AddReg
[DirectIODriver_EventLog_Inst.AddReg]
HKR,EventMessageFile,%REG_EXPAND_SZ%,“%%SystemRoot%%\System32\IoLogMsg.dll”
HKR,TypesSupported,%REG_DWORD%,7
[Strings]
; *******Localizable Strings*******
mjtsai= “MjtsaiCorp”
Desc_x860= “MjtsaiCorp Systemdrivers”
DirectIODriverDesc= “Virtual Device 1.0.0.1 for Direct I/O Demo”
USB\VID_04d8&PID_fe2c.DeviceDesc= “OSEC Robotics 2.0FS v2.3”
; *******Non Localizable Strings*******
SERVICE_BOOT_START = 0x0
SERVICE_SYSTEM_START = 0x1
SERVICE_AUTO_START = 0x2
SERVICE_DEMAND_START = 0x3
SERVICE_DISABLED = 0x4
SERVICE_KERNEL_DRIVER = 0x1
SERVICE_ERROR_IGNORE = 0x0
SERVICE_ERROR_NORMAL = 0x1
SERVICE_ERROR_SEVERE = 0x2
SERVICE_ERROR_CRITICAL = 0x3
REG_EXPAND_SZ = 0x00020000
REG_DWORD = 0x00010001
On Sat, Jun 7, 2008 at 4:52 PM, Martin O’Brien
wrote:
> How about you post your code.
>
>
> mm
>
> Paul Ryan wrote:
>
>> After having gone down the suggested path for a couple of weeks I’m still
>> no closer to finding the answer to my previous question. It was odd however
>> that when running against the Process monitor, the Create file with my
>> device name was never run. I’ve tried using the fopen that comes with Visual
>> C++ 2008 and mingw fopen port and both have a similar issue. When running
>> with the mingw I don’t however get a Permission Denied message but rather an
>> Invalid Argument. If I however pass a device like the LTP1 or COM1 devices
>> to the fopen call there is no issue.
>>
>> Any help you can give on this issue would be greatly appreciated.
>>
>> Thanks,
>>
>> –
>> Paul Ryan
>> OSEC Robotics
>> xxxxx@gmail.com mailto:xxxxx
>>
>> On Wed, Apr 30, 2008 at 12:13 PM, Paul Ryan >> xxxxx@gmail.com>> wrote:
>>
>> Thanks guys I’ll give those a try.
>>
>>
>> On Wed, Apr 30, 2008 at 11:23 AM, >> mailto:xxxxx> wrote:
>>
>> Or, if you don’t have the source of your runtime, Sysinternals’
>> Process Monitor can capture the CreateFile flags for you too.
>>
>> -Stephen Cleary
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>>
>>
>>
>>
>> – Paul Ryan
>> xxxxx@gmail.com mailto:xxxxx
>>
>>
>>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
–
Paul Ryan
xxxxx@gmail.com</mailto:xxxxx></mailto:xxxxx></mailto:xxxxx>