Advertisement
Pug_coder

ZHopa

Apr 15th, 2022
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. #include <ntddk.h>
  2. #include <ntifs.h>
  3. #include <ndk/exfuncs.h>
  4. #include <ndk/ketypes.h>
  5. #include <pseh/pseh2.h>
  6. #include <ntstrsafe.h>
  7. #ifndef NDEBUG
  8. #define NDEBUG
  9. #endif
  10. #include <debug.h>
  11.  
  12. DoTlistCommand(VOID)
  13. {
  14. NTSTATUS Status;
  15. PVOID NewGlobalBuffer;
  16. ULONG Size;
  17. SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC DoTlistCommand: Entering.\n");
  18.  
  19. /* Check if a global buffer already exists */
  20. if (!GlobalBuffer)
  21. {
  22. /* It doesn't, allocate one */
  23. GlobalBuffer = SacAllocatePool(4096, GLOBAL_BLOCK_TAG);
  24. if (GlobalBuffer)
  25. {
  26. /* Remember its current size */
  27. GlobalBufferSize = 4096;
  28. }
  29. else
  30. {
  31. /* Out of memory, bail out */
  32. SacPutSimpleMessage(11);
  33. SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC DoTlistCommand: Exiting.\n");
  34. return;
  35. }
  36. }
  37.  
  38.  
  39.  
  40. /* Loop as long as the buffer is too small */
  41. while (TRUE)
  42. {
  43. /* Get the process list */
  44. ProcessInfo = (PSYSTEM_PROCESS_INFORMATION)P;
  45. Status = ZwQuerySystemInformation(SystemProcessInformation,
  46. ProcessInfo,
  47. RemainingSize,
  48. &ReturnLength);
  49.  
  50. if ((Status != STATUS_NO_MEMORY) &&
  51. (Status != STATUS_INFO_LENGTH_MISMATCH))
  52. {
  53. /* It fits! Bail out */
  54. break;
  55. }
  56.  
  57.  
  58. /* We need a new bigger buffer */
  59. NewGlobalBuffer = SacAllocatePool(GlobalBufferSize + 4096,
  60. GLOBAL_BLOCK_TAG);
  61. if (!NewGlobalBuffer)
  62. {
  63. /* Out of memory, bail out */
  64. SacPutSimpleMessage(11);
  65. SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC DoTlistCommand: Exiting.\n");
  66. return;
  67. }
  68.  
  69. /* Free the old one, update state */
  70. ExFreePool(GlobalBuffer);
  71. GlobalBufferSize += 4096;
  72. GlobalBuffer = NewGlobalBuffer;
  73. }
  74.  
  75. }
  76.  
  77. NTSTATUS NTAPI DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegPath)
  78. {
  79. DPRINT1("Sukhanov\n");
  80. ProcessInfo = (PSYSTEM_PROCESS_INFORMATION)P;
  81. Status = ZwQuerySystemInformation(SystemProcessInformation,
  82. ProcessInfo,
  83. RemainingSize,
  84. &ReturnLength);
  85.  
  86. return STATUS_SUCCESS;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement