Skip to content

Instantly share code, notes, and snippets.

View rbran's full-sized avatar
🦜

Rubens Brandão rbran

🦜
View GitHub Profile
@rbran
rbran / 6502.txt
Last active August 20, 2024 10:59
List of 6502 instructions generated using ghidra sleigh with sleigh-rs
NOTE: bits are from least to most significant, 'X' means the value could not be defined as a single bit.
name DEC:
bits 01100011
bits 01110011
bits 01101011
bits 01111011
name INC:
bits 01100111
bits 01110111
bits 01101111
pub struct Architecture {
pub name: String,
}
#[derive(Clone, Copy)]
pub struct RegisterInfo;
#[derive(Clone, Copy, Hash, PartialEq, Eq)]
pub struct Register;
#[derive(Clone, Copy)]
pub struct RegisterStackInfo;
// This code demonstrate how to break a simple disassembler.
// you may need to build with "-no-pie"
// gcc -o get_key get_key.c -no-pie
#include <stdio.h>
const char reveal_key[] = "The key is '%x'\n";
int get_key(int argc) {
int key = 0;
__asm__(
@rbran
rbran / cases.md
Created June 13, 2023 14:16
x86-64 icicle pattern matchers ordering

table instruction

id location context pattern
355 ia.sinc:1558:1 ________________________________!_______________________!!_____! !!!!!!!!________________________________________________________
356 ia.sinc:1559:1 ________________________________!_________________________!!___! !!!!!!!!________________________________________________________
370 ia.sinc:1634:1 ________________________________!__________!!____!!!___________! !!!!!!!!______!!!!______________________________________________
371 ia.sinc:1636:1 ________________________________!__________!!____!!!___________! !!!!!!!!______!!!!______________________________________________
372 ia.sinc:1638:1 ________________________________!__________!!____!!!___________! !!!!!!!!______!!!!______________________________________________
373 ia.sinc:1640:1 ________________________________!__________!!____!!!___________! `!!!!!!!!______!!!!
@rbran
rbran / generic_borrow_forced.rs
Created May 14, 2023 11:46
Avoid using a blanket implementations by forcing the user to provide a reference in the first place.
use std::borrow::Cow;
/// A trait for things that can speak.
trait Speaker {
fn speak(&self);
}
/// BasicSpeaker is an empty struct that exists only to implement Speaker.
#[derive(Clone)]
struct BasicSpeaker;
@rbran
rbran / generic_borrow.rs
Created May 14, 2023 11:38
Avoid using a blanket implementations by using Borrow instead.
use std::borrow::{Borrow, Cow};
/// A trait for things that can speak.
trait Speaker {
fn speak(&self);
}
/// BasicSpeaker is an empty struct that exists only to implement Speaker.
#[derive(Clone)]
struct BasicSpeaker;
@rbran
rbran / deku_reader.rs
Created January 26, 2023 16:11
Deku read from std::io::Read proposal
use deku::prelude::*;
#[derive(Debug, PartialEq, DekuRead)]
struct DekuStruct {
field_a: u8,
field_b: u16,
field_c: DekuEnum,
}
#[derive(Debug, PartialEq, DekuRead)]
#[deku(type = "u8")]
@rbran
rbran / downcast-rc.rs
Last active July 5, 2022 13:02
if you already have an Rc, downcast is cheap on Rust
use std::any::Any;
use std::collections::HashMap;
use std::rc::Rc;
struct Foo {
id: u8,
name: String,
value: u128,
}
@rbran
rbran / gist:88b8a19050a92d161ea52b78f28fb5f9
Created December 16, 2021 11:37
lapce Arch Linux PKGBUILD
# Maintainer: George Rawlinson <[email protected]>
# Modified: Rubens Brandao <[email protected]>
pkgname=lapce
pkgver=0.0.4
pkgrel=1
pkgdesc="Lightning-fast and Powerful Code Editor"
arch=('x86_64')
url="https://github.com/lapce/lapce"
license=('Apache')
depends=('gcc-libs' 'libxcb' 'expat' 'freetype2' 'libxkbcommon')
@rbran
rbran / create-my-signed-boot-cert.sh
Created December 6, 2021 17:54
My UEFI signed Kernel stub
#!/bin/bash
# Copyright (c) 2015 by Roderick W. Smith
# Licensed under the terms of the GPL v3
NAME=$(cat /etc/hostname)
if [ -z "$NAME" ]; then
echo -n "Enter a Common Name to embed in the keys: "
read NAME