EngMapFile function (winddi.h)

The EngMapFile function creates or opens a file and maps it into system space.

Syntax

ENGAPI PVOID EngMapFile(
  [in]  LPWSTR    pwsz,
  [in]  ULONG     cjSize,
  [out] ULONG_PTR *piFile
);

Parameters

[in] pwsz

Pointer to a null-terminated string that contains the fully qualified name of the file to be mapped. An example of a fully qualified file name string is L"\??\c:\test.dat".

[in] cjSize

Specifies the number of bytes of the file to map.

[out] piFile

Pointer to a memory location that receives an identifier for the mapped file, provided that the mapping succeeded. If the mapping did not succeed, the memory location receives the value zero. When the mapped file needs to be released, this value should be passed to EngUnmapFile.

Return value

EngMapFile returns a pointer to the mapped view of the file if it succeeds. Otherwise, it returns NULL.

Remarks

If the file already exists, EngMapFile opens and maps it for read/write. If the file does not exist, EngMapFile creates and maps it for read/write.

The value of cjSize affects the mapping of the file as follows:

  • When cjSize is zero, GDI maps the file in its entirety.
  • When cjSize is greater than the size of the file, GDI expands the file to cjSize bytes in size before mapping it in system memory. No assumptions should be made about the contents of memory that extend beyond the file's original size.
  • When cjSize is less than the size of the file, GDI truncates the file to cjSize bytes in size before mapping it into system memory.
A driver can read and write to the file through the returned pointer.

Requirements

Requirement Value
Minimum supported client Available in Windows 2000 and later versions of the Windows operating systems.
Target Platform Universal
Header winddi.h (include Winddi.h)
Library Win32k.lib
DLL Win32k.sys

See also

EngDeleteFile

EngUnmapFile