system-calls

the answer is always wrong in this MIPS recursion . got 10, supposed to be 55

℡╲_俬逩灬. 提交于 2019-12-25 18:55:34
问题 This code is supposed to print the sum of numbers from 10 to 0. It should be printing 55, but is printing 10 instead. Can you help me figure out where it's going wrong? main: # initialize values to 3 registers addi $a0,$zero,10 jal sum # call method # Print out the summation upto 10 li $v0,1 # print integer add $a1,$v0,$zero # load return value into argument syscall li $v0,10 # Exit syscall sum: addi $sp,$sp,-8 # allocate space on stack sw $ra,0($sp) # store the return address sw $a0,4($sp) #

Ubuntu 16.04 assembly code for shell

瘦欲@ 提交于 2019-12-25 04:23:21
问题 .global main main: call func .string "/bin/sh" func: push %rsp pop %rsi pop %rdi mov $0x00, %edx mov $0x3b, %eax syscall I wrote assembly lagunage like above for execute /bin/sh I compiled it but when I try to execute program, /bin/sh: 0: Can't open ???? this error is occur. It doesn't execute /bin/sh. I want to know why I can't execute /bin/sh I'm using Ubuntu 16.04 and x64 Architectures 回答1: Your code is needlessly hard to follow because of using push/pop in a weird way, but running your

Linux System Calls

元气小坏坏 提交于 2019-12-25 03:45:35
问题 Whats the changed over time on how Linux system calls were implemented on older (8086/88) Intel CPUS vs more modern CPU's. 回答1: The biggest change is the sysenter/sysexit (Intel's creation) and syscall/sysret (AMD's version) instructions on newer x86 (and Intel 64/AMD64) processors. These speed up system calls drastically compared to the interrupt method used previously. This has to do with reducing the steps the processor must go through when invoking a system call, and you can read up on

Is there a way to output ANSI escape sequences using low level output?

元气小坏坏 提交于 2019-12-25 01:35:27
问题 I'm trying to make a graphical engine in console. I don't use any of the GLs, but soon hoping to start. It is written in C and as for now, it is capable of building semi-3D environment in color, but I found, that win cmd supports True color scheme, using ANSI escape sequences. Throughout my research on this topic I've found WriteFile() , on which all the printfs and putcs are based in Win10. But for all goods it does not provide it is still slow. As internal code shows, writefile is

How do I make a system call and resume execution without waiting for the call to return?

孤者浪人 提交于 2019-12-24 21:07:21
问题 Basically I want to use system(), exec(), back-ticks or something to make a system call, but then to immediately resume execution in the calling script without caring about the result of the call and whether or not it returns, dies, stalls, whatever. Is it possible to do this without threading/forking? 回答1: Short answer, no. This is the entire point of fork() . The only question is whether you call fork() directly, or get something else to do that for you. As mentioned, you could use the

Multiple user processes accessing kernel linked list

爱⌒轻易说出口 提交于 2019-12-24 19:56:29
问题 I have 10 user space application which could invoke the same system call to kernel. For example 10 user space program could invoke bind system call. Upon receiving the system call, my code in the kernel would insert a data in linked list I created in the kernel space. I am using kernel linked list to add, remove and traverse node. I am also locking the node before writing to prevent the scenario where the list is not corrupted when accessed simultaneously by different user space processes. I

A way to call execl, execle, execlp, execv, execvP or execvp from Node.js

蹲街弑〆低调 提交于 2019-12-24 14:55:04
问题 POSIX systems expose family of exec functions, that allow one to load something maybe different into current process, keeping open file descriptors, process identifier and so on. This can be done for variety of reasons, and in my case this is bootstrapping — I want to change command line options of my own process, and then reload it over existing process, so there would be no child process. Unfortunately, to much of my surprise, I could not find the way to call any of exec* functions in Node

Sending an intent from c++ to java in Android 5.0.1_r1

北城以北 提交于 2019-12-24 14:08:41
问题 After going through several posts I figured out I could send the intent with the following line of code (second line used for debugging): int ret = system("am broadcast -a android.intent.action.MIKE_ACCESSED --user 0"); __android_log_print(ANDROID_LOG_DEBUG, "gxp18", "Shell command returned %i", ret); Unfortunately, this returns always (No matter what is the command used in the system("...")): Shell command returned 32512 Interestingly, I can successfully send the intent through adb using:

Raw Clone system call

。_饼干妹妹 提交于 2019-12-24 11:56:17
问题 I am trying to use the raw clone system, but I could not find any proper documentation. I tried to write a small program to try it, but this ends up with a segmentation fault. I cannot understand where I am wrong. here is the small application : define STACK_SIZE 0x10000 define BUFSIZE 200 #define _GNU_SOURCE void hello (){ fprintf(stderr,"Hello word\n"); _exit(0); } int main() { int res; void *stack = mmap(0, STACK_SIZE, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); pid_t ptid,

madvise(DODUMP) on the same ptr/size as a successful madvise(DONTDUMP) fails with EINVAL

Deadly 提交于 2019-12-24 10:27:51
问题 Testing a MariaDB anomaly of mysqld (10.3 branch) what it does is on startup: A memory allocation returns ptr=0x7fffe1a00000 for bytes=2097152 Before the madvise syscall, the /proc/{pid}/smap entry is: 7fffe1a00000-7fffe1c00000 rw-s 00000000 00:0f 18481215 /SYSV00000000 (deleted) Size: 2048 kB KernelPageSize: 2048 kB MMUPageSize: 2048 kB Rss: 0 kB Pss: 0 kB Shared_Clean: 0 kB Shared_Dirty: 0 kB Private_Clean: 0 kB Private_Dirty: 0 kB Referenced: 0 kB Anonymous: 0 kB LazyFree: 0 kB