如何修复此错误:Project235.exe中0x00E33743处抛出异常:0xC0000005:访问冲突读取位置0x00000000

时间:2017-12-10 00:42:54

标签: visual-studio-2015 x86

我在Visual Studios 2015中的0x00E33743处抛出一个错误,我目前正在使用x86汇编语言。我的目标是将此过程从提供的输入BYTE数组复制到目标BYTE数组。问题是,当我开始使用mov eax时,[esi]会在eax中加载目标的值,即抛出错误时。我想知道是否有人知道我为什么会收到这个错误并且可以帮助我。

;---------------------------------------------------------------------------------------------------------------------
; copies bytes from a supplied input BYTE array to a target BYTE array
; receives:         
;   [ebp-4] = pointer to buffer array
;   [ebp-8] = pointer to the output byte array
;   [ebp-12] = max size buffer
; returns:
;   eax = the pointer to the next character in the input array after the carriage return and line feed characters
;---------------------------------------------------------------------------------------------------------------------
bufferCopy PROC
    push ebp                                        ; save the base pointer
    mov ebp,esp                                     ; base of the stack frame
    push OFFSET buffer                              ; points to the beginning of buffer
    push OFFSET olympian                            ; pointer to the output array
    push BSIZE                                      ; buffer size
    sub esp,16                                      ; create temp variable "tmp"
    push esi                                        ; save esi
    push eax                                        ; save eax

; store the input byte into the max size
    mov esi,[ebp-4]                                 ; load pointer to byte in esi
    mov ecx,[ebp-12]                                ; max size of the buffer
    mov eax,[esi]                                   ; load the value of byte in eax
    mov [ebp-16],eax                                ; store in tmp

; move target byte to the input byte
    mov esi,[ebp-8]                                 ; load pointer to target in esi
    mov eax,[esi]                                   ; load the value of target in eax
    mov esi,[ebp-4]                                 ; load pointer to input byte in esi
    mov [esi],eax                                   ; move eax (target) to input location

; move tmp/input to target
    mov eax,[ebp-16]                                ; move value stored in max (input) to eax
    mov esi,[ebp-8]                                 ; load pointer to target in esi
    mov [esi],eax                                   ; move eax (input) to target location
    push [esi]+1                                    ; moving the target's pointer over

    push [esi]+2                                    ; moving the target's pointer over
    pop eax                                         ; restore eax
    pop esi                                         ; restore esi
    pop ebp                                         ; remove base pointer

    ret                                             ; clean up stack!
bufferCopy ENDP

0 个答案:

没有答案