在我的程序中,当我退出ASM代码部分并返回到C ++代码时,我在project00.exe中的0x93b3237d获得了Unhandled异常:0xC0000005:访问冲突。在Crtexe.c中,行mainret = main(argc,argv,envp);并且在将0C添加到ESP时进行反汇编。我认为问题可能是主函数的返回地址在返回之前已损坏,并导致其失败。程序找到两组的交集和并集。使用VS10并没有想法。


    include "iostream.h"//modify line to show up in code block

    using namespace std;

    typedef int DWORD;      //4 btye double word
    typedef char BYTE;      //1 byte
    typedef short WORD;     //2 byte double word

    int main(){

    int i =0;
    BYTE str0[50] = "1qaz2wsx3edc4rfv5tgb6yhn7ujm8ik,9ol.0p;/-[?]F!Q";
    BYTE str1[50] ="QAZ@WSX#EDC$RFV%TGB^YHN&UJM*IK)P:?_{?}|1`";
    DWORD length0 ;
    DWORD length1 ;
    BYTE IntersectArray[50];
    BYTE result [100] ;

    __asm{
    p:
    pusha
    lea eax, str0
    call COUNT
    mov length0,ecx
    lea eax, str1
    call COUNT
    mov length1,ecx
    call INTERSECTION
    call JoinSet
    xor eax,eax
    popa
    ret




    COUNT:
    mov ecx,0;
    Q: mov dl, [eax]
    cmp dl,0h
    JE cEND
    inc eax
    inc ecx
    jmp Q
    cEnd: ret


    INTERSECTION:
        lea edx, str0
        mov ebx, length0
        lea esi, IntersectArray
        first: mov al, [edx]
        mov ecx, length1
        lea edi, str1
        repne SCASB
        cmp ecx,0
        JNZ INTER
    Back:   inc edx
        cmp ebx,0
        JZ EXITSTUFF
        dec ebx
        jmp first

    INTER: mov [esi] , al
       inc esi
       jmp Back

    EXITSTUFF:
        mov [esi], 0
        ret

    JoinSet :
        lea edi, result
        lea esi, str0
        mov ecx, length0
        REP MOVSB



            lea edx, str1
        mov ebx, length1
        lea esi, result + [ebx]
        f: mov al, [edx]
        mov ecx, length0
        lea edi, str0
        repne SCASB
        cmp ecx,0
        JNZ B
         mov [esi] , al
           inc esi
    B:      inc edx
        cmp ebx,0
        JZ EXITSTU
        dec ebx
        jmp f

    EXITSTU:
        mov [esi], 0
        ret
    }


休息

    for(int i =0;i < 50;i++){
cout <<IntersectArray[i];}
cout << endl;
for (int i =0; i<100;i++)
cout <<result[i];
cout << endl;
system("pause");
return 0;
}

最佳答案

可能因为我从未进行过任何x86汇编而引起的愚蠢评论。但是我认为asm是内联的吗?那么,您的第一个“ ret”实际上是从哪里回来的呢?

关于c++ - project00.exe中0x93b3237d的未处理异常:0xC0000005:访问冲突,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10201911/

10-11 16:41