File tree Expand file tree Collapse file tree 4 files changed +14
-5
lines changed Expand file tree Collapse file tree 4 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ static void Main(string[] args)
42
42
var shell = Assembly . Load ( "SharpShell" ) ;
43
43
var program = shell . GetType ( "SharpShell.Program" ) ! ;
44
44
var main = program . GetMethod ( "Main" , BindingFlags . Static | BindingFlags . NonPublic ) ! ;
45
- main . Invoke ( null , [ Array . Empty < string > ( ) ] ) ;
45
+ main . Invoke ( null , [ args ] ) ;
46
46
}
47
47
}
48
48
}
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ public class Program
6
6
{
7
7
static void Main ( string [ ] args )
8
8
{
9
- UnmanagedPSEntry . Start ( Array . Empty < string > ( ) , 0 ) ;
9
+ UnmanagedPSEntry . Start ( args , 0 ) ;
10
10
}
11
11
}
12
12
}
Original file line number Diff line number Diff line change 2
2
3
3
set DOTNET_CLI_TELEMETRY_OPTOUT = 1
4
4
cd /d D:\pwsh
5
- ..\dotnet\dotnet.exe msbuild .\run_pwsh.xml
5
+ ..\dotnet\dotnet.exe msbuild .\run_pwsh.xml -p:CommandLineArgs= " %* "
Original file line number Diff line number Diff line change 1
1
<Project ToolsVersion =" Current" xmlns =" http://schemas.microsoft.com/developer/msbuild/2003" >
2
2
<UsingTask TaskName =" RunShellcode" TaskFactory =" RoslynCodeTaskFactory" AssemblyFile =" $(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
3
+ <ParameterGroup >
4
+ <CommandLineArgs ParameterType =" System.String" />
5
+ </ParameterGroup >
3
6
<Task >
4
7
<Using Namespace =" System" />
5
8
<Using Namespace =" System.IO" />
16
19
17
20
public class RunShellcode : Task
18
21
{
22
+ public string CommandLineArgs { get; set; }
23
+
19
24
public override bool Execute()
20
25
{
21
26
var dll = File.ReadAllBytes("SharpShell.Loader.dll");
22
27
var loader = Assembly.Load(dll);
23
28
var type = loader.GetType("SharpShell.Loader.Program")!;
24
29
var method = type.GetMethod("Main", BindingFlags.Static | BindingFlags.NonPublic)!;
25
- var res = method.Invoke(null, new object[] {new string[] {}});
30
+
31
+ /* Handle commandline args */
32
+ var cmdlineArgs = String.IsNullOrEmpty(CommandLineArgs) ? new string[]{} : new string[]{CommandLineArgs};
33
+
34
+ var res = method.Invoke(null, new object[] {cmdlineArgs});
26
35
return true;
27
36
}
28
37
}
32
41
</UsingTask >
33
42
34
43
<Target Name =" Run" >
35
- <RunShellcode />
44
+ <RunShellcode CommandLineArgs = " $(CommandLineArgs) " />
36
45
</Target >
37
46
</Project >
You can’t perform that action at this time.
0 commit comments