0 likes | 1 Views
## [Download Now](https://crackedmac.com/download-100-free-full-setup/)<br><br>Adobe Illustrator CC Pre-Activated Offline Installer Portable for Windows PC. The industry-standard vector graphics software lets you create logos, icons, drawings, typography, and illustrations for print, web, video, and mobile.
E N D
WINDOWS NT INTERNALS– 05 Computer Call September 22, 1997
DRIVER DEVELOPMENT ISSUES Driver design strategies • Used formal design methods • Data flow diagram • State machine models • Analysis of expected data repetition • List of external events and driver actions • Use of incremented development • Kind of kernel mode objects • Context and state information • Driver entry routine and unload routine • Use registry editor • Dispatch routines that process IRP_MJ_CREATE, IRP_MJ_CLOSE • Dispatch routines that process IRP_MJ_XXX,START I/O logic without starting the device • Real start I/O logic, interrupt service routine and DPC routine
CODING CONVENTIONS General recommendations • Avoid use of assembly language • Put platform specific code in its own module or within #if def /#end if statements • Use RtlXxx routines instead of standard C runtime library • Comment the code Naming conventions • Add driver specific prefix to each routines • Name the routine that describes what it does
DRIVER MEMORY ALLOCATION Memory available to drivers • Kernel stack • Paged pool- • Non paged pool-
WORKING WITH KERNEL STACK • Avoid kernel stack overflow by the guidelines •Don’t make deeply nested calls to internal routines • Limit the depth of recursion •Don’t build large temporary data structures • Working with the pool areas • Non paged pool- for routines running at or above DISPATCH_LEVEL IRQL • Non paged pool must succeed- memory for emergencies only • Non paged pool cache aligned- aligned on the natural boundary of a CPU data-cache line • Non paged pool cache aligned musts- temporary I/O buffer • Paged pool- for routines running below DISPATCH_LEVEL IRQL • Paged pool cache aligned- I/O buffer used by FSD
ZONE BUFFERS A zone buffer is a piece of driver allocated pool Steps to manage the zone buffers • Call exallocate pool and initialize zone buffer with exinitialize zone • Call either exallocate from zone or interlocked allocate from zone • Use either exfree to zone exinterlocked free to zone • Call exfree pool
LOOKASIDE LIST A linked list of fixed size memory blocks Steps to manage Lookaside list • Use exinitialize Xxx Lookaside list in drive entry routine • Call exallocate from Xxx Lookaside list • Call exfree to Xxx Lookaside list • Use exdelete Xxx Lookaside list
UNICODE STRING Unicode-string , * punicode-string Field USHORT Length USHORT Maximum Length PWSTR Buffer
SYNCHRONIZING MULTIPLE CPU’S • NT uses synchronization objects called spinlocks Spin Locks Operation CPU A CPU B Raise IRQL Repeat Request Spinlock Until Acquired f00,x=1 f00,y=2 Release Spinlock Raise IRQL Repeat Request Spinlock Until Acquired f00,x=10 f00,y=20 Release Spinlock Restore IRQL Restore IRQL Struct foo Spinlock for “f00” Int x; int y;
WRITING A DRIVER ENTRY ROUTINE • Driver entry routine runs at PASSIVE_LEVEL IRQL Parameters 1 . Pointer to drive object 2 .UNICODE_STRING containing path to the driver’s service key in registry e,g HKEY_LOCAL MACHINE\system \current control set\services\drive Steps in driver entry routine 1.Finding and allocating hardware 2.Initialize the driver object 3.Call IO create controller in case of multiunit controller 4.Call IO create device to create device object 5.Make device visible by calling IO create symbolic link 6.Connect device to interrupt object and DPC objects 7.Repeat steps 3-6 for all controllers/devices 8.Return STATUS_SUCCESS to I/O Manager
INITIALIZING DRIVER ENTRY POINTS • Routine responsible for setting up function pointers • Function pointers •Functions with explicit slots in the drive object •IRP dispatch functions
• Creating device objects • IO create device takes description of your device and returns a device object •IO create device links device object into list of devices • Choosing a buffering strategy • Buffered I/O or direct I/O • Done by Oring flags field of device object •DO_BUFFERD_IO •DO_DIRECT_IO
WRITING REINITIALIZE ROUTINES • Registers a reinitialize routine by calling IO register device reinitialization • Routines runs at PASSIVE_LEVEL IRQL PARAMETERS • Pointer to driver object • Context block specified at registration • Count of reinitialization calls
WRITING AN UNLOAD ROUTINE • Routine runs at PASSIVE_LEVEL IRQL PARAMETERS • Pointer to driver object Steps in unload routine • Save the state of the device in registry • Disable interrupts from the device • Deallocate hardware • Use IO delete symbol link • Remove device object using IO delete device • Repeat step 4-5 in case of multiunit controller and delete controller object • Repeat steps 4-6 for all controllers and devices • Deallocate any pool
WRITING SHUTDOWN ROUTINES • Routine runs at PASSIVE_LEVEL IRQL • Put the device into a known state PARAMETERS • Pointer to driver object • Pointer to shutdown IRP • To receive shutdown notifications,call IO register shutdown notification