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

QQ登录

只需一步,快速开始

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

od(ollydbg) v2.01 (27-Sep-2013) cmdbar(Cmdline) 汇编源码(source)

[复制链接]

30

主题

211

回帖

2788

积分

用户组: 版主

UID
1821
精华
7
威望
69 点
宅币
2168 个
贡献
206 次
宅之契约
0 份
在线时间
481 小时
注册时间
2016-7-12
发表于 2017-1-27 17:27:38 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 Ayala 于 2017-1-27 17:29 编辑

为了支持od改名使用了动态获取函数名的方式
窗体绘制部分

  1. .386
  2. .model flat,stdcall
  3. option casemap:none

  4. include windows.inc

  5. include gdi32.inc
  6. includelib gdi32.lib

  7. include user32.inc
  8. includelib user32.lib

  9. include kernel32.inc
  10. includelib kernel32.lib

  11. include msvcrt.inc
  12. includelib msvcrt.lib

  13. include macro\strings.mac

  14. include CmdBar.inc
  15. include _A0_.ASM
  16. include _S0_.ASM



  17. comment #


  18. ;#

  19. bClassName                 EQU        $CTW0("CmdBarWndClass")       
  20. bWndName                EQU        $CTW0("CmdBarWindow")
  21. bPluginname                EQU $CTW0("CmdBar")
  22. bPluginversion        EQU $CTW0("1.00.02")


  23. ;--------------------------------------------------------------------------------
  24. ;       
  25. ;--------------------------------------------------------------------------------
  26. .code
  27. ;typedef int  MENUFUNC(struct t_table *,wchar_t *,ulong,int);

  28. SubmenuFunc proc c pt,_name,index,mode
  29.         mov eax,mode
  30.        
  31.         .if eax==MENU_VERIFY
  32.                 mov eax,MENU_NORMAL
  33.         .elseif eax==MENU_EXECUTE
  34.                 invoke Resumeallthreads
  35.                 mov edx,hwollymain
  36.                 invoke MessageBoxW,[edx],$CTW0("so boring"),$CTW0("about:"),MB_OK
  37.                 invoke Suspendallthreads
  38.                 mov eax,MENU_REDRAW
  39.         .else
  40.                 mov eax,MENU_REDRAW
  41.         .endif
  42.         ret
  43. SubmenuFunc endp

  44. WndProc proc hWnd,Msg,wParam,lParam
  45.         .if Msg==5
  46.                 invoke SendMessageW,ghWnd,5,wParam,lParam
  47.         .endif
  48.         invoke CallWindowProcW,gPrevWndProc,hWnd,Msg,wParam,lParam
  49.        
  50.         ret
  51. WndProc endp

  52. ComboBoxProc proc hWnd,Msg,wParam,lParam
  53.         LOCAL info[MAX_PATH]:WORD
  54.         LOCAL show[MAX_PATH]:WORD
  55.         mov eax,Msg
  56.         .if eax==100h        ;WM_KEYDOWN
  57.                 mov eax,wParam
  58.                 .if eax==13        ;key_enter
  59.                         invoke GetWindowTextLengthW,ghComboBox
  60.                         .if eax>0       
  61.                                 invoke GetWindowTextW,ghComboBox,addr info,MAX_PATH-1
  62.                                
  63.                                 invoke Execute,addr info,addr show
  64.                                 .if !eax
  65.                                         invoke addline,addr info       
  66.                                 .endif
  67.                                 invoke SetWindowTextW,ghEdit,addr show
  68.                                 invoke SetFocus,ghComboBox
  69.                         .endif
  70.                         xor eax,eax
  71.                 .elseif eax==17        ;VK_CONTROL
  72.                         xor eax,eax
  73.                 .elseif eax==27        ;VK_ESCAPE
  74.                         invoke SetWindowTextW,ghComboBox,offset gString
  75.                         invoke SetWindowTextW,ghEdit,offset gString
  76.                         xor eax,eax
  77.                 .else
  78.                         invoke CallWindowProcW,gPrevCBProc, hWnd, Msg, wParam, lParam
  79.                 .endif
  80.         .elseif eax==101h ;WM_KEYUP
  81.                 .if (wParam !=13 && wParam != 17 && wParam != 27)
  82.                         invoke GetWindowTextW,ghComboBox,addr info,MAX_PATH-1
  83.                         invoke showinfo,addr info
  84.                 .endif
  85.                 invoke CallWindowProcW,gPrevCBProc, hWnd, Msg, wParam, lParam
  86.         .elseif eax==102h && (wParam ==13 || wParam==27)        ;WM_CHAR VK_ESCAPE
  87.                 xor eax,eax
  88.         .else
  89.                 invoke CallWindowProcW,gPrevCBProc, hWnd, Msg, wParam, lParam       
  90.         .endif
  91.        
  92.         ret
  93. ComboBoxProc endp

  94. bWndMov proc uses ebx
  95.         LOCAL lpRect:RECT
  96.         lea ebx,lpRect
  97.         assume ebx:ptr RECT
  98.        
  99.         mov edx,hwollymain
  100.         invoke GetClientRect,[edx],ebx
  101.        
  102.         mov eax,[ebx].right
  103.         sub eax,[ebx].left
  104.         mov ecx,[ebx].bottom
  105.         sub ecx,45
  106.        
  107.         invoke MoveWindow,ghWnd,0,ecx,eax,25,TRUE
  108.         invoke ShowWindow,ghWnd,5
  109.        
  110.         assume ebx:nothing
  111.         ret
  112. bWndMov endp
  113. bWndMovi proc uses ebx
  114.         LOCAL lpRect:RECT
  115.         lea ebx,lpRect
  116.         assume ebx:ptr RECT
  117.         mov edx,hwollymain
  118.         invoke GetClientRect,[edx],ebx
  119.        
  120.         mov eax,[ebx].right
  121.         sub eax,450
  122.        
  123.         invoke MoveWindow,ghEdit,440,3,eax,19,TRUE
  124.         invoke ShowWindow,ghEdit,5
  125.        
  126.         assume ebx:nothing
  127.         ret
  128. bWndMovi endp
  129. bWndMovc proc uses ebx esi

  130.         LOCAL lpPoint:POINT
  131.         LOCAL lpRect1:RECT
  132.         LOCAL lpRect2:RECT
  133.         LOCAL lpRect:RECT
  134.         mov edx,hwollymain
  135.         invoke GetWindowRect,[edx],addr lpRect1
  136.         mov edx,hwclient
  137.         invoke GetClientRect,[edx],addr lpRect2
  138.        
  139.         mov eax,[lpRect1].left
  140.         mov [lpPoint].x,eax
  141.        
  142.         mov eax,[lpRect1].top
  143.         mov [lpPoint].y,eax
  144.        
  145.         mov edx,hwollymain
  146.         invoke ScreenToClient,[edx],addr lpPoint
  147.        
  148.         mov edx,[lpRect2].top
  149.         cmp edx,[lpPoint].y
  150.         setnz al
  151.         movzx esi,al
  152.        
  153.         lea ebx,lpRect
  154.         assume ebx:ptr RECT
  155.         mov edx,hwollymain
  156.         invoke GetClientRect,[edx],ebx
  157.        
  158.         neg esi
  159.         sbb esi,esi
  160.         and esi,17h
  161.        
  162.         mov eax,[ebx].bottom
  163.         sub eax,esi
  164.         sub eax,[ebx].top
  165.         sub eax,45
  166.        
  167.         mov ecx,[ebx].right
  168.         sub ecx,[ebx].left
  169.        
  170.         mov edx,hwclient
  171.         invoke MoveWindow,[edx],0,esi,ecx,eax,TRUE

  172.         assume ebx:nothing
  173.         ret
  174. bWndMovc endp
  175. bWndPaint proc uses esi edi ebx hwnd
  176.         LOCAL Paint:PAINTSTRUCT
  177.         LOCAL Rect:RECT
  178.         invoke bWndMov
  179.         invoke bWndMovi
  180.         invoke bWndMovc
  181.         invoke BeginPaint,hwnd,addr Paint
  182.         mov esi,eax
  183.         invoke GetClientRect,hwnd,addr Rect
  184.         invoke GetSysColor,15
  185.         invoke CreateSolidBrush,eax
  186.         mov edi,eax
  187.         invoke FillRect,esi,addr Rect,edi
  188.         invoke DeleteObject,edi
  189.         invoke EndPaint,hwnd,addr Paint
  190.         mov edx,hwollymain
  191.         invoke InvalidateRect,[edx],0,TRUE
  192.         xor eax,eax
  193.         ret
  194. bWndPaint endp

  195. bWndSize proc hwnd
  196.         invoke bWndMovc
  197.         invoke bWndMovi
  198.         invoke bWndMov
  199.         mov edx,hwollymain
  200.         invoke InvalidateRect,[edx],0,TRUE
  201.         xor eax,eax
  202.         ret
  203. bWndSize endp

  204. bWndSetFocus proc hwnd
  205.         invoke SetFocus,ghComboBox
  206.         xor eax,eax
  207.         ret
  208. bWndSetFocus endp

  209. bWndCreate proc uses esi edi ebx hwnd
  210.         LOCAL Rect:RECT
  211.         LOCAL lpBtnName[102]:WORD
  212.         invoke GetClientRect,hwnd,addr Rect
  213.        
  214.         mov esi,1001
  215.         mov ebx,1
  216.         mov edi,5
  217.         .repeat
  218.                 invoke wsprintfW,addr lpBtnName,$CTW0("M%d"),ebx
  219.                
  220.                 mov edx,hollyinst
  221.                 invoke CreateWindowExW,0,$CTW0("BUTTON"),addr lpBtnName,5001800Bh,edi,3,28,19,hwnd,esi,[edx],0
  222.                 mov ghBtn[ebx*4][-4],eax
  223.                 inc esi
  224.                 inc ebx
  225.                 lea edi,[edi][28]
  226.         .until ebx==6
  227.        
  228.         mov esi,hollyinst
  229.         invoke CreateWindowExW,0,$CTW0("STATIC"),$CTW0("Command :"),05000000Bh,150,4,80,20,hwnd,1003,[esi],0
  230.         invoke CreateWindowExW,0,$CTW0("COMBOBOX"),offset gString,050A10E42h,230,1,200,200,hwnd,1001,[esi],0
  231.         mov ghComboBox,eax
  232.         invoke GetWindow,eax,5
  233.         invoke SetWindowLongW,eax,-4,offset ComboBoxProc
  234.         mov gPrevCBProc,eax
  235.        
  236.         mov eax,[Rect].right
  237.         sub eax,50
  238.        
  239.         invoke CreateWindowExW,0,$CTW0("EDIT"),offset gString,050800804h,440,3,eax,19,hwnd,0,[esi],0
  240.         mov ghEdit,eax
  241.        
  242.         xor eax,eax
  243.         ret
  244. bWndCreate endp

  245. bWndDrawItem proc uses esi edi ebx hwnd,lParam
  246.         LOCAL Rect:RECT
  247.         LOCAL dRect:RECT
  248.         LOCAL wString[102]:WORD
  249.        
  250.         mov esi,lParam
  251.         mov eax,(DRAWITEMSTRUCT ptr [esi]).CtlID
  252.        
  253.         .if eax>=1001 && eax<=1005
  254.                 assume esi:ptr DRAWITEMSTRUCT
  255.                 mov edi,[esi].hdc
  256.                 invoke SetBkMode,edi,1
  257.                 invoke GetSysColor,15
  258.                 invoke CreateSolidBrush,eax
  259.                 mov ebx,eax
  260.                 invoke RtlMoveMemory,addr Rect,addr [esi].rcItem,sizeof RECT
  261.                 invoke FillRect,edi,addr Rect,ebx
  262.                 invoke DeleteObject,ebx
  263.                 .if [esi].itemState & 1
  264.                         invoke GetSysColor,16
  265.                         invoke CreateSolidBrush,eax
  266.                         mov ebx,eax
  267.                         invoke FrameRect,edi,addr Rect,ebx
  268.                         invoke DeleteObject,ebx
  269.                 .endif
  270.                 invoke GetDlgItem,hwnd,[esi].CtlID
  271.                 lea ebx,wString
  272.                 invoke GetWindowTextW,eax,ebx,100
  273.                 invoke GetDlgItem,hwnd,[esi].CtlID
  274.                
  275.                 .if (word ptr [wString]!=2f30h) ;"/0"
  276.                         invoke RtlMoveMemory,addr Rect,addr [esi].rcItem,sizeof RECT
  277.                         .if [esi].itemState & 1
  278.                                 invoke OffsetRect,addr Rect,1,1
  279.                         .endif
  280.                         invoke RtlMoveMemory,addr dRect,addr Rect,sizeof RECT
  281.                         invoke DrawTextW,edi,ebx,-1,addr Rect,411h
  282.                        
  283.                         mov eax,dRect.right
  284.                         sub eax,dRect.left
  285.                         sub eax,Rect.right
  286.                         add eax,Rect.left
  287.                         cdq
  288.                         sub eax,edx
  289.                         shr eax,1
  290.                         mov ecx,eax
  291.                        
  292.                        
  293.                         mov eax,dRect.bottom
  294.                         sub eax,dRect.top
  295.                         sub eax,Rect.bottom
  296.                         add eax,Rect.top
  297.                         cdq
  298.                         sub eax,edx
  299.                         shr eax,1
  300.                         mov edx,eax
  301.                        
  302.                         invoke OffsetRect,addr Rect,ecx,edx
  303.                         invoke SetBkMode,edi,1
  304.                        
  305.                         .if [esi].itemState & 4
  306.                                 invoke OffsetRect,addr Rect,1,1
  307.                                 invoke GetSysColor,20
  308.                                 invoke SetTextColor,edi,eax
  309.                                 invoke DrawTextW,edi,ebx,-1,addr Rect,11h
  310.                                 invoke OffsetRect,addr Rect,-1,-1
  311.                                 invoke GetSysColor,16
  312.                                 invoke SetTextColor,edi,eax
  313.                         .else
  314.                                 mov eax,1001
  315.                                 add eax,giBtn
  316.                                 .if [esi].CtlID==eax
  317.                                         invoke SetTextColor,edi,0ffh
  318.                                 .else
  319.                                         invoke SetTextColor,edi,0
  320.                                 .endif               
  321.                                 invoke GetSysColor,15
  322.                                 invoke SetBkColor,edi,eax
  323.                         .endif
  324.                         invoke DrawTextW,edi,ebx,-1,addr Rect,11h
  325.                 .endif
  326.                
  327.                 assume esi:nothing
  328.         .endif
  329.         xor eax,eax
  330.         inc eax
  331.         ret
  332. bWndDrawItem endp

  333. bWndCommand proc wParam
  334.         LOCAL Rect:RECT
  335.         mov eax,wParam
  336.         .if eax>=1001 && eax<=1005
  337.                 sub eax,1001
  338.                 .if [eax*4][gDumpaddr] && eax!=giBtn
  339.                         mov giBtn,eax
  340.                         mov eax,gDumpaddr[eax*4]
  341.                         invoke Setcpu,0,0,eax,-1,0,16
  342.                         invoke GetClientRect,ghWnd,addr Rect
  343.                         invoke InvalidateRect,ghWnd,0,1
  344.                 .endif
  345.         .endif
  346.         xor eax,eax
  347.         ret
  348. bWndCommand endp

  349. bWndProc proc hwnd,Msg,wParam,lParam
  350.         mov eax,Msg
  351.         .if eax==15        ;WM_PAINT
  352.                 invoke bWndPaint,hwnd
  353.         .elseif eax==5        ;WM_SIZE
  354.                 invoke bWndSize,hwnd
  355.         .elseif eax==7        ;WM_SETFOCUS
  356.                 invoke bWndSetFocus,hwnd
  357.         .elseif eax==1        ;WM_CREATE
  358.                 invoke bWndCreate,hwnd
  359.         .elseif eax==43        ;WM_DRAWITEM
  360.                 invoke bWndDrawItem,hwnd,lParam
  361.         .elseif eax==273;WM_COMMAND
  362.                 invoke bWndCommand,wParam
  363.         .else
  364.                 invoke DefWindowProcW,hwnd,Msg,wParam,lParam
  365.         .endif
  366.        
  367.         ret
  368. bWndProc endp


  369. align 4
  370. ODBG2_Plugininit proc c uses ebx
  371.         LOCAL lpWNDCLASSEXW:WNDCLASSEX
  372.         LOCAL lpRect:RECT
  373.        
  374.         lea ebx,lpWNDCLASSEXW
  375.         assume ebx:ptr WNDCLASSEX
  376.        
  377.         mov [ebx].cbSize,sizeof WNDCLASSEX
  378.         mov [ebx].style,11
  379.         mov [ebx].lpfnWndProc,offset bWndProc
  380.         mov [ebx].cbClsExtra,0
  381.         mov [ebx].cbWndExtra,0       
  382.        
  383.         mov eax,hollyinst
  384.         mov eax,dword ptr [eax]
  385.        
  386.         mov [ebx].hInstance,eax       
  387.         mov [ebx].hIcon,0
  388.        
  389.         invoke LoadCursorW,eax,7F00h
  390.         mov [ebx].hCursor,eax       
  391.         mov [ebx].hbrBackground,15       
  392.         mov [ebx].lpszMenuName,0
  393.         mov [ebx].lpszClassName,bClassName
  394.         mov [ebx].hIconSm,0
  395.         assume ebx:nothing
  396.        
  397.         invoke RegisterClassExW,ebx
  398.        
  399.         lea ebx,lpRect
  400.         assume ebx:ptr RECT
  401.         mov edx,hwollymain
  402.         invoke GetClientRect,[edx],ebx
  403.        
  404.        
  405.         mov eax,[ebx].bottom
  406.         sub eax,45
  407.        
  408.         mov edx,hwollymain
  409.         mov ecx,hollyinst
  410.        
  411.         invoke CreateWindowExW,0,\
  412.                                                 bClassName,\
  413.                                                 bWndName,\
  414.                                                 50000000h,\;WS_CHILD|WS_VISIBLE
  415.                                                 0,\
  416.                                                 eax,\
  417.                                                 [ebx].right,\
  418.                                                 25,\
  419.                                                 [edx],\
  420.                                                 0,\
  421.                                                 [ecx],\
  422.                                                 0
  423.         mov ghWnd,eax
  424.        
  425.         assume ebx:nothing
  426.        
  427.         mov edx,hwollymain
  428.         invoke SetWindowLongW,[edx],-4,offset WndProc
  429.         mov gPrevWndProc,eax
  430.        
  431.         xor eax,eax
  432.         ret
  433. ODBG2_Plugininit endp

  434. ;int __cdecl ODBG2_Plugindump(t_dump *pd,
  435. ;  wchar_t *s,uchar *mask,int n,int *select,ulong addr,int column)
  436. align 4
  437. ODBG2_Plugindump proc c uses esi edi ebx pd,s,_mask,n,select,_addr,column
  438.         LOCAL info[MAX_PATH]:WORD
  439. .data
  440.         gpT_dump  dd 0
  441.         gSelstart dd 5 dup(0)
  442.         gSelend          dd 5 dup(0)
  443. .code       
  444.         .if column==DF_FILLCACHE
  445.                 mov esi,pd
  446.                 mov ebx,_addr
  447.                 assume esi:ptr t_dump
  448.                 .if esi && ebx
  449.                         mov eax,[esi].menutype
  450.                         and eax,DMT_CPUMASK
  451.                         .if eax==DMT_CPUDUMP
  452.                                 mov eax,giBtn
  453.                                 .if eax || eax!= gDumpaddr[0*4]
  454.                                         invoke wsprintfW,addr info,$CTW0("g_nCurDumpAddress: %d addr: %0.8x"),eax,[esi].selstart
  455.                                         ;varapi (void)    Tempinfo(wchar_t *format,...);
  456.                                         invoke Tempinfo,addr info
  457.                                         mov eax,giBtn
  458.                                         mov edx,[esi].selend
  459.                                         .if gDumpaddr[eax*4]!=edx
  460.                                                 mov gDumpaddr[eax*4],ebx
  461.                                                 mov edx,[esi].selstart
  462.                                                 mov gSelstart[eax*4],edx
  463.                                                 mov edx,[esi].selend
  464.                                                 mov gSelend[eax*4],edx
  465.                                         .endif
  466.                                         mov ecx,eax
  467.                                         mov ebx,gSelstart[ecx*4]
  468.                                         mov edi,gSelend[ecx*4]
  469.                                        
  470.                                         mov eax,edi
  471.                                         sub eax,ebx
  472.                                         cdq
  473.                                         xor eax,edx
  474.                                         sub eax,edx
  475.                                         inc eax
  476.                                         inc ecx
  477.                                         mov gpT_dump,esi
  478.                                        
  479.                                         CTW  "MEM: %d, ",4,fmt
  480.                                         CTW  "Start: 0x%08X, "
  481.                                         CTW  "End: 0x%08X, "
  482.                                         CTW0 "Block: 0x%X\{%d\}"
  483.                                        
  484.                                         invoke wsprintfW,addr info,offset fmt,\
  485.                                                                         ecx,ebx,edi,eax,eax
  486.                                         invoke Tempinfo,addr info                               
  487.                                         mov eax,giBtn
  488.                                         mov edx,gSelstart[eax*4]
  489.                                         mov [esi].sel0,edx
  490.                                        
  491.                                         mov edx,gSelend[eax*4]
  492.                                         inc edx
  493.                                         mov [esi].sel1,edx
  494.                                        
  495.                                 .else
  496.                                         mov gDumpaddr[0*4],ebx
  497.                                         mov gDumpaddr[1*4],ebx
  498.                                         mov gDumpaddr[2*4],ebx
  499.                                         mov gDumpaddr[3*4],ebx
  500.                                         mov gDumpaddr[4*4],ebx
  501.                                         mov gpT_dump,esi
  502.                                 .endif
  503.                         .endif
  504.                 .endif
  505.                 assume esi:nothing
  506.         .endif
  507.         xor eax,eax
  508.         ret
  509. ODBG2_Plugindump endp
  510. ODBG2_Pluginmenu proc c _type
  511. .data
  512.         submenu t_menu <$CTW0("about:"),$CTW0("about"),0,offset SubmenuFunc,0,<0>>
  513.                         t_menu <0,0,0,0,0,<0>>
  514.         gmenu         t_menu <$CTW0("CmdBar"),$CTW0("CmdBar"),0,0,offset submenu,<0>>
  515.                         t_menu <0,0,0,0,0,<0>>
  516. .code
  517.         invoke crt_wcscmp,_type,PWM_MAIN
  518.         .if !eax
  519.                 mov eax,offset gmenu
  520.         .else
  521.                 xor eax,eax
  522.         .endif
  523.         ret
  524. ODBG2_Pluginmenu endp
  525. ODBG2_Pluginquery proc c ollydbgversion,features,pluginname,pluginversion
  526.         .if ollydbgversion>=201
  527.                 invoke RtlMoveMemory,pluginname,bPluginname,32
  528.                 invoke RtlMoveMemory,pluginversion,bPluginversion,32
  529.                 mov eax,2010001h
  530.         .else
  531.                 xor eax,eax
  532.         .endif
  533.         ret
  534. ODBG2_Pluginquery endp
  535. ODBG2_Pluginreset proc
  536.         and gDumpaddr[0],0
  537.         and gDumpaddr[4],0
  538.         and gDumpaddr[8],0
  539.         and gDumpaddr[0ch],0
  540.         and gDumpaddr[10h],0
  541.         and giBtn,0
  542.         xor eax,eax
  543.         ret
  544. ODBG2_Pluginreset endp
  545. ODBG2_Pluginnotify proc c action,data,p1,p2
  546.         xor eax,eax
  547.         ret
  548. ODBG2_Pluginnotify endp
  549. ODBG2_Pluginclose proc c
  550.         xor eax,eax
  551.         ret
  552. ODBG2_Pluginclose endp
  553. ODBG2_Pluginanalyse proc c t_module,pmod
  554.         xor eax,eax
  555.         ret
  556. ODBG2_Pluginanalyse endp
  557. ODBG2_Plugindestroy proc c
  558.         mov edx,hollyinst
  559.         invoke UnregisterClassW,bClassName,[edx]
  560.         ret
  561. ODBG2_Plugindestroy endp



  562. dllmain proc uses edi esi ebx hInst:DWORD, reason:DWORD, reserved1:DWORD

  563.         invoke GetModuleHandle,NULL
  564.         mov gExeHande,eax
  565.         invoke InitImportTable
  566.         mov eax,1
  567.         ret
  568. dllmain endp

  569. end dllmain
