Skip to content

Instantly share code, notes, and snippets.

View davidxifeng's full-sized avatar
🥛
Go/Linux/Vim/React/Flutter/Astro/Kubernetes

David Nishikaze davidxifeng

🥛
Go/Linux/Vim/React/Flutter/Astro/Kubernetes
View GitHub Profile
@davidxifeng
davidxifeng / tips.md
Last active August 29, 2015 14:15
questions

系统开发

  1. 什么是自旋锁 spin lock? 什么是互斥锁? 各有什么特点,应用在何种场景?
  2. compare and swap (cas)是什么? 原子操作, 编译器(gcc) 固有指令
  3. 读写锁 (锁定读, 锁定写, 未加锁 3种状态) 共享-独占锁

图形学

  1. 仿射变换 齐次坐标空间
  2. 贝塞儿曲线 二次/三次 特点 应用 true type, 矢量图, 曲面

Lua

@davidxifeng
davidxifeng / print_table.lua
Created March 19, 2015 11:11
Lua's print table by cloudwu
local print = print
local tconcat = table.concat
local tinsert = table.insert
local srep = string.rep
local type = type
local pairs = pairs
local tostring = tostring
local next = next

Exploiting Lua 5.1 on 32-bit Windows

The following Lua program generates a Lua bytecode program called ignore-unsigned-sga.fnt, which in turn loads a DLL from within an extremely locked down Lua 5.1 sandbox in a program called RelicCOH2.exe. The remainder of this document attempts to explain how this program works by a whirlwind tour of relevent bits of the Lua 5.1 virtual machine.

if string.dump(function()end):sub(1, 12) ~= "\27Lua\81\0\1\4\4\4\8\0" then
  error("This generator requires a 32-bit version of Lua 5.1")
end

local function outer()
  local magic -- In bytecode, the stack slot corresponding to this local is changed

Keybase proof

I hereby claim:

  • I am davidfeng on github.
  • I am davidfeng (https://keybase.io/davidfeng) on keybase.
  • I have a public key ASAVA-RbCz8YZU5tKQt1QuSu7y6cULUvX-fSutmFkKeI7Qo

To claim this, I am signing this object: