DbgkpSectionToFileHandle

VOID *__stdcall DbgkpSectionToFileHandle(VOID *SectionObject){
  _OBJECT_NAME_INFORMATION *v1; 
  NTSTATUS v2; 
  UINT64 ShareAccess; 
  UINT64 OpenOptions; 
  _IO_STATUS_BLOCK IoStatusBlock; 
  _OBJECT_ATTRIBUTES ObjectAttributes; 
  _OBJECT_NAME_INFORMATION *FileNameInfo; 
  VOID *FileHandle; 

  *(&ObjectAttributes.Length + 1) = 0;
  *(&ObjectAttributes.Attributes + 1) = 0;
  FileHandle = 0i64;
  FileNameInfo = 0i64;
  IoStatusBlock = 0i64;
  if( MmGetFileNameForSection((_SECTION *)SectionObject, &FileNameInfo) < 0 )
    return 0i64;
  v1 = FileNameInfo;
  ObjectAttributes.RootDirectory = 0i64;
  LODWORD(OpenOptions) = 32;
  ObjectAttributes.ObjectName = (_UNICODE_STRING *)FileNameInfo;
  ObjectAttributes.Length = 48;
  *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
  ObjectAttributes.Attributes = 1600;
  LODWORD(ShareAccess) = 7;
  v2 = ZwOpenFile(&FileHandle, 0x80100000ui64, &ObjectAttributes, &IoStatusBlock, ShareAccess, OpenOptions);
  ExFreePoolWithTag(v1, 0);
  if( v2 < 0 )
    return 0i64;
  else
    return FileHandle;
}

Referenced by:

DbgkCreateThread
DbgkMapViewOfSection
DbgkpPostFakeThreadMessages