Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example cpp/ScreenCaptureforHWND not working - Unhandled exception at 0x00007FFD3B8B9129 (KernelBase.dll) in ScreenCaptureforHWND.exe #37

Closed
gileli121 opened this issue Jul 6, 2019 · 10 comments

Comments

@gileli121
Copy link

Hello, I tried to run the example
ScreenCaptureforHWND

Using Visual Studio 2019 on Windows 10 64bit with SDK 10.0.18362.0

The example app was successfully built and working until I select some window to capture.

When I select a window, it always throws an exception
image

Unhandled exception at 0x00007FFD3B8B9129 (KernelBase.dll) in ScreenCaptureforHWND.exe: 0xC000041D: An unhandled exception was encountered during a user callback.

It is no matter what window I select. It always fails in this like.

Please fix the example.

Thank you.

@robmikh
Copy link
Member

robmikh commented Jul 7, 2019

It seems that you're failing the QI to get the IGraphicsCaptureItemInterop interface. Which version of Windows are you running? This feature was added in the 1903 update.

@gileli121
Copy link
Author

I have OS Build 10.0.17763.557
I will try it again after updating and will let you know if the issue resolved

@gileli121
Copy link
Author

gileli121 commented Jul 7, 2019

Hello, after I updated the example works. Good. is there an otption to not capture the mouse pointer?

And now I have another issue with the API function DwmRegisterThumbnail from here:
https://docs.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmregisterthumbnail

My program makes some big use with this function and after this update the function is not working as expected. Please see the issue I reported to Microsoft:

https://answers.microsoft.com/en-us/windows/forum/windows_10-update/dwmregisterthumbnail-is-not-working-as-expected-in/72dcf82e-7e8e-46f6-b7f3-d80f6f34fefa?tm=1562540172919

I know that the issue is not related to this. I just don't know where to get the support.
Please let me know where to get support about this issue. I am not sure that I reported it in the right place.

The issue is big and it broke something in my program...
Please help me to get support about this.

Thanks

@robmikh
Copy link
Member

robmikh commented Jul 8, 2019

Glad to hear the sample is working. The current Insider builds have an API we plan to add that makes the cursor rendering configurable. Look for a new property on GraphicsCaptureSession named IsCursorCaptureEnabled.

As for your issue with DwmRegisterThumbnail, what exactly are you having a problem with? Multiple thumbnails that are assigned to a single window, or the same thumbnail (or at least thumbnails targeting the same window) across multiple windows? I tried both just now and couldn't reproduce any issues. What would I do to reproduce this?

@gileli121
Copy link
Author

gileli121 commented Jul 8, 2019

Hello, I think that the problem is when you use the API via DLL file.. I could reproduce the bug only by using the API from a script that written in Autoit.

Please try to run this code:
https://pastebin.com/MNABim8w

Note that you will need to update the target window to display a preview for in line:
$targetGUI = HWnd(0x000000000002004C)

The problem is that you will see only one window getting the live preview. it did not happned before the update.

This is how it looks:
image

The preview 2 window don't get a live preview. Only the first one.
If I will remove this line that create the first preview:
$handle1 = RegisterWindowLivePreview($targetGUI,$hGUI1)

The second preview will work.

I think that the problem is because the API returns the same HTHUMBNAIL twice.
The this line:
$aRet = DllCall("dwmapi.dll", "int", "DwmRegisterThumbnail", "hwnd", $hwnd, "hwnd", $hWndOw, "ptr*", DllStructGetPtr($tID))
Will call to this function. the function returns the ID 1 even the second time. I think that this is the bug..
But in C++ version I did not saw this. The ID was 2 on the second call and not 1.

@gileli121
Copy link
Author

It seems that you did some change in dwmapi.dll in this update.
It seems that this dll now stores some global memory for the HTHUMBNAIL ID.

I know this because I found the solution.
The solution is open the dll file using:
$dwmDll = DllOpen('dwmapi.dll')

And then in any line that calls the dll, I need to use the dll handle $dwmDll
So instead of
DllCall('dwmapi.dll', ...
I write
DllCall($dwmDll, ...

This was solved the issue and now the script print different HTHUMBNAIL on the second call as expected.

@robmikh
Copy link
Member

robmikh commented Jul 8, 2019

That seems like there was a behavior change in Autoit, I can't get this to happen in C++. Glad everything was sorted out for you.

@robmikh robmikh closed this as completed Jul 8, 2019
@krenner
Copy link
Member

krenner commented Jul 11, 2019

Hi gileli121 - I wanted to comment on your question re: mouse cursors. Insider preview builds 18894 or greater have a new property on GraphicsCaptureSession named IsCursorCaptureEnabled. Release notes are here.

@gileli121
Copy link
Author

Thanks.
Will be also an option to remove the yellow frame of the window that under capture mode?

@robotogre
Copy link

@robmikh I am seeing this error in the latest version of Windows 10 LTSC 1809 (17763.1728).

Am I out of luck?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants