Handle of physical memory


SUBMITTED BY: Guest

DATE: June 10, 2013, 7:57 p.m.

FORMAT: C++

SIZE: 1.3 kB

HITS: 912

  1. #include <windows.h>
  2. #include <aclapi.h>
  3. #include <stdio.h>
  4. typedef DWORD* NTSTATUS;
  5. typedef struct _UNICODE_STRING {
  6. USHORT Length;
  7. USHORT MaximumLength;
  8. PWSTR Buffer;
  9. } UNICODE_STRING, *PUNICODE_STRING;
  10. #define INIT_UNICODE_STRING(var,string) UNICODE_STRING var = {sizeof (string) - sizeof (WORD),sizeof (string),string}
  11. typedef struct _OBJECT_ATTRIBUTES {
  12. ULONG Length;
  13. HANDLE RootDirectory;
  14. PUNICODE_STRING ObjectName;
  15. ULONG Attributes;
  16. PVOID SecurityDescriptor;
  17. PVOID SecurityQualityOfService;
  18. } OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
  19. typedef NTSTATUS (__stdcall*OpenSection)(PHANDLE SectionHandle,
  20. ACCESS_MASK DesiredAccess,
  21. POBJECT_ATTRIBUTES ObjectAttributes);
  22. OpenSection NtOpenSection;
  23. int main(int argc, char *argv[])
  24. {
  25. EXPLICIT_ACCESS Access;
  26. HANDLE Section; NTSTATUS status;
  27. INIT_UNICODE_STRING(name, L"\\Device\\PhysicalMemory");
  28. OBJECT_ATTRIBUTES oa ={sizeof(oa),0,&name,0,0,0};
  29. memset(&Access, 0, sizeof(EXPLICIT_ACCESS));
  30. status = NtOpenSection(&Section, WRITE_DAC | READ_CONTROL, &oa);
  31. if(status==0)
  32. {
  33. printf("Success");
  34. }
  35. return 0;
  36. }

comments powered by Disqus