Showing all posts by Void
Example sending data to a process using signals

receive.c:

send.c:

Testing:

Note: You cannot use .sival_ptr between different processes, only sival_int is OK.

Create and read custom section in Linux ELF header

Let’s create test C file:

Create custom section data:

Compile test binary:

Create read_section.c with content:

Compile read_section:

Result:

Let’s test it with objdump:

Control LEDs with shift register on Arduino (ATmega168/328)

AVR code for controlling LEDs with button by external interrupt and shift register “74HC595”

Scheme:

Source code:

Result:

External links:
EXTERNAL INTERRUPTS ON THE ATmega168/328
The 74HC595 8 bit shift register
Arduino Pin Mapping

Posted on January 14, 2017, 8:26 pm By
No comments yet Categories: C
Example of using readv(2) and writev(2) in C.

In this example, we will create a file and fill it with data using writev. Next we read the file using readv.

Create file:

Read data from file:

Posted on December 2, 2016, 7:54 am By
No comments yet Categories: C
Replace the system call in Linux using the kernel module.

This example is not necessary to check anywhere else, it is not safe for the operating system and user data!

In this example we will replace the system call “write”. This kernel module replaces the data that is displayed to stdout on the word “moo” for a specific user.

cowsay.c:

Makefile:

Let us compile module and check how it works.

An example of using OpenSSL GOST engine in C,C++

In this example we will extract the public key data from X509 GOST R 34.10-2001 certificate.

compile and execute:

vsftpd move files after upload to specified directory

how-to:

After successful file upload it will be moved to the “Incoming” directory.
Directory must be exists and have proper permissions.
Also “Incoming” directory must be in the same filesystem as uploaded file.

How to restore MAC address in Linux with C.

In this example you can learn how to get default interface’s mac address even if it was changed in operating system. Example written in C 89.
Program uses ethtool’s kernel ioctl. “ethtool -P interface_name” does the same work.

Get network interfaces list in Linux with libnl3

This example shows how to get network interfaces list with IP and MAC addresses.

Output example:

Source code:

compile:

Posted on May 18, 2016, 5:29 pm By
No comments yet Categories: C, Linux
Hello world in nasm (assembler x86_64)

code:

run:

Next Page