Skip to content

Instantly share code, notes, and snippets.

@7shi
7shi / gist:9167101
Created Feb 23, 2014
スタート低レイヤー #5の発表メモです。
View gist:9167101
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 Mar 7, 2014
[C++]スパースファイルの実験
View sparse.cpp
#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 Aug 29, 2015
NetBSD/i386 6.0.1のブートをトレース
View netbsd-boot.md
@7shi
7shi / disasm1.fsx
Created Apr 12, 2014
[F#]機械語入門で書いたコード
View disasm1.fsx
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 Aug 29, 2015
[F#]apoutのログを変換
View 7runconv.fsx
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 Aug 29, 2015
OpenRISC test
View sample.c
int global = 10;
void null()
{
return;
}
int return_zero()
{
return 0;
View gist:9a58e3796db8a7202ff6
$ 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 Aug 29, 2015
EXE入門で作ったプログラム
View makeexe.c
#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 Aug 29, 2015
[F#]逆アセンブラ(途中)
View disasm.fsx
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 Aug 29, 2015
[F#]Schedule Board (http://www.rumix.com/sb/) のファイルを変換・修復
View ConvSch.fsx
// 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
You can’t perform that action at this time.