Category Archives: C
Example sending data to a process using signals




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:


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”


Source code:


External links:
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.



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:

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:


Posted on May 18, 2016, 5:29 pm By
No comments yet Categories: C, Linux
Get a pointer to the structure through a pointer to a member.

Posted on February 9, 2016, 3:19 pm By
No comments yet Categories: C
Define your own custom conversion specifiers for printf.

In this example we define two specifiers: %P, %W.
%P -> prints IPv4 address from struct in_addr.
%W -> prints IPv6 address from struct in6_addr.

Example code: ( The GNU C Library only. )

Next Page