Last active
April 3, 2024 09:19
-
-
Save q3k/e5952111283ea59ee78a7699919a055b to your computer and use it in GitHub Desktop.
Linux syscalls in .exe executed under Wine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
const char *buf = "hello from linux\n"; | |
char * const argv[] = { | |
"/bin/sh", | |
"-c", | |
"echo 'hello from execve'", | |
NULL, | |
}; | |
int main() { | |
printf("hello from win32\n"); | |
size_t ret; | |
size_t size = strlen(buf); | |
asm volatile | |
( | |
"syscall" | |
: "=a" (ret) | |
: "0"(1), "D"(1), "S"(buf), "d"(size) | |
: "rcx", "r11", "memory" | |
); | |
asm volatile | |
( | |
"syscall" | |
: "=a" (ret) | |
: "0"(59), "D"(argv[0]), "S"(argv), "d"(0) | |
: "rcx", "r11", "memory" | |
); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cursed.exe (built in msys2): https://object.ceph-eu.hswaw.net/q3k-personal/b8159d43e0698d...