news 2026/6/10 9:34:22

板凳----------(枯藤 )vs2026+win10(第五章-2)

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
板凳----------(枯藤 )vs2026+win10(第五章-2)

致谢:
VS2026配置x86/x64调用32位和64位汇编语言动态库环境 参考
https://blog.csdn.net/chenyijun/article/details/148952640

Lrvine64.obj 外部库可以在这里下载 链接: https://pan.baidu.com/s/1ljbseUDxpBcG_rrnhAiMEA 提取码: skbd;----------------------------------------;Procedure Prototypes;---------------------------------------- CloseFile PROTO;close afilehandle Clrscr PROTO;clearthescreenCreateOutputFile PROTO;createfileforwriting Crlf PROTO;output carriage-return / linefeed Delay PROTO;delayforn milliseconds DumpMem PROTO;display memory dump DumpRegs PROTO;display register dump GetCommandTail PROTO;get command-line string GetDateTime PROTO,;get systemdateandtimestartTime:PTR QWORD GetMaxXY PROTO;get console rows and columns GetMseconds PROTO;get milliseconds past midnight GetTextColor PROTO;Get the console window's color attributes. Gotoxy PROTO;setthe cursor position IsDigit PROTO;returnZF=1ifAL is a decimal digit MsgBox PROTO;display popup message box MsgBoxAsk PROTO;display popup yes/no question box OpenInputFile PROTO;openfileininput mode ParseDecimal32 PROTO;convert unsigned decimal string to32-bit binary ParseInteger32 PROTO;convert signed decimal string to32-bit binary Randomize PROTO;reseed random number generator RandomRange PROTO;generate random integerinspecified range Random32 PROTO;generate32-bit random integer ReadInt PROTO;readsigned decimal integer from console ReadChar PROTO;reach single character from console ReadDec PROTO;readunsigned decimal integer from console ReadFloat PROTO;readfloating-point value from keyboard ReadFromFile PROTO;readbuffer from inputfileReadHex PROTO;readhexadecimal integer from console ReadKey PROTO;Reads keyboard inputifavailable(4/6/03)ReadKeyFlush PROTO;Flush ReadKey buffer and repeat counter(4/6/03)ReadString PROTO;readstring from console SetTextColor PROTO;setconsole text color ShowFPUStack PROTO;writefloating-point stack to console window StrLength PROTO;returns the length of a string WaitMsg PROTO;displaywaitmessage,waitforEnter key WriteBin PROTO;writeinteger to outputinbinaryformatWriteBinB PROTO;writebinary integerinbyte, word,or doublewordformatWriteChar PROTO;writesingle character to output WriteDec PROTO;writeunsigned decimal integer to output WriteFloat PROTO;writeST(0)to consoleinfloating-pointformatWriteHex PROTO;writehexadecimal integer to output WriteHexB PROTO;writehexadecimal integerinword or doublewordformatWriteInt PROTO;writesigned integer to output;WriteStackFrame;writestack frame data(James Brink--see proto laterinthisfile);WriteStackFrameName;writestack frame data with proc name(James Brink)WriteString PROTO;writenull-terminated string to output WriteToFile PROTO;writea buffer to an outputfileWriteWindowsMsg PROTO;writelast error message generated by MS-Windows
;call32lib.asm INCLUDE Irvine32.inc .data filename BYTE"newfile.txt",0 array DWORD1,2,3,4,5,6,7,8,9,0Ah,0Bh .code main PROC;==========等待,清屏===========;call Crlf;call Clrscr;call WaitMsg;"Press any key...";===========创建新文件==========;mov edx, OFFSET filename;call CreateOutputFile;=============暂停2秒=========;mov eax,2000;2;call Delay;============产生十六进制形式显示内存一段数据===;mov esi, OFFSET array;mov ecx, LENGTHOF array;mov ebx, TYPE array;call DumpMem;=========十六进制形式显示寄存器和EFLAGS内容===;CALL DumpRegs INVOKE ExitProcess,0main ENDP END main
INCLUDE Irvine32.inc;加密密钥 KEY=5.data;待加密数组 array DWORD1,2,3,4,5,6,7,8,9,0Ah,0Bh;提示信息 msgBefore BYTE"加密前数组:",0 msgAfter BYTE"加密后数组:",0 .code main PROC;==========显示加密前数组==========mov edx, OFFSET msgBefore call WriteString call Crlf mov esi, OFFSET array;数组首地址 mov ecx, LENGTHOF array;数组长度(循环次数) call PrintArray;调用打印数组过程;==========调用加密过程==========mov esi, OFFSET array;传递数组首地址 mov ecx, LENGTHOF array;传递数组长度 call Encrypt;调用加密过程(无直接参数,通过寄存器传参);==========显示加密后数组==========mov edx, OFFSET msgAfter call WriteString call Crlf mov esi, OFFSET array mov ecx, LENGTHOF array call PrintArray;退出程序 INVOKE ExitProcess,0main ENDP;==========自定义加密过程(异或加密)==========;输入:ESI=数组首地址,ECX=数组长度;功能:对DWORD数组每个元素异或KEY加密 Encrypt PROC push esi;保护寄存器(可选) push ecx EncryptLoop: xor DWORD PTR[esi], KEY;数组元素异或密钥addesi,4;下一个DWORD元素(4字节) loop EncryptLoop pop ecx pop esi ret Encrypt ENDP;==========辅助:打印DWORD数组==========;输入:ESI=数组首地址,ECX=数组长度 PrintArray PROC push esi push ecx PrintLoop: mov eax,[esi];取当前元素 call WriteDec;打印十进制数 mov al,' ';空格分隔 call WriteCharaddesi,4;下一个元素 loop PrintLoop call Crlf;换行 pop ecx pop esi ret PrintArray ENDP END main========================加密前数组:1234567891011加密后数组:476103213121514

