当前位置: 首页 > news >正文

板凳----------(枯藤 )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 个字节的区域,没有任何空隙。

http://www.cnnetsun.cn/news/70228.html

相关文章:

  • (附带word报告)并联型有源电力滤波器APF simulink仿真 利用基于瞬时无功功率理论...
  • Zernike 多项式在圆形、六边形、椭圆形、矩形或环形瞳孔上应用(Matlab代码实现)
  • 如何通过LobeChat提升大模型token的利用率和转化率?
  • GitHub热门Fork项目:用Qwen3-VL-8B实现图片自动打标签
  • 使用Ollama运行Seed-Coder-8B-Base:轻量级代码生成解决方案
  • 企业级部署首选:Stable-Diffusion-3.5-FP8生产环境搭建指南
  • 我开源了一个Markdown转PDF工具
  • Python 基础语法(二):程序流程控制
  • YoloV8 Detect类扩展支持Qwen-Image生成掩码
  • 深度学习视频教程资源合集
  • 9 个课堂汇报 AI 工具,专科生快速生成内容推荐
  • 郭大勇:以安全固根基 共建数字金融新生态
  • CFCA张野解读《2025数字银行调查报告》
  • CFCA刘通:以多维互信的数字身份服务 赋能金融数字化转型
  • 多模态AI前沿:从Agent构建到视频AIGC
  • SQL的导入导出数据和查询
  • 滚动轴承缺陷动力学模型:从理论到实践
  • GG3M (鸽姆) Global Governance Meta-Mind Model: 商业计划书 Global Civilization Governance OS (Eastern Wisdom
  • Comsol微环谐振腔与环形波导耦和:对比波束包络与波动光学两个模块
  • 整体设计 之28 整体设计 架构表表述总表的 完整程序(之27 的Q268 )(codebuddy)
  • 云手机 实体手机的云端延伸
  • 交换机和网卡的 PFC 机制工作原理与实例解析
  • UI自动化测试常见面试题
  • Linux OOM 问题之 DMSERVER 受害者
  • Flutter引擎裁剪与鸿蒙方舟编译协同优化
  • STM32CubeMX的main.c开头介绍
  • 26.MPSOC FPGA linux读AHT20传感器
  • 嵌入式系统时序图完全指南:从原理到实战
  • 小团队与大团队的管理差异
  • [CISCN2019 华东南赛区]Web4