-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Replace usages of Marshal.AllocHGlobal with malloc in libraries #54468
Closed
Closed
Changes from 32 commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
10f15f7
System.Private.CoreLib
reflectronic 61340eb
System.Net.Security
reflectronic 96d410b
System.Net.NameResolution
reflectronic f93fe74
System.Net.NetworkInformation
reflectronic 6badbdd
System.Net.Quic
reflectronic d2b561f
System.Net.HttpListener
reflectronic 38824c5
nint casts
reflectronic 8ec610e
System.Text.Encoding.CodePages
reflectronic 2db0e86
intptr casts
reflectronic 658bf85
System.Speech
reflectronic 0930248
System.ServiceProcess.ServiceController
reflectronic 89ded43
NativeMemoryHelper in System.Speech
reflectronic 340735a
NativeMemoryHelper System.Text.Encoding.CodePages
reflectronic 7038fca
Crypto
reflectronic 453f15e
System.Reflection.Metadata
reflectronic 325b20d
System.Net.Http.WinHttpHandler
reflectronic 36c48a4
System.Management
reflectronic 09d0361
System.Diagnostics.EventLog
reflectronic 190fb6b
System.Drawing.Common
reflectronic 673925a
System.DirectoryServices.Protocols
reflectronic 29e37a5
System.DirectoryServices.AccountManagement
reflectronic 2510792
System.DirectoryServices
reflectronic 935a77a
System.Data.Odbc
reflectronic 68a9dc7
System.Diagnostics.PerformanceCounter
reflectronic 443c362
more System.Drawing.Common
reflectronic 5dd3cf6
more System.Private.CoreLib
reflectronic 8783e8c
Fix build break
reflectronic 3184c15
Fix additional embarrassing mistakes
reflectronic 6a0746a
Fix mistake
reflectronic 59cfa9b
fixing
reflectronic f8d77c2
fix project files
reflectronic 8bc626d
powershell doesn't know how to preserve BOM
reflectronic d52bb61
fix project files
reflectronic aa86b70
does SRM csproj have BOM?
reflectronic e6b6e8e
more csproj fixes
reflectronic f0fb97a
one last time
reflectronic 3423d98
Some changes
reflectronic b5dd0da
revert System.DirectoryServices.Protocols
reflectronic 8a1f781
revert System.DirectoryServices.AccountManagement
reflectronic 6fe4d7c
revert System.DirectoryServices
reflectronic c2275fc
fix corelib and other stuff
reflectronic 068248c
revert System.Drawing.Common
reflectronic b875528
fix SafeNativeMemoryHandle
reflectronic f89bc04
Sysem.Text.Encoding.CodePages safenativememoryhandle
reflectronic 2a961d3
fixxxx
reflectronic 1b0f51a
do it again
reflectronic af272a8
Improve crypto
reflectronic a2042c6
EventLog and other stuff
reflectronic 6e57302
misc other updates
reflectronic db1ee0c
Back out System.ServiceProcess
reflectronic e79d136
final fix perhaps
reflectronic b7c3292
Merge branch 'main' into replace-allochglobal
reflectronic 7156b1e
source.dot.net lied to me
reflectronic 3ea5947
Update MsQuicStream.cs
reflectronic fc6147a
fix
reflectronic 1b3e561
Compile errors
reflectronic 1f60dbf
Another fix
reflectronic 852508b
Fix
reflectronic 332e3aa
add unsafe
reflectronic de3481e
revert ldap interop
reflectronic 8d3fbdd
temp change
reflectronic c31c674
improvement
reflectronic 8a12cec
add unsafe
reflectronic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -453,7 +453,7 @@ private static ECCurve.ECCurveType ConvertToCurveTypeEnum(Interop.BCrypt.ECC_CUR | |
return curveType; | ||
} | ||
|
||
internal static SafeNCryptKeyHandle ImportKeyBlob( | ||
internal static unsafe SafeNCryptKeyHandle ImportKeyBlob( | ||
string blobType, | ||
ReadOnlySpan<byte> keyBlob, | ||
string curveName, | ||
|
@@ -471,8 +471,8 @@ internal static SafeNCryptKeyHandle ImportKeyBlob( | |
IntPtr buffPtr = IntPtr.Zero; | ||
try | ||
{ | ||
descPtr = Marshal.AllocHGlobal(Marshal.SizeOf(desc)); | ||
buffPtr = Marshal.AllocHGlobal(Marshal.SizeOf(buff)); | ||
descPtr = (nint)NativeMemory.Alloc((uint)Marshal.SizeOf(desc)); | ||
buffPtr = (nint)NativeMemory.Alloc((uint)Marshal.SizeOf(buff)); | ||
buff.cbBuffer = (curveName.Length + 1) * 2; // Add 1 for null terminator | ||
buff.BufferType = Interop.BCrypt.CngBufferDescriptors.NCRYPTBUFFER_ECC_CURVE_NAME; | ||
buff.pvBuffer = safeCurveName.DangerousGetHandle(); | ||
|
@@ -495,8 +495,8 @@ ref MemoryMarshal.GetReference(keyBlob), | |
} | ||
finally | ||
{ | ||
Marshal.FreeHGlobal(descPtr); | ||
Marshal.FreeHGlobal(buffPtr); | ||
NativeMemory.Free((void*)(nint)descPtr); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to change the type of the variables to |
||
NativeMemory.Free((void*)(nint)buffPtr); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: ReAllocHGlobal