Questions tagged [system-calls]

A system call is used by programs to request services from the operating system's kernel.

3690 questions
1
vote
0 answers

How can I test that a program handles partial read()s and write()s correctly?

It's well-known that the read and write syscalls can operate on fewer bytes than requested. But this is relatively rare and often not tested well. Consider this buggy C program: #include int main(void) { const char *buf = "Hello,…
1
vote
1 answer

Problem with hooking ntdll.dll calls

I'm currently working on hooking ntdll.dll calls via dll injection. At first, I create thread in existing process via CreateRemoteThread() then I load my dll via LoadLibrary and finally hook calls on PROCESS_ATTACH. Injection works fine, but then I…
qutron
  • 1,710
  • 4
  • 18
  • 30
1
vote
1 answer

How can I check if my syscall failed in NASM

I would like to know if anybody has a solution to my problem. I'm doing a project for school. This project is about creating a function (only in NASM) that uses a syscall (I have to create ft_read which reproduces the behaviour of the real read…
1
vote
2 answers

Get list of fixed drives

How can I get a list of all mount points for physical drives only? I see there is a similar answer on here but this lists all mount points including network shares. How can I get a listing of all drives on Windows using golang?
Jack bladk
  • 13
  • 2
1
vote
1 answer

Using syscall open() to open a file in FUSE

I'm recently working on fuse, but yet still cant have a grasp of how it works since i have very little knowledge about filesystem in linux. One of the most confusing thing is that what will happen if i use syscall open() to open a file within the…
1
vote
1 answer

ptrace system call returns -1 with errno=0

I am trying to do some very basic stuff using ptrace but I am a getting a really odd behavior. unsigned long start=strtoul(start_text,NULL,16); long start_data; if ((start_data = ptrace(PTRACE_PEEKTEXT,child_pid,(void*)start,NULL))<0){ …
EL_9
  • 404
  • 2
  • 10
1
vote
1 answer

XV6 - Pass parameters to systemcall and get return value

I need to write a system call in XV6 that gets a few integers and a few integer pointers as arguments, and I don't understand how to do it. I read about argint and argptr, but I don't understand how to use them. For example, I don't understand if…
Dani
  • 719
  • 1
  • 7
  • 14
1
vote
1 answer

strace -c doesn't report exit system calls

I'm working through some homework, and I need to report which system calls a C program makes use of. I noticed though that exit doesn't show up in strace reports. #include int main() { …
Carcigenicate
  • 43,494
  • 9
  • 68
  • 117
1
vote
0 answers

NASM program doesn't print constant integer (macOS)

I try to print b, but it prints nothing. Also I wanted to find length of b to hardcode it (because dws have the same length), but it printed nothing too (that's why I created lenlen — len of blen, so that I can print blen). Don't pay attention to k…
Martian
  • 227
  • 1
  • 15
1
vote
1 answer

Syscall Constant syscall.ENONET Undefined in Go

I tried to run the following bar.go script package main import ( "fmt" "syscall" ) func main() { fmt.Printf("%d\n", uintptr(syscall.ENONET)) } by calling go run bar.go and get this error: # command-line-arguments ./bar.go:9:29:…
dekauliya
  • 1,303
  • 2
  • 15
  • 26
1
vote
0 answers

Comparing Go Win32 syscall and cgo: does it have the same overhead?

In Windows, this is the most common way to call a Win32 function (resumed steps to call GetForegroundWindow function): dllUser32 := syscall.NewLazyDLL("user32.dll") GetForegroundWindow := dllUser32.NewProc("GetForegroundWindow") hwnd, _, _ :=…
rodrigocfd
  • 6,450
  • 6
  • 34
  • 68
1
vote
1 answer

Linux syscalls: PTRACE_O_TRACECLONE causes indefinite hanging

I have a binary from which I need to intercept a certain syscall--in this case unlinkat--and make it do nothing. I have the following code which works fine for a single process; however, with PTRACE_O_TRACECLONE added to the ptrace opts, after the…
stuart
  • 1,005
  • 1
  • 10
  • 18
1
vote
1 answer

How to change errno value in asm x64

I write assembly for a school project and I'm stuck on a point, i need re rewrite Read in asm, so i got it, but i need to set the errno variable, then my read can return -1 in case of an error and set value of errno to 9 for example. And i don't…
Maxime Crespo
  • 199
  • 1
  • 10
1
vote
0 answers

Unable to make successive system calls to print to STDOUT

I'm attempting to get ahead of my schooling by teaching myself assembly. I created a Hello World that prints the entire string in one go, and as far as I can tell, it works fine: global _start section .data hello db "Hello World", 0xa section…
Carcigenicate
  • 43,494
  • 9
  • 68
  • 117
1
vote
1 answer

My syscall cause segmentation fault (core dumped)

I'm writing a simple syscall based on this tutorial, and boot into the new kernel with my syscall in it, but when I compile a test, and execute it, it cause segmentation fault (core dumped). My my_syscall.h (hello.c equivalent in the tutorial) looks…
Felis
  • 11
  • 2
1 2 3
99
100