1

さて、ここに私の問題があります。変数をスタックにプッシュした後、ローカル変数用のスペースを作成します。手順から戻る前に、DumpMemを使用してスタックを表示するにはどうすればよいですか?

include irvine32.inc

.data
X   sdword   10, -10, 20, -20, 30, -30, 40, -40

.code
begin:
mov ecx, offset x
push ecx
call StackProcedure

StackProcedure PROC
        push ebp
        mov ebp, esp
        sub esp, 32
        lea esi, [ebp-32]
        mov ecx, 32
L1:     mov BYTE PTR [esi], '*'
        inc esi
        loop L1
        add esp, 32
        pop ebp
        ret
StackProcedure ENDP

finfin:
invoke exitProcess,0
end begin
4

2 に答える 2

1

IrvineDumpMemは、レジスタに3つの値しか必要としません。これらのレジスタのみが接続され、関数が戻ったときに他のすべて(レジスタ、メモリ、スタック)は変更されません。したがって、その使用は簡単です。

include irvine32.inc

.data
    X sdword   10, -10, 20, -20, 30, -30, 40, -40

.code

StackProcedure PROC
    push ebp
    mov ebp, esp
    sub esp, 32
    lea esi, [ebp-32]
    mov ecx, 32
L1: mov BYTE PTR [esi], '*'
    inc esi
    loop L1

        mov esi, esp                ; Start address
        mov ecx, 48                 ; Number of bytes to dump
        mov ebx, 1                  ; 1 - size byte
        call DumpMem                ; call Irvine's DumpMem

    add esp, 32
    pop ebp
    ret
StackProcedure ENDP

main PROC
    mov ecx, offset x
    push ecx
    call StackProcedure
    invoke exitProcess,0
main ENDP

END main

これは実際には聞かれなかったと思います。Irvine'sDumpMemは、逆アセンブラダンプで期待されるように、開始アドレスと同等のASCII文字以外のアドレスを表示しません。独自の表示(タイトルと改行)があるため、その追加情報を提供する関数の間に埋め込むことはできません。アドレス、16進値、ASCII文字を含む16バイトの行を表示する関数は次のとおりです。

include irvine32.inc

.data
    X sdword   10, -10, 20, -20, 30, -30, 40, -40

.code

DumpMemLine PROC C USES EBX ESI, address:PTR      ; dumps 16 bytes hex & char
    mov eax, address
    call WriteHex               ; call Irvine's WriteHex (8 hex digits)
    mov al, ' '
    call WriteChar              ; call Irvine's WriteChar (space)
    call WriteChar              ; call Irvine's WriteChar (space)

    mov esi, address
    mov ecx, 16
    L1:
    mov al, [esi]
    cmp al, 14                  ; ASCII code >= 14d?
    jae @F                      ; Yes, can be written unchanged
    cmp al, 7                   ; ASCII code < 7d?
    jb @F                       ; Yes, can be written unchanged
    cmp al, 11                  ; ASCII code == 11d?
    je @F                       ; Yes, can be written unchanged
    cmp al, 12                  ; ASCII code == 12d?
    je @F                       ; Yes, can be written unchanged
    mov al, ' '                 ; Replace characters that `WriteChar` will "cook" (7,8,9,10,13)
    @@:                         ; This is label where the `jcond @F` jump to
    mov ebx, 1                  ; Two hex digits
    call WriteHexB              ; call Irvine's WriteHexB
    mov al, ' '
    call WriteChar              ; call Irvine's WriteChar (space)
    inc esi
    loop L1
    call WriteChar              ; call Irvine's WriteChar (space)

    mov esi, address
    mov ecx, 16
    @@:
    mov al, [esi]
    call WriteChar              ; call Irvine's WriteChar
    inc esi
    loop @B

    mov al, 10
    call WriteChar              ; call Irvine's WriteChar (line feed)

    ret
DumpMemLine ENDP

StackProcedure PROC
    push ebp
    mov ebp, esp
    sub esp, 32
    lea esi, [ebp-32]
    mov ecx, 32
L1: mov BYTE PTR [esi], '*'
    inc esi
    loop L1

        mov esi, esp                ; Start address
        mov ecx, 48                 ; Number of bytes to dump
        mov ebx, 1                  ; 1 - size byte
        call DumpMem                ; call Irvine's DumpMem

        ; Dump three lines à 16 bytes
        push esp                    ; Argument for DumpMemLine
        call DumpMemLine
        add dword ptr [esp], 16     ; Increment the pushed argument
        call DumpMemLine
        add dword ptr [esp], 16     ; Increment the pushed argument
        call DumpMemLine
        add esp, 4                  ; Clean up the stack

    add esp, 32
    pop ebp
    ret
StackProcedure ENDP

main PROC
    mov ecx, offset x
    push ecx
    call StackProcedure
    invoke exitProcess,0
main ENDP

END main
于 2015-12-30T10:42:20.273 に答える
0

メモリダンプを確認しようとしていると思います。正しい場合は、GDBデバッガを使用してプログラムをデバッグできます。また、ブレークポイントを設定することで、レジスタ、セグメント、制御レジスタ、フレームなどのメモリの詳細を確認できます。リンクをたどってGDBの詳細を入手してください。

http://www.yolinux.com/TUTORIALS/GDB-Commands.html
于 2012-04-26T06:15:38.433 に答える