Using IRP_MJ_CREATE (handle/createFile/access rom drive)

device driver

    Sponsored Links

    Next

  • 1. GetCommState()
    I'm using the function GetCommState() but I get an INVALID FUNCTION error. My handle is valid, I included windows.h. Anybody knows what the error means? -- Vern
  • 2. When does ImageProcessing Actually Get Called in a Print Driver?
    I am a little confused as to when the ImageProccessing function gets called in the OEMUNI dll. The documentation says: "The method can return the modified bitmap to Unidrv or send it directly to the print spooler." However it seems to be called by spoolsv.exe which I thought was the spooler. So how can ImageProcessing send the data back to Unidrv or to the spooler if it is already being called by the spooler. I trying to follow the flow of execution so I can get a bitmap driver running fo a project that I need to demo. Also, my ImageProcessing function is only called once. As a result all I seem to get is the top of the page. I know that the bitmap is supposed to be banded but I only seem to get one band. Is there some return value that needs to be set to indicate that you are ready to receive the next band? Thanks, Bob
  • 3. PCI Configuration Status Register Access
    Would like to read and write PCI Configuration Status Register, offset 6. For the particular device I am working with, the PLX 9056, this status register has dynamic information that I need to read/test and write/reset. I know how to read all the PCI Configuration registers via IRP_MN_READ_CONFIG, and presumably write them all back via IRP_MN_WRITE_CONFIG, but is there any way to read/write a single byte? Thanks.

Using IRP_MJ_CREATE (handle/createFile/access rom drive)

Postby Wm9pZGJlcmcx » Fri, 13 Mar 2009 00:43:03 GMT

Hello,

I think this is the right section? I'm trying to write some code which uses 
a handle to access a rom drive on windows xp. The code below produces this 
output, "Error opening drive\.<:debug1"   < been an arrow

The codes not correctly accessing the drive. I've been googling and I think 
it might be related to not issuing IRP_MJ_CREATE to request the use of a 
handle. This would put IRP_MJ_CREATE above createFile( handle) on the stack.

Has anyone any code or reference material which could help me in using 
IRP_MJ_CREATE, if its the problem? I've had I go but I dont think thats right.


Many thanks.

IRP_MJ_CREATE  http://www.**--****.com/ 
createFile  http://www.**--****.com/ (VS.85).aspx


#include <stdlib.h>    
#include <string.h>  
#include <stdio.h>   
#include <windows.h> 
#include <winioctl.h> 
       
 
 
 
    int main() 
    {    
         
        HANDLE device; 
        char deviceName[20]; 
         
        IoCallDriver( 
                IN PDEVICE_OBJECT deviceName, 
        IN OUT PIRP IRP_MJ_CREATE, 
        ); 
 
        strcpy(deviceName, "\\\\.\\e:"); 
                IRP_MJ_CREATE; 
        device = CreateFile(deviceName, GENERIC_READ | GENERIC_WRITE, 
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0); 
         
        if(device == INVALID_HANDLE_VALUE) //Error opening drive 
        { 
           printf("Error opening drive"); 
        } 
         
        printf("%s", deviceName); 
 
        printf("debug1"); 
 
 
    } 

Re: Using IRP_MJ_CREATE (handle/createFile/access rom drive)

Postby Maxim S. Shatskih » Sat, 14 Mar 2009 06:02:49 GMT

> a handle to access a rom drive on windows xp. The code below produces this 

And what is the return value of GetLastError?

-- 
Maxim S. Shatskih
Windows DDK MVP
 XXXX@XXXXX.COM 
 http://www.**--****.com/ 


Re: Using IRP_MJ_CREATE (handle/createFile/access rom drive)

Postby Tim Roberts » Tue, 17 Mar 2009 06:57:46 GMT



You have a number of confusions here.  First, this is NOT the code you are
really compiling.  This code does not actually compile (in part beause
PDEVICE_OBJECT is not defined).

Second, IoCallDriver is a kernel API.  It is not used by user-mode code.
When you call CreateFile, that gets translated to kernel mode and is sent
to the driver as an IRP_MJ_CREATE request on your behalf.

Third, you don't really have "\\\\.\\e:" in the code you are using.  I'm
guessing you really have "\\.\e:", or something similar, because that's the
only way you could have produced the output you had.

