locum 0.1.4

Captures everything a Direct3D 11 game draws in a frame, to look at, query, change and replay: d3d11.dll and dxgi.dll beside the game that watch every call on its way to the real runtime.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
//! Generated by `cargo xtask gen` from the `windows` crate's `ID3D12ShaderCacheSession_Vtbl`; do not edit.

#![allow(
    non_snake_case,
    clippy::too_many_arguments,
    clippy::missing_safety_doc,
    dead_code
)]

use core::ffi::c_void;

/// Every method of `ID3D12ShaderCacheSession` in vtable order. The defaults forward to the wrapped object [`Cache12Methods::inner`].
///
/// # Safety
/// The implementing type must be `#[repr(C)]` with a pointer to [`vtable`]'s table as its first field,
/// and `inner` must return a live `ID3D12ShaderCacheSession`.
pub unsafe trait Cache12Methods: Sized {
    /// The wrapped object, an `ID3D12ShaderCacheSession`.
    fn inner(&self) -> *mut c_void;
    unsafe fn QueryInterface(
        &self,
        iid: *const windows::core::GUID,
        out: *mut *mut c_void,
    ) -> windows::core::HRESULT;
    unsafe fn AddRef(&self) -> u32;
    unsafe fn Release(&self) -> u32;
    unsafe fn GetPrivateData(
        &self,
        a0: *const windows::core::GUID,
        a1: *mut u32,
        a2: *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe { real::GetPrivateData(self.inner(), a0, a1, a2) }
    }
    unsafe fn SetPrivateData(
        &self,
        a0: *const windows::core::GUID,
        a1: u32,
        a2: *const core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe { real::SetPrivateData(self.inner(), a0, a1, a2) }
    }
    unsafe fn SetPrivateDataInterface(
        &self,
        a0: *const windows::core::GUID,
        a1: *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe { real::SetPrivateDataInterface(self.inner(), a0, a1) }
    }
    unsafe fn SetName(&self, a0: windows::core::PCWSTR) -> windows::core::HRESULT {
        unsafe { real::SetName(self.inner(), a0) }
    }
    unsafe fn GetDevice(
        &self,
        a0: *const windows::core::GUID,
        a1: *mut *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe { real::GetDevice(self.inner(), a0, a1) }
    }
    unsafe fn FindValue(
        &self,
        a0: *const core::ffi::c_void,
        a1: u32,
        a2: *mut core::ffi::c_void,
        a3: *mut u32,
    ) -> windows::core::HRESULT {
        unsafe { real::FindValue(self.inner(), a0, a1, a2, a3) }
    }
    unsafe fn StoreValue(
        &self,
        a0: *const core::ffi::c_void,
        a1: u32,
        a2: *const core::ffi::c_void,
        a3: u32,
    ) -> windows::core::HRESULT {
        unsafe { real::StoreValue(self.inner(), a0, a1, a2, a3) }
    }
    unsafe fn SetDeleteOnDestroy(&self) {
        unsafe { real::SetDeleteOnDestroy(self.inner()) }
    }
    unsafe fn GetDesc(&self, a0: *mut windows::Win32::Graphics::Direct3D12::D3D12_SHADER_CACHE_SESSION_DESC) {
        unsafe { real::GetDesc(self.inner(), a0) }
    }
}

/// Each method called on the real (wrapped) object: the trait's defaults, and overrides that still want the
/// real behaviour.
pub mod real {
    use core::ffi::c_void;

    /// `GetPrivateData` on the real object.
    pub unsafe fn GetPrivateData(
        inner: *mut c_void,
        a0: *const windows::core::GUID,
        a1: *mut u32,
        a2: *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            ((*(*(inner
                as *const *const windows::Win32::Graphics::Direct3D12::ID3D12ShaderCacheSession_Vtbl)))
                .base__
                .base__
                .GetPrivateData)(inner, a0, a1, a2)
        }
    }
    /// `SetPrivateData` on the real object.
    pub unsafe fn SetPrivateData(
        inner: *mut c_void,
        a0: *const windows::core::GUID,
        a1: u32,
        a2: *const core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            ((*(*(inner
                as *const *const windows::Win32::Graphics::Direct3D12::ID3D12ShaderCacheSession_Vtbl)))
                .base__
                .base__
                .SetPrivateData)(inner, a0, a1, a2)
        }
    }
    /// `SetPrivateDataInterface` on the real object.
    pub unsafe fn SetPrivateDataInterface(
        inner: *mut c_void,
        a0: *const windows::core::GUID,
        a1: *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            ((*(*(inner
                as *const *const windows::Win32::Graphics::Direct3D12::ID3D12ShaderCacheSession_Vtbl)))
                .base__
                .base__
                .SetPrivateDataInterface)(inner, a0, a1)
        }
    }
    /// `SetName` on the real object.
    pub unsafe fn SetName(inner: *mut c_void, a0: windows::core::PCWSTR) -> windows::core::HRESULT {
        unsafe {
            ((*(*(inner
                as *const *const windows::Win32::Graphics::Direct3D12::ID3D12ShaderCacheSession_Vtbl)))
                .base__
                .base__
                .SetName)(inner, a0)
        }
    }
    /// `GetDevice` on the real object.
    pub unsafe fn GetDevice(
        inner: *mut c_void,
        a0: *const windows::core::GUID,
        a1: *mut *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            ((*(*(inner
                as *const *const windows::Win32::Graphics::Direct3D12::ID3D12ShaderCacheSession_Vtbl)))
                .base__
                .GetDevice)(inner, a0, a1)
        }
    }
    /// `FindValue` on the real object.
    pub unsafe fn FindValue(
        inner: *mut c_void,
        a0: *const core::ffi::c_void,
        a1: u32,
        a2: *mut core::ffi::c_void,
        a3: *mut u32,
    ) -> windows::core::HRESULT {
        unsafe {
            ((*(*(inner
                as *const *const windows::Win32::Graphics::Direct3D12::ID3D12ShaderCacheSession_Vtbl)))
                .FindValue)(inner, a0, a1, a2, a3)
        }
    }
    /// `StoreValue` on the real object.
    pub unsafe fn StoreValue(
        inner: *mut c_void,
        a0: *const core::ffi::c_void,
        a1: u32,
        a2: *const core::ffi::c_void,
        a3: u32,
    ) -> windows::core::HRESULT {
        unsafe {
            ((*(*(inner
                as *const *const windows::Win32::Graphics::Direct3D12::ID3D12ShaderCacheSession_Vtbl)))
                .StoreValue)(inner, a0, a1, a2, a3)
        }
    }
    /// `SetDeleteOnDestroy` on the real object.
    pub unsafe fn SetDeleteOnDestroy(inner: *mut c_void) {
        unsafe {
            ((*(*(inner
                as *const *const windows::Win32::Graphics::Direct3D12::ID3D12ShaderCacheSession_Vtbl)))
                .SetDeleteOnDestroy)(inner)
        }
    }
    /// `GetDesc` on the real object.
    pub unsafe fn GetDesc(
        inner: *mut c_void,
        a0: *mut windows::Win32::Graphics::Direct3D12::D3D12_SHADER_CACHE_SESSION_DESC,
    ) {
        unsafe {
            ((*(*(inner
                as *const *const windows::Win32::Graphics::Direct3D12::ID3D12ShaderCacheSession_Vtbl)))
                .GetDesc)(inner, a0)
        }
    }
}

unsafe extern "system" fn QueryInterface<T: Cache12Methods>(
    this: *mut c_void,
    iid: *const windows::core::GUID,
    out: *mut *mut c_void,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).QueryInterface(iid, out) }
}
unsafe extern "system" fn AddRef<T: Cache12Methods>(this: *mut c_void) -> u32 {
    unsafe { (*(this as *const T)).AddRef() }
}
unsafe extern "system" fn Release<T: Cache12Methods>(this: *mut c_void) -> u32 {
    unsafe { (*(this as *const T)).Release() }
}
unsafe extern "system" fn GetPrivateData<T: Cache12Methods>(
    this: *mut c_void,
    a0: *const windows::core::GUID,
    a1: *mut u32,
    a2: *mut core::ffi::c_void,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).GetPrivateData(a0, a1, a2) }
}
unsafe extern "system" fn SetPrivateData<T: Cache12Methods>(
    this: *mut c_void,
    a0: *const windows::core::GUID,
    a1: u32,
    a2: *const core::ffi::c_void,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).SetPrivateData(a0, a1, a2) }
}
unsafe extern "system" fn SetPrivateDataInterface<T: Cache12Methods>(
    this: *mut c_void,
    a0: *const windows::core::GUID,
    a1: *mut core::ffi::c_void,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).SetPrivateDataInterface(a0, a1) }
}
unsafe extern "system" fn SetName<T: Cache12Methods>(
    this: *mut c_void,
    a0: windows::core::PCWSTR,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).SetName(a0) }
}
unsafe extern "system" fn GetDevice<T: Cache12Methods>(
    this: *mut c_void,
    a0: *const windows::core::GUID,
    a1: *mut *mut core::ffi::c_void,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).GetDevice(a0, a1) }
}
unsafe extern "system" fn FindValue<T: Cache12Methods>(
    this: *mut c_void,
    a0: *const core::ffi::c_void,
    a1: u32,
    a2: *mut core::ffi::c_void,
    a3: *mut u32,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).FindValue(a0, a1, a2, a3) }
}
unsafe extern "system" fn StoreValue<T: Cache12Methods>(
    this: *mut c_void,
    a0: *const core::ffi::c_void,
    a1: u32,
    a2: *const core::ffi::c_void,
    a3: u32,
) -> windows::core::HRESULT {
    unsafe { (*(this as *const T)).StoreValue(a0, a1, a2, a3) }
}
unsafe extern "system" fn SetDeleteOnDestroy<T: Cache12Methods>(this: *mut c_void) {
    unsafe { (*(this as *const T)).SetDeleteOnDestroy() }
}
unsafe extern "system" fn GetDesc<T: Cache12Methods>(
    this: *mut c_void,
    a0: *mut windows::Win32::Graphics::Direct3D12::D3D12_SHADER_CACHE_SESSION_DESC,
) {
    unsafe { (*(this as *const T)).GetDesc(a0) }
}

