-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
54 lines (47 loc) · 1.44 KB
/
Program.cs
File metadata and controls
54 lines (47 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System.Runtime.InteropServices;
class ConsoleFwdCheck
{
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int MessageBox(IntPtr hWnd, String txt, String cap, uint type);
[DllImport("kernel32.dll")]
public static extern uint GetFileType(IntPtr hFile);
[DllImport("kernel32.dll")]
public static extern IntPtr GetStdHandle(IntPtr stdHandle);
static IntPtr redirCheck = (nint)GetFileType(GetStdHandle(-12));
static void Main(string[] args)
{
if (args.Length > 0 && !String.IsNullOrEmpty(args[0]))
{
switch (args[0])
{
case "0":
ConsoleFwd.Enumerate.StreamFwd();
break;
case "1":
break;
default:
break;
}
}
else
{
redirCheckFn();
}
static void redirCheckFn()
{
if (redirCheck == (1))
{
MessageBox(new IntPtr(0), "Exe launched with standard io as a file", "x", 0);
}
if (redirCheck == (2))
{
MessageBox(new IntPtr(0), "Exe launched with normal standard io", "x", 0);
}
else
{
Console.WriteLine($"Launched with(out) console redirect (Code: {redirCheck})");
Thread.Sleep(2000);
}
}
}
}