-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTranslateChave.asm
120 lines (88 loc) · 2.92 KB
/
TranslateChave.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
.686
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\msvcrt.inc
include \masm32\include\masm32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\msvcrt.lib
includelib \masm32\lib\masm32.lib
include \masm32\macros\macros.asm
.data
chavecript db "Digite a chave de criptografia: ", 0ah, 0h
inputStringChave db 50 dup(0)
arqentr db "Digite o nome do arquivo para ser lido: ", 0ah, 0h
inputStringArqEntr db 50 dup(' ')
fileBuffer db 8 dup(0)
fileBuffer2 db 8 dup(0)
outputHandle dd 0
readCount dd 0
writeCount dd 0
inputHandle dd 0
write_count dd 0
fileHandle1 dd 0
counter dd 0
variavel dd 0
beto db 4
cont dd 0
.code
start:
invoke GetStdHandle, STD_OUTPUT_HANDLE
mov outputHandle, eax
invoke WriteConsole, outputHandle, addr chavecript, sizeof chavecript, addr write_count, NULL
invoke GetStdHandle, STD_INPUT_HANDLE
mov inputHandle, eax
invoke ReadConsole, inputHandle, addr inputStringChave, sizeof inputStringChave, addr write_count, NULL
invoke GetStdHandle, STD_OUTPUT_HANDLE
mov outputHandle, eax
invoke WriteConsole, outputHandle, addr arqentr, sizeof arqentr, addr write_count, NULL
invoke GetStdHandle, STD_INPUT_HANDLE
mov inputHandle, eax
invoke ReadConsole, inputHandle, addr inputStringArqEntr, sizeof inputStringArqEntr, addr write_count, NULL
mov esi, offset inputStringChave ; Tratamento de erro para reconhecimento do caracter de retorno
proximochave:
mov al, [esi] ;
inc esi ;
cmp al, 13 ; Verificar se eh o caractere ASCII CR - FINALIZAR
jne proximochave
dec esi ;
xor al, al ;
mov [esi], al ;
mov esi, offset inputStringArqEntr ; Tratamento de erro para reconhecimento do caracter de retorno
proximoentr:
mov al, [esi] ;
inc esi ;
cmp al, 13 ; Verificar se eh o caractere ASCII CR - FINALIZAR
jne proximoentr
dec esi ;
xor al, al ;
mov [esi], al ;
invoke CreateFile, addr inputStringArqEntr, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL
mov fileHandle1, eax
invoke ReadFile, fileHandle1, addr fileBuffer, 8, addr readCount, NULL
ciclo:
mov esi, offset inputStringChave
add esi, cont
mov al, [esi]
sub al, 48
movzx eax, al
mov variavel, eax
mov esi, offset fileBuffer
add esi, cont
mov edi, offset fileBuffer2
mov al, [esi]
add edi, variavel
mov [edi], al
inc cont
cmp cont, 8
jl ciclo
invoke GetStdHandle, STD_OUTPUT_HANDLE
mov outputHandle, eax
invoke WriteConsole, outputHandle, addr inputStringChave, sizeof inputStringChave, addr write_count, NULL
invoke GetStdHandle, STD_OUTPUT_HANDLE
mov outputHandle, eax
invoke WriteConsole, outputHandle, addr fileBuffer2, sizeof fileBuffer2, addr write_count, NULL
invoke CloseHandle, fileHandle1
invoke ExitProcess, 0
end start