git-svn-id: svn://kolibrios.org@897 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-11-03 09:38:21 +00:00
parent 7470652b79
commit 53f90bca38
9 changed files with 616 additions and 157 deletions

View File

@ -326,8 +326,6 @@ BgrDrawMode equ (OS_BASE+0x023BFF4)
BgrDataWidth equ (OS_BASE+0x023BFF8)
BgrDataHeight equ (OS_BASE+0x023BFFC)
;display_data equ (OS_BASE+0x023C000) ;1024*1280=0x140000
virtual at (OS_BASE+0x023CF80)
tss TSS
end virtual

View File

@ -9,6 +9,9 @@
int __stdcall strncmp(const char *s1, const char *s2, size_t n);
extern int __stdcall mnt_exec(void *raw, size_t raw_size, char *path,
char *cmdline, u32_t flags) asm ("mnt_exec");
static dll_t core_dll;
static char* strupr(char *str )
@ -27,6 +30,37 @@ static char* strupr(char *str )
return( str );
}
void * memcpy(void * _dest, const void *_src, size_t _n)
{
int d0, d1, d2;
__asm__ __volatile__(
"rep ; movsl\n\t"
"testb $2,%b4\n\t"
"je 1f\n\t"
"movsw\n"
"1:\ttestb $1,%b4\n\t"
"je 2f\n\t"
"movsb\n"
"2:"
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
:"0" (_n/4), "q" (_n),"1" ((long)_dest),"2" ((long)_src)
: "memory");
return (_dest);
}
size_t strlen(const char *str)
{
int d0;
register int __res;
__asm__ __volatile__(
"repne\n\t"
"scasb\n\t"
"notl %0\n\t"
"decl %0"
:"=c" (__res), "=&D" (d0) :"1" (str),"a" (0), "0" (0xffffffff));
return __res;
}
void init_core_dll()
{
PIMAGE_DOS_HEADER dos;
@ -124,3 +158,221 @@ srv_t* __fastcall load_pe_driver(const char *path)
}
}
typedef struct
{
int a_type;
union
{
long a_val;
void *a_ptr;
void (*a_fcn)( ) ;
}a_un;
}auxv_t;
#define AUX_COUNT 0
typedef struct
{
int argc; /* always 2 */
char *path; /* argv[0] program path */
char *cmdline; /* argv[1] command line. May be null */
u32_t sep1; /* separator. must be zero */
char *env; /* single environment string */
u32_t sep2; /* separator. must be zero */
auxv_t aux[1]; /* aux. AT_NULL for now */
}exec_stack_t;
addr_t new_app_space(void);
int __stdcall pe_app_param(char *path, void *raw, addr_t ex_pg_dir,
addr_t ex_stack_page) asm ("pe_app_param");
int sys_exec(char *path, char *cmdline, u32_t flags)
{
addr_t ex_pg_dir;
addr_t ex_stack_tab;
addr_t ex_stack_page;
addr_t ex_pl0_stack;
exec_stack_t *ex_stack;
int stack_size;
char *ex_path;
char *ex_cmdline = NULL;
size_t raw_size;
u32_t *raw;
int pathsize = 0;
int cmdsize = 0;
int envsize = 0;
u32_t tmp;
DBG("\nexec %s cmd %s flags %x\n", path, cmdline, flags);
if( ! path)
{
DBG("invalid path\n");
return;
};
raw = load_file(path, &raw_size);
if( ! raw )
return -5; /* FIXME */
if( (raw[0] == 0x554E454D) &&
( ( raw[1] == 0x31305445) ||
( raw[1] == 0x30305445) ) )
{
DBG("leagacy Kolibri application\n");
int tmp = mnt_exec(raw, raw_size, path, cmdline, flags);
return tmp;
}
if( ! validate_pe(raw, raw_size) )
{
DBG("invalid executable file %s\n", path);
mem_free(raw);
return -31;
}
pathsize = strlen(path)+1;
if( cmdline )
cmdsize = strlen(cmdline)+1;
stack_size = sizeof(exec_stack_t) + pathsize +
cmdsize + envsize + AUX_COUNT*sizeof(auxv_t);
stack_size = (stack_size + 15) & ~15; /* keep stack aligned */
DBG("stacksize %d\n", stack_size);
if( stack_size > 4096 )
{
DBG("command line too long\n");
return -30;
}
ex_pg_dir = new_app_space();
if( !ex_pg_dir )
{
mem_free(raw);
return -30; /* FIXME */
};
ex_stack_tab = ex_pg_dir + 4096;
ex_pl0_stack = ex_pg_dir + 4096 * 2;
ex_stack_page = core_alloc(0); /* 2^0 = 1 page */
if( ! ex_stack_page )
{
core_free(ex_stack_tab);
mem_free(raw);
return -30; /* FIXME */
};
__asm__ __volatile__ (
"xorl %%eax, %%eax \n\t"
"rep stosl"
:"=c"(tmp),"=D"(tmp)
:"c"(1024),"D"(ex_stack_page + OS_BASE)
:"eax","cc");
((u32_t*)(ex_stack_tab+OS_BASE))[1023] = ex_stack_page | 7;
ex_stack = (exec_stack_t*)(ex_stack_page + OS_BASE
+ PAGE_SIZE - stack_size);
ex_stack->argc = 2;
ex_path = MakePtr(char*, ex_stack, sizeof(exec_stack_t)+AUX_COUNT*sizeof(auxv_t));
memcpy(ex_path, path, pathsize);
ex_stack->path = (char*)(((addr_t)ex_path & 0xFFF) + 0x7FCFF000); /* top of stack */
if( cmdline )
{
ex_cmdline = ex_path + pathsize;
memcpy(ex_cmdline, cmdline, cmdsize);
ex_stack->cmdline = ex_stack->path + pathsize;
};
/*
ex_stack.env = null
ex_stack.aux[0] = AT_NULL
*/
DBG("create stack at %x\n\tpath %x\n\tcmdline %x\n",
ex_stack, ex_stack->path, ex_stack->cmdline);
pe_app_param(path, raw, ex_pg_dir, ex_stack_page);
return 0;
};
#define master_tab (page_tabs+ (page_tabs>>10))
void sys_app_entry(addr_t raw, addr_t ex_stack)
{
PIMAGE_DOS_HEADER dos;
PIMAGE_NT_HEADERS32 nt;
size_t img_size;
count_t img_pages;
count_t img_tabs;
count_t i;
u32_t tmp;
__asm__ __volatile__ ("sti");
DBG("pe_app_entry: raw %x esp %x\n", raw, ex_stack);
dos = (PIMAGE_DOS_HEADER)raw;
nt = MakePtr( PIMAGE_NT_HEADERS32, dos, dos->e_lfanew);
img_size = nt->OptionalHeader.SizeOfImage;
img_pages = img_size >> 12;
img_tabs = ((img_size + 0x3FFFFF) & ~0x3FFFFF) >> 22;
DBG("app pages %d app tabs %d\n", img_pages, img_tabs);
for(i = 0; i < img_tabs; i++)
{
addr_t tab = core_alloc(0);
((u32_t*)master_tab)[i] = tab|7; /* FIXME */
}
((u32_t*)master_tab)[0x7FC/4] = (ex_stack & 0xFFFFF000)|7; /* FIXME */
__asm__ __volatile__ (
"xorl %%eax, %%eax \n\t"
"rep stosl"
:"=c"(tmp),"=D"(tmp)
:"c"(img_tabs<<10),"D"(page_tabs)
:"eax","cc");
for(i = 0; i < img_pages; i++)
{
addr_t page = core_alloc(0);
((u32_t*)page_tabs)[i] = page | 7; /* FIXME */
}
create_image(0, raw);
__asm__ __volatile__ (
"xchgw %bx, %bx");
addr_t entry = nt->OptionalHeader.AddressOfEntryPoint +
nt->OptionalHeader.ImageBase;
// __asm__ __volatile__ (
// "call %0":: "r" (entry));
while(1);
};

