title: Executing void(char*) function as a void(void)
body: <pre><code>void print( char * str ){ printf("%s",str); }
  
  void some_function(){
      ... Loads a file into `char * buffer` ...
      ... Stores the function print before `buffer` address ...
      ((void(*)(void))buffer();
  }
  </code></pre>
  
  <p>In the file, there is a "Hello World" in it, and some unreadable characters. Executing the buffer will print "Hello World".</p>
  
  <p>I know you can execute a pointer like this:</p>
  
  <pre><code>void (*foo)(int) = &amp;bar; // such that void bar(int)
  (*foo)(123);
  </code></pre>
  
  <p>But executing void(int) function as a void(void) function with its function and parameters in memory is new to me.</p>
  
  <p>Is there a standard of how a function look like in memory (like a string is terminated by a null character) such that you can execute it in this way?</p>