Subversion Repositories Kolibri OS

Rev

Rev 9353 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.         use32
  2.         db      'MENUET01'
  3.         dd      1
  4.         dd      Start
  5.         dd      I_END
  6. MemSize dd      Mem
  7.         dd      StackTop
  8.         dd      0,AppPath
  9.  
  10. VERSION equ     '0.01+'
  11.  
  12. ;-----------------------------------------------------------------------------
  13. Bitness equ     32
  14. ;-----------------------------------------------------------------------------
  15. bit     equ     1 shl
  16. by      equ     shl 8 +
  17.  
  18. %B      =       32
  19.  
  20. macro   even    Value { rb (Value-1)-($+Value-1) mod Value }
  21.  
  22. macro   ifc    Opc&
  23. {
  24. local ..L
  25.         jnc     ..L
  26.         Opc
  27. ..L:
  28. }
  29.  
  30. macro   ifa    Opc&
  31. {
  32. local ..L
  33.         jna     ..L
  34.         Opc
  35. ..L:
  36. }
  37.  
  38. macro   ifae   Opc&
  39. {
  40. local ..L
  41.         jnae    ..L
  42.         Opc
  43. ..L:
  44. }
  45.  
  46. macro   ifb    Opc&
  47. {
  48. local ..L
  49.         jnb     ..L
  50.         Opc
  51. ..L:
  52. }
  53.  
  54. macro   ifbe   Opc&
  55. {
  56. local ..L
  57.         jnbe    ..L
  58.         Opc
  59. ..L:
  60. }
  61.  
  62. macro   ifg     Opc&
  63. {
  64. local ..L
  65.         jng     ..L
  66.         Opc
  67. ..L:
  68. }
  69.  
  70. macro   ifge   Opc&
  71. {
  72. local ..L
  73.         jnge    ..L
  74.         Opc
  75. ..L:
  76. }
  77.  
  78. macro   ifl    Opc&
  79. {
  80. local ..L
  81.         jnl     ..L
  82.         Opc
  83. ..L:
  84. }
  85.  
  86. macro   ifle   Opc&
  87. {
  88. local ..L
  89.         jnle    ..L
  90.         Opc
  91. ..L:
  92. }
  93.  
  94. macro   ifno   Opc&
  95. {
  96. local ..L
  97.         jo      ..L
  98.         Opc
  99. ..L:
  100. }
  101.  
  102. macro   ifnp   Opc&
  103. {
  104. local ..L
  105.         jp      ..L
  106.         Opc
  107. ..L:
  108. }
  109.  
  110. macro   ifns   Opc&
  111. {
  112. local ..L
  113.         js      ..L
  114.         Opc
  115. ..L:
  116. }
  117.  
  118. macro   ifnz   Opc&
  119. {
  120. local ..L
  121.         jz      ..L
  122.         Opc
  123. ..L:
  124. }
  125.  
  126. macro   ifo    Opc&
  127. {
  128. local ..L
  129.         jno     ..L
  130.         Opc
  131. ..L:
  132. }
  133.  
  134. macro   ifp    Opc&
  135. {
  136. local ..L
  137.         jnp     ..L
  138.         Opc
  139. ..L:
  140. }
  141.  
  142. macro   ifs    Opc&
  143. {
  144. local ..L
  145.         jns     ..L
  146.         Opc
  147. ..L:
  148. }
  149.  
  150. macro   ifz    Opc&
  151. {
  152. local ..L
  153.         jnz     ..L
  154.         Opc
  155. ..L:
  156. }
  157.  
  158. macro   lea     Dst,Src
  159. {
  160. local ..L,..H
  161. virtual at 0
  162.         mov     al,byte Src
  163. load ..L byte from 0x0
  164. if ..L = 0xA0
  165.   load ..H dword from 0x1
  166. end if
  167. end virtual
  168. if ..L = 0xA0
  169.         mov     Dst,..H
  170. else
  171.         lea     Dst,Src
  172. end if
  173. }
  174.  
  175. include 'kosfuncs.inc'
  176. include '../../macros.inc'
  177.  
  178. include 'font.inc'
  179. include 'tools.inc'
  180. include 'kernel.inc'
  181.  
  182. virtual at rsp
  183. All:
  184. .edi    dd ?
  185. .esi    dd ?
  186. .ebp    dd ?
  187. .res    dd ?
  188. .ebx    dd ?
  189. .edx    dd ?
  190. .ecx    dd ?
  191. .eax    dd ?
  192. end virtual
  193.  
  194. macro   jecxnz  Target
  195. {
  196.         inc     ecx
  197.         loop    Target
  198. }
  199.  
  200. TestFile        db '/sys/develop/scancode',0
  201.  
  202. MinWidth = 90
  203. MaxWidth = 255
  204. MinHeight = 75
  205. MaxHeight = 255
  206.  
  207. DATA_WIDTH      = 88                    ; in characters, multiple of 4
  208.  
  209. CMD_WIDTH       = DATA_WIDTH
  210.  
  211. CursorNormSize = 2
  212. CursorBigsSize = FontHeight
  213.  
  214. ;-----------------------------------------------------------------------------
  215. ;                           Fast load test file event
  216. DoLoad: mov     esi,TestFile
  217.         mov     edi,LoadName
  218.         jmp     OnLoadInit
  219. ;-----------------------------------------------------------------------------
  220. ;                           Load executable event
  221. OnLoad: mov     esi,[CurArg]
  222. OnLoadInit:
  223.         mov     edi,LoadName
  224.         or      [PrgNameLen],-1
  225.         mov     [PrgNamePtr],edi
  226.     .CopyName:
  227.         lodsb
  228.         stosb
  229.         inc     [PrgNameLen]
  230.         cmp     al,'/'
  231.         jnz     @F
  232.         or      [PrgNameLen],-1
  233.         mov     [PrgNamePtr],edi
  234.     @@:
  235.         cmp     al,' '
  236.         ja      .CopyName
  237.         mov     byte [edi-1],0
  238.         and     [LoadParams],0
  239.         dec     esi
  240.         call    GetArg.SkipSpaces
  241.         cmp     al,0
  242.         jz      @F
  243.         mov     [LoadParams],esi
  244.     @@:
  245.        ;and     [DumpPos],0
  246.         mov     ecx,[Symbols]
  247.         jecxz   DoReLoad
  248.         mcall   68,13
  249.         and     [Symbols],0
  250.         and     [NumSymbols],0
  251. DoReLoad:
  252.         mcall   18,7
  253.         mov     [DbgWnd],eax
  254.         xchg    ecx,eax
  255.         mcall   70,FN70LoadBlock
  256.         test    eax,eax
  257.         jns     .Loaded
  258.  
  259.     .LoadErr:
  260.         push    eax
  261.         mov     esi,LoadErrMsg
  262.         call    PutMessage
  263.         pop     eax
  264.         not     eax
  265.         cmp     eax,0x20
  266.         jae     .UnkErr
  267.         mov     esi,[LoadErrMsgs+eax*4]
  268.         test    esi,esi
  269.         jnz     PutMessage
  270.  
  271.     .UnkErr:
  272.         mov     esi,UnkErrMsg
  273.         inc     eax
  274.         push    eax
  275.         call    PutMessageNoDraw
  276.         jmp     DrawMessages
  277.  
  278. .Loaded:
  279.         mov     [DebuggeePID],eax
  280.         mov     [bSuspended],1
  281.         mcall   5,20
  282.         push    ecx
  283.         call    GetContext
  284.         mov     edi,OldContext
  285.         mov     ecx,(CtxEnd-Context)/4
  286.         rep     movsd
  287.         ; activate debugger window
  288.         pop     ecx
  289.         mcall   18,3
  290.         call    GetDump
  291. if 1
  292.         push    dword [ShowNames]
  293.         mov     [ShowNames],-1
  294. end if
  295.         mov     [AfterKey],0
  296.         call    ShowImage
  297.         mov     esi,LoadSuccMsg
  298.         push    [DebuggeePID]
  299.         call    PutMessageNoDraw
  300.         call    DrawMessages
  301.     ; try to load symbols
  302.         mov     esi,LoadName
  303.         mov     edi,SymbolsFile
  304.         push    edi
  305.     @@:
  306.         lodsb
  307.         stosb
  308.         test    al,al
  309.         jnz     @B
  310.         lea     ecx,[edi-1]
  311.     @@:
  312.         dec     edi
  313.         cmp     edi,SymbolsFile
  314.         jb      @F
  315.         cmp     byte [edi],'/'
  316.         jz      @F
  317.         cmp     byte [edi],'.'
  318.         jnz     @B
  319.         mov     ecx,edi
  320.     @@:
  321.         mov     dword [ecx],'.dbg'
  322.         mov     byte [ecx+4],0
  323.         pop     esi
  324.         mov     ebp,esi
  325.         push    ecx esi
  326.         call    OnLoadSymbols.Silent    ; Try to load .dbg file
  327.         pop     esi ecx
  328.         xor     eax,eax
  329.         cmp     [NumSymbols],eax
  330.         jne     @F
  331.         mov     dword [ecx],'.map'      ; If failed, try .map file too
  332.         call    OnLoadSymbols.Silent
  333.     @@:
  334. if 1
  335.         pop     eax
  336.         mov     [ShowNames],al
  337.         call    DrawMessages
  338. end if
  339.         ret
  340.  
  341. ;-----------------------------------------------------------------------------
  342. ;                        Working with debug context
  343. GetNewContext:
  344.         mov     esi,Context
  345.         mov     edi,OldContext
  346.         mov     ecx,(CtxEnd-Context)/4
  347.         rep     movsd
  348.  
  349. GetContext:
  350.         mcall   69,1,[DebuggeePID],CtxEnd-Context,Context
  351.         ret
  352.  
  353. SetContext:
  354.         mcall   69,2,[DebuggeePID],28h,Context
  355.         ret
  356.  
  357. ;-----------------------------------------------------------------------------
  358. ;                        Resume process event
  359. DoResume:
  360.         mcall   69,5,[DebuggeePID]
  361.         mov     [bSuspended],0
  362.         ret
  363.  
  364. ;-----------------------------------------------------------------------------
  365. ;                        Breakpoints manipulation
  366. OnBp:   mov     esi,[CurArg]
  367.         call    CalcExpression
  368.         jc      .Ret
  369.         xchg    eax,ebp
  370.         push    eax
  371.         call    FindBreakPoint
  372.         inc     eax
  373.         pop     eax
  374.         jz      .NotFound
  375.         mov     esi,aDuplicateBreakpoint
  376.         jmp     .SayErr
  377.     .NotFound:
  378.         mov     bl,1
  379.         call    AddBreakPoint
  380.         jnc     .Ret
  381.         mov     esi,aBreakpointLimitExceeded
  382.     .SayErr:
  383.         call    PutMessage
  384.     .Ret:
  385.         jmp     DrawMessages;DrawDisAsm
  386.  
  387. ;-----------------------------------------------------------------------------
  388. ;                            Dump memory event
  389. OnDump: mov     esi,[CurArg]
  390.         cmp     byte [esi],0
  391.         jnz     .Param
  392.        ;add     [DumpPos],DUMP_HEIGHT*10h
  393.         add     [DataAddr],8*8
  394.         jmp     .DoIt
  395.  
  396.     .Param:
  397.         call    CalcExpression
  398.         jc      .Ret
  399.        ;mov     [DumpPos],ebp
  400.         mov     [DataAddr],ebp
  401.     .DoIt:
  402.        ;call    GetDump
  403.        ;call    DrawDump.Redraw
  404.         call    DrawMessages
  405.     .Ret:
  406.         ret
  407.  
  408. OnBpmb: mov     dh,0011b
  409.         jmp     DoBpm
  410.  
  411. OnBpmw: mov     dh,0111b
  412.         jmp     DoBpm
  413.  
  414. OnBpmd: mov     dh,1111b
  415.  
  416. DoBpm:  mov     esi,[CurArg]
  417.         cmp     byte [esi],'w'
  418.         jnz     @F
  419.         and     dh,not 2
  420.         inc     esi
  421.     @@:
  422.         push    edx
  423.         call    CalcExpression
  424.         pop     edx
  425.         jnc     @F
  426.         ret
  427.     ; ebp = expression, dh = flags
  428.     @@:
  429.         movzx   eax,dh
  430.         shr     eax,2
  431.         test    ebp,eax
  432.         jz      @F
  433.         mov     esi,aUnaligned
  434.         jmp     PutMessage
  435.     @@:
  436.         mov     eax,ebp
  437.         mov     bl,0Bh
  438.         call    AddBreakPoint
  439.         jnc     @F
  440.         mov     esi,aBreakpointLimitExceeded
  441.         jmp     PutMessage
  442.     ; now find index
  443.     @@:
  444.         push    eax
  445.         xor     ecx,ecx
  446.     .L1:
  447.         cmp     [DrXBreak+ecx*4],0
  448.         jnz     .L2
  449.         push    ecx
  450.         mov     dl,cl
  451.         mov     esi,ebp
  452.         mcall   69,9,[DebuggeePID]
  453.         test    eax,eax
  454.         jz      .OK
  455.         pop     ecx
  456.     .L2:
  457.         inc     ecx
  458.         cmp     ecx,4
  459.         jb      .L1
  460.         pop     eax
  461.         call    ClearBreakPoint
  462.         mov     esi,aBreakpointLimitExceeded
  463.         jmp     PutMessage
  464.     .OK:
  465.         pop     ecx
  466.         pop     eax
  467.         and     byte [edi],not 2        ; breakpoint is enabled
  468.         shl     dl,6
  469.         or      dl,dh
  470.         mov     byte [edi+1],dl
  471.         inc     eax
  472.         mov     [DrXBreak+ecx*4],eax
  473.         ret
  474.  
  475. OnBc:   mov     esi,[CurArg]
  476.     @@:
  477.         call    GetHexNumber
  478.         jc      OnBp.Ret
  479.         call    ClearBreakPoint
  480.         jmp     @B
  481. OnBd:
  482.         mov     esi,[CurArg]
  483.     @@:
  484.         call    GetHexNumber
  485.         jc      OnBp.Ret
  486.         call    DisableBreakPoint
  487.         jmp     @B
  488. OnBe:
  489.         mov     esi,[CurArg]
  490.     @@:
  491.         call    GetHexNumber
  492.         jc      OnBp.Ret
  493.         push    eax
  494.         call    FindEnabledBreakPoint
  495.         pop     eax
  496.         jz      .Err
  497.         call    EnableBreakPoint
  498.         jmp     @B
  499.     .Err:
  500.         mov     esi,OnBeErrMsg
  501.         jmp     PutMessage
  502.  
  503. GetHexNumber:
  504.         call    GetArg.SkipSpaces
  505.         xor     ecx,ecx
  506.         xor     edx,edx
  507.     @@:
  508.         lodsb
  509.         call    IsHexDigit
  510.         jc      .Ret
  511.         shl     edx,4
  512.         or      dl,al
  513.         inc     ecx
  514.         jmp     @B
  515.     .Ret:
  516.         dec     esi
  517.         cmp     ecx,1
  518.         xchg    eax,edx
  519.         ret
  520.  
  521. ;-----------------------------------------------------------------------------
  522. ;                       Breakpoints list event
  523. OnBl:   mov     esi,[CurArg]
  524.         cmp     byte [esi],0
  525.         jz      .ListAll
  526.         call    GetHexNumber
  527.         jc      .Ret
  528.         cmp     eax,BreakPointsN
  529.         jae     .Err
  530.         push    eax
  531.         add     eax,eax
  532.         lea     edi,[BreakPoints+eax+eax*2]
  533.         pop     eax
  534.         test    byte [edi+4],1
  535.         jz      .Err
  536.         call    ShowBreakInfo
  537.     .Ret:
  538.         ret
  539.     .Err:
  540.         mov     esi,aInvalidBreak
  541.         jmp     PutMessage
  542.  
  543.     .ListAll:
  544.         mov     edi,BreakPoints
  545.         xor     eax,eax
  546.     @@:
  547.         test    byte [edi+4],1
  548.         jz      .Cont
  549.         push    edi eax
  550.         call    ShowBreakInfo
  551.         pop     eax edi
  552.     .Cont:
  553.         add     edi,6
  554.         inc     eax
  555.         cmp     eax,BreakPointsN
  556.         jb      @B
  557.         ret
  558.  
  559. ShowBreakInfo:
  560.         push    edi
  561.         test    byte [edi+4],8
  562.         jnz     .DR
  563.         push    dword [edi]
  564.         push    eax
  565.         mov     esi,aBreakNum
  566.         call    PutMessageNoDraw
  567.         jmp     .CMN
  568.     .DR:
  569.         push    eax
  570.         mov     esi,aMemBreak1
  571.         call    PutMessageNoDraw
  572.         pop     edi
  573.         push    edi
  574.         mov     esi,aMemBreak2
  575.         test    byte [edi+5],2
  576.         jz      @F
  577.         mov     esi,aMemBreak3
  578.     @@:
  579.         call    PutMessageNoDraw
  580.         pop     edi
  581.         push    edi
  582.         mov     esi,aMemBreak6
  583.         test    byte [edi+5],8
  584.         jnz     @F
  585.         mov     esi,aMemBreak5
  586.         test    byte [edi+5],4
  587.         jnz     @F
  588.         mov     esi,aMemBreak4
  589.     @@:
  590.         call    PutMessageNoDraw
  591.         pop     edi
  592.         push    edi
  593.         push    dword [edi]
  594.         mov     esi,aMemBreak7
  595.         call    PutMessageNoDraw
  596.     .CMN:
  597.         pop     edi
  598.         test    byte [edi+4],2
  599.         jz      @F
  600.         push    edi
  601.         mov     esi,aDisabled
  602.         call    PutMessageNoDraw
  603.         pop     edi
  604.     @@:
  605.         test    byte [edi+4],4
  606.         jz      @F
  607.         mov     esi,aOneShot
  608.         call    PutMessageNoDraw
  609.     @@:
  610.         mov     esi,NewLine
  611.         jmp     PutMessage
  612.  
  613. ;-----------------------------------------------------------------------------
  614. ;                       Unpack executable event
  615. OnUnpack:
  616.     ; program must be loaded - checked when command was parsed
  617.     ; program must be stopped
  618.         mov     esi,aRunningErr
  619.         cmp     [bSuspended],0
  620.         jz      PutMessage
  621.    ; all breakpoints must be disabled
  622.         mov     edi,BreakPoints
  623.     @@:
  624.         test    byte [edi+4],1
  625.         jz      .Cont
  626.         test    byte [edi+4],2
  627.         jnz     .Cont
  628.         mov     esi,aEnabledBreakErr
  629.         jmp     PutMessage
  630.     .Cont:
  631.         add     edi,6
  632.         cmp     edi,BreakPoints+BreakPointsN*6
  633.         jb      @B
  634.     ; ok, now do it
  635.     ; set breakpoint on 0xC dword access
  636.         push    9
  637.         pop     ebx
  638.         mov     ecx,[DebuggeePID]
  639.         mov     dx,1111b*256
  640.         push    0xC
  641.         pop     esi
  642.     @@:
  643.         mcall   69
  644.         test    eax,eax
  645.         jz      .BreakOK
  646.         inc     edx
  647.         cmp     dl,4
  648.         jb      @B
  649.     .BreakOK:
  650.         call    GoOn
  651.     ; now wait for event
  652.     .Wait:
  653.         mcall   10
  654.         dec     eax
  655.         jz      .Redraw
  656.         dec     eax
  657.         jz      .Key
  658.         dec     eax
  659.         jnz     .Debug
  660.     ; button; we have only one button, close
  661.         or      eax,-1
  662.         mcall
  663.  
  664.     .Redraw:
  665.         mov     [DoDraw],1
  666.         call    DrawWindow
  667.         jmp     .Wait
  668.  
  669.     .Key:
  670.         mov     al,2
  671.         mcall
  672.         cmp     ah,3   ; Ctrl+C
  673.         jnz     .Wait
  674.  
  675.     .UserBreak:
  676.         mov     esi,aInterrupted
  677.     .X1:
  678.         push    edx esi
  679.         call    PutMessage
  680.         pop     esi edx
  681.         or      dh,80h
  682.         mcall   69,9,[DebuggeePID]
  683.         cmp     esi,aUnpacked
  684.         jnz     OnSuspend
  685.         jmp     AfterSuspend
  686.  
  687.     .Debug:
  688.         cmp     [DbgBufLen],4*3
  689.         jnz     .NotOur
  690.         cmp     dword [DbgBuf],3
  691.         jnz     .NotOur
  692.         test    byte [DbgBuf+8],1
  693.         jnz     .Our
  694.  
  695.     .NotOur:
  696.         mov     esi,aInterrupted
  697.         push    edx
  698.         call    PutMessage
  699.         pop     edx
  700.         or      dh,80h
  701.         mcall   69,9,[DebuggeePID]
  702.         jmp     DebugMsg
  703.  
  704.     .Our:
  705.         and     [DbgBufLen],0
  706.         push    edx
  707.         call    GetContext
  708.         push    eax
  709.         mcall   69,6,[DebuggeePID],4,0xC,esp
  710.         pop     eax
  711.         pop     edx
  712.         cmp     eax,[_EIP]
  713.         jz      .Done
  714.         call    DoResume
  715.         jmp     .Wait
  716.  
  717.     .Done:
  718.         mov     esi,aUnpacked
  719.         jmp     .X1
  720.  
  721. ;-----------------------------------------------------------------------------
  722. ;                        Calculate expression event
  723. OnCalc: mov     esi,[CurArg]
  724.         call    CalcExpression
  725.         jc      .Ret
  726.         push    ebp
  727.         mov     esi,CalcString
  728.         call    PutMessageNoDraw
  729.         jmp     DrawMessages
  730.     .Ret:
  731.         ret
  732.  
  733. ;-----------------------------------------------------------------------------
  734. ;                       Access to register value event
  735. OnReg:  mov     esi,[CurArg]
  736.         call    GetArg.SkipSpaces
  737.         call    FindReg
  738.         jnc     @F
  739.     .Err:
  740.         mov     esi,RSyntax
  741.         jmp     PutMessage
  742.     @@:
  743.         call    GetArg.SkipSpaces
  744.         test    al,al
  745.         jz      .Err
  746.         cmp     al,'='
  747.         jnz     @F
  748.         inc     esi
  749.         call    GetArg.SkipSpaces
  750.         test    al,al
  751.         jz      .Err
  752.     @@:
  753.         push    edi
  754.         call    CalcExpression
  755.         pop     edi
  756.         jc      .Ret
  757.     ; now edi=register id, ebp=value
  758.         cmp     [bSuspended],0
  759.         mov     esi,aRunningErr
  760.         jz      PutMessage
  761.         xchg    eax,ebp
  762.         cmp     edi,24
  763.         jz      .EIP
  764.         sub     edi,4
  765.         jb      .8LO
  766.         sub     edi,4
  767.         jb      .8HI
  768.         sub     edi,8
  769.         jb      .16
  770.         mov     [_EAX+edi*4],eax
  771.         jmp     .Ret
  772.     .16:
  773.         mov     word [_EAX+(edi+8)*4],ax
  774.         jmp     .Ret
  775.     .8LO:
  776.         mov     byte [_EAX+(edi+4)*4],al
  777.         jmp     .Ret
  778.     .8HI:
  779.         mov     byte [_EAX+(edi+4)*4+1],al
  780.         jmp     .Ret
  781.     .EIP:
  782.         mov     [_EIP],eax
  783.        ;call    UpdateDisAsmEIP
  784.     .Ret:
  785.         call    SetContext
  786.         jmp     DrawMessages;DrawRegisters.ReDraw
  787.  
  788. ;-----------------------------------------------------------------------------
  789. ;                       Step execution event
  790. ;Here we get [<number>] argument at do step <number> times
  791. OnStepMultiple:
  792.         cmp     [bSuspended],0
  793.         jz      OnStep.Running
  794.         mov     [StepNum],1
  795.         mov     esi,[CurArg]
  796.         test    esi,esi
  797.         jz      .Do
  798.         cmp     byte [esi],0
  799.         jz      .Do
  800.         call    GetHexNumber
  801.         jc      .Ret
  802.         or      eax,eax ; check if lesser or equal than 0
  803.         jle     .Ret
  804.         mov     [StepNum],eax
  805. .Do:    call    OnStep
  806.         dec     [StepNum]
  807.         jnz     .Do
  808. .Ret:   ret
  809.  
  810. OnStep:
  811.         cmp     [bSuspended],0
  812.         jz      .Running
  813.         call    GetContext
  814.         or      byte [_EFL+1],1 ; set TF
  815.         call    SetContext
  816.         and     byte [_EFL+1],not 1
  817.     ; if instruction at eip is "int xx", set one-shot breakpoint immediately after
  818.         mov     eax,[_EIP]
  819.         call    FindEnabledBreakPoint
  820.         jnz     @F
  821.         cmp     byte [edi+5],0xCD
  822.         jz      .Int
  823.      @@:
  824.         push    0
  825.         mcall   69,6,[DebuggeePID],3,[_EIP],esp
  826.         cmp     eax,edx
  827.         pop     eax
  828.         jnz     .DoIt
  829.         cmp     al,0xCD
  830.         jz      .Int
  831.         cmp     ax,0x050F
  832.         jz      .SysCall
  833.         cmp     ax,0x340F
  834.         jz      .SysEnter
  835.     ; resume process
  836.     .DoIt:
  837.         call    GoOn
  838.         cmp     [bAfterGo],0
  839.         jz      @F
  840.         mov     [bAfterGo],2
  841.     @@:
  842.         ret
  843.  
  844.     ; return address is [ebp-4]
  845.     .SysEnter:
  846.         push    0
  847.         inc     edx     ; read 4 bytes
  848.         mov     esi,[_EBP]
  849.         sub     esi,4
  850.         mcall   69
  851.         cmp     eax,edx
  852.         pop     eax
  853.         jnz     .SysCall
  854.         push    eax
  855.         and     byte [_EFL+1],not 1
  856.         call    SetContext
  857.         pop     eax
  858.         jmp     @F
  859.  
  860.     .SysCall:
  861.         and     byte [_EFL+1],not 1     ; clear TF - avoid system halt (!)
  862.         call    SetContext
  863.     .Int:
  864.         mov     eax,[_EIP]
  865.         inc     eax
  866.         inc     eax
  867.     @@:
  868.         push    eax
  869.         call    FindEnabledBreakPoint
  870.         pop     eax
  871.         jz      .DoIt
  872.     ; there is no enabled breakpoint yet; set temporary breakpoint
  873.         mov     bl,5
  874.         call    AddBreakPoint
  875.         jmp     .DoIt
  876.  
  877.     .Running:
  878.         mov     esi,aRunningErr
  879.         jmp     PutMessage
  880.  
  881. ;-----------------------------------------------------------------------------
  882. ;                       Proceed process event
  883. ;Here we get [<number>] argument at do step <number> times
  884. OnProceedMultiple:
  885.         cmp     [bSuspended],0
  886.         jz      OnStep.Running
  887.         mov     [ProcNum],1
  888.         mov     esi,[CurArg]
  889.         test    esi,esi
  890.         jz      .Do
  891.         cmp     byte [esi],0
  892.         jz      .Do
  893.         call    GetHexNumber
  894.         jc      .Ret
  895.         or      eax,eax ; check if lesser or equal than 0
  896.         jle     .Ret
  897.         mov     [ProcNum],eax
  898.         and     [CurArg],0
  899. .Do:
  900.         call    OnProceed
  901.         dec     [ProcNum]
  902.         jnz     .Do
  903. .Ret:
  904.         ret
  905.  
  906. OnProceed:
  907.         cmp     [bSuspended],0
  908.         jz      OnStep.Running
  909.         mov     esi,[_EIP]
  910.  
  911.     @@:
  912.         call    GetByteNoBreak
  913.         jc      OnStep
  914.         inc     esi
  915.     ; skip prefixes
  916.         call    IsPrefix
  917.         jz      @B
  918.         cmp     al,0xE8         ; call
  919.         jnz     @f
  920.         add     esi,4
  921.         jmp     .DoIt
  922.  
  923.     ; A4,A5 = movs; A6,A7 = cmps
  924.     @@:
  925.         cmp     al,0xA4
  926.         jb      @F
  927.         cmp     al,0xA8
  928.         jb      .DoIt
  929.  
  930.     ; AA,AB = stos; AC,AD = lods; AE,AF = scas
  931.     @@:
  932.         cmp     al,0xAA
  933.         jb      @F
  934.         cmp     al,0xB0
  935.         jb      .DoIt
  936.  
  937.     ; E0 = loopnz; E1 = loopz; E2 = loop
  938.     @@:
  939.         cmp     al,0xE0
  940.         jb      .NoLoop
  941.         cmp     al,0xE2
  942.         ja      .NoLoop
  943.         inc     esi
  944.         jmp     .DoIt
  945.  
  946.     ; FF /2 = call
  947.     .NoLoop:
  948.         cmp     al,0xFF
  949.         jnz     OnStep
  950.         call    GetByteNoBreak
  951.         jc      OnStep
  952.         inc     esi
  953.         mov     cl,al
  954.         and     al,00111000b
  955.         cmp     al,00010000b
  956.         jnz     OnStep
  957.     ; skip instruction
  958.         mov     al,cl
  959.         and     eax,7
  960.         shr     cl,6
  961.         jz      .Mod0
  962.         jp      .DoIt
  963.         cmp     al,4
  964.         jnz     @F
  965.         inc     esi
  966.     @@:
  967.         inc     esi
  968.         dec     cl
  969.         jz      @F
  970.         add     esi,3
  971.     @@:
  972.         jmp     .DoIt
  973.     .Mod0:
  974.         cmp     al,4
  975.         jnz     @F
  976.         call    GetByteNoBreak
  977.         jc      OnStep
  978.         inc     esi
  979.         and     al,7
  980.     @@:
  981.         cmp     al,5
  982.         jnz     .DoIt
  983.         add     esi,4
  984.     .DoIt:
  985.     ; insert one-shot breakpoint at esi and resume
  986.         call    GetByteNoBreak
  987.         jc      OnStep
  988.         mov     eax,esi
  989.         call    FindEnabledBreakPoint
  990.         jz      @F
  991.         mov     eax,esi
  992.         mov     bl,5
  993.         call    AddBreakPoint
  994.         jmp     OnStep.DoIt
  995.     @@:
  996.         ret
  997.  
  998. ;-----------------------------------------------------------------------------
  999. ;                        Read next byte of machine code
  1000. GetByteNoBreak:
  1001.         mov     eax,esi
  1002.         call    FindEnabledBreakPoint
  1003.         jnz     .NoBreak
  1004.         mov     al,[edi+5]
  1005.         clc
  1006.         ret
  1007.  
  1008.     .NoBreak:
  1009.         xor     edx,edx
  1010.         push    edx
  1011.         inc     edx
  1012.         mov     edi,esp
  1013.         mcall   69,6,[DebuggeePID]
  1014.         dec     eax
  1015.         clc
  1016.         jz      @F
  1017.         stc
  1018.     @@:
  1019.         pop     eax
  1020.         ret
  1021.  
  1022. IsPrefix:
  1023.         cmp     al,0x64         ; fs:
  1024.         jz      .Ret
  1025.         cmp     al,0x65         ; gs:
  1026.         jz      .Ret
  1027.         cmp     al,0x66         ; use16/32
  1028.         jz      .Ret
  1029.         cmp     al,0x67         ; addr16/32
  1030.         jz      .Ret
  1031.         cmp     al,0xF0         ; lock
  1032.         jz      .Ret
  1033.         cmp     al,0xF2         ; repnz
  1034.         jz      .Ret
  1035.         cmp     al,0xF3         ; rep(z)
  1036.         jz      .Ret
  1037.         cmp     al,0x2E         ; cs:
  1038.         jz      .Ret
  1039.         cmp     al,0x36         ; ss:
  1040.         jz      .Ret
  1041.         cmp     al,0x3E         ; ds:
  1042.         jz      .Ret
  1043.         cmp     al,0x26         ; es:
  1044.     .Ret:
  1045.         ret
  1046.  
  1047. OnResume:
  1048.         mov     esi,[CurArg]
  1049.         cmp     byte [esi],0
  1050.         jz      GoOn
  1051.         call    CalcExpression
  1052.         jc      .Ret
  1053.     .Jmp:
  1054.         mov     eax,ebp
  1055.         push    eax
  1056.         call    FindEnabledBreakPoint
  1057.         pop     eax
  1058.         jz      GoOn
  1059.         mov     bl,5   ; valid enabled one-shot
  1060.         call    AddBreakPoint
  1061.         jnc     GoOn
  1062.         mov     esi,aBreakpointLimitExceeded
  1063.         call    PutMessage
  1064.     .Ret:
  1065.         ret
  1066.  
  1067. ;-----------------------------------------------------------------------------
  1068. ;                                 Jump event
  1069. OnJump: mov     esi,[CurArg]
  1070.         cmp     byte [rsi],0
  1071.         jz      .Ret
  1072.         call    CalcExpression
  1073.         jc      .Ret
  1074.         mov     ecx,[CurrentWindow]
  1075.         mov     [CodeAddr+rcx*4],ebp
  1076.         jecxnz  .Next
  1077.         mov     [CPUYPos],1
  1078. .Next:
  1079.         cmp     ecx,1           ;Reg Window?
  1080.         jnz     .NReg
  1081.         mov     eax,[RegXPtr]
  1082.         cmp     eax,9
  1083.         jae     .NReg
  1084.         mov     eax,[RegRTab+rax*4]
  1085.         mov     [rax],ebp
  1086.         call    SetContext
  1087. .NReg:
  1088.         mov     [AfterKey],1
  1089.         call    ShowImage
  1090. .Ret:   ret
  1091.  
  1092. ;-----------------------------------------------------------------------------
  1093. ;                                 Help event
  1094. OnHelp: mov     esi,HelpMsg
  1095.         mov     edi,[CurArg]
  1096.         cmp     byte [edi],0
  1097.         jz      .X
  1098.         mov     esi,HelpGroups
  1099.         call    FindCmd
  1100.         jc      .NoCmd
  1101.         mov     esi,[esi+12]
  1102.     .X:
  1103.         jmp     PutMessage
  1104.  
  1105.     .NoCmd:
  1106.         mov     esi,aUnknownCommand
  1107.         jmp     .X
  1108.  
  1109. ;-----------------------------------------------------------------------------
  1110. ;                        Detach process event
  1111. OnDetach:
  1112.         mcall    69,3,[DebuggeePID]
  1113.         and     [DebuggeePID],0
  1114.         call    FreeSymbols
  1115.         mov     esi,aContinued
  1116.         jmp     PutMessage
  1117.  
  1118. ;-----------------------------------------------------------------------------
  1119. ;                         Reload executable event
  1120. OnReLoad:
  1121.         cmp     [DebuggeePID],0
  1122.         jnz     TerminateReLoad
  1123.         mov     esi,NeedDebuggee
  1124.         cmp     byte [LoadName],0
  1125.         jnz     DoReLoad
  1126.         jz      PutMessage
  1127.  
  1128. TerminateReLoad:
  1129.         mov     [bReload],1
  1130. ;-----------------------------------------------------------------------------
  1131. ;                        Terminate process event
  1132. OnTerminate:
  1133.         mcall   69,8,[DebuggeePID]
  1134.         ret
  1135.  
  1136. ;-----------------------------------------------------------------------------
  1137. ;                         Suspend process event
  1138. AfterSuspend:
  1139.         mov     [bSuspended],1
  1140.         call    GetNewContext
  1141.         call    GetDump
  1142.         call    ShowImage
  1143.         ret
  1144.  
  1145. OnSuspend:
  1146.         mcall   69,4,[DebuggeePID]
  1147.         call    AfterSuspend
  1148.         mov     esi,aSuspended
  1149.         jmp     PutMessage
  1150. GoOn:
  1151.     ; test for enabled breakpoint at eip
  1152.         mov     eax,[_EIP]
  1153.         call    FindEnabledBreakPoint
  1154.         jnz     .NoBreak
  1155.     ; temporarily disable breakpoint, make step, enable breakpoint, continue
  1156.         inc     eax
  1157.         mov     [TempBreak],eax
  1158.         mov     [bAfterGo],1
  1159.         dec     eax
  1160.         call    DisableBreakPoint
  1161.         call    GetContext
  1162.         or      byte [_EFL+1],1         ; set TF
  1163.         call    SetContext
  1164.         and     byte [_EFL+1],not 1
  1165.         call    DoResume
  1166.         ret
  1167.     .NoBreak:
  1168.         call    DoResume
  1169. ShowImage:
  1170.         pushad
  1171.         call    InitConsole
  1172.         call    DrawWindow
  1173.         popad
  1174.         ret
  1175.  
  1176. even 4
  1177. InitConsole:
  1178.         mov     eax,[CurWidth]
  1179.         mul     [CurHeight]
  1180.         mov     ecx,eax
  1181.         mov     edi,ConsoleDataPtr
  1182.         mov     eax,3F203F20h
  1183.         shr     ecx,1
  1184.         rep     stosd
  1185.         adc     cl,cl
  1186.         rep     stosw
  1187.         ;
  1188.         mov     ebx,MSG_HEIGHT                  ;dY
  1189.         mov     ecx,[CurWidth]                  ;\dX
  1190.         sub     ecx,2                           ;/
  1191.         mov     esi,1                           ;X
  1192.         mov     edi,MinHeight-MSG_HEIGHT-1      ;Y
  1193.         mov     edx,87208720h
  1194.         call    ClearWindow
  1195.         ;
  1196.         call    DrawFrame
  1197.         ret
  1198.  
  1199. InitCoords:
  1200.         mov     [CPUXPos],1
  1201.         mov     [CPUYPos],1
  1202.         mov     [CPUXPtr],0
  1203.         mov     [MemXPos],11
  1204.         mov     [MemYPos],41
  1205.         mov     eax,[CurWidth]
  1206.         SUB     eax,21
  1207.         mov     [StkXPos],eax
  1208.         mov     [StkYPos],28
  1209.         mov     [RegXPos],1
  1210.         mov     [RegYPos],30
  1211.         mov     [RegLDat],12
  1212.         and     [RegXPtr],0
  1213.         ret
  1214.  
  1215. GetDataByte:
  1216. ;I: esi - address
  1217. ;O: al  - byte
  1218.         pushad
  1219.         mov     al,0
  1220.         push    eax
  1221.         mcall   69,6,[DebuggeePID],1,[All.esi+4],esp
  1222. if 1
  1223.         mov     esi,[All.esi+4]
  1224.         mov     edi,esp
  1225.         call    RestoreFromBreaksOne
  1226. end if
  1227.         cmp     eax,-1  ;invalid PID?
  1228.         jz      @F      ;Yes,CF=0
  1229.         cmp     eax,1   ;CF=1,eax=1 if OK
  1230.         cmc
  1231. @@:     pop     dword [esp+1Ch]
  1232.         popad
  1233.         ret
  1234.  
  1235. SafeStoreDD:
  1236.         pushad
  1237.         mov     eax,69
  1238.         mov     ebx,7
  1239.         mov     ecx,[DebuggeePID]
  1240.         mov     edx,4
  1241.         mov     esi,edi
  1242.         lea     edi,[All.eax]
  1243.         int     40h
  1244.         popad
  1245.         ret
  1246.  
  1247. SafeStore:
  1248.         pushad
  1249.         mov     eax,69
  1250.         mov     ebx,7
  1251.         mov     ecx,[DebuggeePID]
  1252.         mov     edx,1
  1253.         mov     esi,edi
  1254.         lea     edi,[All.eax]
  1255.         int     40h
  1256.         popad
  1257.         ret
  1258.  
  1259. DrawWindow:
  1260.         btr     dword [DoDraw],0
  1261.         jc      .CopyDraw
  1262.         mov     esi,ConsoleDataPtr
  1263.         mov     edi,ConsoleDataOld
  1264.         mov     ecx,[CurWidth]
  1265.         imul    ecx,[CurHeight]
  1266.         shr     ecx,1
  1267.         repz    cmpsd
  1268.         jnz     .CopyDraw
  1269.         adc     cl,cl
  1270.         repz    cmpsw
  1271.         jz      .SkipDraw
  1272. .CopyDraw:
  1273.         mov     esi,ConsoleDataPtr
  1274.         mov     edi,ConsoleDataOld
  1275.         mov     ecx,[CurWidth]
  1276.         imul    ecx,[CurHeight]
  1277.         shr     ecx,1
  1278.         rep     movsd
  1279.         adc     cl,cl
  1280.         rep     movsw
  1281.  
  1282.         push    SF_REDRAW
  1283.         pop     eax
  1284.         push    SSF_BEGIN_DRAW
  1285.         pop     ebx
  1286.         int     40h
  1287.         mov     al,SF_STYLE_SETTINGS
  1288.         mov     bl,SSF_GET_SKIN_HEIGHT
  1289.         int     40h
  1290.         mov     [SkinH],eax
  1291.         mov     ebx,[CurWidth]
  1292.         imul    ebx,FontWidth
  1293.         add     ebx,100*65536+5*2-1
  1294.         mov     ecx,[CurHeight]
  1295.         imul    ecx,FontHeight
  1296.         lea     ecx,[eax+ecx+5-1+100*65536]
  1297.         xor     eax,eax
  1298.         mov     edx,0x53000000
  1299.  
  1300.         mov     edi,HeaderN
  1301.         cmp     [DebuggeePID],0
  1302.         jz      @F
  1303.         mov     edi,HeaderY
  1304.     @@: int     40h
  1305.  
  1306.         mov     al,SF_DRAW_RECT
  1307.         xor     edx,edx
  1308.         cmp     [FillWidth],0
  1309.         jz      @F
  1310.         mov     ebx,[WndWidth]
  1311.         sub     ebx,[FillWidth]
  1312.         sub     ebx,5-1
  1313.         shl     ebx,16
  1314.         mov     bx,word [FillWidth]
  1315.         mov     ecx,[SkinH-2]
  1316.         mov     cx,word [WndHeight]
  1317.         sub     cx,word [SkinH]
  1318.         sub     cx,5-1
  1319.         int     40h
  1320. @@:
  1321.         cmp     [FillHeight],0
  1322.         jz      @F
  1323.         xor     edx,edx
  1324.         mov     ebx,50000h
  1325.         mov     bx,word [WndWidth]
  1326.         sub     ebx,9
  1327.         mov     ecx,[WndHeight]
  1328.         sub     ecx,[FillHeight]
  1329.         sub     ecx,5-1
  1330.         shl     ecx,16
  1331.         mov     cx,word [FillHeight]
  1332.         int     40h
  1333. @@:
  1334.         call    DrawImage
  1335.         mov     al,SF_PUT_IMAGE_EXT
  1336.         mov     ebx,[MemForImage]
  1337.         test    ebx,ebx
  1338.         jz      @F
  1339.         mov     ecx,[CurWidth]
  1340.         imul    ecx,FontWidth*10000h
  1341.         mov     cx,word [CurHeight]
  1342.         imul    cx,FontHeight
  1343.         mov     edx,[SkinH]
  1344.         add     edx,5*10000h
  1345.         mov     esi,8
  1346.         mov     edi,ConsoleColors
  1347.         xor     ebp,ebp
  1348.         int     40h
  1349. @@:
  1350.         mov     al,SF_REDRAW
  1351.         push    SSF_END_DRAW
  1352.         pop     ebx
  1353.         int     40h
  1354. .SkipDraw:
  1355.         ret
  1356.  
  1357. align 16
  1358. DrawImage:
  1359.         mov     [bMemForImageValidData],byte 1
  1360.         cmp     [MemForImage],0
  1361.         jnz     .Allocated
  1362. ; allocate memory for image
  1363.         mov     ecx,[CurWidth]
  1364.         imul    ecx,[CurHeight]
  1365.         imul    ecx,FontWidth*FontHeight
  1366.         call    PGAlloc
  1367.         test    eax,eax
  1368. ifz     ret
  1369.         mov     [MemForImage],eax
  1370.         mov     [bMemForImageValidData],byte 0
  1371. .Allocated:
  1372.         push    ebp
  1373.         and     [MaxX],0
  1374.         or      [MinX],-1
  1375.         and     [MaxY],0
  1376.         or      [MinY],-1
  1377.         mov     eax,[CursorY]
  1378.         mul     [CurWidth]
  1379.         add     eax,[CursorX]
  1380.         add     eax,eax
  1381.         add     eax,ConsoleDataPtr
  1382.         xchg    [CurCursorPos],eax
  1383.         mov     [OldCursorPos],eax
  1384.         mov     edi,[MemForImage]
  1385.         mov     esi,ConsoleDataPtr
  1386.         mov     ecx,[CurHeight]
  1387. .LH:
  1388.         push    ecx
  1389.         mov     ecx,[CurWidth]
  1390. .LW:
  1391.         push    ecx
  1392.         mov     eax,[CurWidth]
  1393.         imul    eax,[CurHeight]
  1394.         mov     ebx,[esi]
  1395.         cmp     [bMemForImageValidData],0
  1396.         jz      @F
  1397.         cmp     esi,[CurCursorPos]
  1398.         jz      @F
  1399.         cmp     esi,[OldCursorPos]
  1400.         jz      @F
  1401.         cmp     bx,[eax*2+esi]
  1402.         jnz     @F
  1403.         inc     esi
  1404.         inc     esi
  1405.         jmp     .SkipSymbol
  1406. @@:
  1407.         mov     [eax*2+esi],bx
  1408.         cmp     ecx,[MinX]
  1409.         ja      @F
  1410.         mov     [MinX],ecx
  1411. @@:
  1412.         cmp     ecx,[MaxX]
  1413.         jb      @F
  1414.         mov     [MaxX],ecx
  1415. @@:
  1416.         mov     eax,[esp+4]
  1417.         mov     [MinY],eax
  1418.         cmp     eax,[MaxY]
  1419.         jb      @F
  1420.         mov     [MaxY],eax
  1421. @@:
  1422.         push    edi
  1423.         xor     eax,eax
  1424.         mov     al,[esi+1]
  1425.         and     al,0xF
  1426.         mov     ebx,eax
  1427.         mov     al,[esi+1]
  1428.         shr     al,4
  1429.         mov     ebp,eax
  1430.         sub     ebx,ebp
  1431.         lodsb
  1432.         inc     esi
  1433. if FontWidth > 8
  1434.         lea     edx,[eax+eax+Font]
  1435. else
  1436.         lea     edx,[eax+Font]
  1437. end if
  1438. .SH:
  1439.         mov     ecx,[edx]
  1440. repeat FontWidth
  1441.         shr     ecx,1
  1442.         sbb     eax,eax
  1443.         and     eax,ebx
  1444.         add     eax,ebp
  1445.         mov     [edi+%-1],al
  1446. end repeat
  1447.         mov     eax,[CurWidth]
  1448. if FontWidth = 6
  1449.         lea     eax,[eax*2+eax]
  1450.         lea     edi,[edi+eax*2]
  1451. else if FontWidth = 7
  1452.         lea     edi,[edi+eax*8]
  1453.         sub     edi,eax
  1454. else if FontWidth = 8
  1455.         lea     edi,[edi+eax*8]
  1456. else if FontWidth = 9
  1457.         lea     edi,[edi+eax*8]
  1458.         add     edi,eax
  1459. else if FontWidth = 10
  1460.         lea     eax,[eax*4+eax]
  1461.         lea     edi,[edi+eax*2]
  1462. else
  1463. Unknown FontWidth Value!
  1464. end if
  1465. if FontWidth > 8
  1466.         add     edx,256*2
  1467.         cmp     edx,Font+256*2*FontHeight
  1468. else
  1469.         add     edx,256
  1470.         cmp     edx,Font+256*FontHeight
  1471. end if
  1472.         jb      .SH
  1473.         pop     edi
  1474. .SkipSymbol:
  1475.         pop     ecx
  1476.         add     edi,FontWidth
  1477.         dec     ecx
  1478.         jnz     .LW
  1479.         mov     eax,[CurWidth]
  1480.         imul    eax,(FontHeight-1)*FontWidth
  1481.         add     edi,eax
  1482.         pop     ecx
  1483.         dec     ecx
  1484.         jnz     .LH
  1485. ; cursor
  1486.         mov     eax,[CursorY]
  1487.         inc     eax
  1488.         jz      .NoCursor
  1489.         mul     [CurWidth]
  1490.         imul    eax,FontHeight*FontWidth
  1491.         mov     edx,[CursorX]
  1492.         inc     edx
  1493.         imul    edx,FontWidth
  1494.         add     eax,edx
  1495.         add     eax,[MemForImage]
  1496.         mov     edx,[CurWidth]
  1497.         imul    edx,FontWidth
  1498.         neg     edx
  1499.         mov     ecx,[CursorSize]
  1500. .CursorLoop:
  1501.         push    ecx
  1502.         mov     ecx,FontWidth
  1503.         add     eax,edx
  1504.         push    eax
  1505. @@:
  1506.         xor     byte [eax-1],7
  1507.         sub     eax,1
  1508.         loop    @B
  1509.         pop     eax
  1510.         pop     ecx
  1511.         loop    .CursorLoop
  1512. .NoCursor:
  1513.         cmp     [MinY],-1
  1514.         jz      .NoDraw
  1515.         mov     ecx,[CurWidth]
  1516.         mov     ebx,[CurHeight]
  1517.         mov     eax,ebx
  1518.         sub     ebx,[MaxY]
  1519.         sub     eax,[MinY]
  1520.         sub     eax,ebx
  1521.         inc     eax
  1522.         imul    ebp,eax,FontHeight
  1523.         mov     edx,ecx
  1524.         sub     edx,[MaxX]
  1525.         imul    edx,FontWidth
  1526.         mov     eax,edx
  1527.         shl     edx,16
  1528.         imul    dx,bx,FontHeight
  1529.         imul    ebx,[CurWidth]
  1530.         mov     ecx,[MaxX]
  1531.         sub     ecx,[MinX]
  1532.         inc     ecx
  1533.         imul    ecx,FontWidth*10000h
  1534.         add     ecx,ebp
  1535.         imul    ebx,FontWidth*FontHeight
  1536.         add     ebx,[MemForImage]
  1537.         add     ebx,eax
  1538.         add     edx,[SkinH]
  1539.         add     edx,5*10000h
  1540.         imul    esi,[CurWidth],FontWidth
  1541.         mov     ebp,ecx
  1542.         shr     ebp,16
  1543.         sub     esi,ebp
  1544.         mov     ebp,esi
  1545.         push    SF_PUT_IMAGE_EXT
  1546.         pop     eax
  1547.         mov     edi,ConsoleColors
  1548.         push    8
  1549.         pop     esi
  1550.         int     40h
  1551. .NoDraw:
  1552.         pop     ebp
  1553.         ret
  1554. even 4
  1555. Redraw:
  1556.         mov     al,SF_THREAD_INFO
  1557.         mov     ebx,ProcInfo
  1558.         or      ecx,-1
  1559.         int     40h
  1560. ; test if rolled up
  1561. ; height of rolled up window is [skinh]+3
  1562.         mov     eax,[ebx+46]
  1563.         sub     eax,[SkinH]
  1564.         cmp     eax,5
  1565.         ja      @F
  1566.         mov     al,SF_REDRAW
  1567.         push    SSF_BEGIN_DRAW
  1568.         pop     ebx
  1569.         int     0x40
  1570.         xor     eax,eax
  1571. ; ebx, ecx, edi are ignored by function 0 after first redraw
  1572.         mov     edx,0x53000000
  1573.         int     0x40
  1574.         mov     al,SF_REDRAW
  1575.         inc     ebx
  1576.         int     0x40
  1577.         jmp     WaitEvent
  1578. @@:
  1579.         xor     ecx,ecx
  1580.         mov     eax,[ebx+42]
  1581.         mov     [WndWidth],eax
  1582.         sub     eax,5*2-1
  1583.         jae     @F
  1584.         xor     eax,eax
  1585. @@:
  1586.         cdq
  1587.         mov     esi,FontWidth
  1588.         div     esi
  1589.         cmp     eax,MinWidth
  1590.         jae     @F
  1591.         mov     al,MinWidth
  1592.         mov     ch,1
  1593. @@:
  1594.         cmp     eax,MaxWidth
  1595.         jbe     @F
  1596.         mov     eax,MaxWidth
  1597.         mov     ch,1
  1598. @@:
  1599.         cmp     eax,[CurWidth]
  1600.         mov     [CurWidth],eax
  1601.         setnz   cl
  1602.         or      cl,ch
  1603.         test    edx,edx
  1604.         mov     [FillWidth],edx
  1605.         setnz   ch
  1606.         mov     eax,[ebx+46]
  1607.         mov     [WndHeight],eax
  1608.         sub     eax,[SkinH]
  1609.         sub     eax,5-1
  1610.         jns     @F
  1611.         xor     eax,eax
  1612. @@:
  1613.         cdq
  1614.         mov     esi,FontHeight
  1615.         div     esi
  1616.         cmp     eax,MinHeight
  1617.         jae     @F
  1618.         mov     al,MinHeight
  1619.         mov     cl,1
  1620. @@:
  1621.         cmp     eax,MaxHeight
  1622.         jbe     @F
  1623.         mov     eax,MaxHeight
  1624.         mov     cl,1
  1625. @@:
  1626.         mov     [FillHeight],edx
  1627.         cmp     eax,[CurHeight]
  1628.         mov     [CurHeight],eax
  1629.         jnz     .ReSize
  1630.         test    cl,cl
  1631.         jnz     .ReSize
  1632.         test    edx,edx
  1633.         setnz   cl
  1634.         or      cl,ch
  1635.         jz      @F
  1636.         test    byte [ebx+70],1
  1637.         jnz     @F
  1638. .ReSize:
  1639.         push    SF_CHANGE_WINDOW
  1640.         pop     eax
  1641.         or      ebx,-1
  1642.         or      ecx,-1
  1643.         mov     edx,[CurWidth]
  1644.         imul    edx,FontWidth
  1645.         add     edx,5*2-1
  1646.         mov     esi,[CurHeight]
  1647.         imul    esi,FontHeight
  1648.         add     esi,[SkinH]
  1649.         add     esi,5-1
  1650.         int     40h
  1651. .ReSizeDraw:
  1652.         mov     ecx,[MemForImage]
  1653.         call    PGFree
  1654.         and     [MemForImage],0
  1655.         call    InitConsole
  1656.         call    InitCoords
  1657.         jmp     WaitEvent
  1658. @@:     mov     [DoDraw],1
  1659.         call    DrawWindow
  1660.         jmp     WaitEvent
  1661.  
  1662. even 4
  1663. Start:
  1664.         xor     eax,eax
  1665.         mov     edi,NeedZeroStart
  1666.         mov     ecx,(NeedZeroEnd-NeedZeroStart+3)/4
  1667.         rep     stosd
  1668.  
  1669.         call    DetectCPU
  1670.         mov     [CPUType],dl
  1671.         call    DetectFPU
  1672.         mov     [FPUType],al
  1673.  
  1674.         cmp     [CPUType],5
  1675.         jb      @F
  1676.         xor     eax,eax
  1677.         cpuid
  1678.         mov     edi,MsgXMMX+4
  1679.         mov     [edi+0],ebx
  1680.         mov     [edi+4],edx
  1681.         mov     [edi+8],ecx
  1682.         cmp     eax,1
  1683.         jl      .L1
  1684.         xor     eax,eax
  1685.         inc     eax
  1686.         cpuid
  1687.         xchg    eax,edx
  1688.         jmp     .L2
  1689. .L1:    xor     eax,eax
  1690. .L2:    test    eax,00800000h   ; CPU have MMX?
  1691.         setnz   [MMXType]
  1692.         test    eax,02000000h   ; CPU have SSE?
  1693.         setnz   [XMMType]
  1694.       @@:
  1695.  
  1696.         push    SF_SYS_MISC
  1697.         pop     eax
  1698.         push    SSF_HEAP_INIT
  1699.         pop     ebx
  1700.         int     40h
  1701.  
  1702.         call    InitCmdHistBuffer
  1703.         call    InitDefault
  1704.  
  1705.         call    InitCoords
  1706.         call    ShowImage
  1707.  
  1708.         ; set event mask - default events and debugging events
  1709.         mcall   40,EVM_REDRAW or EVM_KEY or EVM_BUTTON or EVM_DEBUG
  1710.         ; set debug messages buffer
  1711.         mov     ecx,DbgBufSize
  1712.         mov     dword [ecx],256
  1713.         xor     ebx,ebx
  1714.         mov     [ecx+4],ebx
  1715.         mov     al,69
  1716.         mcall
  1717.  
  1718.         call    ShowImage
  1719.  
  1720. WaitEvent:
  1721.         push    SF_WAIT_EVENT
  1722.         pop     eax
  1723.         int     40h
  1724.  
  1725.         cmp     al,9
  1726.         jz      DebugMsg
  1727.         dec     eax
  1728.         jz      Redraw
  1729.         dec     eax
  1730.         jz      Key
  1731.         sub     eax,4
  1732.         jz      Mouse
  1733. ; button - we have only one button, close
  1734. ;-----------------------------------------------------------------------------
  1735. ;                                Quit event
  1736. OnQuit:
  1737.         or      eax,-1
  1738.         int     40h
  1739. Key:
  1740.         mov     al,SF_KEYBOARD
  1741.         push    SSF_GET_CONTROL_KEYS
  1742.         pop     ebx
  1743.         int     0x40
  1744.         and     eax,0x3F
  1745.         mov     [CtrlState],al
  1746.  
  1747.         mov     al,SF_GET_KEY
  1748.         int     40h
  1749.         test    al,al
  1750.         jnz     WaitEvent
  1751.  
  1752.         shr     eax,8
  1753.  
  1754.         cmp     ah,5Dh
  1755. ifz     call    DumpScreen
  1756.  
  1757.         cmp     [DebuggeePID],0
  1758.         jz      DoCommandLine
  1759.         cmp     [CmdLineActive],0
  1760.         jnz     GetCommandLine
  1761.  
  1762.         jmp     WinSwitch
  1763.  
  1764. F7:     cmp     [DebuggeePID],0
  1765.         jz      .No
  1766.         call    OnStep
  1767.     .No:jmp     WaitEvent
  1768.  
  1769. F8:     cmp     [DebuggeePID],0
  1770.         jz      F7.No
  1771.         call    OnProceed
  1772.         jmp     F7.No
  1773.  
  1774. even 16
  1775. Mouse:
  1776. if 0
  1777.         mov     eax,SF_MOUSE_GET
  1778.         mov     ebx,SSF_BUTTON_EXT
  1779.         int     0x40
  1780.         mov     byte [MouseState],1
  1781.         bt      eax,24 ;left but. double click
  1782.         jc      @F
  1783.         mov     byte [MouseState],0
  1784.         bt      eax,8 ;left but. down
  1785.         jc      @F
  1786.         jmp     WaitEvent
  1787. @@:
  1788.         mov     eax,SF_MOUSE_GET
  1789.         mov     ebx,SSF_WINDOW_POSITION
  1790.         int     0x40
  1791. end if
  1792.         jmp     WaitEvent
  1793.  
  1794. DumpScreen:
  1795.         pushad
  1796.         mov     dword [DumpName+4],'0000'
  1797. .1:
  1798.         mov     [DumpBlock.Func],SSF_GET_INFO
  1799.         mcall   70,DumpBlock
  1800.         or      eax,eax
  1801.         jnz     .2
  1802.         inc     byte [DumpName+7]
  1803.         cmp     byte [DumpName+7],'9'
  1804.         jbe     .1
  1805.         mov     byte [DumpName+7],'0'
  1806.         inc     byte [DumpName+6]
  1807.         cmp     byte [DumpName+6],'9'
  1808.         jbe     .1
  1809.         mov     byte [DumpName+6],'0'
  1810.         popad
  1811.         ret
  1812. .2:     mov     [DumpBlock.Func],SSF_CREATE_FILE
  1813.         mcall   70,DumpBlock
  1814.         or      eax,eax
  1815.         jnz     .Err
  1816.         mov     ebx,[CurHeight]
  1817.         mov     esi,ConsoleDataPtr
  1818.         mov     edi,ConsoleDataOld
  1819. .3:     mov     ecx,[CurWidth]
  1820. .4:     mov     al,[rsi]
  1821.         test    al,al
  1822.         jz      .5
  1823.         cmp     al,0Ah
  1824.         jz      .5
  1825.         cmp     al,0Dh
  1826.         jz      .5
  1827.         cmp     al,10h
  1828.         jb      .X
  1829.         jmp     .6
  1830. .5:     mov     al,20h
  1831.         jmp     .6
  1832. .X:     mov     al,'.'
  1833. .6:     mov     [rdi],al
  1834.         add     esi,2
  1835.         inc     edi
  1836.         loop    .4
  1837.         mov     byte [rdi],13
  1838.         inc     edi
  1839.         dec     ebx
  1840.         jnz     .3
  1841.         mov     ecx,[CurWidth]
  1842.         inc     ecx
  1843.         imul    ecx,[CurHeight]
  1844.         mov     [DumpBlock.Size],ecx
  1845.         mov     [DumpBlock.Func],SSF_WRITE_FILE
  1846.         mcall   70,DumpBlock
  1847. .Err:   popad
  1848.         ret
  1849.  
  1850. AfterGoException:
  1851.         push    eax
  1852.         mov     eax,[TempBreak]
  1853.         dec     eax
  1854.         push    esi
  1855.         call    EnableBreakPoint
  1856.     ; in any case, clear TF and RF
  1857.         call    GetNewContext
  1858.         and     [_EFL],not 10100h       ; clear TF,RF
  1859.         call    SetContext
  1860.         xor     edx,edx
  1861.         mov     [TempBreak],edx
  1862.         xchg    dl,[bAfterGo]
  1863.         pop     esi
  1864.         pop     eax
  1865.         cmp     dl,2
  1866.         jnz     @F
  1867.         lodsd
  1868.         push    esi
  1869.         call    GetDump
  1870.         jmp     Exception.Done
  1871.     @@:
  1872.         test    eax,eax
  1873.         jz      .NotInt1
  1874.     ; if exception is result of single step, simply ignore it and continue
  1875.         test    dword [esi],0xF
  1876.         jnz     DbgMsgStart.5
  1877.         lodsd
  1878.         push    esi
  1879.         mov     esi,OldContext
  1880.         mov     edi,Context
  1881.         mov     ecx,28h/4
  1882.         rep     movsd
  1883.         call    DoResume
  1884.         jmp     DbgMsgEnd
  1885.     .NotInt1:
  1886.     ; in other case, work as without temp_break
  1887.         lodsd
  1888.         push    esi
  1889.         push    eax
  1890.         jmp     Exception.4
  1891.  
  1892.     .NoTour:
  1893.  
  1894. DebugMsg:
  1895.         neg     [DbgBufSize]
  1896.         mov     esi,DbgBuf
  1897. DbgMsgStart:
  1898.         lodsd
  1899.         add     esi,4
  1900.         dec     eax
  1901.         jz      Exception
  1902.         dec     eax
  1903.         jz      Terminated
  1904.         dec     eax
  1905.         jnz     DbgNotify
  1906.  
  1907.         mov     [bSuspended],1
  1908.         cmp     [bAfterGo],0
  1909.         jnz     AfterGoException
  1910.         push    esi
  1911.         call    GetNewContext
  1912.         and     [_EFL],not 10100h       ; clear TF,RF
  1913.         call    SetContext
  1914.         pop     esi
  1915.     .5:
  1916.         push    esi
  1917.         call    GetDump
  1918.         pop     esi
  1919.         lodsd
  1920.         xor     ecx,ecx
  1921.     .6:
  1922.         bt      eax,ecx
  1923.         jnc     .7
  1924.         mov     ebx,[DrXBreak+ecx*4]
  1925.         test    ebx,ebx
  1926.         jz      .7
  1927.         pushad
  1928.         dec     ebx
  1929.         push    ebx
  1930.         mov     esi,aBreakStop
  1931.         call    PutMessageNoDraw
  1932.         popad
  1933.     .7:
  1934.         inc     ecx
  1935.         cmp     cl,4
  1936.         jb      .6
  1937.         push    esi
  1938.         jmp     Exception.DoneDraw
  1939.  
  1940. DbgNotify:
  1941.         int3
  1942.         add     esi,32
  1943.         push    esi
  1944.         jmp     DbgMsgEnd
  1945.  
  1946. Terminated:
  1947.         push    esi
  1948.         mov     esi,TerminatedMsg
  1949.         call    PutMessage
  1950.         and     [DebuggeePID],0
  1951.         and     [TempBreak],0
  1952.         mov     [bAfterGo],0
  1953.         xor     eax,eax
  1954.         mov     ecx,BreakPointsN*6/4+4
  1955.         mov     edi,BreakPoints
  1956.         rep     stosd
  1957.         cmp     [bReload],1
  1958.         sbb     [bReload],-1
  1959.         jnz     Exception.Done
  1960.         call    FreeSymbols
  1961.         jmp     Exception.Done
  1962.  
  1963. Exception:
  1964.         mov     [bSuspended],1
  1965.         cmp     [bAfterGo],0
  1966.         jnz     AfterGoException
  1967.         lodsd
  1968.         push    esi
  1969.         push    eax
  1970.         call    GetNewContext
  1971.         and     [_EFL],not 10100h       ; clear TF,RF
  1972.         call    SetContext
  1973.     .4:
  1974.         call    GetDump
  1975.         pop     eax
  1976.     ; int3 command generates exception 0x0D, #GP
  1977.         push    eax
  1978.         cmp     al,0x0D
  1979.         jnz     .NotDbg
  1980.     ; check for 0xCC byte at eip
  1981.         push    0
  1982.         mcall   69,6,[DebuggeePID],1,[_EIP],esp
  1983.         pop     eax
  1984.         cmp     al,0xCC
  1985.         je      .Int3
  1986.     ; check for 0xCD03 word at eip
  1987.         push    0
  1988.         inc     edx
  1989.         mcall   69;,6,[DebuggeePID],2,[_EIP],esp
  1990.         pop     eax
  1991.         cmp     ax,0x03CD
  1992.         jne     .NotDbg
  1993.         mov     eax,[_EIP]
  1994.         inc     [_EIP]
  1995.         inc     [_EIP]
  1996.         jmp     .UserINT3
  1997.     .Int3:
  1998.     ; this is either dbg breakpoint or int3 cmd in debuggee
  1999.         mov     eax,[_EIP]
  2000.         call    FindEnabledBreakPoint
  2001.         jnz     .UserINT3
  2002.     ; dbg breakpoint; clear if one-shot
  2003.         pop     ecx
  2004.         push    eax
  2005.         mov     esi,aBreakStop
  2006.         test    byte [edi+4],4
  2007.         jz      .PutMsgEAX
  2008.         pop     ecx
  2009.         call    ClearBreakPoint
  2010.         jmp     .Done
  2011.  
  2012.     .UserINT3:
  2013.         mov     eax,[_EIP]
  2014.         inc     [_EIP]
  2015.     .UserINT3_:
  2016.         pop     ecx
  2017.         push    eax
  2018.         call    SetContext
  2019.         mov     esi,aUserBreak
  2020.         jmp     .PutMsgEAX
  2021.  
  2022.     .NotDbg:
  2023.         pop     eax
  2024.         push    eax
  2025.         push    eax
  2026.         mov     esi,aException
  2027.         call    PutMessageNoDraw
  2028.         pop     eax
  2029.  
  2030.         cmp     al,16
  2031.         ja      .Suspended
  2032.         mov     esi,[MsgFaultSel+eax*4]
  2033.     .ShowMess:
  2034.         call    PutMessageNoDraw
  2035.     .Suspended:
  2036.         mov     esi,aSuspended
  2037.     .PutMsgEAX:
  2038.         call    PutMessageNoDraw
  2039.     .DoneDraw:
  2040.         call    DrawMessages
  2041.     .Done:
  2042.         mcall   18,3,[DbgWnd]   ; activate dbg window
  2043.         call    ShowImage
  2044.  
  2045. DbgMsgEnd:
  2046.         pop     esi
  2047.         mov     ecx,[DbgBufLen]
  2048.         add     ecx,DbgBuf
  2049.         cmp     esi,ecx
  2050.         jnz     DbgMsgStart
  2051.         and     [DbgBufLen],0
  2052.         neg     [DbgBufSize]
  2053.         cmp     [bReload],2
  2054.         jnz     @F
  2055.         mov     [bReload],0
  2056.         call    DoReLoad
  2057.     @@:
  2058.         jmp     WaitEvent
  2059.  
  2060. ;-----------------------------------------------------------------------------
  2061. ;                        Add breakpoint
  2062. ; in: EAX = address; BL = flags
  2063. ; out: CF = 1 => error
  2064. ;      CF = 0 and EAX = breakpoint number
  2065. AddBreakPoint:
  2066.         xor     ecx,ecx
  2067.         mov     edi,BreakPoints
  2068.     @@:
  2069.         test    byte [edi+4],1
  2070.         jz      .Found
  2071.         add     edi,6
  2072.         inc     ecx
  2073.         cmp     ecx,BreakPointsN
  2074.         jb      @B
  2075.         stc
  2076.         ret
  2077.     .Found:
  2078.         stosd
  2079.         xchg    eax,ecx
  2080.         mov     [edi],bl
  2081.         test    bl,2
  2082.         jnz     @F
  2083.         or      byte [edi],2
  2084.         push    eax
  2085.         call    EnableBreakPoint
  2086.         pop     eax
  2087.     @@:
  2088.         clc
  2089.         ret
  2090. ;-----------------------------------------------------------------------------
  2091. ;                         Remove breakpoint
  2092. ClearBreakPoint:
  2093.         cmp     eax,BreakPointsN
  2094.         jae     .Ret
  2095.         mov     ecx,4
  2096.         inc     eax
  2097.     .1:
  2098.         cmp     [DrXBreak-4+ecx*4],eax
  2099.         jnz     @F
  2100.         and     [DrXBreak-4+ecx*4],0
  2101.     @@:
  2102.         loop    .1
  2103.         dec     eax
  2104.         push    eax
  2105.         add     eax,eax
  2106.         lea     edi,[BreakPoints+eax+eax*2+4]
  2107.         test    byte [edi],1
  2108.         pop     eax
  2109.         jz      .Ret
  2110.         push    edi
  2111.         call    DisableBreakPoint
  2112.         pop     edi
  2113.         mov     byte [edi],0
  2114.     .Ret:
  2115.         ret
  2116. ;-----------------------------------------------------------------------------
  2117. ;                          Disable breakpoint
  2118. DisableBreakPoint:
  2119.         cmp     eax,BreakPointsN
  2120.         jae     .Ret
  2121.         add     eax,eax
  2122.         lea     edi,[BreakPoints+eax+eax*2+5]
  2123.         test    byte [edi-1],1
  2124.         jz      .Ret
  2125.         test    byte [edi-1],2
  2126.         jnz     .Ret
  2127.         or      byte [edi-1],2
  2128.         test    byte [edi-1],8
  2129.         jnz     .DR
  2130.         push    esi
  2131.         mcall   69,7,[DebuggeePID],1,[edi-5]
  2132.         pop     esi
  2133.     .Ret:
  2134.         ret
  2135.     .DR:
  2136.         mov     dl,[edi]
  2137.         shr     dl,6
  2138.         mov     dh,80h
  2139.         mcall   69,9,[DebuggeePID]
  2140.         ret
  2141. ;-----------------------------------------------------------------------------
  2142. ;                           Enable breakpoint
  2143. EnableBreakPoint:
  2144.         push    esi
  2145.         cmp     eax,BreakPointsN
  2146.         jae     .Ret
  2147.         add     eax,eax
  2148.         lea     edi,[BreakPoints+eax+eax*2+5]
  2149.         test    byte [edi-1],1
  2150.         jz      .Ret
  2151.         test    byte [edi-1],2
  2152.         jz      .Ret
  2153.         and     byte [edi-1],not 2
  2154.         test    byte [edi-1],8
  2155.         jnz     .DR
  2156.         mcall   69,6,[DebuggeePID],1,[edi-5]
  2157.         dec     eax
  2158.         jnz     .Err
  2159.         push    0xCC
  2160.         mov     edi,esp
  2161.         inc     ebx
  2162.         mcall   69
  2163.         pop     eax
  2164.     .Ret:
  2165.         pop     esi
  2166.         ret
  2167.     .Err:
  2168.         or      byte [edi-1],2
  2169.         mov     esi,aBreakErr
  2170.         call    PutMessage
  2171.         pop     esi
  2172.         ret
  2173.     .DR:
  2174.         mov     esi,[edi-5]
  2175.         mov     dl,[edi]
  2176.         shr     dl,6
  2177.         mov     dh,[edi]
  2178.         and     dh,0xF
  2179.         mcall   69,9,[DebuggeePID]
  2180.         test    eax,eax
  2181.         jnz     .Err
  2182.         pop     esi
  2183.         ret
  2184. ;-----------------------------------------------------------------------------
  2185. ;                             Find breakpoint
  2186. FindBreakPoint:
  2187.         xor     ecx,ecx
  2188.         xchg    eax,ecx
  2189.         mov     edi,BreakPoints
  2190.     @@:
  2191.         test    byte [edi+4],1
  2192.         jz      .Cont
  2193.         test    byte [edi+4],8
  2194.         jnz     .Cont
  2195.         cmp     [edi],ecx
  2196.         jz      .Found
  2197.     .Cont:
  2198.         add     edi,6
  2199.         inc     eax
  2200.         cmp     eax,BreakPointsN
  2201.         jb      @B
  2202.         or      eax,-1
  2203.     .Found:
  2204.         ret
  2205. ;-----------------------------------------------------------------------------
  2206. ;
  2207. FindEnabledBreakPoint:
  2208.         xor     ecx,ecx
  2209.         xchg    eax,ecx
  2210.         mov     edi,BreakPoints
  2211.     @@:
  2212.         test    byte [edi+4],1
  2213.         jz      .Cont
  2214.         test    byte [edi+4],2 or 8
  2215.         jnz     .Cont
  2216.         cmp     [edi],ecx
  2217.         jz      .Found
  2218.     .Cont:
  2219.         add     edi,6
  2220.         inc     eax
  2221.         cmp     eax,BreakPointsN
  2222.         jb      @B
  2223.         or      eax,-1
  2224.     .Found:
  2225.         ret
  2226.  
  2227. GetDump:
  2228. if 0
  2229.         mov     edi,DumpData
  2230.         mov     esi,[edi-4]
  2231.         mov     edx,DUMP_HEIGHT*10h
  2232.         mov     ecx,edx
  2233.         xor     eax,eax
  2234.         push    edi
  2235.         rep     stosb
  2236.         pop     edi
  2237.         mcall   69,6,[DebuggeePID]
  2238.         cmp     eax,-1
  2239.         jnz     @F
  2240.         mov     esi,ReadMemErr
  2241.         call    PutMessage
  2242.         xor     eax,eax
  2243.     @@:
  2244.         mov     [edi-8],eax
  2245. ; in: edi=buffer,eax=size,esi=address
  2246. RestoreFromBreaks:
  2247.         mov     ebx,BreakPoints
  2248.     @@:
  2249.         test    byte [ebx+4],1
  2250.         jz      .Cont           ; ignore invalid
  2251.         test    byte [ebx+4],2 or 8
  2252.         jnz     .Cont           ; ignore disabled and memory breaks
  2253.         mov     ecx,[ebx]
  2254.         sub     ecx,esi
  2255.         cmp     ecx,eax
  2256.         jae     .Cont
  2257.         mov     dl,[ebx+5]
  2258.         mov     [edi+ecx],dl
  2259.     .Cont:
  2260.         add     ebx,6
  2261.         cmp     ebx,BreakPoints+BreakPointsN*6
  2262.         jb      @B
  2263. end if
  2264.         ret
  2265.  
  2266. ; in: edi=buffer,esi=address
  2267. RestoreFromBreaksOne:
  2268.         mov     ebx,BreakPoints
  2269.     @@:
  2270.         test    byte [ebx+4],1
  2271.         jz      .Cont           ; ignore invalid
  2272.         test    byte [ebx+4],2 or 8
  2273.         jnz     .Cont           ; ignore disabled and memory breaks
  2274.         mov     ecx,[ebx]
  2275.         sub     ecx,esi
  2276.         cmp     ecx,1
  2277.         jae     .Cont
  2278.         mov     dl,[ebx+5]
  2279.         mov     [edi+ecx],dl
  2280.         jmp     .Exit
  2281.     .Cont:
  2282.         add     ebx,6
  2283.         cmp     ebx,BreakPoints+BreakPointsN*6
  2284.         jb      @B
  2285.     .Exit:
  2286.         ret
  2287.  
  2288. GetCommandLine:
  2289.         cmp     ah,0x01
  2290.         jz      .Esc
  2291.         cmp     al,8
  2292.         jz      .Backspace
  2293.         cmp     al,0xB0
  2294.         jz      .Left
  2295.         cmp     al,0xB3
  2296.         jz      .Right
  2297.         cmp     al,0x0D
  2298.         jz      .Enter
  2299.         cmp     al,0xB6
  2300.         jz      .Del
  2301.         cmp     al,0xB4
  2302.         jz      .Home
  2303.         cmp     al,0xB5
  2304.         jz      .End
  2305.         cmp     al,0xB1
  2306.         jz      .Dn
  2307.         cmp     al,0xB2
  2308.         jz      .Up
  2309.         mov     [CmdHistBuffer.TmpLineFlag],0
  2310.         cmp     [CmdLineLen],CMD_WIDTH
  2311.         jae     WaitEvent
  2312.         push    eax
  2313.         call    ClearCmdLineEnd
  2314.         pop     eax
  2315.         mov     edi,CmdLine
  2316.         mov     ecx,[CmdLineLen]
  2317.         add     edi,ecx
  2318.         lea     esi,[edi-1]
  2319.         sub     ecx,[CmdLinePos]
  2320.         std
  2321.         rep     movsb
  2322.         cld
  2323.         stosb
  2324.         inc     [CmdLineLen]
  2325.         call    DrawCmdLineEnd
  2326.         inc     [CmdLinePos]
  2327.         call    DrawCursor
  2328.         jmp     WaitEvent
  2329.  
  2330.  
  2331.     .Esc:
  2332.         xor     eax,eax
  2333.         mov     [CmdLinePos],eax
  2334.         mov     [CmdLineLen],eax
  2335.         mov     [CmdLineActive],al
  2336.         call    DrawCursor
  2337.         jmp     WaitEvent
  2338.  
  2339.     .Backspace:
  2340.         mov     [CmdHistBuffer.TmpLineFlag],0
  2341.         cmp     [CmdLinePos],0
  2342.         jz      WaitEvent
  2343.         dec     [CmdLinePos]
  2344.  
  2345.     .DelChar:
  2346.         mov     [CmdHistBuffer.TmpLineFlag],0
  2347.         call    ClearCmdLineEnd
  2348.         mov     edi,[CmdLinePos]
  2349.         dec     [CmdLineLen]
  2350.         mov     ecx,[CmdLineLen]
  2351.         sub     ecx,edi
  2352.         add     edi,CmdLine
  2353.         lea     esi,[edi+1]
  2354.         rep     movsb
  2355.         call    DrawCmdLineEnd
  2356.         call    DrawCursor
  2357.         jmp     WaitEvent
  2358.  
  2359.     .Del:
  2360.         mov     eax,[CmdLinePos]
  2361.         cmp     eax,[CmdLineLen]
  2362.         jae     WaitEvent
  2363.         jmp     .DelChar
  2364.  
  2365.     .Left:
  2366.         cmp     [CmdLinePos],0
  2367.         jz      WaitEvent
  2368.         call    HideCursor
  2369.         dec     [CmdLinePos]
  2370.         call    DrawCursor
  2371.         jmp     WaitEvent
  2372.  
  2373.     .Right:
  2374.         mov     eax,[CmdLinePos]
  2375.         cmp     eax,[CmdLineLen]
  2376.         jae     WaitEvent
  2377.         call    HideCursor
  2378.         inc     [CmdLinePos]
  2379.         call    DrawCursor
  2380.         jmp     WaitEvent
  2381.  
  2382.     .Home:
  2383.         call    HideCursor
  2384.         and     [CmdLinePos],0
  2385.         call    DrawCursor
  2386.         jmp     WaitEvent
  2387.  
  2388.     .End:
  2389.         call    HideCursor
  2390.         mov     eax,[CmdLineLen]
  2391.         mov     [CmdLinePos],eax
  2392.         call    DrawCursor
  2393.         jmp     WaitEvent
  2394.  
  2395.         .Up:
  2396.                 xor     edx,edx
  2397.                 jmp     .Hist
  2398.         .Dn:
  2399.                 xor     edx,edx
  2400.                 inc     edx
  2401.         .Hist:
  2402.                 cmp     [CmdHistBuffer.TmpLineFlag],1
  2403.                 je      @F
  2404.                 mov     eax,CmdLine
  2405.                 mov     ecx,[CmdLineLen]
  2406.                 mov     byte [eax+ecx],0
  2407.                 call    AddCmdHistTmpLine
  2408.         @@:
  2409.                 test    edx,edx
  2410.                 jnz     .Hist.Next
  2411.                 cmp     [CmdHistBuffer.NFlag],0
  2412.                 jne     @F
  2413.                 call    GetCmdHistLine
  2414.                 inc     [CmdHistBuffer.NFlag]
  2415.                 jmp     .Hist.CPLine
  2416.  
  2417.         @@:
  2418.                 call    PrevCmdHistLine
  2419.                 jc      WaitEvent
  2420.                 call    GetCmdHistLine
  2421.                 inc     [CmdHistBuffer.NFlag]
  2422.                 jmp     .Hist.CPLine
  2423.  
  2424.         .Hist.Next:
  2425.                 cmp     [CmdHistBuffer.NFlag],0
  2426.                 je      WaitEvent
  2427.  
  2428.                 call    NextCmdHistLine
  2429.                 call    GetCmdHistLine
  2430.                 jnc     .Hist.CPLine
  2431.                 call    GetCmdHistTmpLine
  2432.                 mov     [CmdHistBuffer.TmpLineFlag],0
  2433.                 mov     [CmdHistBuffer.NFlag],0
  2434.  
  2435.         .Hist.CPLine:
  2436.  
  2437.                 mov     esi,eax
  2438.                 mov     edi,CmdLine
  2439.                 xor     ecx,ecx
  2440.         @@:
  2441.                 inc     ecx
  2442.                 lodsb
  2443.                 stosb
  2444.                 test    al,al
  2445.                 jnz     @B
  2446.  
  2447.                 dec     ecx
  2448.                 mov     [CmdLinePos],0
  2449.                 call    ClearCmdLineEnd
  2450.                 mov     [CmdLineLen],ecx
  2451.                 mov     [CmdLinePos],ecx
  2452.                 call    DrawCmdLine
  2453.                 call    DrawCursor
  2454.  
  2455.                 jmp     WaitEvent
  2456.  
  2457.         ; We also trying to execute previous command, if empty command_line
  2458.     .Enter:
  2459.         mov     [CmdLineActive],0
  2460.  
  2461.         mov     ecx,[CmdLineLen]
  2462.         test    ecx,ecx
  2463.         jnz     .ExecCur
  2464.         mov     cl,byte [CmdLinePrev]
  2465.         cmp     cl,0
  2466.         jz      WaitEvent
  2467.  
  2468.     .ExecPrev:
  2469.         mov     esi,CmdLinePrev
  2470.         jmp     .Exec
  2471.  
  2472.     .ExecCur:
  2473.         mov     esi,CmdLine
  2474.  
  2475.     .Exec:
  2476.         mov     byte [esi+ecx],0
  2477.  
  2478.         mov     eax,esi
  2479.         call    AddCmdHistLine
  2480.         mov     [CmdHistBuffer.NFlag],0
  2481.  
  2482.         and     [CmdLinePos],0
  2483.         push    esi
  2484.         call    ClearCmdLineEnd
  2485.         call    DrawCursor
  2486.         pop     esi
  2487.         and     [CmdLineLen],0
  2488.         ; skip leading spaces
  2489.         call    GetArg.SkipSpaces
  2490.         cmp     al,0
  2491.         jz      WaitEvent
  2492.         ; now esi points to command
  2493.         push    esi
  2494.         mov     esi,Prompt
  2495.         call    PutMessageNoDraw
  2496.         pop     esi
  2497.         push    esi
  2498.         call    PutMessageNoDraw
  2499. Z1:
  2500.         mov     esi,NewLine
  2501.         call    PutMessage
  2502.         pop     esi
  2503.         push    esi
  2504.         call    GetArg
  2505.         mov     [CurArg],esi
  2506.         pop     edi
  2507.         mov     esi,Commands
  2508.         call    FindCmd
  2509.         mov     eax,aUnknownCommand
  2510.         jc      .X11
  2511.  
  2512.         ; check command requirements
  2513.         ; flags field:
  2514.         ; &1: command may be called without parameters
  2515.         ; &2: command may be called with parameters
  2516.         ; &4: command may be called without loaded program
  2517.         ; &8: command may be called with loaded program
  2518.         mov     eax,[esi+8]
  2519.         mov     ecx,[CurArg]
  2520.         cmp     byte [ecx],0
  2521.         jz      .NoArgs
  2522.         test    byte [esi+16],2
  2523.         jz      .X11
  2524.         jmp     @F
  2525.  
  2526.     .NoArgs:
  2527.         test    byte [esi+16],1
  2528.         jz      .X11
  2529.     @@:
  2530.         cmp     [DebuggeePID],0
  2531.         jz      .NoDebuggee
  2532.         mov     eax,aAlreadyLoaded
  2533.         test    byte [esi+16],8
  2534.         jz      .X11
  2535.         jmp     .X9
  2536.  
  2537.     .NoDebuggee:
  2538.         mov     eax,NeedDebuggee
  2539.         test    byte [esi+16],4
  2540.         jnz     .X9
  2541.     .X11:
  2542.         xchg    esi,eax
  2543.         call    PutMessage
  2544.         ; store cmdline for repeating
  2545.     .X10:
  2546.         mov     esi,CmdLine
  2547.         mov     ecx,[CmdLineLen]
  2548.     @@:
  2549.         or      ecx,ecx
  2550.         jle     .We
  2551.         mov     al,[esi+ecx]
  2552.         mov     [CmdLinePrev+ecx],al
  2553.         dec     ecx
  2554.         jmp     @B
  2555.  
  2556.     .We:
  2557.         mov     [CmdLineLen],0
  2558.         jmp     WaitEvent
  2559.  
  2560.     .X9:
  2561.         call    dword [esi+4]
  2562.         jmp     .X10
  2563.  
  2564. PutMessage:
  2565.         call    PutMessageNoDraw
  2566. DrawMessages:
  2567.         mov     [AfterKey],1
  2568.         call    ShowImage
  2569.         ret
  2570.  
  2571. include "cmdhist.inc"
  2572. include "parser.inc"
  2573. include "message.inc"
  2574.  
  2575. HeaderN db      'SunSys Debugger ver ',VERSION,' - No program loaded',0
  2576. HeaderY db      'SunSys Debugger ver ',VERSION,' - ',60 dup 32,0
  2577. HeaderE:
  2578. ;
  2579. LoadErrMsg      db      'Cannot load program. ',0
  2580. UnkErrMsg       db      'Unknown error code -%4X',10,0
  2581. aCannotLoadFile db      'Cannot load file. ',0
  2582. UnkErrMsg2    db      'Unknown error code %4X.',10,0
  2583. LoadErrMsgs:
  2584.         dd      .1,0,.3,0,.5,.6,0,0,.9,.A,0,0,0,0,0,0
  2585.         dd      0,0,0,0,0,0,0,0,0,0,0,0,0,.1E,.1F,.20
  2586. .1              db      'HD undefined.',10,0
  2587. .3              db      'Unknown FS.',10,0
  2588. .5              db      'File not found.',10,0
  2589. .6              db      'Unexpected EOF.',10,0
  2590. .9              db      'FAT table corrupted.',10,0
  2591. .A              db      'Access denied.',10,0
  2592. .1E             db      'No memory.',10,0
  2593. .1F             db      'Not Menuet/Kolibri executable.',10,0
  2594. .20             db      'Too many processes.',10,0
  2595. LoadSuccMsg     db      'Program loaded successfully! PID=%4X. Use "g" to run.',10,0
  2596. TerminatedMsg   db      'Program terminated.',10,0
  2597. MsgFaultSel     dd  aDivide,aDebug,aNonMask,aUndefined,aOverflow
  2598.                 dd  aBounds,aInvalid,aCoProcessorNA,aDoubleFault
  2599.                 dd  aUndefined,aInvalidTSS,aSegment,aStack
  2600.                 dd  aProtection,aPageFault,aUndefined,aCoProcessor
  2601. aDivide         db      '(Divide error)',10,0
  2602. aDebug          db      '(Single-step/debug exception)',10,0
  2603. aNonMask        db      '(Nonmaskable interrupt)',10,0
  2604. aOverflow       db      '(Overflow)',10,0
  2605. aBounds         db      '(Bounds check)',10,0
  2606. aInvalid        db      '(Invalid opcode)',10,0
  2607. aCoProcessorNA  db      '(Coprocessor not available)',10,0
  2608. aDoubleFault    db      '(Double fault)',10,0
  2609. aUndefined      db      '(Undefined fault)',10,0
  2610. aInvalidTSS     db      '(Invalid TSS)',10,0
  2611. aSegment        db      '(Segment not present)',10,0
  2612. aStack          db      '(Stack fault)',10,0
  2613. aProtection     db      '(General protection fault)',10,0
  2614. aPageFault      db      '(Page fault)',10,0
  2615. aCoProcessor    db      '(Coprocessor error)',10,0
  2616. aSuspended      db      'Suspended',10,0
  2617. aContinued      db      'Continuing',10,0
  2618. aRunningErr     db      'Program is running',10,0
  2619. aException      db      'Debugged program caused an exception %2X. ',0
  2620. aBreakErr       db      'Cannot activate breakpoint, it will be disabled',10,0
  2621. aDuplicateBreakpoint db 'Duplicate breakpoint',10,0
  2622. aInvalidBreak   db      'Invalid breakpoint number',10,0
  2623. aBreakNum       db      '%2X: at %8X',0
  2624. aMemBreak1      db      '%2X: on ',0
  2625. aMemBreak2      db      'read from ',0
  2626. aMemBreak3      db      'access of ',0
  2627. aMemBreak4      db      'byte',0
  2628. aMemBreak5      db      'word',0
  2629. aMemBreak6      db      'dword',0
  2630. aMemBreak7      db      ' at %8X',0
  2631. aOneShot        db      ', one-shot',0
  2632. aDisabled       db      ', disabled',0
  2633. aBreakStop      db      'Breakpoint #%2X',10,0
  2634. aUserBreak      db      'int3 command at %8X',10,0
  2635. ReadMemErr      db      'ERROR: cannot read process memory!!!',10,0
  2636. aBreakpointLimitExceeded db 'Breakpoint limit exceeded',10,0
  2637. aUnknownCommand db      'Unknown command',10,0
  2638. NeedDebuggee    db      'No program loaded. Use "load" command.',10,0
  2639. aAlreadyLoaded  db      'Program is already loaded. Use "terminate" or "detach" commands',10,0
  2640. aParseError     db      'Parse error',10,0
  2641. aDivByZero      db      'Division by 0',10,0
  2642. CalcString      db      '%8X',10,0
  2643. aNoMemory       db      'No memory',10,0
  2644. aSymbolsLoaded  db      'Symbols loaded',10,0
  2645. aUnaligned      db      'Unaligned address',10,0
  2646. aEnabledBreakErr db     'Enabled breakpoints are not allowed',10,0
  2647. aInterrupted    db      'Interrupted',10,0
  2648. aUnpacked       db      'Unpacked successful!',10,0
  2649. OnBeErrMsg      db      'There is already enabled breakpoint on this address',10,0
  2650.  
  2651. DumpPath        db      '/TMP0/1/'
  2652. DumpName        db      'DUMP0000.TXT',0
  2653.  
  2654. even 4
  2655. ConsoleColors   dd      0x000000,0x000080,0x008000,0x008080
  2656.                 dd      0x800000,0x800080,0x808000,0xC0C0C0
  2657.                 dd      0x1D272F,0x0000FF,0x00FF00,0x00FFFF;0x808080,0x0000FF,0x00FF00,0x00FFFF
  2658.                 dd      0xFF0000,0xFF00FF,0xFFFF00,0xFFFFFF
  2659.  
  2660. CurWidth        dd      MinWidth
  2661. CurHeight       dd      MinHeight
  2662. FillWidth       dd      0
  2663. FillHeight      dd      0
  2664.  
  2665. MemForImage     dd      0
  2666.  
  2667. bWasE0          db      0
  2668. CtrlState       db      0
  2669. MouseState      db      0
  2670. bMemForImageValidData   db 0
  2671.  
  2672. bReload         db      0
  2673. bAfterGo        db      0
  2674. bSuspended      db      0
  2675. CodeType        db      32
  2676.  
  2677. DoDraw          db      0
  2678. SymbolSection   db      0
  2679. CmdLineActive   db      0,?
  2680.  
  2681. CursorX         dd      -1
  2682. CursorY         dd      -1
  2683. CursorSize      dd      CursorNormSize
  2684. CurCursorPos    dd      -1
  2685. OldCursorPos    dd      -1
  2686.  
  2687. DebuggeePID     dd      0
  2688.  
  2689. DumpBlock:
  2690. .Func           dd      0
  2691.                 dd      0
  2692.                 dd      0
  2693. .Size           dd      0
  2694.                 dd      ConsoleDataOld
  2695.                 db      0
  2696.                 dd      DumpPath
  2697.  
  2698. FN70LoadBlock:  dd 7
  2699.                 dd 1
  2700. LoadParams      dd 0
  2701.                 dd 0
  2702.                 dd 0
  2703. LoadName:       db 0
  2704.                 rb 255
  2705.  
  2706. FN70ReadBlock:  dd 0
  2707.                 rq 1
  2708.                 dd ?
  2709.                 dd ?
  2710.                 db 0
  2711.                 dd ?
  2712.  
  2713. FN70AttrBlock:  dd 5
  2714.                 dd 0,0,0
  2715.                 dd FileAttr
  2716.                 db 0
  2717.                 dd ?
  2718.  
  2719. IncludeAllGlobals
  2720.  
  2721. DbgWnd          dd      ?
  2722. TempBreak       dd      ?
  2723.  
  2724. WndWidth        dd      ?
  2725. WndHeight       dd      ?
  2726.  
  2727. MinY            dd      ?
  2728. MaxY            dd      ?
  2729. MinX            dd      ?
  2730. MaxX            dd      ?
  2731.  
  2732. Tmp             dd      ?
  2733. SkinH           dd      ?
  2734. StdColors       rd      10
  2735.  
  2736. AppPath         rb      4096
  2737. ProcInfo        rb      1024
  2738.  
  2739. even 16
  2740. ConsoleDataPtr  rw      (MaxWidth+0)*MaxHeight
  2741. even 16
  2742. ConsoleDataOld  rw      (MaxWidth+1)*MaxHeight
  2743.  
  2744. even 16
  2745. NeedZeroStart:
  2746.  
  2747. DbgBufSize      dd      ?
  2748. DbgBufLen       dd      ?
  2749. DbgBuf          rb      256
  2750.  
  2751. FileAttr        rb      40
  2752.  
  2753. even 4
  2754. Context:
  2755. _EIP    dd ?
  2756. _EFL    dd ?
  2757. _EAX    dd ?
  2758. _ECX    dd ?
  2759. _EDX    dd ?
  2760. _EBX    dd ?
  2761. _ESP    dd ?
  2762. _EBP    dd ?
  2763. _ESI    dd ?
  2764. _EDI    dd ?
  2765.  
  2766. _CTX_FLAGS:
  2767.         dd ?
  2768.         dd ?
  2769.  
  2770. _SSE_FLAGS:
  2771.  
  2772. _FCW    dw ?
  2773. _FSW    dw ?
  2774. _FTW    db ?
  2775.         db ?
  2776. _FOP    dw ?
  2777. _FPU_IP dd ?
  2778.         dw ?
  2779.         dw ?
  2780.  
  2781. _FPU_DP dd ?
  2782.         dw ?
  2783.         dw ?
  2784.  
  2785. _MXCSR  dd ?
  2786. _MXCSRM dd ?
  2787.  
  2788. FPU_CONTEXT:
  2789. MMX_CONTEXT:
  2790. _ST0:
  2791. _MM0:   rq 2
  2792. _ST1:
  2793. _MM1:   rq 2
  2794. _ST2:
  2795. _MM2:   rq 2
  2796. _ST3:
  2797. _MM3:   rq 2
  2798. _ST4:
  2799. _MM4:   rq 2
  2800. _ST5:
  2801. _MM5:   rq 2
  2802. _ST6:
  2803. _MM6:   rq 2
  2804. _ST7:
  2805. _MM7:   rq 2
  2806.  
  2807. SSE_CONTEXT:
  2808. _XMM0   rq 2
  2809. _XMM1   rq 2
  2810. _XMM2   rq 2
  2811. _XMM3   rq 2
  2812. _XMM4   rq 2
  2813. _XMM5   rq 2
  2814. _XMM6   rq 2
  2815. _XMM7   rq 2
  2816. CtxEnd:
  2817.  
  2818. OldContext      rb      (CtxEnd-Context)
  2819.  
  2820. Plus = (OldContext-Context)
  2821.  
  2822. StepNum         dd      ?
  2823. ProcNum         dd      ?
  2824. if 0
  2825. DUMP_HEIGHT     = 6                     ; in text lines
  2826. ;
  2827. DumpRead        dd      ?
  2828. DumpPos         dd      ?
  2829. DumpData        rb      DUMP_HEIGHT*10h
  2830. end if
  2831.  
  2832. CmdLine         rb      CMD_WIDTH+1
  2833. CmdLineLen      dd      ?
  2834. CmdLinePos      dd      ?
  2835. CurArg          dd      ?
  2836.  
  2837. CmdLinePrev     rb      CMD_WIDTH+1
  2838.  
  2839. SymbolsFile     rb      260
  2840.  
  2841. PrgNamePtr      dd      ?
  2842. PrgNameLen      dd      ?
  2843.  
  2844. Symbols         dd      ?
  2845. NumSymbols      dd      ?
  2846.  
  2847. CmdHistBuffer:
  2848. .Ptr                    dd      ?
  2849. .Size                   dd      ?
  2850. .LastNodeOffset         dd      ?
  2851. .NewNodeOffset          dd      ?
  2852. .CurNodeOffset          dd      ?
  2853. .TmpLineFlag            db      ?
  2854. .NFlag                  db      ?
  2855.  
  2856. ; breakpoint structure:
  2857. ; dword +0: address
  2858. ; byte +4: flags
  2859. ; bit 0: 1 <=> breakpoint valid
  2860. ; bit 1: 1 <=> breakpoint disabled
  2861. ; bit 2: 1 <=> one-shot breakpoint
  2862. ; bit 3: 1 <=> DRx breakpoint
  2863. ; byte +5: overwritten byte
  2864. ;          for DRx breaks: flags + (index shl 6)
  2865. BreakPointsN = 256
  2866. BreakPoints     rb      BreakPointsN*6
  2867. DrXBreak        rd      4
  2868. ;-----------------------------------------------------------------------------
  2869. CurrentWindow   dd      ?
  2870. CPUXPos         dd      ?               ; coordinates of cursor in windows
  2871. CPUYPos         dd      ?
  2872. CPUXPtr         dd      ?
  2873. MemXPos         dd      ?
  2874. MemYPos         dd      ?
  2875. StkXPos         dd      ?
  2876. StkYPos         dd      ?
  2877. RegXPos         dd      ?
  2878. RegYPos         dd      ?
  2879. RegLDat         dd      ?
  2880. RegXPtr         dd      ?
  2881. CPUType         db      ?
  2882. FPUType         db      ?
  2883. MMXType         db      ?
  2884. XMMType         db      ?
  2885. JumpTaken       db      ?
  2886. AfterKey        db      ?
  2887. ;-----------------------------------------------------------------------------
  2888. TmpB            rb      0
  2889. Temp            dd      ?
  2890. ;-----------------------------------------------------------------------------
  2891. CodeAddr        dd      ?       ;0 order
  2892. RegsAddr        dd      ?       ;1
  2893. DataAddr        dd      ?       ;2
  2894. StckAddr        dd      ?       ;3
  2895. OriginPtr:      rd      2
  2896. AddrBuffer:     rd      30
  2897. ;-----------------------------------------------------------------------------
  2898. NeedZeroEnd:
  2899. ;-----------------------------------------------------------------------------
  2900. BufferI:        rb      1024
  2901. BufferO:        rb      1024
  2902. ;-----------------------------------------------------------------------------
  2903. ; stack
  2904. even 4
  2905.                 rb      32768
  2906. StackTop:
  2907. ;-----------------------------------------------------------------------------
  2908. Mem:
  2909. ;-----------------------------------------------------------------------------
  2910. I_END = UDataStr        ;%v
  2911. ;-----------------------------------------------------------------------------
  2912.