View File

@ -368,11 +368,18 @@ update_mem_size:
align 4
_GetPgAddr:
get_pg_addr:
cmp eax, OS_BASE
jae @F
shr eax, 12
mov eax, [page_tabs+eax*4]
and eax, 0xFFFFF000
ret
@@:
sub eax, OS_BASE
and eax, 0xFFFFF000
ret
align 4
proc page_fault_handler

View File

@ -7,8 +7,11 @@
$Revision$
EFL_IF equ 0x0200
EFL_IOPL1 equ 0x1000
EFL_IOPL2 equ 0x2000
EFL_IOPL3 equ 0x3000
GREEDY_KERNEL equ 0
struc APP_HEADER_00
{ .banner dq ?
@ -46,31 +49,79 @@ macro _clear_ op
rep stosd
}
fs_execute_from_sysdir:
xor ebx, ebx
xor edx, edx
mov esi, sysdir_path
align 4
proc fs_execute
test_app_header:
virtual at eax
APP_HEADER_00 APP_HEADER_00
end virtual
virtual at eax
APP_HEADER_01 APP_HEADER_01
end virtual
;fn_read:dword, file_size:dword, cluster:dword
cmp dword [eax], 'MENU'
jne .fail
cmp word [eax+4],'ET'
jne .fail
; ebx - cmdline
; edx - flags
; ebp - full filename
; [esp+4] = procedure DoRead, [esp+8] = filesize & [esp+12]... - arguments for it
cmp [eax+6], word '00'
jne .check_01_header
mov ecx,[APP_HEADER_00.start]
mov [ebx+0x08], ecx ;app_eip
mov edx,[APP_HEADER_00.mem_size]
mov [ebx+0x10], edx ;app_mem
shr edx,1
sub edx,0x10
mov [ebx+0x0C], edx ;app_esp
mov ecx,[APP_HEADER_00.i_param]
mov [ebx], ecx ;app_cmdline
mov [ebx+4], dword 0 ;app_path
mov edx, [APP_HEADER_00.i_end]
mov [ebx+0x14], edx
ret
.check_01_header:
cmp [eax+6],word '01'
jne .fail
mov ecx,[APP_HEADER_01.start]
mov [ebx+0x08], ecx ;app_eip
mov edx,[APP_HEADER_01.mem_size]
; \begin{diamond}[20.08.2006]
; sanity check (functions 19,58 load app_i_end bytes and that must
; fit in allocated memory to prevent kernel faults)
cmp edx,[APP_HEADER_01.i_end]
jb .fail
; \end{diamond}[20.08.2006]
mov [ebx+0x10], edx ;app_mem
mov ecx,[APP_HEADER_01.stack_top]
mov [ebx+0x0C], ecx ;app_esp
mov edx,[APP_HEADER_01.i_param]
mov [ebx], edx ;app_cmdline
mov ecx,[APP_HEADER_01.i_icon]
mov [ebx+4], ecx ;app_path
mov edx, [APP_HEADER_01.i_end]
mov [ebx+0x14], edx
ret
.fail:
xor eax, eax
ret
proc mnt_exec stdcall file_base:dword, file_size:dword, \
path:dword, cmd_line:dword, flags:dword
locals
cmdline rd 64 ;256/4
filename rd 256 ;1024/4
flags dd ?
cmdline rb 256
filename rb 1024
save_cr3 dd ?
slot dd ?
slot_base dd ?
file_base dd ?
file_size dd ?
;app header data
hdr_cmdline dd ? ;0x00
hdr_path dd ? ;0x04
@ -80,16 +131,13 @@ proc fs_execute
hdr_i_end dd ? ;0x14
endl
pushad
mov [flags], edx
; [ebp] pointer to filename
push ebx
push edi
push esi
mov esi, [path]
lea edi, [filename]
lea ecx, [edi+1024]
mov al, '/'
stosb
@@:
cmp edi, ecx
jae .bigfilename
@ -97,41 +145,26 @@ proc fs_execute
stosb
test al, al
jnz @b
mov esi, [ebp]
mov esi, [cmd_line]
test esi, esi
jz .namecopied
mov byte [edi-1], '/'
jz .no_cmdline
lea edi, [cmdline]
lea ecx, [edi+255]
mov [edi+252], dword 0
@@:
cmp edi, ecx
jae .bigfilename
jae .no_cmdline
lodsb
stosb
test al, al
jnz @b
jmp .namecopied
.bigfilename:
popad
mov eax, -ERROR_FILE_NOT_FOUND
ret
.namecopied:
mov [cmdline], ebx
test ebx, ebx
jz @F
lea eax, [cmdline]
mov dword [eax+252], 0
stdcall strncpy, eax, ebx, 255
@@:
lea eax, [filename]
stdcall load_file, eax
mov ecx, -ERROR_FILE_NOT_FOUND
test eax, eax
jz .err_file
mov [file_base], eax
mov [file_size], ebx
.no_cmdline:
mov eax, [file_base]
lea ebx, [hdr_cmdline]
call test_app_header
mov ecx, -0x1F
@ -140,17 +173,8 @@ proc fs_execute
DEBUGF 1,"%s",new_process_loading
.wait_lock:
cmp [application_table_status],0
je .get_lock
call change_task
jmp .wait_lock
.get_lock:
mov eax, 1
xchg eax, [application_table_status]
cmp eax, 0
jne .wait_lock
lea ebx, [application_table_status]
call wait_mutex
call set_application_table_status
@ -222,9 +246,20 @@ proc fs_execute
mov eax, [save_cr3]
call set_cr3
xor ebx, ebx
mov [application_table_status],ebx ;unlock application_table_status mutex
mov [application_table_status], 0 ;unlock application_table_status mutex
mov eax,[process_number] ;set result
pop edi
pop esi
pop ebx
ret
.bigfilename:
pop edi
pop esi
pop ebx
mov eax, -ERROR_FILE_NOT_FOUND
ret
.failed:
mov eax, [save_cr3]
@ -233,7 +268,11 @@ proc fs_execute
.err_hdr:
mov ecx, [file_base]
call @mem_free@4
.err_file:
pop edi
pop esi
pop ebx
xor eax, eax
mov [application_table_status],eax
mov eax, ecx
@ -241,65 +280,162 @@ proc fs_execute
endp
align 4
test_app_header:
virtual at eax
APP_HEADER_00 APP_HEADER_00
end virtual
virtual at eax
APP_HEADER_01 APP_HEADER_01
end virtual
proc pe_app_param stdcall path:dword, raw:dword, ex_pg_dir:dword, ex_stack_page:dword
cmp dword [eax], 'MENU'
jne .fail
cmp word [eax+4],'ET'
jne .fail
locals
slot dd ?
slot_base dd ?
endl
cmp [eax+6], word '00'
jne .check_01_header
push ebx
push esi
push edi
lea ebx, [application_table_status]
call wait_mutex
call set_application_table_status
call get_new_process_place
test eax, eax
mov ecx, -0x20 ; too many processes
jz .err
mov [slot], eax
shl eax, 8
add eax, SLOT_BASE
mov [slot_base], eax
mov edi, eax
_clear_ 256 ;clean extended information about process
; write application name
lea eax, [path]
stdcall strrchr, eax, '/' ; now eax points to name without path
lea esi, [eax+1]
test eax, eax
jnz @F
lea esi, [path]
@@:
mov ecx, 8 ; 8 chars for name
mov edi, [slot_base]
.copy_process_name_loop:
lodsb
cmp al, '.'
jz .copy_process_name_done
test al, al
jz .copy_process_name_done
stosb
loop .copy_process_name_loop
.copy_process_name_done:
mov eax, [ex_pg_dir]
mov ebx, [slot_base]
mov [ebx+APPDATA.dir_table],eax
;mov eax,[hdr_mem]
;mov [ebx+APPDATA.mem_size],eax
lea edi, [eax+OS_BASE+8192]
mov [ebx+APPDATA.pl0_stack], edi
add edi, RING0_STACK_SIZE
mov [ebx+APPDATA.saved_esp0], edi
mov [ebx+APPDATA.fpu_state], edi
mov [ebx+APPDATA.fpu_handler], 0
mov [ebx+APPDATA.sse_handler], 0
;set default io permission map
mov [ebx+APPDATA.io_map],\
(tss._io_map_0-OS_BASE+PG_MAP)
mov [ebx+APPDATA.io_map+4],\
(tss._io_map_1-OS_BASE+PG_MAP)
mov esi, fpu_data
mov ecx, 512/4
rep movsd
mov eax, [slot]
cmp eax,[TASK_COUNT]
jle .noinc
inc dword [TASK_COUNT] ;update number of processes
.noinc:
lea edx, [ebx+APP_EV_OFFSET]
mov [ebx+APPDATA.fd_ev],edx
mov [ebx+APPDATA.bk_ev],edx
add edx, APP_OBJ_OFFSET-APP_EV_OFFSET
mov [ebx+APPDATA.fd_obj],edx
mov [ebx+APPDATA.bk_obj],edx
mov ecx, [def_cursor]
mov [ebx+APPDATA.cursor],ecx
xor ecx, ecx
call @core_alloc@4
add eax, OS_BASE ;FIXME
mov esi,[current_slot]
mov esi,[esi+APPDATA.cur_dir]
mov ecx,0x1000/4
mov edi,eax
mov [ebx+APPDATA.cur_dir],eax
rep movsd
mov ebx, [slot]
mov eax, ebx
shl ebx, 5
mov dword [CURRENT_TASK+ebx+0x10], 0
lea ecx,[draw_data+ebx] ;ecx - pointer to draw data
; set window state to 'normal' (non-minimized/maximized/rolled-up) state
mov [ebx+window_data+WDATA.fl_wstate], WSTATE_NORMAL
mov [ebx+window_data+WDATA.fl_redraw], 1
add ebx,CURRENT_TASK ;ebx - pointer to information about process
mov [ebx+TASKDATA.wnd_number],al;set window number on screen = process slot
mov [ebx+TASKDATA.event_mask],dword 1+2+4 ;set default event flags (see 40 function)
inc dword [process_number]
mov eax,[process_number]
mov [ebx+4],eax ;set PID
;set draw data to full screen
mov [ecx+0],dword 0
mov [ecx+4],dword 0
mov eax,[Screen_Max_X]
mov [ecx+8],eax
mov eax,[Screen_Max_Y]
mov [ecx+12],eax
mov ebx, [ex_pg_dir]
add ebx, OS_BASE+8192-16
mov [ebx], dword _sys_app_entry
mov eax, [raw]
mov edx, [ex_stack_page]
mov [ebx+8], eax
mov [ebx+12], edx
mov ecx, [slot]
shl ecx, 5
mov [ecx*8+SLOT_BASE+APPDATA.saved_esp], ebx
xor ebx, ebx ; process state - running
mov [CURRENT_TASK+ecx+TASKDATA.state], bl
; DEBUGF 1,"%s",new_process_running
.err:
mov [application_table_status], 0 ;unlock application_table_status mutex
mov eax,[process_number] ;set result
pop edi
pop esi
pop ebx
mov ecx,[APP_HEADER_00.start]
mov [ebx+0x08], ecx ;app_eip
mov edx,[APP_HEADER_00.mem_size]
mov [ebx+0x10], edx ;app_mem
shr edx,1
sub edx,0x10
mov [ebx+0x0C], edx ;app_esp
mov ecx,[APP_HEADER_00.i_param]
mov [ebx], ecx ;app_cmdline
mov [ebx+4], dword 0 ;app_path
mov edx, [APP_HEADER_00.i_end]
mov [ebx+0x14], edx
ret
endp
.check_01_header:
cmp [eax+6],word '01'
jne .fail
mov ecx,[APP_HEADER_01.start]
mov [ebx+0x08], ecx ;app_eip
mov edx,[APP_HEADER_01.mem_size]
; \begin{diamond}[20.08.2006]
; sanity check (functions 19,58 load app_i_end bytes and that must
; fit in allocated memory to prevent kernel faults)
cmp edx,[APP_HEADER_01.i_end]
jb .fail
; \end{diamond}[20.08.2006]
mov [ebx+0x10], edx ;app_mem
mov ecx,[APP_HEADER_01.stack_top]
mov [ebx+0x0C], ecx ;app_esp
mov edx,[APP_HEADER_01.i_param]
mov [ebx], edx ;app_cmdline
mov ecx,[APP_HEADER_01.i_icon]
mov [ebx+4], ecx ;app_path
mov edx, [APP_HEADER_01.i_end]
mov [ebx+0x14], edx
ret
.fail:
xor eax, eax
ret
align 4
proc get_new_process_place
@ -454,6 +590,44 @@ proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword
ret
endp
align 4
_new_app_space:
mov ecx, 2
call @core_alloc@4
test eax, eax
jz .fail
push esi
push edi
mov edx, eax
mov ecx, 512
lea edi, [eax + OS_BASE]
xor eax, eax
cld
rep stosd
mov ecx, 512
mov esi, _sys_pdbr+(HEAP_BASE shr 20)
rep movsd
lea eax, [edx+PG_SW]
mov [edx+OS_BASE+(page_tabs shr 20)], eax
add eax, 4096
mov [edx+OS_BASE+0x7FC], eax
lea edi, [edx+OS_BASE+8192]
mov ecx, 2048
xor eax, eax
rep stosd
mov eax, edx
.fail:
pop edi
pop esi
ret
align 4
set_cr3:
@ -917,10 +1091,6 @@ wait_mutex:
pop eax
ret
EFL_IF equ 0x0200
EFL_IOPL1 equ 0x1000
EFL_IOPL2 equ 0x2000
EFL_IOPL3 equ 0x3000
align 4

