Write the data to the code snippet

Source: Internet
Author: User

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>_

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.