/programs/develop/libraries/console_coff/build.bat |
---|
File deleted |
\ No newline at end of file |
/programs/develop/libraries/console_coff/console_ru.txt |
---|
File deleted |
/programs/develop/libraries/console_coff/conscrlv.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/develop/libraries/console_coff/Tupfile.lua |
---|
File deleted |
/programs/develop/libraries/console_coff/font8x16.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/develop/libraries/console_coff/conscrl.inc |
---|
File deleted |
/programs/develop/libraries/console_coff/font.inc |
---|
File deleted |
/programs/develop/libraries/console_coff/examples/testcon2_eng.asm |
---|
File deleted |
/programs/develop/libraries/console_coff/examples/testcon2_rus.asm |
---|
File deleted |
/programs/develop/libraries/console_coff/examples/testcon.asm |
---|
File deleted |
/programs/develop/libraries/console_coff/examples/proc32.inc |
---|
File deleted |
/programs/develop/libraries/console_coff/examples/test_gets.asm |
---|
File deleted |
/programs/develop/libraries/console_coff/examples/test_gets2.asm |
---|
File deleted |
/programs/develop/libraries/console_coff/examples/test_getch.asm |
---|
File deleted |
/programs/develop/libraries/console_coff/examples/Tupfile.lua |
---|
File deleted |
/programs/develop/libraries/console_coff/examples |
---|
Property changes: |
Deleted: svn:ignore |
-*.o |
-*.a |
/programs/develop/libraries/console_coff/console.asm |
---|
File deleted |
/programs/develop/libraries/console_coff/console_en.txt |
---|
File deleted |
\ No newline at end of file |
/programs/develop/libraries/console_coff |
---|
Property changes: |
Deleted: svn:ignore |
-*.o |
-*.a |
/programs/develop/libraries/console/console.asm |
---|
1,14 → 1,32 |
; ãªæ¨¨ à ¡®âë á ª®á®«ìî ¤«ï ¯à®£à ¬¬ ®«¨¡à¨ |
; diamond, 2006-2008 |
format PE console 0.8 DLL at 7FEF0000h |
section '.flat' code readable executable |
format MS COFF |
public EXPORTS |
section '.flat' code readable align 16 |
include 'font.inc' |
include 'conscrl.inc' |
include '../../../export.inc' |
;void __stdcall START(dword state); |
START: |
; N.B. The current kernel implementation does not require |
; evident heap initialization, because if DLL is loaded, heap is already initialized |
; (if heap was not initialized, loader does this implicitly). |
; So this action does nothing useful, but nothing harmful. |
push ebx |
push 68 |
pop eax |
push 11 |
pop ebx |
int 0x40 |
pop ebx |
or eax, -1 |
ret 4 |
; ¨æ¨ «¨§ æ¨ï ª®á®«¨ |
; void __stdcall con_init(dword wnd_width, dword wnd_height, |
; dword scr_width, dword scr_height, const char* title); |
15,11 → 33,6 |
align 4 |
con_init: |
mov [con_flags], 7 |
mov [con.cursor_height], (15*font_height+50)/100 |
mov [con.input_start], con.input_buffer |
mov [con.input_end], con.input_buffer |
mov [con.entered_char], -1 |
pop eax |
pop [con.wnd_width] |
1827,7 → 1840,6 |
; ®â®ª ®ª ª®á®«¨. ¡à ¡ âë¢ ¥â ¢¢®¤ ¨ ¢ë¢®¤. |
con.thread: |
or [con.vscroll_pt], -1 |
; ®â®ª ॠ£¨àã¥â IPC, ª®â®à®¥ ¨á¯®«ì§ã¥âáï ⮫쪮 ¤«ï ⮣®, çâ®¡ë ¥£® ¬®¦® ¡ë«® "à §¡ã¤¨âì" |
push 40 |
pop eax |
1837,7 → 1849,6 |
mov al, 60 |
mov bl, 1 |
mov ecx, con.ipc_buf |
mov byte [ecx+4], 8 |
push 0x11 |
pop edx |
int 0x40 |
2534,57 → 2545,109 |
con.def_wnd_x dd 200 |
con.def_wnd_y dd 50 |
con.init_cmd db 0 |
con.title_init_console db "Console",0 |
align 4 |
data export |
export 'console.dll', \ |
version, 'version', \ |
con_init, 'con_init', \ |
con_write_asciiz, 'con_write_asciiz', \ |
con_write_length, 'con_write_string', \ |
con_printf, 'con_printf', \ |
con_exit, 'con_exit', \ |
con_get_flags, 'con_get_flags', \ |
con_set_flags, 'con_set_flags', \ |
con_kbhit, 'con_kbhit', \ |
con_getch, 'con_getch', \ |
con_getch2, 'con_getch2', \ |
con_gets, 'con_gets', \ |
con_gets2, 'con_gets2', \ |
con_get_font_height, 'con_get_font_height', \ |
con_get_cursor_height, 'con_get_cursor_height', \ |
con_set_cursor_height, 'con_set_cursor_height', \ |
con_cls, 'con_cls', \ |
con_get_cursor_pos, 'con_get_cursor_pos', \ |
con_set_cursor_pos, 'con_set_cursor_pos', \ |
con_set_title, 'con_set_title' |
end data |
struc process_info |
{ |
cpu_usage dd ? ; +0 |
window_stack_position dw ? ; +4 |
window_stack_value dw ? ; +6 |
dw ? ; +8 |
process_name rb 12 ; +10 |
memory_start dd ? ; +22 |
used_memory dd ? ; +26 |
PID dd ? ; +30 |
box.x dd ? ; +34 |
box.y dd ? ; +38 |
box.width dd ? ; +42 |
box.height dd ? ; +46 |
slot_state dw ? ; +50 |
dw ? ; +52 |
client_box.x dd ? ; +54 |
client_box.y dd ? ; +58 |
client_box.width dd ? ; +62 |
client_box.height dd ? ; +66 |
wnd_state db ? ; +70 |
rb (1024-71) |
} |
process_info_buffer process_info |
window_status rd 1 |
version dd 0x00020008 |
con.vscroll_pt dd -1 |
align 16 |
EXPORTS: |
dd szStart, START |
dd szVersion, 0x00020008 |
dd szcon_init, con_init |
dd szcon_write_asciiz, con_write_asciiz |
dd szcon_write_string, con_write_length |
dd szcon_printf, con_printf |
dd szcon_exit, con_exit |
dd szcon_get_flags, con_get_flags |
dd szcon_set_flags, con_set_flags |
dd szcon_kbhit, con_kbhit |
dd szcon_getch, con_getch |
dd szcon_getch2, con_getch2 |
dd szcon_gets, con_gets |
dd szcon_gets2, con_gets2 |
dd szcon_get_font_height, con_get_font_height |
dd szcon_get_cursor_height,con_get_cursor_height |
dd szcon_set_cursor_height,con_set_cursor_height |
dd szcon_cls, con_cls |
dd szcon_get_cursor_pos, con_get_cursor_pos |
dd szcon_set_cursor_pos, con_set_cursor_pos |
dd szcon_set_title, con_set_title |
dd 0 |
con_flags dd 7 |
con.cursor_height dd (15*font_height+50)/100 |
con.input_start dd con.input_buffer |
con.input_end dd con.input_buffer |
con_esc_attr_n dd 0 |
con_esc_attrs dd 0,0,0,0 |
con_esc db 0 |
con_sci db 0 |
con.entered_char dw -1 |
con.bGetchRequested db 0 |
con.bWasE0 db 0 |
szStart db 'START',0 |
szcon_init db 'con_init',0 |
szcon_write_asciiz db 'con_write_asciiz',0 |
szcon_write_string db 'con_write_string',0 |
szcon_printf db 'con_printf',0 |
szcon_exit db 'con_exit',0 |
szVersion db 'version',0 |
szcon_get_flags db 'con_get_flags',0 |
szcon_set_flags db 'con_set_flags',0 |
szcon_kbhit db 'con_kbhit',0 |
szcon_getch db 'con_getch',0 |
szcon_getch2 db 'con_getch2',0 |
szcon_gets db 'con_gets',0 |
szcon_gets2 db 'con_gets2',0 |
szcon_get_font_height db 'con_get_font_height',0 |
szcon_get_cursor_height db 'con_get_cursor_height',0 |
szcon_set_cursor_height db 'con_set_cursor_height',0 |
szcon_cls db 'con_cls',0 |
szcon_get_cursor_pos db 'con_get_cursor_pos',0 |
szcon_set_cursor_pos db 'con_set_cursor_pos',0 |
szcon_set_title db 'con_set_title',0 |
con.thread_err db 'Cannot create console thread!',13,10,0 |
con.nomem_err db 'Not enough memory!',13,10,0 |
con.aFinished db ' [Finished]',0 |
con.aNull db '(null)',0 |
con.beep db 0x90, 0x3C, 0x00 |
con.ipc_buf dd 0,8,0,0 |
db 0 |
section '.data' data readable writable |
con_flags dd ? |
con.cursor_height dd ? |
con.input_start dd ? |
con.input_end dd ? |
section '.data' data readable writable align 16 |
con_esc_attr_n dd ? |
con_esc_attrs dd ?,?,?,? |
con_esc db ? |
con_sci db ? |
con.entered_char dw ? |
con.bGetchRequested db ? |
con.bWasE0 db ? |
con.init_cmd db ? |
con.finished_title rb 256 |
con.cur_x rd 1 |
2612,7 → 2675,6 |
con.bDownPressed_saved rb 1 |
con.bScrollingUp_saved rb 1 |
con.bScrollingDown_saved rb 1 |
con.vscroll_pt dd ? |
con.input_buffer rw 128 |
con.input_buffer_end = $ |
2619,8 → 2681,6 |
con.kbd_layout rb 128 |
con.ipc_buf rb 0x11 |
; 1 = exit, 2 = set title, 3 = redraw, 4 = getch |
con.thread_op rb 1 |
con.bUpPressed rb 1 |
2630,29 → 2690,3 |
con.stack rb 1024 |
con.stack_top = $ |
struc process_info |
{ |
cpu_usage dd ? ; +0 |
window_stack_position dw ? ; +4 |
window_stack_value dw ? ; +6 |
dw ? ; +8 |
process_name rb 12 ; +10 |
memory_start dd ? ; +22 |
used_memory dd ? ; +26 |
PID dd ? ; +30 |
box.x dd ? ; +34 |
box.y dd ? ; +38 |
box.width dd ? ; +42 |
box.height dd ? ; +46 |
slot_state dw ? ; +50 |
dw ? ; +52 |
client_box.x dd ? ; +54 |
client_box.y dd ? ; +58 |
client_box.width dd ? ; +62 |
client_box.height dd ? ; +66 |
wnd_state db ? ; +70 |
rb (1024-71) |
} |
process_info_buffer process_info |
window_status rd 1 |
/programs/develop/libraries/console/Tupfile.lua |
---|
1,3 → 1,2 |
if tup.getconfig("NO_FASM") ~= "" then return end |
ROOT = "../../../.." |
tup.rule("console.asm", "fasm %f %o " .. tup.getconfig("PESTRIP_CMD") .. tup.getconfig("KPACK_CMD"), "console.dll") |
tup.rule("console.asm", "fasm %f %o " .. tup.getconfig("KPACK_CMD"), "console.obj") |
/programs/develop/libraries/console/examples/Tupfile.lua |
---|
1,3 → 1,2 |
if tup.getconfig("NO_FASM") ~= "" then return end |
ROOT = "../../../../.." |
tup.foreach_rule("*.asm", "fasm %f %o " .. tup.getconfig("PESTRIP_CMD") .. tup.getconfig("KPACK_CMD"), "%B") |
tup.foreach_rule("*.asm", "fasm %f %o " .. tup.getconfig("KPACK_CMD"), "%B") |
/programs/develop/libraries/console/examples/testcon2_rus.asm |
---|
1,9 → 1,41 |
format PE console 0.8 |
include 'proc32.inc' |
include '../../../../import.inc' |
DLL_ENTRY equ 1 |
DLL_EXIT equ -1 |
REQ_DLL_VER equ 2 |
use32 |
db 'MENUET01' |
dd 1 |
dd start |
dd i_end |
dd mem |
dd mem |
dd 0 |
dd 0 |
start: |
invoke con_set_title, caption |
stdcall load_dll_and_import, dllname, imports |
test eax, eax |
jz exit |
; check version |
cmp word [dll_ver], REQ_DLL_VER |
jb exit |
cmp word [dll_ver+2], REQ_DLL_VER |
ja exit |
push DLL_ENTRY |
call [dll_start] |
; yes! Now do some work (show color strings in this case). |
push caption |
push -1 |
push -1 |
push -1 |
push -1 |
call [con_init] |
; C-equivalent of the following code: |
; for (ebx=0;ebx<0x100;ebx++) |
; { |
35,20 → 67,86 |
push 0 |
call [con_exit] |
exit: |
or eax, -1 |
int 0x40 |
proc load_dll_and_import stdcall, _dllname:dword, _imports:dword |
pushad |
; load DLL |
push 68 |
pop eax |
push 19 |
pop ebx |
mov ecx, [_dllname] |
int 0x40 |
test eax, eax |
jz import_fail |
; initialize import |
mov edi, eax |
mov esi, [_imports] |
import_loop: |
lodsd |
test eax, eax |
jz import_done |
mov edx, edi |
import_find: |
mov ebx, [edx] |
test ebx, ebx |
jz import_not_found |
push eax |
@@: |
mov cl, [eax] |
cmp cl, [ebx] |
jnz import_find_next |
test cl, cl |
jz import_found |
inc eax |
inc ebx |
jmp @b |
import_find_next: |
pop eax |
add edx, 8 |
jmp import_find |
import_found: |
pop eax |
mov eax, [edx+4] |
mov [esi-4], eax |
jmp import_loop |
import_not_found: |
import_fail: |
popad |
xor eax, eax |
ret |
import_done: |
popad |
xor eax, eax |
inc eax |
ret |
endp |
align 4 |
data import |
library console, 'console.dll' |
import console, \ |
con_set_title, 'con_set_title', \ |
con_write_asciiz, 'con_write_asciiz', \ |
con_printf, 'con_printf', \ |
con_set_flags, 'con_set_flags', \ |
con_exit, 'con_exit' |
end data |
imports: |
dll_start dd szStart |
dll_ver dd szVersion |
con_init dd szcon_init |
con_write_asciiz dd szcon_write_asciiz |
con_printf dd szcon_printf |
con_set_flags dd szcon_set_flags |
con_exit dd szcon_exit |
dd 0 |
szStart db 'START',0 |
szVersion db 'version',0 |
szcon_init db 'con_init',0 |
szcon_write_asciiz db 'con_write_asciiz',0 |
szcon_printf db 'con_printf',0 |
szcon_set_flags db 'con_set_flags',0 |
szcon_exit db 'con_exit',0 |
dllname db '/sys/lib/console.obj',0 |
caption db 'Console test - colors',0 |
t1 db '¢¥â 0x%02X: ',0 |
text db '®â ¯à¨¬¥à ⥪áâ .',10,0 |
55,3 → 153,9 |
text2 db 27,'[7m íâ® ¯à¨¬¥à ¨á¯®«ì§®¢ ¨ï ' |
db 27,'[1;36;41mEsc' |
db 27,'[7m-¯®á«¥¤®¢ ⥫ì®á⥩.',10,0 |
i_end: |
align 4 |
rb 2048 ; stack |
mem: |
/programs/develop/libraries/console/examples/testcon.asm |
---|
1,20 → 1,58 |
format PE console 0.8 |
include '../../../../import.inc' |
use32 |
db 'MENUET01' |
dd 1 |
dd start |
dd i_end |
dd mem |
dd mem |
dd 0 |
dd 0 |
; useful includes |
include '../../../../macros.inc' |
purge mov,add,sub |
include '../../../../proc32.inc' |
include '../../../../dll.inc' |
start: |
; First 3 steps are intended to load/init console DLL |
; and are identical for all console programs |
; load DLL |
stdcall dll.Load, @IMPORT |
test eax, eax |
jnz exit |
; yes! Now do some work (say helloworld in this case). |
push caption |
push -1 |
push -1 |
push -1 |
push -1 |
call [con_init] |
push aHelloWorld |
call [con_write_asciiz] |
push 0 |
call [con_exit] |
xor eax, eax |
ret |
exit: |
or eax, -1 |
int 0x40 |
caption db 'Console test',0 |
aHelloWorld db 'Hello, World!',10,0 |
align 4 |
data import |
library console, 'console.dll' |
@IMPORT: |
library console, 'console.obj' |
import console, \ |
con_start, 'START', \ |
con_init, 'con_init', \ |
con_write_asciiz, 'con_write_asciiz', \ |
con_exit, 'con_exit' |
end data |
con_exit, 'con_exit', \ |
con_gets, 'con_gets' |
i_end: |
align 4 |
rb 2048 ; stack |
mem: |
/programs/develop/libraries/console/examples/test_getch.asm |
---|
1,10 → 1,42 |
format PE console 0.8 |
include 'proc32.inc' |
include '../../../../import.inc' |
DLL_ENTRY equ 1 |
DLL_EXIT equ -1 |
REQ_DLL_VER equ 3 |
use32 |
db 'MENUET01' |
dd 1 |
dd start |
dd i_end |
dd mem |
dd mem |
dd 0 |
dd 0 |
start: |
invoke con_set_title, caption |
stdcall load_dll_and_import, dllname, imports |
test eax, eax |
jz exit |
; check version |
cmp word [dll_ver], REQ_DLL_VER |
jb exit |
cmp word [dll_ver+2], REQ_DLL_VER |
ja exit |
push DLL_ENTRY |
call [dll_start] |
; yes! Now do some work (getch() demo in this case). |
push caption |
push -1 |
push -1 |
push -1 |
push -1 |
call [con_init] |
; C-equivalent of the following code: |
; con_printf(start_string); |
; int c; |
46,20 → 78,91 |
push 1 |
call [con_exit] |
exit: |
or eax, -1 |
int 0x40 |
proc load_dll_and_import stdcall, _dllname:dword, _imports:dword |
pushad |
; load DLL |
push 68 |
pop eax |
push 19 |
pop ebx |
mov ecx, [_dllname] |
int 0x40 |
test eax, eax |
jz import_fail |
; initialize import |
mov edi, eax |
mov esi, [_imports] |
import_loop: |
lodsd |
test eax, eax |
jz import_done |
mov edx, edi |
import_find: |
mov ebx, [edx] |
test ebx, ebx |
jz import_not_found |
push eax |
@@: |
mov cl, [eax] |
cmp cl, [ebx] |
jnz import_find_next |
test cl, cl |
jz import_found |
inc eax |
inc ebx |
jmp @b |
import_find_next: |
pop eax |
add edx, 8 |
jmp import_find |
import_found: |
pop eax |
mov eax, [edx+4] |
mov [esi-4], eax |
jmp import_loop |
import_not_found: |
import_fail: |
popad |
xor eax, eax |
ret |
import_done: |
popad |
xor eax, eax |
inc eax |
ret |
endp |
align 4 |
data import |
library console, 'console.dll' |
import console, \ |
con_set_title, 'con_set_title', \ |
con_printf, 'con_printf', \ |
con_exit, 'con_exit', \ |
con_getch, 'con_getch' |
end data |
imports: |
dll_start dd szStart |
dll_ver dd szVersion |
con_init dd szcon_init |
con_printf dd szcon_printf |
con_exit dd szcon_exit |
con_getch dd szcon_getch |
dd 0 |
szStart db 'START',0 |
szVersion db 'version',0 |
szcon_init db 'con_init',0 |
szcon_printf db 'con_printf',0 |
szcon_exit db 'con_exit',0 |
szcon_getch db 'con_getch',0 |
dllname db '/sys/lib/console.obj',0 |
caption db 'Console test - getch()',0 |
start_string db 'Press any key to see its code, or Esc to exit',10,0 |
string_normal db 'normal character with code %d=0x%02X',10,0 |
string_extended db 'extended character with code %d=0x%02X',10,0 |
i_end: |
align 4 |
rb 2048 ; stack |
mem: |
/programs/develop/libraries/console/examples/test_gets.asm |
---|
1,10 → 1,42 |
format PE console 0.8 |
include 'proc32.inc' |
include '../../../../import.inc' |
DLL_ENTRY equ 1 |
DLL_EXIT equ -1 |
REQ_DLL_VER equ 3 |
use32 |
db 'MENUET01' |
dd 1 |
dd start |
dd i_end |
dd mem |
dd mem |
dd 0 |
dd 0 |
start: |
invoke con_set_title, caption |
stdcall load_dll_and_import, dllname, imports |
test eax, eax |
jz exit |
; check version |
cmp word [dll_ver], REQ_DLL_VER |
jb exit |
cmp word [dll_ver+2], REQ_DLL_VER |
ja exit |
push DLL_ENTRY |
call [dll_start] |
; yes! Now do some work (gets() demo in this case). |
push caption |
push -1 |
push -1 |
push -1 |
push -1 |
call [con_init] |
; C-equivalent of the following code: |
; for (;;) |
; { |
33,22 → 65,92 |
push 1 |
call [con_exit] |
exit: |
or eax, -1 |
int 0x40 |
proc load_dll_and_import stdcall, _dllname:dword, _imports:dword |
pushad |
; load DLL |
push 68 |
pop eax |
push 19 |
pop ebx |
mov ecx, [_dllname] |
int 0x40 |
test eax, eax |
jz import_fail |
; initialize import |
mov edi, eax |
mov esi, [_imports] |
import_loop: |
lodsd |
test eax, eax |
jz import_done |
mov edx, edi |
import_find: |
mov ebx, [edx] |
test ebx, ebx |
jz import_not_found |
push eax |
@@: |
mov cl, [eax] |
cmp cl, [ebx] |
jnz import_find_next |
test cl, cl |
jz import_found |
inc eax |
inc ebx |
jmp @b |
import_find_next: |
pop eax |
add edx, 8 |
jmp import_find |
import_found: |
pop eax |
mov eax, [edx+4] |
mov [esi-4], eax |
jmp import_loop |
import_not_found: |
import_fail: |
popad |
xor eax, eax |
ret |
import_done: |
popad |
xor eax, eax |
inc eax |
ret |
endp |
align 4 |
data import |
library console, 'console.dll' |
import console, \ |
con_set_title, 'con_set_title', \ |
con_write_asciiz, 'con_write_asciiz', \ |
con_exit, 'con_exit', \ |
con_gets, 'con_gets' |
end data |
imports: |
dll_start dd szStart |
dll_ver dd szVersion |
con_init dd szcon_init |
con_write_asciiz dd szcon_write_asciiz |
con_exit dd szcon_exit |
con_gets dd szcon_gets |
dd 0 |
szStart db 'START',0 |
szVersion db 'version',0 |
szcon_init db 'con_init',0 |
szcon_write_asciiz db 'con_write_asciiz',0 |
szcon_exit db 'con_exit',0 |
szcon_gets db 'con_gets',0 |
dllname db '/sys/lib/console.obj',0 |
caption db 'Console test - gets()',0 |
str1 db 'Enter string (empty for exit): ',0 |
str2 db 'You entered: ',0 |
i_end: |
s rb 256 |
align 4 |
rb 2048 ; stack |
mem: |
/programs/develop/libraries/console/examples/test_gets2.asm |
---|
1,8 → 1,35 |
format PE GUI 0.8 ; initialize console ourselves |
include 'proc32.inc' |
include '../../../../import.inc' |
DLL_ENTRY equ 1 |
DLL_EXIT equ -1 |
REQ_DLL_VER equ 4 |
use32 |
db 'MENUET01' |
dd 1 |
dd start |
dd i_end |
dd mem |
dd mem |
dd 0 |
dd 0 |
start: |
stdcall load_dll_and_import, dllname, imports |
test eax, eax |
jz exit |
; check version |
cmp word [dll_ver], REQ_DLL_VER |
jb exit |
cmp word [dll_ver+2], REQ_DLL_VER |
ja exit |
push DLL_ENTRY |
call [dll_start] |
; yes! Now do some work (gets2() demo in this case). |
push caption |
push 25 |
push 80 |
39,8 → 66,8 |
push 1 |
call [con_exit] |
exit: |
xor eax, eax |
ret |
or eax, -1 |
int 0x40 |
proc mycallback stdcall, keycode:dword, pstr:dword, pn:dword, ppos:dword |
mov eax, [keycode] |
133,17 → 160,81 |
ret |
endp |
proc load_dll_and_import stdcall, _dllname:dword, _imports:dword |
pushad |
; load DLL |
push 68 |
pop eax |
push 19 |
pop ebx |
mov ecx, [_dllname] |
int 0x40 |
test eax, eax |
jz import_fail |
; initialize import |
mov edi, eax |
mov esi, [_imports] |
import_loop: |
lodsd |
test eax, eax |
jz import_done |
mov edx, edi |
import_find: |
mov ebx, [edx] |
test ebx, ebx |
jz import_not_found |
push eax |
@@: |
mov cl, [eax] |
cmp cl, [ebx] |
jnz import_find_next |
test cl, cl |
jz import_found |
inc eax |
inc ebx |
jmp @b |
import_find_next: |
pop eax |
add edx, 8 |
jmp import_find |
import_found: |
pop eax |
mov eax, [edx+4] |
mov [esi-4], eax |
jmp import_loop |
import_not_found: |
import_fail: |
popad |
xor eax, eax |
ret |
import_done: |
popad |
xor eax, eax |
inc eax |
ret |
endp |
align 4 |
data import |
library console, 'console.dll' |
import console, \ |
con_init, 'con_init', \ |
con_write_asciiz, 'con_write_asciiz', \ |
con_exit, 'con_exit', \ |
con_gets2, 'con_gets2' |
end data |
imports: |
dll_start dd szStart |
dll_ver dd szVersion |
con_init dd szcon_init |
con_write_asciiz dd szcon_write_asciiz |
con_exit dd szcon_exit |
con_gets2 dd szcon_gets2 |
dd 0 |
szStart db 'START',0 |
szVersion db 'version',0 |
szcon_init db 'con_init',0 |
szcon_write_asciiz db 'con_write_asciiz',0 |
szcon_exit db 'con_exit',0 |
szcon_gets2 db 'con_gets2',0 |
dllname db '/sys/lib/console.obj',0 |
caption db 'Console test - gets2()',0 |
str1 db 'Enter string (empty for exit): ',0 |
str2 db 'You entered: ',0 |
155,4 → 246,10 |
str6 db 'next line in the history' |
str6.len = $ - str6 |
i_end: |
s rb 256 |
align 4 |
rb 2048 ; stack |
mem: |
/programs/develop/libraries/console/examples/testcon2_eng.asm |
---|
1,9 → 1,41 |
format PE console 0.8 |
include 'proc32.inc' |
include '../../../../import.inc' |
DLL_ENTRY equ 1 |
DLL_EXIT equ -1 |
REQ_DLL_VER equ 2 |
use32 |
db 'MENUET01' |
dd 1 |
dd start |
dd i_end |
dd mem |
dd mem |
dd 0 |
dd 0 |
start: |
invoke con_set_title, caption |
stdcall load_dll_and_import, dllname, imports |
test eax, eax |
jz exit |
; check version |
cmp word [dll_ver], REQ_DLL_VER |
jb exit |
cmp word [dll_ver+2], REQ_DLL_VER |
ja exit |
push DLL_ENTRY |
call [dll_start] |
; yes! Now do some work (show color strings in this case). |
push caption |
push -1 |
push -1 |
push -1 |
push -1 |
call [con_init] |
; C-equivalent of the following code: |
; for (ebx=0;ebx<0x100;ebx++) |
; { |
35,20 → 67,86 |
push 0 |
call [con_exit] |
exit: |
or eax, -1 |
int 0x40 |
proc load_dll_and_import stdcall, _dllname:dword, _imports:dword |
pushad |
; load DLL |
push 68 |
pop eax |
push 19 |
pop ebx |
mov ecx, [_dllname] |
int 0x40 |
test eax, eax |
jz import_fail |
; initialize import |
mov edi, eax |
mov esi, [_imports] |
import_loop: |
lodsd |
test eax, eax |
jz import_done |
mov edx, edi |
import_find: |
mov ebx, [edx] |
test ebx, ebx |
jz import_not_found |
push eax |
@@: |
mov cl, [eax] |
cmp cl, [ebx] |
jnz import_find_next |
test cl, cl |
jz import_found |
inc eax |
inc ebx |
jmp @b |
import_find_next: |
pop eax |
add edx, 8 |
jmp import_find |
import_found: |
pop eax |
mov eax, [edx+4] |
mov [esi-4], eax |
jmp import_loop |
import_not_found: |
import_fail: |
popad |
xor eax, eax |
ret |
import_done: |
popad |
xor eax, eax |
inc eax |
ret |
endp |
align 4 |
data import |
library console, 'console.dll' |
import console, \ |
con_set_title, 'con_set_title', \ |
con_write_asciiz, 'con_write_asciiz', \ |
con_printf, 'con_printf', \ |
con_set_flags, 'con_set_flags', \ |
con_exit, 'con_exit' |
end data |
imports: |
dll_start dd szStart |
dll_ver dd szVersion |
con_init dd szcon_init |
con_write_asciiz dd szcon_write_asciiz |
con_printf dd szcon_printf |
con_set_flags dd szcon_set_flags |
con_exit dd szcon_exit |
dd 0 |
szStart db 'START',0 |
szVersion db 'version',0 |
szcon_init db 'con_init',0 |
szcon_write_asciiz db 'con_write_asciiz',0 |
szcon_printf db 'con_printf',0 |
szcon_set_flags db 'con_set_flags',0 |
szcon_exit db 'con_exit',0 |
dllname db '/sys/lib/console.obj',0 |
caption db 'Console test - colors',0 |
t1 db 'Color 0x%02X: ',0 |
text db 'This is sample text.',10,0 |
55,3 → 153,9 |
text2 db 27,'[7mAnd this is an example of ' |
db 27,'[1;36;41mEsc' |
db 27,'[7m-sequences.',10,0 |
i_end: |
align 4 |
rb 2048 ; stack |
mem: |
/programs/develop/libraries/console/console_en.txt |
---|
1,4 → 1,4 |
console.dll exports the following functions |
console.obj exports the following functions |
typedef unsigned long dword; /* 32-bit unsigned integer */ |
typedef unsigned short word; /* 16-bit unsigned integer */ |
/programs/develop/libraries/console/console_ru.txt |
---|
1,4 → 1,4 |
console.dll ýêñïîðòèðóåò ñëåäóþùèå ôóíêöèè: |
console.obj ýêñïîðòèðóåò ñëåäóþùèå ôóíêöèè: |
typedef unsigned long dword; /* 32-áèòíîå áåççíàêîâîå öåëîå */ |
typedef unsigned short word; /* 16-áèòíîå áåççíàêîâîå öåëîå */ |