Advertisement
kVWa2Q0WVdSSF

Untitled

Mar 1st, 2022
1,579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 3.95 KB | None | 0 0
  1.  __try
  2.     {
  3.         switch (DriverInformationClass)
  4.         {
  5.             // Basic information such as flags, driver base and driver size.
  6.             case DriverBasicInformation:
  7.             {
  8.                 if (DriverInformationLength == sizeof(DRIVER_BASIC_INFORMATION))
  9.                 {
  10.                     PDRIVER_BASIC_INFORMATION basicInfo;
  11.  
  12.                     basicInfo = (PDRIVER_BASIC_INFORMATION)DriverInformation;
  13.                     basicInfo->Flags = driverObject->Flags;
  14.                     basicInfo->DriverStart = driverObject->DriverStart;
  15.                     basicInfo->DriverSize = driverObject->DriverSize;
  16.                 }
  17.                 else
  18.                 {
  19.                     status = STATUS_INFO_LENGTH_MISMATCH;
  20.                 }
  21.  
  22.                 if (ReturnLength)
  23.                     *ReturnLength = sizeof(DRIVER_BASIC_INFORMATION);
  24.             }
  25.             break;
  26.  
  27.             // The name of the driver - e.g. \Driver\Null.
  28.             case DriverNameInformation:
  29.             {
  30.                 if (DriverInformation)
  31.                 {
  32.                     /* Check buffer length. */
  33.                     if (sizeof(UNICODE_STRING) + driverObject->DriverName.Length <=
  34.                         DriverInformationLength)
  35.                     {
  36.                         KphpCopyInfoUnicodeString(
  37.                             DriverInformation,
  38.                             &driverObject->DriverName
  39.                             );
  40.                     }
  41.                     else
  42.                     {
  43.                         status = STATUS_BUFFER_TOO_SMALL;
  44.                     }
  45.                 }
  46.  
  47.                 if (ReturnLength)
  48.                     *ReturnLength = sizeof(UNICODE_STRING) + driverObject->DriverName.Length;
  49.             }
  50.             break;
  51.  
  52.             // The name of the driver's service key - e.g. \REGISTRY\...
  53.            case DriverServiceKeyNameInformation:
  54.            {
  55.                if (driverObject->DriverExtension)
  56.                {
  57.                    if (DriverInformation)
  58.                    {
  59.                        if (sizeof(UNICODE_STRING) +
  60.                            driverObject->DriverExtension->ServiceKeyName.Length <=
  61.                            DriverInformationLength)
  62.                        {
  63.                            KphpCopyInfoUnicodeString(
  64.                                DriverInformation,
  65.                                &driverObject->DriverExtension->ServiceKeyName
  66.                                );
  67.                        }
  68.                        else
  69.                        {
  70.                            status = STATUS_BUFFER_TOO_SMALL;
  71.                        }
  72.                    }
  73.  
  74.                    if (ReturnLength)
  75.                    {
  76.                        *ReturnLength = sizeof(UNICODE_STRING) +
  77.                            driverObject->DriverExtension->ServiceKeyName.Length;
  78.                    }
  79.                }
  80.                else
  81.                {
  82.                    if (DriverInformation)
  83.                    {
  84.                        if (sizeof(UNICODE_STRING) <= DriverInformationLength)
  85.                        {
  86.                            // Zero the information buffer.
  87.                            KphpCopyInfoUnicodeString(
  88.                                DriverInformation,
  89.                                NULL
  90.                                );
  91.                        }
  92.                        else
  93.                        {
  94.                            status = STATUS_BUFFER_TOO_SMALL;
  95.                        }
  96.                    }
  97.  
  98.                    if (ReturnLength)
  99.                        *ReturnLength = sizeof(UNICODE_STRING);
  100.                }
  101.            }
  102.            break;
  103.  
  104.            default:
  105.            {
  106.                status = STATUS_INVALID_INFO_CLASS;
  107.            }
  108.        }
  109.    }
  110.    __except (EXCEPTION_EXECUTE_HANDLER)
  111.    {
  112.        status = GetExceptionCode();
  113.    }
  114.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement