Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <Windows.h>
static char error_message[1024];
static char *StrGetLastError(DWORD error_code)
{
LPSTR messageBuffer = NULL;
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
#define _GNU_SOURCE // needed for MAP_ANONYMOUS
#include <stdio.h>
#include <sys/mman.h>
int main(void)
{
void *ptr = mmap(NULL, 24, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (ptr == MAP_FAILED) {
perror("mmap");
return 1;
#include <winternl.h>
#include <Windows.h> // includes GetStdHandle()
#include <string.h>
// #include <stdio.h>
typedef VOID (NTAPI *PIO_APC_ROUTINE)(PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG Reserved);
typedef NTSTATUS (NTAPI *NtWriteFile_t)(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine,
PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length,
PLARGE_INTEGER ByteOffset, PULONG Key);
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
#include <sys/syscall.h> // includes SYS_write
#include <unistd.h> // includes STDOUT_FILENO
#include <string.h>
// #include <stdio.h>
#if defined(__APPLE__)
#ifndef _SYS_SYSCALL_H_
#define SYS_write 4
#endif
#elif defined(__linux__)
#include <stdio.h>
__asm__(".globl func\n\t" // optional, makes the function visible outside of main_aarch64.c
"func:\n\t" // for macOS (Mach-O), change func to _func
"mov w0, #7\n\t"
"ret"
);
// the definition of func is written in assembly language above
extern int func(void);
#include <stdio.h>
__asm__(".globl func\n\t" // optional, makes the function visible outside of main_x86_64.c
"func:\n\t" // for macOS (Mach-O), change func to _func
"movl $7,%eax\n\t"
"ret"
);
// the definition of func is written in assembly language above
extern int func(void);
FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install -y build-essential
CMD ["/bin/bash"]

Keybase proof

I hereby claim:

  • I am chrislattman on github.
  • I am chrislattman (https://keybase.io/chrislattman) on keybase.
  • I have a public key whose fingerprint is A346 AA69 DECA 1F33 CFF1 A3B2 28D8 856F 4B2D C146

To claim this, I am signing this object: