找回密码
 立即注册→加入我们

QQ登录

只需一步,快速开始

搜索
热搜: 下载 VB C 实现 编写
查看: 2542|回复: 2

vb外联asm

[复制链接]
发表于 2021-2-11 23:14:20 | 显示全部楼层 |阅读模式

欢迎访问技术宅的结界,请注册或者登录吧。

您需要 登录 才可以下载或查看,没有账号?立即注册→加入我们

×
本帖最后由 Ayala 于 2021-2-11 23:21 编辑

图像_2021-02-11_232052.png

  1. .686p
  2. .model flat,stdcall
  3. .nolist
  4. option casemap:none
  5. ;OPTION PROC:export


  6. include Strings.mac

  7. include windows.inc
  8. include user32.inc
  9. include kernel32.inc
  10. includelib user32.lib
  11. includelib kernel32.lib
  12. include msvcrt.inc
  13. includelib msvcrt.lib


  14. include ws2_32.inc
  15. includelib ws2_32.lib

  16. IDD_DLG1 EQU 1000

  17. IDC_EDT1 EQU 1001
  18. IDC_EDT2 EQU 1004
  19. IDC_EDT3 EQU 1003
  20. IDC_EDT4 EQU 1006
  21. IDC_EDT5 EQU 1008
  22. IDC_EDT6 EQU 1011
  23. IDC_EDT7 EQU 1012

  24. IDC_BTN1 EQU 1002
  25. IDC_BTN2 EQU 1009
  26. IDC_BTN3 EQU 1010



  27. .data
  28.         C2cmd   byte MAX_PATH dup(0)
  29.         asmcmd  byte MAX_PATH dup(0)
  30.         asmpath byte MAX_PATH dup(0)
  31.         incpath byte MAX_PATH dup(0)
  32.         asmfile byte MAX_PATH dup(0)
  33.         tagfile byte MAX_PATH dup(0)
  34. .code

  35. DlgBuildAsmCmd proc hDlg:HWND
  36.         invoke crt_sprintf,offset asmcmd ,$CTA0("%s %s %s %s & pause"),offset asmpath,offset incpath,offset asmfile,offset tagfile
  37.         invoke SetDlgItemText,hDlg,IDC_EDT5,offset asmcmd
  38.         ret
  39. DlgBuildAsmCmd endp

  40. DlgInit proc hDlg:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
  41.         invoke SetDlgItemText,hDlg,IDC_EDT1,offset C2cmd
  42.         invoke SetDlgItemText,hDlg,IDC_EDT3,offset asmpath
  43.         invoke SetDlgItemText,hDlg,IDC_EDT4,offset incpath
  44.         invoke SetDlgItemText,hDlg,IDC_EDT6,offset asmfile
  45.         invoke SetDlgItemText,hDlg,IDC_EDT7,offset tagfile
  46.         invoke DlgBuildAsmCmd,hDlg
  47.         ret
  48. DlgInit endp

  49. DlgCmd proc hDlg:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

  50.         mov eax, wParam
  51.         and eax,0ffffh
  52.        
  53.         .if eax == IDC_BTN1
  54.                 invoke GetDlgItemText,hDlg,IDC_EDT1,offset C2cmd,MAX_PATH
  55.                 invoke crt_system,offset C2cmd
  56.                
  57.         .elseif eax == IDC_BTN2
  58.                 invoke crt_system,offset asmcmd
  59.         .elseif eax == IDC_BTN3
  60.                 invoke DlgBuildAsmCmd,hDlg
  61.         .endif
  62.        
  63.         ret
  64. DlgCmd endp

  65. DlgProc proc hDlg:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

  66.         mov eax, uMsg

  67.         .if eax == WM_INITDIALOG
  68.                 invoke DlgInit, hDlg, uMsg, wParam, lParam
  69.                 mov eax,TRUE
  70.         .elseif eax == WM_COMMAND
  71.                 invoke DlgCmd, hDlg, uMsg, wParam, lParam
  72.         .elseif eax == WM_CLOSE
  73.                 invoke EndDialog, hDlg, 0
  74.                 mov eax,TRUE
  75.                
  76.         .else
  77.                 mov eax, FALSE
  78.                
  79.         .endif
  80.        
  81.            ret
  82. DlgProc endp


  83. _main proc

  84.         invoke GetCommandLine
  85.         invoke crt_sprintf,offset C2cmd ,$CTA0("org\\%s -Fa foo.asm"),eax
  86.         invoke crt_sprintf,offset asmpath ,$CTA0("..\\masm32\\bin\\ML.EXE /c /coff /Cp /nologo")
  87.         invoke crt_sprintf,offset incpath ,$CTA0("/I..\\masm32\\include\\ /I..\\masm32\\macros\")
  88.         invoke crt_sprintf,offset asmfile ,$CTA0(".\\Module2\\Module2.asm")
  89.         invoke crt_sprintf,offset tagfile ,$CTA0("-Fo.\\Module2.OBJ")
  90.        
  91.         invoke GetModuleHandle,NULL
  92.         invoke DialogBoxParam,eax,IDD_DLG1,NULL,DlgProc,0
  93.        
  94.         ret
  95. _main endp

  96. end _main

复制代码


  1. #define IDD_DLG1 1000
  2. #define IDC_EDT1 1001
  3. #define IDC_BTN1 1002
  4. #define IDC_EDT2 1004
  5. #define IDC_EDT3 1003
  6. #define IDC_STC1 1005
  7. #define IDC_EDT4 1006
  8. #define IDC_STC2 1007
  9. #define IDC_EDT5 1008
  10. #define IDC_BTN2 1009
  11. #define IDC_BTN3 1010
  12. #define IDC_EDT6 1011
  13. #define IDC_EDT7 1012
  14. #define IDC_STC3 1013
  15. #define IDC_STC4 1014

  16. #include "../../../masm32/include/resource.h"

  17. IDD_DLG1 DIALOGEX 10,10,513,273
  18. CAPTION "IDD_DLG"
  19. FONT 8,"MS Sans Serif",0,0,0
  20. STYLE WS_VISIBLE|WS_OVERLAPPEDWINDOW
  21. BEGIN
  22.   CONTROL "",IDC_EDT1,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP|ES_MULTILINE,3,150,372,42,WS_EX_CLIENTEDGE
  23.   CONTROL "编译源文件",IDC_BTN1,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,387,150,123,42
  24.   CONTROL "",IDC_EDT2,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,3,198,507,72,WS_EX_CLIENTEDGE
  25.   CONTROL "",IDC_EDT3,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|ES_MULTILINE,3,3,369,24,WS_EX_CLIENTEDGE
  26.   CONTROL "汇编编译器路径",IDC_STC1,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_CENTERIMAGE,384,6,114,21
  27.   CONTROL "",IDC_EDT4,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP|ES_MULTILINE,3,30,369,33,WS_EX_CLIENTEDGE
  28.   CONTROL "头文件路径",IDC_STC2,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_CENTERIMAGE,384,36,114,21
  29.   CONTROL "",IDC_EDT5,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP|ES_MULTILINE,3,111,372,36,WS_EX_CLIENTEDGE
  30.   CONTROL "编译asm",IDC_BTN2,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,387,111,123,36
  31.   CONTROL "重生成编译命令",IDC_BTN3,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,387,84,93,21
  32.   CONTROL "",IDC_EDT6,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP|ES_MULTILINE,3,66,303,21,WS_EX_CLIENTEDGE
  33.   CONTROL "",IDC_EDT7,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP|ES_MULTILINE,3,87,303,21,WS_EX_CLIENTEDGE
  34.   CONTROL "汇编源文件",IDC_STC3,"Static",WS_CHILDWINDOW|WS_VISIBLE,312,69,54,21
  35.   CONTROL "目标文件",IDC_STC4,"Static",WS_CHILDWINDOW|WS_VISIBLE,312,90,54,21
  36. END

复制代码


测试代码

  1. '主窗体
  2. Private Sub Command1_Click()
  3.     newthread "111111111111111"
  4. End Sub
  5. '模块2
  6. Public Function threadproc(ByVal p As Long)
  7.     MsgBox "threadproc"
  8. End Function

  9. Public Function newthread(s As String)
  10.     threadproc 0
  11. End Function


复制代码


  1. .686p
  2. .model flat,stdcall
  3. .nolist
  4. ;option casemap:none



  5. include Strings.mac

  6. include windows.inc
  7. include user32.inc
  8. include kernel32.inc
  9. includelib user32.lib
  10. includelib kernel32.lib
  11. includelib Vbaexe6.lib


  12. .code


  13. ?threadproc@Module2@@AAGXXZ proc syscall  s

  14.         invoke MessageBoxW,NULL,$CTW0("xxxx"),$CTW0("xxxx"),MB_OK
  15.         ret
  16. ?threadproc@Module2@@AAGXXZ endp

  17. ?newthread@Module2@@AAGXXZ proc syscall  a1,a2
  18.        
  19.         mov eax,a2
  20.         mov eax,[eax]
  21.         invoke MessageBoxW,NULL,$CTW0("1111"),eax,MB_OK
  22.        
  23.         invoke CreateThread,NULL,0,?threadproc@Module2@@AAGXXZ,0,0,0
  24.        
  25.         ret 8
  26. ?newthread@Module2@@AAGXXZ endp




  27. end
复制代码


c2.exe (6 KB, 下载次数: 1) vb目录里新建目录org,将原来c2房里,把这个换上

回复

使用道具 举报

发表于 2021-2-13 00:43:46 | 显示全部楼层
好棒(看不懂
戈登这几天才从A5那知道如何把ASM在VB内调用(long数组
回复 赞! 靠!

使用道具 举报

发表于 2021-2-21 03:11:37 | 显示全部楼层
戈登走過去 发表于 2021-2-13 00:43
好棒(看不懂
戈登这几天才从A5那知道如何把ASM在VB内调用(long数组

Long数组只是众多方法之一,这里的则是更自然的方法——使用汇编器编译.obj直接参与VB6的链接过程。

类似于直接用汇编器编写VB6的Module、Class、Form之类的东西。
回复 赞! 靠!

使用道具 举报

本版积分规则

QQ|Archiver|小黑屋|技术宅的结界 ( 滇ICP备16008837号 )|网站地图

GMT+8, 2024-11-22 05:44 , Processed in 0.033209 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表