Have you done any C programming before?  What is it that you are hoping to
do with the CD drive, once you get it open?
-- 
Tim Roberts,  XXXX@XXXXX.COM 
Providenza & Boekelheide, Inc.

Similar Threads:

1.Obtaining Driver handle in Vista using CreateFile()

Folks,

I am having trouble obtaining a handle to a WDF driver using 
CreateFile(DosDeviceName, other parameters) in Vista. 

My driver is a software only driver and with some help from Chkinf was able 
to muck around with my inf file to get the driver successfully install (I 
make this statement based on the fact that the setupact.log in the windows 
folder doesn't have any errors related to this particular driver listed and 
there are no bangs or questions marks next to my driver in Device Manager). 
Initially the chkinf complained about not recognizing the GUID and I had to 
use the class Name 'System' and the associated GUID to make chkinf happy and 
eventually Vista happy. Therefore my driver ended up under the 'System 
Devices' tree. 

Now when I try to open a handle to this driver using the Symbolic link name 
I am failing. Before this my driver was under the class name 'Test Tools' 
with some other GUID and WinXP 32 and 64 bit didn't have any problems with it.

Has anyone seen this before and point me towards the solution.

Thanks!

Ram
Driver Developer

2.Don't receive IRP_MJ_CREATE on a CreateFile

Hi,

I use CreateFile on my device to DeviceIoControl on it.
But AFAI understand I should receive IRP_MJ_CREATE on CreateFile and CLEANUP
& CLOSE on CloseHandle (am I right ?) but my driver does not receive these
events. But it receive these from other time (maybe explorer.exe).

What's the problem ?



3.why my DispatchCreate( ) doesn't responds the IRP_MJ_CREATE ( I mean createfile( ) )

  getlasterror( ) returns "2 " .

  But , my dirver is shown in the Winobj.exe or in the DevView.exe,
and see nothing singularity.









4.why my DispatchCreate( ) doesn't responds the IRP_MJ_CREATE ( I mean createfile( ) )

On 8 Apr, 08:26, "OCEAN.Long" < XXXX@XXXXX.COM > wrote:
> getlasterror( ) returns "2 " .
>>
>> But , my dirver is shown in the Winobj.exe or in the DevView.exe,>
> and see nothing singularity.

Make sure you clear the DO_INITIALISING flag from thew device object
at the end of  AddDevice.

Without doing this the IO manager wont forward you any IRPs

5.IRP_MJ_CREATE is called twice with one createfile call from application

Hi,
I have a usb driver.I am trying to open it and close the file in my
application.I call createfile and closefile only once in my
application.but in my driver IRP_MJ_CREATE and IRP_MJ_CLOSE are called
twice.It sounds very different to me.Is there any scenario that
IRP_MJ_CREATE is called automatically without my application calling
createfile.why is it calling twice??????

This is my log

