Skip to content

Instantly share code, notes, and snippets.

View isnullxbh's full-sized avatar
:octocat:

Oleg E. Vorobiov isnullxbh

:octocat:
View GitHub Profile
@isnullxbh
isnullxbh / main.cpp
Created March 28, 2022 17:34
Retrieve metadata for malloc
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <iostream>
struct Metadata
{
std::uint64_t data {};
auto size() const noexcept -> std::uint64_t { return (data & 0xFFFFFFFFFFFFFFF8) - sizeof(data); }
#define HM_CONCAT_(ARG0, ARG1) ARG0 ## ARG1
#define HM_CONCAT(ARG0, ARG1) HM_CONCAT_(ARG0, ARG1)
#define HM_STRINGIFY_(ARG) #ARG
#define HM_STRINGIFY(ARG) HM_STRINGIFY_(ARG)
#define HM_SEPARATE_WITH_SPACE(ARG0, ARG1) ARG0 ARG1
#define HM_COMPILER_SPECIFIC_PRAGMA_(ARG) _Pragma(HM_STRINGIFY(HM_SEPARATE_WITH_SPACE(HERMES_COMPILER, ARG)))
#define HM_COMPILER_SPECIFIC_PRAGMA(ARG) HM_COMPILER_SPECIFIC_PRAGMA_(ARG)
#define HM_DISABLE_WARNINGS_PUSH \
@isnullxbh
isnullxbh / kern_fstream.cxx
Created August 7, 2018 06:30
Write into file from kernel-space
#include <sys/time.h>
#include <sys/vnode.h>
#include <sys/fcntl.h>
...
static int idx = 0;
char file_name_buf[100];