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

DataTarget.CreateSnapshotAndAttach error: Unable to find an entry point named 'PssCaptureSnapshot' in DLL 'kernel32.dll' #953

Open
R4ND3LL opened this issue Aug 30, 2021 · 2 comments

Comments

@R4ND3LL
Copy link

R4ND3LL commented Aug 30, 2021

This line of code produces the error below:
var target = DataTarget.CreateSnapshotAndAttach(Process.GetCurrentProcess().Id);

System.EntryPointNotFoundException: Unable to find an entry point named 'PssCaptureSnapshot' in DLL 'kernel32.dll'.

       at Microsoft.Diagnostics.Runtime.WindowsProcessDataReader.PssCaptureSnapshot(IntPtr ProcessHandle, PSS_CAPTURE_FLAGS CaptureFlags, Int32 ThreadContextFlags, IntPtr& SnapshotHandle)
   at Microsoft.Diagnostics.Runtime.WindowsProcessDataReader..ctor(Int32 processId, WindowsProcessDataReaderMode mode)
   at Microsoft.Diagnostics.Runtime.DataTarget.CreateSnapshotAndAttach(Int32 processId)
   at ServerAdminPlugin.StackTraceAnalyzer.GetAllStackTraces()

Environment: .NET 5 app running on Windows Server 2008 R2 Standard, with, among other things, latest .NET 5 SDK installed. Same error happens on .NetFramework 4.8 app running on Windows Server 2008.

Same code works on dev machine (Win 10).

End result is this terminates the app, even though it's wrapped in try-catch.

@R4ND3LL
Copy link
Author

R4ND3LL commented Aug 31, 2021

I may have answered my own question. Microsoft states that this function is only supported on:

Minimum supported client Windows 8.1 [desktop apps only]
Minimum supported server Windows Server 2012 R2 [desktop apps only]

Researching elsewhere, I found this function was only included on kernel32.dll version 6.3+.

Would be nice if this was noted somewhere in the docs around CreateSnapshotAndAttach use on Windows.

@liudonghua123
Copy link

I encountered the same problems when back port cpython 3.12 to windows 7, and I rewrite the usage of PssCaptureSnapshot.

See liudonghua123/windows-python-installer@d1ad543, https://github.com/adang1345/PythonWin7/blob/master/patches/restore-win7-handling.patch.

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

2 participants