Skip to content

Instantly share code, notes, and snippets.

View martinomburajr's full-sized avatar
🦆
Relentlessly pursuing those carbs

Martin Ombura Jr. martinomburajr

🦆
Relentlessly pursuing those carbs
View GitHub Profile
@martinomburajr
martinomburajr / disassembled_bin_main.asm
Created February 16, 2022 06:00
The Rust Runtime - Medium Article's Code Snippets
00000001000010f0 _main:
1000010f0: 55 pushq %rbp
1000010f1: 48 89 e5 movq %rsp, %rbp
1000010f4: 48 89 f2 movq %rsi, %rdx
1000010f7: 48 63 f7 movslq %edi, %rsi
1000010fa: 48 8d 3d 8f ff ff ff leaq -113(%rip), %rdi
100001101: e8 4a 05 00 00 callq 1354 <__ZN3std2rt10lang_start17h25bc31422b914902E>
100001106: 5d popq %rbp
100001107: c3 retq
100001108: 90 nop
@martinomburajr
martinomburajr / send-sendto-sendmsg.c
Created May 31, 2019 05:15
Sending a buffer over network unix
#include <sys/types.h>
#include <sys/socket.h>
ssize_t send(int sockfd, const void *buf, size_t len, int flags);
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
const struct sockaddr *dest_addr, socklen_t addrlen);
ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags);
@martinomburajr
martinomburajr / write-send-socket.c
Last active May 31, 2019 05:14
Writing to a Connection in UNIX
#include <unistd.h>
ssize_t write(int fd, const void *buf, size_t count);
@martinomburajr
martinomburajr / net-packetconnn.go
Created May 31, 2019 04:20
net.PacketConn in go
//net/net.go l300
type PacketConn interface {
ReadFrom(p []byte) (n int, addr Addr, err error)
WriteTo(p []byte, addr Addr) (n int, err error)
Close() error
LocalAddr() Addr
SetDeadline(t time.Time) error
SetReadDeadline(t time.Time) error
@martinomburajr
martinomburajr / net-packetconnn.go
Created May 31, 2019 04:20
net.PacketConn in go
//net/net.go l300
type PacketConn interface {
ReadFrom(p []byte) (n int, addr Addr, err error)
WriteTo(p []byte, addr Addr) (n int, err error)
Close() error
LocalAddr() Addr
SetDeadline(t time.Time) error
SetReadDeadline(t time.Time) error
@martinomburajr
martinomburajr / net-packetconnn.go
Created May 31, 2019 04:20
net.PacketConn in go
//net/net.go l300
type PacketConn interface {
ReadFrom(p []byte) (n int, addr Addr, err error)
WriteTo(p []byte, addr Addr) (n int, err error)
Close() error
LocalAddr() Addr
SetDeadline(t time.Time) error
SetReadDeadline(t time.Time) error
// A RawConn is a raw network connection. syscall/net.go
type RawConn interface {
Control(f func(fd uintptr)) error
Read(f func(fd uintptr) (done bool)) error
Write(f func(fd uintptr) (done bool)) error
}
@martinomburajr
martinomburajr / syscall-conn.go
Created May 29, 2019 04:44
syscall.conn interface
// Conn is implemented by some types in the net and os packages to provide
// access to the underlying file descriptor or handle.
type Conn interface {
// SyscallConn returns a raw network connection.
SyscallConn() (RawConn, error)
}
@martinomburajr
martinomburajr / net-conn-struct.go
Last active May 29, 2019 04:22
net.conn struct
// net.conn struct file: net/net.go l:164
type conn struct {
fd *netFD
}
func (c *conn) ok() bool { return c != nil && c.fd != nil }
// Implementation of the Conn interface.
// Read implements the Conn Read method.
func (c *conn) Read(b []byte) (int, error) {}
// Write implements the Conn Write method.
@martinomburajr
martinomburajr / open-create-openat-read-write-seek-syscalls.c
Created May 23, 2019 05:01
Open - Create - OpenAt - Read- Write - Seek Unix Syscalls
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);
int creat(const char *pathname, mode_t mode);
int openat(int dirfd, const char *pathname, int flags);