Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am laomaiweng on github.
  • I am laomaiweng (https://keybase.io/laomaiweng) on keybase.
  • I have a public key ASCBI2jf8CtFXEcluDmHvuG1Xyu3ZYqsfwpIWRI-gmwXogo

To claim this, I am signing this object:

@laomaiweng
laomaiweng / idatag-fix-not-in-func-crash.patch
Created July 6, 2019 21:56
[IDATag] Fix crash with context menu on offsets not in a func
diff --git a/src/hooks_disas.cpp b/src/hooks_disas.cpp
index 38ad8d0..57b3470 100644
--- a/src/hooks_disas.cpp
+++ b/src/hooks_disas.cpp
@@ -108,11 +108,12 @@ action_state_t idaapi show_context_menu_disas_ah_t::update(action_update_ctx_t *
int idaapi show_context_menu_disas_func_ah_t::activate(action_activation_ctx_t *ctx)
{
Idatag_context_disas_func* context_menu = new Idatag_context_disas_func(ctx);
- if (myModel->is_in_func(ctx->cur_ea))
+ if (myModel->is_in_func(ctx->cur_ea) != BADADDR)
#!/bin/bash
die() {
echo "error: $*"
exit 1
} >&2
if [[ $# != 1 || "$1" =~ ^(-h|--help)$ ]]; then
echo "usage: ${0##*/} <recipient>"
exit 1
@laomaiweng
laomaiweng / x86emu.py
Last active July 20, 2023 08:51
basic x86-64 emulator using unicorn
#!/usr/bin/env python3
from dataclasses import dataclass
import os
import re
import sys
from intervaltree import Interval, IntervalTree
from pygments import highlight
from pygments.formatters import TerminalFormatter
import enum
from construct import this, Bytes, Check, Computed, Enum, Flag, GreedyRange, Hex, If, Int16ul, Int32sl, Int32ul, Int64sl, Int8ul, Optional, PaddedString, Struct
class CommandId(enum.IntEnum):
UpdateTabNavigation = 1
RestoredEntry = 2
WindowDeprecated = 3
SelectedNavigationInTab = 4
PinnedState = 5
@laomaiweng
laomaiweng / fakehome.c
Last active January 11, 2024 14:40
fake getpwuid home dir with LD_PRELOAD
/*
* Force the home directory for polluters that bypass $HOME with `getpwuid`.
* To use, set your desired $HOME and LD_PRELOAD this library.
*
* Compile with:
*
* gcc -O2 -Wall -Wextra -shared -fPIC -ldl -o libfakehome.so fakehome.c
*
*/