   Binary Code in C++
  How can I excute code contained in a char array in C++? I''ve tried the following:   char x [5] = { /* Code here in hex... */ };void main (){  void (*f)() = x;  f();}Anyway, Dev-C++ refuses to compile that with the warning:5 C:\code\bin.cpp initialization to `void (*)()'' from `char *''Does anyone know what''s wrong and how I can fix it? 
  void (*f)() = (void(*)())x; ;quote:Original post by Beer Hunter  void (*f)() = (void(*)())x;   Thankyou much!;  Windows really lets you do that? ;quote:Original post by Arild Fines  Windows really lets you do that?I''m guessing that you posted in the wrong topic? If not, I can assure you that I''ve run such code under Linux as well. ;  That is just standard anonymous function pointer casting ;  My Norton AV 2003 went crazy when i tested this It probably assumes that my code with potential for self-modification is hazardous to run... ;  Heh, then it should go crazy whenever you run an N64 emulator or things like that, since they dynamically recompile code, and run it just like that.. are you sure you didn''t put your code on the stack (local function variable)? That''s what AV programs should detect, since that''s the danger of buffer overflows (injecting code through the stack) ;I padded extra 'stack' space with NOPs, and Norton let it thru just fine.I guess that it saw the random instructions in the code, and determined that it's threatening the system.It makes perfect sense, though Yes i used stack mem, didn't feel the need to manually alloc it in my little test.EDIT: typo...   [edited by - Nik02 on August 3, 2003 6:35:30 AM];  Well heh, I just wanted to have a way to hex code since ASM is a pain in the ass in the C++ and this allows for self-modification too. A lot of interesting issues were brought up however... Now to read a little on how C++ passes parameters and I''ll be all set. Thanks everyone! 