INCLUDE Irvine32.inc .data cmdTail BYTE129DUP(0);空缓冲区 .code main PROC mov edx, OFFSET cmdTail call GetCommandTail;填充缓冲区 INVOKE ExitProcess,0 main ENDP ———————————————— 原文链接:https://blog.csdn.net/chenyijun/article/details/148927787



核心结论
cmdTail BYTE 129 DUP(0) 的内存布局规则:
0x00406038 是 cmdTail 的起始地址;
从 0x00406038 开始,连续占用 129 个字节的内存空间(这 129 字节就是 129 DUP(0) 对应的内容);
这些字节会「紧挨着」起始地址向后排布,没有间隔。
结合你的截图验证
从内存 2 窗口能看到:
起始地址 0x00406038 开始,前几个字节存储了 file1.txt file2.txt(ASCII 码:66 69 6C 65 31 2E 74 78 74 20 66 69 6C 65 32 2E 74 78 74);
后续字节直到 0x00406038 + 128(因为从 0 开始计数,129 字节的最后一个地址是 0x00406038 + 128 = 0x004060B9),全部填充为 00(对应 DUP(0) 的初始化值)。
直观的地址范围
cmdTail 的完整内存范围:
起始地址:0x00406038
结束地址:0x00406038 + 128 = 0x004060B9
这之间的 129 个字节,就是 129 DUP(0) 对应的全部内容(即使前半部分被赋值为 file1.txt file2.txt,未赋值的部分仍保留初始值 00)。
补充说明
DUP(0) 是汇编的「重复初始化」语法:
129 DUP(0) 表示「连续分配 129 个字节,每个字节初始值为 0」;
程序运行时如果给前 N 个字节赋值(比如写入 file1.txt file2.txt),剩余的 129 - N 个字节仍保持 00,但它们依然属于 cmdTail 的内存空间,且紧挨着已赋值的部分。
简单总结:129 DUP(0) 的内容就是从 0x00406038 开始,向后连续 129 个字节的区域,没有任何空隙。

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/10 10:46:25

校园书店运营触发器适配

实验背景以校园书店运营为场景,设计数据库表结构、插入测试数据,完成 4 类触发器的设计与验证,掌握 Oracle 触发器的应用,模拟企业数据完整性保障、操作审计等场景。一、基础表与用户准备1. 基础表结构图书信息表:图书…

作者头像 李华
网站建设 2026/6/9 18:07:50

AI元人文构想:构建人本主义的司法价值叙事舞台

AI元人文构想:构建人本主义的司法价值叙事舞台摘要:司法系统的智能化浪潮在提升效率的同时,也引发了一场深刻的“叙事危机”:以精确计算为特征的技术逻辑,正悄然侵蚀以价值权衡与故事建构为核心的司法叙事逻辑。传统“…

作者头像 李华
网站建设 2026/6/9 18:49:10

从 0 到 1:Flutter 状态管理实战 —— 打造高性能待办清单应用

欢迎大家加入[开源鸿蒙跨平台开发者社区](https://openharmonycrossplatform.csdn.net),一起共建开源鸿蒙跨平台生态。在 Flutter 开发中,状态管理始终是核心且容易让开发者困惑的话题。很多初学者会陷入 “setState 够用吗?”“Provider 和 …

作者头像 李华
网站建设 2026/6/10 10:45:01

GPT-SoVITS语音克隆实战:1分钟数据训练专属TTS模型

GPT-SoVITS语音克隆实战:1分钟数据训练专属TTS模型 在智能语音助手、虚拟偶像和有声内容爆发的今天,我们越来越不满足于千篇一律的“机器音”。用户想要的是自己的声音——能为孩子朗读睡前故事的母亲的声音,能在直播中代班的主播声音&#x…

作者头像 李华
网站建设 2026/6/10 10:45:16

使用Miniconda镜像降低GPU算力资源浪费的5个技巧

使用Miniconda镜像降低GPU算力资源浪费的5个技巧 在现代AI研发环境中,一个常见的尴尬场景是:你提交了一个训练任务,满怀期待地等待模型收敛,结果几分钟后收到告警——“torch not found”或“CUDA version mismatch”。更糟的是&…

作者头像 李华