Results 1 to 2 of 2

Thread: error,i need help debugging it. small code

  1. #1

    Thread Starter
    Hyperactive Member Cmdr0Sunburn's Avatar
    Join Date
    May 2001
    Location
    g0t r00t?
    Posts
    461

    error,i need help debugging it. small code

    when i calling CHECKDCFAKER and get an error, im loading a file in some dynamic memory and preforming a crc32 check on it, i dont know where the error is please help.

    Code:
        .386
        .model flat, stdcall
        option casemap :none  
    
        Include c:\asm\masm32\Include\windows.inc
        Include c:\asm\masm32\Include\user32.inc
        Include c:\asm\masm32\Include\kernel32.inc
        Include c:\asm\masm32\Include\GDI32.inc
        Include c:\asm\masm32\Include\SHELL32.inc
        
        IncludeLib c:\asm\masm32\lib\SHELL32.lib
        IncludeLib c:\asm\masm32\lib\GDI32.lib
        IncludeLib c:\asm\masm32\lib\user32.lib
        IncludeLib c:\asm\masm32\lib\kernel32.lib
        
         
              szText macro Name, Text:VARARG
            Local lbl
              jmp lbl
                Name db Text,0
              lbl:
            endm
    
          m2m macro M1, M2
            push M2
            pop  M1
          endm
    
          return macro arg
            mov eax, arg
            ret
          endm
    
    Crc32 PROTO :DWORD, :DWORD
    InitCrc32Tbl PROTO
    CHECKDCFAKER PROTO :DWORD
    
    .Data?
    crctab dd ?
    hFile HANDLE ? ; File handle 
    hMemory HANDLE ? ;handle to the allocated memory block 
    pMemory DWORD ? ;pointer to the allocated memory block 
    SizeReadWrite DWORD ? ; number of bytes actually read or write 
    .Data
    buf_P db "C:\asm\first\Qages\Qages.exe",0
    
    .Const 
    IDM_OPEN Equ 1 
    IDM_SAVE Equ 2 
    IDM_EXIT Equ 3 
    MAXSIZE Equ 260 
    MEMSIZE Equ 65535 
    .Code
    LIBMAIN Proc px:DWORD, py:DWORD, pz:DWORD
    return TRUE
    ret
    LIBMAIN EndP
    ;*-------------------------------------------*
    ; void InitCRC(void);
    ; Precomputes a 256*4 CRC array for use with
    ; Crc32()
    ;*-------------------------------------------*
    
    InitCrc32Tbl Proc Uses esi edi ebx
    
    lea edi,crctab + (255*4)
    xor edx,edx
    dec dl
    std 
    CalcTblValues:
    mov eax,edx
    mov ebx,0edb88320h  ; winzip polynominal
    push 8  ;mov ecx,8
    pop ecx
    ReflectBitsCompute_Loop:
    shr eax,1    
    sbb esi,esi  
    and esi,ebx 
    xor eax,esi  
    dec ecx
    jz ReflectBitsCompute_Loop
    stosd
    dec edx
    jns CalcTblValues
    cld
    ret
    InitCrc32Tbl EndP
    ;*-------------------------------------------*
    ; int FastCRC(*buffer, sizeof(buffer);
    ; Calculates a 32 Bit Cyclic Redundancy Code
    ; over a buffer with length sizeof(buffer),
    ; using a precomputed CRC table. InitCRC()
    ; must be called *once* before.
    ; Speed: ~7 MB/s on a Intel PII 300
    ;*-------------------------------------------*
    Crc32 Proc Uses esi edi lpData:DWORD,bLen:DWORD
    
    mov esi,lpData 
    lea edi,crctab 
    mov ecx,bLen 
    
    xor eax,eax 
    dec eax
    xor edx,edx
    @@:
    mov dl,byte ptr [esi] 
    inc esi               
    xor dl,al             
    
    shr eax,8                       
    xor eax,dword ptr [edi+(edx*4)] 
    
    dec ecx 
    jnz @B
    
    not eax 
    ret
    Crc32 EndP
    
    CHECKDCFAKER Proc pDAT:DWORD
    Local pCRCD :DWORD
    Invoke CreateFile,Addr buf_P,GENERIC_READ or GENERIC_WRITE ,FILE_SHARE_READ or FILE_SHARE_WRITE,\ 
    NULL,OPEN_EXISTING,FILE_ATTRIBUTE_ARCHIVE,\ 
    NULL 
    mov hFile,eax 
    Invoke GlobalAlloc,GMEM_MOVEABLE or GMEM_ZEROINIT,MEMSIZE 
    mov hMemory,eax 
    Invoke GlobalLock,hMemory 
    mov pMemory,eax 
    Invoke ReadFile,hFile,pMemory,MEMSIZE-1,Addr SizeReadWrite,NULL 
    
    Invoke InitCrc32Tbl ;int crc
    Invoke Crc32,Addr pMemory,Addr SizeReadWrite ;call it
    mov DWORD PTR [pDAT] ,eax
    Invoke CloseHandle,hFile 
    Invoke GlobalUnlock,pMemory 
    Invoke GlobalFree,hMemory 
    
    ret
    CHECKDCFAKER EndP
    End LIBMAIN
    I know a lot oF Vb, expert in C++, and i think in assembly.
    MSVC++6.NET
    vb6
    masm
    Windowz Xp
    I find my self using this a lot in C++

    __asm {
    }

  2. #2

    Thread Starter
    Hyperactive Member Cmdr0Sunburn's Avatar
    Join Date
    May 2001
    Location
    g0t r00t?
    Posts
    461
    this is extreemy old and i have solved it. sorry.
    I know a lot oF Vb, expert in C++, and i think in assembly.
    MSVC++6.NET
    vb6
    masm
    Windowz Xp
    I find my self using this a lot in C++

    __asm {
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width