Thread: DeviceIOControl()

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    206

    DeviceIOControl()

    I'm getting error 87 (Invalid parameter) from DeviceIOControl():
    Code:
    #define CTL_CODE( DeviceType, Function, Method, Access ) (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) )
    
    #define FILE_DEVICE_UNKNOWN		0x00000022
    #define IOCTL_UNKNOWN_BASE		FILE_DEVICE_UNKNOWN
    #define METHOD_BUFFERED			0
    #define FILE_READ_ACCESS		0x0001
    #define FILE_WRITE_ACCESS		0x0002
    
    #define IOCTL_CE_READMEMORY		CTL_CODE(IOCTL_UNKNOWN_BASE, 0x0800, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
    #define IOCTL_CE_WRITEMEMORY		CTL_CODE(IOCTL_UNKNOWN_BASE, 0x0801, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
    #define IOCTL_CE_OPENPROCESS    	CTL_CODE(IOCTL_UNKNOWN_BASE, 0x0802, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
    
    
    bool LoadDriver::WriteByte(DWORD _Address, BYTE _Byte, int _PID)
    {
    	unsigned long recv;
    		struct input 
    		{ 
    		   UINT_PTR processid; 
    		   void *startaddress; 
    		   unsigned short int bytestowrite;  
    		} _Input = {_PID, (void*)_Address, _Byte};
    		HANDLE mService = CreateFile("C:\\Rakion\\dbk32.sys", FILE_WRITE_DATA | FILE_READ_DATA, FILE_SHARE_READ | FILE_SHARE_WRITE,
    		NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    		cout<<GetLastError()<<"\n"<<flush;
    		DeviceIoControl(mService,IOCTL_CE_WRITEMEMORY,&_Input,sizeof(_Input),NULL,NULL,&recv,NULL);
    		cout<<GetLastError()<<"      "<<mService<<"\n"<<flush;
    	return 0;
    }
    As you can see, I used GetLastError(); after CreateFile and DeviceIoControl(); I get 0 (No Error) after CreateFile and 87 (Invalid parameter) after DeviceIoControl.

    Which parameter is wrong? I've tried at least 20 variations of the function.
    Last edited by Denethor2000; 11-04-2005 at 02:44 PM.

  2. #2
    Bioport Productions
    Join Date
    Oct 2005
    Posts
    215
    Invalid parameter means exactly what it says. Search google.com for DeviceIoControl and you'll find the definition, then figure out which parameter is wrong.
    -"What we wish, we readily believe, and what we ourselves think, we imagine others think also."
    PHP Code:
    sadf 

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    206
    Quote Originally Posted by durban
    Invalid parameter means exactly what it says. Search google.com for DeviceIoControl and you'll find the definition, then figure out which parameter is wrong.
    I've done that, which is why I'm asking here.

    It's not a compiler error. Everything is correct according to MSDN.

    Don't be an ass.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Win32 Serial Communication & DeviceIoControl()
    By button_basher in forum Networking/Device Communication
    Replies: 1
    Last Post: 12-01-2005, 09:37 PM