1.
Application and Driver interactive access (other modes)
A, user layer incoming data exe part of the code
B, the drive layer receives the data and processes the SYS part of the code
C, drive layer to return data to the user layer
D, the user layer to obtain processing results
E, exception handling in the drive
"225"
“
A, user layer incoming data exe part of the code
Modify the header file Method_neither
#define Add_code Ctl_code (
File_device_unknown,
0x800
Method_neither,
file_any_access)
When talking about direct memory access mode, we have to talk about the method of Ctl_code macro again
Ctl_code (devicetype,function,method,acess);
method is the number of values that specify the mode of data passing:
method_buffered//using buffer mode operation 0
Method_in_direct//Direct Write Method 1
Method_out_direct//Direct read mode 2
Method_neither//Other methods 3
”
"280" Copy the Code of lesson 29th, modify it on this basis
2.
B, the drive layer receives the data and processes the SYS part of the code
Get the output buffer size
ULONG cbout = stack->parameters.deviceiocontrol.outputbufferlength;
VOID probeforread (__in PVOID Address, __in size_t Length, __in ULONG Alignment);
VOID probeforwrite (__inout PVOID Address, __in size_t Length, __in ULONG Alignment);
1 get input into buffer first address
UCHAR *inputbuffer= (UCHAR *) stack->parameters.deviceiocontrol.type3inputbuffer;
Try
{
Probeforread (inputbuffer,cbin,__alignof (int));
__except (Exception_execute_handler)
{
Kdprint ("Specifies that the memory is unreadable or not writable and will continue to execute the code behind \ n"));
}
Try
{
Operation Output Buffers
2 Get output Buffer first address
PVOID outputbuffer=pirp->userbuffer;
Determine if the pointer is writable
Probeforwrite (outputbuffer,cbout,4);
__except (Exception_execute_handler)
{
Kdprint ("Specifies that the memory is unreadable or not writable and will continue to execute behind
Code \ n "));
}
__alignof operator
Returns a value of type size_t, which is the size of the type alignment requirement (in bytes)
Format: __alignof (Type)
Comments:
Example:
Value of an expression
__alignof (char) 1
__alignof (short) 2
__alignof (int) 4
__alignof (__int64) 8
__alignof (float) 4
__alignof (Double) 8
__alignof (char*) 4
For the base type it has the same value as sizeof. But consider this example:
typedef struct {int A; double b;} S
__alignof (S) = = 8
In this case, the value of __alignof is the alignment requirement for the longest element in the struct
Similarly, for
#pragma pack (1)
#pragma pack ()
Add,sub,mul,div, String
Modify the EXE section
Modify the SYS section
yjx_driver_030_ actual combat EXE and SYS communication (other modes)