天天看點

最簡單的Windows程式

準備研究一下vmp 保護,從一個最簡單的Windows程式入手似乎是個不錯的想法。

怎樣才最簡單呢,隻有一個MessageBox 調用好了。

彈出消息,退出,哦也,夠簡單吧。

祭出法器VC2010,建立win32 項目,

#include "stdafx.h"

int APIENTRY _tWinMain(HINSTANCE hInstance,

                     HINSTANCE hPrevInstance,

                     LPTSTR    lpCmdLine,

                     int       nCmdShow)

{

 MessageBox(NULL, L"Smallest", L"smallest", MB_OK);

 return 0;

}

Release 模式編譯生成,OD調試跟蹤之。

矮油,太臃腫了!

尋回失落的法器masm32,哇哦,都v11了!

找個simple example,瘦身,再瘦...

; ?

      .486                      ; create 32 bit code

      .model flat, stdcall      ; 32 bit memory model

      option casemap :none      ; case sensitive

      include \masm32\include\windows.inc

      include \masm32\include\kernel32.inc

      include \masm32\include\user32.inc

      includelib \masm32\lib\kernel32.lib

      includelib \masm32\lib\user32.lib

    .const

szTitle     db ‘Smallest‘, 0

szMessage   db ‘smallest‘, 0

    .code

start:

      invoke MessageBox, NULL, addr szMessage, addr szTitle, MB_OK

      invoke ExitProcess,eax

end start

好了,build all,恩,這才是最簡單的Windows 程式吧,:-)

繼續閱讀