public RemoteThread Create(IntPtr address, bool isStarted = true)
{
// Create the thread
var ret = ThreadCore.NtQueryInformationThread(
ThreadCore.CreateRemoteThread(MemorySharp.Handle, address, IntPtr.Zero, ThreadCreationFlags.Suspended));
// Get the native thread previously created
// Loop until the native thread is retrieved
ProcessThread nativeThread;
do
{
nativeThread = MemorySharp.Threads.NativeThreads.FirstOrDefault(t => t.Id == ret.ThreadId);
} while (nativeThread == null);
// Wrap the native thread in an object of the library
var result = new RemoteThread(MemorySharp, nativeThread);
// If the thread must be started
if (isStarted)
result.Resume();
return result;
}