Rust: Calling Functions With Different Calling Conventions From Same File

The other day I had some fun with assembly and wanted to try to call assembly functions from Rust. Each compiler follows a certain calling convention, that specifies how parameters are passed between functions. The calling convention is part of an ABI, an application binary interface. There are two major calling conventions out there: System V ABI and “Microsoft/PE x64”. The latter has no real official name, at least I can’t find one Read more…

Include Assembler Source Files In Rust Project (and Build with Cargo)

Recently I stumbled upon a Rust project, where *.S– and *.rs-files were side by side in the same Cargo src-directory and I was like: “What the heck, I always wanted this!” This was a pure and lucky coincidence, really. If you programmed in C/++ before, you probably know this. The gcc (or to be more specific, the linker) can consume object files generated from *.c or *.S files, where the latter means files Read more…

Measuring TTFB (Time to First Byte) for HTTP Requests in Rust

The other day I created a small CLI + library written in Rust, that helps to measure the TTFB (time to first byte) for HTTP GET-Requests in Rust. I had this project on my to-do list for a few months now and finally some time for it. I got inspired by the Dev Tools in Google Chrome. You can see an example screenshot from Chrome down below: I wanted to program something similar. Read more…

How to Find Out if a Binary Runs Inside QEMU

In the previous blog post we talked about how to use QEMUs debugcon feature. To do this responsibly, we should only do this if the binary runs in fact inside QEMU. To find this out, one can use the cpuid instruction. It gives us a lot of information about our environment including information about the CPU brand name or if we run inside a hypervisor. This instruction is specific for the x86-platform. It Read more…

How to Use QEMUs “debugcon”-Feature (and Write to a File)

QEMU is a hypervisor often used for low-level OS/kernel development and testing. Especially when you write your own OS/kernel, things can get really hard and difficult to debug. Furthermore, there are not many debug capabilities in the sense, that you can’t write to files or screen in early phases of the boot process due to the lack of an initialized environment with drivers etc. For this case, QEMU has a featured called debugcon. Read more…