export set_screen

git-svn-id: svn://kolibrios.org@757 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-02-24 16:21:55 +00:00
parent 251159e3c5
commit e461a53e3d
2 changed files with 332 additions and 296 deletions

View File

@ -6,299 +6,300 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision$ $Revision$
include 'export.inc' include 'export.inc'
align 4 align 4
proc load_PE stdcall, file_name:dword proc load_PE stdcall, file_name:dword
locals locals
image dd ? image dd ?
entry dd ? entry dd ?
base dd ? base dd ?
endl endl
stdcall load_file, [file_name] stdcall load_file, [file_name]
test eax, eax test eax, eax
jz .fail jz .fail
mov [image], eax mov [image], eax
mov edx, [eax+60] mov edx, [eax+60]
stdcall kernel_alloc, [eax+80+edx] stdcall kernel_alloc, [eax+80+edx]
test eax, eax test eax, eax
jz .cleanup jz .cleanup
mov [base], eax mov [base], eax
stdcall map_PE, eax, [image] stdcall map_PE, eax, [image]
mov [entry], eax mov [entry], eax
test eax, eax test eax, eax
jnz .cleanup jnz .cleanup
stdcall kernel_free, [base] stdcall kernel_free, [base]
.cleanup: .cleanup:
stdcall kernel_free, [image] stdcall kernel_free, [image]
mov eax, [entry] mov eax, [entry]
ret ret
.fail: .fail:
xor eax, eax xor eax, eax
ret ret
endp endp
DWORD equ dword DWORD equ dword
PTR equ PTR equ
align 4 align 4
map_PE: ;stdcall base:dword, image:dword map_PE: ;stdcall base:dword, image:dword
cld cld
push ebp push ebp
push edi push edi
push esi push esi
push ebx push ebx
sub esp, 60 sub esp, 60
mov ebx, DWORD PTR [esp+84] mov ebx, DWORD PTR [esp+84]
mov ebp, DWORD PTR [esp+80] mov ebp, DWORD PTR [esp+80]
mov edx, ebx mov edx, ebx
mov esi, ebx mov esi, ebx
add edx, DWORD PTR [ebx+60] add edx, DWORD PTR [ebx+60]
mov edi, ebp mov edi, ebp
mov DWORD PTR [esp+32], edx mov DWORD PTR [esp+32], edx
mov ecx, DWORD PTR [edx+84] mov ecx, DWORD PTR [edx+84]
shr ecx, 2 shr ecx, 2
rep movsd rep movsd
movzx eax, WORD PTR [edx+6] movzx eax, WORD PTR [edx+6]
mov DWORD PTR [esp+36], 0 mov DWORD PTR [esp+36], 0
mov DWORD PTR [esp+16], eax mov DWORD PTR [esp+16], eax
jmp L2 jmp L2
L3: L3:
mov eax, DWORD PTR [edx+264] mov eax, DWORD PTR [edx+264]
test eax, eax test eax, eax
je L4 je L4
mov esi, ebx mov esi, ebx
mov edi, ebp mov edi, ebp
add esi, DWORD PTR [edx+268] add esi, DWORD PTR [edx+268]
mov ecx, eax mov ecx, eax
add edi, DWORD PTR [edx+260] add edi, DWORD PTR [edx+260]
shr ecx, 2 shr ecx, 2
rep movsd rep movsd
L4: L4:
mov ecx, DWORD PTR [edx+256] mov ecx, DWORD PTR [edx+256]
add ecx, 4095 add ecx, 4095
and ecx, -4096 and ecx, -4096
cmp ecx, eax cmp ecx, eax
jbe L6 jbe L6
sub ecx, eax sub ecx, eax
add eax, DWORD PTR [edx+260] add eax, DWORD PTR [edx+260]
lea edi, [eax+ebp] lea edi, [eax+ebp]
xor eax, eax xor eax, eax
rep stosb rep stosb
L6: L6:
inc DWORD PTR [esp+36] inc DWORD PTR [esp+36]
add edx, 40 add edx, 40
L2: L2:
mov esi, DWORD PTR [esp+16] mov esi, DWORD PTR [esp+16]
cmp DWORD PTR [esp+36], esi cmp DWORD PTR [esp+36], esi
jne L3 jne L3
mov edi, DWORD PTR [esp+32] mov edi, DWORD PTR [esp+32]
cmp DWORD PTR [edi+164], 0 cmp DWORD PTR [edi+164], 0
je L9 je L9
mov esi, ebp mov esi, ebp
mov ecx, ebp mov ecx, ebp
sub esi, DWORD PTR [edi+52] sub esi, DWORD PTR [edi+52]
add ecx, DWORD PTR [edi+160] add ecx, DWORD PTR [edi+160]
mov eax, esi mov eax, esi
shr eax, 16 shr eax, 16
mov DWORD PTR [esp+12], eax mov DWORD PTR [esp+12], eax
jmp L11 jmp L11
L12: L12:
lea ebx, [eax-8] lea ebx, [eax-8]
xor edi, edi xor edi, edi
shr ebx,1 shr ebx,1
jmp L13 jmp L13
L14: L14:
movzx eax, WORD PTR [ecx+8+edi*2] movzx eax, WORD PTR [ecx+8+edi*2]
mov edx, eax mov edx, eax
shr eax, 12 shr eax, 12
and edx, 4095 and edx, 4095
add edx, DWORD PTR [ecx] add edx, DWORD PTR [ecx]
cmp ax, 2 cmp ax, 2
je L17 je L17
cmp ax, 3 cmp ax, 3
je L18 je L18
dec ax dec ax
jne L15 jne L15
mov eax, DWORD PTR [esp+12] mov eax, DWORD PTR [esp+12]
add WORD PTR [edx+ebp], ax add WORD PTR [edx+ebp], ax
L17: L17:
add WORD PTR [edx+ebp], si add WORD PTR [edx+ebp], si
L18: L18:
add DWORD PTR [edx+ebp], esi add DWORD PTR [edx+ebp], esi
L15: L15:
inc edi inc edi
L13: L13:
cmp edi, ebx cmp edi, ebx
jne L14 jne L14
add ecx, DWORD PTR [ecx+4] add ecx, DWORD PTR [ecx+4]
L11: L11:
mov eax, DWORD PTR [ecx+4] mov eax, DWORD PTR [ecx+4]
test eax, eax test eax, eax
jne L12 jne L12
L9: L9:
mov edx, DWORD PTR [esp+32] mov edx, DWORD PTR [esp+32]
cmp DWORD PTR [edx+132], 0 cmp DWORD PTR [edx+132], 0
je L20 je L20
mov eax, ebp mov eax, ebp
add eax, DWORD PTR [edx+128] add eax, DWORD PTR [edx+128]
mov DWORD PTR [esp+40], 0 mov DWORD PTR [esp+40], 0
add eax, 20 add eax, 20
mov DWORD PTR [esp+56], eax mov DWORD PTR [esp+56], eax
L22: L22:
mov ecx, DWORD PTR [esp+56] mov ecx, DWORD PTR [esp+56]
cmp DWORD PTR [ecx-16], 0 cmp DWORD PTR [ecx-16], 0
jne L23 jne L23
cmp DWORD PTR [ecx-8], 0 cmp DWORD PTR [ecx-8], 0
je L25 je L25
L23: L23:
mov edi, DWORD PTR [__exports+32] mov edi, DWORD PTR [__exports+32]
mov esi, DWORD PTR [__exports+28] mov esi, DWORD PTR [__exports+28]
mov eax, DWORD PTR [esp+56] mov eax, DWORD PTR [esp+56]
mov DWORD PTR [esp+20], edi mov DWORD PTR [esp+20], edi
sub edi, -2147483648 sub edi, -2147483648
sub esi, -2147483648 sub esi, -2147483648
mov DWORD PTR [esp+44], esi mov DWORD PTR [esp+44], esi
mov ecx, DWORD PTR [eax-4] mov ecx, DWORD PTR [eax-4]
mov DWORD PTR [esp+48], edi mov DWORD PTR [esp+48], edi
mov edx, DWORD PTR [eax-20] mov edx, DWORD PTR [eax-20]
mov DWORD PTR [esp+52], 0 mov DWORD PTR [esp+52], 0
add ecx, ebp add ecx, ebp
add edx, ebp add edx, ebp
mov DWORD PTR [esp+24], edx mov DWORD PTR [esp+24], edx
mov DWORD PTR [esp+28], ecx mov DWORD PTR [esp+28], ecx
L26: L26:
mov esi, DWORD PTR [esp+52] mov esi, DWORD PTR [esp+52]
mov edi, DWORD PTR [esp+24] mov edi, DWORD PTR [esp+24]
mov eax, DWORD PTR [edi+esi*4] mov eax, DWORD PTR [edi+esi*4]
test eax, eax test eax, eax
je L27 je L27
test eax, eax test eax, eax
js L27 js L27
lea edi, [ebp+eax] lea edi, [ebp+eax]
mov eax, DWORD PTR [esp+28] mov eax, DWORD PTR [esp+28]
mov DWORD PTR [eax+esi*4], 0 mov DWORD PTR [eax+esi*4], 0
lea esi, [edi+2] lea esi, [edi+2]
push eax push eax
push 32 push 32
movzx eax, WORD PTR [edi] movzx eax, WORD PTR [edi]
mov edx, DWORD PTR [esp+56] mov edx, DWORD PTR [esp+56]
mov eax, DWORD PTR [edx+eax*4] mov eax, DWORD PTR [edx+eax*4]
sub eax, -2147483648 sub eax, -2147483648
push eax push eax
push esi push esi
call strncmp call strncmp
pop ebx pop ebx
xor ebx, ebx xor ebx, ebx
test eax, eax test eax, eax
jne L32 jne L32
jmp L30 jmp L30
L33: L33:
push ecx push ecx
push 32 push 32
mov ecx, DWORD PTR [esp+28] mov ecx, DWORD PTR [esp+28]
mov eax, DWORD PTR [ecx-2147483648+ebx*4] mov eax, DWORD PTR [ecx-2147483648+ebx*4]
sub eax, -2147483648 sub eax, -2147483648
push eax push eax
push esi push esi
call strncmp call strncmp
pop edx pop edx
test eax, eax test eax, eax
jne L34 jne L34
mov esi, DWORD PTR [esp+44] mov esi, DWORD PTR [esp+44]
mov edx, DWORD PTR [esp+52] mov edx, DWORD PTR [esp+52]
mov ecx, DWORD PTR [esp+28] mov ecx, DWORD PTR [esp+28]
mov eax, DWORD PTR [esi+ebx*4] mov eax, DWORD PTR [esi+ebx*4]
sub eax, -2147483648 sub eax, -2147483648
mov DWORD PTR [ecx+edx*4], eax mov DWORD PTR [ecx+edx*4], eax
jmp L36 jmp L36
L34: L34:
inc ebx inc ebx
L32: L32:
cmp ebx, DWORD PTR [__exports+24] cmp ebx, DWORD PTR [__exports+24]
jb L33 jb L33
L36: L36:
cmp ebx, DWORD PTR [__exports+24] cmp ebx, DWORD PTR [__exports+24]
jne L37 jne L37
mov esi, msg_unresolved mov esi, msg_unresolved
call sys_msg_board_str call sys_msg_board_str
lea esi, [edi+2] lea esi, [edi+2]
call sys_msg_board_str call sys_msg_board_str
mov esi, msg_CR mov esi, msg_CR
call sys_msg_board_str call sys_msg_board_str
mov DWORD PTR [esp+40], 1 mov DWORD PTR [esp+40], 1
jmp L37 jmp L37
L30: L30:
movzx eax, WORD PTR [edi] movzx eax, WORD PTR [edi]
mov esi, DWORD PTR [esp+44] mov esi, DWORD PTR [esp+44]
mov edi, DWORD PTR [esp+52] mov edi, DWORD PTR [esp+52]
mov edx, DWORD PTR [esp+28] mov edx, DWORD PTR [esp+28]
mov eax, DWORD PTR [esi+eax*4] mov eax, DWORD PTR [esi+eax*4]
sub eax, -2147483648 sub eax, -2147483648
mov DWORD PTR [edx+edi*4], eax mov DWORD PTR [edx+edi*4], eax
L37: L37:
inc DWORD PTR [esp+52] inc DWORD PTR [esp+52]
jmp L26 jmp L26
L27: L27:
add DWORD PTR [esp+56], 20 add DWORD PTR [esp+56], 20
jmp L22 jmp L22
L25: L25:
xor eax, eax xor eax, eax
cmp DWORD PTR [esp+40], 0 cmp DWORD PTR [esp+40], 0
jne L40 jne L40
L20: L20:
mov ecx, DWORD PTR [esp+32] mov ecx, DWORD PTR [esp+32]
mov eax, ebp mov eax, ebp
add eax, DWORD PTR [ecx+40] add eax, DWORD PTR [ecx+40]
L40: L40:
add esp, 60 add esp, 60
pop ebx pop ebx
pop esi pop esi
pop edi pop edi
pop ebp pop ebp
ret 8 ret 8
align 16 align 16
__exports: __exports:
export 'KERNEL', \ export 'KERNEL', \
alloc_kernel_space, 'AllocKernelSpace', \ ; stdcall alloc_kernel_space, 'AllocKernelSpace', \ ; stdcall
free_kernel_space, 'FreeKernelSpace', \ ; stdcall free_kernel_space, 'FreeKernelSpace', \ ; stdcall
kernel_alloc, 'KernelAlloc', \ ; stdcall kernel_alloc, 'KernelAlloc', \ ; stdcall
kernel_free, 'KernelFree', \ ; stdcall kernel_free, 'KernelFree', \ ; stdcall
malloc, 'Kmalloc', \ malloc, 'Kmalloc', \
free, 'Kfree', \ free, 'Kfree', \
map_io_mem, 'MapIoMem', \ ; stdcall map_io_mem, 'MapIoMem', \ ; stdcall
\ \
pci_api, 'PciApi', \ set_screen, 'SetScreen', \
pci_read8, 'PciRead8', \ ; stdcall pci_api, 'PciApi', \
pci_read16, 'PciRead16', \ ; stdcall pci_read8, 'PciRead8', \ ; stdcall
pci_read32, 'PciRead32', \ ; stdcall pci_read16, 'PciRead16', \ ; stdcall
pci_write8, 'PciWrite8', \ ; stdcall pci_read32, 'PciRead32', \ ; stdcall
pci_write16, 'PciWrite16', \ ; stdcall pci_write8, 'PciWrite8', \ ; stdcall
pci_write32, 'PciWrite32', \ ; stdcall pci_write16, 'PciWrite16', \ ; stdcall
\ pci_write32, 'PciWrite32', \ ; stdcall
reg_service, 'RegService', \ \
user_alloc, 'UserAlloc', \ ; stdcall reg_service, 'RegService', \
user_free, 'UserFree', \ ; stdcall user_alloc, 'UserAlloc', \ ; stdcall
sys_msg_board_str, 'SysMsgBoardStr' user_free, 'UserFree', \ ; stdcall
sys_msg_board_str, 'SysMsgBoardStr'

View File

@ -5173,6 +5173,41 @@ read_from_hd: ; Read from hd - fn not in use
paleholder: paleholder:
ret ret
align 4
set_screen:
cmp eax, [Screen_Max_X]
jne .set
cmp edx, [Screen_Max_Y]
jne .set
ret
.set:
pushfd
cli
mov [Screen_Max_X], eax
mov [Screen_Max_Y], edx
mov [screen_workarea.right],eax
mov [screen_workarea.bottom], edx
inc eax
shl eax, 2 ;32 bpp
mov [BytesPerScanLine], eax
push ebx
push esi
push edi
call repos_windows
mov eax, 0
mov ebx, 0
mov ecx, [Screen_Max_X]
mov edx, [Screen_Max_Y]
call calculatescreen
pop edi
pop esi
pop ebx
popfd
ret
; --------------- APM --------------------- ; --------------- APM ---------------------
apm_entry dp 0 apm_entry dp 0