Cast a function pointer to a long

I am not sure if that is feasible, but I need to cast a function pointer to long in order to map C level code back to java code.

Answers


A pointer's value is an integer, you just need to know what exactly you are doing, and allocate enough storage to store the pointer's value. (In a 32bit OS, a pointer occupies 32bit storage, in a 64bit OS, pointer occupies 64bit storage).

A C example:

#include <stdio.h>

void fun()
{
    printf("fun\n");
    return;
}

typedef void (*fun_type)();

int main()
{
    long long int a = (long long int)fun;

    fun_type func_point = (fun_type)a;

    func_point();
    return 0;
}

Need Your Help

PHP Markdown/file editor Security

php security post cracking

so I am working on a super simple blog that uses the markdown format with rss.reader for the posts. It is extremely simple yet complicated for the people that I want to be able to make posts. So I ...

PHP5.3 hangs IIS6 on windows2003 64bit

php iis-6 64-bit windows-server-2003

I am setting up php 64bit on IIS6 (windows 2k3 ).