1
+ typedef LONG NTSTATUS;
2
+ #include < d3dkmthk.h>
3
+
1
4
enum class NV_STATUS : uint32_t
2
5
{
3
6
Success = 0 ,
@@ -14,7 +17,8 @@ struct NV_ARCH_INFO
14
17
{
15
18
uint32_t Version;
16
19
uint32_t Architecture;
17
- uint32_t Unknown[2 ];
20
+ uint32_t Implementation;
21
+ uint32_t Unknown[1 ];
18
22
};
19
23
20
24
struct NV_SCG_PRIORITY_INFO
@@ -29,21 +33,35 @@ struct NV_SCG_PRIORITY_INFO
29
33
uint32_t Unknown8; // 14
30
34
};
31
35
36
+ struct NV_D3DKMT_PRIVATE_DRIVER_DATA // nvwg2umx.dll (546.33)
37
+ {
38
+ uint32_t Header; // 0 NVDA
39
+ char Padding[0xE4 ]; // 4
40
+ uint32_t Architecture; // E8
41
+ };
42
+
32
43
using PfnNvAPI_QueryInterface = void *(__stdcall *)(NV_INTERFACE InterfaceId);
33
44
using PfnNvAPI_GPU_GetArchInfo = NV_STATUS(__stdcall *)(void *GPUHandle, NV_ARCH_INFO *ArchInfo);
34
45
35
46
PfnNvAPI_QueryInterface OriginalNvAPI_QueryInterface = nullptr ;
36
47
PfnNvAPI_GPU_GetArchInfo OriginalNvAPI_GPU_GetArchInfo = nullptr ;
48
+ decltype (&D3DKMTQueryAdapterInfo) OriginalD3DKMTQueryAdapterInfo = nullptr;
37
49
38
50
NV_STATUS __stdcall HookedNvAPI_GPU_GetArchInfo (void *GPUHandle, NV_ARCH_INFO *ArchInfo)
39
51
{
40
52
if (OriginalNvAPI_GPU_GetArchInfo)
41
53
{
42
54
const auto status = OriginalNvAPI_GPU_GetArchInfo (GPUHandle, ArchInfo);
43
55
44
- // Spoof Ada GPU arch
45
- if (status == NV_STATUS::Success && ArchInfo && ArchInfo->Architecture < 0x190 )
46
- ArchInfo->Architecture = 0x190 ;
56
+ if (status == NV_STATUS::Success && ArchInfo)
57
+ {
58
+ // if (arch < ada or arch >= special)
59
+ if (ArchInfo->Architecture < 0x190 || ArchInfo->Architecture >= 0xE0000000 )
60
+ {
61
+ ArchInfo->Architecture = 0x190 ; // Force Ada
62
+ ArchInfo->Implementation = 4 ; // Force GA104
63
+ }
64
+ }
47
65
48
66
return status;
49
67
}
@@ -67,17 +85,40 @@ void *__stdcall HookedNvAPI_QueryInterface(NV_INTERFACE InterfaceId)
67
85
{
68
86
const auto result = OriginalNvAPI_QueryInterface (InterfaceId);
69
87
70
- if (InterfaceId == NV_INTERFACE::GPU_GetArchInfo )
88
+ if (result )
71
89
{
72
- OriginalNvAPI_GPU_GetArchInfo = static_cast <PfnNvAPI_GPU_GetArchInfo>(result);
73
- return &HookedNvAPI_GPU_GetArchInfo;
90
+ if (InterfaceId == NV_INTERFACE::GPU_GetArchInfo)
91
+ {
92
+ OriginalNvAPI_GPU_GetArchInfo = static_cast <PfnNvAPI_GPU_GetArchInfo>(result);
93
+ return &HookedNvAPI_GPU_GetArchInfo;
94
+ }
95
+
96
+ if (InterfaceId == NV_INTERFACE::D3D12_SetRawScgPriority)
97
+ return &HookedNvAPI_D3D12_SetRawScgPriority;
74
98
}
75
99
76
- if (InterfaceId == NV_INTERFACE::D3D12_SetRawScgPriority)
77
- return &HookedNvAPI_D3D12_SetRawScgPriority;
100
+ return result;
101
+ }
102
+
103
+ #if 0
104
+ NTSTATUS WINAPI HookedD3DKMTQueryAdapterInfo(const D3DKMT_QUERYADAPTERINFO *Info)
105
+ {
106
+ const auto result = OriginalD3DKMTQueryAdapterInfo(Info);
107
+
108
+ if (result == 0 && Info && Info->Type == KMTQAITYPE_UMDRIVERPRIVATE)
109
+ {
110
+ if (Info->pPrivateDriverData && Info->PrivateDriverDataSize >= sizeof(NV_D3DKMT_PRIVATE_DRIVER_DATA))
111
+ {
112
+ auto driverData = static_cast<NV_D3DKMT_PRIVATE_DRIVER_DATA *>(Info->pPrivateDriverData);
113
+
114
+ if (driverData->Header == 0x4E564441)
115
+ driverData->Architecture = 0x150;
116
+ }
117
+ }
78
118
79
119
return result;
80
120
}
121
+ #endif
81
122
82
123
bool TryInterceptNvAPIFunction (void *ModuleHandle, const void *FunctionName, void **FunctionPointer)
83
124
{
0 commit comments