Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Why Do Void Function Pointers EXECUTE Arrays Of Hexcode?

$
0
0
I know how to use functions pointers in C and C++ and I know if you have something like

char buf[] = {
      0x48, 0xb8, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x48, 0xbf, 0x02, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x0f, 0x05
  };
((void (*) (void))buf)();



That this will execute those binary instructions in hexadecimal notation BUT WHY? I don't get why that works since that's an array of data not a function?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>