Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ZribeDev authored Feb 29, 2024
1 parent d3b9798 commit fbf361b
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,44 @@ static void SetProcessCriticalStatus(int pid, bool setStatus, Action<string, Col
logAction($"Something went wrong: {ex.Message}", Color.Red);
}
}
```
Since you don't have the same logging setup as me, I've tweaked the code to use Console.WriteLine instead. Check it out:
```csharp
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

const int STATUS_SUCCESS = 0;
const int ProcessBreakOnTermination = 0x1D;

[DllImport("ntdll.dll", SetLastError = true)]
static extern int NtSetInformationProcess(IntPtr processHandle, int processInformationClass, ref int processInformation, int processInformationLength);

static void SetProcessCriticalStatus(int pid, bool setStatus)
{
try
{
Process process = Process.GetProcessById(pid);
if (process == null)
{
Console.WriteLine("Couldn't find the process.");
return;
}

int isCritical = setStatus ? 1 : 0;
int result = NtSetInformationProcess(process.Handle, ProcessBreakOnTermination, ref isCritical, sizeof(int));
if (result == STATUS_SUCCESS)
{
Console.WriteLine($"Process {(setStatus ? "is now vulnerable" : "is back to normal")} successfully.");
}
else
{
Console.WriteLine($"Couldn't change the process. Error: {result}");
}
}
catch (Exception ex)
{
Console.WriteLine($"Something went wrong: {ex.Message}");
}
}

0 comments on commit fbf361b

Please sign in to comment.