Projects STRLCPY PowerShdll Commits 1ccea488
🤬
  • Added no output mode

    Added no output mode
  • Loading...
  • p3nt4 committed 7 years ago
    1ccea488
    1 parent 7772482a
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    createPSRelease.sh
     1 + 
  • ■ ■ ■ ■ ■ ■
    dll/Common.cs
    skipped 110 lines
    111 111   Console.WriteLine(ps.exe(cmd));
    112 112   }
    113 113   }
    114  - public static string LoadScript(string filename)
     114 + public string LoadScript(string filename)
    115 115   {
    116 116   try
    117 117   {
    skipped 11 lines
    129 129   catch (Exception e)
    130 130   {
    131 131   string errorText = e.Message + "\n";
     132 + pp = Process.GetCurrentProcess().Parent();
     133 + PSConsole.stealConsole(pp);
     134 + Console.CancelKeyPress += delegate {
     135 + this.cleanup();
     136 + };
     137 + Console.SetCursorPosition(0, Console.CursorTop + 2);
    132 138   Console.WriteLine(errorText);
    133 139   return ("error");
    134 140   }
    skipped 11 lines
    146 152   Console.WriteLine("rundll32 PowerShdll,main -f <path>\t Run the script passed as argument");
    147 153   Console.WriteLine("rundll32 PowerShdll,main -w\t Start an interactive console in a new window");
    148 154   Console.WriteLine("rundll32 PowerShdll,main -i\t Start an interactive console in this console");
     155 + Console.WriteLine("\nIf you do not have an interractive console, use -n to avoid crashes on ouput");
     156 + 
    149 157   }
    150 158   public void start(string[] args) {
    151  - if (args[0]=="") { usage(); return; }
    152  - else if (args[0] == "-h")
     159 + int i=0;
     160 + bool useConsole = true;
     161 + string ret;
     162 + if (args[i]=="") { usage(); return; }
     163 + if (args[i] == "-n")
     164 + {
     165 + i++;
     166 + useConsole = false;
     167 + }
     168 + if (args[i] == "-h")
    153 169   {
    154 170   usage();
    155 171   }
    156  - else if (args[0] == "-w")
     172 + else if (args[i] == "-w")
    157 173   {
    158 174   PSConsole.getNewConsole();
    159 175   this.interact();
    160 176   }
    161  - else if (args[0] == "-i")
     177 + else if (args[i] == "-i")
    162 178   {
    163 179   pp = Process.GetCurrentProcess().Parent();
    164 180   pp.Suspend();
    skipped 9 lines
    174 190   ps.close();
    175 191   pp.Resume();
    176 192   }
    177  - else if (args[0] == "-f")
     193 + else if (args[i] == "-f")
    178 194   {
    179  - if (args.Length < 2) {usage(); return; }
    180  - pp = Process.GetCurrentProcess().Parent();
    181  - PSConsole.stealConsole(pp);
    182  - Console.CancelKeyPress += delegate {
    183  - this.cleanup();
    184  - };
    185  - Console.SetCursorPosition(0, Console.CursorTop + 1);
    186  - string script = PowerShdll.LoadScript(args[1]);
     195 + i++;
     196 + if (args.Length < 2) { usage(); return; }
     197 + if (args[i] == "-n")
     198 + {
     199 + if (args.Length < 3) { usage(); return; }
     200 + i++;
     201 + useConsole = false;
     202 + }
     203 + string script = LoadScript(args[i]);
    187 204   if (script != "error")
    188 205   {
    189  - Console.Write(ps.exe(script));
    190  - }
     206 + ret = ps.exe(script);
     207 + if (useConsole) {
     208 + pp = Process.GetCurrentProcess().Parent();
     209 + PSConsole.stealConsole(pp);
     210 + Console.CancelKeyPress += delegate {
     211 + this.cleanup();
     212 + };
     213 + Console.SetCursorPosition(0, Console.CursorTop + 1);
     214 + Console.WriteLine(ret);
     215 + }
     216 + }
    191 217   }
    192 218   else
     219 + {
     220 + string script = string.Join(" ",args, i, args.Length-i);
     221 + if (script[0] == '"' && script[script.Length - 1] == '"') {
     222 + script = script.Substring(1, script.Length - 2);
     223 + }
     224 + ret = ps.exe(script);
     225 + if (useConsole)
    193 226   {
    194 227   pp = Process.GetCurrentProcess().Parent();
    195 228   PSConsole.stealConsole(pp);
    skipped 1 lines
    197 230   this.cleanup();
    198 231   };
    199 232   Console.SetCursorPosition(0, Console.CursorTop + 1);
    200  - string script = string.Join(" ", args);
    201  - Console.Write(ps.exe(script));
    202  - ps.close();
     233 + Console.WriteLine(ret);
     234 + }
     235 + ps.close();
    203 236   }
    204 237   return;
    205 238   }
    skipped 112 lines
  • dll/bin/x64/Release/PowerShdll.dll
    Binary file.
  • ■ ■ ■ ■ ■ ■
    dll/bin/x64/Release/test.ps1
     1 +cd C:\;
     2 +Start-Process cmd.exe;
     3 +ls;
  • dll/bin/x86/Release/PowerShdll.dll
    Binary file.
  • exe/bin/Release/PowerShdll.vshost.exe
    Binary file.
  • ■ ■ ■ ■ ■ ■
    exe/bin/Release/PowerShdll.vshost.exe.config
     1 +<?xml version="1.0" encoding="utf-8" ?>
     2 +<configuration>
     3 + <startup>
     4 + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
     5 + </startup>
     6 +</configuration>
  • ■ ■ ■ ■ ■ ■
    exe/bin/Release/PowerShdll.vshost.exe.manifest
     1 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
     2 +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
     3 + <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
     4 + <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
     5 + <security>
     6 + <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
     7 + <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
     8 + </requestedPrivileges>
     9 + </security>
     10 + </trustInfo>
     11 +</assembly>
     12 + 
Please wait...
Page is in error, reload to recover