Look at the following small program, very simple, what do you think the implementation results will be?
------------------------------------------------------------
; file name: 11. Asm
; Display a string information using the console
.386
. Model Flat,stdcall
Option Casemap:none
Include \masm7\include\windows.inc
Include \masm7\include\kernel32.inc
Include \masm7\include\masm32.inc
Includelib \masm7\lib\kernel32.lib
Includelib \masm7\lib\masm32.lib
. Code
Messadd DD 0
Mess db ' How are you! ', 0
Start
Lea Eax,mess
mov messadd,eax; write the data in the code snippet
Invoke Stdout,messadd
Invoke Exitprocess,null
End Start
-----------------------------------------------------------
Is it too simple to use the console to output a string? Yes, that's the original purpose of the program!
But the results are not imagined. Because in the execution of the program, the first reflection of our eyes is a wrong message box!
Why is that? Because Windows sets a property of the code snippet when it is linked, it is "read \ Execute \ Code", which is not allowed to write. So it's a mistake! Is there any way to solve it?
Follow these steps to make the code snippet have write properties:
D:\masm7>ml/coff 4.ASM/LINK/SUBSYSTEM:CONSOLE/SECTION:.TEXT,RW; R-Read, W-write
Microsoft (R) Macro assembler Version 6.14.8444
Copyright (C) Microsoft Corp. 1981-1997. All rights reserved.
Assembling:4.asm
Microsoft (R) incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp. 1992-1998. All rights reserved.
/subsystem:console/section:.text,rw
"4.obj"
"/out:4.exe"
D:\masm7>11
How to Are you!
D:\masm7>_