Estoy intentando hacer un programa sencillo utilizando el cifrado XOR para mediante una clave cifrar un archivo.
Estoy intentando que el modificador -i especifique el archivo y que el modificador -k la clave. Sin embargo la funcion CommandLineArgvW aparentemente no me esta retornando un puntero a cadenas sino un puntero a caracteres. Especificamente el primer caracter de la cadena. ¿Como hago que retorne la cadena completa?
Código
.686p .model flat, stdcall includelib \masm32\lib\msvcrt.lib includelib \masm32\lib\kernel32.lib includelib \masm32\lib\shell32.lib printf proto C, :vararg exit proto C, :dword putchar proto C, :dword strlen proto C, :dword strcpy proto C, :dword, :dword strcmp proto C, :dword, :dword memset proto C, :dword, :dword, :dword GetCommandLineW proto stdcall CommandLineToArgvW proto stdcall, :dword, :dword t macro i:vararg local s const segment s db i, 0 const ends exitm <offset s> endm halt macro local s s: jmp s endm .data? db ? .data db ? .code start: call main invoke exit, 0h main proc local szFileName[256]:byte, szKey[256]:byte, szCmdLine:dword, lpArgv:dword, dwArgc:dword invoke memset, addr szFileName, 256, 0 invoke memset, addr szKey, 256, 0 invoke GetCommandLineW mov szCmdLine, eax invoke CommandLineToArgvW, szCmdLine, addr dwArgc mov lpArgv, eax test eax, eax jnz @0 invoke printf, t(0ah, 0dh, "Error loading command line information.") mov eax, -1 ret @0: xor ecx, ecx mov ecx, 01h mov ebx, lpArgv .while ecx<dwArgc mov ebx, lpArgv mov eax, 4 mul ecx add ebx, eax mov ebx, [ebx] push ecx invoke printf, t(0ah, 0dh, "Argument %d is %s"), ecx, ebx pop ecx push ecx invoke strcmp, ebx, t("-i") pop ecx test eax, eax jnz @1 push ecx inc ecx mov eax, 4 mul ecx add ebx, eax mov ebx, [ebx] invoke strcpy, addr szFileName, ebx pop ecx @1: inc ecx .endw ret main endp end start
Citar
mov ebx, lpArgv
mov eax, 4
mul ecx
add ebx, eax
mov ebx, [ebx]
push ecx
invoke printf, t(0ah, 0dh, "Argument %d is %s"), ecx, ebx
pop ecx
mov eax, 4
mul ecx
add ebx, eax
mov ebx, [ebx]
push ecx
invoke printf, t(0ah, 0dh, "Argument %d is %s"), ecx, ebx
pop ecx
Citar
C:\Users\Programming\Desktop>console abc def
Argument 1 is a
Argument 2 is d
C:\Users\Programming\Desktop>
Argument 1 is a
Argument 2 is d
C:\Users\Programming\Desktop>