#[allow(clippy::let_and_return)] // Uniform post-call interception in generated methods.
unsafe impl Cache12Methods for crate::d3d12::Object {
    fn inner(&self) -> *mut c_void {
        self.real()
    }
    unsafe fn QueryInterface(
        &self,
        iid: *const windows::core::GUID,
        out: *mut *mut c_void,
    ) -> windows::core::HRESULT {
        unsafe { self.query(iid, out) }
    }
    unsafe fn AddRef(&self) -> u32 {
        self.add_ref()
    }
    unsafe fn Release(&self) -> u32 {
        unsafe { self.release() }
    }
    unsafe fn GetPrivateData(
        &self,
        a0: *const windows::core::GUID,
        a1: *mut u32,
        a2: *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            let result = real::GetPrivateData(self.real(), a0, a1, a2);
            self.private_output(result, a0, a1, a2);
            result
        }
    }
    unsafe fn SetPrivateData(
        &self,
        a0: *const windows::core::GUID,
        a1: u32,
        a2: *const core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            let result = real::SetPrivateData(self.real(), a0, a1, a2);
            if result.is_ok() {
                self.private_interface(a0, false);
            }
            result
        }
    }
    unsafe fn SetPrivateDataInterface(
        &self,
        a0: *const windows::core::GUID,
        a1: *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            let result = real::SetPrivateDataInterface(self.real(), a0, crate::d3d12::unwrap(a1));
            if result.is_ok() {
                self.private_interface(a0, !a1.is_null());
            }
            result
        }
    }
    unsafe fn SetName(&self, a0: windows::core::PCWSTR) -> windows::core::HRESULT {
        unsafe {
            let result = real::SetName(self.real(), a0);
            result
        }
    }
    unsafe fn GetDevice(
        &self,
        a0: *const windows::core::GUID,
        a1: *mut *mut core::ffi::c_void,
    ) -> windows::core::HRESULT {
        unsafe {
            let result = real::GetDevice(self.real(), a0, a1);
            crate::d3d12::wrap_output(result, a0, a1);
            result
        }
    }
    unsafe fn FindValue(
        &self,
        a0: *const core::ffi::c_void,
        a1: u32,
        a2: *mut core::ffi::c_void,
        a3: *mut u32,
    ) -> windows::core::HRESULT {
        unsafe {
            let result = real::FindValue(self.real(), a0, a1, crate::d3d12::unwrap(a2), a3);
            result
        }
    }
    unsafe fn StoreValue(
        &self,
        a0: *const core::ffi::c_void,
        a1: u32,
        a2: *const core::ffi::c_void,
        a3: u32,
    ) -> windows::core::HRESULT {
        unsafe {
            let result = real::StoreValue(self.real(), a0, a1, a2, a3);
            result
        }
    }
    unsafe fn SetDeleteOnDestroy(&self) {
        unsafe {
            real::SetDeleteOnDestroy(self.real());
        }
    }
    unsafe fn GetDesc(&self, a0: *mut windows::Win32::Graphics::Direct3D12::D3D12_SHADER_CACHE_SESSION_DESC) {
        unsafe {
            real::GetDesc(self.real(), a0);
        }
    }
}

/// The `ID3D12ShaderCacheSession` vtable whose entries call `T`'s methods.
pub const fn vtable<T: Cache12Methods>() -> windows::Win32::Graphics::Direct3D12::ID3D12ShaderCacheSession_Vtbl
{
    windows::Win32::Graphics::Direct3D12::ID3D12ShaderCacheSession_Vtbl {
        base__: windows::Win32::Graphics::Direct3D12::ID3D12DeviceChild_Vtbl {
            base__: windows::Win32::Graphics::Direct3D12::ID3D12Object_Vtbl {
                base__: windows::core::IUnknown_Vtbl {
                    QueryInterface: QueryInterface::<T>,
                    AddRef: AddRef::<T>,
                    Release: Release::<T>,
                },
                GetPrivateData: GetPrivateData::<T>,
                SetPrivateData: SetPrivateData::<T>,
                SetPrivateDataInterface: SetPrivateDataInterface::<T>,
                SetName: SetName::<T>,
            },
            GetDevice: GetDevice::<T>,
        },
        FindValue: FindValue::<T>,
        StoreValue: StoreValue::<T>,
        SetDeleteOnDestroy: SetDeleteOnDestroy::<T>,
        GetDesc: GetDesc::<T>,
    }
}