NTSTATUS
MmCreateSection(
      __deref_out PVOID *SectionObject,
      __in ACCESS_MASK DesiredAccess,
      __in_opt POBJECT_ATTRIBUTES ObjectAttributes,
      __in PLARGE_INTEGER InputMaximumSize,
      __in WIN32_PROTECTION_MASK SectionPageProtection,
      __in ULONG AllocationAttributes,
      __in_opt HANDLE FileHandle,
      __in_opt PFILE_OBJECT FileObject
  );

Routine Description:

    This function creates a section object and opens a handle to the object
    with the specified desired access.

Arguments:

    Section - A pointer to a variable that will
              receive the section object address.

    DesiredAccess - The desired types of access for the section.

    DesiredAccess Flags

         EXECUTE - Execute access to the section is desired.

         READ - Read access to the section is desired.

         WRITE - Write access to the section is desired.

    ObjectAttributes - Supplies a pointer to an object attributes structure.

    InputMaximumSize - Supplies the maximum size of the section in bytes.
                       This value is rounded up to the host page size and
                       specifies the size of the section (page file
                       backed section) or the maximum size to which a
                       file can be extended or mapped (file backed
                       section).

    SectionPageProtection - Supplies the protection to place on each page
                            in the section.  One of PAGE_READ, PAGE_READWRITE,
                            PAGE_EXECUTE, or PAGE_WRITECOPY and, optionally,
                            PAGE_NOCACHE or PAGE_WRITECOMBINE may be specified.

                            Note the NO_CACHE, write combined and GUARD
                            attributes are mutually exclusive.
                            MiMakeProtectionMask enforces this.

    AllocationAttributes - Supplies a set of flags that describe the
                           allocation attributes of the section.

        AllocationAttributes Flags

        SEC_BASED - The section is a based section and will be
                    allocated at the same virtual address in each process
                    address space that receives the section.  This does not
                    imply that addresses are reserved for based sections.
                    Rather if the section cannot be mapped at the based address
                    an error is returned.

        SEC_RESERVE - All pages of the section are set to the
                      reserved state.

        SEC_COMMIT - All pages of the section are set to the commit state.

        SEC_IMAGE - The file specified by the file handle is an
                    executable image file.

        SEC_FILE - The file specified by the file handle is a mapped
                   file.  If a file handle is supplied and neither
                   SEC_IMAGE or SEC_FILE is supplied, SEC_FILE is
                   assumed.

        SEC_LARGE_PAGES - The section will be created using large pages.
                          This physical memory is allocated immediately upon
                          section creation (instead of upon access).  If
                          contiguous physical memory for the large page(s)
                          cannot be found, then the section creation will fail
                          (rather than use small pages).

                          Since this physical memory is allocated up front and
                          is nonpaged (to ensure it remains physically
                          contiguous and in a large page), privilege is
                          required.  Since section mappers can extend the
                          section life indefinitely, section creators should
                          ensure proper access permissions are used.

                          Note subsequent mapped views must specify a large
                          page aligned start address and length (or must
                          have available virtual space so the system can find
                          one) for them to automatically receive large page(s)
                          for the view.  Callers of the map APIs do not need
                          to specify large pages - the system will automatically
                          provide the mapping in large pages (assuming
                          satisfactory alignment) or small pages if not.

    FileHandle - Supplies an optional handle of an open file object.
                 If the value of this handle is null, then the
                 section will be backed by a paging file. Otherwise
                 the section is backed by the specified data file.

    FileObject - Supplies an optional pointer to the file object.  If this
                 value is NULL and the FileHandle is NULL, then there is
                 no file to map (image or mapped file).  If this value
                 is specified, then the File is to be mapped as a MAPPED FILE
                 and NO file size checking will be performed.

                 ONLY THE SYSTEM CACHE SHOULD PROVIDE A FILE OBJECT WITH THE
                 CALL!! as this is optimized to not check the size, only do
                 data mapping, no protection check, etc.

    Note - Only one of FileHandle or File should be specified!

Return Value:

    Returns the relevant NTSTATUS code.