复制代码


功能实现:

  1. MAX_HIST EQU 32

  2. .data       
  3.         gcmdlist         label         t_command        ;
  4.                                                
  5.                                                 t_command <$CTW0("D"),                 $CTW0("A"),        0,                                offset subDumpcmd,        $CTW0("Dump at Address")>
  6.                                                 t_command <$CTW0("DUMP"),        $CTW0("A"),        0,                                offset subDumpcmd,        $CTW0("Dump at Address")>
  7.                                                 t_command <$CTW0("DA"),                 $CTW0("a"),        DUMP_DISASM,        offset subDumpcmd,        $CTW0("Dump as Disassembly")>
  8.                                                 t_command <$CTW0("DB"),                 $CTW0("a"),        DUMP_HEXA16,        offset subDumpcmd,        $CTW0("Dump in Hex byte format")>
  9.                                                 t_command <$CTW0("DC"),                 $CTW0("a"),        DUMP_ASC64,                offset subDumpcmd,        $CTW0("Dump in Ascii format")>
  10.                                                 t_command <$CTW0("DD"),                 $CTW0("a"),        DUMP_ADDR,                offset subDumpcmd,        $CTW0("Dump in Stack format")>
  11.                                                 t_command <$CTW0("DU"),                 $CTW0("a"),        DUMP_UNI64,                offset subDumpcmd,        $CTW0("Dump in Unicode format")>
  12.                                                 t_command <$CTW0("DW"),                 $CTW0("a"),        DUMP_IHEX16,        offset subDumpcmd,        $CTW0("Dump in Hex word format")>
  13.                                                
  14.                                                 t_command <$CTW0("DFF"),         $CTW0("a"),        DUMP_FLOAT32,        offset subDumpcmd,        $CTW0("Dump in 32-bit floats")>
  15.                                                 t_command <$CTW0("DFD"),         $CTW0("a"),        DUMP_FLOAT64,        offset subDumpcmd,        $CTW0("Dump in 64-bit floats")>
  16.                                                 t_command <$CTW0("DFT"),         $CTW0("a"),        DUMP_FLOAT80,        offset subDumpcmd,        $CTW0("Dump in 80-bit floats")>
  17.                                                
  18.                                                 t_command <$CTW0("DT"),                $CTW0("AS"),DUMP_DECODE,        offset subDumpStruc,$CTW0("Dump as structure")>
  19.                                                
  20.                                                 t_command <$CTW0("ORIG"),        $CTW0(""),        0,                                offset subDorigin,        $CTW0("Disassemble at EIP")>
  21.                                                 t_command <$CTW0("*"),                 $CTW0(""),        0,                                offset subDorigin,        $CTW0("Disassemble at EIP")>
  22.                                                
  23.                                                 t_command <$CTW0("STK"),         $CTW0("A"),        0,                                offset subStakcmd,        $CTW0("Go to address in stack")>
  24.                                                
  25.                                                 t_command <$CTW0("AT"),                 $CTW0("A"),        0,                                offset subDasmcmd,        $CTW0("Disassemble at address")>
  26.                                                 t_command <$CTW0("FOLLOW"),        $CTW0("A"),        0,                                offset subDasmcmd,        $CTW0("Disassemble at address")>
  27.                                                
  28.                                                 t_command <$CTW0("BP"),                $CTW0("AS"),BP_MANUAL,                offset subBreakpt,        $CTW0("int3 [,condition] breakpoint")>
  29.                                                 t_command <$CTW0("BC"),                $CTW0("A"),        0,                                offset subDelbpt,        $CTW0("Delete int3 breakpoint")>
  30.                                                
  31.                                                 t_command <$CTW0("MR"),                $CTW0("Av"),BP_MR,                        offset subMembkpt,        $CTW0("Memory breakpt on access")>
  32.                                                 t_command <$CTW0("MW"),                $CTW0("Av"),BP_MW,                        offset subMembkpt,        $CTW0("Memory breakpt on write")>
  33.                                                 t_command <$CTW0("ME"),                $CTW0("Av"),BP_ME,                        offset subMembkpt,        $CTW0("Memory breakpt on execute")>
  34.                                                 t_command <$CTW0("MRWE"),        $CTW0("Av"),BP_MRWE,                offset subMembkpt,        $CTW0("Memory breakpt on R.W.E")>
  35.                                                 t_command <$CTW0("MD"),                $CTW0("Av"),0,                                offset subMembkpt,        $CTW0("Remove memory breakpoint")>
  36.                                                
  37.                                                 t_command <$CTW0("HR"),                $CTW0("A"),        BP_HR,                        offset subHwbreak,        $CTW0("HW break on access")>
  38.                                                 t_command <$CTW0("HW"),                $CTW0("A"),        BP_HW,                        offset subHwbreak,        $CTW0("HW break on write")>
  39.                                                 t_command <$CTW0("HE"),                $CTW0("A"),        BP_HE,                        offset subHwbreak,        $CTW0("HW break on execute")>
  40.                                                 t_command <$CTW0("HD"),                $CTW0("a"),        0,                                offset subHwbreak,        $CTW0("Remove HW breakpoint")>
  41.                                                
  42.                                                 t_command <$CTW0("OPEN"),        $CTW0("S"),        0,                                offset subOpenexe,        $CTW0("Open a execute file")>
  43.                                                 t_command <$CTW0("ATT"),        $CTW0("L"),        0,                                offset subAttach,        $CTW0("Attach a process")>
  44.                                                 t_command <$CTW0("ATTACH"),        $CTW0("L"),        0,                                offset subAttach,        $CTW0("Attach a process")>
  45.                                                
  46.                                                 t_command <$CTW0("?"),                $CTW0("V"),        0,                                offset subExpress,        $CTW0("Estimate expression")>
  47.                                                 t_command <$CTW0("CALC"),        $CTW0("V"),        0,                                offset subExpress,        $CTW0("Estimate expression")>
  48.                                                
  49.                                                
  50.                                                 t_command <$CTW0("W"),                $CTW0("S"),        0,                                offset subWatch,        $CTW0("Add watch expression")>
  51.                                                 t_command <$CTW0("WATCH"),        $CTW0("S"),        0,                                offset subWatch,        $CTW0("Add watch expression")>
  52.                                                
  53.                                                 t_command <$CTW0("EB"),                $CTW0("AL"),1,                                offset subMemEdit,        $CTW0("memory edit byte")>
  54.                                                 t_command <$CTW0("EW"),                $CTW0("AL"),2,                                offset subMemEdit,        $CTW0("memory edit word")>
  55.                                                 t_command <$CTW0("ED"),                $CTW0("AL"),4,                                offset subMemEdit,        $CTW0("memory edit dword")>
  56.                                                 t_command <$CTW0("EQ"),                $CTW0("AL"),8,                                offset subMemEdit,        $CTW0("memory edit qword")>
  57.                                                 t_command <$CTW0("EFF"),        $CTW0("AL"),1004h,                        offset subMemEdit,        $CTW0("memory edit float")>
  58.                                                 t_command <$CTW0("EFD"),        $CTW0("AL"),1008h,                        offset subMemEdit,        $CTW0("memory edit double")>
  59.                                                 t_command <$CTW0("EFT"),        $CTW0("AL"),100Ah,                        offset subMemEdit,        $CTW0("memory edit long double")>
  60.                                                
  61.                                                 t_command <$CTW0("R"),                $CTW0("RL"),0,                                offset subRegEdit,        $CTW0("reg edit ")>
  62.                                                
  63.                                                
  64.         gcmdlistEnd                        t_command <0,0,0,0,0>

  65. .data?       
  66. g_g label byte       
  67.         gaddress                         dd ?                                ;Operands A/a (address expression)
  68.         gn                                        dd ?                                ;Operands N/n (count)
  69.         glval                                t_result <>                        ;Operand  L   (lvalue address)
  70.         gval                                t_result <>                        ;Operands V/v (expression)
  71.         grval                                t_result <>                        ;Operands R (reg expression)
  72.         gstr                                dw MAX_PATH dup(?)        ;Operand  S (any string)
  73.         gcmd                                dw MAX_PATH dup(?)        ;Command  (uppercase)
  74. g_glength equ $ - offset g_g       
  75.         gaddr EQU gaddress
  76.                
  77. comment #
  78. static wchar_t      cmd[TEXTLEN];         // Command  (uppercase)
  79. static ulong     address;              // Operands A/a (address expression)
  80. static t_result  lvalue;               // Operand  L   (lvalue address)
  81. static t_result  value;                // Operands V/v (expression)
  82. static wchar_t      string[TEXTLEN];      // Operand  S   (any string)
  83. static int       count;                // Operands N/n (count)

  84. ;#


  85. .code
  86. subMemEdit proc answer,parm
  87.         mov eax,parm
  88.         .if eax == 1008h
  89.                 fld glval.f
  90.                 fstp qword ptr glval._data
  91.         .elseif eax == 1004h
  92.                 fld glval.f
  93.                 fstp dword ptr glval._data
  94.         .endif
  95.        
  96.         and eax,0Fh
  97.         invoke Writememory,addr glval._data,gaddr,eax,MM_SILENT or MM_REMOVEINT3 or MM_ADJUSTINT3
  98.         .if !eax
  99.                 invoke wsprintfW,answer,$CTW0("Unable to modify memory")
  100.                 mov eax,-1
  101.                 jmp done
  102.         .endif
  103.        
  104.         invoke Broadcast,484h,0,0
  105.        
  106.         xor eax,eax
  107. done:
  108.         ret
  109. subMemEdit endp

  110. subRegEdit proc uses esi answer,parm
  111.         invoke Getcputhreadid
  112.         invoke Findthread,eax
  113.         mov esi,eax
  114.         assume esi:ptr t_thread
  115.         .if !esi || ![esi].regvalid
  116.                 invoke wsprintfW,answer,$CTW0("Unable to modify register")
  117.                 mov eax,-1
  118.                 jmp done
  119.         .endif
  120.         .if !([esi].reg.status & RV_USERMOD)
  121.                 invoke RtlMoveMemory,addr [esi].oldreg,addr [esi].reg,sizeof t_reg
  122.                 or [esi].reg.status,RV_USERMOD
  123.         .endif
  124.         mov ecx,grval.lvaladdr
  125.         mov eax,grval.lvaltype
  126.         and eax,EXPR_TYPEMASK
  127.         .if         eax == EXPR_BYTE
  128.                 mov al,glval._data
  129.                 .if ecx>=4
  130.                         sub ecx,4
  131.                         shl ecx,2
  132.                         inc ecx
  133.                 .else
  134.                         shl ecx,2       
  135.                 .endif
  136.                 mov byte ptr [esi].reg.r[ecx],al
  137.                
  138.         .elseif eax == EXPR_WORD
  139.                 mov ax,glval.w
  140.                 mov word ptr [esi].reg.r[ecx*4],ax
  141.                
  142.         .elseif eax == EXPR_DWORD
  143.                 .if glval.datatype==EXPR_DWORD
  144.                         mov eax,glval.u
  145.                 .else
  146.                         push eax
  147.                         fld glval.f
  148.                         fstp dword ptr [esp]
  149.                         pop eax
  150.                 .endif       
  151.                 mov [esi].reg.r[ecx*4],eax
  152.                
  153.         .elseif eax == EXPR_FLOAT10
  154.                 imul ecx,ecx,sizeof tbyte
  155.                 fld glval.f
  156.                 fstp [esi].reg.f[ecx]
  157.         .else
  158.                
  159.         .endif       
  160.         or [esi].reg.status,RV_MODIFIED
  161.         invoke Broadcast,484h,0,0
  162.         xor eax,eax
  163.        
  164.         assume esi:nothing
  165. done:       
  166.         ret
  167. subRegEdit endp

  168. subDumpStruc proc uses esi answer,parm
  169.         LOCAL _title[TEXTLEN]:WORD
  170.         LOCAL _count:DWORD
  171.         .if word ptr gstr[0*2]==0
  172.                 invoke wsprintfW,answer,$CTW0("..........")
  173.                 jmp done
  174.         .endif
  175.         invoke Getstructureitemcount,offset gstr,addr _count
  176.         .if !eax
  177.                 invoke wsprintfW,answer,$CTW0("Undefined Structure: %s"),offset gstr
  178.         .endif
  179.                                                                                
  180.         invoke wsprintfW,addr _title,$CTW0("Structure %s at "),offset gstr
  181.         mov ecx,TEXTLEN
  182.         sub ecx,eax
  183.         lea eax,_title[eax*2]
  184.        
  185.         invoke Decodeaddress,gaddr,0,20400h,eax,ecx,0
  186.         invoke Createdumpwindow,addr _title,gaddr,_count,0,parm,gaddr,gaddr,offset gstr

  187. done:       
  188.         xor eax,eax
  189.         ret
  190. subDumpStruc endp

  191. subWatch proc uses esi answer,parm
  192.         LOCAL w:t_watch
  193.         LOCAL P:POINT
  194.         mov esi,watch
  195.         assume esi:ptr t_table
  196.         mov ecx,[esi].sorted.n
  197.        
  198.         .if ecx<[esi].sorted.nmax && word ptr [gstr]!=0
  199.                 dec ecx
  200.                 mov w._index,ecx
  201.                 mov w._size,1
  202.                 mov w._type,0
  203.                 invoke RtlMoveMemory,addr w._expr,offset gstr,TEXTLEN
  204.                 invoke Addsorteddata,addr [esi].sorted,addr w
  205.                
  206.                 mov eax,[esi].sorted.selected
  207.                 lea edx,[eax+1]
  208.                 invoke Maketableareavisible,esi,-1,0,eax,0,edx
  209.                 mov edx,hwollymain
  210.                 invoke SendMessageW,[edx],WM_COMMAND,8A0h,0
  211.         .endif
  212.         assume esi:nothing
  213.         xor eax,eax
  214.         ret
  215. subWatch endp

  216. subExpress proc answer,parm
  217.         invoke wsprintfW,answer,addr gval.value
  218.         xor eax,eax
  219.         ret
  220. subExpress endp

  221. subOpenexe proc answer,parm
  222.         .if word ptr gstr!=0
  223.                 invoke OpenExecfile,offset gstr,0,0
  224.         .endif
  225.         xor eax,eax
  226.         ret
  227. subOpenexe endp

  228. subAttach proc answer,parm
  229.         .if glval.datatype ==EXPR_DWORD
  230.                 invoke AttachProcess,glval.l
  231.                 invoke Setstatus,STAT_ATTACHING
  232.                 invoke Broadcast,484h,0,0
  233.         .endif
  234.         xor eax,eax
  235.         ret
  236. subAttach endp

  237. subHwbreak proc uses ebx esi edi answer,parm
  238.         LOCAL index:DWORD
  239.         mov ebx,bphard
  240.         assume ebx:ptr t_table
  241.         or index,-1
  242.         .if [ebx].sorted.n>0
  243.                 mov esi,[ebx].sorted.data
  244.                 assume esi:ptr t_bphard
  245.                 xor eax,eax
  246.                 .repeat
  247.                         mov edx,[esi]._addr
  248.                         mov ecx,[esi].index
  249.                         .if ecx!=-1 && edx==gaddr
  250.                                 mov index,ecx
  251.                                 .break
  252.                         .endif
  253.                         add esi,[ebx].sorted.itemsize
  254.                         inc eax
  255.                 .until eax>=[ebx].sorted.n
  256.                 assume esi:nothing
  257.         .endif

  258.         .if parm==0
  259.                 .if index!=-1
  260.                         invoke Removehardbreakpoint,index
  261.                 .endif
  262.                 jmp done
  263.         .endif
  264.        
  265.         .if index!=-1
  266.                 mov eax,(t_bphard ptr [esi])._type
  267.                 .if eax==parm
  268.                         invoke wsprintfW,answer,$CTW0("HW breakpoint already set slot %d"),index
  269.                         jmp done
  270.                 .endif
  271.         .endif
  272.        
  273.         invoke Findfreehardbreakslot,parm
  274.         mov index,eax
  275.        
  276.         .if eax < 0
  277.                 invoke wsprintfW,answer,$CTW0("No enough slot for HW breakpoint")
  278.                 jmp done
  279.         .endif
  280.        
  281.         invoke Sethardbreakpoint,index,1,parm,0,gaddr,0,0,0,0,0,0
  282.         .if eax
  283.                 invoke wsprintfW,answer,$CTW0("Slot %d Unable to set HW breakpoint"),index
  284.                 jmp done
  285.         .endif
  286.                
  287.         assume ebx:nothing
  288. done:       
  289.         xor eax,eax
  290.         ret
  291. subHwbreak endp

  292. subMembkpt proc answer,parm
  293.         .if !parm
  294.                 invoke Enablemembreakpoint,gaddr,FALSE
  295.                 xor eax,eax
  296.                 jmp done
  297.         .endif
  298.        
  299.         .if gval.datatype==EXPR_INVALID
  300.                 mov eax,1                                ;none
  301.         .else       
  302.                 .if gval.datatype!=EXPR_DWORD
  303.                         invoke wsprintfW,answer,$CTW0("Integer expression expected")
  304.                         mov eax,-1
  305.                         jmp done
  306.                 .endif
  307.                
  308.                 mov eax,gval.u
  309.                 .if eax
  310.                         .if eax<=10000h
  311.                                 nop                                ;value
  312.                         .elseif eax>gaddr
  313.                                 sub eax,gaddr        ;address
  314.                         .else
  315.                                 invoke wsprintfW,answer,$CTW0("Invalid memory range %d"),eax
  316.                                 mov eax,-1
  317.                                 jmp done
  318.                         .endif
  319.                 .endif
  320.         .endif
  321.        
  322.         invoke Setmembreakpoint,gaddr,eax,parm,0,0,0,0,0
  323.         .if eax
  324.                 invoke wsprintfW,answer,$CTW0("Unable to set breakpoint %08X"),gaddr
  325.                 mov eax,-1
  326.         .else
  327.                 invoke Enablemembreakpoint,gaddr,TRUE
  328.                 xor eax,eax
  329.         .endif
  330. done:       
  331.         ret
  332. subMembkpt endp

  333. subBreakpt proc answer,parm
  334.         LOCAL cond[MAX_PATH]:WORD
  335.         mov ecx,offset gstr
  336.         .if word ptr [ecx]!=0
  337.                 lea edx,cond
  338.                 .repeat
  339.                         mov ax,[ecx]
  340.                         mov [edx],ax
  341.                         add ecx,2
  342.                         add edx,2
  343.                 .until !ax
  344.                 lea ecx,cond
  345.                 mov eax,parm
  346.                 or eax,BP_CONDBREAK
  347.         .else
  348.                 mov eax,parm
  349.                 xor ecx,ecx       
  350.                 or eax,BP_BREAK
  351.         .endif
  352.        
  353.         invoke Setint3breakpoint,gaddress,eax,0,0,0,0,ecx,offset gString,offset gstr
  354.         invoke Broadcast,484h,0,0
  355.         xor eax,eax
  356.         ret
  357. subBreakpt endp

  358. subDelbpt proc answer,parm
  359.         invoke Removeint3breakpoint,gaddr,BP_MANUAL
  360.         invoke Broadcast,484h,0,0
  361.         xor eax,eax
  362.         ret
  363. subDelbpt endp


  364. subDumpcmd proc answer,parm
  365.         invoke Setcpu,0,0,gaddress,0,0,CPU_DUMPHIST or CPU_DUMPFIRST or CPU_DUMPFOCUS
  366.         mov ecx,parm
  367.         .if ecx
  368.                 invoke Getcpudumpdump
  369.                 invoke Setdumptype,eax,ecx
  370.         .endif
  371.         xor eax,eax
  372.         ret
  373. subDumpcmd endp

  374. subStakcmd proc answer,parm
  375.           invoke Setcpu,0,0,0,0,gaddress,CPU_DUMPHIST or CPU_DUMPFIRST or CPU_DUMPFOCUS
  376.           xor eax,eax
  377.           ret
  378. subStakcmd endp


  379. subDorigin proc answer,parm
  380.         invoke Getcputhreadid
  381.         invoke Findthread,eax
  382.         .if eax
  383.                 assume eax:ptr t_thread
  384.                 invoke Setcpu,0,[eax].context._Eip,0,0,0,CPU_ASMHIST or CPU_ASMCENTER
  385.                 invoke Broadcast,484h,0,0
  386.                 assume eax:nothing
  387.         .endif
  388.         xor eax,eax
  389.         ret       
  390. subDorigin endp


  391. subDasmcmd proc answer,parm
  392.         invoke Setcpu,0,gaddress,0,0,0,CPU_ASMHIST or CPU_ASMCENTER
  393.         xor eax,eax
  394.         ret
  395. subDasmcmd endp



  396. .data
  397.         gnhist                                  dd 0
  398. .data?
  399.         ghistory                          dw MAX_HIST*MAX_PATH dup(?)
  400.         ghistoryEnd                label word

  401. .code
  402. addline proc uses esi edi ebx cmd
  403.         mov esi,cmd
  404.         .if !esi
  405.                 jmp done
  406.         .endif
  407.         .if word ptr [esi]==0
  408.                 mov gnhist,0
  409.                 invoke SetWindowTextW,ghEdit,offset gString
  410.         .else
  411.                 ;Remove identical strings from the history.
  412.                 mov eax,gnhist
  413.                 imul eax,eax,MAX_PATH*2
  414.                 mov edi,offset ghistory
  415.                 add edi,eax
  416.                 mov ebx,edi
  417.                 .repeat
  418.                         sub edi,MAX_PATH*2
  419.                         invoke lstrcmpiW,edi,esi
  420.                         .if !eax
  421.                                 mov eax,edi
  422.                                 add eax,MAX_PATH*2
  423.                                
  424.                                 mov ecx,ebx
  425.                                 sub ecx,eax
  426.                                 invoke RtlMoveMemory,edi,eax,ecx
  427.                                
  428.                                 sub ebx,MAX_PATH*2
  429.                                 dec gnhist
  430.                         .endif
  431.                 .until edi<= offset ghistory
  432.                
  433.                 ;Insert new string.
  434.                 .if gnhist>=MAX_HIST
  435.                         mov gnhist,MAX_HIST - 1
  436.                 .endif
  437.                
  438.                 mov edi,offset ghistory
  439.                 mov ecx,gnhist
  440.                 .if ecx
  441.                         imul ecx,ecx,MAX_PATH*2
  442.                         mov eax,edi
  443.                         add eax,MAX_PATH*2
  444.                         invoke RtlMoveMemory,eax,edi,ecx
  445.                 .endif
  446.                
  447.                 invoke RtlMoveMemory,edi,esi,MAX_PATH*2
  448.                 inc gnhist
  449.         .endif
  450.         ;Copy history to combobox.
  451.        
  452.         invoke SendMessageW,ghComboBox,CB_RESETCONTENT,0,0
  453.        
  454.         xor ebx,ebx
  455.         .repeat
  456.                 invoke SendMessageW,ghComboBox,CB_ADDSTRING,0,edi
  457.                 inc ebx
  458.                 add edi,MAX_PATH*2
  459.         .until ebx>=gnhist
  460.         .if gnhist > 0
  461.                 invoke SetWindowTextW,ghComboBox,esi
  462.                 invoke SendMessageW,ghComboBox,CB_SETEDITSEL,0,MAX_PATH
  463.         .endif
  464. done:       
  465.         ret
  466. addline endp


  467. showinfo proc uses esi edi ebx cmd
  468.         LOCAL lpString[MAX_PATH]:WORD
  469.         LOCAL lpcmd[MAX_PATH]:WORD
  470.         LOCAL len:DWORD
  471.         LOCAL p:DWORD
  472.        
  473.         invoke crt_malloc,4
  474.         mov p,eax
  475.                        
  476.         mov esi,cmd
  477.         .if word ptr [esi]==0
  478.                 invoke SetWindowTextW,ghEdit,offset gString
  479.                 jmp done
  480.         .endif
  481.        
  482.         xor ebx,ebx
  483.         lea ecx,lpcmd
  484.         .repeat
  485.                 mov ax,[esi][ebx*2]
  486.                 mov [ecx][ebx*2],ax
  487.                 inc ebx
  488.         .until !ax
  489.         dec ebx
  490.         mov len,ebx
  491.        
  492.         mov ax,[ecx]
  493.         .if ax>="0" && ax<="9"
  494.                 mov eax,ecx
  495.         .else
  496.                 invoke crt_wcschr,ecx,20h; " "
  497.         .endif
  498.         xor ebx,ebx
  499.        
  500.         .if eax
  501.                 mov word ptr [eax],0
  502.                 mov edi,offset gcmdlist
  503.                 assume edi:ptr t_command
  504.                 .repeat
  505.                         invoke lstrcmpiW,addr lpcmd,[edi].cmd
  506.                         .if !eax
  507.                                 lea eax,[ebx*4+4]
  508.                                 invoke crt_realloc,p,eax
  509.                                 mov p,eax
  510.                                 mov [eax][ebx*4],edi
  511.                                 inc ebx
  512.                         .endif
  513.                         add edi,sizeof t_command
  514.                 .until edi>=offset gcmdlistEnd
  515.                
  516.         .else
  517.                 mov edi,offset gcmdlist
  518.                
  519.                 .repeat
  520.                         invoke crt__wcsnicmp,esi,[edi].cmd,len
  521.                         .if !eax
  522.                                 lea eax,[ebx*4+4]
  523.                                 invoke crt_realloc,p,eax
  524.                                 mov p,eax
  525.                                 mov [eax][ebx*4],edi
  526.                                 inc ebx
  527.                         .endif
  528.                         add edi,sizeof t_command
  529.                 .until edi>=offset gcmdlistEnd
  530.                 assume edi:nothing
  531.         .endif
  532.        
  533.         .if ebx>1
  534.                 invoke RtlZeroMemory,addr lpString,MAX_PATH*2
  535.                 lea edi,lpString
  536.                 mov esi,p
  537.                 xor ecx,ecx
  538.                 .repeat
  539.                          mov eax,[esi][ecx*4]
  540.                          assume eax:ptr t_command
  541.                         mov eax,[eax].cmd
  542.                          .repeat
  543.                                  mov dx,word ptr [eax]
  544.                                 mov [edi],dx
  545.                                 add eax,2
  546.                                 add edi,2                        
  547.                          .until dx==0
  548.                         mov word ptr [edi-2],20h                
  549.                          assume eax:nothing
  550.                          inc ecx
  551.                          mov eax,edi
  552.                          lea edx,lpString
  553.                          sub eax,edx
  554.                 .until ecx>=ebx || eax>=200h
  555.                 mov word ptr [edi],0
  556.                 invoke SetWindowTextW,ghEdit,addr lpString
  557.         .elseif ebx==1
  558.                 lea edi,lpcmd
  559.                 invoke RtlZeroMemory,edi,MAX_PATH*2
  560.                
  561.                 mov esi,p
  562.                 mov esi,[esi][0*4]
  563.                 assume esi:ptr t_command
  564.                 xor ebx,ebx
  565.                 .while 1
  566.                         mov ecx,[esi].args
  567.                         mov ax,[ecx][ebx*2]
  568.                         .break .if !ax
  569.                         .if (word ptr lpcmd[0]!=0)
  570.                                 mov word ptr [edi],","
  571.                                 add edi,2
  572.                         .endif
  573.                         .if ax=="A"
  574.                                 mov ecx,$CTW0(" address")
  575.                         .elseif ax=="a"
  576.                                 mov ecx,$CTW0(" [address]")
  577.                         .elseif ax=="S"
  578.                                 mov ecx,$CTW0(" string")       
  579.                         .elseif ax=="V"
  580.                                 mov ecx,$CTW0(" expression")
  581.                         .elseif ax=="v"
  582.                                 mov ecx,$CTW0(" [expression]")
  583.                         .elseif ax=="L"
  584.                                 mov ecx,$CTW0(" expression")
  585.                         .elseif ax=="R"
  586.                                 mov ecx,$CTW0(" Reg")
  587.                         .else
  588.                                 mov ecx,offset gString
  589.                         .endif
  590.                        
  591.                         .while 1
  592.                                 mov ax,[ecx]
  593.                                 .break .if !ax       
  594.                                 mov [edi],ax
  595.                                 add ecx,2
  596.                                 add edi,2
  597.                         .endw
  598.                         inc ebx
  599.                 .endw
  600.                
  601.                 invoke wsprintfW,addr lpString,$TW0(" %s%s -- %s"),[esi].cmd,addr lpcmd,[esi].help
  602.                 invoke SetWindowTextW,ghEdit,addr lpString
  603.                 assume esi:nothing
  604.         .else
  605.                 .if len
  606.                         invoke wsprintfW,addr lpString,$CTW0("No valid command begin with \= %s \=."),esi
  607.                         invoke SetWindowTextW,ghEdit,addr lpString
  608.                 .else
  609.                         invoke SetWindowTextW,ghEdit,offset gString
  610.                 .endif
  611.         .endif
  612.        
  613. done:
  614.         invoke crt_free,p       
  615.         ret
  616. showinfo endp








  617. Execute proc uses esi edi ebx cmd,info
  618.         LOCAL len:DWORD
  619.         LOCAL result:t_result
  620.         ;check args
  621.         mov esi,cmd
  622.         .if !esi || word ptr [esi] ==0 || info ==NULL
  623.                 mov eax,-1
  624.                 jmp done
  625.         .endif
  626.        
  627.         invoke RtlZeroMemory,offset g_g,g_glength
  628.        
  629.        
  630.         ;skip spaces
  631.         .while word ptr [esi]==20h || word ptr [esi]==9h        ;" " & "\t"
  632.                 lea esi,[esi][sizeof word]
  633.         .endw
  634.        
  635.         ;
  636.         mov edi,offset gcmd
  637.         xor ebx,ebx
  638.         .repeat
  639.                 mov ax,[esi]
  640.                 invoke crt_iswalpha,eax
  641.                 .if eax
  642.                         mov ax,[esi]
  643.                         invoke crt_towupper,eax
  644.                         mov [edi][ebx*2],ax
  645.                         lea esi,[esi][sizeof word]
  646.                 .else
  647.                         mov ax,word ptr [esi]
  648.                         .if ax=="?" || ax=="*" || ax==":"
  649.                                 mov [edi],ax
  650.                                 mov ebx,1
  651.                                 lea esi,[esi][sizeof word]
  652.                                 .break
  653.                         .endif
  654.                         .break
  655.                 .endif
  656.                 inc ebx
  657.         .until ebx>=MAX_HIST
  658.         mov word ptr [edi][ebx*2],0
  659.        
  660.         ;search
  661.         xor ebx,ebx
  662.         mov edi,offset gcmdlist
  663.         assume edi:ptr t_command
  664.         .repeat
  665.                 invoke lstrcmpiW,offset gcmd,[edi].cmd
  666.                 .break .if !eax
  667.                 add edi,sizeof t_command
  668.                 inc ebx
  669.         .until edi >=offset gcmdlistEnd

  670.         ;fail done
  671.         .if edi>=offset gcmdlistEnd
  672.                 invoke wsprintfW,info,$CTW0("Unrecognized command: %s"),offset gcmd
  673.                 mov eax,-1
  674.                 jmp done
  675.         .endif
  676.        
  677.         ;Now get operands esi
  678.        
  679.         xor ebx,ebx
  680.          
  681.         .while 1
  682.                 ;skip spaces
  683.                 .while word ptr [esi]==20h || word ptr [esi]==9h        ;" " & "\t"
  684.                         lea esi,[esi][sizeof word]
  685.                 .endw       
  686.                
  687.                 mov eax,[edi].args
  688.                 mov ax,[eax][ebx*2]
  689.                 inc ebx
  690.                
  691.                
  692.                 .break .if !ax
  693.                 .if ax=="a"
  694.                         mov dx,[esi]
  695.                         .if dx=="," || dx=="=" ||dx==";" || !dx
  696.                                 mov gaddress,0
  697.                                 .if dx
  698.                                         lea esi,[esi][sizeof word]
  699.                                 .endif
  700.                         .else
  701.                                 jmp @F       
  702.                         .endif
  703.                 .elseif ax=="A"
  704.                         @@:
  705.                         invoke Getcputhreadid
  706.                         invoke Expression,addr result,esi,0,0,0,eax,0,0,0
  707.                         .if eax<0
  708.                                 invoke wsprintfW,info,$CTW0("Invalid expression")
  709.                                 mov eax,-1
  710.                                 jmp done
  711.                         .endif
  712.                         mov len,eax
  713.                        
  714.                         .if result.datatype!=EXPR_DWORD
  715.                                 invoke wsprintfW,info,$CTW0("Integer expression expected")
  716.                                 mov eax,-1
  717.                                 jmp done
  718.                         .endif
  719.                         invoke Findmemory,result.u
  720.                         .if !eax
  721.                                 invoke wsprintfW,info,$CTW0("Address 0x%08X points to nowhere"),result.u
  722.                                 mov eax,-1
  723.                                 jmp done
  724.                         .endif
  725.                        
  726.                         mov eax,result.u
  727.                         mov gaddress,eax
  728.                         mov eax,len
  729.                         add eax,eax
  730.                         add esi,eax
  731.                 .elseif ax=="L"
  732.                         invoke Getcputhreadid
  733.                         invoke Expression,offset glval,esi,0,0,0,eax,0,0,0
  734.                         mov len,eax
  735.                         .if eax < 0 || glval.datatype==EXPR_INVALID
  736.                                 invoke wsprintfW,info,addr glval.value
  737.                                 mov eax,-1
  738.                                 jmp done
  739.                         .endif
  740.                         mov eax,len
  741.                         shl eax,1
  742.                         add esi,eax
  743.                 .elseif ax=="v"
  744.                         mov dx,[esi]
  745.                         .if dx=="," || dx=="=" ||dx==";" || !dx
  746.                                 mov result.datatype,EXPR_INVALID
  747.                                 mov result.u,0
  748.                                 .if dx
  749.                                         lea esi,[esi][sizeof word]
  750.                                 .endif
  751.                         .else
  752.                                 jmp @F
  753.                         .endif
  754.                 .elseif ax=="V"
  755.                         @@:
  756.                         invoke Getcputhreadid
  757.                         invoke Expression,offset gval,esi,0,0,0,eax,0,0,0
  758.                         mov len,eax
  759.                         .if eax < 0 || result.datatype==EXPR_INVALID
  760.                                 invoke wsprintfW,info,addr gval.value
  761.                                 mov eax,-1
  762.                                 jmp done
  763.                         .endif
  764.                         mov eax,len
  765.                         shl eax,1
  766.                         add esi,eax
  767.                 .elseif ax=="S"
  768.                         mov ecx,offset gstr
  769.                         .while 1       
  770.                                 mov dx,[esi]
  771.                                 mov [ecx],dx
  772.                                 .break .if !dx
  773.                                 add ecx,2
  774.                                 add esi,2
  775.                         .endw                       
  776.                 .elseif ax=="R"
  777.                         invoke Getcputhreadid
  778.                         invoke Expression,offset grval,esi,0,0,0,eax,0,0,0
  779.                         mov len,eax
  780.                         .if eax < 0 || !(grval.lvaltype & EXPR_REG)
  781.                                 invoke wsprintfW,info,$CTW0("undefined register")
  782.                                 mov eax,-1
  783.                                 jmp done
  784.                         .endif
  785.                         mov eax,len
  786.                         shl eax,1
  787.                         add esi,eax
  788.                 .else
  789.                         and eax,0FFFFh
  790.                         invoke wsprintfW,info,$CTW0("Internal error: undefined operand type %c"),eax
  791.                         mov eax,-1
  792.                         jmp done       
  793.                 .endif
  794.                
  795.                 mov eax,[edi].args
  796.                 mov ax,[eax][ebx*2]
  797.                 .if ax
  798.                         .while word ptr [esi]==20h || word ptr [esi]==9h        ;" " & "\t"
  799.                                 lea esi,[esi][sizeof word]
  800.                         .endw
  801.                         .if word ptr [esi]=="," || word ptr [esi]=="="
  802.                                 lea esi,[esi][sizeof word]
  803.                         .endif
  804.                 .endif
  805.         .endw
  806.        
  807.         .if word ptr [esi]!=0 && word ptr [esi]!=";"
  808.                 invoke wsprintfW,info,$CTW0("Extra characters on line: %.64s"),esi
  809.                 mov eax,-1
  810.                 jmp done
  811.         .endif
  812.         invoke wsprintfW,info,offset gString
  813.         invoke [edi].func,info,[edi].parm
  814.                
  815.         assume edi:nothing
  816. done:       
  817.         ret
  818. Execute endp

