Jump to content

Hello can anyone give me idea how to work with this function:

typedef int(*NvAPI_GPU_SetCoolerLevels_t)(int *handle, unsigned int, int fanlevel);
NvAPI_GPU_SetCoolerLevels_t NvAPI_GPU_SetCoolerLevels = 0;

NvAPI_GPU_SetCoolerLevels = NvQueryInterface(0x891FA0AE);


//////and now set speed to 100%, hdlGPU[0] means that speed will be set to first gpu.
int retval = NvAPI_GPU_SetCoolerLevels(hdlGPU[0], 0, 100);
	if (retval != 0)//retval retrieves action status {
		printf("Status: %i \n", retval);
	}

It throws error: 

System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

Problem is I cant find why its not working I believe adress is wrong or I missing params from function

NvAPI_GPU_SetCoolerLevels_t

.

Worst part is that nvidia docs doesnt provide any info about this function at all.

In some github repositories I readed that if you want manage fan speed you have to change params to NvAPI_GPU_SetCoolerPolicyTable, but I couldnt find what params exist for this function. So now I'm quite lost.

P.S. for testing reason i gathering gpus fan speed and it shows correctly so problem left on SetCoolerLevels and SetCoolerPolicyTable

P.S.S. some update if I remove unsigned int from SetCoolerLevels, it prints error -9 according:

https://docs.nvidia.com/gameworks/content/gameworkslibrary/coresdk/nvapi/group__nvapistatus.html#gacb260029291e5a208093a44b804b5549

it could mean:

A: An argument's structure version is not supported.

B:The handle is no longer valid (likely due to GPU or display re-configuration)

I hope I did mistake because I don't know any other options to manage gpu fan speeds.

P.S.S.S I was looking over github project but none of them worked.

I stuck with this problem for 2 days, I hope anyone could help.

CPU: Intel I7-8700K | Motherboard: Gigabyte Aorus Z390 Master | RAM: Corsair Vengeance 3000Mhz 2x8GB | GPU: Asus ROG 1080Ti OC | PSU: Seasonic Prime 650W Titanium | SSD: 1x Samsung Evo 970 250GB M2 1x Samsung Evo 970 1TB M2 | CPU COOLER: Noctua D15

Link to comment
https://linustechtips.com/topic/913160-assembling-code-in-c-for-nvapi/
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×