SetWindowDisplayAffinity bad usecase

Marius Ukt 0 Reputation points
2024-04-10T09:58:17.7933333+00:00

Hey,

We have a classroom of exam computers that are monitored by the class admin through a remote feed that uses the Windows API to take screenshots at specified intervals. Some students have found that if they execute an app with SetWindowDisplayAffinity(logo_hwnd, WDA_EXCLUDEFROMCAPTURE), it will be invisible to any monitoring tool except physical cameras, thus allowing them to cheat, which is bad. Can a computer administrator execute some command to disable this function? Maybe there is methods to take a screenshot ignoring this setting.

Sincerely, Marius

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,425 questions
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. RLWA32 40,481 Reputation points
    2024-04-11T16:39:03.03+00:00

    Another option that will require some programming to accomplish --

    A per-user service can be installed that starts automatically at user sign-on and periodically checks top-level windows with the GetWindowDisplayAffinity function. Advantages of per-user services are that non-administrators cannot stop a service and service restart options can be used to automatically restart the service if the user kills its process. If the service detects a window for which WDA_EXCLUDEFROMCAPTURE or WDA_MONITOR has been set then the service can terminate the related process and perform logging and/or notification actions.

    1 person found this answer helpful.

  2. richard thompson 5 Reputation points
    2024-04-11T19:23:41.7666667+00:00
    Entering the facility before closing and hiding in the premises until after closing.
    
    1 person found this answer helpful.
    0 comments No comments

  3. Castorix31 81,736 Reputation points
    2024-04-11T19:37:34.2266667+00:00

    A way is to inject code into the remote process and call SetWindowDisplayAffinity with WDA_NONE

    I tested on Windows10 22H2 with a WH_GETMESSAGE hook (global hook with a DLL, J. Richter method by posting to the window a (WM_USER + x) message to call SetWindowDisplayAffinity)

    I don't know if this still works on Windows 11...

    (should be doable without DLL with CreateRemoteThread, but more complex)

    1 person found this answer helpful.
    0 comments No comments

  4. Xiaopo Yang - MSFT 11,496 Reputation points Microsoft Vendor
    2024-04-11T02:13:02.5133333+00:00

    Hello @Marius Ukt,

    It's better to apply an Application Whitelist Policy in Windows instead of breaking the API. See Administer Software Restriction Policies or search guides on Internet.

    Thank you.


  5. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more