Compare commits

...

10 Commits

Author SHA1 Message Date
83f3af547d outdated/mhc: Post-SVN tidy
- Move source code from `trunk` into root directory.
- Checked build files and ASM include paths.
2025-09-14 11:25:00 +01:00
7ccd4288f5 outdated/kerpack: Post-SVN tidy
- Move source code from `trunk` into root directory.
- Checked build files and ASM include paths.
2025-08-12 00:43:43 +01:00
b14f77c304 outdated/jpegview: Post-SVN tidy
- Move source code from `trunk` into root directory.
- Update build files and checked ASM include paths.
2025-08-04 10:23:58 +01:00
e1eda2ae34 outdated/iconedit: Post-SVN tidy
- Move source code from `trunk` into root directory.
- Update build files and ASM include paths.
2025-08-03 22:05:01 +01:00
c66301590c outdated/gifview: Post-SVN tidy
- Move source code from `trunk` into root directory.
- Update build files and checked ASM include paths.
2025-08-02 19:38:15 +01:00
d5e7a90c50 outdated/mixer: Post-SVN tidy
- Move source code from `trunk` into root directory.
- Update build files and ASM include paths.
2025-06-28 01:13:52 -04:00
1f9efb9437 outdated/archer: Post-SVN tidy
- Move source code from `trunk` into root directory.
- Checked ASM include paths.
- Note: Line endings standardised from `CRLF` > `LF`, so best to view diffs with whitespace changes hidden.
2025-06-28 01:08:48 -04:00
c4a39efecb outdated/clip: Post-SVN tidy
- Move source code from `trunk` into root directory.
- Update build files and ASM include paths.
- Note: Line endings standardised from `CRLF` > `LF`, so best to view diffs with whitespace changes hidden.
2025-06-28 00:46:38 -04:00
fa3049df7e outdated/bgitest: Post-SVN tidy
- Move source code from `trunk` into root directory.
- Update build files and ASM include paths.
2025-06-28 00:37:25 -04:00
760b12025f outdated/mfar: Post-SVN tidy
- Move source code from `trunk` into root directory.
2025-06-28 00:26:51 -04:00
80 changed files with 1924 additions and 1889 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
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")
add_include(tup.getvariantdir())

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
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")
add_include(tup.getvariantdir())

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
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")
add_include(tup.getvariantdir())

View File

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