execute binary machine code from C

前端 未结 2 1168
借酒劲吻你
借酒劲吻你 2020-11-29 02:53

following this instructions I have managed to produce only 528 bytes in size a.out (when gcc main.c gave me 8539 bytes big file initially).

main.c was:



        
2条回答
  •  悲哀的现实
    2020-11-29 03:51

    The point is that DEP protection is enabled! you can goto Configurations -> Linker -> Advance -> DEP turn off , it's ok now .

    void main(){
    int i = 11;
    //The following is the method to generate the machine code directly!
    //mov eax, 1; ret;
    const char *code = "\xB8\x10\x00\x00\x00\xc3";
        __asm call code;  //test successful~..vs 2017
        __asm mov i ,eax;
    printf("i=%d", i);
    }
    

提交回复
热议问题