View File

@ -49,11 +49,12 @@ v86_create:
; first half (0x800 bytes) is page table for addresses 0 - 0x100000,
; second half is for V86-to-linear translation.
; Third and fourth are for I/O permission map.
mov ecx, 2
call @core_alloc@4
mov ecx, 0x4000
mov edx, PG_SW
call @mem_alloc@8
test eax, eax
jz .fail2
add eax, OS_BASE
mov [ebx+V86_machine.pagedir], eax
push edi eax
mov edi, eax
@ -72,14 +73,14 @@ v86_create:
mov edi, eax
add eax, 1000h
push eax
sub eax, OS_BASE
call get_pg_addr
or al, PG_UW
stosd
; ...and also copy system page tables
; thx to Serge, system is located at high addresses
add edi, (OS_BASE shr 20) - 4
add edi, (HEAP_BASE shr 20) - 4
push esi
mov esi, (OS_BASE shr 20) + _sys_pdbr
mov esi, (HEAP_BASE shr 20) + _sys_pdbr
mov ecx, 0x80000000 shr 22
rep movsd
@ -110,6 +111,7 @@ v86_create:
mov [edi+800h], eax
lea eax, [edx + 111b]
stosd
add edx, 0x1000
loop @b
pop eax
pop edi
@ -145,8 +147,7 @@ v86_destroy:
push eax
mov ecx, [eax+V86_machine.pagedir]
sub ecx, OS_BASE
call @core_free@4
call @mem_free@4
pop eax
jmp free
@ -300,10 +301,10 @@ v86_start:
push dword [ecx+APPDATA.io_map]
push dword [ecx+APPDATA.io_map+4]
mov dword [ecx+APPDATA.io_map], eax
mov dword [page_tabs + (tss._io_map_0 shr 10)], eax
; mov dword [page_tabs + (tss._io_map_0 shr 10)], eax
add eax, 0x1000
mov dword [ecx+APPDATA.io_map+4], eax
mov dword [page_tabs + (tss._io_map_1 shr 10)], eax
; mov dword [page_tabs + (tss._io_map_1 shr 10)], eax
push [ecx+APPDATA.dir_table]
push [ecx+APPDATA.saved_esp0]
@ -820,10 +821,10 @@ end if
mov [SLOT_BASE+ecx+APPDATA.dir_table], eax
pop ebx
mov dword [SLOT_BASE+ecx+APPDATA.io_map+4], ebx
mov dword [page_tabs + (tss._io_map_1 shr 10)], ebx
; mov dword [page_tabs + (tss._io_map_1 shr 10)], ebx
pop ebx
mov dword [SLOT_BASE+ecx+APPDATA.io_map], ebx
mov dword [page_tabs + (tss._io_map_0 shr 10)], ebx
; mov dword [page_tabs + (tss._io_map_0 shr 10)], ebx
mov cr3, eax
; mov [irq_tab+5*4], 0
sti

