タグ

ブックマーク / hogelog.hatenablog.com (1)

  • C言語でクロージャ - hogelogの日記

    わりとありがちなネタで。まったく関係ない講義受けてるときにふと思いついた。 #include <stdio.h> #include <string.h> char COUNTER_CODE[] = { 0x55,0x89,0xe5,0xff, 0x05,0x00,0x00,0x00, 0x00,0xa1,0x00,0x00, 0x00,0x00,0xc9,0xc3 }; /* int falsecounter(){ return ++*((int *)0x00); } */ int (*makecounter())(){ char *counter = (char *)malloc(16); unsigned int count = (unsigned int)calloc(1, 4); memcpy(counter, COUNTER_CODE, 16); memcpy(counter+5

    C言語でクロージャ - hogelogの日記
    rydot
    rydot 2012/11/03
  • 1