-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
201 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using System.Diagnostics; | ||
using System.Runtime.InteropServices; | ||
using SBMI = Sucrose.Backgroundog.Manage.Internal; | ||
|
||
namespace Sucrose.Backgroundog.Extension | ||
{ | ||
internal static class Lifecycle | ||
{ | ||
public static bool Resume(IntPtr Handle) | ||
{ | ||
int Result = NtResumeProcess(Handle); | ||
|
||
if (Result == 0) | ||
{ | ||
return true; | ||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
public static bool Resume(Process Process) | ||
{ | ||
return Resume(Process.Handle); | ||
} | ||
|
||
public static bool Suspend(IntPtr Handle) | ||
{ | ||
int Result = NtSuspendProcess(Handle); | ||
|
||
if (Result == 0) | ||
{ | ||
return true; | ||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
public static bool Suspend(Process Process) | ||
{ | ||
return Suspend(Process.Handle); | ||
} | ||
|
||
public static void ResumeThread(Process Process) | ||
{ | ||
foreach (ProcessThread Thread in Process.Threads) | ||
{ | ||
IntPtr Threading = OpenThread(SBMI.THREAD_SUSPEND_RESUME, false, Thread.Id); | ||
|
||
ResumeThread(Threading); | ||
} | ||
} | ||
|
||
public static void SuspendThread(Process Process) | ||
{ | ||
foreach (ProcessThread Thread in Process.Threads) | ||
{ | ||
IntPtr Threading = OpenThread(SBMI.THREAD_SUSPEND_RESUME, false, Thread.Id); | ||
|
||
SuspendThread(Threading); | ||
} | ||
} | ||
|
||
[DllImport("kernel32.dll")] | ||
private static extern int ResumeThread(IntPtr hThread); | ||
|
||
[DllImport("kernel32.dll")] | ||
private static extern uint SuspendThread(IntPtr hThread); | ||
|
||
[DllImport("ntdll.dll")] | ||
private static extern int NtResumeProcess(IntPtr ProcessHandle); | ||
|
||
[DllImport("ntdll.dll")] | ||
private static extern int NtSuspendProcess(IntPtr ProcessHandle); | ||
|
||
[DllImport("kernel32.dll")] | ||
private static extern IntPtr OpenThread(int dwDesiredAccess, bool bInheritHandle, int dwThreadId); | ||
} | ||
} |
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