コード例 #1
0
ファイル: nvidia.c プロジェクト: processhacker2/plugins-extra
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;
}
コード例 #2
0
ファイル: nvidia.c プロジェクト: simon734/processhacker2
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;
    }
}