fix: correction des structures et entêtes

This commit is contained in:
Nicolas Hordé 2019-07-14 12:47:14 +02:00
parent 26b8139657
commit dc0184f27d
29 changed files with 94 additions and 146 deletions

View File

@ -39,6 +39,9 @@ struc entries
.filesize dd 0 .filesize dd 0
.sizeof = $ - .filename .sizeof = $ - .filename
} }
virtual at 0
entries entries
end virtual
;Pour recherches ;Pour recherches
struc find files struc find files

View File

@ -25,12 +25,18 @@ struc regs
;.sst6 dt 0 ;.sst6 dt 0
;.sst7 dt 0 ;.sst7 dt 0
} }
virtual at 0
regs regs
end virtual
struc tuple off,seg struc tuple off,seg
{ {
.off dw 0 ;adresse .off dw 0 ;adresse
.seg dw 0 ;segment .seg dw 0 ;segment
} }
virtual at 0
tuple tuple ?,?
end virtual
struc vector off,seg struc vector off,seg
{ {
@ -40,8 +46,11 @@ virtual at .data
.sizeof = $ - .data .sizeof = $ - .data
end virtual end virtual
} }
virtual at 0
vector vector ?,?
end virtual
struc ints ;bloc interruption struc ints;bloc interruption
{ {
.number db 0 ;numero de l'interruption .number db 0 ;numero de l'interruption
.activated db 0 ;activé ou non .activated db 0 ;activé ou non
@ -60,6 +69,9 @@ struc ints ;bloc interruption
.vector8 vector ? .vector8 vector ?
.sizeof = $ - .number .sizeof = $ - .number
} }
virtual at 0
ints ints
end virtual
struc mb asize,aname ;Bloc de mémoire struc mb asize,aname ;Bloc de mémoire
{ {
@ -76,18 +88,21 @@ virtual at 0
mb mb ?,? mb mb ?,?
end virtual end virtual
struc exe major struc exe major,exports,imports,sections,starting
;Executable COS ;Executable COS
{ {
.checks db "CE" ;signature de l'exe .checks db "CE" ;signature de l'exe
.major db 1 ;N° version .major db 1 ;N° version
.checksum dd 0 ;Checksum de l'exe .checksum dd 0 ;Checksum de l'exe
.compressed db 0 ;a 1 si compressé par RLE .compressed db 0 ;a 1 si compressé par RLE
.exports dw 0 ;importation de fonctions .exports dw exports ;importation de fonctions
.imports dw 0 ;exportation de fonctions .imports dw imports ;exportation de fonctions
.sections dw 0 ;sections des blocs mémoire .sections dw sections ;sections des blocs mémoire
.starting dw 15 .starting dw starting
} }
virtual at 0
exe exe ?,?,?,?,?
end virtual
struc descriptor limit_low,base_low,base_middle,dpltype,limit_high,base_high struc descriptor limit_low,base_low,base_middle,dpltype,limit_high,base_high
{ {
@ -99,6 +114,9 @@ struc descriptor limit_low,base_low,base_middle,dpltype,limit_high,base_high
.base_high db 0 .base_high db 0
.sizeof = $ - .limit_low .sizeof = $ - .limit_low
} }
virtual at 0
descriptor descriptor ?,?,?,?,?,?
end virtual
free equ 0 ;Reference quand libre free equ 0 ;Reference quand libre
@ -163,9 +181,6 @@ macro stdcall proc,[arg] ; directly call STDCALL procedure
end if end if
push cs push cs
call proc call proc
if size@ccall
add sp,size@ccall
end if
} }
macro invoke proc,[arg] ; directly call STDCALL procedure macro invoke proc,[arg] ; directly call STDCALL procedure
@ -178,11 +193,7 @@ macro invoke proc,[arg] ; directly call STDCALL procedure
size@ccall = size@ccall+2 size@ccall = size@ccall+2
common common
end if end if
call far [cs:proc] call far [cs:proc] }
if size@ccall
add sp,size@ccall
end if
}
macro proc [args] ; define procedure macro proc [args] ; define procedure
{ common { common
@ -208,7 +219,7 @@ macro epiloguedef procname,flag,parmbytes,localbytes,reglist
if parmbytes | localbytes if parmbytes | localbytes
leave leave
end if end if
retf } retf parmbytes }
macro define@proc name,statement macro define@proc name,statement
{ local params,flag,regs,parmbytes,localbytes,current { local params,flag,regs,parmbytes,localbytes,current

View File

@ -7,7 +7,7 @@ include "..\include\3d.h"
org 0h org 0h
header exe 1 header exe 1,exports,imports,0,0
exporting exporting
declare draw3d_point declare draw3d_point

View File

@ -7,8 +7,7 @@ include "..\include\bmp.h"
org 0h org 0h
start: header exe 1,exports,imports,0,0
header exe 1
exporting exporting
declare showbmp declare showbmp

View File

@ -7,7 +7,7 @@ include "..\include\pci.h"
org 0h org 0h
header exe 1 header exe 1,exports,0,0,0
exporting exporting
declare cpuinfo declare cpuinfo

View File

@ -6,7 +6,7 @@ include "..\include\graphic.h"
org 0h org 0h
header exe 1 header exe 1,exports,imports,0,0
exporting exporting
declare hline declare hline

View File

@ -6,8 +6,7 @@ include "..\include\divers.h"
org 0h org 0h
start: header exe 1,exports,0,0,0
header exe 1
waitkey: waitkey:
mov ax,0 mov ax,0

View File

@ -5,7 +5,7 @@ include "..\include\mem.h"
org 0h org 0h
header exe 1 header exe 1,exports,0,0,0
exporting exporting
declare random declare random

View File

@ -6,7 +6,7 @@ include "..\include\divers.h"
org 0h org 0h
header exe 1 header exe 1,exports,0,0,0
exporting exporting

View File

@ -5,7 +5,7 @@ include "..\include\mem.h"
org 0h org 0h
header exe 1 header exe 1,exports,imports,0,0
exporting exporting
declare print declare print

View File

@ -2,7 +2,7 @@ all: boot/boot12.bin lib/3d.lib noyau/systeme.sys programs/commande.ce
sync sync
install: install:
(sudo apt-get install fasm qemu fusefat cgdb) (sudo apt-get install fasm qemu fusefat gdb)
clean: clean:
make -C final clean make -C final clean

View File

@ -186,10 +186,7 @@ endp
proc installirqhandler uses eax bx cx edx si di ds es proc installirqhandler uses eax bx cx edx si di ds es
push fs push fs
virtual at 0 stdcall mbcreate,interruptionbloc,256*ints.sizeof
.intsori ints
end virtual
stdcall mbcreate,interruptionbloc,256*.intsori.sizeof
mov es,ax mov es,ax
mov ax,0x0000 mov ax,0x0000
mov ds,ax mov ds,ax
@ -198,14 +195,11 @@ proc installirqhandler uses eax bx cx edx si di ds es
virtual at si virtual at si
.vector vector .vector vector
end virtual end virtual
virtual at 0
.vectorori vector
end virtual
mov fs,[.vector.data.seg] mov fs,[.vector.data.seg]
mov bx,[.vector.data.off] mov bx,[.vector.data.off]
cmp byte [fs:bx],0xCF ;iret cmp byte [fs:bx],0xCF ;iret
je .founded je .founded
add si,.vectorori.sizeof add si,vector.sizeof
cmp si,256*4 cmp si,256*4
jb .searchdummypointer jb .searchdummypointer
xor edx,edx xor edx,edx
@ -250,8 +244,8 @@ proc installirqhandler uses eax bx cx edx si di ds es
add bx,coupling add bx,coupling
mov [.vector.data.seg],cs mov [.vector.data.seg],cs
mov [.vector.data.off],bx mov [.vector.data.off],bx
add si,.vectorori.sizeof add si,vector.sizeof
add di,.intsori.sizeof add di,ints.sizeof
inc cl inc cl
cmp cl,0 cmp cl,0
jne .copy jne .copy
@ -366,10 +360,7 @@ jc .end
mov es,ax mov es,ax
mov ax,[int] mov ax,[int]
sub ax,256 sub ax,256
virtual at 0 mov cx,ints.sizeof
.intsorig ints
end virtual
mov cx,.intsorig.sizeof
mul cx mul cx
mov si,ax mov si,ax
virtual at si virtual at si
@ -387,9 +378,6 @@ mov cl,8
virtual at si virtual at si
.vector vector .vector vector
end virtual end virtual
virtual at 0
.vectorori vector
end virtual
cmp [es:.vector.content],0 cmp [es:.vector.content],0
je .end je .end
push word [cs:calling_reg.seflags] push word [cs:calling_reg.seflags]
@ -405,7 +393,7 @@ cli
stdcall savecontext,calling_reg stdcall savecontext,calling_reg
stdcall restorecontextg,function_reg stdcall restorecontextg,function_reg
.next: .next:
add si,.vectorori.sizeof add si,vector.sizeof
dec cl dec cl
jnz .launchall jnz .launchall
.end: .end:

View File

@ -3,7 +3,7 @@ include "..\include\fat.h"
org 0h org 0h
header exe 1 header exe 1,exports,imports,0,0
exporting exporting
@ -168,10 +168,7 @@ proc execfile, file:word
push cs push cs
push .arrive push .arrive
push ds push ds
virtual at 0 push word [exe.starting]
.exe exe
end virtual
push word [.exe.starting]
push ds push ds
push ds push ds
push ds push ds
@ -579,10 +576,7 @@ proc findnextfile uses ax bx cx di si ds es, pointer:word
.findnextfileagain: .findnextfileagain:
cmp [es:.find.firstsearch],1 cmp [es:.find.firstsearch],1
je .first je .first
virtual at 0 add bx,entries.sizeof
.entries2 entries
end virtual
add bx,.entries2.sizeof
cmp bx,[cs:clustersize] cmp bx,[cs:clustersize]
jb .nopop jb .nopop
.first: .first:
@ -635,7 +629,7 @@ proc findnextfile uses ax bx cx di si ds es, pointer:word
.find2 find .find2 find
end virtual end virtual
lea di,[es:.find2.result] lea di,[es:.find2.result]
mov cx,.entries2.sizeof mov cx,entries.sizeof
cld cld
rep movsb rep movsb
clc clc

View File

@ -98,10 +98,7 @@ proc flatmode uses eax bx ds
add dword [.gdt+2],eax ; store as GDT linear base addr add dword [.gdt+2],eax ; store as GDT linear base addr
; now load the GDT into the GDTR ; now load the GDT into the GDTR
lgdt fword [.gdt] ; load GDT base lgdt fword [.gdt] ; load GDT base
virtual at 0 mov bx,1 * descriptor.sizeof ; point to first descriptor
.descriptor descriptor
end virtual
mov bx,1 * .descriptor.sizeof ; point to first descriptor
cli ; turn off interrupts cli ; turn off interrupts
mov eax,cr0 ; prepare to enter protected mode mov eax,cr0 ; prepare to enter protected mode
or al,1 ; flip the PE bit or al,1 ; flip the PE bit
@ -138,14 +135,11 @@ proc mbloadsection uses ax bx cx si di ds es, blocks:word
mov ax,[blocks] mov ax,[blocks]
mov es,ax mov es,ax
mov ds,ax mov ds,ax
cmp word [0],"EC" cmp word [0],"CE"
jne .notace jne .notace
lea si,[toresov] lea si,[toresov]
mov word [ss:si],0FFFFh mov word [ss:si],0FFFFh
virtual at 0 mov bx,[ds:exe.sections]
.exe exe
end virtual
mov bx,[ds:.exe.sections]
cmp bx,0 cmp bx,0
je .finishloading je .finishloading
.loading: .loading:
@ -229,7 +223,7 @@ proc mbcreate uses bx cx dx si di ds es, blocks:word, size:word
dec dx dec dx
dec dx dec dx
mov gs,dx mov gs,dx
cmp word [gs:0x0],'NH' cmp word [gs:0x0],'HN'
je .oktoset je .oktoset
mov ax,memorystart mov ax,memorystart
.oktoset: .oktoset:
@ -245,7 +239,7 @@ proc mbcreate uses bx cx dx si di ds es, blocks:word, size:word
cmp dl,false cmp dl,false
je .notenougtmem je .notenougtmem
mov es,bx mov es,bx
cmp word [es:mb.check],"NH" cmp word [es:mb.check],"HN"
jne .memoryerror jne .memoryerror
cmp [es:mb.isnotlast],true cmp [es:mb.isnotlast],true
sete dl sete dl
@ -254,7 +248,7 @@ proc mbcreate uses bx cx dx si di ds es, blocks:word, size:word
mov ax,[es:mb.sizes] mov ax,[es:mb.sizes]
cmp cx,ax cmp cx,ax
ja .notsogood ja .notsogood
mov word [es:mb.check],"NH" mov word [es:mb.check],"HN"
mov [es:mb.isnotlast],true mov [es:mb.isnotlast],true
mov [es:mb.reference],gs mov [es:mb.reference],gs
mov [es:mb.isresident],false mov [es:mb.isresident],false
@ -311,7 +305,7 @@ proc mbfree uses ax bx cx si di ds es, blocks:word
dec bx dec bx
dec bx dec bx
mov es,bx mov es,bx
cmp word [es:mb.check],"NH" cmp word [es:mb.check],"HN"
jne .memoryerror jne .memoryerror
cmp [es:mb.reference],free cmp [es:mb.reference],free
je .wasfree je .wasfree
@ -330,7 +324,7 @@ proc mbfree uses ax bx cx si di ds es, blocks:word
dec bx dec bx
.searchtofree: .searchtofree:
mov es,bx mov es,bx
cmp word [es:mb.check],"NH" cmp word [es:mb.check],"HN"
jne .memoryerror jne .memoryerror
inc bx inc bx
inc bx inc bx
@ -373,7 +367,7 @@ proc mbclean uses ax bx dx es gs
xor dx,dx xor dx,dx
.searchfree: .searchfree:
mov gs,bx mov gs,bx
cmp word [gs:mb.check],"NH" cmp word [gs:mb.check],"HN"
jne .memoryerror jne .memoryerror
inc bx inc bx
inc bx inc bx
@ -425,7 +419,7 @@ proc mbresident uses bx es, blocks:word
dec bx dec bx
dec bx dec bx
mov es,bx mov es,bx
cmp word [es:mb.check],"NH" cmp word [es:mb.check],"HN"
jne .memoryerror jne .memoryerror
mov [es:mb.isresident],true mov [es:mb.isresident],true
ret ret
@ -440,7 +434,7 @@ proc mbnonresident uses bx es, blocks:word
dec bx dec bx
dec bx dec bx
mov es,bx mov es,bx
cmp word [es:mb.check],"NH" cmp word [es:mb.check],"HN"
jne .memoryerror jne .memoryerror
mov [es:mb.isresident],false mov [es:mb.isresident],false
ret ret
@ -456,7 +450,7 @@ proc mbchown uses bx dx es,blocks:word, owner:word
dec bx dec bx
dec bx dec bx
mov es,bx mov es,bx
cmp word [es:mb.check],"NH" cmp word [es:mb.check],"HN"
jne .memoryerror jne .memoryerror
cmp [es:mb.reference],free cmp [es:mb.reference],free
je .wasfree je .wasfree
@ -490,7 +484,7 @@ proc mbget uses bx dx es, num:word
xor dx,dx xor dx,dx
.searchfree: .searchfree:
mov es,bx mov es,bx
cmp word [es:mb.check],"NH" cmp word [es:mb.check],"HN"
jne .memoryerror jne .memoryerror
inc bx inc bx
inc bx inc bx
@ -526,7 +520,7 @@ proc mbfind uses bx si di es, blocks:word
.search: .search:
mov es,bx mov es,bx
lea di,[es:mb.names] lea di,[es:mb.names]
cmp word [es:mb.check],"NH" cmp word [es:mb.check],"HN"
jne .memoryerror jne .memoryerror
inc bx inc bx
inc bx inc bx
@ -573,7 +567,7 @@ proc mbfindsb uses bx dx si di es, blocks:word, owner:word
mov dx,[owner] mov dx,[owner]
.search: .search:
mov es,bx mov es,bx
cmp word [es:mb.check],"NH" cmp word [es:mb.check],"HN"
jne .memoryerror jne .memoryerror
inc bx inc bx
inc bx inc bx
@ -615,12 +609,9 @@ endp
;Resouds les dépendances du bloc de mémoire %0 ;Resouds les dépendances du bloc de mémoire %0
proc mbloadfuncs uses ax bx cx dx si ds, blocks:word proc mbloadfuncs uses ax bx cx dx si ds, blocks:word
mov ds,[blocks] mov ds,[blocks]
cmp word [0],"EC" cmp word [0],"CE"
jne .notace jne .notace
virtual at 0 mov si,[ds:exe.imports]
.exe exe
end virtual
mov si,[ds:.exe.imports]
cmp si,0 cmp si,0
je .endofloading je .endofloading
.loadfuncs: .loadfuncs:
@ -677,9 +668,6 @@ proc mbsearchfunc uses bx si di es, func:word
mov bx,[func] mov bx,[func]
mov si,bx mov si,bx
.findend: .findend:
virtual at 0
.exe exe
end virtual
inc bx inc bx
cmp byte [bx], ':' cmp byte [bx], ':'
jne .findend jne .findend
@ -688,9 +676,9 @@ proc mbsearchfunc uses bx si di es, func:word
mov byte [bx],':' mov byte [bx],':'
jc .notfoundattallthesb jc .notfoundattallthesb
mov es,ax mov es,ax
cmp word [es:.exe.checks],"EC" cmp word [es:exe.checks],"CE"
jne .notfoundattallthesb jne .notfoundattallthesb
mov di,[es:.exe.exports] mov di,[es:exe.exports]
inc bx inc bx
inc bx inc bx
.functions: .functions:

View File

@ -12,7 +12,7 @@ memorystart equ 0052h ;premier bloc de la m
org 0h org 0h
mb0: mb0:
header exe 1 header exe 1,0,imports,allsection,start
start: start:
push cs push cs

View File

@ -6,7 +6,7 @@ include "..\include\graphic.h"
org 0h org 0h
header exe 1 header exe 1,exports,imports,0,0
exporting exporting
declare setvideomode declare setvideomode

View File

@ -9,8 +9,7 @@ include "..\include\cpu.h"
org 0h org 0h
start: header exe 1,0,imports,0,realstart
header exe 1
realstart: realstart:
invoke print, msginit invoke print, msginit
@ -509,33 +508,27 @@ suitelistmcb2:
invoke print invoke print
cmp word [fs:0x0],'EC' cmp word [fs:0x0],'EC'
jne endofdumpformoment jne endofdumpformoment
virtual at 0 push dword [fs:exe.starting]
.exe exe
end virtual
push dword [fs:.exe.starting]
push fs push fs
push fs push fs
push dword [fs:.exe.sections] push dword [fs:exe.sections]
push fs push fs
push fs push fs
push dword [fs:.exe.imports] push dword [fs:exe.imports]
push fs push fs
push fs push fs
push dword [fs:.exe.exports] push dword [fs:exe.exports]
push fs push fs
push fs push fs
cmp [fs:.exe.compressed],true cmp [fs:exe.compressed],true
jne notcompressed jne notcompressed
push oui push oui
jmp suiteiscompressed jmp suiteiscompressed
notcompressed: notcompressed:
push non push non
suiteiscompressed: suiteiscompressed:
virtual at 0 push dword [fs:exe.checksum]
.exe exe push dword [fs:exe.major]
end virtual
push dword [fs:.exe.checksum]
push dword [fs:.exe.major]
invoke print, dumpshowce invoke print, dumpshowce
endofdumpformoment: endofdumpformoment:
ret ret
@ -582,10 +575,7 @@ haveatargetsections:
mov fs,ax mov fs,ax
cmp word [fs:0x0],'EC' cmp word [fs:0x0],'EC'
jne errornotace2 jne errornotace2
virtual at 0 mov si,[fs:exe.sections]
.exe exe
end virtual
mov si,[fs:.exe.sections]
cmp si,0 cmp si,0
je errornosections je errornosections
xor edx,edx xor edx,edx
@ -632,10 +622,7 @@ haveatargetexports:
mov fs,ax mov fs,ax
cmp word [fs:0x0],'EC' cmp word [fs:0x0],'EC'
jne errornotace2 jne errornotace2
virtual at 0 mov si,[fs:exe.exports]
.exe exe
end virtual
mov si,[fs:.exe.exports]
cmp si,0 cmp si,0
je errornoexports je errornoexports
xor edx,edx xor edx,edx
@ -682,10 +669,7 @@ haveatargetimports:
mov fs,ax mov fs,ax
cmp word [fs:0x0],'EC' cmp word [fs:0x0],'EC'
jne errornotace2 jne errornotace2
virtual at 0 mov si,[fs:exe.imports]
.exe exe
end virtual
mov si,[fs:.exe.imports]
cmp si,0 cmp si,0
je errornoimports je errornoimports
xor edx,edx xor edx,edx
@ -818,10 +802,7 @@ xor ebx,ebx
intoirq: intoirq:
xor eax,eax xor eax,eax
mov al,[bx+ irqmap] mov al,[bx+ irqmap]
virtual at 0 mov dx,ints.sizeof
.intsori ints
end virtual
mov dx,.intsori.sizeof
mul dx mul dx
mov si,ax mov si,ax
virtual at si virtual at si
@ -902,10 +883,7 @@ mov es,ax
invoke gettypeditem,di,0,' ' invoke gettypeditem,di,0,' '
xor edi,edi xor edi,edi
mov di,ax mov di,ax
virtual at 0 mov cx,ints.sizeof
.intsori ints
end virtual
mov cx,.intsori.sizeof
mul cx mul cx
mov si,ax mov si,ax
virtual at si virtual at si

View File

@ -7,8 +7,7 @@ include "..\include\graphic.h"
org 0h org 0h
start: header exe 1,0,imports,0,realstart
header exe 1
realstart: realstart:
mov ax,0305h mov ax,0305h

View File

@ -6,8 +6,7 @@ include "..\include\divers.h"
org 0h org 0h
start: header exe 1,0,imports,0,realstart
header exe 1
realstart: realstart:
invoke print,message invoke print,message

View File

@ -8,8 +8,7 @@ include "..\include\graphic.h"
org 0h org 0h
start: header exe 1,0,imports,0,realstart
header exe 1
realstart: realstart:
invoke saveparamto, infos invoke saveparamto, infos

View File

@ -6,8 +6,7 @@ include "..\include\divers.h"
org 0h org 0h
start: header exe 1,0,0,0,realstart
header exe 1
realstart: realstart:
retf retf

View File

@ -6,8 +6,7 @@ include "..\include\divers.h"
org 0h org 0h
start: header exe 1,0,imports,0,realstart
header exe 1
realstart: realstart:
invoke mballoc,65535 invoke mballoc,65535

View File

@ -6,8 +6,7 @@ include "..\include\divers.h"
org 0h org 0h
start: header exe 1,0,0,0,realstart
header exe 1
realstart: realstart:
mov eax,cr0 mov eax,cr0

View File

@ -6,8 +6,7 @@ include "..\include\divers.h"
org 0h org 0h
start: header exe 1,0,imports,0,realstart
header exe 1
realstart: realstart:
invoke mouseon invoke mouseon

View File

@ -6,8 +6,7 @@ include "..\include\divers.h"
org 0h org 0h
start: header exe 1,0,imports,0,realstart
header exe 1
realstart: realstart:
invoke randomize invoke randomize

View File

@ -8,8 +8,7 @@ include "..\include\3d.h"
org 0h org 0h
start: header exe 1,0,imports,0,realstart
header exe 1
realstart: realstart:
invoke randomize invoke randomize

View File

@ -8,8 +8,7 @@ include "..\include\3d.h"
org 0h org 0h
start: header exe 1,0,imports,0,realstart
header exe 1
alldata: alldata:
camera vertex3d 320.0,240.0,70.0 camera vertex3d 320.0,240.0,70.0

View File

@ -6,8 +6,7 @@ include "..\include\divers.h"
org 0h org 0h
start: header exe 1,0,imports,0,realstart
header exe 1
realstart: realstart:
invoke savestate invoke savestate

View File

@ -7,8 +7,7 @@ include "..\include\graphic.h"
org 0h org 0h
start: header exe 1,0,imports,0,realstart
header exe 1
realstart: realstart:
mov ax,0305h mov ax,0305h