I want to execute a shell script(exactly as mentioned in the code below) from my .asm file but can,t find the alternative to the following lines in assembly.I am using masm611 to assemble and compile the files.
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "myscript.sh";
proc.Start();
First, you don't say which architecture; so this is unanswerable. An easy solution should be to just code this in C, then compile to assembly code - that's a switch all popular C compilers have, AFAIK - then just transplant to your own code, linking with appropriate libraries.
Disclaimer: I don't work in assembly.
Since your example is in .NET and you mention MASM, I assume that you work on Windows. On Windows, you can use either Win32 API to start a process, or the C RTL. Either way, you have to link to a static (.lib) library and call a function. In Win32 API,
ShellExecute()
is the easiest one to use (there's alsoCreateProcess()
, but the calling sequence is a pain). In the RTL, there's_execl()
and its relatives. Read up on consuming static libraries from assembly..NET code, like the
Process.Start()
stuff you've mentioned, does not translate into x86 assembly at all.May I ask why this has to be done from assembly? "Assembly" and "shell scripts" rarely go together. Note: on Windows, shell scripts have a .bat or a .cmd extension. .sh, on the other hand, is characteristic of *nix or MacOS.