> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenExistingHeapFromFileMapping

> 从文件映射对象在系统内存中创建一个专用诊断堆。即使在发生 GPU 故障或的情况下，所创建的堆也可以保持存在。

从文件映射对象在系统内存中创建一个专用诊断堆。即使在发生 GPU 故障或设备已移除的情况下，所创建的堆也可以保持存在。

## 语法

```cpp theme={null}
HRESULT OpenExistingHeapFromFileMapping(
    HANDLE hFileMapping,
    const IID & riid,
    void  ppvHeap
)
```

### 参数

*hFileMapping*\
类型：HANDLE

用于创建堆的文件映射对象的句柄。

*riid*\
类型：const IID &

堆接口 ([ID3D12Heap](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/interfaces/id3d12heap/id3d12heap_public.md)) 的全局唯一标识符 (**GUID**)。

可以使用 **\_\_uuidof()** 宏获取堆接口的 **REFIID** 或 **GUID**。例如，**\_\_uuidof(ID3D12Heap)** 将检索堆接口的 **GUID**。

*ppvHeap \[out]*\
类型：void \*\*

[SAL](https://learn.microsoft.com/en-us/visualstudio/code-quality/annotating-function-parameters-and-return-values?view=vs-2015\&preserve-view=true)：`COM_Outptr`

指向内存块的指针。成功时，D3D12 运行时会将指向新打开堆的指针写入该内存块。指针的类型取决于提供的 **riid** 参数。

### 返回值

类型：HRESULT

如果没有足够的内存来打开现有堆，则此方法返回 **E\_OUTOFMEMORY**。有关其他可能的返回值，请参阅 [Direct3D 12 返回代码](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/d3d12-graphics-reference-returnvalues)。

## 备注

堆是在系统内存中创建的，并允许 CPU 访问。它包装整个 VirtualAlloc 区域。

堆可用于放置资源和保留资源，与其他堆一样正交。基于无法由应用程序选择的标志，可能仍然存在限制。

## 要求

**头文件：** d3d12\_xs.h 或 d3d12\_x.h\
**库：** d3d12\_xs.lib 或 d3d12\_x.lib\
**支持的平台**：XBOX Series 主机和 XBOX One 系列

## 另请参阅

[ID3D12Device3 接口](https://docs.xbox.com/zh-CN/reference/graphics/d3d12_x/interfaces/id3d12device3/id3d12device3.md)


## Related topics

- [OpenExistingHeapFromAddress](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/interfaces/id3d12device3/methods/id3d12device3_openexistingheapfromaddress_public.md)
- [D3D12_FEATURE_DATA_EXISTING_HEAPS](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/structs/d3d12_feature_data_existing_heaps_public.md)
- [OpenFile](https://docs.xbox.com/zh-CN/reference/system/dstorage/interfaces/IDStorageFactoryX/methods/idstoragefactoryx_openfile.md)
- [OpenSharedHandle](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_opensharedhandle_public.md)
- [Update Open Id Connection](https://docs.xbox.com/api-reference/authentication/update-open-id-connection.md)
