-
-
Notifications
You must be signed in to change notification settings - Fork 3k
WPF - Modify CopyMemory EntryPoint to work with .Net Core #2885
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
Conversation
Contributes to cefsharp#2796
|
✅ Build CefSharp 76.1.90-CI3256 completed (commit 344d90b446 by @kpreisser) |
Is there a reason you chose
As we only target |
|
✅ Build CefSharp 76.1.90-CI3259 completed (commit 9233614c43 by @) |
… the buffers do not overlap.
a7cf10a to
1b77af4
Compare
No particular reason, I was just following the comments in https://github.com/dotnet/coreclr/issues/24008 for changing I updated the PR to use the faster |
|
✅ Build CefSharp 76.1.90-CI3260 completed (commit 145624719d by @kpreisser) |
Actually it would appear to be that Confirmed in the output of
The other being to use NativeMethodWrapper.CopyMemoryUsingHandle which I had previous added with the intention of bench marking to see if the native call was quicker than the Additional background http://www.vbforums.com/showthread.php?856067-Which-Windows-DLL-actually-has-RtlCopyMemory&p=5238099&viewfull=1#post5238099 |
RtlCopyMemory was only working for 64bit, falling back to RtlMoveMemory for now. Details in #2885 (comment) Follow up to c11157f
- RtlCopyMemory only works on x64, we could use the slower RtlMoveMemory, going with a native wrapper around RtlCopyMemory - Renamed CopyMemoryUsingHandle to MemoryCopy (cannot be CopyMemory or RtlCopyMemory as macro with that name already exists) #2885 (comment) Issue #2885
|
Changed to use native wrapper around Originally the |
|
Thank for your the background information and the fix! Sorry, I didn't test running as x86 after changing the PR from (As additional thought, since kernel32's Thanks! |
All good 😄 Makes no sense that it exists on |
Contributes to #2796
Summary:
CopyMemoryentrypoint declaration, which is not working on .NET Core 3.0 askernel32.dlldoesn't have anCopyMemoryexport.Changes:
EntryPointfromCopyMemorytoRtlCopyMemorynumberOfBytesparameter fromuinttoUIntPtrNote: I believe using an pointer type (
IntPtrorUIntPtr) for thenumberOfBytesparameter is correct even though pinvoke.net (and other sites) specify it asint, because the documentation forCopyMemory/RtlCopyMemorydeclares it asSIZE_Twhich is defined as pointer-sized integer (ULONG_PTR). Additionally, I have done some testing to verify that the value is actually interpreted as 64-bit integer when running as x64 (by specifying a value greater than 0xFFFFFFFF and verifying the correct number of bytes was copied).Note: There is also a managed API
Buffer.MemoryCopy()that could be used instead of p/invokingRtlCopyMemory/RtlMoveMemory, available starting with .NET Framework 4.6, but that one seems to be slower.How Has This Been Tested?
Tested manually using
CefSharp.MinimalExample.NetCore.Wpf(see cefsharp/CefSharp.MinimalExample#57)Types of changes
Checklist: