diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Cargo.toml | 18 | ||||
-rw-r--r-- | nvcuda.txt | 501 | ||||
-rw-r--r-- | src/bin.rs | 76 | ||||
-rw-r--r-- | src/cu.rs | 85 | ||||
-rw-r--r-- | src/lib.rs | 23 | ||||
-rw-r--r-- | src/win_err.rs | 103 |
7 files changed, 808 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96ef6c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..e219645 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "not_cuda" +version = "0.1.0" +authors = ["Andrzej Janik <[email protected]>"] +edition = "2018" + +[lib] +name = "not_cuda" +path = "src/lib.rs" +crate-type = ["cdylib"] + +[[bin]] +name = "not_cuda" +path = "src/bin.rs" + +[dependencies] +detours-sys = "0.1" +clap = "2.33"
\ No newline at end of file diff --git a/nvcuda.txt b/nvcuda.txt new file mode 100644 index 0000000..6a604e2 --- /dev/null +++ b/nvcuda.txt @@ -0,0 +1,501 @@ +Microsoft (R) COFF/PE Dumper Version 14.16.27034.0 +Copyright (C) Microsoft Corporation. All rights reserved. + + +Dump of file C:\Windows\System32\nvcuda.dll + +File Type: DLL + + Section contains the following exports for nvcuda.dll + + 00000000 characteristics + FFFFFFFF time date stamp + 0.00 version + 1 ordinal base + 473 number of functions + 473 number of names + + ordinal hint RVA name + + 1 0 001C1C50 cuArray3DCreate + 2 1 001A6290 cuArray3DCreate_v2 + 3 2 001C1E50 cuArray3DGetDescriptor + 4 3 001A6490 cuArray3DGetDescriptor_v2 + 5 4 001C1850 cuArrayCreate + 6 5 001A5CB0 cuArrayCreate_v2 + 7 6 001A60B0 cuArrayDestroy + 8 7 001C1A50 cuArrayGetDescriptor + 9 8 001A5EB0 cuArrayGetDescriptor_v2 + 10 9 0019C1B0 cuCtxAttach + 11 A 001BD230 cuCtxCreate + 12 B 0019A0B0 cuCtxCreate_v2 + 13 C 001C2900 cuCtxDestroy + 14 D 0019A2E0 cuCtxDestroy_v2 + 15 E 0019C3A0 cuCtxDetach + 16 F 001BAD50 cuCtxDisablePeerAccess + 17 10 001BAB50 cuCtxEnablePeerAccess + 18 11 0019BDB0 cuCtxGetApiVersion + 19 12 0019B630 cuCtxGetCacheConfig + 20 13 0019AAA0 cuCtxGetCurrent + 21 14 0019AC80 cuCtxGetDevice + 22 15 0019AE60 cuCtxGetFlags + 23 16 0019B430 cuCtxGetLimit + 24 17 0019B9F0 cuCtxGetSharedMemConfig + 25 18 0019BFB0 cuCtxGetStreamPriorityRange + 26 19 001C2AF0 cuCtxPopCurrent + 27 1A 0019A6C0 cuCtxPopCurrent_v2 + 28 1B 001C2CE0 cuCtxPushCurrent + 29 1C 0019A4D0 cuCtxPushCurrent_v2 + 30 1D 0019B810 cuCtxSetCacheConfig + 31 1E 0019A8B0 cuCtxSetCurrent + 32 1F 0019B220 cuCtxSetLimit + 33 20 0019BBD0 cuCtxSetSharedMemConfig + 34 21 0019B040 cuCtxSynchronize + 35 22 001CE4C0 cuD3D10CtxCreate + 36 23 001CCBB0 cuD3D10CtxCreateOnDevice + 37 24 001CC950 cuD3D10CtxCreate_v2 + 38 25 001CC2A0 cuD3D10GetDevice + 39 26 001CC4E0 cuD3D10GetDevices + 40 27 001CCE10 cuD3D10GetDirect3DDevice + 41 28 001CD400 cuD3D10MapResources + 42 29 001CCFF0 cuD3D10RegisterResource + 43 2A 001CDA00 cuD3D10ResourceGetMappedArray + 44 2B 001CE720 cuD3D10ResourceGetMappedPitch + 45 2C 001CE050 cuD3D10ResourceGetMappedPitch_v2 + 46 2D 001CE950 cuD3D10ResourceGetMappedPointer + 47 2E 001CDC30 cuD3D10ResourceGetMappedPointer_v2 + 48 2F 001CEB60 cuD3D10ResourceGetMappedSize + 49 30 001CDE40 cuD3D10ResourceGetMappedSize_v2 + 50 31 001CED70 cuD3D10ResourceGetSurfaceDimensions + 51 32 001CE280 cuD3D10ResourceGetSurfaceDimensions_v2 + 52 33 001CD800 cuD3D10ResourceSetMapFlags + 53 34 001CD600 cuD3D10UnmapResources + 54 35 001CD220 cuD3D10UnregisterResource + 55 36 001CFD20 cuD3D11CtxCreate + 56 37 001CF8E0 cuD3D11CtxCreateOnDevice + 57 38 001CF680 cuD3D11CtxCreate_v2 + 58 39 001CEFD0 cuD3D11GetDevice + 59 3A 001CF210 cuD3D11GetDevices + 60 3B 001CFB40 cuD3D11GetDirect3DDevice + 61 3C 001D2240 cuD3D9Begin + 62 3D 001D2DD0 cuD3D9CtxCreate + 63 3E 001D0680 cuD3D9CtxCreateOnDevice + 64 3F 001D0420 cuD3D9CtxCreate_v2 + 65 40 001D2420 cuD3D9End + 66 41 001CFFA0 cuD3D9GetDevice + 67 42 001D01D0 cuD3D9GetDevices + 68 43 001D08E0 cuD3D9GetDirect3DDevice + 69 44 001D10F0 cuD3D9MapResources + 70 45 001D3930 cuD3D9MapVertexBuffer + 71 46 001D2800 cuD3D9MapVertexBuffer_v2 + 72 47 001D0CE0 cuD3D9RegisterResource + 73 48 001D2600 cuD3D9RegisterVertexBuffer + 74 49 001D1950 cuD3D9ResourceGetMappedArray + 75 4A 001D36F0 cuD3D9ResourceGetMappedPitch + 76 4B 001D2000 cuD3D9ResourceGetMappedPitch_v2 + 77 4C 001D3290 cuD3D9ResourceGetMappedPointer + 78 4D 001D1BA0 cuD3D9ResourceGetMappedPointer_v2 + 79 4E 001D34C0 cuD3D9ResourceGetMappedSize + 80 4F 001D1DD0 cuD3D9ResourceGetMappedSize_v2 + 81 50 001D3030 cuD3D9ResourceGetSurfaceDimensions + 82 51 001D16F0 cuD3D9ResourceGetSurfaceDimensions_v2 + 83 52 001D14F0 cuD3D9ResourceSetMapFlags + 84 53 001D12F0 cuD3D9UnmapResources + 85 54 001D2A10 cuD3D9UnmapVertexBuffer + 86 55 001D0F10 cuD3D9UnregisterResource + 87 56 001D2BF0 cuD3D9UnregisterVertexBuffer + 88 57 001AC930 cuDestroyExternalMemory + 89 58 001AD190 cuDestroyExternalSemaphore + 90 59 001BA940 cuDeviceCanAccessPeer + 91 5A 001994C0 cuDeviceComputeCapability + 92 5B 001982C0 cuDeviceGet + 93 5C 00198EC0 cuDeviceGetAttribute + 94 5D 0019FA10 cuDeviceGetByPCIBusId + 95 5E 001984B0 cuDeviceGetCount + 96 5F 00198AA0 cuDeviceGetLuid + 97 60 00198690 cuDeviceGetName + 98 61 001BAF30 cuDeviceGetP2PAttribute + 99 62 0019FC10 cuDeviceGetPCIBusId + 100 63 001992D0 cuDeviceGetProperties + 101 64 001988A0 cuDeviceGetUuid + 102 65 00199CC0 cuDevicePrimaryCtxGetState + 103 66 001998D0 cuDevicePrimaryCtxRelease + 104 67 00199ED0 cuDevicePrimaryCtxReset + 105 68 001996D0 cuDevicePrimaryCtxRetain + 106 69 00199AC0 cuDevicePrimaryCtxSetFlags + 107 6A 001BD020 cuDeviceTotalMem + 108 6B 00198CB0 cuDeviceTotalMem_v2 + 109 6C 001980D0 cuDriverGetVersion + 110 6D 001AB750 cuEventCreate + 111 6E 001C30B0 cuEventDestroy + 112 6F 001ABF10 cuEventDestroy_v2 + 113 70 001AC100 cuEventElapsedTime + 114 71 001ABB50 cuEventQuery + 115 72 001C9300 cuEventRecord + 116 73 001AB940 cuEventRecord_ptsz + 117 74 001ABD30 cuEventSynchronize + 118 75 001AC510 cuExternalMemoryGetMappedBuffer + 119 76 001AC720 cuExternalMemoryGetMappedMipmappedArray + 120 77 001ADF80 cuFuncGetAttribute + 121 78 001AE190 cuFuncSetAttribute + 122 79 001AF1D0 cuFuncSetBlockShape + 123 7A 001AE3A0 cuFuncSetCacheConfig + 124 7B 001AE590 cuFuncSetSharedMemConfig + 125 7C 001AF3F0 cuFuncSetSharedSize + 126 7D 001D5CA0 cuGLCtxCreate + 127 7E 001D43E0 cuGLCtxCreate_v2 + 128 7F 001D5600 cuGLGetDevices + 129 80 001D41A0 cuGLGetDevices_v2 + 130 81 001D4600 cuGLInit + 131 82 001D5EC0 cuGLMapBufferObject + 132 83 001D6100 cuGLMapBufferObjectAsync + 133 84 001D5A50 cuGLMapBufferObjectAsync_v2 + 134 85 001D51B0 cuGLMapBufferObjectAsync_v2_ptsz + 135 86 001D5840 cuGLMapBufferObject_v2 + 136 87 001D49E0 cuGLMapBufferObject_v2_ptds + 137 88 001D4800 cuGLRegisterBufferObject + 138 89 001D4FB0 cuGLSetBufferObjectMapFlags + 139 8A 001D4BF0 cuGLUnmapBufferObject + 140 8B 001D5400 cuGLUnmapBufferObjectAsync + 141 8C 001D4DD0 cuGLUnregisterBufferObject + 142 8D 00197CE0 cuGetErrorName + 143 8E 00197AE0 cuGetErrorString + 144 8F 001BBFF0 cuGetExportTable + 145 90 001B2260 cuGraphAddChildGraphNode + 146 91 001B39A0 cuGraphAddDependencies + 147 92 001B26B0 cuGraphAddEmptyNode + 148 93 001B1BC0 cuGraphAddHostNode + 149 94 001B0860 cuGraphAddKernelNode + 150 95 001B0EE0 cuGraphAddMemcpyNode + 151 96 001B1550 cuGraphAddMemsetNode + 152 97 001B24B0 cuGraphChildGraphNodeGetGraph + 153 98 001B28E0 cuGraphClone + 154 99 001B0660 cuGraphCreate + 155 9A 001B4ED0 cuGraphDestroy + 156 9B 001B3E00 cuGraphDestroyNode + 157 9C 001B4CF0 cuGraphExecDestroy + 158 9D 001B48A0 cuGraphExecHostNodeSetParams + 159 9E 001B4230 cuGraphExecKernelNodeSetParams + 160 9F 001B4440 cuGraphExecMemcpyNodeSetParams + 161 A0 001B4670 cuGraphExecMemsetNodeSetParams + 162 A1 001B50B0 cuGraphExecUpdate + 163 A2 001B3330 cuGraphGetEdges + 164 A3 001B2EF0 cuGraphGetNodes + 165 A4 001B3110 cuGraphGetRootNodes + 166 A5 001B1E10 cuGraphHostNodeGetParams + 167 A6 001B2040 cuGraphHostNodeSetParams + 168 A7 001B3FE0 cuGraphInstantiate + 169 A8 001B0AB0 cuGraphKernelNodeGetParams + 170 A9 001B0CE0 cuGraphKernelNodeSetParams + 171 AA 001CC070 cuGraphLaunch + 172 AB 001B4AE0 cuGraphLaunch_ptsz + 173 AC 001B1150 cuGraphMemcpyNodeGetParams + 174 AD 001B1350 cuGraphMemcpyNodeSetParams + 175 AE 001B17C0 cuGraphMemsetNodeGetParams + 176 AF 001B19C0 cuGraphMemsetNodeSetParams + 177 B0 001B2AE0 cuGraphNodeFindInClone + 178 B1 001B3560 cuGraphNodeGetDependencies + 179 B2 001B3780 cuGraphNodeGetDependentNodes + 180 B3 001B2CF0 cuGraphNodeGetType + 181 B4 001B3BD0 cuGraphRemoveDependencies + 182 B5 001CC730 cuGraphicsD3D10RegisterResource + 183 B6 001CF460 cuGraphicsD3D11RegisterResource + 184 B7 001D0AC0 cuGraphicsD3D9RegisterResource + 185 B8 001D3B60 cuGraphicsGLRegisterBuffer + 186 B9 001D3D70 cuGraphicsGLRegisterImage + 187 BA 001C9A50 cuGraphicsMapResources + 188 BB 001BBBB0 cuGraphicsMapResources_ptsz + 189 BC 001BB570 cuGraphicsResourceGetMappedMipmappedArray + 190 BD 001C26D0 cuGraphicsResourceGetMappedPointer + 191 BE 001BB770 cuGraphicsResourceGetMappedPointer_v2 + 192 BF 001BC4A0 cuGraphicsResourceSetMapFlags + 193 C0 001BB9B0 cuGraphicsResourceSetMapFlags_v2 + 194 C1 001BB340 cuGraphicsSubResourceGetMappedArray + 195 C2 001C9C70 cuGraphicsUnmapResources + 196 C3 001BBDD0 cuGraphicsUnmapResources_ptsz + 197 C4 001BB160 cuGraphicsUnregisterResource + 198 C5 001AC310 cuImportExternalMemory + 199 C6 001ACB10 cuImportExternalSemaphore + 200 C7 00197EE0 cuInit + 201 C8 001A0760 cuIpcCloseMemHandle + 202 C9 0019FE20 cuIpcGetEventHandle + 203 CA 001A02C0 cuIpcGetMemHandle + 204 CB 001A0020 cuIpcOpenEventHandle + 205 CC 001A04C0 cuIpcOpenMemHandle + 206 CD 001AFE10 cuLaunch + 207 CE 001CACE0 cuLaunchCooperativeKernel + 208 CF 001AED80 cuLaunchCooperativeKernelMultiDevice + 209 D0 001AEAA0 cuLaunchCooperativeKernel_ptsz + 210 D1 001B0010 cuLaunchGrid + 211 D2 001B0220 cuLaunchGridAsync + 212 D3 001C9810 cuLaunchHostFunc + 213 D4 001AEF90 cuLaunchHostFunc_ptsz + 214 D5 001C9500 cuLaunchKernel + 215 D6 001AE790 cuLaunchKernel_ptsz + 216 D7 001BC8D0 cuLinkAddData + 217 D8 0019DA00 cuLinkAddData_v2 + 218 D9 001BCB80 cuLinkAddFile + 219 DA 0019DCB0 cuLinkAddFile_v2 + 220 DB 0019DF20 cuLinkComplete + 221 DC 001BC6A0 cuLinkCreate + 222 DD 0019D7D0 cuLinkCreate_v2 + 223 DE 0019E160 cuLinkDestroy + 224 DF 001A6EE0 cuMemAddressFree + 225 E0 001A6C90 cuMemAddressReserve + 226 E1 001A8A70 cuMemAdvise + 227 E2 001BD860 cuMemAlloc + 228 E3 001BE0B0 cuMemAllocHost + 229 E4 0019EDD0 cuMemAllocHost_v2 + 230 E5 0019F800 cuMemAllocManaged + 231 E6 001BDA70 cuMemAllocPitch + 232 E7 0019E790 cuMemAllocPitch_v2 + 233 E8 0019E570 cuMemAlloc_v2 + 234 E9 001A7100 cuMemCreate + 235 EA 001A7DD0 cuMemExportToShareableHandle + 236 EB 001BDCB0 cuMemFree + 237 EC 0019EFE0 cuMemFreeHost + 238 ED 0019E9D0 cuMemFree_v2 + 239 EE 001A7BC0 cuMemGetAccess + 240 EF 001BDEA0 cuMemGetAddressRange + 241 F0 0019EBC0 cuMemGetAddressRange_v2 + 242 F1 001A8210 cuMemGetAllocationGranularity + 243 F2 001A8420 cuMemGetAllocationPropertiesFromHandle + 244 F3 001BD670 cuMemGetInfo + 245 F4 0019E370 cuMemGetInfo_v2 + 246 F5 0019F1C0 cuMemHostAlloc + 247 F6 001BE2C0 cuMemHostGetDevicePointer + 248 F7 0019F3D0 cuMemHostGetDevicePointer_v2 + 249 F8 0019F600 cuMemHostGetFlags + 250 F9 001BC280 cuMemHostRegister + 251 FA 001A0940 cuMemHostRegister_v2 + 252 FB 001A0B50 cuMemHostUnregister + 253 FC 001A8000 cuMemImportFromShareableHandle + 254 FD 001A7510 cuMemMap + 255 FE 001CAAA0 cuMemPrefetchAsync + 256 FF 001A8830 cuMemPrefetchAsync_ptsz + 257 100 001A8CB0 cuMemRangeGetAttribute + 258 101 001A8F20 cuMemRangeGetAttributes + 259 102 001A7330 cuMemRelease + 260 103 001A7990 cuMemSetAccess + 261 104 001A7770 cuMemUnmap + 262 105 001C66E0 cuMemcpy + 263 106 001BFA70 cuMemcpy2D + 264 107 001C0690 cuMemcpy2DAsync + 265 108 001C54B0 cuMemcpy2DAsync_v2 + 266 109 001A3A40 cuMemcpy2DAsync_v2_ptsz + 267 10A 001BFC50 cuMemcpy2DUnaligned + 268 10B 001C4A60 cuMemcpy2DUnaligned_v2 + 269 10C 001A24D0 cuMemcpy2DUnaligned_v2_ptds + 270 10D 001C4880 cuMemcpy2D_v2 + 271 10E 001A22F0 cuMemcpy2D_v2_ptds + 272 10F 001BFE30 cuMemcpy3D + 273 110 001C0890 cuMemcpy3DAsync + 274 111 001C56B0 cuMemcpy3DAsync_v2 + 275 112 001A3C40 cuMemcpy3DAsync_v2_ptsz + 276 113 001C6FF0 cuMemcpy3DPeer + 277 114 001C71D0 cuMemcpy3DPeerAsync + 278 115 001A3E40 cuMemcpy3DPeerAsync_ptsz + 279 116 001A2890 cuMemcpy3DPeer_ptds + 280 117 001C4C40 cuMemcpy3D_v2 + 281 118 001A26B0 cuMemcpy3D_v2_ptds + 282 119 001C6900 cuMemcpyAsync + 283 11A 001A2A70 cuMemcpyAsync_ptsz + 284 11B 001BF3B0 cuMemcpyAtoA + 285 11C 001C4190 cuMemcpyAtoA_v2 + 286 11D 001A20A0 cuMemcpyAtoA_v2_ptds + 287 11E 001BED40 cuMemcpyAtoD + 288 11F 001C3B00 cuMemcpyAtoD_v2 + 289 120 001A1A10 cuMemcpyAtoD_v2_ptds + 290 121 001BF180 cuMemcpyAtoH + 291 122 001BF830 cuMemcpyAtoHAsync + 292 123 001C4630 cuMemcpyAtoHAsync_v2 + 293 124 001A37F0 cuMemcpyAtoHAsync_v2_ptsz + 294 125 001C3F60 cuMemcpyAtoH_v2 + 295 126 001A1E70 cuMemcpyAtoH_v2_ptds + 296 127 001BEB20 cuMemcpyDtoA + 297 128 001C38D0 cuMemcpyDtoA_v2 + 298 129 001A17E0 cuMemcpyDtoA_v2_ptds + 299 12A 001BE910 cuMemcpyDtoD + 300 12B 001C0470 cuMemcpyDtoDAsync + 301 12C 001C5280 cuMemcpyDtoDAsync_v2 + 302 12D 001A3370 cuMemcpyDtoDAsync_v2_ptsz + 303 12E 001C36B0 cuMemcpyDtoD_v2 + 304 12F 001A15C0 cuMemcpyDtoD_v2_ptds + 305 130 001BE700 cuMemcpyDtoH + 306 131 001C0240 cuMemcpyDtoHAsync + 307 132 001C5050 cuMemcpyDtoHAsync_v2 + 308 133 001A3140 cuMemcpyDtoHAsync_v2_ptsz + 309 134 001C34A0 cuMemcpyDtoH_v2 + 310 135 001A13B0 cuMemcpyDtoH_v2_ptds + 311 136 001BEF60 cuMemcpyHtoA + 312 137 001BF5F0 cuMemcpyHtoAAsync + 313 138 001C43E0 cuMemcpyHtoAAsync_v2 + 314 139 001A35A0 cuMemcpyHtoAAsync_v2_ptsz + 315 13A 001C3D30 cuMemcpyHtoA_v2 + 316 13B 001A1C40 cuMemcpyHtoA_v2_ptds + 317 13C 001BE4F0 cuMemcpyHtoD + 318 13D 001C0010 cuMemcpyHtoDAsync + 319 13E 001C4E20 cuMemcpyHtoDAsync_v2 + 320 13F 001A2F10 cuMemcpyHtoDAsync_v2_ptsz + 321 140 001C3290 cuMemcpyHtoD_v2 + 322 141 001A11A0 cuMemcpyHtoD_v2_ptds + 323 142 001C6B30 cuMemcpyPeer + 324 143 001C6D80 cuMemcpyPeerAsync + 325 144 001A2CA0 cuMemcpyPeerAsync_ptsz + 326 145 001A0F50 cuMemcpyPeer_ptds + 327 146 001A0D30 cuMemcpy_ptds + 328 147 001C0CC0 cuMemsetD16 + 329 148 001C7600 cuMemsetD16Async + 330 149 001A50A0 cuMemsetD16Async_ptsz + 331 14A 001C5B00 cuMemsetD16_v2 + 332 14B 001A4290 cuMemsetD16_v2_ptds + 333 14C 001C1390 cuMemsetD2D16 + 334 14D 001C7CF0 cuMemsetD2D16Async + 335 14E 001A5790 cuMemsetD2D16Async_ptsz + 336 14F 001C6200 cuMemsetD2D16_v2 + 337 150 001A4990 cuMemsetD2D16_v2_ptds + 338 151 001C15F0 cuMemsetD2D32 + 339 152 001C7F80 cuMemsetD2D32Async + 340 153 001A5A20 cuMemsetD2D32Async_ptsz + 341 154 001C6470 cuMemsetD2D32_v2 + 342 155 001A4C00 cuMemsetD2D32_v2_ptds + 343 156 001C1130 cuMemsetD2D8 + 344 157 001C7A60 cuMemsetD2D8Async + 345 158 001A5500 cuMemsetD2D8Async_ptsz + 346 159 001C5F90 cuMemsetD2D8_v2 + 347 15A 001A4720 cuMemsetD2D8_v2_ptds + 348 15B 001C0EF0 cuMemsetD32 + 349 15C 001C7830 cuMemsetD32Async + 350 15D 001A52D0 cuMemsetD32Async_ptsz + 351 15E 001C5D50 cuMemsetD32_v2 + 352 15F 001A44E0 cuMemsetD32_v2_ptds + 353 160 001C0A90 cuMemsetD8 + 354 161 001C73D0 cuMemsetD8Async + 355 162 001A4E70 cuMemsetD8Async_ptsz + 356 163 001C58B0 cuMemsetD8_v2 + 357 164 001A4040 cuMemsetD8_v2_ptds + 358 165 001A6690 cuMipmappedArrayCreate + 359 166 001A6AB0 cuMipmappedArrayDestroy + 360 167 001A68A0 cuMipmappedArrayGetLevel + 361 168 0019CF70 cuModuleGetFunction + 362 169 001BD450 cuModuleGetGlobal + 363 16A 0019D180 cuModuleGetGlobal_v2 + 364 16B 0019D5C0 cuModuleGetSurfRef + 365 16C 0019D3B0 cuModuleGetTexRef + 366 16D 0019C580 cuModuleLoad + 367 16E 0019C770 cuModuleLoadData + 368 16F 0019C960 cuModuleLoadDataEx + 369 170 0019CBA0 cuModuleLoadFatBinary + 370 171 0019CD90 cuModuleUnload + 371 172 001B5C40 cuOccupancyAvailableDynamicSMemPerBlock + 372 173 001B52E0 cuOccupancyMaxActiveBlocksPerMultiprocessor + 373 174 001B5510 cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags + 374 175 001B5750 cuOccupancyMaxPotentialBlockSize + 375 176 001B59C0 cuOccupancyMaxPotentialBlockSizeWithFlags + 376 177 001AF5E0 cuParamSetSize + 377 178 001B0450 cuParamSetTexRef + 378 179 001AF9E0 cuParamSetf + 379 17A 001AF7D0 cuParamSeti + 380 17B 001AFBF0 cuParamSetv + 381 17C 001A8620 cuPointerGetAttribute + 382 17D 001A93A0 cuPointerGetAttributes + 383 17E 001A9190 cuPointerSetAttribute + 384 17F 001D6370 cuProfilerInitialize + 385 180 001D6580 cuProfilerStart + 386 181 001D6760 cuProfilerStop + 387 182 001CAFC0 cuSignalExternalSemaphoresAsync + 388 183 001ACD10 cuSignalExternalSemaphoresAsync_ptsz + 389 184 001C8A60 cuStreamAddCallback + 390 185 001AA280 cuStreamAddCallback_ptsz + 391 186 001C8CE0 cuStreamAttachMemAsync + 392 187 001AAF40 cuStreamAttachMemAsync_ptsz + 393 188 001CA850 cuStreamBatchMemOp + 394 189 001ADD30 cuStreamBatchMemOp_ptsz + 395 18A 001CB440 cuStreamBeginCapture + 396 18B 001CB630 cuStreamBeginCapture_ptsz + 397 18C 001CB830 cuStreamBeginCapture_v2 + 398 18D 001AA500 cuStreamBeginCapture_v2_ptsz + 399 18E 001A95D0 cuStreamCreate + 400 18F 001A97F0 cuStreamCreateWithPriority + 401 190 001C2ED0 cuStreamDestroy + 402 191 001AB560 cuStreamDestroy_v2 + 403 192 001CBA30 cuStreamEndCapture + 404 193 001AA900 cuStreamEndCapture_ptsz + 405 194 001CBE50 cuStreamGetCaptureInfo + 406 195 001AAD20 cuStreamGetCaptureInfo_ptsz + 407 196 001C8630 cuStreamGetCtx + 408 197 001A9E50 cuStreamGetCtx_ptsz + 409 198 001C8420 cuStreamGetFlags + 410 199 001A9C40 cuStreamGetFlags_ptsz + 411 19A 001C8210 cuStreamGetPriority + 412 19B 001A9A30 cuStreamGetPriority_ptsz + 413 19C 001CBC40 cuStreamIsCapturing + 414 19D 001AAB10 cuStreamIsCapturing_ptsz + 415 19E 001C8F20 cuStreamQuery + 416 19F 001AB180 cuStreamQuery_ptsz + 417 1A0 001C9110 cuStreamSynchronize + 418 1A1 001AB370 cuStreamSynchronize_ptsz + 419 1A2 001C8840 cuStreamWaitEvent + 420 1A3 001AA060 cuStreamWaitEvent_ptsz + 421 1A4 001CA100 cuStreamWaitValue32 + 422 1A5 001AD370 cuStreamWaitValue32_ptsz + 423 1A6 001CA5E0 cuStreamWaitValue64 + 424 1A7 001AD5E0 cuStreamWaitValue64_ptsz + 425 1A8 001C9E90 cuStreamWriteValue32 + 426 1A9 001AD850 cuStreamWriteValue32_ptsz + 427 1AA 001CA370 cuStreamWriteValue64 + 428 1AB 001ADAC0 cuStreamWriteValue64_ptsz + 429 1AC 001BA360 cuSurfObjectCreate + 430 1AD 001BA560 cuSurfObjectDestroy + 431 1AE 001BA740 cuSurfObjectGetResourceDesc + 432 1AF 001B9750 cuSurfRefGetArray + 433 1B0 001B9540 cuSurfRefSetArray + 434 1B1 001B9950 cuTexObjectCreate + 435 1B2 001B9B80 cuTexObjectDestroy + 436 1B3 001B9D60 cuTexObjectGetResourceDesc + 437 1B4 001BA160 cuTexObjectGetResourceViewDesc + 438 1B5 001B9F60 cuTexObjectGetTextureDesc + 439 1B6 001B9180 cuTexRefCreate + 440 1B7 001B9360 cuTexRefDestroy + 441 1B8 001C24C0 cuTexRefGetAddress + 442 1B9 001B7F50 cuTexRefGetAddressMode + 443 1BA 001B7930 cuTexRefGetAddress_v2 + 444 1BB 001B7B50 cuTexRefGetArray + 445 1BC 001B8D80 cuTexRefGetBorderColor + 446 1BD 001B8160 cuTexRefGetFilterMode + 447 1BE 001B8F80 cuTexRefGetFlags + 448 1BF 001B8360 cuTexRefGetFormat + 449 1C0 001B8B80 cuTexRefGetMaxAnisotropy + 450 1C1 001B8570 cuTexRefGetMipmapFilterMode + 451 1C2 001B8770 cuTexRefGetMipmapLevelBias + 452 1C3 001B8970 cuTexRefGetMipmapLevelClamp + 453 1C4 001B7D50 cuTexRefGetMipmappedArray + 454 1C5 001C2050 cuTexRefSetAddress + 455 1C6 001C2290 cuTexRefSetAddress2D + 456 1C7 001BCDF0 cuTexRefSetAddress2D_v2 + 457 1C8 001B64E0 cuTexRefSetAddress2D_v3 + 458 1C9 001B6920 cuTexRefSetAddressMode + 459 1CA 001B6290 cuTexRefSetAddress_v2 + 460 1CB 001B5E70 cuTexRefSetArray + 461 1CC 001B7540 cuTexRefSetBorderColor + 462 1CD 001B6B30 cuTexRefSetFilterMode + 463 1CE 001B7740 cuTexRefSetFlags + 464 1CF 001B6710 cuTexRefSetFormat + 465 1D0 001B7340 cuTexRefSetMaxAnisotropy + 466 1D1 001B6D20 cuTexRefSetMipmapFilterMode + 467 1D2 001B6F20 cuTexRefSetMipmapLevelBias + 468 1D3 001B7120 cuTexRefSetMipmapLevelClamp + 469 1D4 001B6080 cuTexRefSetMipmappedArray + 470 1D5 001AA700 cuThreadExchangeStreamCaptureMode + 471 1D6 001D3FA0 cuWGLGetDevice + 472 1D7 001CB200 cuWaitExternalSemaphoresAsync + 473 1D8 001ACF50 cuWaitExternalSemaphoresAsync_ptsz + + Summary + + 116000 .data + 4B000 .pdata + AD0000 .rdata + 15000 .reloc + 7000 .rsrc + 473000 .text diff --git a/src/bin.rs b/src/bin.rs new file mode 100644 index 0000000..d0e9230 --- /dev/null +++ b/src/bin.rs @@ -0,0 +1,76 @@ +extern crate clap; +extern crate detours_sys; + +use std::error::Error; +use std::ffi::OsStr; +use std::mem; +use std::os::windows::ffi::OsStrExt; +use std::ptr; + +use clap::{App, AppSettings, Arg}; + +mod win_err; + +fn main() -> Result<(), Box<dyn Error>> { + let matches = App::new("notCUDA injector") + .setting(AppSettings::TrailingVarArg) + .arg( + Arg::with_name("EXE") + .help("Path to the executable to be injected with notCUDA") + .required(true), + ) + .arg( + Arg::with_name("ARGS") + .multiple(true) + .help("Arguments that will be passed to <EXE>"), + ) + .get_matches(); + let exe = matches.value_of_os("EXE").unwrap(); + let args: Vec<&OsStr> = matches + .values_of_os("ARGS") + .map(|x| x.collect()) + .unwrap_or_else(|| Vec::new()); + let mut cmd_line = Vec::<u16>::with_capacity(exe.len() + 2); + cmd_line.push('\"' as u16); + copy_to(exe, &mut cmd_line); + cmd_line.push('\"' as u16); + cmd_line.push(' ' as u16); + args.split_last().map(|(last_arg, args)| { + for arg in args { + cmd_line.reserve(arg.len()); + copy_to(arg, &mut cmd_line); + cmd_line.push(' ' as u16); + } + copy_to(last_arg, &mut cmd_line); + }); + + cmd_line.push(0); + let mut startup_info = unsafe { mem::zeroed::<detours_sys::_STARTUPINFOW>() }; + let mut proc_info = unsafe { mem::zeroed::<detours_sys::_PROCESS_INFORMATION>() }; + let process_success = unsafe { + detours_sys::DetourCreateProcessWithDllExW( + ptr::null(), + cmd_line.as_mut_ptr(), + ptr::null_mut(), + ptr::null_mut(), + 0, + 0x10, + ptr::null_mut(), + ptr::null(), + &mut startup_info as *mut _, + &mut proc_info as *mut _, + "nvcuda_redirect.dll".as_ptr() as *const i8, + Option::None, + ) + }; + if process_success == 0 { + return Err(win_err::error_string(win_err::errno()))?; + } + Ok(()) +} + +fn copy_to(from: &OsStr, to: &mut Vec<u16>) { + for x in from.encode_wide() { + to.push(x); + } +} diff --git a/src/cu.rs b/src/cu.rs new file mode 100644 index 0000000..c8c08ab --- /dev/null +++ b/src/cu.rs @@ -0,0 +1,85 @@ +#[repr(C)] +#[allow(non_camel_case_types)] +pub enum Result { + SUCCESS = 0, + ERROR_INVALID_VALUE = 1, + ERROR_OUT_OF_MEMORY = 2, + ERROR_NOT_INITIALIZED = 3, + ERROR_DEINITIALIZED = 4, + ERROR_PROFILER_DISABLED = 5, + ERROR_PROFILER_NOT_INITIALIZED = 6, + ERROR_PROFILER_ALREADY_STARTED = 7, + ERROR_PROFILER_ALREADY_STOPPED = 8, + ERROR_NO_DEVICE = 100, + ERROR_INVALID_DEVICE = 101, + ERROR_INVALID_IMAGE = 200, + ERROR_INVALID_CONTEXT = 201, + ERROR_CONTEXT_ALREADY_CURRENT = 202, + ERROR_MAP_FAILED = 205, + ERROR_UNMAP_FAILED = 206, + ERROR_ARRAY_IS_MAPPED = 207, + ERROR_ALREADY_MAPPED = 208, + ERROR_NO_BINARY_FOR_GPU = 209, + ERROR_ALREADY_ACQUIRED = 210, + ERROR_NOT_MAPPED = 211, + ERROR_NOT_MAPPED_AS_ARRAY = 212, + ERROR_NOT_MAPPED_AS_POINTER = 213, + ERROR_ECC_UNCORRECTABLE = 214, + ERROR_UNSUPPORTED_LIMIT = 215, + ERROR_CONTEXT_ALREADY_IN_USE = 216, + ERROR_PEER_ACCESS_UNSUPPORTED = 217, + ERROR_INVALID_PTX = 218, + ERROR_INVALID_GRAPHICS_CONTEXT = 219, + ERROR_NVLINK_UNCORRECTABLE = 220, + ERROR_JIT_COMPILER_NOT_FOUND = 221, + ERROR_INVALID_SOURCE = 300, + ERROR_FILE_NOT_FOUND = 301, + ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND = 302, + ERROR_SHARED_OBJECT_INIT_FAILED = 303, + ERROR_OPERATING_SYSTEM = 304, + ERROR_INVALID_HANDLE = 400, + ERROR_ILLEGAL_STATE = 401, + ERROR_NOT_FOUND = 500, + ERROR_NOT_READY = 600, + ERROR_ILLEGAL_ADDRESS = 700, + ERROR_LAUNCH_OUT_OF_RESOURCES = 701, + ERROR_LAUNCH_TIMEOUT = 702, + ERROR_LAUNCH_INCOMPATIBLE_TEXTURING = 703, + ERROR_PEER_ACCESS_ALREADY_ENABLED = 704, + ERROR_PEER_ACCESS_NOT_ENABLED = 705, + ERROR_PRIMARY_CONTEXT_ACTIVE = 708, + ERROR_CONTEXT_IS_DESTROYED = 709, + ERROR_ASSERT = 710, + ERROR_TOO_MANY_PEERS = 711, + ERROR_HOST_MEMORY_ALREADY_REGISTERED = 712, + ERROR_HOST_MEMORY_NOT_REGISTERED = 713, + ERROR_HARDWARE_STACK_ERROR = 714, + ERROR_ILLEGAL_INSTRUCTION = 715, + ERROR_MISALIGNED_ADDRESS = 716, + ERROR_INVALID_ADDRESS_SPACE = 717, + ERROR_INVALID_PC = 718, + ERROR_LAUNCH_FAILED = 719, + ERROR_COOPERATIVE_LAUNCH_TOO_LARGE = 720, + ERROR_NOT_PERMITTED = 800, + ERROR_NOT_SUPPORTED = 801, + ERROR_SYSTEM_NOT_READY = 802, + ERROR_SYSTEM_DRIVER_MISMATCH = 803, + ERROR_COMPAT_NOT_SUPPORTED_ON_DEVICE = 804, + ERROR_STREAM_CAPTURE_UNSUPPORTED = 900, + ERROR_STREAM_CAPTURE_INVALIDATED = 901, + ERROR_STREAM_CAPTURE_MERGE = 902, + ERROR_STREAM_CAPTURE_UNMATCHED = 903, + ERROR_STREAM_CAPTURE_UNJOINED = 904, + ERROR_STREAM_CAPTURE_ISOLATION = 905, + ERROR_STREAM_CAPTURE_IMPLICIT = 906, + ERROR_CAPTURED_EVENT = 907, + ERROR_STREAM_CAPTURE_WRONG_THREAD = 908, + ERROR_TIMEOUT = 909, + ERROR_GRAPH_EXEC_UPDATE_FAILURE = 910, + ERROR_UNKNOWN = 999, +} + +#[repr(C)] +pub struct Uuid { + x: [std::os::raw::c_char; 16] +}
\ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..fee62d0 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,23 @@ +mod cu; + +#[no_mangle] +pub extern "stdcall" fn cuDriverGetVersion(version: &mut std::os::raw::c_int) -> cu::Result { + *version = 0; + return cu::Result::SUCCESS; +} + +#[no_mangle] +pub extern "stdcall" fn cuInit(_: *const std::os::raw::c_uint) -> cu::Result { + return cu::Result::SUCCESS; +} + +#[no_mangle] +pub extern "stdcall" fn cuGetExportTable(_: *const *const std::os::raw::c_void, _: cu::Uuid) -> cu::Result { + return cu::Result::ERROR_NOT_SUPPORTED; +} + +#[no_mangle] +pub extern "stdcall" fn cuDeviceGetCount(count: &mut std::os::raw::c_int) -> cu::Result { + *count = 1; + return cu::Result::SUCCESS; +} diff --git a/src/win_err.rs b/src/win_err.rs new file mode 100644 index 0000000..f3a675b --- /dev/null +++ b/src/win_err.rs @@ -0,0 +1,103 @@ +#![allow(non_snake_case)] + +use std::ptr; + +mod c { + use std::ffi::c_void; + use std::os::raw::{c_ulong}; + + pub type DWORD = c_ulong; + pub type HANDLE = LPVOID; + pub type LPVOID = *mut c_void; + pub type HINSTANCE = HANDLE; + pub type HMODULE = HINSTANCE; + pub type WCHAR = u16; + pub type LPCWSTR = *const WCHAR; + pub type LPWSTR = *mut WCHAR; + + pub const FACILITY_NT_BIT: DWORD = 0x1000_0000; + pub const FORMAT_MESSAGE_FROM_HMODULE: DWORD = 0x00000800; + pub const FORMAT_MESSAGE_FROM_SYSTEM: DWORD = 0x00001000; + pub const FORMAT_MESSAGE_IGNORE_INSERTS: DWORD = 0x00000200; + + extern "system" { + pub fn GetLastError() -> DWORD; + pub fn GetModuleHandleW(lpModuleName: LPCWSTR) -> HMODULE; + pub fn FormatMessageW( + flags: DWORD, + lpSrc: LPVOID, + msgId: DWORD, + langId: DWORD, + buf: LPWSTR, + nsize: DWORD, + args: *const c_void, + ) -> DWORD; + } +} + +pub fn errno() -> i32 { + unsafe { c::GetLastError() as i32 } +} + +/// Gets a detailed string description for the given error number. +pub fn error_string(mut errnum: i32) -> String { + // This value is calculated from the macro + // MAKELANGID(LANG_SYSTEM_DEFAULT, SUBLANG_SYS_DEFAULT) + let langId = 0x0800 as c::DWORD; + + let mut buf = [0 as c::WCHAR; 2048]; + + unsafe { + let mut module = ptr::null_mut(); + let mut flags = 0; + + // NTSTATUS errors may be encoded as HRESULT, which may returned from + // GetLastError. For more information about Windows error codes, see + // `[MS-ERREF]`: https://msdn.microsoft.com/en-us/library/cc231198.aspx + if (errnum & c::FACILITY_NT_BIT as i32) != 0 { + // format according to https://support.microsoft.com/en-us/help/259693 + const NTDLL_DLL: &[u16] = &[ + 'N' as _, 'T' as _, 'D' as _, 'L' as _, 'L' as _, '.' as _, 'D' as _, 'L' as _, + 'L' as _, 0, + ]; + module = c::GetModuleHandleW(NTDLL_DLL.as_ptr()); + + if module != ptr::null_mut() { + errnum ^= c::FACILITY_NT_BIT as i32; + flags = c::FORMAT_MESSAGE_FROM_HMODULE; + } + } + + let res = c::FormatMessageW( + flags | c::FORMAT_MESSAGE_FROM_SYSTEM | c::FORMAT_MESSAGE_IGNORE_INSERTS, + module, + errnum as c::DWORD, + langId, + buf.as_mut_ptr(), + buf.len() as c::DWORD, + ptr::null(), + ) as usize; + if res == 0 { + // Sometimes FormatMessageW can fail e.g., system doesn't like langId, + let fm_err = errno(); + return format!( + "OS Error {} (FormatMessageW() returned error {})", + errnum, fm_err + ); + } + + match String::from_utf16(&buf[..res]) { + Ok(mut msg) => { + // Trim trailing CRLF inserted by FormatMessageW + let len = msg.trim_end().len(); + msg.truncate(len); + msg + } + Err(..) => format!( + "OS Error {} (FormatMessageW() returned \ + invalid UTF-16)", + errnum + ), + } + } +} |