Skip to content

Instantly share code, notes, and snippets.

@ErikAugust
ErikAugust / spectre.c
Last active January 5, 2025 07:01
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@lattera
lattera / Makefile
Created January 4, 2018 01:30 — forked from ErikAugust/spectre.c
Spectre example code
PROG= spectre
SRCS= spectre.c
MAN=
MK_CFI= yes
MK_PIE= yes
MK_SAFESTACK= yes
MK_LLD_IS_LD= yes

Core Coding Standard

Coding practices are a source of a lot of arguments among programmers. Coding standards, to some degree, help us to put certain questions to bed and resolve stylistic debates. No coding standard makes everyone happy. (And even their existence is sure to make some unhappy.) What follows are the standards we put together on the Core team, which have become the general coding standard for all programming teams on new code development. We’ve tried to balance the need for creating a common, recognizable and readable code base with not unduly burdening the programmer with minor code formatting concerns.

Table Of Contents

@shafik
shafik / WhatIsStrictAliasingAndWhyDoWeCare.md
Last active May 15, 2025 03:57
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

@saelo
saelo / pwn.js
Created May 6, 2018 16:12
Exploit for the "roll a d8" challenge of PlaidCTF 2018
//
// Quick and dirty exploit for the "roll a d8" challenge of PlaidCTF 2018.
// N-day exploit for https://chromium.googlesource.com/v8/v8/+/b5da57a06de8791693c248b7aafc734861a3785d
//
// Scroll down do "BEGIN EXPLOIT" to skip the utility functions.
//
// Copyright (c) 2018 Samuel Groß
//
//

h-encore

h-encore, where h ⬆️👤 for hacks ➕ homebrews, is the 🥈 public jailbreak for the PS Vita™️ which supports the newest firmwares 3️⃣.6️⃣5️⃣, 3️⃣.6️⃣7️⃣ ➕ 3️⃣.6️⃣8️⃣. It allows ➡️👤 🛠️ kernel- ➕ user-modifications, change the ⏰ 🚄, install plugins, 🏃‍♂️ homebrews ➕ much more.

Requirements

  • Your device must be on firmware 3️⃣.6️⃣5️⃣, 3️⃣.6️⃣7️⃣ or 3️⃣.6️⃣8️⃣. Any other is ❌️ supported. If you're on a lower firmware, 🙏 decide 💅 to what firmware ➡️👤 🙏 to update, then 🔍️ for a trustable guide on /r/vitahacks (if ➡️👤 💡 how ➕ 🙏 to contribute, ➡️👤 🥫 edit this readme ➕ 🛠️ a pull request, such that fellow readers have got an easier life). Remember that on firmware 3️⃣.6️⃣5️⃣ ➡️👤 have got the possibility to install enso, the permanent hack, whereas on 3️⃣.6️⃣7️⃣ ➕ 3️⃣.6️⃣8️⃣ ➡️👤 ❌️.
  • If your device is a phat OLED model, ➡️👤 need a Memory ♠️ in order to install. There's no need for a Memory ♠️ on Slim/PS 📺️ mode
@jspohr
jspohr / microsecs.c
Last active September 1, 2024 21:55
Avoid overflow when converting time to microseconds
// Taken from the Rust code base: https://github.com/rust-lang/rust/blob/3809bbf47c8557bd149b3e52ceb47434ca8378d5/src/libstd/sys_common/mod.rs#L124
// Computes (value*numer)/denom without overflow, as long as both
// (numer*denom) and the overall result fit into i64 (which is the case
// for our time conversions).
int64_t int64MulDiv(int64_t value, int64_t numer, int64_t denom) {
int64_t q = value / denom;
int64_t r = value % denom;
// Decompose value as (value/denom*denom + value%denom),
// substitute into (value*numer)/denom and simplify.
// r < denom, so (denom*numer) is the upper bound of (r*numer)
@cr1901
cr1901 / clock_domains.md
Last active July 4, 2021 07:14
Migen Clock Domain Summary

Migen Clock Domains Summary

Terminology

  • Declaring a clock domain:
    • self.clock_domains.cd_mycd = ClockDomain()
  • Referencing a clock domain:
    • self.sync.mycd += []
    • ClockSignal("mycd")
  • Requesting an I/O signal:
  • platform.request("clk12")
@yifanlu
yifanlu / start.sh
Created December 6, 2018 06:15
PlayStation Classic root shell through UART serial
#!/bin/sh
# THIS IS NOT FOR REGULAR USERS!!!
# You need to solder to the UART port and short the two pads under the PCB near the charger.
# Baud rate: 921600
red_led () {
SLEEP=1
LOOP=1
if [ x"$1" != x ]; then LOOP=$1; fi
@katahiromz
katahiromz / ghost-thread.c
Last active November 25, 2019 11:55
ghost thread
typedef struct GHOST_INFO
{
HWND hwndTarget;
HANDLE GhostStartupEvent;
HANDLE GhostQuitEvent;
DWORD cTargets;
ULONG_PTR InputThreadId;
} GHOST_INFO;
// Private message PM_CREATE_GHOST: