#include
#include
int main()
{
int ret;
ret = MessageBoxA(NULL, "content", "title", MB_YESNO);
printf("ret=%d", ret);
return 0;
}
#include
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow){
MessageBox(
NULL,
TEXT ("content"),
TEXT ("title"),
MB_YESNO);
return 0;
}
WINUSERAPI int WINAPI
MessageBoxA(
HWND hWnd,
LPCSTR lpText,
LPCSTR lpCaption,
UINT uType);
MessageBoxA #Ascii版
MessageBoxW #Unicode版
#define WINAPI __stdcall
#define MB_YESNO __MSABI_LONG(0x00000004)
简写 | 全称 |
---|---|
H | Handler |
LP | Long pointer |
C | const |
T | TCHAR |
STR | string |
开发环境 masm + masm plus
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
.data
MsgBoxCaption db "title",0
MsgBoxText db "content",0
.code
start:
invoke MessageBox, NULL, addr MsgBoxText, addr MsgBoxCaption, MB_OK+MB_ICONQUESTION
invoke ExitProcess, NULL
end start
用OLLydbg调试汇编编译的程序
00401000 >/$ 6A 20 push 0x20 ; /Style = MB_OK|MB_ICONQUESTION|MB_APPLMODAL
00401002 |. 68 00304000 push 01_msgbo.00403000 ; |Title = "title"
00401007 |. 68 06304000 push 01_msgbo.00403006 ; |Text = "content"
0040100C |. 6A 00 push 0x0 ; |hOwner = NULL
0040100E |. E8 0D000000 call ; \MessageBoxA
00401013 |. 6A 00 push 0x0 ; /ExitCode = 0x0
00401015 \. E8 00000000 call ; \ExitProcess
0040101A .- FF25 00204000 jmp dword ptr ds:[<&kernel32.ExitProcess>] ; kernel32.ExitProcess
00401020 $- FF25 08204000 jmp dword ptr ds:[<&user32.MessageBoxA>] ; user32.MessageBoxA
alt+m 查看程序数据段 .data
地址:00403000
大小:00001000
内容:00403000 74 69 74 6C 65 00 63 6F 6E 74 65 6E 74 00 00 00 title.content...
在内存中查看立即数
00403000 6C746974 titl
00403004 6F630065 e.co
00403008 6E65746E nten
0040300C 00000074 t...
参数逆序存储
(push
),pop
时就是正常顺序。0x74H = 't'
,从地址方向和字符读取的方向正好对应坐标轴的第3象限
方便记忆,MsgBoxCaption 和 MsgBoxText 以0x00
隔开。ascii
值存储,(Unicode采用双字节,前128(2^7
)个的值与ASCII相等)。字符与十六进制:字符 | 十六进制 |
---|---|
0-9 |
0x30H-0x39H |
A-Z |
0x41H-5AH |
a-z |
0x61H-7AH |
a |
0x61H |
e |
0x65H |
i |
0x69H |
o |
0x6FH |
u |
0x75H |
python求字符与ASCII
>>> ord('a') #97
>>> hex(ord('a')) #'0x61'
>>> chr(97) #'a'
>>> chr(0x61) #'a'
0x30H * 2 = 0x60H
0x30H + 0x10H = 0x40H
Microsoft Windows API
https://docs.microsoft.com/en-us/windows/win32/apiindex/windows-api-list
pdf
https://github.com/sv4us/ebook/tree/master/Windows API