Added the missing calling convention (CallingConvention.Cdecl) for the unmanaged function pointers in the NVAPI wrapper.

This commit is contained in:
Michael Möller 2020-02-11 23:49:20 +01:00
parent d2c60279a0
commit 710fe75138

View File

@ -237,41 +237,72 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
Marshal.SizeOf(typeof(NvGPUCoolerLevels)) | 0x10000; Marshal.SizeOf(typeof(NvGPUCoolerLevels)) | 0x10000;
private delegate IntPtr nvapi_QueryInterfaceDelegate(uint id); private delegate IntPtr nvapi_QueryInterfaceDelegate(uint id);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate NvStatus NvAPI_InitializeDelegate(); private delegate NvStatus NvAPI_InitializeDelegate();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate NvStatus NvAPI_GPU_GetFullNameDelegate( private delegate NvStatus NvAPI_GPU_GetFullNameDelegate(
NvPhysicalGpuHandle gpuHandle, StringBuilder name); NvPhysicalGpuHandle gpuHandle, StringBuilder name);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate NvStatus NvAPI_GPU_GetThermalSettingsDelegate( public delegate NvStatus NvAPI_GPU_GetThermalSettingsDelegate(
NvPhysicalGpuHandle gpuHandle, int sensorIndex, NvPhysicalGpuHandle gpuHandle, int sensorIndex,
ref NvGPUThermalSettings nvGPUThermalSettings); ref NvGPUThermalSettings nvGPUThermalSettings);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate NvStatus NvAPI_EnumNvidiaDisplayHandleDelegate(int thisEnum, public delegate NvStatus NvAPI_EnumNvidiaDisplayHandleDelegate(int thisEnum,
ref NvDisplayHandle displayHandle); ref NvDisplayHandle displayHandle);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate NvStatus NvAPI_GetPhysicalGPUsFromDisplayDelegate( public delegate NvStatus NvAPI_GetPhysicalGPUsFromDisplayDelegate(
NvDisplayHandle displayHandle, [Out] NvPhysicalGpuHandle[] gpuHandles, NvDisplayHandle displayHandle, [Out] NvPhysicalGpuHandle[] gpuHandles,
out uint gpuCount); out uint gpuCount);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate NvStatus NvAPI_EnumPhysicalGPUsDelegate( public delegate NvStatus NvAPI_EnumPhysicalGPUsDelegate(
[Out] NvPhysicalGpuHandle[] gpuHandles, out int gpuCount); [Out] NvPhysicalGpuHandle[] gpuHandles, out int gpuCount);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate NvStatus NvAPI_GPU_GetTachReadingDelegate( public delegate NvStatus NvAPI_GPU_GetTachReadingDelegate(
NvPhysicalGpuHandle gpuHandle, out int value); NvPhysicalGpuHandle gpuHandle, out int value);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate NvStatus NvAPI_GPU_GetAllClocksDelegate( public delegate NvStatus NvAPI_GPU_GetAllClocksDelegate(
NvPhysicalGpuHandle gpuHandle, ref NvClocks nvClocks); NvPhysicalGpuHandle gpuHandle, ref NvClocks nvClocks);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate NvStatus NvAPI_GPU_GetPStatesDelegate( public delegate NvStatus NvAPI_GPU_GetPStatesDelegate(
NvPhysicalGpuHandle gpuHandle, ref NvPStates nvPStates); NvPhysicalGpuHandle gpuHandle, ref NvPStates nvPStates);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate NvStatus NvAPI_GPU_GetUsagesDelegate( public delegate NvStatus NvAPI_GPU_GetUsagesDelegate(
NvPhysicalGpuHandle gpuHandle, ref NvUsages nvUsages); NvPhysicalGpuHandle gpuHandle, ref NvUsages nvUsages);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate NvStatus NvAPI_GPU_GetCoolerSettingsDelegate( public delegate NvStatus NvAPI_GPU_GetCoolerSettingsDelegate(
NvPhysicalGpuHandle gpuHandle, int coolerIndex, NvPhysicalGpuHandle gpuHandle, int coolerIndex,
ref NvGPUCoolerSettings nvGPUCoolerSettings); ref NvGPUCoolerSettings nvGPUCoolerSettings);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate NvStatus NvAPI_GPU_SetCoolerLevelsDelegate( public delegate NvStatus NvAPI_GPU_SetCoolerLevelsDelegate(
NvPhysicalGpuHandle gpuHandle, int coolerIndex, NvPhysicalGpuHandle gpuHandle, int coolerIndex,
ref NvGPUCoolerLevels NvGPUCoolerLevels); ref NvGPUCoolerLevels NvGPUCoolerLevels);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate NvStatus NvAPI_GPU_GetMemoryInfoDelegate( public delegate NvStatus NvAPI_GPU_GetMemoryInfoDelegate(
NvDisplayHandle displayHandle, ref NvMemoryInfo nvMemoryInfo); NvDisplayHandle displayHandle, ref NvMemoryInfo nvMemoryInfo);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate NvStatus NvAPI_GetDisplayDriverVersionDelegate( public delegate NvStatus NvAPI_GetDisplayDriverVersionDelegate(
NvDisplayHandle displayHandle, [In, Out] ref NvDisplayDriverVersion NvDisplayHandle displayHandle, [In, Out] ref NvDisplayDriverVersion
nvDisplayDriverVersion); nvDisplayDriverVersion);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate NvStatus NvAPI_GetInterfaceVersionStringDelegate( public delegate NvStatus NvAPI_GetInterfaceVersionStringDelegate(
StringBuilder version); StringBuilder version);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate NvStatus NvAPI_GPU_GetPCIIdentifiersDelegate( public delegate NvStatus NvAPI_GPU_GetPCIIdentifiersDelegate(
NvPhysicalGpuHandle gpuHandle, out uint deviceId, out uint subSystemId, NvPhysicalGpuHandle gpuHandle, out uint deviceId, out uint subSystemId,
out uint revisionId, out uint extDeviceId); out uint revisionId, out uint extDeviceId);