You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 26, 2023. It is now read-only.
* Add `SafeThreadHandle`
* Add `CreateProcessFlags.STACK_SIZE_PARAM_IS_A_RESERVATION`
* Add `PInvoke.SIZE_T`
* Add `CreateThread`, `CreateRemoteThread`, and `CreateRemoteThreadEx`
* Add a test for `CreateThread`
* Add tests for `CreateRemoteThread` and `CreateRemoteThreadEx`
* Ensure SafeThreadHandle is release w/ 'using'
* - Remove SafeThreadHandle - SafeObjectHandle has the same functionality.
- Remove SIZE_T - use UIntPtr instead; C# 9 can leverage nuint.
- Address review feedback
- Replace IntPtr parameters with pointers.
- Use FriendlyFlags.Optional where appropriate.
- Update tests.
* Add FriendlyFlags.NativeInt
* Add CreateThreadFlags enum
* Keep a reference to the ThreadProc delegate in a static field.
Co-authored-by: Andrew Arnott <[email protected]>
/// Note that this test DOES NOT create a true REMOTE thread in a foreign process; it just leverages this function to create a thread in the current (i.e, the test) procrss.
981
+
/// Nevertheless, this approach provides modest confidence that the P/Invoke definition is well-formed.
982
+
///
983
+
/// Creates a thread by supplying <see cref="CreateThread_Test_ThreadMain(void*)"/> as its ThreadProc/<see cref="Kernel32.THREAD_START_ROUTINE"/>.
984
+
/// The ThreadProc updates a bool value (supplied by the thread that created it) from false -> true. This change
985
+
/// is observed by the calling thread as proof of successful thread-creation.
986
+
///
987
+
/// Also validates that the (native) Thread-ID for the newly created Thread is different than the (native) Thread-ID
/// Note that this test DOES NOT create a true REMOTE thread in a foreign process; it just leverages this function to create a thread in the current (i.e, the test) procrss.
1015
+
/// Nevertheless, this approach provides modest confidence that the P/Invoke definition is well-formed.
1016
+
///
1017
+
/// Creates a thread by supplying <see cref="CreateThread_Test_ThreadMain(void*)"/> as its ThreadProc/<see cref="Kernel32.THREAD_START_ROUTINE"/>.
1018
+
/// The ThreadProc updates a bool value (supplied by the thread that created it) from false -> true. This change
1019
+
/// is observed by the calling thread as proof of successful thread-creation.
1020
+
///
1021
+
/// Also validates that the (native) Thread-ID for the newly created Thread is different than the (native) Thread-ID
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+
namespacePInvoke
5
+
{
6
+
usingSystem;
7
+
8
+
/// <content>
9
+
/// Contains the <see cref="CreateThreadFlags"/> nested type.
10
+
/// </content>
11
+
publicpartialclassKernel32
12
+
{
13
+
/// <summary>
14
+
/// Flags that may be passed to the <see cref="CreateThread(SECURITY_ATTRIBUTES*, UIntPtr, THREAD_START_ROUTINE, void*, CreateThreadFlags, uint*)"/> function
15
+
/// </summary>
16
+
[Flags]
17
+
publicenumCreateThreadFlags
18
+
{
19
+
None=0x0,
20
+
21
+
/// <summary>
22
+
/// The primary thread of the new process is created in a suspended state, and does not run until the <see cref="ResumeThread"/> function is called.
23
+
/// </summary>
24
+
CREATE_SUSPENDED=0x00000004,
25
+
26
+
/// <summary>
27
+
/// The dwStackSize parameter in <see cref="CreateThread(SECURITY_ATTRIBUTES*, UIntPtr, THREAD_START_ROUTINE, void*, CreateThreadFlags, uint*)"/>
28
+
/// specifies the initial reserve size of the stack. If this flag is not specified,
0 commit comments