News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

GetLastError() == 0x306

Started by yo_gdg, February 06, 2007, 06:07:10 PM

Previous topic - Next topic

yo_gdg

Hola,

  Tengo un problema, estoy escribiendo una función que no me anda, entonces pruebo con GetLastError() y siempre me devuelve
0x306 = "No se puede acceder a esa posición de memoria" ( o algo así ). La función la estoy escribiendo usando ESP directamente,
después de tantos intentos sin resultados, probé la misma pero usando LOCAL y así si me anda.
  Les dejo el código a ver si me ayudan:

"
OPTION PROC     : PUBLIC
OPTION PROLOGUE : NONE
OPTION EPILOGUE : NONE
Compile         PROC   lpFrom, lpTo : DWORD

            mov      ECX, [ ESP + 8 ]   ; ECX = lpTo
            xor      EAX, EAX         ; EAX = 0
            
            push   ESI
            push   EDI
            push   EBX
            sub      ESP, ( ( MAX_PATH ) * 2 + SIZEOF( DWORD ) + SIZEOF( WIN32_FIND_DATA ) )
            
            lea      EBX, [ ESP + ( MAX_PATH ) * 2 + SIZEOF( DWORD ) ]   ; EBX = &wfd
            lea      EDI, [ ESP + ( MAX_PATH ) * 1 ]                  ; EDI = szTo
            mov      ESI, ESP                                 ; ESI = szFrom
            
            invoke   CreateDirectory, ECX, EAX
            ;
            ; szFrom = lpFrom + "*.*";
            invoke   lstrcpy, ESI,\
                  [ ESP + ( MAX_PATH ) * 2 + SIZEOF( DWORD ) + SIZEOF( WIN32_FIND_DATA )\
                  + SIZEOF( DWORD ) * 3 + SIZEOF( DWORD ) ]
            invoke   lstrcat, EAX, OFFSET szFilter
            
            invoke   FindFirstFile, EAX, EBX
            cmp      EAX, INVALID_HANDLE_VALUE
            je      @Salir
            
            mov      [ ESP + ( MAX_PATH ) * 2 ], EAX; hSearch = FindFirstFile(...)
@DoWhileI:      cmp      [ EBX ].WIN32_FIND_DATA.cFileName[ 0 ], '.'
            je      @DoWhileF
            
            ;
            ; szTo = lpTo + wfd.cFileName
            invoke   lstrcpy, EDI, [ ESP + ( MAX_PATH ) * 2 + SIZEOF( DWORD ) + SIZEOF( WIN32_FIND_DATA )\
                  + SIZEOF( DWORD ) * 3 + SIZEOF( DWORD ) * 2 ]
            lea      ECX, [ EBX ].WIN32_FIND_DATA.cFileName
            invoke   lstrcat, EAX, ECX
            
            test   [ EBX ].WIN32_FIND_DATA.dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY
            jnz      @F
            invoke   CreateEmptyFile, EAX
            jmp      @DoWhileF
            
@@:            invoke   lstrcat, EAX, OFFSET szBackSlash; szTo = lpTo + "\\" + wfd.cFileName + "\\"

            ;
            ; szFrom = lpFrom + wfd.cFileName + "\\"
            invoke   lstrcpy, ESI,\
                  [ ESP + ( MAX_PATH ) * 2 + SIZEOF( DWORD ) + SIZEOF( WIN32_FIND_DATA )\
                  + SIZEOF( DWORD ) * 3 + SIZEOF( DWORD ) ]
            lea      ECX, [ EBX ].WIN32_FIND_DATA.cFileName
            invoke   lstrcat, EAX, ECX
            invoke   lstrcat, EAX, OFFSET szBackSlash
            
            invoke   Compile, ESI, EDI
            
@DoWhileF:      mov      EAX, [ ESP + ( MAX_PATH ) * 2 ]
            invoke   FindNextFile, EAX, EBX
            or      EAX, EAX
            jnz      @DoWhileI
            
            invoke   FindClose, [ ESP + ( MAX_PATH ) * 2 ]
            xor      EAX, EAX

@Salir:         add      ESP, ( ( MAX_PATH ) * 2 + SIZEOF( DWORD ) + SIZEOF( WIN32_FIND_DATA ) )
            pop      EBX
            pop      ESI
            pop      EDI
            ret      8
Compile         ENDP

TNick

"Tengo una dinnero" is all that I know in this language (I hope is right and I hope is this language):)
1) The official language of this forum is english
2) This is what I get from Windows Error Description (RadASM)
Error name:
    (?)

Error value:
    0x00000306 (774)

Description:
    The storage control blocks were destroyed.

3) Excuse me for not having the time to take a look at your code

Regards,
Nick

MichaelW

MSDN: System Error Codes lists 0x306 = 774 as "One or more errors occurred while processing the request". Not really a very useful error message :(
eschew obfuscation

Tedd

first check "CreateDirectory" succeeds - if you have access rights
also that you have access to the destination directory.
No snowflake in an avalanche feels responsible.

P1

Homework in Spanish.  Poorly translated DOS code to WIN API code.

Double translation error.    :dazzled:

Regards,  P1   :8)