VOID NvApiInitialize(VOID) { ULONG sampleCount; if (!PhGetIntegerSetting(SETTING_NAME_ENABLE_GPU)) return; sampleCount = PhGetIntegerSetting(L"SampleCount"); PhInitializeCircularBuffer_FLOAT(&GpuUtilizationHistory, sampleCount); PhInitializeCircularBuffer_ULONG(&GpuMemoryHistory, sampleCount); PhInitializeCircularBuffer_FLOAT(&GpuBoardHistory, sampleCount); PhInitializeCircularBuffer_FLOAT(&GpuBusHistory, sampleCount); NvGpuPhysicalHandleList = PhCreateList(1); NvGpuDisplayHandleList = PhCreateList(1); #ifdef _M_IX86 if (!(NvApiLibrary = LoadLibrary(L"nvapi.dll"))) return; #else if (!(NvApiLibrary = LoadLibrary(L"nvapi64.dll"))) return; #endif // Retrieve the NvAPI_QueryInterface function address if (!(NvAPI_QueryInterface = PhGetProcedureAddress(NvApiLibrary, "nvapi_QueryInterface", 0))) return; // Initialization functions if (!(NvAPI_Initialize = NvAPI_QueryInterface(0x150E828UL))) return; if (!(NvAPI_Unload = NvAPI_QueryInterface(0xD22BDD7EUL))) return; // Error functions NvAPI_GetErrorMessage = NvAPI_QueryInterface(0x6C2D048CUL); // Handle functions NvAPI_EnumPhysicalGPUs = NvAPI_QueryInterface(0xE5AC921FUL); NvAPI_EnumNvidiaDisplayHandle = NvAPI_QueryInterface(0x9ABDD40DUL); // Information functions NvAPI_SYS_GetDriverAndBranchVersion = NvAPI_QueryInterface(0x2926AAADUL); NvAPI_GPU_GetFullName = NvAPI_QueryInterface(0xCEEE8E9FUL); // Query functions NvAPI_GPU_GetMemoryInfo = NvAPI_QueryInterface(0x774AA982UL); NvAPI_GPU_GetThermalSettings = NvAPI_QueryInterface(0xE3640A56UL); NvAPI_GPU_GetCoolerSettings = NvAPI_QueryInterface(0xDA141340UL); NvAPI_GPU_GetPerfDecreaseInfo = NvAPI_QueryInterface(0x7F7F4600UL); NvAPI_GPU_GetTachReading = NvAPI_QueryInterface(0x5F608315UL); NvAPI_GPU_GetAllClockFrequencies = NvAPI_QueryInterface(0xDCB616C3UL); // Undocumented functions below NvAPI_GPU_GetUsages = NvAPI_QueryInterface(0x189A1FDFUL); NvAPI_GPU_GetAllClocks = NvAPI_QueryInterface(0x1BD69F49UL); NvAPI_GPU_GetVoltageDomainsStatus = NvAPI_QueryInterface(0xC16C7E2CUL); NvAPI_GPU_GetPerfClocks = NvAPI_QueryInterface(0x1EA54A3B); NvAPI_GPU_GetVoltages = NvAPI_QueryInterface(0x7D656244); NvAPI_GPU_QueryActiveApps = NvAPI_QueryInterface(0x65B1C5F5); NvAPI_GPU_GetShaderPipeCount = NvAPI_QueryInterface(0x63E2F56F); NvAPI_GPU_GetShaderSubPipeCount = NvAPI_QueryInterface(0x0BE17923); NvAPI_GPU_GetRamBusWidth = NvAPI_QueryInterface(0x7975C581); NvAPI_GPU_GetRamBankCount = NvAPI_QueryInterface(0x17073A3CUL); NvAPI_GPU_GetRamType = NvAPI_QueryInterface(0x57F7CAACUL); NvAPI_GPU_GetRamMaker = NvAPI_QueryInterface(0x42AEA16AUL); NvAPI_GPU_GetFoundry = NvAPI_QueryInterface(0x5D857A00UL); //NvAPI_GetDisplayDriverMemoryInfo = NvAPI_QueryInterface(0x774AA982); //NvAPI_GetPhysicalGPUsFromDisplay = NvAPI_QueryInterface(0x34EF9506); NvAPI_GetDisplayDriverVersion = NvAPI_QueryInterface(0xF951A4D1UL); NvAPI_GetDisplayDriverRegistryPath = NvAPI_QueryInterface(0x0E24CEEEUL); //NvAPI_RestartDisplayDriver = NvAPI_QueryInterface(0xB4B26B65UL); //NvAPI_GPU_GetBoardInfo = NvAPI_QueryInterface(0x22D54523); //NvAPI_GPU_GetBusType = NvAPI_QueryInterface(0x1BB18724); //NvAPI_GPU_GetIRQ = NvAPI_QueryInterface(0xE4715417); NvAPI_GPU_GetVbiosVersionString = NvAPI_QueryInterface(0xA561FD7DUL); NvAPI_GPU_GetShortName = NvAPI_QueryInterface(0xD988F0F3UL); NvAPI_GPU_GetArchInfo = NvAPI_QueryInterface(0xD8265D24UL); NvAPI_GPU_GetPCIIdentifiers = NvAPI_QueryInterface(0x2DDFB66EUL); NvAPI_GPU_GetPartitionCount = NvAPI_QueryInterface(0x86F05D7AUL); NvAPI_GPU_GetGpuCoreCount = NvAPI_QueryInterface(0xC7026A87UL); NvAPI_GPU_GetPCIEInfo = NvAPI_QueryInterface(0xE3795199UL); NvAPI_GPU_GetFBWidthAndLocation = NvAPI_QueryInterface(0x11104158UL); NvAPI_GPU_ClientPowerTopologyGetStatus = NvAPI_QueryInterface(0x0EDCF624EUL); NvAPI_GetDisplayDriverBuildTitle = NvAPI_QueryInterface(0x7562E947); NvAPI_GetDisplayDriverCompileType = NvAPI_QueryInterface(0x988AEA78); NvAPI_GetDisplayDriverSecurityLevel = NvAPI_QueryInterface(0x9D772BBA); NvAPI_GPU_GetVPECount = NvAPI_QueryInterface(0xD8CBF37B); NvAPI_GPU_GetTargetID = NvAPI_QueryInterface(0x35B5FD2F); //NvAPI_GPU_GetExtendedMinorRevision = NvAPI_QueryInterface(0x025F17421); //NvAPI_GPU_GetSerialNumber = NvAPI_QueryInterface(0x14B83A5F); if (NvAPI_Initialize() == NVAPI_OK) { NvGpuEnumPhysicalHandles(); NvGpuEnumDisplayHandles(); NvApiInitialized = TRUE; } }
BOOLEAN InitializeNvApi(VOID) { NvGpuPhysicalHandleList = PhCreateList(1); NvGpuDisplayHandleList = PhCreateList(1); #ifdef _M_IX86 if (!(NvApiLibrary = LoadLibrary(L"nvapi.dll"))) return FALSE; #else if (!(NvApiLibrary = LoadLibrary(L"nvapi64.dll"))) return FALSE; #endif if (!(NvAPI_QueryInterface = PhGetProcedureAddress(NvApiLibrary, "nvapi_QueryInterface", 0))) return FALSE; if (!(NvAPI_Initialize = NvAPI_QueryInterface(0x150E828UL))) return FALSE; if (!(NvAPI_Unload = NvAPI_QueryInterface(0xD22BDD7EUL))) return FALSE; if (!(NvAPI_GetErrorMessage = NvAPI_QueryInterface(0x6C2D048CUL))) return FALSE; if (!(NvAPI_EnumPhysicalGPUs = NvAPI_QueryInterface(0xE5AC921FUL))) return FALSE; if (!(NvAPI_EnumNvidiaDisplayHandle = NvAPI_QueryInterface(0x9ABDD40DUL))) return FALSE; // Information functions NvAPI_SYS_GetDriverAndBranchVersion = NvAPI_QueryInterface(0x2926AAADUL); NvAPI_GPU_GetFullName = NvAPI_QueryInterface(0xCEEE8E9FUL); // Query functions NvAPI_GPU_GetMemoryInfo = NvAPI_QueryInterface(0x774AA982UL); NvAPI_GPU_GetThermalSettings = NvAPI_QueryInterface(0xE3640A56UL); NvAPI_GPU_GetCoolerSettings = NvAPI_QueryInterface(0xDA141340UL); NvAPI_GPU_GetPerfDecreaseInfo = NvAPI_QueryInterface(0x7F7F4600UL); NvAPI_GPU_GetTachReading = NvAPI_QueryInterface(0x5F608315UL); NvAPI_GPU_GetAllClockFrequencies = NvAPI_QueryInterface(0xDCB616C3UL); // Undocumented Query functions NvAPI_GPU_GetUsages = NvAPI_QueryInterface(0x189A1FDFUL); NvAPI_GPU_GetAllClocks = NvAPI_QueryInterface(0x1BD69F49UL); NvAPI_GPU_GetVoltageDomainsStatus = NvAPI_QueryInterface(0xC16C7E2CUL); //NvAPI_GPU_GetPerfClocks = NvAPI_QueryInterface(0x1EA54A3B); //NvAPI_GPU_GetVoltages = NvAPI_QueryInterface(0x7D656244); //NvAPI_GPU_QueryActiveApps = NvAPI_QueryInterface(0x65B1C5F5); //NvAPI_GPU_GetShaderPipeCount = NvAPI_QueryInterface(0x63E2F56F); //NvAPI_GPU_GetShaderSubPipeCount = NvAPI_QueryInterface(0x0BE17923); NvAPI_GPU_GetRamBusWidth = NvAPI_QueryInterface(0x7975C581); // ADD ME NvAPI_GPU_GetRamBankCount = NvAPI_QueryInterface(0x17073A3CUL); NvAPI_GPU_GetRamType = NvAPI_QueryInterface(0x57F7CAACUL); NvAPI_GPU_GetRamMaker = NvAPI_QueryInterface(0x42AEA16AUL); NvAPI_GPU_GetFoundry = NvAPI_QueryInterface(0x5D857A00UL); //NvAPI_GetDisplayDriverMemoryInfo = NvAPI_QueryInterface(0x774AA982); //NvAPI_GetPhysicalGPUsFromDisplay = NvAPI_QueryInterface(0x34EF9506); NvAPI_GetDisplayDriverVersion = NvAPI_QueryInterface(0xF951A4D1UL); NvAPI_GetDisplayDriverRegistryPath = NvAPI_QueryInterface(0x0E24CEEEUL); //NvAPI_RestartDisplayDriver = NvAPI_QueryInterface(0xB4B26B65UL); //NvAPI_GPU_GetBoardInfo = NvAPI_QueryInterface(0x22D54523); //NvAPI_GPU_GetBusType = NvAPI_QueryInterface(0x1BB18724); //NvAPI_GPU_GetIRQ = NvAPI_QueryInterface(0xE4715417); NvAPI_GPU_GetVbiosVersionString = NvAPI_QueryInterface(0xA561FD7DUL); NvAPI_GPU_GetShortName = NvAPI_QueryInterface(0xD988F0F3UL); NvAPI_GPU_GetArchInfo = NvAPI_QueryInterface(0xD8265D24UL); NvAPI_GPU_GetPCIIdentifiers = NvAPI_QueryInterface(0x2DDFB66EUL); NvAPI_GPU_GetPartitionCount = NvAPI_QueryInterface(0x86F05D7AUL); NvAPI_GPU_GetGpuCoreCount = NvAPI_QueryInterface(0xC7026A87UL); NvAPI_GPU_GetPCIEInfo = NvAPI_QueryInterface(0xE3795199UL); NvAPI_GPU_GetFBWidthAndLocation = NvAPI_QueryInterface(0x11104158UL); NvAPI_GPU_ClientPowerTopologyGetStatus = NvAPI_QueryInterface(0x0EDCF624EUL); //typedef NvAPI_Status (WINAPIV *_NvAPI_GetDisplayDriverBuildTitle)(_In_ NvDisplayHandle hNvDisplay, NvAPI_ShortString pDriverBuildTitle); //typedef NvAPI_Status (WINAPIV *_NvAPI_GetDisplayDriverCompileType)(_In_ NvDisplayHandle hNvDisplay, NvU32* pDriverCompileType); //typedef NvAPI_Status (WINAPIV *_NvAPI_GetDisplayDriverSecurityLevel)(_In_ NvDisplayHandle hNvDisplay, NvU32* pDriverSecurityLevel); //typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetVPECount)(_In_ NvPhysicalGpuHandle hPhysicalGPU, NvU32* pVPECount); //typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetSerialNumber)(_In_ NvPhysicalGpuHandle hPhysicalGPU, NvU32* serialnumber); //typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetExtendedMinorRevision)(_In_ NvPhysicalGpuHandle hPhysicalGPU, NvU32* revision); //typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetTargetID)(_In_ NvPhysicalGpuHandle hPhysicalGPU, NvU32* target); //_NvAPI_GPU_GetExtendedMinorRevision NvAPI_GPU_GetExtendedMinorRevision; //_NvAPI_GPU_GetTargetID NvAPI_GPU_GetTargetID; //_NvAPI_GPU_GetSerialNumber NvAPI_GPU_GetSerialNumber; //_NvAPI_GPU_GetVPECount NvAPI_GPU_GetVPECount; //_NvAPI_GetDisplayDriverBuildTitle NvAPI_GetDisplayDriverBuildTitle; //_NvAPI_GetDisplayDriverCompileType NvAPI_GetDisplayDriverCompileType; //_NvAPI_GetDisplayDriverSecurityLevel NvAPI_GetDisplayDriverSecurityLevel; //NvAPI_GPU_GetExtendedMinorRevision = NvAPI_QueryInterface(0x025F17421); //NvAPI_GPU_GetTargetID = NvAPI_QueryInterface(0x35B5FD2F); //NvAPI_GPU_GetSerialNumber = NvAPI_QueryInterface(0x14B83A5F); //NvAPI_GPU_GetVPECount = NvAPI_QueryInterface(0xD8CBF37B); //NvAPI_GetDisplayDriverBuildTitle = NvAPI_QueryInterface(0x7562E947); //NvAPI_GetDisplayDriverCompileType = NvAPI_QueryInterface(0x988AEA78); //NvAPI_GetDisplayDriverSecurityLevel = NvAPI_QueryInterface(0x9D772BBA); if (NvAPI_Initialize() == NVAPI_OK) { NvGpuEnumPhysicalHandles(); NvGpuEnumDisplayHandles(); return TRUE; } return FALSE; }
VOID InitGfx(VOID) { HMODULE module; // Specify the nVidia Library to load. #ifdef _M_IX86 module = LoadLibrary(L"nvapi.dll"); #else module = LoadLibrary(L"nvapi64.dll"); #endif if (module == NULL) { // Specify the Ati Library to load. #ifdef _M_IX86 module = LoadLibrary(L"atiadlxy.dll"); #else module = LoadLibrary(L"atiadlxx.dll"); #endif if (module != NULL) { GraphicsType = AtiGraphics; } } else { GraphicsType = NvidiaGraphics; } switch (GraphicsType) { case NvidiaGraphics: { // Find our QueryInterface API NvAPI_QueryInterface = (P_NvAPI_QueryInterface)GetProcAddress(module, "nvapi_QueryInterface"); // Check if QueryInterface was found. if (NvAPI_QueryInterface != NULL) { // 50/50 these ID's and API defs are correct. // Library initialization functions NvAPI_Initialize = (P_NvAPI_Initialize)NvAPI_QueryInterface(0x150E828); NvAPI_Unload = (P_NvAPI_Unload)NvAPI_QueryInterface(0xD22BDD7E); // Error Functions NvAPI_GetErrorMessage = (P_NvAPI_GetErrorMessage)NvAPI_QueryInterface(0x6C2D048Cu); // Handle Functions NvAPI_EnumPhysicalGPUs = (P_NvAPI_EnumPhysicalGPUs)NvAPI_QueryInterface(0xE5AC921F); NvAPI_EnumNvidiaDisplayHandle = (P_NvAPI_EnumNvidiaDisplayHandle)NvAPI_QueryInterface(0x9ABDD40D); // Query Functions NvAPI_GetUsages = (P_NvAPI_GPU_GetUsages)NvAPI_QueryInterface(0x189A1FDF); NvAPI_GetMemoryInfo = (P_NvAPI_GetMemoryInfo)NvAPI_QueryInterface(0x774AA982); NvAPI_GetPhysicalGPUsFromDisplay = (P_NvAPI_GetPhysicalGPUsFromDisplay)NvAPI_QueryInterface(0x34EF9506); NvAPI_GetInterfaceVersionString = (P_NvAPI_GetInterfaceVersionString)NvAPI_QueryInterface(0x1053FA5); NvAPI_GetFullName = (P_NvAPI_GPU_GetFullName)NvAPI_QueryInterface(0xCEEE8E9F); NvAPI_GetAllClocks = (P_NvAPI_GPU_GetAllClocks)NvAPI_QueryInterface(0x1BD69F49); NvAPI_GetThermalSettings = (P_NvAPI_GPU_GetThermalSettings)NvAPI_QueryInterface(0xE3640A56); NvAPI_GetCoolerSettings = (P_NvAPI_GPU_GetCoolerSettings)NvAPI_QueryInterface(0xDA141340); NvAPI_GetDisplayDriverVersion = (P_NvAPI_GetDisplayDriverVersion)NvAPI_QueryInterface(0xF951A4D1); NvAPI_GetPerfDecreaseInfo = (P_NvAPI_GPU_GetPerfDecreaseInfo)NvAPI_QueryInterface(0x7F7F4600); { NvStatus status = NvAPI_Initialize(); if (NV_SUCCESS(status)) { physHandle = EnumNvidiaGpuHandles(); dispHandle = EnumNvidiaDisplayHandles(); } else { LogEvent(L"gfxinfo: (InitGfx) NvAPI_Initialize failed (%s)", status); } } } } break; case AtiGraphics: { //ADL_MAIN_CONTROL_DESTROY ADL_Main_Control_Destroy = NULL; //ADL_ADAPTER_NUMBEROFADAPTERS_GET ADL_Adapter_NumberOfAdapters_Get = NULL; //ADL_ADAPTER_ADAPTERINFO_GET ADL_Adapter_AdapterInfo_Get = NULL; //ADL_Main_Control_Create = (ADL_MAIN_CONTROL_CREATE)GetProcAddress(module, "ADL_Main_Control_Create"); //ADL_Main_Control_Destroy = (ADL_MAIN_CONTROL_DESTROY)GetProcAddress(module, "ADL_Main_Control_Destroy"); //ADL_Adapter_NumberOfAdapters_Get = (ADL_ADAPTER_NUMBEROFADAPTERS_GET)GetProcAddress(module, "ADL_Adapter_NumberOfAdapters_Get"); //ADL_Adapter_AdapterInfo_Get = (ADL_ADAPTER_ADAPTERINFO_GET)GetProcAddress(module, "ADL_Adapter_AdapterInfo_Get"); //ADL_Display_DisplayInfo_Get = (ADL_DISPLAY_DISPLAYINFO_GET)GetProcAddress(module, "ADL_Display_DisplayInfo_Get"); //ADL_Display_ColorCaps_Get = (ADL_DISPLAY_COLORCAPS_GET)GetProcAddress(module, "ADL_Display_ColorCaps_Get"); //ADL_Display_Color_Get = (ADL_DISPLAY_COLOR_GET)GetProcAddress(module, "ADL_Display_Color_Get"); //ADL_Display_Color_Set = (ADL_DISPLAY_COLOR_SET)GetProcAddress(module, "ADL_Display_Color_Set"); //Adl_GetCurrentActivity = (P_Adl_OVERDRIVE_CURRENTACTIVITY_Get)GetProcAddress(module, "ADL_Overdrive5_CurrentActivity_Get"); } break; default: { } break; } }