Drive layer Active send data to application layer __ Drive

Source: Internet
Author: User

Last reprinted a blog has introduced the drive layer to actively send data to the application layer method, one of the methods described below is somewhat different, the last time you created the event object at the application layer, creating MDL (Memory Descriptor) at the driver layer to implement synchronous communication, and this time creating virtual memory at the application tier, The driver translates the virtual address into a physical address and then turns it into a virtual address that the driver can access, as well as the purpose of memory sharing.

Driver Layer Part Code

Switch (IoControlCode)
{case
	2001:                         //Incoming shared memory
		 {
				buff = (Uchar *) irp-> AssociatedIrp.SystemBuffer;
				Memmove (&a,&buff[4],4);
				output= (char*) Mmmapiospace (Mmgetphysicaladdress ((void*) a), 256,0);
				break;
	 Case 2002:                         //Get semaphore
		 {
				buff = (Uchar *) Irp->associatedirp.systembuffer;
				Memmove (&appevent,&buff[0],4);
				Memmove (&sysevent,&buff[4],4);
				Obreferenceobjectbyhandle (appevent,generic_all,null,kernelmode,&appeventobject,null);
				Obreferenceobjectbyhandle (sysevent,generic_all,null,kernelmode,&syseventobject,null);
				break;
	...
}
The above is the application layer through the corresponding control code incoming events and shared memory, the next driver layer to actively relax the content to the application layer

		Memmove (&output[0],&a,4);
		KeSetEvent ((prkevent) appeventobject,0,0);
		KeWaitForSingleObject ((prkevent) syseventobject,executive,kernelmode,0,0);
		Keresetevent ((prkevent) syseventobject);
		Memmove (&a,&output[4],4);


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.