最初由 gzgzlxg 发布
VC实际就是垃圾代码生成器,你如果不信我的话,可以随便写几句编译,然后用ida分析,就一目了然了。4楼所说得其实就是将编译条件设置到发行,加上优化,去掉VC++的那些库,得出的结果就是1k一下,但是就是这个1k一下,还是垃圾代码,你所写的那段代码最小可以做到连PE文件头在内200个字节自己左右,但你必须会自己修改pe文件头,4楼的方法中也必须设置link的参数,其中/ALIGN:xx 必须在0x40一下(这个数是2 的倍数)。
// Release方式编译,结果是1KB的可执行程序
#pragma comment(linker,"/MERGE:.data=.text")
#pragma comment(linker,"/MERGE:.rdata=.text")
#pragma comment(linker,"/ENTRY:main")
#pragma comment(linker,"/OPT:NOWIN98")
#include <windows.h>
int main()
{
char *text="my first window";
char *caption="good";
MessageBox(0,text,caption,0);
return 0;
}
0040101E >/$ 6A 00 push 0 ; /Style = MB_OK|MB_APPLMODAL
00401020 |. 68 18104000 push 00401018 ; |Title = "good"
00401025 |. 68 08104000 push 00401008 ; |Text = "my first window"
0040102A |. 6A 00 push 0 ; |hOwner = NULL
0040102C |. FF15 00104000 call [<&USER32.MessageBoxA>] ; \MessageBoxA
00401032 |. 33C0 xor eax,eax
00401034 \. C3 retn
00000000h: 4D 5A 90 00 03 00 00 00 04 00 00 00 FF FF 00 00
00000010h: B8 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00
00000020h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000030h: 00 00 00 00 00 00 00 00 00 00 00 00 C8 00 00 00
00000040h: 0E 1F BA 0E 00 B4 09 CD 21 B8 01 4C CD 21 54 68
00000050h: 69 73 20 70 72 6F 67 72 61 6D 20 63 61 6E 6E 6F
00000060h: 74 20 62 65 20 72 75 6E 20 69 6E 20 44 4F 53 20
00000070h: 6D 6F 64 65 2E 0D 0D 0A 24 00 00 00 00 00 00 00
00000080h: 9D 14 24 DA D9 75 4A 89 D9 75 4A 89 D9 75 4A 89
00000090h: D9 75 4B 89 D8 75 4A 89 BB 6A 59 89 DA 75 4A 89
000000a0h: 8D 56 7A 89 D8 75 4A 89 52 69 63 68 D9 75 4A 89
000000b0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000000c0h: 00 00 00 00 00 00 00 00 50 45 00 00 4C 01 01 00
000000d0h: 3C E3 7A 44 00 00 00 00 00 00 00 00 E0 00 0F 01
000000e0h: 0B 01 06 00 00 02 00 00 00 00 00 00 00 00 00 00
000000f0h: 1E 10 00 00 00 10 00 00 00 20 00 00 00 00 40 00
00000100h: 00 10 00 00 00 02 00 00 04 00 00 00 00 00 00 00
00000110h: 04 00 00 00 00 00 00 00 00 20 00 00 00 02 00 00
00000120h: 00 00 00 00 03 00 00 00 00 00 10 00 00 10 00 00
00000130h: 00 00 10 00 00 10 00 00 00 00 00 00 10 00 00 00
00000140h: 00 00 00 00 00 00 00 00 38 10 00 00 28 00 00 00
00000150h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000160h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000170h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000180h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000190h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000001a0h: 00 10 00 00 08 00 00 00 00 00 00 00 00 00 00 00
000001b0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000001c0h: 2E 74 65 78 74 00 00 00 82 00 00 00 00 10 00 00
000001d0h: 00 02 00 00 00 02 00 00 00 00 00 00 00 00 00 00
000001e0h: 00 00 00 00 20 00 00 60 00 00 00 00 00 00 00 00
000001f0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000200h: 68 10 00 00 00 00 00 00 6D 79 20 66 69 72 73 74
00000210h: 20 77 69 6E 64 6F 77 00 67 6F 6F 64 00 00 6A 00
00000220h: 68 18 10 40 00 68 08 10 40 00 6A 00 FF 15 00 10
00000230h: 40 00 33 C0 C3 CC CC CC 60 10 00 00 00 00 00 00
00000240h: 00 00 00 00 76 10 00 00 00 10 00 00 00 00 00 00
00000250h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000260h: 68 10 00 00 00 00 00 00 BE 01 4D 65 73 73 61 67
00000270h: 65 42 6F 78 41 00 55 53 45 52 33 32 2E 64 6C 6C
00000280h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000290h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000002a0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000002b0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000002c0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000002d0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000002e0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000002f0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000300h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000310h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000320h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000330h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000340h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000350h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000360h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000370h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000380h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000390h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000003a0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000003b0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000003c0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000003d0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000003e0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000003f0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
哪里有垃圾代码?不要告诉我对齐'00'数据也叫垃圾
代码.
BCB那才是"垃圾代码生成器".