Using IRP_MJ_CREATE (handle/createFile/access rom drive)

This is a discussion on Using IRP_MJ_CREATE (handle/createFile/access rom drive) within the C Programming forums, part of the General Programming Boards category; Hello, I'm trying to write some code which uses a handle to access a rom drive on windows xp. The ...

  1. #1
    Registered User
    Join Date
    May 2008

    Using IRP_MJ_CREATE (handle/createFile/access rom drive)


    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\.E:"

    The codes not correctly accessing the drive. I've been googling and I think it might be related not issuing IRP_MJ_CREATE to request the use of a handle. According to msdn E (rom drive) should be set out as "\\.\E:"

    Has anyone any code or reference material which could help me in using IRP_MJ_CREATE, if its the problem?

    Many thanks.

    CreateFile Function

    #include <stdlib.h>   
    #include <string.h> 
    #include <stdio.h>  
    #include <windows.h>
    #include <winioctl.h>
    	int main()
    		HANDLE device;
    	    char deviceName[20];
    		strcpy(deviceName, "\\.\E:");
    		if(device == INVALID_HANDLE_VALUE) //Error opening drive
    		   printf("Error opening drive");
    		printf("%s", deviceName);

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    You may want to use double backslashes here:
    strcpy(deviceName, "\\.\E:");
    As you see from your printout, the name actually in deviceName is "\.E:", which is an illegal name.

    This also makes me doubt that you are a good enough programmer (yet!) to write driver code. It is far harder than writing user-mode code, since anything you do wrong will possibly affect the entire system, both in reliability/stability and correct execution of applications (e.g. you could easily write to a stray pointer and make your entire Windows installation useless).

    If you want advice on how to implement IRP_MJ_CREATE, then I suggest you post your code for it, not just the user-mode side.

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SATA HDD failure
    By PING in forum Tech Board
    Replies: 4
    Last Post: 12-23-2008, 12:25 AM
  2. Detect SCSI Hard Drive Serial Number
    By mercury529 in forum Windows Programming
    Replies: 3
    Last Post: 10-17-2006, 07:23 PM
  3. Replies: 2
    Last Post: 07-06-2005, 08:11 PM
  4. Spin A Drive and such
    By Seph_31 in forum C Programming
    Replies: 15
    Last Post: 11-20-2003, 06:04 PM
  5. A Word of Wisdom from DavidP
    By DavidP in forum A Brief History of
    Replies: 59
    Last Post: 05-28-2002, 04:39 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21