Driver layer:
Pio_stack_location stack = iogetcurrentirpstacklocation (pirp );
// Obtain the input buffer size
Ulong cbin = stack-> parameters. deviceiocontrol. inputbufferlength;
// Obtain the size of the output buffer.
Ulong cbout = stack-> parameters. deviceiocontrol. outputbufferlength;
// Obtain the ioctl code
Ulong code = stack-> parameters. deviceiocontrol. iocontrolcode;
Ctl_code (Devicetype,Function,Method,Access) // Ntddk. h
Method:
Method_buffered // buffer Mode
Method_in_direct or method_out_direct // direct ing address
Method_neither
If it is method_in_direct or method_out_direct, the input and buffer modes are the same, but the output is no longer the input address,
UseMmgetsystemaddressformdlsafe in pmdlMDL,
/* IRP-> mdladdress */In mm_page_priorityPriorityNormalpagepriority); ing
IfMethod_neither:
Input address int * inputbuffer = (int *) Stack-> parameters. deviceiocontrol. type3inputbuffer;
Output address: IRQ-> userbuffer
Before the operation, you must determine: probeforreadAndThe two functions probeforwrite determine whether they can be read and written.
Last
// Process the corresponding IPR
Pirp-> iostatus. Information = Info; // you can specify 0 bytes for the returned operation.
Pirp-> iostatus. Status = STATUS_SUCCESS; // return success
Iocompleterequest (pirp, io_no_increment); // indicates that the IRP is completed.
User Layer
1: createfile
2: bool winapi deviceiocontrol (
_ In handleHdevice,
_ In DWORDDwiocontrolcode,
_ In lpvoidLpinbuffer,
_ In DWORDNinbuffersize,
_ Out lpvoidLpoutbuffer,
_ In DWORDNoutbuffersize,
_ Out lpdwordLpbytesreturned,
_ In lpoverlappedLpoverlapped
);
Http://www.hztraining.com/bbs/showtopic-484.aspx