GetDeviceGammaRamp() API hangs in Windows 10 insider preview 18362.53

I just updated to Windows 10 April 2019 build 18362.53 and I found an issue when calling the GetDeviceGammaRamp() API.  If I call this API in the following way then the API will hang and never return.  This used to work in all previous versions of Windows:

WORD lpRamp[3 * 256] = { NULL };

HDC hDC = GetDC(nullptr);

GetDeviceGammaRamp(hDC, lpRamp);

Answer
Answer

Hi Elisha,

 

Thank you for writing to Microsoft Community Forums.

 

As you are on build 18362.53, I suggest you to update the Windows Insider Build to the latest Preview and check if you are still facing the same issue.

 

For the latest Windows Insider Build, you can refer Announcing Windows 10 Insider Preview Build 18875.

 

For reference, you may also refer GetDeviceGammaRamp and check if this helps.

 

If you are still facing the same issue, then I suggest you to post your query in MSDN Forums, where we have support professionals who are well equipped with the knowledge on API.

Best regards,
Shafeeq Ali Khan
Microsoft Community – Moderator

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Answer
Answer

Hello Shafeeq,

First of all, thank you for your response!  I don't really want to upgrade to Build 18875 because this is a production machine and I cannot risk having some of the defects that may exist in an early build like that.

As far as this issue, I found out that it seems to only happen when you run the code inside the DllMain() function as seen below.  I coped the full code so that you can reproduce the issue yourself (see below).  I should also mention that if I run SetDeviceGammaRamp() in the DllMain() as listed below it will fail to run and all code after that line will fail to run.  So it seems there is an issue with both GetDeviceGammaRamp() and SetDeviceGammaRamp().

I am ok to post this on MSDN forums, but I mainly posted it here because it is a bug in the latest version of Windows Insider Preview that is coming out next month.  I figured you would want to know about the bug so you can fix it.  This is the first time posting on any Microsoft forum, even though I have been using Microsoft Windows since Windows for Workgroups 3.11.  If the guys on the MSDN forum can fix defects in the Windows Insider Preview then I am ok to post it there.  Again I am just posting this to make you aware of a bug in the new version of Windows that is coming out next month.

Below is a sample of the full code that triggers the bug in Windows:

#include <windows.h>

WORD lpRamp[3 * 256] = { NULL };
HDC hDC = nullptr;

// Dll main function
bool APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved)
{
    switch (fdwReason)
    {
    case DLL_PROCESS_ATTACH:
        hDC = GetDC(nullptr);
        GetDeviceGammaRamp(hDC, lpRamp);  // <-- It will hang on this line
        break;
    case DLL_PROCESS_DETACH:
        SetDeviceGammaRamp(hDC, lpRamp);  // <-- The dll will exit on this line and nothing after this line will ever run
        ReleaseDC(nullptr, hDC);
        break;
    }
    return true;
}

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated February 2, 2021 Views 920 Applies to: