ãã£ã±ããã¼ããã¹ã¿ãã¯ã§ãå®è¡ã§ãã¡ããã®ãã
#include <stdio.h> #include <stdlib.h> #include <memory.h> typedef void (*function)(char*, void*); static void func(char* var, void* address) { printf("%10s = 0x%08x\n", var, address); } int main(int argc, char** argv) { void* fheap = malloc(1000); char fstack[1000]; if (!fheap) { return 1; } memcpy(fheap, func, 1000); memcpy(fstack, func, 1000); ((function)fheap)("fheap", fheap); ((function)fstack)("fstack", fstack); func("func", func); }
% cygcheck -cd cygwin Cygwin Package Information Package Version cygwin 1.7.0-64 % gcc a.c % ./a.exe fheap = 0x00d001d8 fstack = 0x0022c948 func = 0x00401130 %