2013-05-09 22:49:02 +04:00
|
|
|
|
; Programa Mostra memoria
|
|
|
|
|
; Projeto: Clovis Bombardelli e Felipe Gustavo Bombardelli
|
|
|
|
|
; Usar Fasm Assembler
|
|
|
|
|
; Dez/2007
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; Infos:
|
|
|
|
|
; keys: w - add 0x200 to current memory address
|
|
|
|
|
; s - sub 0x200
|
|
|
|
|
; e - add 0x10
|
|
|
|
|
; d - sub 0x10
|
|
|
|
|
;
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
use32
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
org 0x0
|
|
|
|
|
|
|
|
|
|
STACK_SIZE=1024
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
db 'MENUET01' ; 8 byte id
|
|
|
|
|
dd 0x01 ; header version
|
|
|
|
|
dd START ; start of code
|
|
|
|
|
dd I_END ; size of image
|
|
|
|
|
dd I_END+STACK_SIZE ; memory for app
|
|
|
|
|
dd I_END+STACK_SIZE ; esp
|
|
|
|
|
dd 0x0 , 0x0 ; I_Param , I_Icon
|
|
|
|
|
|
2013-06-09 10:40:31 +04:00
|
|
|
|
include 'lang.inc' ;language support
|
2013-05-09 22:49:02 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
START:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main:
|
|
|
|
|
|
|
|
|
|
call monta_quadro
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
.a: mov eax, 11 ; espera por evento
|
2013-06-09 10:40:31 +04:00
|
|
|
|
int 0x40 ; 0= -> redraw
|
2013-05-09 22:49:02 +04:00
|
|
|
|
or al,al
|
|
|
|
|
jz .h
|
2013-06-09 10:40:31 +04:00
|
|
|
|
cmp al, 2 ; 1= -> REDRAW
|
|
|
|
|
jb main ; 2= -> tecla pressionada
|
|
|
|
|
jz .c ; 3= -> bot<6F>o pressionado
|
2013-05-09 22:49:02 +04:00
|
|
|
|
|
2013-06-09 10:40:31 +04:00
|
|
|
|
; bot<6F>o
|
|
|
|
|
mov eax,17 ;
|
2013-05-09 22:49:02 +04:00
|
|
|
|
int 0x40 ; OBSERVA<56><41>ES
|
|
|
|
|
cmp ah,1 ; se o bot<6F>o apertado for fechar, minimizar, maximizar...todos devem ser do sistema
|
|
|
|
|
jnz .b ; mover...etc
|
|
|
|
|
or eax,-1 ; saida do aplicativo **************************deve ser do sistema
|
|
|
|
|
int 0x40 ; nunca do aplicativo
|
|
|
|
|
|
2013-06-09 10:40:31 +04:00
|
|
|
|
.b: jmp .a ; loop para novo evento
|
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
|
2013-06-09 10:40:31 +04:00
|
|
|
|
; tecla
|
2013-05-09 22:49:02 +04:00
|
|
|
|
.c: mov eax,2 ; getkey
|
|
|
|
|
int 0x40
|
2013-06-09 10:40:31 +04:00
|
|
|
|
;cmp al, 1
|
2013-05-09 22:49:02 +04:00
|
|
|
|
;jnz .a
|
|
|
|
|
cmp ah, 'w'
|
|
|
|
|
jne .a1
|
|
|
|
|
add [end_base], 0x200
|
|
|
|
|
jmp main ;
|
|
|
|
|
.a1: cmp ah, 's'
|
|
|
|
|
jne .a2
|
|
|
|
|
cmp [end_base], dword 0x80000000
|
|
|
|
|
jbe .a2
|
2013-06-09 10:40:31 +04:00
|
|
|
|
sub [end_base], 0x200
|
2013-05-09 22:49:02 +04:00
|
|
|
|
jmp main ;
|
|
|
|
|
.a2: cmp ah, 'e'
|
|
|
|
|
jne .a3
|
|
|
|
|
add [end_base], 0x10
|
|
|
|
|
jmp main ;
|
|
|
|
|
.a3: cmp ah, 'd'
|
|
|
|
|
jne .b1
|
|
|
|
|
cmp [end_base], dword 0x80000000
|
|
|
|
|
jbe .b1
|
|
|
|
|
sub [end_base], 0x10
|
|
|
|
|
.b1: jmp main
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; atualiza apenas o codigo hex / ascii
|
|
|
|
|
.h:
|
|
|
|
|
call hex_loop
|
2013-06-09 10:40:31 +04:00
|
|
|
|
; inc [contador] ; usado apenas para testar a dinamica
|
2013-05-09 22:49:02 +04:00
|
|
|
|
jmp .a ; retorna para buscar novo evento
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
monta_quadro:
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
; posi<73><69>o inicial, subfun<75><6E>o 1
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
|
|
|
|
mov eax,12
|
|
|
|
|
mov ebx,1
|
2013-05-09 22:49:02 +04:00
|
|
|
|
int 0x40
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
; Desenha o quadro
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
mov eax,0 ; fun<75><6E>o 0 : define e monta o quadro
|
|
|
|
|
mov ebx,100*65536+480 ; [x pos] *65536 + [x lar]
|
|
|
|
|
mov ecx,100*65536+440 ; [y pos] *65536 + [y alt]
|
|
|
|
|
mov edx,[cor_janela] ; cor area RRGGBB
|
|
|
|
|
mov edi,titulo ; Titulo
|
|
|
|
|
int 0x40
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
; escreve texto no quadro (barra superior)
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
|
|
|
|
mov edi,[cor_janela]
|
|
|
|
|
mov eax,4
|
2013-05-09 22:49:02 +04:00
|
|
|
|
mov ecx, [cor_texto]
|
2013-06-09 10:40:31 +04:00
|
|
|
|
mov ebx,8*65536+8
|
|
|
|
|
mov edx,teste
|
|
|
|
|
int 0x40
|
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
add ebx,11 ; adiciona espa<70>o na coord y
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
|
|
|
|
mov eax,4
|
2013-05-09 22:49:02 +04:00
|
|
|
|
mov ecx, [cor_texto]
|
2013-06-09 10:40:31 +04:00
|
|
|
|
mov edx,barra1
|
|
|
|
|
int 0x40
|
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
call hex_loop
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
|
|
|
|
; posi<73><69>o final, subfun<75><6E>o 2
|
|
|
|
|
|
|
|
|
|
.d: mov eax,12
|
|
|
|
|
mov ebx,2
|
|
|
|
|
int 0x40
|
|
|
|
|
|
|
|
|
|
ret
|
2013-05-09 22:49:02 +04:00
|
|
|
|
|
|
|
|
|
; buscar conteudo da memoria para mostrar
|
|
|
|
|
|
2013-06-09 10:40:31 +04:00
|
|
|
|
hex_loop:
|
2013-05-09 22:49:02 +04:00
|
|
|
|
xor eax, eax
|
|
|
|
|
mov ebx, [end_base] ; endere<72>o base
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
; imprime o endere<72>o
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
mov edx, 8*65536+40 ; posi<73><69>o inicial hex
|
|
|
|
|
mov [pos_ascii], edx
|
|
|
|
|
add [pos_ascii], 360*65536 ; posi<73><69>o inicial ascii
|
|
|
|
|
mov word [pos_x], 0
|
|
|
|
|
mov al, [quant_linhas]
|
2013-06-09 10:40:31 +04:00
|
|
|
|
mov edi,[cor_janela]
|
2013-05-09 22:49:02 +04:00
|
|
|
|
|
2013-06-09 10:40:31 +04:00
|
|
|
|
.c: push eax ;
|
|
|
|
|
push edx ;
|
|
|
|
|
|
|
|
|
|
push ebx ; salva endere<72>o base
|
2013-05-09 22:49:02 +04:00
|
|
|
|
mov al, 47
|
|
|
|
|
mov ecx, ebx ; imprime o endere<72>o
|
|
|
|
|
mov ebx, 0x00080100
|
|
|
|
|
mov esi, [cor_endereco]
|
|
|
|
|
int 0x40
|
2013-06-09 10:40:31 +04:00
|
|
|
|
pop ebx ;
|
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
add edx, 60*65536 ; pula 8 espa<70>os mais alguma coisa
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
|
|
|
|
; busca hexcode
|
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
mov esi, [cor_hexcode]
|
|
|
|
|
mov al, 4
|
|
|
|
|
|
|
|
|
|
.b: push eax ; ----------------------------------------------------------ok
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
mov al, 72 ; ebx= endere<72>o de leitura (nao funcionou...) change this service to another
|
|
|
|
|
int 0x40 ; retorna ecx= dword da posi<73><69>o ebx
|
|
|
|
|
|
|
|
|
|
push ebx ; ----------------------------------------------------------ok
|
|
|
|
|
mov ebx, 0x00020100 ; 2 digitos, modo hex
|
|
|
|
|
mov al, 4
|
|
|
|
|
|
|
|
|
|
.a: push eax ; controle -------------------------------------------------ok
|
2013-06-09 10:40:31 +04:00
|
|
|
|
push ecx ; codigo
|
|
|
|
|
push edx ; posi<73><69>o
|
2013-05-09 22:49:02 +04:00
|
|
|
|
and ecx, 0xff
|
|
|
|
|
mov al, 47
|
|
|
|
|
int 0x40
|
|
|
|
|
call imprime_car$
|
2013-06-09 10:40:31 +04:00
|
|
|
|
pop edx ;
|
|
|
|
|
pop ecx ;
|
2013-05-09 22:49:02 +04:00
|
|
|
|
shr ecx, 8
|
|
|
|
|
add edx, (18)*65536
|
|
|
|
|
pop eax ; ----------------------------------------------------------ok
|
|
|
|
|
dec al
|
|
|
|
|
jnz .a
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
pop ebx ; ----------------------------------------------------------ok
|
|
|
|
|
add ebx, 4 ; soma 4 ao endere<72>o base
|
|
|
|
|
pop eax ; ----------------------------------------------------------ok
|
|
|
|
|
dec al ; imprimir mais 4 vezes incrementando ebx em 4
|
|
|
|
|
jnz .b
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
|
|
|
|
pop edx ;
|
2013-05-09 22:49:02 +04:00
|
|
|
|
add edx, 10 ;
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
|
|
|
|
; imprime a string ascii
|
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
push ebx
|
|
|
|
|
push edx
|
2013-06-09 10:40:31 +04:00
|
|
|
|
mov al, 4
|
|
|
|
|
mov ebx, [pos_ascii] ; endere<72>o na tela
|
2013-05-09 22:49:02 +04:00
|
|
|
|
mov edx, ascii_string ; endere<72>o da string
|
|
|
|
|
or ecx, [cor_ascii] ; cor
|
|
|
|
|
int 0x40
|
|
|
|
|
mov [ascii_x], byte 0
|
|
|
|
|
add [pos_ascii], 10
|
|
|
|
|
pop edx
|
|
|
|
|
pop ebx
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
|
|
|
|
pop eax ;
|
2013-05-09 22:49:02 +04:00
|
|
|
|
dec al
|
|
|
|
|
jnz .c
|
|
|
|
|
ret
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
imprime_car$: ; ecx tem o caractere a imprimir
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
push ebx
|
|
|
|
|
xor ebx, ebx
|
|
|
|
|
mov bl, [ascii_x]
|
|
|
|
|
or cl, cl
|
|
|
|
|
jnz .c
|
|
|
|
|
mov cl, 0x20
|
2013-06-09 10:40:31 +04:00
|
|
|
|
.c: mov [ebx+ascii_string], cl
|
2013-05-09 22:49:02 +04:00
|
|
|
|
inc [ascii_x]
|
|
|
|
|
pop ebx
|
|
|
|
|
ret
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
|
|
|
|
|
; para acessar a memoria do sistema:
|
|
|
|
|
;
|
|
|
|
|
; acessar a base das tabelas de pagina<6E>ao
|
|
|
|
|
; com o endere<72>o buscar o descritor de pagina
|
|
|
|
|
; ler o endere<72>o f<>sico ndo descritor
|
|
|
|
|
; ou buscar a pagina do sistema e ler nele o endere<72>o fisico
|
|
|
|
|
|
|
|
|
|
; DATA AREA
|
|
|
|
|
align 0x10
|
|
|
|
|
;contador dd 0 ; para testar a dinamica
|
|
|
|
|
cor_janela dd 0x346f72c3 ; atrib, tipo, corRGB
|
|
|
|
|
cor_texto dd 0xc0fffffe ; fonte variavel, cor branca
|
|
|
|
|
cor_endereco dd 0xc0fffffc
|
|
|
|
|
cor_hexcode dd 0xc0fffffd
|
|
|
|
|
cor_ascii dd 0xc0fffffa
|
|
|
|
|
pos_x db 0
|
|
|
|
|
pos_y db 0
|
|
|
|
|
quant_linhas db 0x20
|
|
|
|
|
ascii_x db 0
|
|
|
|
|
end_base dd 0x80000000 ; ok
|
|
|
|
|
pos_ascii dd 0
|
2013-06-09 10:40:31 +04:00
|
|
|
|
ascii_string rb 0x11
|
2013-05-09 22:49:02 +04:00
|
|
|
|
reservado rb 3
|
|
|
|
|
|
2013-06-09 10:40:31 +04:00
|
|
|
|
if lang eq it
|
|
|
|
|
titulo db 'Visualizza la memoria del sistema operativo',0
|
|
|
|
|
teste db '-------- ----------------- Codice Hex ----------------- -- A S C I I --',0
|
|
|
|
|
barra1 db 'Indirizzo:00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 0123456789abcdef',0
|
2013-05-09 22:49:02 +04:00
|
|
|
|
|
2013-06-09 10:40:31 +04:00
|
|
|
|
else if lang eq es
|
|
|
|
|
titulo db 'Mostra a memoria do sistema operacional',0
|
|
|
|
|
teste db '-------- ------------------ Hex Code ------------------- -- A S C I I --',0
|
|
|
|
|
barra1 db 'Address: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 0123456789abcdef',0
|
2013-05-09 22:49:02 +04:00
|
|
|
|
|
2013-06-09 10:40:31 +04:00
|
|
|
|
else
|
|
|
|
|
titulo db 'Displays the operating system memory',0
|
|
|
|
|
teste db '-------- ------------------ Hex Code ------------------- -- A S C I I --',0
|
|
|
|
|
barra1 db 'Address: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 0123456789abcdef',0
|
|
|
|
|
end if
|
2013-05-09 22:49:02 +04:00
|
|
|
|
|
|
|
|
|
align 0x10
|
|
|
|
|
I_END:
|
2013-06-09 10:40:31 +04:00
|
|
|
|
|
2013-05-09 22:49:02 +04:00
|
|
|
|
|
|
|
|
|
; service 72 from system calls
|
2013-06-09 10:40:31 +04:00
|
|
|
|
;
|
2013-05-09 22:49:02 +04:00
|
|
|
|
; must contain:
|
|
|
|
|
; mov eax, [eax]
|
|
|
|
|
; mov [esp+32], eax
|
|
|
|
|
; ret
|
|
|
|
|
|
|
|
|
|
|