复制代码


kit.zip (1003.9 KB, 下载次数: 8, 售价: 1 个宅币)



回复

使用道具 举报

1

主题

7

回帖

58

积分

用户组: 小·技术宅

UID
1660
精华
0
威望
2 点
宅币
46 个
贡献
0 次
宅之契约
0 份
在线时间
8 小时
注册时间
2016-5-5
发表于 2017-2-2 20:58:12 | 显示全部楼层
于是我在想要不要学习汇编......
回复 赞! 靠!

使用道具 举报

0

主题

3

回帖

98

积分

用户组: 小·技术宅

UID
958
精华
0
威望
1 点
宅币
93 个
贡献
0 次
宅之契约
0 份
在线时间
15 小时
注册时间
2015-7-15
发表于 2017-2-6 09:04:42 | 显示全部楼层
厉害厉害
回复

使用道具 举报

0

主题

1

回帖

21

积分

用户组: 初·技术宅

UID
2261
精华
0
威望
1 点
宅币
18 个
贡献
0 次
宅之契约
0 份
在线时间
6 小时
注册时间
2017-2-19
发表于 2017-2-20 21:38:32 | 显示全部楼层
本帖最后由 a725782500 于 2017-2-20 21:41 编辑

标记下。没有收藏按键好麻烦啊。。
实力眼瞎。。最下面有选项。。。。。
回复 赞! 靠!

使用道具 举报

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

GMT+8, 2024-4-25 06:49 , Processed in 0.048702 second(s), 34 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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