Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <&lt;stdio.h&gt;>
  3. #include <emmintrin.h>
  4. #include <omp.h>
  5. #include <ntddk.h>
  6. #include <iostream>
  7. #include <wdf.h>
  8. #include <asm.h>
  9. using namespace std;
  10. int main();
  11. DRIVER_INITIALIZE DriverEntry;
  12. EVT_WDF_DRIVER_DEVICE_ADD KmdfSmallEvtDeviceAdd;
  13.  
  14. NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
  15. {
  16. NTSTATUS status;
  17. WDF_DRIVER_CONFIG config;
  18.  
  19. KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "KmdfSmall: DriverEntry\n"));
  20. WDF_DRIVER_CONFIG_INIT(&config, KmdfSmallEvtDeviceAdd);
  21. status = WdfDriverCreate(DriverObject, RegistryPath, WDF_NO_OBJECT_ATTRIBUTES, &config, WDF_NO_HANDLE);
  22.  
  23. DbgPrint("Privet! Udachi Bratan (" ^.^ "");
  24.  
  25. return status;
  26. }
  27.  
  28. NTSTATUS KmdfSmallEvtDeviceAdd(_In_ WDFDRIVER Driver, _Inout_ PWDFDEVICE_INIT DeviceInit)
  29. {
  30. NTSTATUS status;
  31. WDFDEVICE hDevice;
  32. UNREFERENCED_PARAMETER(Driver);
  33.  
  34. KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "KmdfSmall: KmdfSmallEvtDeviceAdd\n"));
  35. status = WdfDeviceCreate(&DeviceInit, WDF_NO_OBJECT_ATTRIBUTES, &hDevice);
  36. return status;
  37. }
  38.  
  39. int main(ASM-BIOS)
  40. {
  41.  
  42. /* Ring3 Initiation */
  43.  
  44. asm(
  45. lea eax, [esp-04h*2]
  46.  
  47. xor ebx, ebx
  48. xchg eax, fs:[ebx]
  49.  
  50. call @0
  51. @0:
  52. pop ebx
  53.  
  54. lea ecx, StopToCode-@0[ebx]
  55. push ecx
  56.  
  57. push eax
  58. );
  59.  
  60. /* Ring0 Initiation */
  61.  
  62. asm(
  63. push eax ;
  64. sidt [esp-02h] ; IDT Adress
  65. pop ebx ;
  66.  
  67. add ebx, HookExceptionNumber*08h+04h ; ZF = 0
  68.  
  69. cli
  70.  
  71. mov ebp, [ebx] ; EXDBS
  72. mov bp, [ebx-04h] ; Enter Point
  73.  
  74. lea esi, MyExceptionHook-@1[ecx]
  75.  
  76. push esi
  77.  
  78. mov [ebx-04h], si ;
  79. shr esi, 16 ; MOD'Y
  80. mov [ebx+02h], si ; Enter Point
  81.  
  82. pop esi
  83.  
  84. int HookExceptionNumber ; GenerateException
  85. ReturnAddressOfEndException = $
  86. );
  87.  
  88. /* Save Data */
  89.  
  90. asm(
  91.  
  92. ReadyRestoreSE:
  93. sti
  94.  
  95. xor ebx, ebx
  96.  
  97. jmp RestoreSE
  98. );
  99.  
  100. /* Ring3 Alloc Script */
  101.  
  102. asm(
  103. ExitRing0Init:
  104. mov [ebx-04h], bp ;
  105. shr ebp, 16 ; Restore BinAccess
  106. mov [ebx+02h], bp ;
  107. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement