WIP: programs/other: Post-SVN tidy #275

Draft
ace-dent wants to merge 10 commits from ace-dent/kolibrios-gitea:PR-TidySVN-other into main
80 changed files with 1924 additions and 1889 deletions

View File

@@ -155,7 +155,7 @@ echo Building other
echo * echo *
rem fasm other\archer\trunk\@rcher.asm %BIN%\@rcher rem fasm other\archer\trunk\@rcher.asm %BIN%\@rcher
fasm other\calc\calc.asm %BIN%\calc fasm other\calc\calc.asm %BIN%\calc
fasm other\mhc\trunk\mhc.asm %BIN%\mhc rem fasm other\mhc\trunk\mhc.asm %BIN%\mhc
fasm other\period\period.asm %BIN%\period fasm other\period\period.asm %BIN%\period
fasm other\rtfread\rtfread.asm %BIN%\rtfread fasm other\rtfread\rtfread.asm %BIN%\rtfread
@@ -165,12 +165,12 @@ echo *
rem media\ac97snd\trunk\ac97snd.asm ac97snd rem media\ac97snd\trunk\ac97snd.asm ac97snd
fasm media\animage\animage.asm %BIN%\animage fasm media\animage\animage.asm %BIN%\animage
fasm media\cdp\trunk\cdp.asm %BIN%\cdp fasm media\cdp\trunk\cdp.asm %BIN%\cdp
fasm media\gifview\trunk\gifview.asm %BIN%\gifview rem fasm media\gifview\trunk\gifview.asm %BIN%\gifview
fasm media\iconedit\trunk\iconedit.asm %BIN%\iconedit rem fasm media\iconedit\trunk\iconedit.asm %BIN%\iconedit
fasm media\jpegview\trunk\jpegview.asm %BIN%\jpegview rem fasm media\jpegview\trunk\jpegview.asm %BIN%\jpegview
fasm media\midamp\trunk\midamp.asm %BIN%\midamp fasm media\midamp\trunk\midamp.asm %BIN%\midamp
fasm media\midiplay\trunk\midiplay.asm %BIN%\midiplay fasm media\midiplay\trunk\midiplay.asm %BIN%\midiplay
fasm media\mixer\trunk\mixer.asm %BIN%\mixer rem fasm media\mixer\trunk\mixer.asm %BIN%\mixer
fasm media\mv\trunk\mv.asm %BIN%\mv fasm media\mv\trunk\mv.asm %BIN%\mv
fasm media\pic4\trunk\pic4.asm %BIN%\pic4 fasm media\pic4\trunk\pic4.asm %BIN%\pic4
@@ -208,7 +208,7 @@ cd demos\aclock\trunk\
nasmw -t -f bin -o ..\..\..\%BIN%\demos\aclock aclock.asm nasmw -t -f bin -o ..\..\..\%BIN%\demos\aclock aclock.asm
cd ..\..\.. cd ..\..\..
fasm demos\bcdclk\trunk\bcdclk.asm %BIN%\demos\bcdclk fasm demos\bcdclk\trunk\bcdclk.asm %BIN%\demos\bcdclk
fasm demos\bgitest\trunk\bgitest.asm %BIN%\fonts\bgitest rem fasm demos\bgitest\trunk\bgitest.asm %BIN%\fonts\bgitest
fasm demos\colorref\trunk\colorref.asm %BIN%\demos\colorref fasm demos\colorref\trunk\colorref.asm %BIN%\demos\colorref
fasm demos\crownscr\trunk\crownscr.asm %BIN%\3d\crownscr fasm demos\crownscr\trunk\crownscr.asm %BIN%\3d\crownscr
fasm demos\cslide\trunk\cslide.asm %BIN%\demos\cslide fasm demos\cslide\trunk\cslide.asm %BIN%\demos\cslide
@@ -367,7 +367,7 @@ echo *
rem kpack %BIN%\@rcher rem kpack %BIN%\@rcher
kpack %BIN%\calc kpack %BIN%\calc
kpack %BIN%\mhc rem kpack %BIN%\mhc
kpack %BIN%\period kpack %BIN%\period
kpack %BIN%\rtfread kpack %BIN%\rtfread
@@ -377,12 +377,12 @@ echo *
kpack %BIN%\animage kpack %BIN%\animage
kpack %BIN%\cdp kpack %BIN%\cdp
kpack %BIN%\gifview rem kpack %BIN%\gifview
kpack %BIN%\iconedit rem kpack %BIN%\iconedit
kpack %BIN%\jpegview kpack %BIN%\jpegview
kpack %BIN%\midamp kpack %BIN%\midamp
kpack %BIN%\midiplay kpack %BIN%\midiplay
kpack %BIN%\mixer rem kpack %BIN%\mixer
kpack %BIN%\mp3s kpack %BIN%\mp3s
kpack %BIN%\mv kpack %BIN%\mv
kpack %BIN%\pic4 kpack %BIN%\pic4
@@ -413,7 +413,7 @@ kpack %BIN%\3d\3dcube2
kpack %BIN%\3d\3dtcub10 kpack %BIN%\3d\3dtcub10
kpack %BIN%\demos\aclock kpack %BIN%\demos\aclock
kpack %BIN%\demos\bcdclk kpack %BIN%\demos\bcdclk
kpack %BIN%\fonts\bgitest rem kpack %BIN%\fonts\bgitest
kpack %BIN%\demos\colorref kpack %BIN%\demos\colorref
kpack %BIN%\3d\crownscr kpack %BIN%\3d\crownscr
kpack %BIN%\demos\cslide kpack %BIN%\demos\cslide

View File

@@ -1,481 +1,482 @@
; @RCHER - Deflate unpacker v2.0 beta ; SPDX-License-Identifier: NOASSERTION
; ;
; Written in pure assembler by Ivushkin Andrey aka Willow
; ; @RCHER - Deflate unpacker v2.0 beta
; Created: May 6, 2005 ;
; ; Written in pure assembler by Ivushkin Andrey aka Willow
; Last changed: August 26, 2006 ;
; ; Created: May 6, 2005
; Compile with FASM ;
; Last changed: August 26, 2006
SYS equ meos ;
OUTBUF equ 4*1024*1024 ; Compile with FASM
png_imag = output+OUTBUF
PARAM_PTR = os_work;png_image SYS equ meos
MEMINIT=next_code;output OUTBUF equ 4*1024*1024
DUMPFILE equ '/hd0/1/out.txt' png_imag = output+OUTBUF
PARAM_PTR = os_work;png_image
SHOW_RBLOCK equ 0;1 MEMINIT=next_code;output
SHOW_PNG_SEC equ 0;1 DUMPFILE equ '/hd0/1/out.txt'
SHOW_METH equ 0;1
FILE_NUM equ 15;8 SHOW_RBLOCK equ 0;1
MEMORY equ 0x800000 SHOW_PNG_SEC equ 0;1
SHOW_METH equ 0;1
BITS equ 16 FILE_NUM equ 15;8
BUFSIZE equ 32 MEMORY equ 0x800000
BUFPTR equ area
BITS equ 16
PASSW_LEN equ 32 BUFSIZE equ 32
NO_STOPS equ 1 BUFPTR equ area
SHOW_CHARS equ 0
BSIZE equ 512 PASSW_LEN equ 32
INBUF equ BUFSIZE*BSIZE*2 NO_STOPS equ 1
IGNORE_DIRS equ 0 SHOW_CHARS equ 0
BSIZE equ 512
MOVE_SLINE_LEV equ 8 INBUF equ BUFSIZE*BSIZE*2
IGNORE_DIRS equ 0
DECRYPT_MODE equ 100b
PNG_MODE equ 10b MOVE_SLINE_LEV equ 8
TAR_MODE equ 1000b
STAY_MODE equ 10000b DECRYPT_MODE equ 100b
IPC_MODE equ 100000b PNG_MODE equ 10b
RAW_MODE equ 1000000b TAR_MODE equ 1000b
THREAD_YES equ 10000000b STAY_MODE equ 10000b
LIST_MODE equ 100000000b IPC_MODE equ 100000b
MEM_MODE equ 1000000000b RAW_MODE equ 1000000b
FIND_MODE equ 10000000000b THREAD_YES equ 10000000b
LIST_MODE equ 100000000b
if SYS eq win MEM_MODE equ 1000000000b
format PE console FIND_MODE equ 10000000000b
entry start
;match =win,SYS if SYS eq win
;{ format PE console
; include 'D:\Ivushkin\projects\fasmw\INCLUDE\win32a.inc' entry start
;} ;match =win,SYS
else ;{
use32 ; include 'D:\Ivushkin\projects\fasmw\INCLUDE\win32a.inc'
;}
org 0x0 else
use32
db 'MENUET01'
dd 0x01 org 0x0
dd start
dd I_END db 'MENUET01'
dd MEMINIT dd 0x01
dd main_stack_top;MEMORY-2048 dd start
if PARAM_PTR eq param dd I_END
dd 0 dd MEMINIT
else dd main_stack_top;MEMORY-2048
dd PARAM_PTR if PARAM_PTR eq param
end if dd 0
dd 0x0 else
dd PARAM_PTR
if PARAM_PTR eq param end if
param db 'N' dd 0x0
db '000015'
db '/hd/1/zip/gz/fasm-1~1.tgz',0 if PARAM_PTR eq param
end if param db 'N'
;match =meos,SYS db '000015'
;{ db '/hd/1/zip/gz/fasm-1~1.tgz',0
include "..\..\..\macros.inc" end if
; purge mov ;match =meos,SYS
include "..\..\..\debug.inc" ;{
include 'dump.inc' include "..\..\..\macros.inc"
;} ; purge mov
end if include "..\..\..\debug.inc"
include 'dump.inc'
include 'lang.inc' ;}
language equ lang end if
if SYS eq win include 'lang.inc'
section '.text' code readable executable writeable language equ lang
end if
if SYS eq win
include "arcmacro.inc" section '.text' code readable executable writeable
include "parser.inc" end if
include "deflate.inc"
include "sys.inc" include "arcmacro.inc"
include "parser.inc"
FileNum dd FILE_NUM include "deflate.inc"
;FNAME equ '/hd/1/zip/pngsuite/s01n3p01.png' include "sys.inc"
start: FileNum dd FILE_NUM
if SYS eq win ;FNAME equ '/hd/1/zip/pngsuite/s01n3p01.png'
invoke GetStdHandle, STD_OUTPUT_HANDLE
mov [cons],eax start:
invoke GetStdHandle, STD_INPUT_HANDLE if SYS eq win
mov [cons_in],eax invoke GetStdHandle, STD_OUTPUT_HANDLE
Msg 0 mov [cons],eax
Msg 1 invoke GetStdHandle, STD_INPUT_HANDLE
else mov [cons_in],eax
Msg 0 Msg 0
Msg 1 Msg 1
mcall 40,1000101b else
; jmp again Msg 0
CmdLine Msg 1
cmdl: mcall 40,1000101b
test [Flags],LIST_MODE ; jmp again
jz red CmdLine
cmdl:
; Dump [lpath],[lpath_len],os_work test [Flags],LIST_MODE
; ud2 jz red
red:
call draw_window ; Dump [lpath],[lpath_len],os_work
mcall 12,2 ; ud2
red:
still: call draw_window
mcall 10 mcall 12,2
cmp eax,1
je red still:
cmp eax,2 mcall 10
jne .nokey cmp eax,1
mcall 2 je red
cmp ah,9 cmp eax,2
jz quit jne .nokey
jmp still mcall 2
.nokey: cmp ah,9
cmp eax,3 jz quit
jne still jmp still
mcall 17 .nokey:
cmp ah,1 cmp eax,3
jne still jne still
mcall 23,30 mcall 17
cmp eax,3 cmp ah,1
jne .noquit jne still
call KillViewer mcall 23,30
mcall -1 cmp eax,3
.noquit: jne .noquit
mcall 17 call KillViewer
mcall 64,1,MEMINIT mcall -1
QueryFile .noquit:
mov [FileNum],FILE_NUM mcall 17
test eax,eax mcall 64,1,MEMINIT
jnz still QueryFile
end if mov [FileNum],FILE_NUM
again: test eax,eax
; Dump Flags,4,os_work jnz still
mov [fat_],fat end if
Newline again:
xor eax,eax ; Dump Flags,4,os_work
; and [Flags],STAY_MODE mov [fat_],fat
and [_CRC32_],eax Newline
and [IDATsize],eax xor eax,eax
mov [Adler32],1 ; and [Flags],STAY_MODE
call OpenFile and [_CRC32_],eax
test ebx,ebx and [IDATsize],eax
jnz .sizeok2 mov [Adler32],1
.sizebad2: call OpenFile
Msg 14 test ebx,ebx
jmp quit jnz .sizeok2
.sizeok2: .sizebad2:
call KillViewer Msg 14
xor eax,eax jmp quit
mov ecx,(child_stack-fat)/4 .sizeok2:
mov edi,fat call KillViewer
rep stosd xor eax,eax
mov [filesize],ebx mov ecx,(child_stack-fat)/4
test [Flags],RAW_MODE mov edi,fat
jz .norawm rep stosd
mov eax,[arc_base] mov [filesize],ebx
xor ebx,ebx test [Flags],RAW_MODE
call FileSeek jz .norawm
jmp .sizeok mov eax,[arc_base]
.norawm: xor ebx,ebx
call SfxParse call FileSeek
jmp .sizeok
call ZipParse .norawm:
cmp edx,52 call SfxParse
je .notzip
mov ecx,[FileNum] call ZipParse
call ZipFindN cmp edx,52
cmp edx,4 je .notzip
je quit mov ecx,[FileNum]
test [Flags],DECRYPT_MODE call ZipFindN
jz .nopass cmp edx,4
call ZipDecrypt je quit
push esi test [Flags],DECRYPT_MODE
mov ecx,31 jz .nopass
._: call ZipDecrypt
mov al,[esi] push esi
push eax mov ecx,31
call decrypt_byte ._:
xor al,byte[esp] mov al,[esi]
add esp,4 push eax
call UKeys call decrypt_byte
mov [esi],al xor al,byte[esp]
inc esi add esp,4
loop ._ call UKeys
pop esi mov [esi],al
ud2 inc esi
.nopass: loop ._
cmp [unp_size],0 pop esi
jne .sizeok ud2
.sizebadq: .nopass:
Msg 13 cmp [unp_size],0
jmp quit jne .sizeok
.notzip: .sizebadq:
call GzipParse Msg 13
test edx,edx jmp quit
jne .notgzip .notzip:
jmp .sizeok call GzipParse
.notgzip: test edx,edx
call PngParse jne .notgzip
test edx,edx jmp .sizeok
jz .sizeok1 .notgzip:
cmp edx,21 call PngParse
je .sizebad test edx,edx
test [Flags],RAW_MODE jz .sizeok1
jne .sizeok cmp edx,21
Msg 40 je .sizebad
jmp exit test [Flags],RAW_MODE
.sizebad: jne .sizeok
Msg 17 Msg 40
jmp exit jmp exit
.sizeok1: .sizebad:
if ~ SYS eq win Msg 17
end if jmp exit
Msg 39 ; unpacking PNG .sizeok1:
mov ecx,[unp_size] if ~ SYS eq win
add ecx,output end if
mov [png_],ecx Msg 39 ; unpacking PNG
mov eax,[PNG_info.Width] mov ecx,[unp_size]
imul eax,[PNG_info.Height] add ecx,output
lea eax,[eax+eax*2] mov [png_],ecx
add ecx,eax mov eax,[PNG_info.Width]
; dps 'Mem=' imul eax,[PNG_info.Height]
; dpd ecx lea eax,[eax+eax*2]
mcall 64,1 add ecx,eax
test eax,eax ; dps 'Mem='
jz .ok ; dpd ecx
Msg 41 mcall 64,1
jmp exit test eax,eax
.ok: jz .ok
mov edi,[outp] Msg 41
call Deflate.blkbegin jmp exit
jmp .defl_end .ok:
.sizeok: mov edi,[outp]
mov ecx,[unp_size] call Deflate.blkbegin
dpd ecx jmp .defl_end
add ecx,output .sizeok:
; mov [png_],ecx mov ecx,[unp_size]
mcall 64,1 dpd ecx
test eax,eax add ecx,output
jz .ok2 ; mov [png_],ecx
Msg 41 mcall 64,1
jmp exit test eax,eax
.ok2: jz .ok2
call Deflate ; <=========== Msg 41
.defl_end: jmp exit
test [bits],7 .ok2:
jnz .esi_ok call Deflate ; <===========
dec esi .defl_end:
.esi_ok: test [bits],7
push dword[esi] ; <- Adler !!! jnz .esi_ok
mov esi,output dec esi
sub edi,esi .esi_ok:
mov ecx,edi push dword[esi] ; <- Adler !!!
mov [outfile.size],ecx mov esi,output
test [Flags],RAW_MODE sub edi,esi
jnz .skipAdler mov ecx,edi
test [Flags],PNG_MODE mov [outfile.size],ecx
jnz .skipCRC test [Flags],RAW_MODE
push esi ecx jnz .skipAdler
call UCRC test [Flags],PNG_MODE
Msg 11 jnz .skipCRC
mov eax,[_CRC32_] push esi ecx
mov edx,36 call UCRC
cmp eax,[CRC_check] Msg 11
je .crcok mov eax,[_CRC32_]
dec edx mov edx,36
.crcok: cmp eax,[CRC_check]
Msg edx je .crcok
if SYS eq win dec edx
else .crcok:
dph eax Msg edx
end if if SYS eq win
pop ecx esi else
jmp .skipAdler dph eax
.skipCRC: end if
; dps 'Out=' pop ecx esi
; dpd ecx jmp .skipAdler
call UAdler .skipCRC:
Msg 10 ; dps 'Out='
mov eax,[Adler32] ; dpd ecx
bswap eax ; <- calculated Adler !!! call UAdler
mov edx,36 Msg 10
cmp eax,[esp] mov eax,[Adler32]
je .adlok bswap eax ; <- calculated Adler !!!
dec edx mov edx,36
.adlok: cmp eax,[esp]
Msg edx je .adlok
if SYS eq win dec edx
else .adlok:
dph eax Msg edx
end if if SYS eq win
.skipAdler: else
pop eax dph eax
Newline end if
.nomoreIDAT: .skipAdler:
mov ebx,output pop eax
if SYS eq win Newline
Msg 37 .nomoreIDAT:
invoke CloseHandle, [hnd] mov ebx,output
if SYS eq win
invoke CreateFile,dumpfile,GENERIC_WRITE, FILE_SHARE_WRITE, NULL, \ Msg 37
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL invoke CloseHandle, [hnd]
mov [hnd],eax
invoke WriteFile, eax,ebx,[outfile.size],cparam1,NULL invoke CreateFile,dumpfile,GENERIC_WRITE, FILE_SHARE_WRITE, NULL, \
invoke CloseHandle, [hnd] CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL
else mov [hnd],eax
test [Flags],PNG_MODE invoke WriteFile, eax,ebx,[outfile.size],cparam1,NULL
jnz .nosave invoke CloseHandle, [hnd]
test [Flags],LIST_MODE else
jnz quit test [Flags],PNG_MODE
jnz .nosave
test [Flags],TAR_MODE test [Flags],LIST_MODE
jnz .nomsg jnz quit
Msg 37
.nomsg: test [Flags],TAR_MODE
mov [outfile.out],ebx jnz .nomsg
mcall 70,outfile Msg 37
; dps 'Before Quit1' .nomsg:
; ud2 mov [outfile.out],ebx
test [Flags],TAR_MODE mcall 70,outfile
jz exit.pad ; dps 'Before Quit1'
; call StartPad ; ud2
.nosave: test [Flags],TAR_MODE
end if jz exit.pad
test [Flags],PNG_MODE ; call StartPad
jz NoPng .nosave:
xor eax,eax end if
mov edi,filters test [Flags],PNG_MODE
mov ecx,6 jz NoPng
rep stosd xor eax,eax
mov edi,[png_] mov edi,filters
mov esi,output mov ecx,6
;// rep stosd
mov [outp],edi mov edi,[png_]
;// mov esi,output
call PngFilter ;//
call FiltStats mov [outp],edi
mov [outfile.size],edi ;//
mov ebx,[outp];png_image call PngFilter
if SYS eq win call FiltStats
exit: mov [outfile.size],edi
Msg 12 mov ebx,[outp];png_image
invoke CreateFile,outfile,GENERIC_WRITE, FILE_SHARE_WRITE, NULL, \ if SYS eq win
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL exit:
mov [hnd],eax Msg 12
invoke WriteFile, eax,ebx,[outfile.size],cparam1,NULL invoke CreateFile,outfile,GENERIC_WRITE, FILE_SHARE_WRITE, NULL, \
invoke CloseHandle, [hnd] CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL
call RunViewer mov [hnd],eax
and [arc_base],0 invoke WriteFile, eax,ebx,[outfile.size],cparam1,NULL
and [Flags],STAY_MODE invoke CloseHandle, [hnd]
; dps 'Before Quit2' call RunViewer
quit: and [arc_base],0
QueryFile and [Flags],STAY_MODE
test eax,eax ; dps 'Before Quit2'
jnz again quit:
invoke ExitProcess,0 QueryFile
else test eax,eax
exit: jnz again
mov [outfile.out],ebx invoke ExitProcess,0
test [Flags],TAR_MODE else
jz .notar exit:
Msg 37 mov [outfile.out],ebx
test [Flags],LIST_MODE test [Flags],TAR_MODE
jne quit jz .notar
mcall 70,outfile Msg 37
.pad: test [Flags],LIST_MODE
call StartPad jne quit
.notar: mcall 70,outfile
Msg 12 .pad:
call RunViewer call StartPad
and [arc_base],0 .notar:
and [Flags],STAY_MODE Msg 12
quit: call RunViewer
test [Flags],STAY_MODE and [arc_base],0
jnz red and [Flags],STAY_MODE
mcall -1 quit:
end if test [Flags],STAY_MODE
jnz red
NoPng: mcall -1
test [Flags],TAR_MODE end if
if SYS eq win
jz quit NoPng:
else test [Flags],TAR_MODE
jz still if SYS eq win
end if jz quit
; Dump output,255,os_work else
; ud2 jz still
; mov ecx,dumpf_len end if
; mov esi,dumpfile ; Dump output,255,os_work
; mov edi,filename ; ud2
; rep movsb ; mov ecx,dumpf_len
; call OpenFile ; mov esi,dumpfile
; test ebx,ebx ; mov edi,filename
; jz again.sizebadq ; rep movsb
call TarParse ; call OpenFile
mov ecx,[FileNum] ; test ebx,ebx
call TarFindN ; jz again.sizebadq
; dpd [outfile.size] call TarParse
cmp [outfile.size],0 mov ecx,[FileNum]
jz again.sizebadq call TarFindN
mov ebx,esi ; dpd [outfile.size]
jmp exit cmp [outfile.size],0
jz again.sizebadq
if ~ SYS eq win mov ebx,esi
draw_window: jmp exit
mcall 12,1
mov ebx,15 if ~ SYS eq win
mov ecx,ebx draw_window:
mov edx,0x0e26830 mcall 12,1
mov edi,edx mov ebx,15
mcall 0,,,,0x1f2a870 mov ecx,ebx
mcall 8,,,1+1 shl 30 mov edx,0x0e26830
mcall 4,<6,5>,0x10d0d0d0,msgs+5,1 mov edi,edx
mcall ,<5,5>,0x10202020 mcall 0,,,,0x1f2a870
ret mcall 8,,,1+1 shl 30
end if mcall 4,<6,5>,0x10d0d0d0,msgs+5,1
mcall ,<5,5>,0x10202020
include 'data.inc' ret
end if
if SYS eq win
section '.idata' import data readable writeable include 'data.inc'
library kernel,'KERNEL32.DLL',\ if SYS eq win
comdlg,'COMDLG32.DLL',\ section '.idata' import data readable writeable
user,'USER32.DLL'
library kernel,'KERNEL32.DLL',\
import kernel,\ comdlg,'COMDLG32.DLL',\
CreateFile,'CreateFileA',\ user,'USER32.DLL'
GetFileSize,'GetFileSize',\
ReadFile,'ReadFile',\ import kernel,\
WriteFile,'WriteFile',\ CreateFile,'CreateFileA',\
SetFilePointer,'SetFilePointer',\ GetFileSize,'GetFileSize',\
CloseHandle,'CloseHandle',\ ReadFile,'ReadFile',\
GetStdHandle,'GetStdHandle',\ WriteFile,'WriteFile',\
WriteConsole,'WriteConsoleA',\ SetFilePointer,'SetFilePointer',\
ReadConsole,'ReadConsoleA',\ CloseHandle,'CloseHandle',\
CreateProcess,'CreateProcessA',\ GetStdHandle,'GetStdHandle',\
WritePrivateProfileString,'WritePrivateProfileStringA',\ WriteConsole,'WriteConsoleA',\
ExitProcess,'ExitProcess' ReadConsole,'ReadConsoleA',\
CreateProcess,'CreateProcessA',\
import comdlg,\ WritePrivateProfileString,'WritePrivateProfileStringA',\
GetOpenFileName,'GetOpenFileNameA' ExitProcess,'ExitProcess'
import user,\ import comdlg,\
wsprintf,'wsprintfA',\ GetOpenFileName,'GetOpenFileNameA'
SendMessage,'SendMessageA',\
FindWindowEx,'FindWindowExA',\ import user,\
WaitForInputIdle,'WaitForInputIdle' wsprintf,'wsprintfA',\
SendMessage,'SendMessageA',\
FindWindowEx,'FindWindowExA',\
section '.reloc' fixups data readable discardable WaitForInputIdle,'WaitForInputIdle'
end if
if ~ SYS in <meos,win> section '.reloc' fixups data readable discardable
error "Please specify SYS: meos OR win" end if
end if
if ~ SYS in <meos,win>
error "Please specify SYS: meos OR win"
end if

View File

@@ -1,5 +1,5 @@
if tup.getconfig("NO_FASM") ~= "" then return end if tup.getconfig("NO_FASM") ~= "" then return end
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../../.." or tup.getconfig("HELPERDIR") HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../.." or tup.getconfig("HELPERDIR")
tup.include(HELPERDIR .. "/use_fasm.lua") tup.include(HELPERDIR .. "/use_fasm.lua")
add_include(tup.getvariantdir()) add_include(tup.getvariantdir())

View File

@@ -1,3 +1,9 @@
; SPDX-License-Identifier: NOASSERTION
;
; Text encoded with Code Page 866 - Cyrillic
; BGI Font Test ; BGI Font Test
; ;
; Written in pure assembler by Ivushkin Andrey aka Willow ; Written in pure assembler by Ivushkin Andrey aka Willow
@@ -69,7 +75,7 @@ use32
not1strun dd 0x0 not1strun dd 0x0
include 'lang.inc' include 'lang.inc'
include '..\..\..\..\macros.inc' include '..\..\..\macros.inc'
;include 'debug.inc' ;include 'debug.inc'
include 'bgifont.inc' include 'bgifont.inc'

View File

@@ -1,413 +1,419 @@
; <--- description ---> ; SPDX-License-Identifier: NOASSERTION
; compiler: FASM ;
; name: Clipboard server/daemon
; version: 0.2 ; Text encoded with Code Page 866 - Cyrillic
; author: barsuk
; <--- include all MeOS stuff ---> ; <--- description --->
include "lang.inc" ; compiler: FASM
include "..\..\..\..\macros.inc" ; name: Clipboard server/daemon
; version: 0.2
; <--- start of MenuetOS application ---> ; author: barsuk
MEOS_APP_START
; <--- include all MeOS stuff --->
;define DEBUG TRUE include "lang.inc"
define DEBUG FALSE include "..\..\..\macros.inc"
include "bdebug.inc"
; <--- start of MenuetOS application --->
DEFAULT_SIZE = 0x10010 ; 64K + size of headers MEOS_APP_START
MAX_SIZE = 0x01000000 ; 16 M
MAX_FORMAT = 16 ;define DEBUG TRUE
DELAY = 10 ; 1/10 sec between sending attempts define DEBUG FALSE
ATTEMPT = 5 ; number of sending attempts include "bdebug.inc"
DEFAULT_SIZE = 0x10010 ; 64K + size of headers
; <--- start of code ---> MAX_SIZE = 0x01000000 ; 16 M
CODE MAX_FORMAT = 16
DELAY = 10 ; 1/10 sec between sending attempts
; ¢®-¯¥à¢ëå, ­ ¤® 㡨âì ¢á¥ @clip, ª ª¨¥ ­ ©¤ãâáï: ATTEMPT = 5 ; number of sending attempts
; ¤¥¬®­ ¡ãä¥à  ®¡¬¥­  ¤®«¦¥­ ¡ëâì ⮫쪮 ®¤¨­!
; ¨ ¨¬ ®ª ¦¥âáï á ¬ë© ¬®«®¤®© ¨§ ¤¥¬®­®¢...
; <--- start of code --->
mov ecx, 2 ; ¯¥à¢ë© ­®¬¥à á«®â  ¤«ï ¯à®¢¥àª¨ CODE
mov ebp, info
mov ebx, ebp ; ¢®-¯¥à¢ëå, ­ ¤® 㡨âì ¢á¥ @clip, ª ª¨¥ ­ ©¤ãâáï:
mov edx, 18 ; ¤¥¬®­ ¡ãä¥à  ®¡¬¥­  ¤®«¦¥­ ¡ëâì ⮫쪮 ®¤¨­!
.next_process: ; ¨ ¨¬ ®ª ¦¥âáï á ¬ë© ¬®«®¤®© ¨§ ¤¥¬®­®¢...
mov eax, 9
int 0x40 mov ecx, 2 ; ¯¥à¢ë© ­®¬¥à á«®â  ¤«ï ¯à®¢¥àª¨
cmp dword [ebx + 10], '@CLI' mov ebp, info
jnz .differ mov ebx, ebp
cmp byte [ebx + 14], 'P' mov edx, 18
jnz .differ .next_process:
.similar: mov eax, 9
xchg eax, edx int 0x40
mov ebx, 2 cmp dword [ebx + 10], '@CLI'
int 0x40 jnz .differ
mov ebx, ebp cmp byte [ebx + 14], 'P'
xchg eax, edx jnz .differ
.differ: .similar:
inc ecx xchg eax, edx
cmp ecx, eax mov ebx, 2
jae .done ; process not found int 0x40
jmp .next_process mov ebx, ebp
xchg eax, edx
.done: .differ:
mov eax, 68 ; init heap inc ecx
mov ebx, 11 cmp ecx, eax
int 0x40 jae .done ; process not found
jmp .next_process
mov eax, 66 ; set hotkey: Ctrl-Alt-V
mov ebx, 4 .done:
mov ecx, 47 mov eax, 68 ; init heap
mov edx, 0x110 ; 0x110 mov ebx, 11
int 0x40 int 0x40
print "set hot key (1 bad)"
pregs mov eax, 66 ; set hotkey: Ctrl-Alt-V
mov ebx, 4
mov ebp, DEFAULT_SIZE mov ecx, 47
mov edx, 0x110 ; 0x110
mov eax, 68 ; get memory for buffer int 0x40
mov ebx, 12 print "set hot key (1 bad)"
mov ecx, ebp pregs
int 0x40
mov esi, IPC_buffer mov ebp, DEFAULT_SIZE
mov [esi], eax
mov eax, 68 ; get memory for buffer
mov eax, 60 ; define buffer for IPC mov ebx, 12
mov ebx, 1 mov ecx, ebp
mov ecx, [esi] int 0x40
mov edx, ebp mov esi, IPC_buffer
int 0x40 mov [esi], eax
mov eax, 40 mov eax, 60 ; define buffer for IPC
mov ebx, 01000010b ; mov ebx, 1
int 0x40 mov ecx, [esi]
mov edx, ebp
wait_event: ; main cycle int 0x40
mov eax, [IPC_buffer]
mov dword [eax], 0 ; unlock buffer mov eax, 40
mov dword [eax + 4], 8 mov ebx, 01000010b ;
int 0x40
mov eax, 10 ; wait
int 0x40 wait_event: ; main cycle
print "event" mov eax, [IPC_buffer]
pregs mov dword [eax], 0 ; unlock buffer
mov dword [eax + 4], 8
;dec eax
;dec eax mov eax, 10 ; wait
cmp eax, 2 int 0x40
jnz ipc_event print "event"
pregs
print "hotkey"
;dec eax
mov eax, 2 ;dec eax
int 0x40 cmp eax, 2
pregs jnz ipc_event
cmp ah, 47 ; "v" up
jnz wait_event print "hotkey"
print "hotkey v up" mov eax, 2
; it is hotkey int 0x40
mov eax, 1 pregs
mov ebx, eax cmp ah, 47 ; "v" up
call find_format jnz wait_event
pregs
cmp eax, -1 print "hotkey v up"
jz wait_event ; it is hotkey
mov esi, [data_buffer + eax * 4] mov eax, 1
mov edi, [data_size + eax * 4] mov ebx, eax
mov ecx, 2 call find_format
print "ping" pregs
.next: cmp eax, -1
mov eax, 72 jz wait_event
movzx edx, byte [esi] mov esi, [data_buffer + eax * 4]
int 0x40 ; here we should pause if eax = 1 mov edi, [data_size + eax * 4]
pregs mov ecx, 2
print "ping"
inc esi .next:
dec edi mov eax, 72
jnz .next movzx edx, byte [esi]
jmp wait_event int 0x40 ; here we should pause if eax = 1
pregs
ipc_event:
inc esi
; we get an IPC message dec edi
jnz .next
print "recv. " jmp wait_event
mov eax, [IPC_buffer] ipc_event:
mov dword [eax], 1 ; lock buffer
mov dword [eax + 4], 8 ; we get an IPC message
dph1 dword [eax] ; lock print "recv. "
dph1 dword [eax + 4] ; current used size
dph1 dword [eax + 8] ; pid mov eax, [IPC_buffer]
dph1 dword [eax + 12] ; len mov dword [eax], 1 ; lock buffer
print "" mov dword [eax + 4], 8
dph1 dword [eax + 16] ; cmd << 16 | fmt
dph1 dword [eax + 20] dph1 dword [eax] ; lock
dph1 dword [eax + 24] dph1 dword [eax + 4] ; current used size
dph1 dword [eax + 8] ; pid
mov ebx, [eax + 8 + 4] dph1 dword [eax + 12] ; len
cmp ebx, 8 print ""
jb wait_event ; all my messages have 8-byte header dph1 dword [eax + 16] ; cmd << 16 | fmt
; so ignore this one dph1 dword [eax + 20]
dph1 dword [eax + 24]
movzx ecx, word [eax + 8 + 8] ; command
cmp ecx, 1 mov ebx, [eax + 8 + 4]
jz command_setsize cmp ebx, 8
cmp ecx, 2 jb wait_event ; all my messages have 8-byte header
jz command_set ; so ignore this one
cmp ecx, 3
jz command_getsize movzx ecx, word [eax + 8 + 8] ; command
cmp ecx, 4 cmp ecx, 1
jz command_get jz command_setsize
cmp ecx, 5 cmp ecx, 2
jz command_delete jz command_set
jmp wait_event ; unrecognised command cmp ecx, 3
jz command_getsize
command_setsize: cmp ecx, 4
jz command_get
; the only thing we really need to do here is to grow IPC buffer cmp ecx, 5
; no changes are done to real buffer of chosen format jz command_delete
jmp wait_event ; unrecognised command
; the bad thing is that IPC buffer grows and never becomes less.
; i want to fix this in the next version. command_setsize:
print "set size" ; the only thing we really need to do here is to grow IPC buffer
; no changes are done to real buffer of chosen format
mov esi, [IPC_buffer_size]
mov ecx, [eax + 24] ; size ; the bad thing is that IPC buffer grows and never becomes less.
add ecx, 0x18 ; for headers ; i want to fix this in the next version.
;pregs
cmp esi, ecx print "set size"
jae wait_event
print "ipc buffer resize from esi to ecx" mov esi, [IPC_buffer_size]
pregs mov ecx, [eax + 24] ; size
add ecx, 0x18 ; for headers
mov ebp, MAX_SIZE ; sort of protection. forbid transfer of more ;pregs
cmp ecx, ebp ; than 16,7 Mb of data through buffer cmp esi, ecx
jbe not_much jae wait_event
mov ecx, ebp print "ipc buffer resize from esi to ecx"
pregs
not_much:
xchg eax, edi ; edx := [IPC_buffer] mov ebp, MAX_SIZE ; sort of protection. forbid transfer of more
add ecx, 0x18 ; for headers cmp ecx, ebp ; than 16,7 Mb of data through buffer
jbe not_much
mov [IPC_buffer_size], ecx mov ecx, ebp
mov eax, 68
mov ebx, 12 not_much:
int 0x40 ; get memory xchg eax, edi ; edx := [IPC_buffer]
print "get mem for new buf, eax" add ecx, 0x18 ; for headers
pregs
mov [IPC_buffer], eax mov [IPC_buffer_size], ecx
mov eax, 68
mov dword [eax + 4], 8 mov ebx, 12
mov edx, ecx int 0x40 ; get memory
mov ecx, eax print "get mem for new buf, eax"
mov eax, 60 pregs
mov ebx, 1 mov [IPC_buffer], eax
int 0x40 ; make it IPC buffer
mov dword [eax + 4], 8
mov ecx, edi mov edx, ecx
mov eax, 68 mov ecx, eax
mov ebx, 13 mov eax, 60
int 0x40 ; free old IPC buffer mov ebx, 1
int 0x40 ; make it IPC buffer
jmp wait_event
mov ecx, edi
command_set: mov eax, 68
print "set" mov ebx, 13
int 0x40 ; free old IPC buffer
; here we put the data transfered to us to one of internal buffers
jmp wait_event
;;;outs eax + 0x18
command_set:
movzx eax, word [eax + 18] ; format id print "set"
call find_format
cmp eax, -1 ; here we put the data transfered to us to one of internal buffers
jz new_format
mov edx, eax ;;;outs eax + 0x18
; free old buffer of this format movzx eax, word [eax + 18] ; format id
call find_format
mov ecx, [data_buffer + edx * 4] cmp eax, -1
mov eax, 68 jz new_format
mov ebx, 13 mov edx, eax
int 0x40
jmp set_buffer ; free old buffer of this format
new_format: mov ecx, [data_buffer + edx * 4]
mov eax, data_count ; allocate a buffer mov eax, 68
mov edx, [eax] mov ebx, 13
inc dword [eax] ; no protection, no checks. very bad :( int 0x40
set_buffer: jmp set_buffer
mov eax, [IPC_buffer]
mov ecx, dword [eax + 12] new_format:
sub ecx, 8 ; get length of data itself mov eax, data_count ; allocate a buffer
; subtract size of my headers mov edx, [eax]
;pregs inc dword [eax] ; no protection, no checks. very bad :(
mov [data_size + edx * 4], ecx ; save length of data set_buffer:
mov eax, [IPC_buffer]
mov eax, 68 mov ecx, dword [eax + 12]
mov ebx, 12 sub ecx, 8 ; get length of data itself
int 0x40 ; subtract size of my headers
mov [data_buffer + edx * 4], eax ;pregs
mov [data_size + edx * 4], ecx ; save length of data
; copy data from IPC to new buffer
mov esi, [IPC_buffer] mov eax, 68
mov ebp, esi mov ebx, 12
add esi, 24 ; start of data int 0x40
mov edi, eax mov [data_buffer + edx * 4], eax
rep movsb ; oh, me knows that it's bad
; copy data from IPC to new buffer
mov eax, ebp mov esi, [IPC_buffer]
movzx ecx, word [eax + 18] ; format id mov ebp, esi
mov [data_format + edx * 4], ecx add esi, 24 ; start of data
mov edi, eax
; debug rep movsb ; oh, me knows that it's bad
; print "set debug"
; mov eax, [data_buffer + edx * 4] mov eax, ebp
; mov ebx, [data_size + edx * 4] movzx ecx, word [eax + 18] ; format id
; mov ecx, [data_format + edx * 4] mov [data_format + edx * 4], ecx
; pregs
; debug
jmp wait_event ; print "set debug"
; mov eax, [data_buffer + edx * 4]
command_delete: ; mov ebx, [data_size + edx * 4]
movzx eax, word [eax + 18] ; format id ; mov ecx, [data_format + edx * 4]
cmp eax, -1 ; pregs
jz command_clear
call find_format jmp wait_event
cmp eax, -1
jz wait_event command_delete:
mov ecx, [data_buffer + eax * 4] movzx eax, word [eax + 18] ; format id
mov [data_format + eax * 4], 0 cmp eax, -1
mov eax, 68 jz command_clear
mov ebx, 13 call find_format
int 0x40 cmp eax, -1
jmp wait_event jz wait_event
mov ecx, [data_buffer + eax * 4]
command_clear: mov [data_format + eax * 4], 0
mov eax, 68 mov eax, 68
mov ebx, 13 mov ebx, 13
mov edx, data_buffer int 0x40
.next: jmp wait_event
mov ecx, [edx]
jecxz .nofree command_clear:
int 0x40 mov eax, 68
.nofree: mov ebx, 13
mov [edx + data_size - data_buffer], 0 mov edx, data_buffer
add edx, 4 .next:
cmp edx, data_format mov ecx, [edx]
jnae .next jecxz .nofree
jmp wait_event int 0x40
.nofree:
command_getsize: mov [edx + data_size - data_buffer], 0
add edx, 4
print "get size" cmp edx, data_format
jnae .next
; we should send reply, containing size of data with chosen format id jmp wait_event
movzx eax, word [eax + 18] ; format id
mov esi, 4 command_getsize:
call find_format
;pregs print "get size"
cmp eax, -1
jz zero_size ; we should send reply, containing size of data with chosen format id
movzx eax, word [eax + 18] ; format id
lea edx, [data_size + eax * 4] mov esi, 4
mov eax, [edx] call find_format
jmp send_getsize ;pregs
zero_size: cmp eax, -1
mov edx, dw_zero ; send 0 to indicate that the buffer is empty jz zero_size
send_getsize:
jmp send_msg lea edx, [data_size + eax * 4]
mov eax, [edx]
command_get: jmp send_getsize
print "get" zero_size:
mov edx, dw_zero ; send 0 to indicate that the buffer is empty
; we need to send the data send_getsize:
jmp send_msg
; [:||||:]
command_get:
movzx eax, word [eax + 18] ; format id print "get"
call find_format
cmp eax, -1 ; we need to send the data
jz wait_event
mov edi, eax ;   ­¥ä¨£ ; [:||||:]
mov edx, [data_buffer + edi * 4] movzx eax, word [eax + 18] ; format id
mov esi, [data_size + edi * 4] call find_format
;jmp send_msg cmp eax, -1
jz wait_event
send_msg: mov edi, eax ;   ­¥ä¨£
; for debugging mov edx, [data_buffer + edi * 4]
; mov eax, 5 mov esi, [data_size + edi * 4]
; mov ebx, DELAY*5 ;jmp send_msg
; int 0x40
send_msg:
mov ebp, ATTEMPT ; number of attempts to send
mov eax, [IPC_buffer] ; for debugging
mov ecx, [eax + 8] ; sender PID ; mov eax, 5
mov eax, 60 ; mov ebx, DELAY*5
mov ebx, 2 ; int 0x40
int 0x40
print "send data result eax" mov ebp, ATTEMPT ; number of attempts to send
pregs mov eax, [IPC_buffer]
cmp eax, 2 mov ecx, [eax + 8] ; sender PID
jz .wait mov eax, 60
cmp eax, 3 ; it is strange.. mov ebx, 2
jz .wait ; maybe he needs time to resize his buf int 0x40
jmp wait_event print "send data result eax"
.wait: pregs
dec ebp cmp eax, 2
jz wait_event jz .wait
mov eax, 5 ; sleep a bit cmp eax, 3 ; it is strange..
mov ebx, DELAY jz .wait ; maybe he needs time to resize his buf
int 0x40 jmp wait_event
jmp send_msg .wait:
dec ebp
jz wait_event
find_format: ; small function returning number of format mov eax, 5 ; sleep a bit
mov ebx, DELAY
;print "find format" int 0x40
push ebx jmp send_msg
mov ebx, eax ; format id
and ebx, 0xffff ; it is word
xor eax, eax find_format: ; small function returning number of format
next:
cmp [data_format + eax * 4], ebx ;print "find format"
jz found push ebx
inc eax mov ebx, eax ; format id
cmp eax, MAX_FORMAT and ebx, 0xffff ; it is word
jb next xor eax, eax
not_found: next:
or eax, -1 cmp [data_format + eax * 4], ebx
found: jz found
;pregs inc eax
pop ebx cmp eax, MAX_FORMAT
ret jb next
not_found:
; <--- initialised data ---> or eax, -1
DATA found:
IPC_buffer dd 0 ;pregs
IPC_buffer_size dd DEFAULT_SIZE ; initially 64K pop ebx
ret
info db 1024 dup(0) ; for process info
; <--- initialised data --->
data_buffer dd MAX_FORMAT dup(0) ; buffer for some format DATA
; (256 formats max) IPC_buffer dd 0
data_format dd MAX_FORMAT dup(0) ; format id IPC_buffer_size dd DEFAULT_SIZE ; initially 64K
data_size dd MAX_FORMAT dup(0) ; size of buffer
data_count dd 0 ; number of formats used info db 1024 dup(0) ; for process info
dw_zero dd 0 ; used to tell that
; we don't have a format data_buffer dd MAX_FORMAT dup(0) ; buffer for some format
; (256 formats max)
; <--- uninitialised data ---> data_format dd MAX_FORMAT dup(0) ; format id
UDATA data_size dd MAX_FORMAT dup(0) ; size of buffer
data_count dd 0 ; number of formats used
dw_zero dd 0 ; used to tell that
MEOS_APP_END ; we don't have a format
; <--- end of MenuetOS application --->
; <--- uninitialised data --->
UDATA
MEOS_APP_END
; <--- end of MenuetOS application --->

View File

@@ -1,5 +1,5 @@
if tup.getconfig("NO_FASM") ~= "" then return end if tup.getconfig("NO_FASM") ~= "" then return end
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../../.." or tup.getconfig("HELPERDIR") HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../.." or tup.getconfig("HELPERDIR")
tup.include(HELPERDIR .. "/use_fasm.lua") tup.include(HELPERDIR .. "/use_fasm.lua")
add_include(tup.getvariantdir()) add_include(tup.getvariantdir())

View File

@@ -1,47 +1,50 @@
; debugging include file by barsuk ; SPDX-License-Identifier: NOASSERTION
; if DEBUG=TRUE, adds debug.inc ;
; if DEBUG=FALSE, adds stubs for several macros from debug.inc
; debugging include file by barsuk
match =TRUE, DEBUG ; if DEBUG=TRUE, adds debug.inc
{ ; if DEBUG=FALSE, adds stubs for several macros from debug.inc
include '..\..\..\..\debug.inc' match =TRUE, DEBUG
{
macro dph1 str
\{ include '..\..\..\debug.inc'
debug_print_hex str
push eax macro dph1 str
mov al, ' ' \{
call debug_outchar debug_print_hex str
pop eax push eax
\} mov al, ' '
call debug_outchar
macro outs str pop eax
\{ \}
pushad
lea edx, [str] macro outs str
call debug_outstr \{
popad pushad
\} lea edx, [str]
} call debug_outstr
popad
match =FALSE, DEBUG \}
{ }
macro print message match =FALSE, DEBUG
\{ {
\}
macro print message
macro pregs \{
\{ \}
\}
macro pregs
macro dph1 str \{
\{ \}
\}
macro dph1 str
macro outs str \{
\{ \}
\}
macro outs str
} \{
\}
}

View File

@@ -1,240 +1,246 @@
; <--- description ---> ; SPDX-License-Identifier: NOASSERTION
; compiler: FASM ;
; name: Clipboard Client Demo
; version: 0.1 ; Text encoded with Code Page 866 - Cyrillic
; author: barsuk
; <--- description --->
; <--- include all MeOS stuff ---> ; compiler: FASM
include "lang.inc" ; name: Clipboard Client Demo
include "..\..\..\..\macros.inc" ; version: 0.1
; author: barsuk
TEST_SIZE = 100000 ; ¤®«¦­® ¤¥«¨âìáï ­  4
IPC_buffer_size = TEST_SIZE + 0x10 ; <--- include all MeOS stuff --->
MAX_BUFFER = TEST_SIZE + 0x10 include "lang.inc"
include "..\..\..\macros.inc"
SEND_DELAY = 10
RECV_DELAY = 100 TEST_SIZE = 100000 ; ¤®«¦­® ¤¥«¨âìáï ­  4
ATTEMPT = 5 ; ç¨á«® ¯®¯ë⮪ ®â¯à ¢¨âì á®®¡é¥­¨¥ ¤¥¬®­ã, ¥á«¨ IPC_buffer_size = TEST_SIZE + 0x10
; ®­ § ­ïâ MAX_BUFFER = TEST_SIZE + 0x10
; <--- start of MenuetOS application ---> SEND_DELAY = 10
MEOS_APP_START RECV_DELAY = 100
define DEBUG TRUE ATTEMPT = 5 ; ç¨á«® ¯®¯ë⮪ ®â¯à ¢¨âì á®®¡é¥­¨¥ ¤¥¬®­ã, ¥á«¨
include "bdebug.inc" ; ®­ § ­ïâ
include "clip.inc" ; <--- start of MenuetOS application --->
MEOS_APP_START
; <--- start of code --->
CODE define DEBUG TRUE
include "bdebug.inc"
;;; This is the entry point of the program include "clip.inc"
begin: ; <--- start of code --->
CODE
print "clipboard testing module loaded"
mov eax, 5 ;;; This is the entry point of the program
mov ebx, 100 ; 5 sec
int 0x40 begin:
call clipboard_init print "clipboard testing module loaded"
or eax, eax
jz .err mov eax, 5
mov ebx, 100 ; 5 sec
; put the data into clip_buffer int 0x40
mov esi, test_line call clipboard_init
mov edi, cb.data or eax, eax
mov ecx, cb.size jz .err
rep movsb
; put the data into clip_buffer
print "init ok. @clip found."
mov esi, test_line
mov esi, cb mov edi, cb.data
mov eax, 2 mov ecx, cb.size
call clipboard_write rep movsb
or eax, eax
jz .err print "init ok. @clip found."
print "write test ok." mov esi, cb
mov eax, 2
; á«¥£ª  ®ç¨á⨬ ¡ãä¥à, ¤«ï ­ ¤¥¦­®á⨠¯à®¢¥àª¨ call clipboard_write
or eax, eax
mov dword [cb.data], 0 jz .err
;jmp .exit print "write test ok."
mov eax, 3 ; try to read bad data
mov esi, cb ; á«¥£ª  ®ç¨á⨬ ¡ãä¥à, ¤«ï ­ ¤¥¦­®á⨠¯à®¢¥àª¨
mov edx, 7
call clipboard_read mov dword [cb.data], 0
or eax, eax
jz .bad2 ;jmp .exit
cmp eax, -1 mov eax, 3 ; try to read bad data
jz .err mov esi, cb
mov edx, 7
.bad2: call clipboard_read
print "unset data read ok 1." or eax, eax
mov eax, 88 ; -"- jz .bad2
mov esi, cb cmp eax, -1
mov edx, 7 jz .err
call clipboard_read
or eax, eax .bad2:
jz .bad3 print "unset data read ok 1."
cmp eax, -1 mov eax, 88 ; -"-
jz .err mov esi, cb
mov edx, 7
.bad3: call clipboard_read
print "unset data read ok 2." or eax, eax
jz .bad3
.read: cmp eax, -1
mov eax, 2 jz .err
mov esi, cb
mov edx, 7 .bad3:
call clipboard_read ; read the string we've written print "unset data read ok 2."
or eax, eax
jz .err .read:
cmp eax, -1 mov eax, 2
jz .err mov esi, cb
mov edx, 7
print "read ok o_O, data:" call clipboard_read ; read the string we've written
outs cb.data or eax, eax
print "" jz .err
cmp eax, -1
mov eax, 5 jz .err
mov ebx, 200
int 0x40 print "read ok o_O, data:"
outs cb.data
print ""
; ¯®á«¥¤­ïï ¯à®¢¥àª  - ­  à¥á ©§ ¡ãä¥à .   ¨¬¥­­®, ¢®§ì¬¥¬ ¬­®£® ¤ ­­ëå
; ¨ ¯à®ª ç ¥¬ ¨å ç¥à¥§ ¡ãä¥à mov eax, 5
mov ebx, 200
mov eax, 68 int 0x40
mov ebx, 11
int 0x40
; ¯®á«¥¤­ïï ¯à®¢¥àª  - ­  à¥á ©§ ¡ãä¥à .   ¨¬¥­­®, ¢®§ì¬¥¬ ¬­®£® ¤ ­­ëå
mov eax, 68 ; ¨ ¯à®ª ç ¥¬ ¨å ç¥à¥§ ¡ãä¥à
mov ebx, 12
mov ecx, TEST_SIZE + 12 mov eax, 68
int 0x40 mov ebx, 11
mov [mega_buf], eax int 0x40
mov dword [eax], TEST_SIZE mov eax, 68
mov ebx, 12
lea edx, [eax + 12] mov ecx, TEST_SIZE + 12
mov eax, 12131415 int 0x40
shr ecx, 2 mov [mega_buf], eax
.loop:
mov [edx], eax mov dword [eax], TEST_SIZE
add edx, 4
dec ecx lea edx, [eax + 12]
jnz .loop mov eax, 12131415
shr ecx, 2
print "mega buffer allocated and filled" .loop:
mov [edx], eax
; now write it add edx, 4
dec ecx
mov esi, [mega_buf] jnz .loop
mov eax, 69
call clipboard_write print "mega buffer allocated and filled"
or eax, eax
jz .err ; now write it
print "mega buffer written" mov esi, [mega_buf]
mov eax, 5 mov eax, 69
mov ebx, 100 call clipboard_write
int 0x40 or eax, eax
jz .err
; clear it.
print "mega buffer written"
mov edx, [mega_buf] mov eax, 5
add edx, 12 mov ebx, 100
xor eax, eax int 0x40
mov ecx, TEST_SIZE/4
.loopc: ; clear it.
mov [edx], eax
add edx, 4 mov edx, [mega_buf]
dec ecx add edx, 12
jnz .loopc xor eax, eax
mov ecx, TEST_SIZE/4
; now read .loopc:
mov [edx], eax
mov eax, 69 add edx, 4
mov esi, [mega_buf] dec ecx
mov edx, 7 jnz .loopc
call clipboard_read ; read the string we've written
or eax, eax ; now read
jz .err
cmp eax, -1 mov eax, 69
jz .err mov esi, [mega_buf]
mov edx, 7
print "mega buf read" call clipboard_read ; read the string we've written
or eax, eax
; now compare jz .err
cmp eax, -1
mov edx, [mega_buf] jz .err
add edx, 12
mov eax, 12131415 print "mega buf read"
mov ecx, TEST_SIZE/4
.loopm: ; now compare
cmp eax, [edx]
jnz .err mov edx, [mega_buf]
add edx, 4 add edx, 12
dec ecx mov eax, 12131415
jnz .loopm mov ecx, TEST_SIZE/4
.loopm:
print "deleting mega buf" cmp eax, [edx]
jnz .err
mov eax, 69 add edx, 4
call clipboard_delete dec ecx
or eax, eax jnz .loopm
jz .err
print "deleting mega buf"
mov eax, 5
mov ebx, 100 mov eax, 69
int 0x40 call clipboard_delete
or eax, eax
print "if read error then all is ok" jz .err
mov eax, 69 mov eax, 5
mov esi, [mega_buf] mov ebx, 100
mov edx, 7 int 0x40
call clipboard_read ; read the string we've written
or eax, eax print "if read error then all is ok"
jz .reading
jmp .err mov eax, 69
mov esi, [mega_buf]
.reading: mov edx, 7
call clipboard_read ; read the string we've written
print "test complete!" or eax, eax
jz .reading
.exit: jmp .err
or eax, -1
int 0x40 .reading:
.err: print "test complete!"
print "error!"
jmp .exit .exit:
or eax, -1
int 0x40
; <--- initialised data --->
DATA .err:
print "error!"
CLIP_BUFFER cb, 256 jmp .exit
; in_buf db 256 dup(0)
; out_buf db 'Cthulhu Fhtagn',0 ; <--- initialised data --->
DATA
test_line db 'Cthulhu Fhtagn',0
mega_buf dd 0 CLIP_BUFFER cb, 256
; <--- uninitialised data ---> ; in_buf db 256 dup(0)
UDATA ; out_buf db 'Cthulhu Fhtagn',0
test_line db 'Cthulhu Fhtagn',0
MEOS_APP_END mega_buf dd 0
; <--- end of MenuetOS application --->
; <--- uninitialised data --->
UDATA
MEOS_APP_END
; <--- end of MenuetOS application --->

View File

@@ -1,272 +1,278 @@
; <--- description ---> ; SPDX-License-Identifier: NOASSERTION
; compiler: FASM ;
; name: Clipboard test with GUI.
; version: 0.1 ; Text encoded with Code Page 866 - Cyrillic
; author: barsuk
; comments: uses edit_box by Maxxxx32,<Lrz> (old static version)
; <--- description --->
; compiler: FASM
; <--- include all MeOS stuff ---> ; name: Clipboard test with GUI.
include "lang.inc" ; version: 0.1
include "..\..\..\..\macros.inc" ; author: barsuk
; comments: uses edit_box by Maxxxx32,<Lrz> (old static version)
; <--- start of MenuetOS application --->
MEOS_APP_START
; <--- include all MeOS stuff --->
SEND_DELAY = 10 include "lang.inc"
RECV_DELAY = 100 include "..\..\..\macros.inc"
ATTEMPT = 5
; <--- start of MenuetOS application --->
MEOS_APP_START
define DEBUG TRUE
include "bdebug.inc" SEND_DELAY = 10
RECV_DELAY = 100
include "editbox.inc" ATTEMPT = 5
include "clip.inc"
define DEBUG TRUE
use_edit_box include "bdebug.inc"
; <--- start of code ---> include "editbox.inc"
CODE
include "clip.inc"
call clipboard_init
use_edit_box
call draw_window ; at first create and draw the window
; <--- start of code --->
wait_event: ; main cycle CODE
mov edi, input_box call clipboard_init
call edit_box.mouse
call draw_window ; at first create and draw the window
mov eax, 10
int 0x40 wait_event: ; main cycle
cmp eax, 1 ; if event == 1 mov edi, input_box
je redraw ; jump to redraw handler call edit_box.mouse
cmp eax, 2 ; else if event == 2
je key ; jump to key handler mov eax, 10
cmp eax, 3 ; else if event == 3 int 0x40
je button ; jump to button handler
cmp eax, 1 ; if event == 1
jmp wait_event ; else return to the start of main cycle je redraw ; jump to redraw handler
cmp eax, 2 ; else if event == 2
je key ; jump to key handler
redraw: ; redraw event handler cmp eax, 3 ; else if event == 3
call draw_window je button ; jump to button handler
jmp wait_event
jmp wait_event ; else return to the start of main cycle
key: ; key event handler
mov eax, 2 ; get key code redraw: ; redraw event handler
int 0x40 call draw_window
jmp wait_event
cmp ah, '0'
jb no_digit
cmp ah, '9' key: ; key event handler
ja no_digit mov eax, 2 ; get key code
sub ah, '0' int 0x40
mov byte [format_id], ah
call draw_window cmp ah, '0'
jmp wait_event jb no_digit
no_digit: cmp ah, '9'
ja no_digit
mov edi, input_box sub ah, '0'
call edit_box.key mov byte [format_id], ah
call draw_window
jmp wait_event jmp wait_event
no_digit:
button: ; button event handler mov edi, input_box
mov eax, 17 ; get button identifier call edit_box.key
int 0x40
jmp wait_event
cmp ah, 1
jz exit
button: ; button event handler
cmp ah, 5 mov eax, 17 ; get button identifier
jz copy int 0x40
cmp ah, 6
jz paste cmp ah, 1
jmp wait_event jz exit
copy:
mov esi, input_text cmp ah, 5
mov edi, buffer.data jz copy
mov ecx, [buffer.size] cmp ah, 6
rep movsb ; copy text to buffer jz paste
jmp wait_event
mov edi, input_box copy:
mov edx, [edi + 38] ; ed_size mov esi, input_text
xchg edx, [buffer.size] mov edi, buffer.data
movzx eax, byte [format_id] mov ecx, [buffer.size]
mov esi, buffer rep movsb ; copy text to buffer
call clipboard_write
xchg edx, [buffer.size] mov edi, input_box
jmp wait_event mov edx, [edi + 38] ; ed_size
xchg edx, [buffer.size]
paste: movzx eax, byte [format_id]
mov esi, buffer mov esi, buffer
movzx eax, byte [format_id] call clipboard_write
mov edx, 7 xchg edx, [buffer.size]
call clipboard_read jmp wait_event
or eax, eax paste:
jz wait_event mov esi, buffer
movzx eax, byte [format_id]
cmp eax, -1 mov edx, 7
jz wait_event call clipboard_read
or edx, edx or eax, eax
jz wait_event ; íâ® ¢á¥ ®è¨¡ª¨ jz wait_event
mov eax, input_box cmp eax, -1
;print "input box" jz wait_event
;dph1 [eax]
;dph1 [eax+4] or edx, edx
;dph1 [eax+8] jz wait_event ; íâ® ¢á¥ ®è¨¡ª¨
;dph1 [eax+12]
;dph1 [eax+16] mov eax, input_box
;dph1 [eax+20] ;print "input box"
;dph1 [eax+24] ;dph1 [eax]
;dph1 [eax+4]
;;;;jmp wait_event ;dph1 [eax+8]
;dph1 [eax+12]
mov word [input_box + 36], ed_focus ; flags ;dph1 [eax+16]
;dph1 [eax+20]
mov ecx, [input_box + 38] ; size ;dph1 [eax+24]
print "paste read ecx=size"
jecxz .noloop ;;;;jmp wait_event
mov edi, input_box
mov ah, 8 ; backspace mov word [input_box + 36], ed_focus ; flags
.loop:
call edit_box.key mov ecx, [input_box + 38] ; size
dec ecx print "paste read ecx=size"
jnz .loop jecxz .noloop
.noloop: mov edi, input_box
mov esi, buffer.data mov ah, 8 ; backspace
mov ecx, edx .loop:
pregs call edit_box.key
.loop2: dec ecx
mov ah, [esi] jnz .loop
cmp ah, 0 .noloop:
jz .done mov esi, buffer.data
call edit_box.key ; ï ¡ë ᥡ¥ à㪨 ®â१ « §  â ª®¥ mov ecx, edx
; ­® çâ® ¤¥« âì, ¥á«¨ ¨­ ç¥ ­¥ ¯®«ãç ¥âáï? pregs
inc esi .loop2:
dec ecx mov ah, [esi]
jnz .loop2 cmp ah, 0
jz .done
.done: call edit_box.key ; ï ¡ë ᥡ¥ à㪨 ®â१ « §  â ª®¥
print "rest of data ecx" ; ­® çâ® ¤¥« âì, ¥á«¨ ¨­ ç¥ ­¥ ¯®«ãç ¥âáï?
pregs inc esi
call draw_window dec ecx
jmp wait_event jnz .loop2
exit: .done:
or eax, -1 ; exit application print "rest of data ecx"
int 0x40 pregs
call draw_window
jmp wait_event
draw_window:
mov eax, 12 ; start drawing exit:
mov ebx, 1 or eax, -1 ; exit application
int 0x40 int 0x40
mov eax, 0 ; create and draw the window
mov ebx, 100*65536+400 ; (window_cx)*65536+(window_sx) draw_window:
mov ecx, 100*65536+250 ; (window_cy)*65536+(window_sy) mov eax, 12 ; start drawing
mov edx, 0x33ffffff ; work area color & window type 3 mov ebx, 1
mov edi, head int 0x40
int 0x40
mov eax, 0 ; create and draw the window
mov eax, 4 mov ebx, 100*65536+400 ; (window_cx)*65536+(window_sx)
mov ebx, 10 shl 16 + 10 mov ecx, 100*65536+250 ; (window_cy)*65536+(window_sy)
mov ecx, 0x80000000 mov edx, 0x33ffffff ; work area color & window type 3
mov edx, text1 mov edi, head
int 0x40 int 0x40
mov eax, 4
mov ebx, 10 shl 16 + 20 mov eax, 4
mov edx, text2 mov ebx, 10 shl 16 + 10
int 0x40 mov ecx, 0x80000000
mov eax, 47 mov edx, text1
mov ebx, 0x00020000 int 0x40
movzx ecx, byte [format_id] mov eax, 4
mov edx, 200 shl 16 + 20 mov ebx, 10 shl 16 + 20
mov esi, 0 mov edx, text2
int 0x40 int 0x40
mov eax, 47
mov eax, 8 mov ebx, 0x00020000
mov ebx, 10 shl 16 + 60 movzx ecx, byte [format_id]
mov ecx, 40 shl 16 + 15 mov edx, 200 shl 16 + 20
mov edx, 5 mov esi, 0
mov esi, 0xd72189 int 0x40
int 0x40
mov eax, 4 mov eax, 8
mov ebx, 12 shl 16 + 42 mov ebx, 10 shl 16 + 60
mov ecx, 0x80000000 mov ecx, 40 shl 16 + 15
mov edx, button1 mov edx, 5
int 0x40 mov esi, 0xd72189
int 0x40
mov eax, 8 mov eax, 4
mov ebx, 80 shl 16 + 60 mov ebx, 12 shl 16 + 42
mov ecx, 40 shl 16 + 15 mov ecx, 0x80000000
mov edx, 6 mov edx, button1
mov esi, 0xd72189 int 0x40
int 0x40
mov eax, 4 mov eax, 8
mov ebx, 82 shl 16 + 42 mov ebx, 80 shl 16 + 60
mov ecx, 0x80000000 mov ecx, 40 shl 16 + 15
mov edx, button2 mov edx, 6
int 0x40 mov esi, 0xd72189
int 0x40
mov edi, input_box mov eax, 4
call edit_box.draw mov ebx, 82 shl 16 + 42
mov ecx, 0x80000000
; mov eax, 4 mov edx, button2
; mov ebx, 10 shl 16 + 90 int 0x40
; mov ecx, 0
; mov edx, input_text mov edi, input_box
; mov esi, [input_box + 38] call edit_box.draw
; int 0x40
; mov eax, esi ; mov eax, 4
;print "eax = edit etxt len" ; mov ebx, 10 shl 16 + 90
;pregs ; mov ecx, 0
; mov edx, input_text
; mov esi, [input_box + 38]
; int 0x40
mov eax, 12 ; finish drawing ; mov eax, esi
mov ebx, 2 ;print "eax = edit etxt len"
int 0x40 ;pregs
ret
mov eax, 12 ; finish drawing
mov ebx, 2
; <--- initialised data ---> int 0x40
DATA
ret
format_id db 1
; buffer db 256 dup(0)
; <--- initialised data --->
CLIP_BUFFER buffer, 256 DATA
input_text db 256 dup(0) format_id db 1
input_box edit_box 100,10,70,0xffffff,0,0x00aaaaaa,0,255,input_text
; buffer db 256 dup(0)
; input_box edit_box 100,10,70,0xffffff,0,0xaaaaaa,0,\
; 0xaaaaaa,0,255,input_text,ed_always_focus CLIP_BUFFER buffer, 256
head db "<22>ਬ¥à à ¡®âë á ¡ãä¥à®¬ ®¡¬¥­ ",0 input_text db 256 dup(0)
text1 db "<22> ¦¨¬ ©â¥ æ¨äàë 0-9 ¤«ï ᬥ­ë id ä®à¬ â  ¤ ­­ëå",0 input_box edit_box 100,10,70,0xffffff,0,0x00aaaaaa,0,255,input_text
text2 db "‘¥©ç á ¢ë¡à ­ id ä®à¬ â  ¤ ­­ëå: ",0
; input_box edit_box 100,10,70,0xffffff,0,0xaaaaaa,0,\
button1 db "Š®¯¨à®¢ âì",0 ; 0xaaaaaa,0,255,input_text,ed_always_focus
button2 db "‚áâ ¢¨âì",0
head db "<22>ਬ¥à à ¡®âë á ¡ãä¥à®¬ ®¡¬¥­ ",0
; <--- uninitialised data ---> text1 db "<22> ¦¨¬ ©â¥ æ¨äàë 0-9 ¤«ï ᬥ­ë id ä®à¬ â  ¤ ­­ëå",0
UDATA text2 db "‘¥©ç á ¢ë¡à ­ id ä®à¬ â  ¤ ­­ëå: ",0
button1 db "Š®¯¨à®¢ âì",0
MEOS_APP_END button2 db "‚áâ ¢¨âì",0
; <--- end of MenuetOS application --->
; <--- uninitialised data --->
UDATA
MEOS_APP_END
; <--- end of MenuetOS application --->

View File

@@ -1,5 +1,5 @@
if tup.getconfig("NO_FASM") ~= "" then return end if tup.getconfig("NO_FASM") ~= "" then return end
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../../.." or tup.getconfig("HELPERDIR") HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../.." or tup.getconfig("HELPERDIR")
tup.include(HELPERDIR .. "/use_fasm.lua") tup.include(HELPERDIR .. "/use_fasm.lua")
add_include(tup.getvariantdir()) add_include(tup.getvariantdir())

View File

@@ -1,3 +1,6 @@
; SPDX-License-Identifier: NOASSERTION
;
; ;
; Modified from original icon editor ; Modified from original icon editor
; ;
@@ -14,7 +17,7 @@
dd 0x0 , 0x0 ; I_Param , I_Icon dd 0x0 , 0x0 ; I_Param , I_Icon
include 'lang.inc' include 'lang.inc'
include '..\..\..\..\macros.inc' include '..\..\..\macros.inc'
window_x_size equ 346 window_x_size equ 346
window_y_size equ 312 window_y_size equ 312

View File

@@ -1,4 +1,4 @@
You should really be using the kpack program instead of kerpack. You should really be using the kpack program instead of kerpack.
It also builds nicely on Linux. It also builds nicely on Linux.
kpack can be found in $SVN/programs/other/kpack kpack can be found in programs/other/kpack

View File

@@ -1,417 +1,420 @@
; Kolibri kernel packer ; SPDX-License-Identifier: NOASSERTION
; (C) copyright diamond 2006, 2007 ;
;
; Disassemled and corrected in 2010 specially for FASM ; Kolibri kernel packer
; by Marat Zakiyanov aka Mario79, aka Mario ; (C) copyright diamond 2006, 2007
; ;
; This program is free software; you can redistribute it and/or modify ; Disassemled and corrected in 2010 specially for FASM
; it under the terms of the GNU General Public License as published by ; by Marat Zakiyanov aka Mario79, aka Mario
; the Free Software Foundation; either version 2 of the License, or ;
; (at your option) any later version. ; This program is free software; you can redistribute it and/or modify
; ; it under the terms of the GNU General Public License as published by
; This program is distributed in the hope that it will be useful, ; the Free Software Foundation; either version 2 of the License, or
; but WITHOUT ANY WARRANTY; without even the implied warranty of ; (at your option) any later version.
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;
; GNU General Public License for more details. ; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; Uses LZMA compression library by Igor Pavlov ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; (for more information on LZMA and 7-Zip visit http://www.7-zip.org) ; GNU General Public License for more details.
; (plain-C packer is ported by diamond)
; Uses LZMA compression library by Igor Pavlov
;--------------------------------------------------------------------- ; (for more information on LZMA and 7-Zip visit http://www.7-zip.org)
use32 ; (plain-C packer is ported by diamond)
org 0
;---------------------------------------------------------------------
db 'MENUET01' use32
dd 1 org 0
dd START
dd IM_END db 'MENUET01'
dd I_END dd 1
dd stacktop dd START
dd 0 ;params dd IM_END
dd 0 ;cur_dir_path dd I_END
;--------------------------------------------------------------------- dd stacktop
include '../../../../macros.inc' dd 0 ;params
; do not touch "purge mov"!!! dd 0 ;cur_dir_path
purge mov ; for the correct patch of loader ;---------------------------------------------------------------------
; do not touch "purge mov"!!! include '../../../macros.inc'
;********************************************************************* ; do not touch "purge mov"!!!
die_with_err: purge mov ; for the correct patch of loader
pop esi ; do not touch "purge mov"!!!
@@: ;*********************************************************************
lodsb die_with_err:
test al,al pop esi
jz @f @@:
lodsb
mov cl,al test al,al
mcall 63,1 jz @f
jmp @b
;********************************************************************* mov cl,al
@@: mcall 63,1
mcall 63,,13 jmp @b
mcall ,,10 ;*********************************************************************
mcall -1 @@:
;********************************************************************* mcall 63,,13
START: mcall ,,10
mcall 70,fn70_read mcall -1
cmp eax,6 ;*********************************************************************
jz read_ok START:
;-------------------------------------- mcall 70,fn70_read
read_err: cmp eax,6
call die_with_err jz read_ok
db 'KerPack: cannot load kernel.mnt',0 ;--------------------------------------
;********************************************************************* read_err:
read_ok: call die_with_err
push 18 db 'KerPack: cannot load kernel.mnt',0
call lzma_set_dict_size ;*********************************************************************
; find jump to 32-bit code read_ok:
mov edi,infile - 1 push 18
;-------------------------------------- call lzma_set_dict_size
@@: ; find jump to 32-bit code
inc edi mov edi,infile - 1
cmp dword [edi],0xE88EE08E ; mov fs,ax/mov gs,ax ;--------------------------------------
jnz @b @@:
inc edi
cmp dword [edi+4],0x00BCD08E ; mov ss,ax/mov esp,00xxxxxx cmp dword [edi],0xE88EE08E ; mov fs,ax/mov gs,ax
jnz @b jnz @b
add edi,11 cmp dword [edi+4],0x00BCD08E ; mov ss,ax/mov esp,00xxxxxx
mov [inptr],edi jnz @b
sub edi, infile
mov [indelta],edi add edi,11
lea eax,[ebx+0x10000] mov [inptr],edi
mov dword [loader_patch3+2],eax sub edi, infile
sub ebx,edi mov [indelta],edi
mov [insize],ebx lea eax,[ebx+0x10000]
call preprocess_calltrick2 mov dword [loader_patch3+2],eax
sub ebx,edi
mov al,[cti] mov [insize],ebx
mov [loader_patch5-1],al call preprocess_calltrick2
mov eax,[ctn]
mov [loader_patch4+1],eax mov al,[cti]
mov eax,[inptr] mov [loader_patch5-1],al
add eax, outfile - infile + loader_size - 5 mov eax,[ctn]
push workmem mov [loader_patch4+1],eax
push [insize] mov eax,[inptr]
push eax add eax, outfile - infile + loader_size - 5
push [inptr] push workmem
call lzma_compress push [insize]
push eax
add eax, loader_size-5 push [inptr]
mov [loader_patch1+6],eax call lzma_compress
add eax,[indelta]
mov [outsize],eax add eax, loader_size-5
mov eax,[indelta] mov [loader_patch1+6],eax
mov ecx,dword [eax + outfile + loader_size - 4] add eax,[indelta]
bswap ecx mov [outsize],eax
mov [loader_patch2+4],ecx mov eax,[indelta]
add eax, 0x10000 mov ecx,dword [eax + outfile + loader_size - 4]
mov [loader_patch1+1],eax bswap ecx
mov esi,infile mov [loader_patch2+4],ecx
mov edi,outfile add eax, 0x10000
mov ecx,[indelta] mov [loader_patch1+1],eax
rep movsb mov esi,infile
mov edi,outfile
mov esi,loader_start mov ecx,[indelta]
mov ecx,loader_size rep movsb
rep movsb
mov esi,loader_start
mcall 70,fn70_write mov ecx,loader_size
test eax,eax rep movsb
jz @f
mcall 70,fn70_write
call die_with_err test eax,eax
db 'KerPack: cannot save kernel.mnt',0 jz @f
;*********************************************************************
@@: call die_with_err
call die_with_err db 'KerPack: cannot save kernel.mnt',0
db 'KerPack: all is OK',0 ;*********************************************************************
;********************************************************************* @@:
preprocess_calltrick2: call die_with_err
; input preprocessing db 'KerPack: all is OK',0
mov edi,ct1 ;*********************************************************************
xor eax,eax preprocess_calltrick2:
push edi ; input preprocessing
mov ecx,256/4 mov edi,ct1
rep stosd xor eax,eax
push edi
pop edi mov ecx,256/4
mov ecx,ebx rep stosd
mov esi,[inptr]
mov ebx,inbuftmp pop edi
xchg eax,edx mov ecx,ebx
;-------------------------------------- mov esi,[inptr]
input_pre2: mov ebx,inbuftmp
lodsb xchg eax,edx
;-------------------------------------- ;--------------------------------------
@@: input_pre2:
cmp al,0Fh lodsb
jnz ip1 ;--------------------------------------
@@:
dec ecx cmp al,0Fh
jz input_pre_done2 jnz ip1
lodsb dec ecx
cmp al,80h jz input_pre_done2
jb @b
lodsb
cmp al,90h cmp al,80h
jb @f jb @b
;--------------------------------------
ip1: cmp al,90h
sub al,0E8h jb @f
cmp al,1 ;--------------------------------------
ja input_pre_cont2 ip1:
;-------------------------------------- sub al,0E8h
@@: cmp al,1
cmp ecx,5 ja input_pre_cont2
jb input_pre_done2 ;--------------------------------------
@@:
lodsd cmp ecx,5
add eax,esi jb input_pre_done2
sub eax,[inptr]
cmp eax,[insize] lodsd
jae xxx2 add eax,esi
sub eax,[inptr]
cmp eax,1000000h cmp eax,[insize]
jae xxx2 jae xxx2
sub ecx,4 cmp eax,1000000h
xchg al,ah jae xxx2
rol eax,16
xchg al,ah sub ecx,4
mov [esi-4],eax xchg al,ah
inc edx rol eax,16
mov [ebx],esi xchg al,ah
add ebx,4 mov [esi-4],eax
jmp input_pre_cont2 inc edx
;********************************************************************* mov [ebx],esi
xxx2: add ebx,4
sub esi,4 jmp input_pre_cont2
movzx eax,byte [esi] ;*********************************************************************
mov byte [eax+edi],1 xxx2:
;-------------------------------------- sub esi,4
input_pre_cont2: movzx eax,byte [esi]
loop input_pre2 mov byte [eax+edi],1
;-------------------------------------- ;--------------------------------------
input_pre_done2: input_pre_cont2:
mov [ctn],edx loop input_pre2
xor eax,eax ;--------------------------------------
mov ecx,256 input_pre_done2:
repnz scasb mov [ctn],edx
jnz pack_calltrick_done xor eax,eax
mov ecx,256
not cl repnz scasb
mov [cti],cl jnz pack_calltrick_done
;--------------------------------------
@@: not cl
cmp ebx,inbuftmp mov [cti],cl
jz pack_calltrick_done ;--------------------------------------
@@:
sub ebx,4 cmp ebx,inbuftmp
mov eax,[ebx] jz pack_calltrick_done
mov [eax-4],cl
jmp @b sub ebx,4
;********************************************************************* mov eax,[ebx]
pack_calltrick_done: mov [eax-4],cl
ret jmp @b
;********************************************************************* ;*********************************************************************
;lzma_compress: pack_calltrick_done:
include 'lzma_compress.inc' ret
;--------------------------------------------------------------------- ;*********************************************************************
;lzma_set_dict_size: ;lzma_compress:
include 'lzma_set_dict_size.inc' include 'lzma_compress.inc'
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
; ;lzma_set_dict_size:
include 'loader_lzma.inc' include 'lzma_set_dict_size.inc'
;********************************************************************* ;---------------------------------------------------------------------
fn70_read: ;
dd 0 include 'loader_lzma.inc'
dd 0 ;*********************************************************************
dd 0 fn70_read:
dd 200*1024 dd 0
dd infile dd 0
filename db '/sys/kernel.mnt',0 dd 0
dd 200*1024
fn70_write: dd infile
dd 2 filename db '/sys/kernel.mnt',0
dd 0
dd 0 fn70_write:
outsize dd ? dd 2
dd outfile dd 0
db 0 dd 0
dd filename outsize dd ?
;--------------------------------------------------------------------- dd outfile
align 4 db 0
LiteralNextStates: dd filename
db 0,0,0,0,1,2,3,4,5,6,4,5 ;---------------------------------------------------------------------
MatchNextStates: align 4
db 7,7,7,7,7,7,7,10,10,10,10,10 LiteralNextStates:
RepNextStates: db 0,0,0,0,1,2,3,4,5,6,4,5
db 8,8,8,8,8,8,8,11,11,11,11,11 MatchNextStates:
ShortRepNextStates: db 7,7,7,7,7,7,7,10,10,10,10,10
db 9,9,9,9,9,9,9,11,11,11,11,11 RepNextStates:
;--------------------------------------------------------------------- db 8,8,8,8,8,8,8,11,11,11,11,11
;********************************************************************* ShortRepNextStates:
IM_END: db 9,9,9,9,9,9,9,11,11,11,11,11
;********************************************************************* ;---------------------------------------------------------------------
;params: ;*********************************************************************
; rb 256 IM_END:
;--------------------------------------------------------------------- ;*********************************************************************
;cur_dir_path: ;params:
; rb 4096 ; rb 256
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 4 ;cur_dir_path:
rb 4096 ; rb 4096
stacktop: ;---------------------------------------------------------------------
;--------------------------------------------------------------------- align 4
align 4 rb 4096
inptr dd ? stacktop:
indelta dd ? ;---------------------------------------------------------------------
insize dd ? align 4
ct1 rb 256 inptr dd ?
ctn dd ? indelta dd ?
cti db ? insize dd ?
ct1 rb 256
infile rb 200*1024 ctn dd ?
inbuftmp rb 200*1024 cti db ?
outfile rb 200*1024
workmem rb 6A8000h infile rb 200*1024
;--------------------------------------------------------------------- inbuftmp rb 200*1024
; Compress data area start outfile rb 200*1024
;--------------------------------------------------------------------- workmem rb 6A8000h
align 4 ;---------------------------------------------------------------------
_lenEncoder: ; Compress data area start
rd 8451 ;---------------------------------------------------------------------
;----------------------------------------------------- align 4
_prices: _lenEncoder:
rd 4384 rd 8451
rd 17 ;-----------------------------------------------------
;----------------------------------------------------- _prices:
_finished: rb 1 rd 4384
_writeEndMark: rb 1 rd 17
_longestMatchWasFound: rb 1 ;-----------------------------------------------------
_previousByte: rb 1 _finished: rb 1
_longestMatchLength: rd 1 _writeEndMark: rb 1
;----------------------------------------------------- _longestMatchWasFound: rb 1
g_FastPos: _previousByte: rb 1
rb 1024 _longestMatchLength: rd 1
;----------------------------------------------------- ;-----------------------------------------------------
_posSlotPrices: g_FastPos:
rd 256 rb 1024
;----------------------------------------------------- ;-----------------------------------------------------
_isRep0Long: _posSlotPrices:
rd 192 rd 256
;----------------------------------------------------- ;-----------------------------------------------------
distances: _isRep0Long:
rd 274 rd 192
;----------------------------------------------------- ;-----------------------------------------------------
_optimumCurrentIndex: rd 1 distances:
_additionalOffset: rd 1 rd 274
;----------------------------------------------------- ;-----------------------------------------------------
_isRepG1: _optimumCurrentIndex: rd 1
rd 12 _additionalOffset: rd 1
;----------------------------------------------------- ;-----------------------------------------------------
_isMatch: _isRepG1:
rd 192 rd 12
;----------------------------------------------------- ;-----------------------------------------------------
_alignPriceCount: rd 1 _isMatch:
_numLiteralContextBits: rd 1 rd 192
;----------------------------------------------------- ;-----------------------------------------------------
_literalEncoder: _alignPriceCount: rd 1
rd 114 _numLiteralContextBits: rd 1
;----------------------------------------------------- ;-----------------------------------------------------
nowPos64: _literalEncoder:
rd 2 rd 114
;----------------------------------------------------- ;-----------------------------------------------------
_distancesPrices: nowPos64:
rd 512 rd 2
;----------------------------------------------------- ;-----------------------------------------------------
_repDistances: _distancesPrices:
rd 4 rd 512
;----------------------------------------------------- ;-----------------------------------------------------
_posSlotEncoder: _repDistances:
rd 1028 rd 4
;----------------------------------------------------- ;-----------------------------------------------------
lastPosSlotFillingPos: _posSlotEncoder:
rd 2 rd 1028
;----------------------------------------------------- ;-----------------------------------------------------
_numFastBytes: rd 1 lastPosSlotFillingPos:
_posStateMask: rd 1 rd 2
;----------------------------------------------------- ;-----------------------------------------------------
_isRepG0: _numFastBytes: rd 1
rd 12 _posStateMask: rd 1
;----------------------------------------------------- ;-----------------------------------------------------
_repMatchLenEncoder: _isRepG0:
rd 8451 rd 12
rd 4384 ;-----------------------------------------------------
rd 17 _repMatchLenEncoder:
;----------------------------------------------------- rd 8451
_isRepG2: rd 4384
rd 12 rd 17
;----------------------------------------------------- ;-----------------------------------------------------
_dictionarySize: rd 1 _isRepG2:
_numLiteralPosStateBits: rd 1 rd 12
_distTableSize: rd 1 ;-----------------------------------------------------
_optimumEndIndex: rd 1 _dictionarySize: rd 1
;----------------------------------------------------- _numLiteralPosStateBits: rd 1
;static CState state _distTableSize: rd 1
state.State: rb 1 _optimumEndIndex: rd 1
state.Prev1IsChar: rb 1 ;-----------------------------------------------------
state.Prev2: rb 2 ;static CState state
state.PosPrev2: rd 1 state.State: rb 1
state.BackPrev2: rd 1 state.Prev1IsChar: rb 1
state.Price: rd 1 state.Prev2: rb 2
state.PosPrev: rd 1 state.PosPrev2: rd 1
state.BackPrev: rd 1 state.BackPrev2: rd 1
state.Backs: state.Price: rd 1
rd 4 state.PosPrev: rd 1
;---------------------------------------------------- state.BackPrev: rd 1
rd 40950 state.Backs:
;----------------------------------------------------- rd 4
_alignPrices: ;----------------------------------------------------
rd 16 rd 40950
;----------------------------------------------------- ;-----------------------------------------------------
_isRep: _alignPrices:
rd 12 rd 16
;----------------------------------------------------- ;-----------------------------------------------------
_posAlignEncoder: _isRep:
rd 256 rd 12
;----------------------------------------------------- ;-----------------------------------------------------
i_01: rd 1 _posAlignEncoder:
;----------------------------------------------------- rd 256
_state: rb 1 ;-----------------------------------------------------
_cache: rb 1 i_01: rd 1
_state.Prev2: rb 2 ;-----------------------------------------------------
_posEncoders: rd 1 _state: rb 1
_numPrevBits: rd 1 _cache: rb 1
_numPosBits: rd 1 _state.Prev2: rb 2
_posMask: rd 1 _posEncoders: rd 1
_posStateBits: rd 1 _numPrevBits: rd 1
_range: rd 1 _numPosBits: rd 1
_cacheSize: rd 1 _posMask: rd 1
_cyclicBufferSize: rd 1 _posStateBits: rd 1
;----------------------------------------------------- _range: rd 1
low: _cacheSize: rd 1
rd 2 _cyclicBufferSize: rd 1
;----------------------------------------------------- ;-----------------------------------------------------
Models: low:
rd 512 rd 2
;----------------------------------------------------- ;-----------------------------------------------------
_matchMaxLen: rd 1 Models:
pack_pos: rd 1 rd 512
_cutValue: rd 1 ;-----------------------------------------------------
_hash: rd 1 _matchMaxLen: rd 1
;----------------------------------------------------- pack_pos: rd 1
crc_table: _cutValue: rd 1
rd 256 _hash: rd 1
;----------------------------------------------------- ;-----------------------------------------------------
_buffer: rd 1 crc_table:
_pos: rd 1 rd 256
_streamPos: rd 1 ;-----------------------------------------------------
pack_length: rd 1 _buffer: rd 1
;--------------------------------------------------------------------- _pos: rd 1
; Compress data area end _streamPos: rd 1
;--------------------------------------------------------------------- pack_length: rd 1
I_END: ;---------------------------------------------------------------------
;--------------------------------------------------------------------- ; Compress data area end
;---------------------------------------------------------------------
I_END:
;---------------------------------------------------------------------

View File

@@ -1,5 +1,5 @@
if tup.getconfig("NO_FASM") ~= "" then return end if tup.getconfig("NO_FASM") ~= "" then return end
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../../.." or tup.getconfig("HELPERDIR") HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../.." or tup.getconfig("HELPERDIR")
tup.include(HELPERDIR .. "/use_fasm.lua") tup.include(HELPERDIR .. "/use_fasm.lua")
add_include(tup.getvariantdir()) add_include(tup.getvariantdir())

View File

@@ -1,3 +1,4 @@
; SPDX-License-Identifier: NOASSERTION
; ;
; MIXER ; MIXER
@@ -6,7 +7,7 @@
; ;
include 'lang.inc' include 'lang.inc'
include '..\..\..\..\macros.inc' include '..\..\..\macros.inc'
use32 use32