View File

@ -104,6 +104,9 @@ file_system_lfn:
; 8 : delete file
; 9 : create directory
cmp dword [eax], 7
je .do_exec
; parse file name
xchg ebx, eax
lea esi, [ebx+20]
@ -129,14 +132,6 @@ file_system_lfn:
jz .rootdir
call process_replace_file_name
.parse_normal:
cmp dword [ebx], 7
jne @F
mov edx, [ebx+4]
mov ebx, [ebx+8]
call fs_execute ; esi+ebp, ebx, edx
mov [image_of_eax], eax
ret
@@:
mov edi, rootdirs-8
xor ecx, ecx
push esi
@ -425,6 +420,23 @@ file_system_lfn:
; esi points to ASCIIZ string - rest of name
jmp dword [edi]
.do_exec:
lea ebx, [eax+20]
cmp byte [ebx],0
jnz @F
mov ebx, [ebx+1]
@@:
push dword [eax+4]
push dword [eax+8]
push ebx
call _sys_exec
mov [image_of_eax], eax
add esp, 12
ret
; handlers for devices
; in: ecx = 0 => query virtual directory /xxx
; in: ecx = partition number

View File

@ -140,8 +140,8 @@ ntfs_setup: ; CODE XREF: part_set.inc
mov edx, PG_SW
call @mem_alloc@8
test eax, eax
mov [ntfs_data.frs_buffer], eax
jz problem_fat_dec_count
mov [ntfs_data.frs_buffer], eax
add eax, [ntfs_data.frs_size]
mov [ntfs_data.iab_buffer], eax
; read $MFT disposition
@ -229,8 +229,8 @@ ntfs_setup: ; CODE XREF: part_set.inc
mov edx, PG_SW
call @mem_alloc@8
test eax, eax
mov [ntfs_data.cur_index_buf], eax
jz .fail_free_mft
mov [ntfs_data.cur_index_buf], eax
popad
call free_hd_channel

