#include <windows.h>
#include <aclapi.h>
#include <stdio.h>
typedef DWORD* NTSTATUS;
typedef struct _UNICODE_STRING {
USHORT Length;
USHORT MaximumLength;
PWSTR Buffer;
} UNICODE_STRING, *PUNICODE_STRING;
#define INIT_UNICODE_STRING(var,string) UNICODE_STRING var = {sizeof (string) - sizeof (WORD),sizeof (string),string}
typedef struct _OBJECT_ATTRIBUTES {
ULONG Length;
HANDLE RootDirectory;
PUNICODE_STRING ObjectName;
ULONG Attributes;
PVOID SecurityDescriptor;
PVOID SecurityQualityOfService;
} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
typedef NTSTATUS (__stdcall*OpenSection)(PHANDLE SectionHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes);
OpenSection NtOpenSection;
int main(int argc, char *argv[])
{
EXPLICIT_ACCESS Access;
HANDLE Section; NTSTATUS status;
INIT_UNICODE_STRING(name, L"\\Device\\PhysicalMemory");
OBJECT_ATTRIBUTES oa ={sizeof(oa),0,&name,0,0,0};
memset(&Access, 0, sizeof(EXPLICIT_ACCESS));
status = NtOpenSection(&Section, WRITE_DAC | READ_CONTROL, &oa);
if(status==0)
{
printf("Success");
}
return 0;
}