Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1013 lines
27 KiB

  1. /*++
  2. Copyright (c) 1991 - 2001 Microsoft Corporation
  3. Module Name:
  4. ##### #### ### ##### ## ### ## ## #### ##### #####
  5. ## ## ## ## # ## ## ## ### ## ## ## # ## ## ## ##
  6. ## ## ## ### ## ## ## ## ## #### ## ## ## ## ##
  7. ## ## ## ### ## ## ## ## ## #### ## ## ## ## ##
  8. ## ## ## ### ##### ## ####### ## ## ##### #####
  9. ## ## ## # ## ## ## ## ## ## ## ## # ## ##
  10. ##### #### ### ## ##### ## ## ## ## #### ## ##
  11. Abstract:
  12. This module contains functions specfic to the
  13. display device. The logic in this module is not
  14. hardware specific, but is logic that is common
  15. to all hardware implementations.
  16. Author:
  17. Wesley Witt (wesw) 1-Oct-2001
  18. Environment:
  19. Kernel mode only.
  20. Notes:
  21. --*/
  22. #include "internal.h"
  23. PDISPLAY_DEVICE_EXTENSION g_DeviceExtension = NULL;
  24. NTSTATUS
  25. DoBitmapDisplay(
  26. IN PDISPLAY_DEVICE_EXTENSION DeviceExtension,
  27. IN PVOID BitmapBits,
  28. IN ULONG MsgCode
  29. );
  30. VOID
  31. SaDisplayProcessNotifyRoutine(
  32. IN HANDLE ParentId,
  33. IN HANDLE ProcessId,
  34. IN BOOLEAN Create
  35. );
  36. NTSTATUS
  37. SaDisplayLoadBitmapFromRegistry(
  38. IN PDISPLAY_DEVICE_EXTENSION DeviceExtension,
  39. IN PUNICODE_STRING RegistryPath,
  40. IN PWSTR ValueName,
  41. IN OUT PVOID *DataBuffer
  42. )
  43. /*++
  44. Routine Description:
  45. This routine loads a bitmap resource from the registry.
  46. The bitmaps are loaded from the driver's parameters key.
  47. Arguments:
  48. RegistryPath - Full path to the driver's registry key
  49. ValueName - Name of the value in the registry (also the bitmap name)
  50. DataBuffer - Pointer to a pointer that is allocated by this function.
  51. The allocated memory holds the bitmap's bits.
  52. Return Value:
  53. NT status code.
  54. --*/
  55. {
  56. NTSTATUS status;
  57. PKEY_VALUE_FULL_INFORMATION KeyInformation = NULL;
  58. __try {
  59. status = ReadRegistryValue(
  60. DeviceExtension->DriverExtension,
  61. RegistryPath,
  62. ValueName,
  63. &KeyInformation
  64. );
  65. if (!NT_SUCCESS(status)) {
  66. ERROR_RETURN( DeviceExtension->DeviceType, "SaDisplayLoadBitmapFromRegistry could not read bitmap", status );
  67. }
  68. if (KeyInformation->Type != REG_BINARY) {
  69. status = STATUS_OBJECT_TYPE_MISMATCH;
  70. __leave;
  71. }
  72. *DataBuffer = ExAllocatePool( NonPagedPool, KeyInformation->DataLength );
  73. if (*DataBuffer == NULL) {
  74. status = STATUS_INSUFFICIENT_RESOURCES;
  75. ERROR_RETURN( DeviceExtension->DeviceType, "Could not allocate pool", status );
  76. }
  77. RtlCopyMemory( *DataBuffer, (PUCHAR)KeyInformation + KeyInformation->DataOffset, KeyInformation->DataLength );
  78. status = STATUS_SUCCESS;
  79. } __finally {
  80. if (KeyInformation) {
  81. ExFreePool( KeyInformation );
  82. }
  83. if (!NT_SUCCESS(status)) {
  84. if (*DataBuffer) {
  85. ExFreePool( *DataBuffer );
  86. }
  87. }
  88. }
  89. return status;
  90. }
  91. NTSTATUS
  92. SaDisplayLoadAllBitmaps(
  93. IN PDISPLAY_DEVICE_EXTENSION DeviceExtension,
  94. IN PUNICODE_STRING RegistryPath
  95. )
  96. /*++
  97. Routine Description:
  98. This routine loads all bitmap resources from the registry.
  99. Arguments:
  100. DeviceExtension - Display device extension
  101. RegistryPath - Full path to the driver's registry key
  102. Return Value:
  103. NT status code.
  104. --*/
  105. {
  106. NTSTATUS Status;
  107. PVOID StartingBitmap = NULL;
  108. PVOID CheckDiskBitmap = NULL;
  109. PVOID ReadyBitmap = NULL;
  110. PVOID ShutdownBitmap = NULL;
  111. PVOID UpdateBitmap = NULL;
  112. __try {
  113. ExAcquireFastMutex( &DeviceExtension->DisplayMutex );
  114. Status = SaDisplayLoadBitmapFromRegistry( DeviceExtension, RegistryPath, DISPLAY_STARTING_PARAM, &StartingBitmap );
  115. if (!NT_SUCCESS(Status)) {
  116. REPORT_ERROR( DeviceExtension->DeviceType, "Could not load starting bitmap", Status );
  117. }
  118. Status = SaDisplayLoadBitmapFromRegistry( DeviceExtension, RegistryPath, DISPLAY_CHECKDISK_PARAM, &CheckDiskBitmap );
  119. if (!NT_SUCCESS(Status)) {
  120. REPORT_ERROR( DeviceExtension->DeviceType, "Could not load check disk bitmap", Status );
  121. }
  122. Status = SaDisplayLoadBitmapFromRegistry( DeviceExtension, RegistryPath, DISPLAY_READY_PARAM, &ReadyBitmap );
  123. if (!NT_SUCCESS(Status)) {
  124. REPORT_ERROR( DeviceExtension->DeviceType, "Could not load ready bitmap", Status );
  125. }
  126. Status = SaDisplayLoadBitmapFromRegistry( DeviceExtension, RegistryPath, DISPLAY_SHUTDOWN_PARAM, &ShutdownBitmap );
  127. if (!NT_SUCCESS(Status)) {
  128. REPORT_ERROR( DeviceExtension->DeviceType, "Could not load shutdown bitmap", Status );
  129. }
  130. Status = SaDisplayLoadBitmapFromRegistry( DeviceExtension, RegistryPath, DISPLAY_UPDATE_PARAM, &UpdateBitmap );
  131. if (!NT_SUCCESS(Status)) {
  132. REPORT_ERROR( DeviceExtension->DeviceType, "Could not load update bitmap", Status );
  133. }
  134. Status = STATUS_SUCCESS;
  135. DeviceExtension->StartingBitmap = StartingBitmap;
  136. DeviceExtension->CheckDiskBitmap = CheckDiskBitmap;
  137. DeviceExtension->ReadyBitmap = ReadyBitmap;
  138. DeviceExtension->ShutdownBitmap = ShutdownBitmap;
  139. DeviceExtension->UpdateBitmap = UpdateBitmap;
  140. } __finally {
  141. if (!NT_SUCCESS(Status)) {
  142. if (StartingBitmap) {
  143. ExFreePool( StartingBitmap );
  144. }
  145. if (CheckDiskBitmap) {
  146. ExFreePool( CheckDiskBitmap );
  147. }
  148. if (ReadyBitmap) {
  149. ExFreePool( ReadyBitmap );
  150. }
  151. if (ShutdownBitmap) {
  152. ExFreePool( ShutdownBitmap );
  153. }
  154. if (UpdateBitmap) {
  155. ExFreePool( UpdateBitmap );
  156. }
  157. }
  158. ExReleaseFastMutex( &DeviceExtension->DisplayMutex );
  159. }
  160. return Status;
  161. }
  162. NTSTATUS
  163. SaDisplayDisplayBitmap(
  164. IN PDISPLAY_DEVICE_EXTENSION DeviceExtension,
  165. IN PSA_DISPLAY_SHOW_MESSAGE Bitmap
  166. )
  167. /*++
  168. Routine Description:
  169. This routine calls the local display miniport to display a bitmap.
  170. Arguments:
  171. DeviceExtension - Display device extension
  172. Bitmap - Pointer to a SA_DISPLAY_SHOW_MESSAGE structure
  173. Return Value:
  174. NT status code.
  175. --*/
  176. {
  177. NTSTATUS Status = STATUS_SUCCESS;
  178. __try {
  179. if (DeviceExtension->DisplayType != SA_DISPLAY_TYPE_BIT_MAPPED_LCD) {
  180. Status = STATUS_INVALID_DEVICE_REQUEST;
  181. ERROR_RETURN( DeviceExtension->DeviceType, "The display does not support bitmapped LCD", Status );
  182. }
  183. Status = CallMiniPortDriverReadWrite(
  184. DeviceExtension,
  185. DeviceExtension->DeviceObject,
  186. TRUE,
  187. Bitmap,
  188. sizeof(SA_DISPLAY_SHOW_MESSAGE),
  189. 0
  190. );
  191. if (!NT_SUCCESS(Status)) {
  192. ERROR_RETURN( DeviceExtension->DeviceType, "Could not display the bitmap", Status );
  193. }
  194. } __finally {
  195. }
  196. return Status;
  197. }
  198. NTSTATUS
  199. SaDisplayClearDisplay(
  200. PDISPLAY_DEVICE_EXTENSION DeviceExtension
  201. )
  202. /*++
  203. Routine Description:
  204. This routine causes the local display to be cleared of any bitmap image.
  205. Arguments:
  206. DeviceExtension - Display device extension
  207. Return Value:
  208. NT status code.
  209. --*/
  210. {
  211. NTSTATUS Status = STATUS_SUCCESS;
  212. PSA_DISPLAY_SHOW_MESSAGE Bitmap = NULL;
  213. __try {
  214. if (DeviceExtension->DisplayType != SA_DISPLAY_TYPE_BIT_MAPPED_LCD) {
  215. Status = STATUS_INVALID_DEVICE_REQUEST;
  216. ERROR_RETURN( DeviceExtension->DeviceType, "The display does not support bitmapped LCD", Status );
  217. }
  218. Bitmap = (PSA_DISPLAY_SHOW_MESSAGE) ExAllocatePool( PagedPool, sizeof(SA_DISPLAY_SHOW_MESSAGE) );
  219. if (Bitmap == NULL) {
  220. Status = STATUS_INSUFFICIENT_RESOURCES;
  221. ERROR_RETURN( DeviceExtension->DeviceType, "Could not allocate pool", Status );
  222. }
  223. Bitmap->SizeOfStruct = sizeof(SA_DISPLAY_SHOW_MESSAGE);
  224. Bitmap->Width = DeviceExtension->DisplayWidth;
  225. Bitmap->Height = DeviceExtension->DisplayHeight;
  226. Bitmap->MsgCode = SA_DISPLAY_STARTING;
  227. RtlZeroMemory( Bitmap->Bits, SA_DISPLAY_MAX_BITMAP_SIZE );
  228. Status = SaDisplayDisplayBitmap( DeviceExtension, Bitmap );
  229. if (!NT_SUCCESS(Status)) {
  230. ERROR_RETURN( DeviceExtension->DeviceType, "Could not display bitmap", Status );
  231. }
  232. } __finally {
  233. if (Bitmap) {
  234. ExFreePool( Bitmap );
  235. }
  236. }
  237. return Status;
  238. }
  239. NTSTATUS
  240. SaDisplayStartDevice(
  241. IN PDISPLAY_DEVICE_EXTENSION DeviceExtension
  242. )
  243. /*++
  244. Routine Description:
  245. This is the local display specific code for processing
  246. the PNP start device request. The local display's
  247. capabilities are queried and then all the bitmap
  248. resources are loaded.
  249. Arguments:
  250. DeviceExtension - Display device extension
  251. Return Value:
  252. NT status code.
  253. --*/
  254. {
  255. NTSTATUS Status = STATUS_SUCCESS;
  256. SA_DISPLAY_CAPS DisplayCaps;
  257. Status = CallMiniPortDriverDeviceControl(
  258. DeviceExtension,
  259. DeviceExtension->DeviceObject,
  260. IOCTL_SA_GET_CAPABILITIES,
  261. NULL,
  262. 0,
  263. &DisplayCaps,
  264. sizeof(SA_DISPLAY_CAPS)
  265. );
  266. if (!NT_SUCCESS(Status)) {
  267. REPORT_ERROR( DeviceExtension->DeviceType, "Could not query miniport's capabilities", Status );
  268. return Status;
  269. }
  270. if (DisplayCaps.SizeOfStruct != sizeof(SA_DISPLAY_CAPS)) {
  271. REPORT_ERROR( DeviceExtension->DeviceType, "SA_DISPLAY_CAPS is the wrong size", STATUS_INVALID_BUFFER_SIZE );
  272. return STATUS_INVALID_BUFFER_SIZE;
  273. }
  274. DeviceExtension->DisplayType = DisplayCaps.DisplayType;
  275. DeviceExtension->DisplayHeight = DisplayCaps.DisplayHeight;
  276. DeviceExtension->DisplayWidth = DisplayCaps.DisplayWidth;
  277. Status = SaDisplayLoadAllBitmaps( DeviceExtension, &DeviceExtension->DriverExtension->RegistryPath );
  278. if (!NT_SUCCESS(Status)) {
  279. REPORT_ERROR( DeviceExtension->DeviceType, "Could not load all the bitmaps", Status );
  280. return Status;
  281. }
  282. Status = DoBitmapDisplay(
  283. (PDISPLAY_DEVICE_EXTENSION)DeviceExtension,
  284. ((PDISPLAY_DEVICE_EXTENSION)DeviceExtension)->StartingBitmap,
  285. SA_DISPLAY_STARTING
  286. );
  287. if (!NT_SUCCESS(Status)) {
  288. REPORT_ERROR( DeviceExtension->DeviceType, "Could not display starting bitmap", Status );
  289. }
  290. g_DeviceExtension = DeviceExtension;
  291. Status = PsSetCreateProcessNotifyRoutine(SaDisplayProcessNotifyRoutine,0);
  292. if (!NT_SUCCESS(Status)) {
  293. REPORT_ERROR( DeviceExtension->DeviceType, "Could not display starting bitmap", Status );
  294. }
  295. return STATUS_SUCCESS;
  296. }
  297. /*++
  298. Routine Description:
  299. This is the local display specific code for processing
  300. notification of process creation and termination.
  301. Process name is retrieved and checkdisk bitmap is
  302. displayed if "autochk.exe" is running.
  303. Arguments:
  304. HANDLE - Handle to parent process
  305. HANDLE - Handle to process
  306. BOOLEAN - Flag(Creation or Termination)
  307. Return Value:
  308. None.
  309. --*/
  310. VOID
  311. SaDisplayProcessNotifyRoutine(
  312. IN HANDLE ParentId,
  313. IN HANDLE ProcessId,
  314. IN BOOLEAN Create
  315. )
  316. {
  317. NTSTATUS Status;
  318. PSTR ImageName;
  319. PEPROCESS Process;
  320. if (!g_DeviceExtension)
  321. return;
  322. Status = PsLookupProcessByProcessId(
  323. ProcessId,
  324. &Process
  325. );
  326. if (!NT_SUCCESS(Status)) {
  327. return;
  328. }
  329. ImageName = (PSTR)PsGetProcessImageFileName(Process);
  330. _strlwr(ImageName);
  331. if (strcmp(ImageName,"autochk.exe") == 0) {
  332. if (Create) {
  333. if (g_DeviceExtension->CheckDiskBitmap) {
  334. Status = DoBitmapDisplay(
  335. g_DeviceExtension,
  336. g_DeviceExtension->CheckDiskBitmap,
  337. SA_DISPLAY_ADD_START_TASKS
  338. );
  339. }
  340. } else {
  341. if (g_DeviceExtension->StartingBitmap) {
  342. Status = DoBitmapDisplay(
  343. g_DeviceExtension,
  344. g_DeviceExtension->StartingBitmap,
  345. SA_DISPLAY_ADD_START_TASKS
  346. );
  347. }
  348. }
  349. }
  350. return;
  351. }
  352. NTSTATUS
  353. SaDisplayDeviceInitialization(
  354. IN PSAPORT_DRIVER_EXTENSION DriverExtension
  355. )
  356. /*++
  357. Routine Description:
  358. This is the local display specific code for driver initialization.
  359. This function is called by SaPortInitialize, which is called by
  360. the local display's DriverEntry function.
  361. Arguments:
  362. DriverExtension - Driver extension structure
  363. Return Value:
  364. NT status code.
  365. --*/
  366. {
  367. UNREFERENCED_PARAMETER(DriverExtension);
  368. return STATUS_SUCCESS;
  369. }
  370. NTSTATUS
  371. SaDisplayIoValidation(
  372. IN PDISPLAY_DEVICE_EXTENSION DeviceExtension,
  373. IN PIRP Irp,
  374. PIO_STACK_LOCATION IrpSp
  375. )
  376. /*++
  377. Routine Description:
  378. This is the local display specific code for processing
  379. all I/O validation for reads and writes.
  380. Arguments:
  381. DeviceExtension - Display device extension
  382. Irp - Pointer to an IRP structure that describes the requested I/O operation.
  383. IrpSp - Irp stack pointer
  384. Return Value:
  385. NT status code.
  386. --*/
  387. {
  388. ULONG Length;
  389. if (IrpSp->MajorFunction == IRP_MJ_READ) {
  390. Length = (ULONG)IrpSp->Parameters.Read.Length;
  391. } else if (IrpSp->MajorFunction == IRP_MJ_WRITE) {
  392. Length = (ULONG)IrpSp->Parameters.Write.Length;
  393. } else {
  394. REPORT_ERROR( DeviceExtension->DeviceType, "Invalid I/O request", STATUS_INVALID_PARAMETER_1 );
  395. return STATUS_INVALID_PARAMETER_1;
  396. }
  397. if (Length < sizeof(SA_DISPLAY_SHOW_MESSAGE)) {
  398. REPORT_ERROR( DeviceExtension->DeviceType, "I/O length != sizeof(SA_DISPLAY_SHOW_MESSAGE)", STATUS_INVALID_PARAMETER_2 );
  399. return STATUS_INVALID_PARAMETER_2;
  400. }
  401. //
  402. // For the display device we support the concept of
  403. // the user mode layer obtaining exclusive access
  404. // to the device.
  405. //
  406. ExAcquireFastMutex( &DeviceExtension->DisplayMutex );
  407. if (!DeviceExtension->AllowWrites) {
  408. ExReleaseFastMutex( &DeviceExtension->DisplayMutex );
  409. REPORT_ERROR( DeviceExtension->DeviceType, "Cannot write bitmap because the display is locked", STATUS_MEDIA_WRITE_PROTECTED );
  410. return STATUS_MEDIA_WRITE_PROTECTED;
  411. }
  412. ExReleaseFastMutex( &DeviceExtension->DisplayMutex );
  413. return STATUS_SUCCESS;
  414. }
  415. NTSTATUS
  416. SaDisplayShutdownNotification(
  417. IN PDISPLAY_DEVICE_EXTENSION DeviceExtension,
  418. IN PIRP Irp,
  419. PIO_STACK_LOCATION IrpSp
  420. )
  421. /*++
  422. Routine Description:
  423. This is the local display specific code for processing
  424. the system shutdown notification.
  425. Arguments:
  426. DeviceExtension - Display device extension
  427. Irp - Pointer to an IRP structure that describes the requested I/O operation.
  428. IrpSp - Irp stack pointer
  429. Return Value:
  430. NT status code.
  431. --*/
  432. {
  433. UNREFERENCED_PARAMETER(DeviceExtension);
  434. UNREFERENCED_PARAMETER(Irp);
  435. UNREFERENCED_PARAMETER(IrpSp);
  436. return STATUS_SUCCESS;
  437. }
  438. DECLARE_IOCTL_HANDLER( HandleDisplayLock )
  439. /*++
  440. Routine Description:
  441. This routine processes the private IOCTL_SADISPLAY_LOCK request. This
  442. IOCTL allows an applicatgion to lock out display writes for a period
  443. of time.
  444. Arguments:
  445. DeviceObject - The device object for the target device.
  446. Irp - Pointer to an IRP structure that describes the requested I/O operation.
  447. DeviceExtension - Pointer to the main port driver device extension.
  448. InputBuffer - Pointer to the user's input buffer
  449. InputBufferLength - Length in bytes of the input buffer
  450. OutputBuffer - Pointer to the user's output buffer
  451. OutputBufferLength - Length in bytes of the output buffer
  452. Return Value:
  453. NT status code.
  454. --*/
  455. {
  456. ExAcquireFastMutex( &((PDISPLAY_DEVICE_EXTENSION)DeviceExtension)->DisplayMutex );
  457. ((PDISPLAY_DEVICE_EXTENSION)DeviceExtension)->AllowWrites = FALSE;
  458. ExReleaseFastMutex( &((PDISPLAY_DEVICE_EXTENSION)DeviceExtension)->DisplayMutex );
  459. return CompleteRequest( Irp, STATUS_SUCCESS, 0 );
  460. }
  461. DECLARE_IOCTL_HANDLER( HandleDisplayUnlock )
  462. /*++
  463. Routine Description:
  464. This routine processes the private IOCTL_SADISPLAY_UNLOCK request. This
  465. IOCTL allows an applicatgion to unlock a previous lock.
  466. Arguments:
  467. DeviceObject - The device object for the target device.
  468. Irp - Pointer to an IRP structure that describes the requested I/O operation.
  469. DeviceExtension - Pointer to the main port driver device extension.
  470. InputBuffer - Pointer to the user's input buffer
  471. InputBufferLength - Length in bytes of the input buffer
  472. OutputBuffer - Pointer to the user's output buffer
  473. OutputBufferLength - Length in bytes of the output buffer
  474. Return Value:
  475. NT status code.
  476. --*/
  477. {
  478. ExAcquireFastMutex( &((PDISPLAY_DEVICE_EXTENSION)DeviceExtension)->DisplayMutex );
  479. ((PDISPLAY_DEVICE_EXTENSION)DeviceExtension)->AllowWrites = TRUE;
  480. ExReleaseFastMutex( &((PDISPLAY_DEVICE_EXTENSION)DeviceExtension)->DisplayMutex );
  481. return CompleteRequest( Irp, STATUS_SUCCESS, 0 );
  482. }
  483. NTSTATUS
  484. DoBitmapDisplay(
  485. IN PDISPLAY_DEVICE_EXTENSION DeviceExtension,
  486. IN PVOID BitmapBits,
  487. IN ULONG MsgCode
  488. )
  489. /*++
  490. Routine Description:
  491. This is an internal support function that displays a bitmap on the local display.
  492. Arguments:
  493. DeviceExtension - Pointer to the display specific device extension
  494. BitmapBits - Pointer to the bitmap bits to display
  495. MsgCode - Server appliance message code
  496. Return Value:
  497. NT status code.
  498. --*/
  499. {
  500. NTSTATUS Status;
  501. PSA_DISPLAY_SHOW_MESSAGE Bitmap = NULL;
  502. Status = SaDisplayClearDisplay( DeviceExtension );
  503. if (!NT_SUCCESS(Status)) {
  504. REPORT_ERROR( DeviceExtension->DeviceType, "Could not clear the local display", Status );
  505. return Status;
  506. }
  507. __try {
  508. if (BitmapBits == NULL) {
  509. Status = STATUS_DATA_ERROR;
  510. ERROR_RETURN( DeviceExtension->DeviceType, "Bitmap bits cannot be NULL", Status );
  511. }
  512. Bitmap = (PSA_DISPLAY_SHOW_MESSAGE) ExAllocatePool( PagedPool, sizeof(SA_DISPLAY_SHOW_MESSAGE) );
  513. if (Bitmap == NULL) {
  514. Status = STATUS_INSUFFICIENT_RESOURCES;
  515. ERROR_RETURN( DeviceExtension->DeviceType, "Could not allocate pool", Status );
  516. }
  517. Bitmap->SizeOfStruct = sizeof(SA_DISPLAY_SHOW_MESSAGE);
  518. Bitmap->Width = DeviceExtension->DisplayWidth;
  519. Bitmap->Height = DeviceExtension->DisplayHeight;
  520. Bitmap->MsgCode = MsgCode;
  521. RtlCopyMemory( Bitmap->Bits, BitmapBits, Bitmap->Height * (Bitmap->Width >> 3) );
  522. Status = SaDisplayDisplayBitmap( DeviceExtension, Bitmap );
  523. if (!NT_SUCCESS(Status)) {
  524. ERROR_RETURN( DeviceExtension->DeviceType, "Could not display bitmap", Status );
  525. }
  526. } __finally {
  527. if (Bitmap) {
  528. ExFreePool( Bitmap );
  529. }
  530. }
  531. return Status;
  532. }
  533. DECLARE_IOCTL_HANDLER( HandleDisplayBusyMessage )
  534. /*++
  535. Routine Description:
  536. This routine displays the busy message bitmap on the local display.
  537. Arguments:
  538. DeviceObject - The device object for the target device.
  539. Irp - Pointer to an IRP structure that describes the requested I/O operation.
  540. DeviceExtension - Pointer to the main port driver device extension.
  541. InputBuffer - Pointer to the user's input buffer
  542. InputBufferLength - Length in bytes of the input buffer
  543. OutputBuffer - Pointer to the user's output buffer
  544. OutputBufferLength - Length in bytes of the output buffer
  545. Return Value:
  546. NT status code.
  547. --*/
  548. {
  549. NTSTATUS Status;
  550. Status = DoBitmapDisplay(
  551. (PDISPLAY_DEVICE_EXTENSION)DeviceExtension,
  552. ((PDISPLAY_DEVICE_EXTENSION)DeviceExtension)->CheckDiskBitmap,
  553. SA_DISPLAY_ADD_START_TASKS
  554. );
  555. if (!NT_SUCCESS(Status)) {
  556. REPORT_ERROR( DeviceExtension->DeviceType, "Could not display busy bitmap", Status );
  557. return CompleteRequest( Irp, Status, 0 );
  558. }
  559. return CompleteRequest( Irp, STATUS_SUCCESS, 0 );
  560. }
  561. DECLARE_IOCTL_HANDLER( HandleDisplayShutdownMessage )
  562. /*++
  563. Routine Description:
  564. This routine displays the shutdown message bitmap on the local display.
  565. Arguments:
  566. DeviceObject - The device object for the target device.
  567. Irp - Pointer to an IRP structure that describes the requested I/O operation.
  568. DeviceExtension - Pointer to the main port driver device extension.
  569. InputBuffer - Pointer to the user's input buffer
  570. InputBufferLength - Length in bytes of the input buffer
  571. OutputBuffer - Pointer to the user's output buffer
  572. OutputBufferLength - Length in bytes of the output buffer
  573. Return Value:
  574. NT status code.
  575. --*/
  576. {
  577. NTSTATUS Status;
  578. Status = DoBitmapDisplay(
  579. (PDISPLAY_DEVICE_EXTENSION)DeviceExtension,
  580. ((PDISPLAY_DEVICE_EXTENSION)DeviceExtension)->ShutdownBitmap,
  581. SA_DISPLAY_SHUTTING_DOWN
  582. );
  583. if (!NT_SUCCESS(Status)) {
  584. REPORT_ERROR( DeviceExtension->DeviceType, "Could not display shutdown bitmap", Status );
  585. return CompleteRequest( Irp, Status, 0 );
  586. }
  587. return CompleteRequest( Irp, STATUS_SUCCESS, 0 );
  588. }
  589. DECLARE_IOCTL_HANDLER( HandleDisplayChangeLanguage )
  590. /*++
  591. Routine Description:
  592. This routine causes all internal butmaps to be reloaded from the registry.
  593. Arguments:
  594. DeviceObject - The device object for the target device.
  595. Irp - Pointer to an IRP structure that describes the requested I/O operation.
  596. DeviceExtension - Pointer to the main port driver device extension.
  597. InputBuffer - Pointer to the user's input buffer
  598. InputBufferLength - Length in bytes of the input buffer
  599. OutputBuffer - Pointer to the user's output buffer
  600. OutputBufferLength - Length in bytes of the output buffer
  601. Return Value:
  602. NT status code.
  603. --*/
  604. {
  605. NTSTATUS Status;
  606. Status = SaDisplayLoadAllBitmaps( (PDISPLAY_DEVICE_EXTENSION)DeviceExtension, &DeviceExtension->DriverExtension->RegistryPath );
  607. if (!NT_SUCCESS(Status)) {
  608. REPORT_ERROR( DeviceExtension->DeviceType, "Could not load all bitmaps", Status );
  609. }
  610. return CompleteRequest( Irp, Status, 0 );
  611. }
  612. NTSTATUS
  613. SaDisplayStoreBitmapInRegistry(
  614. IN PDISPLAY_DEVICE_EXTENSION DeviceExtension,
  615. IN PWSTR ValueName,
  616. IN PSA_DISPLAY_SHOW_MESSAGE SaDisplay
  617. )
  618. /*++
  619. Routine Description:
  620. This routine stores a bitmap in the registry.
  621. Arguments:
  622. RegistryPath - Full path to the driver's registry key
  623. ValueName - Name of the value in the registry (also the bitmap name)
  624. SaDisplay - Pointer to the bitmap to be stored
  625. Return Value:
  626. NT status code.
  627. --*/
  628. {
  629. NTSTATUS Status;
  630. Status = WriteRegistryValue(
  631. DeviceExtension->DriverExtension,
  632. &DeviceExtension->DriverExtension->RegistryPath,
  633. ValueName,
  634. REG_BINARY,
  635. SaDisplay->Bits,
  636. SaDisplay->Height * (SaDisplay->Width >> 3)
  637. );
  638. if (!NT_SUCCESS(Status)) {
  639. REPORT_ERROR( DeviceExtension->DeviceType, "WriteRegistryValue failed", Status );
  640. }
  641. return Status;
  642. }
  643. DECLARE_IOCTL_HANDLER( HandleDisplayStoreBitmap )
  644. {
  645. /*++
  646. Routine Description:
  647. This routine stores a bitmap in the registry for the display driver.
  648. Arguments:
  649. DeviceObject - The device object for the target device.
  650. Irp - Pointer to an IRP structure that describes the requested I/O operation.
  651. DeviceExtension - Pointer to the main port driver device extension.
  652. InputBuffer - Pointer to the user's input buffer
  653. InputBufferLength - Length in bytes of the input buffer
  654. OutputBuffer - Pointer to the user's output buffer
  655. OutputBufferLength - Length in bytes of the output buffer
  656. Return Value:
  657. NT status code.
  658. --*/
  659. NTSTATUS Status;
  660. PSA_DISPLAY_SHOW_MESSAGE SaDisplay = (PSA_DISPLAY_SHOW_MESSAGE) InputBuffer;
  661. __try {
  662. if (InputBuffer == NULL || InputBufferLength != sizeof(SA_DISPLAY_SHOW_MESSAGE)) {
  663. Status = STATUS_INVALID_PARAMETER_1;
  664. ERROR_RETURN( DeviceExtension->DeviceType, "Input buffer is invalid", Status );
  665. }
  666. if (SaDisplay->SizeOfStruct != sizeof(SA_DISPLAY_SHOW_MESSAGE)) {
  667. Status = STATUS_INVALID_PARAMETER_2;
  668. ERROR_RETURN( DeviceExtension->DeviceType, "SaDisplay->SizeOfStruct != sizeof(SA_DISPLAY_SHOW_MESSAGE)", Status );
  669. }
  670. if (SaDisplay->Width > ((PDISPLAY_DEVICE_EXTENSION)DeviceExtension)->DisplayWidth || SaDisplay->Height > ((PDISPLAY_DEVICE_EXTENSION)DeviceExtension)->DisplayHeight) {
  671. Status = STATUS_INVALID_PARAMETER_3;
  672. ERROR_RETURN( DeviceExtension->DeviceType, "SaDisplay->SizeOfStruct != sizeof(SA_DISPLAY_SHOW_MESSAGE)", Status );
  673. }
  674. switch (SaDisplay->MsgCode) {
  675. case SA_DISPLAY_STARTING:
  676. Status = SaDisplayStoreBitmapInRegistry( (PDISPLAY_DEVICE_EXTENSION)DeviceExtension, DISPLAY_STARTING_PARAM, SaDisplay );
  677. break;
  678. case SA_DISPLAY_ADD_START_TASKS:
  679. Status = SaDisplayStoreBitmapInRegistry( (PDISPLAY_DEVICE_EXTENSION)DeviceExtension, DISPLAY_UPDATE_PARAM, SaDisplay );
  680. break;
  681. case SA_DISPLAY_READY:
  682. Status = SaDisplayStoreBitmapInRegistry( (PDISPLAY_DEVICE_EXTENSION)DeviceExtension, DISPLAY_READY_PARAM, SaDisplay );
  683. break;
  684. case SA_DISPLAY_SHUTTING_DOWN:
  685. Status = SaDisplayStoreBitmapInRegistry( (PDISPLAY_DEVICE_EXTENSION)DeviceExtension, DISPLAY_SHUTDOWN_PARAM, SaDisplay );
  686. break;
  687. case SA_DISPLAY_CHECK_DISK:
  688. Status = SaDisplayStoreBitmapInRegistry( (PDISPLAY_DEVICE_EXTENSION)DeviceExtension, DISPLAY_CHECKDISK_PARAM, SaDisplay );
  689. break;
  690. default:
  691. Status = STATUS_INVALID_PARAMETER_4;
  692. ERROR_RETURN( DeviceExtension->DeviceType, "Invalid display message id", Status );
  693. break;
  694. }
  695. } __finally {
  696. }
  697. return CompleteRequest( Irp, Status, 0 );
  698. }