]> git.cworth.org Git - apitrace/blob - wrappers/d3d11stubs.cpp
Use skiplist-based FastCallSet within trace::CallSet
[apitrace] / wrappers / d3d11stubs.cpp
1 /**************************************************************************
2  *
3  * Copyright 2012 VMware, Inc.
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  *
24  **************************************************************************/
25
26
27 /*
28  *Stubs for internal D3D11 functions.
29  */
30
31
32 #include "os.hpp"
33
34 #include "d3d11imports.hpp"
35
36
37 static HMODULE g_hD3D11Module = NULL;
38
39
40 static PROC
41 _getD3D11ProcAddress(LPCSTR lpProcName) {
42     if (!g_hD3D11Module) {
43         char szDll[MAX_PATH] = {0};
44         if (!GetSystemDirectoryA(szDll, MAX_PATH)) {
45             return NULL;
46         }
47         strcat(szDll, "\\\\d3d11.dll");
48         g_hD3D11Module = LoadLibraryA(szDll);
49         if (!g_hD3D11Module) {
50             return NULL;
51         }
52     }
53     return GetProcAddress(g_hD3D11Module, lpProcName);
54 }
55
56
57 typedef HRESULT (WINAPI *PFN_D3D11COREREGISTERLAYERS)(const void *unknown0, DWORD unknown1);
58 static PFN_D3D11COREREGISTERLAYERS _D3D11CoreRegisterLayers_ptr = NULL;
59
60 EXTERN_C HRESULT WINAPI
61 D3D11CoreRegisterLayers(const void *unknown0, DWORD unknown1) {
62     const char *_name = "D3D11CoreRegisterLayers";
63     if (!_D3D11CoreRegisterLayers_ptr) {
64         _D3D11CoreRegisterLayers_ptr = (PFN_D3D11COREREGISTERLAYERS)_getD3D11ProcAddress(_name);
65         if (!_D3D11CoreRegisterLayers_ptr) {
66             os::log("error: unavailable function %s\n", _name);
67             os::abort();
68         }
69     }
70     return _D3D11CoreRegisterLayers_ptr(unknown0, unknown1);
71 }
72
73 typedef SIZE_T (WINAPI *PFN_D3D11COREGETLAYEREDDEVICESIZE)(const void *unknown0, DWORD unknown1);
74 static PFN_D3D11COREGETLAYEREDDEVICESIZE _D3D11CoreGetLayeredDeviceSize_ptr = NULL;
75
76 EXTERN_C SIZE_T WINAPI
77 D3D11CoreGetLayeredDeviceSize(const void *unknown0, DWORD unknown1) {
78     const char *_name = "D3D11CoreGetLayeredDeviceSize";
79     if (!_D3D11CoreGetLayeredDeviceSize_ptr) {
80         _D3D11CoreGetLayeredDeviceSize_ptr = (PFN_D3D11COREGETLAYEREDDEVICESIZE)_getD3D11ProcAddress(_name);
81         if (!_D3D11CoreGetLayeredDeviceSize_ptr) {
82             os::log("error: unavailable function %s\n", _name);
83             os::abort();
84         }
85     }
86     return _D3D11CoreGetLayeredDeviceSize_ptr(unknown0, unknown1);
87 }
88
89 typedef HRESULT (WINAPI *PFN_D3D11CORECREATELAYEREDDEVICE)(const void *unknown0, DWORD unknown1, const void *unknown2, REFIID riid, void **ppvObj);
90 static PFN_D3D11CORECREATELAYEREDDEVICE _D3D11CoreCreateLayeredDevice_ptr = NULL;
91
92 EXTERN_C HRESULT WINAPI
93 D3D11CoreCreateLayeredDevice(const void *unknown0, DWORD unknown1, const void *unknown2, REFIID riid, void **ppvObj) {
94     const char *_name = "D3D11CoreCreateLayeredDevice";
95     if (!_D3D11CoreCreateLayeredDevice_ptr) {
96         _D3D11CoreCreateLayeredDevice_ptr = (PFN_D3D11CORECREATELAYEREDDEVICE)_getD3D11ProcAddress(_name);
97         if (!_D3D11CoreCreateLayeredDevice_ptr) {
98             os::log("error: unavailable function %s\n", _name);
99             os::abort();
100         }
101     }
102     return _D3D11CoreCreateLayeredDevice_ptr(unknown0, unknown1, unknown2, riid, ppvObj);
103 }
104
105 typedef HRESULT (WINAPI *PFN_D3D11CORECREATEDEVICE)(DWORD unknown0, DWORD unknown1, DWORD unknown2, DWORD unknown3, DWORD unknown4, DWORD unknown5, DWORD unknown6, DWORD unknown7, DWORD unknown8);
106 static PFN_D3D11CORECREATEDEVICE _D3D11CoreCreateDevice_ptr = NULL;
107
108 EXTERN_C HRESULT WINAPI
109 D3D11CoreCreateDevice(DWORD unknown0, DWORD unknown1, DWORD unknown2, DWORD unknown3, DWORD unknown4, DWORD unknown5, DWORD unknown6, DWORD unknown7, DWORD unknown8) {
110     const char *_name = "D3D11CoreCreateDevice";
111     if (!_D3D11CoreCreateDevice_ptr) {
112         _D3D11CoreCreateDevice_ptr = (PFN_D3D11CORECREATEDEVICE)_getD3D11ProcAddress(_name);
113         if (!_D3D11CoreCreateDevice_ptr) {
114             os::log("error: unavailable function %s\n", _name);
115             os::abort();
116         }
117     }
118     return _D3D11CoreCreateDevice_ptr(unknown0, unknown1, unknown2, unknown3, unknown4, unknown5, unknown6, unknown7, unknown8);
119 }
120
121