View File

@ -3,6 +3,11 @@
#define IMAGE_BASE 0xE0100000
#define LOAD_BASE 0x00100000
#define page_tabs 0xDF800000
void printf (const char *format, ...);
#define CALLER ((addr_t) __builtin_return_address(0))

View File

@ -131,6 +131,11 @@ public _rd_root_end
public _load_file@4
public mnt_exec
public _new_app_space
public pe_app_param
public _strncmp@12
public _LoadFile ; stdcall export
@ -193,7 +198,9 @@ extrn _MemFree
@mem_alloc@8 equ _MemAlloc
@mem_free@4 equ _MemFree
extrn @load_pe@4
extrn _sys_exec
;extrn @load_pe@4
extrn @load_pe_driver@4
extrn _slab_cache_init
@ -203,6 +210,7 @@ extrn _get_free_mem
extrn _bx_from_load
extrn _sys_app_entry
section '.flat' code readable align 4096
@ -374,7 +382,7 @@ _high_code:
;Add IO access table - bit array of permitted ports
mov edi, tss._io_map_0
xor eax, eax
not eax
; not eax
mov ecx, 8192/4
rep stosd ; access to 4096*8=65536 ports
@ -826,8 +834,8 @@ include 'detect/disks.inc'
mov [SLOT_BASE+APPDATA.cursor],eax
mov [SLOT_BASE+APPDATA.cursor+256],eax
;mov ecx, szAtiHW
;call @load_pe_driver@4
; mov ecx, szAtiHW
; call @load_pe_driver@4
; READ TSC / SECOND
@ -888,7 +896,7 @@ include 'detect/disks.inc'
;protect io permission map
mov esi, [default_io_map]
; mov esi, [default_io_map]
; stdcall map_page,esi,(tss._io_map_0-OS_BASE), PG_MAP
; add esi, 0x1000
; stdcall map_page,esi,(tss._io_map_1-OS_BASE), PG_MAP
@ -907,8 +915,11 @@ include 'detect/disks.inc'
; LOAD FIRST APPLICATION
mov ebp, firstapp
call fs_execute_from_sysdir
push 0
push 0
push read_firstapp
call _sys_exec
add esp, 12
cmp eax,2 ; continue if a process has been loaded
je first_app_found
@ -3459,7 +3470,7 @@ checkpixel:
ret
iglobal
cpustring db 'CPU',0
cpustring db '/sys/CPU',0
endg
uglobal
@ -3474,8 +3485,11 @@ checkmisc:
cmp [ctrl_alt_del], 1
jne nocpustart
mov ebp, cpustring
call fs_execute_from_sysdir
push 0
push 0
push cpustring
call _sys_exec
add esp, 12
mov [ctrl_alt_del], 0