Skip to content

Instantly share code, notes, and snippets.

@7shi
7shi / gist:9167101
Created February 23, 2014 05:00
スタート低レイヤー #5の発表メモです。
kern/vnode_if.c
===============
int
VOP_WRITE(struct vnode *vp,
struct uio *uio,
int ioflag,
kauth_cred_t cred)
{
int error;
@7shi
7shi / sparse.cpp
Created March 7, 2014 12:28
[C++]スパースファイルの実験
#include <stdio.h>
int main() {
// 10バイトのファイルを作成
char a[10] = {0};
FILE *f = fopen("test", "wb");
fwrite(a, 1, sizeof(a), f);
fclose(f);
f = fopen("test", "r+b");
@7shi
7shi / netbsd-boot.md
Last active August 29, 2015 13:57
NetBSD/i386 6.0.1のブートをトレース
@7shi
7shi / disasm1.fsx
Created April 12, 2014 08:59
[F#]機械語入門で書いたコード
let aout = System.IO.File.ReadAllBytes "../../write-3.out"
let read16 (a:byte[]) i = ((int a.[i + 1]) <<< 8) ||| (int a.[i])
let tsize = read16 aout 2
let dsize = read16 aout 4
printfn "tsize = %04x, dsize = %04x" tsize dsize
let mem = aout.[16 .. 16 + tsize + dsize - 1]
let mutable i = 0
let show len =
printf "%04x: " i
for j in 0 .. 5 do
@7shi
7shi / 7runconv.fsx
Last active August 29, 2015 14:01
[F#]apoutのログを変換
open System
let rec loop () =
let line = Console.ReadLine ()
if line <> null then
if line.Length > 60 then
let mne = line.[60..].Split(' ').[0]
printfn "%s %s:%s" line.[0..23] line.[40..43] mne
loop ()
loop ()
@7shi
7shi / sample.c
Last active August 29, 2015 14:02
OpenRISC test
int global = 10;
void null()
{
return;
}
int return_zero()
{
return 0;
@7shi
7shi / gist:9a58e3796db8a7202ff6
Last active August 29, 2015 14:02
[NetBSD]sbrk(0)
$ cat sbrk.c
#include <stdio.h>
#include <unistd.h>
int main() {
printf("%p\n", sbrk(0));
printf("%p\n", sbrk(0));
return 0;
}
----
@7shi
7shi / makeexe.c
Last active August 29, 2015 14:03
EXE入門で作ったプログラム
#include <windows.h>
#include <stdio.h>
#include <string.h>
void align(FILE *f, int size) {
int pos = ftell(f);
int aligned = (pos + size - 1) / size * size;
for (; pos < aligned; ++pos) {
fwrite("\0", 1, 1, f);
}
@7shi
7shi / disasm.fsx
Last active August 29, 2015 14:03
[F#]逆アセンブラ(途中)
let bin = System.IO.File.ReadAllBytes "../../cc"
let mutable i = 0
let show len asm =
printf "%08X " i
for j = 0 to len - 1 do
printf "%02X" bin.[i + j]
for j = len to 8 do
printf " "
printfn "%s" asm
i <- i + len
@7shi
7shi / ConvSch.fsx
Last active August 29, 2015 14:03
[F#]Schedule Board (http://www.rumix.com/sb/) のファイルを変換・修復
// This file is in the public domain.
#r "System"
#r "System.Drawing"
#r "System.Windows.Forms"
open System
open System.IO
open System.Text
open System.Drawing