Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/insomnimus/cmdc
Compile a command line into a Windows executable!
https://github.com/insomnimus/cmdc
assembly cli compiler rust win32 windows
Last synced: about 1 month ago
JSON representation
Compile a command line into a Windows executable!
- Host: GitHub
- URL: https://github.com/insomnimus/cmdc
- Owner: insomnimus
- License: mit
- Created: 2022-07-16T23:22:03.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-12T15:18:30.000Z (5 months ago)
- Last Synced: 2024-08-12T17:46:03.700Z (5 months ago)
- Topics: assembly, cli, compiler, rust, win32, windows
- Language: Rust
- Size: 38.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# CMDC - Command Compiler
This program saves a command along with its arguments into a 32 or 64-bit PE executable (Windows only).It receives the command and an output file, writes the serialized command into a pre-determined location in an executable template and saves the modified template into the output file.
For that, the executable template needs to be compiled first; for full control and minimal size, the template is written in assembly.
## But this is what a shell script should do! Why did you write this?!
No particular reason, take it or leave it :^).There is actually one use case that I know of, though: `cargo` style subcommand plugins sometimes need `.exe` extensions.
So instead of writing a small program that basically calls a shell script with an interpreter, you can use `cmdc` to do it for you.## Install
Grab a pre-built binary from the [releases page](https://github.com/insomnimus/cmdc/releases) ([here's the latest release](https://github.com/insomnimus/cmdc/releases/latest)).Or build from source:
## Building
Since the templates are written in assembly and make use of macros provided by [flat-assembler](https://flatassembler.net), you must have the `fasm.exe` installed on your system.
You will also need a recent enough version of rust (tested with 1.73.0).1. Install flat-assembler from [here](https://flatassembler.net) or optionally from [scoop](https://github.com/ScoopInstaller/scoop).
2. If flat-assembler's `INCLUDE` directory is not in your `$INCLUDE` env variable, put it there. Or optionally set the `FASM_INCLUDE` env variable to the directory.
3. If `fasm.exe` is not in `$PATH`, set the `FASM` environment variable to the full path where `fasm.exe` is located; e.g `D:\fasm\fasm.exe`.
4. Build like the usual: `cargo build --release`. The build script will take care of assembling the assembly files.## Usage
Provide a command, an output file and optional arguments.
You can optionally specify a different arch than the one the program was compiled on with `--arch=x32|x64`.```powershell
# cmd style ls
cmdc -o dir.exe -- cmd.exe /c dir
# Inspect the generated executable:
cmdc -i dir.exe
# prints: "cmd.exe" /c dir
# ls using wsl
# note that wsl.exe only works on 64 bit
cmdc -a x64 -o ls.exe -- wsl.exe ls
# Inspect the executable:
cmdc --inspect ls.exe
# prints: "wsl.exe" ls
```