00000000	0.00000000	MYDRIVER - Entering DriverEntry: DriverObject
82D18030
00000001	0.00000531	MYDRIVER - Running under 2000
00000002	0.00021148	MYDRIVER - NEW Entering AddDevice: DriverObject
82D18030, pdo 826CBBA8 (Max Dev Count 5)
00000003	0.00023774	MYDRIVER - IoCreateDevice returned - 0
00000004	0.00024277	MYDRIVER - Successfully created 0 device object.
00000005	0.00027015	MYDRIVER - status of IoCreateSymbolicLink - 0
00000006	0.00035675	MYDRIVER - PNP Request
(IRP_MN_QUERY_RESOURCE_REQUIREMENTS)
00000007	0.00041681	MYDRIVER - PNP Request
(IRP_MN_FILTER_RESOURCE_REQUIREMENTS)
00000008	0.00042659	MYDRIVER - PNP Request (IRP_MN_START_DEVICE)
00000009	0.00061823	MYDRIVER-KEWAIT:103
00000010	0.00881146	MYDRIVER-status SendAwaitUrb:0
00000011	0.00881732	MYDRIVER-status SendAwaitUrb:0
00000012	0.00885811	MYDRIVER-KEWAIT:103
00000013	0.01478121	MYDRIVER-status SendAwaitUrb:0
00000014	0.01478540	MYDRIVER-status SendAwaitUrb:0
00000015	0.01481278	MYDRIVER-KEWAIT:103
00000016	0.02277859	MYDRIVER-status SendAwaitUrb:0
00000017	0.02278278	MYDRIVER-status SendAwaitUrb:0
00000018	0.02278949	MYDRIVER - Configuring device from BRCM
00000019	0.02281631	MYDRIVER-KEWAIT:103
00000020	0.03277679	MYDRIVER-status SendAwaitUrb:0
00000021	0.03278098	MYDRIVER-status SendAwaitUrb:0
00000022	0.03278601	MYDRIVER - Product is BRCM2037
00000023	0.03281199	MYDRIVER-KEWAIT:103
00000024	0.04477552	MYDRIVER-status SendAwaitUrb:0
00000025	0.04477971	MYDRIVER-status SendAwaitUrb:0
00000026	0.04478530	MYDRIVER - Serial number is 524444414442
00000027	0.04480709	MYDRIVER-KEWAIT:103
00000028	0.05177474	MYDRIVER-status SendAwaitUrb:0
00000029	0.05177893	MYDRIVER-status SendAwaitUrb:0
00000030	0.05180183	MYDRIVER-KEWAIT:103
00000031	0.06877326	MYDRIVER-status SendAwaitUrb:0
00000032	0.06877773	MYDRIVER-status SendAwaitUrb:0
00000033	0.06878360	MYDRIVER - BLUETOOTH Configuration Descriptor:
00000034	0.06878752	MYDRIVER - --------------------------
00000035	0.06879170	MYDRIVER - bLength 9
00000036	0.06879590	MYDRIVER - bDescriptorType 0x2
00000037	0.06880037	MYDRIVER - wTotalLength 0x37
00000038	0.06880455	MYDRIVER - bNumInterfaces 0x2
00000039	0.06880874	MYDRIVER - iConfiguration 0x0
00000040	0.06881294	MYDRIVER - bConfigurationValue 0x1
00000041	0.06881741	MYDRIVER - bmAttributes 0xc0
00000042	0.06882159	MYDRIVER - MaxPower  0x32
00000043	0.06882606	MYDRIVER - BLUETOOTH Interface Descriptor:
00000044	0.06882998	MYDRIVER - --------------------------
00000045	0.06883389	MYDRIVER - bLength 9
00000046	0.06883808	MYDRIVER - bDescriptorType 0x4
00000047	0.06884227	MYDRIVER - bInterfaceNumber 0x0
00000048	0.06884646	MYDRIVER - bAlternateSetting 0x0
00000049	0.06885065	MYDRIVER - bNumEndpoints 0x3
00000050	0.06885484	MYDRIVER - bInterfaceClass 0xe0
00000051	0.06885903	MYDRIVER - bInterfaceSubClass 0x1
00000052	0.06886322	MYDRIVER - bInterfaceProtocol 0x1
00000053	0.06886713	MYDRIVER - iInterface 0x0
00000054	0.06887133	MYDRIVER - interfaceindex0x1
00000055	0.06887551	MYDRIVER - BLUETOOTH Interface Descriptor:
00000056	0.06887943	MYDRIVER - --------------------------
00000057	0.06888334	MYDRIVER - bLength 9
00000058	0.06888752	MYDRIVER - bDescriptorType 0x4
00000059	0.06889172	MYDRIVER - bInterfaceNumber 0x1
00000060	0.06889591	MYDRIVER - bAlternateSetting 0x0
00000061	0.06890010	MYDRIVER - bNumEndpoints 0x0
00000062	0.06890429	MYDRIVER - bInterfaceClass 0xfe
00000063	0.06890848	MYDRIVER - bInterfaceSubClass 0x1
00000064	0.06891267	MYDRIVER - bInterfaceProtocol 0x1
00000065	0.06891658	MYDRIVER - iInterface 0x1
00000066	0.06892077	MYDRIVER - interfaceindex0x2
00000067	0.16381468	MYDRIVER-status SendAwaitUrb:0
00000068	0.16382138	MYDRIVER-status SendAwaitUrb:0
00000069	0.16382697	MYDRIVER - In  StartInterruptUrb
00000070	0.16383144	MYDRIVER - interrupt polling is set to pending
00000071	0.16383535	MYDRIVER - Device not busy
00000072	0.16383982	MYDRIVER - After lock is acquired
00000073	0.16399543	MYDRIVER - To WORKING from STOPPED
00000074	0.16417757	MYDRIVER - PNP Request (IRP_MN_QUERY_CAPABILITIES)
00000075	0.16422534	MYDRIVER - PNP Request
(IRP_MN_QUERY_PNP_DEVICE_STATE)
00000076	0.16423596	MYDRIVER - PNP Request
(IRP_MN_QUERY_DEVICE_RELATIONS)
00000077	3.51514268	MYDRIVER - IRP_MJ_CREATE
00000078	3.51514983	MYDRIVER - In  StartInterruptUrb
00000079	3.51515436	MYDRIVER - interrupt polling is already pending
00000080	3.51515865	MYDRIVER - Unable to start Interrupt URB; Device
busy
00000081	3.51516318	MYDRIVER - Unable to start Interrupt URB; Device
busy
00000082	3.51517487	MYDRIVER - IRP_MJ_CLEANUP
00000083	3.51518250	MYDRIVER-status :0
00000084	3.51518774	MYDRIVER - IRP_MJ_CLOSE
00000085	3.51519203	MYDRIVER- Inside stopInterruptUrb
00000086	3.51524067	MYDRIVER - Inside stopBulkinUrb
00000087	3.51526356	MYDRIVER - No queue elements for freeing.
00000088	3.51533651	MYDRIVER - IRP_MJ_CREATE
00000089	3.51534057	MYDRIVER - In  StartInterruptUrb
00000090	3.51534486	MYDRIVER - interrupt polling is already pending
00000091	3.51534939	MYDRIVER - Unable to start Interrupt URB; Device
busy
00000092	3.51535368	MYDRIVER - Unable to start Interrupt URB; Device
busy
00000093	3.51911402	MYDRIVER - servicing OnInterrupt
00000094	3.51912379	MYDRIVER - Interrupt polling IRP 82912868 failed -
C0000120 (USBD status C0010000)
00000095	3.51914978	MYDRIVER - Bulkin polling IRP 828D0978 failed -
C0000120 (USBD status C0010000)
00000096	3.56396532	MYDRIVER - IRP_MJ_CLEANUP
00000097	3.56397510	MYDRIVER-status :0
00000098	3.56398082	MYDRIVER - IRP_MJ_CLOSE
00000099	3.56398582	MYDRIVER - No queue elements for freeing.
00000100	7.91411686	MYDRIVER - PNP Request
(IRP_MN_QUERY_DEVICE_RELATIONS)
00000101	7.91412926	MYDRIVER - PNP Request
(IRP_MN_QUERY_DEVICE_RELATIONS)
00000102	7.91414309	MYDRIVER - PNP Request (IRP_MN_SURPRISE_REMOVAL)
00000103	7.91414976	MYDRIVER - Inside stopdevice 1
00000104	7.91415691	MYDRIVER - Config descriptor 8290BDF0
00000105	7.91416121	MYDRIVER - To SURPRISEREMOVED from WORKING
00000106	7.92438555	MYDRIVER - PNP Request (IRP_MN_REMOVE_DEVICE)
00000107	7.92439508	MYDRIVER -HandleRemoveDevice oktouch 0
00000108	7.92439938	MYDRIVER - Inside stopdevice 0
00000109	7.92440510	MYDRIVER - To REMOVED from SURPRISEREMOVED
00000110	7.92445374	MYDRIVER - Inside DeleteInterruptUrb
00000111	7.92445850	MYDRIVER - Inside DeleteBulkinUrb
00000112	7.92451429	MYDRIVER - Entering DriverUnload: DriverObject
82D18030
00000113	7.92451954	MYDRIVER - Leaving DriverUnload: DriverObject
82D18030
00000000	0.00000000	MYDRIVER - Entering DriverEntry: DriverObject
82D18030

thanks in advance

6. ZwCreateFile handles vs. CreateFile handles

7. Have to disable and enable CD rom and other drives once when using

8. broken driver for dvd/cd rom drive (toshiba dvd-rom sd-c2402)



Return to device driver

 

Who is online

Users browsing this forum: No registered users and 45 guest