forked from KolibriOS/kolibrios
LRL 1.4b
git-svn-id: svn://kolibrios.org@763 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
a5131135c4
commit
5780544c0f
@ -6,9 +6,9 @@ uses
|
|||||||
sysinitpas, {sysinitcyg, sysinitgprof,}
|
sysinitpas, {sysinitcyg, sysinitgprof,}
|
||||||
ctypes, strings,
|
ctypes, strings,
|
||||||
lineinfo, lnfodwrf, heaptrc, matrix,
|
lineinfo, lnfodwrf, heaptrc, matrix,
|
||||||
{windows, winsock, winsock2, initc, cmem, dynlibs, signals,}
|
{windows, winsock, winsock2, initc, cmem, }dynlibs, {signals,}
|
||||||
dos, crt, objects{, messages,
|
dos, crt, objects{, messages,
|
||||||
rtlconsts, sysconst}, sysutils{, math, types,
|
rtlconsts, sysconst}, sysutils, math{, types,
|
||||||
strutils, dateutils, varutils, variants, typinfo, fgl}, classes{,
|
strutils, dateutils, varutils, variants, typinfo, fgl}, classes{,
|
||||||
convutils, stdconvs, cpu, mmx, charset, ucomplex, getopts,
|
convutils, stdconvs, cpu, mmx, charset, ucomplex, getopts,
|
||||||
winevent, sockets, printer,
|
winevent, sockets, printer,
|
||||||
|
@ -146,6 +146,28 @@ asm
|
|||||||
popl %ebx
|
popl %ebx
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure kos_setkeyboardmode(mode: DWord); assembler; register;
|
||||||
|
asm
|
||||||
|
pushl %eax
|
||||||
|
pushl %ebx
|
||||||
|
movl $66, %ecx
|
||||||
|
movl $1, %ebx
|
||||||
|
xchgl %eax, %ecx
|
||||||
|
int $0x40
|
||||||
|
xchgl %eax, %ecx
|
||||||
|
popl %ebx
|
||||||
|
popl %eax
|
||||||
|
end;
|
||||||
|
|
||||||
|
function kos_getkeyboardmode(): DWord; assembler; register;
|
||||||
|
asm
|
||||||
|
pushl %ebx
|
||||||
|
movl $66, %eax
|
||||||
|
movl $2, %ebx
|
||||||
|
int $0x40
|
||||||
|
popl %ebx
|
||||||
|
end;
|
||||||
|
|
||||||
procedure kos_setcaption(caption: PChar); assembler; register;
|
procedure kos_setcaption(caption: PChar); assembler; register;
|
||||||
asm
|
asm
|
||||||
pushl %ecx
|
pushl %ecx
|
||||||
|
@ -23,6 +23,8 @@ function kos_getmousepos(): TKosPoint;
|
|||||||
function kos_getmousewinpos(): TKosPoint;
|
function kos_getmousewinpos(): TKosPoint;
|
||||||
function kos_getmousebuttons(): DWord;
|
function kos_getmousebuttons(): DWord;
|
||||||
procedure kos_maskevents(mask: DWord);
|
procedure kos_maskevents(mask: DWord);
|
||||||
|
procedure kos_setkeyboardmode(mode: DWord);
|
||||||
|
function kos_getkeyboardmode(): DWord;
|
||||||
procedure kos_setcaption(caption: PChar);
|
procedure kos_setcaption(caption: PChar);
|
||||||
|
|
||||||
{ Graphics }
|
{ Graphics }
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
{cp866}
|
{utf8}
|
||||||
|
|
||||||
function DecodeErrNo(ErrNo: DWord): Word;
|
function DecodeErrNo(ErrNo: DWord): Word;
|
||||||
{0 = ãᯥè®
|
{0 = успешно
|
||||||
1 = ¥ ®¯à¥¤¥«¥ ¡ § ¨/¨«¨ à §¤¥« ¦ñá⪮£® ¤¨áª (¯®¤äãªæ¨ï¬¨ 7, 8 äãªæ¨¨ 21)
|
1 = не определена база и/или раздел жёсткого диска (подфункциями 7, 8 функции 21)
|
||||||
2 = äãªæ¨ï ¥ ¯®¤¤¥à¦¨¢ ¥âáï ¤«ï ¤ ®© ä ©«®¢®© á¨á⥬ë
|
2 = функция не поддерживается для данной файловой системы
|
||||||
3 = ¥¨§¢¥áâ ï ä ©«®¢ ï á¨á⥬
|
3 = неизвестная файловая система
|
||||||
4 = § १¥à¢¨à®¢ ®, ¨ª®£¤ ¥ ¢®§¢à é ¥âáï ¢ ⥪ã饩 ॠ«¨§ 樨
|
4 = зарезервировано, никогда не возвращается в текущей реализации
|
||||||
5 = ä ©« ¥ ©¤¥
|
5 = файл не найден
|
||||||
6 = ä ©« § ª®ç¨«áï
|
6 = файл закончился
|
||||||
7 = 㪠§ â¥«ì ¢¥ ¯ ¬ï⨠¯à¨«®¦¥¨ï
|
7 = указатель вне памяти приложения
|
||||||
8 = ¤¨áª § ¯®«¥
|
8 = диск заполнен
|
||||||
9 = â ¡«¨æ FAT à §àãè¥
|
9 = таблица FAT разрушена
|
||||||
10 = ¤®áâ㯠§ ¯à¥éñ
|
10 = доступ запрещён
|
||||||
11 = ®è¨¡ª ãáâனá⢠}
|
11 = ошибка устройства}
|
||||||
begin
|
begin
|
||||||
case ErrNo of
|
case ErrNo of
|
||||||
0: Result := 0;
|
0: Result := 0;
|
||||||
@ -24,7 +24,7 @@ begin
|
|||||||
6: Result := 0;
|
6: Result := 0;
|
||||||
8: Result := 101;
|
8: Result := 101;
|
||||||
else
|
else
|
||||||
Result := 153; { Unknown command (¥¨§¢¥áâ ï ª®¬ ¤ ) }
|
Result := 153; { Unknown command (неизвестная команда) }
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -96,6 +96,8 @@ begin
|
|||||||
InOutRes := 211;
|
InOutRes := 211;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ FIXME: Поправить RTL, факт отсутствия файла не фиксируется при его открытии. }
|
||||||
procedure do_open(var f; p: PChar; flags: Longint);
|
procedure do_open(var f; p: PChar; flags: Longint);
|
||||||
var
|
var
|
||||||
KosFile: PKosFile;
|
KosFile: PKosFile;
|
||||||
@ -104,6 +106,7 @@ var
|
|||||||
RecSize: Longint;
|
RecSize: Longint;
|
||||||
CurrDir: array[0..2048] of Char;
|
CurrDir: array[0..2048] of Char;
|
||||||
CurrDirLen: Longint;
|
CurrDirLen: Longint;
|
||||||
|
Dummy: Longint;
|
||||||
begin
|
begin
|
||||||
case flags and 3 of
|
case flags and 3 of
|
||||||
0: FileRec(f).Mode := fmInput;
|
0: FileRec(f).Mode := fmInput;
|
||||||
@ -111,11 +114,11 @@ begin
|
|||||||
2: FileRec(f).Mode := fmInOut;
|
2: FileRec(f).Mode := fmInOut;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{”®à¬¨à®¢ ¨¥ ¨¬¥¨ ¡á®«î⮣® ¯ãâ¨}
|
{Формирование имени абсолютного пути}
|
||||||
FilePathLen := Length(p);
|
FilePathLen := Length(p);
|
||||||
if p^ <> DirectorySeparator then
|
if p^ <> DirectorySeparator then
|
||||||
begin
|
begin
|
||||||
{XXX: à §¬¥à ¡ãä¥à CurrDir ¬®¦¥â ®ª § âìáï ¥¤®áâ â®çë¬}
|
{XXX: размер буфера CurrDir может оказаться недостаточным}
|
||||||
CurrDirLen := kos_getdir(@CurrDir, SizeOf(CurrDir) - FilePathLen - 1) - 1;
|
CurrDirLen := kos_getdir(@CurrDir, SizeOf(CurrDir) - FilePathLen - 1) - 1;
|
||||||
FilePath := @CurrDir;
|
FilePath := @CurrDir;
|
||||||
|
|
||||||
@ -129,7 +132,7 @@ begin
|
|||||||
end else
|
end else
|
||||||
FilePath := p;
|
FilePath := p;
|
||||||
|
|
||||||
{‘®§¤ ¨¥ áâàãªâãàë TKosFile}
|
{Создание структуры TKosFile}
|
||||||
RecSize := SizeOf(TKosFile) + FilePathLen;
|
RecSize := SizeOf(TKosFile) + FilePathLen;
|
||||||
KosFile := GetMem(RecSize);
|
KosFile := GetMem(RecSize);
|
||||||
FillChar(KosFile^, RecSize, 0);
|
FillChar(KosFile^, RecSize, 0);
|
||||||
@ -138,8 +141,16 @@ begin
|
|||||||
|
|
||||||
if flags and $1000 <> 0 then
|
if flags and $1000 <> 0 then
|
||||||
begin
|
begin
|
||||||
{ ᮧ¤ âì ä ©« }
|
{ создать файл }
|
||||||
InOutRes := DecodeErrNo(kos_rewritefile(KosFile, RecSize));
|
InOutRes := DecodeErrNo(kos_rewritefile(KosFile, RecSize));
|
||||||
end else
|
end else
|
||||||
InOutRes := 0;
|
begin
|
||||||
|
{ попытаться прочитать файл }
|
||||||
|
KosFile^.Size := 1;
|
||||||
|
KosFile^.Data := @Dummy;
|
||||||
|
InOutRes := DecodeErrNo(kos_readfile(KosFile, Dummy));
|
||||||
|
end;
|
||||||
|
|
||||||
|
if InOutRes <> 0 then
|
||||||
|
FreeMem(KosFile);
|
||||||
end;
|
end;
|
||||||
|
@ -1,7 +1,100 @@
|
|||||||
unit Windows;
|
unit Windows;
|
||||||
|
|
||||||
|
{$mode objfpc}
|
||||||
|
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
WinBool = LongBool;
|
||||||
|
Bool = WinBool;
|
||||||
|
Handle = System.THandle;
|
||||||
|
THandle = Handle;
|
||||||
|
|
||||||
|
OVERLAPPED = record
|
||||||
|
Internal : DWORD;
|
||||||
|
InternalHigh : DWORD;
|
||||||
|
Offset : DWORD;
|
||||||
|
OffsetHigh : DWORD;
|
||||||
|
hEvent : HANDLE;
|
||||||
|
end;
|
||||||
|
LPOVERLAPPED = ^OVERLAPPED;
|
||||||
|
_OVERLAPPED = OVERLAPPED;
|
||||||
|
TOVERLAPPED = OVERLAPPED;
|
||||||
|
POVERLAPPED = ^OVERLAPPED;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function GetStdHandle(nStdHandle: DWord): Handle;
|
||||||
|
{function SetStdHandle(nStdHandle:DWORD; hHandle:HANDLE): WinBool;}
|
||||||
|
|
||||||
|
function WriteFile(hFile: THandle; const Buffer; nNumberOfBytesToWrite: DWord; var lpNumberOfBytesWritten: DWord; lpOverlapped: POverlapped): Bool;
|
||||||
|
|
||||||
|
function Std_Input_Handle: DWord;
|
||||||
|
function Std_Output_Handle: DWord;
|
||||||
|
function Std_Error_Handle: DWord;
|
||||||
|
|
||||||
|
function GetTickCount: DWord;
|
||||||
|
function QueryPerformanceCounter(var lpPerformanceCount: Int64): WinBool;
|
||||||
|
function QueryPerformanceFrequency(var lpFrequency: Int64): WinBool;
|
||||||
|
|
||||||
|
function AllocConsole: WinBool;
|
||||||
|
{function FreeConsole: WinBool;}
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
|
||||||
|
function GetStdHandle(nStdHandle: DWord): Handle;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Std_Input_Handle: DWord;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Std_Output_Handle: DWord;
|
||||||
|
begin
|
||||||
|
Result := 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Std_Error_Handle: DWord;
|
||||||
|
begin
|
||||||
|
Result := 2;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function WriteFile(hFile: THandle; const Buffer; nNumberOfBytesToWrite: DWord; var lpNumberOfBytesWritten: DWord; lpOverlapped: POverlapped): Bool;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function GetTickCount: DWord;
|
||||||
|
begin
|
||||||
|
Result := kos_timecounter() * 10;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function QueryPerformanceCounter(var lpPerformanceCount: Int64): WinBool;
|
||||||
|
begin
|
||||||
|
lpPerformanceCount := kos_timecounter();
|
||||||
|
Result := True
|
||||||
|
end;
|
||||||
|
|
||||||
|
function QueryPerformanceFrequency(var lpFrequency: Int64): WinBool;
|
||||||
|
begin
|
||||||
|
lpFrequency := 100;
|
||||||
|
Result := True
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function AllocConsole: WinBool;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -257,6 +257,8 @@ var
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
ExeImage := TExeImage.Create(InputFile);
|
ExeImage := TExeImage.Create(InputFile);
|
||||||
|
|
||||||
|
{$ifdef debug}
|
||||||
WriteHead('NT Header');
|
WriteHead('NT Header');
|
||||||
WriteLn(Format('Size of Code: %d', [ExeImage.SizeOfCode]));
|
WriteLn(Format('Size of Code: %d', [ExeImage.SizeOfCode]));
|
||||||
WriteLn(Format('Size of Init Data: %d', [ExeImage.SizeOfInitializedData]));
|
WriteLn(Format('Size of Init Data: %d', [ExeImage.SizeOfInitializedData]));
|
||||||
@ -267,6 +269,7 @@ begin
|
|||||||
WriteLn(Format('Image Size: %d; Header Size: %d', [ExeImage.ImageSize, ExeImage.HeaderSize]));
|
WriteLn(Format('Image Size: %d; Header Size: %d', [ExeImage.ImageSize, ExeImage.HeaderSize]));
|
||||||
WriteLn(Format('Stack Reserve Size: %d; Stack Commit Size: %d', [ExeImage.StackReserveSize, ExeImage.StackCommitSize]));
|
WriteLn(Format('Stack Reserve Size: %d; Stack Commit Size: %d', [ExeImage.StackReserveSize, ExeImage.StackCommitSize]));
|
||||||
WriteLn(Format('Heap Reserve Size: %d; Heap Comit Size: %d', [ExeImage.HeapReserveSize, ExeImage.HeapCommitSize]));
|
WriteLn(Format('Heap Reserve Size: %d; Heap Comit Size: %d', [ExeImage.HeapReserveSize, ExeImage.HeapCommitSize]));
|
||||||
|
{$endif}
|
||||||
|
|
||||||
ImageBase := ExeImage.ImageBase;
|
ImageBase := ExeImage.ImageBase;
|
||||||
ImageSize := 0;
|
ImageSize := 0;
|
||||||
@ -276,9 +279,12 @@ begin
|
|||||||
for i:=0 to ExeImage.Sections.Count-1 do
|
for i:=0 to ExeImage.Sections.Count-1 do
|
||||||
with ExeImage.Sections[i] do
|
with ExeImage.Sections[i] do
|
||||||
begin
|
begin
|
||||||
|
|
||||||
|
{$ifdef debug}
|
||||||
WriteHead(Format('Section %s (0x%x)', [Name, ObjectFlags]));
|
WriteHead(Format('Section %s (0x%x)', [Name, ObjectFlags]));
|
||||||
WriteLn(Format('Section RVA/Size: 0x%x / %d', [SectionRVA, VirtualSize]));
|
WriteLn(Format('Section RVA/Size: 0x%x / %d', [SectionRVA, VirtualSize]));
|
||||||
WriteLn(Format('Physical Offset/Size: 0x%x / %d', [PhysicalOffset, PhysicalSize]));
|
WriteLn(Format('Physical Offset/Size: 0x%x / %d', [PhysicalOffset, PhysicalSize]));
|
||||||
|
{$endif}
|
||||||
|
|
||||||
Size := ImageBase + SectionRVA;
|
Size := ImageBase + SectionRVA;
|
||||||
FileStream.Position := Size;
|
FileStream.Position := Size;
|
||||||
@ -292,13 +298,6 @@ begin
|
|||||||
FileStream.Write(Buffer^, PhysicalSize);
|
FileStream.Write(Buffer^, PhysicalSize);
|
||||||
FreeMem(Buffer);
|
FreeMem(Buffer);
|
||||||
end;
|
end;
|
||||||
{if VirtualSize - PhysicalSize > 0 then
|
|
||||||
begin
|
|
||||||
GetMem(Buffer, VirtualSize - PhysicalSize);
|
|
||||||
FillByte(Buffer^, VirtualSize - PhysicalSize, 0);
|
|
||||||
FileStream.Write(Buffer^, VirtualSize - PhysicalSize);
|
|
||||||
FreeMem(Buffer);
|
|
||||||
end;}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FillByte(KosHeader, SizeOf(KosHeader), 0);
|
FillByte(KosHeader, SizeOf(KosHeader), 0);
|
Loading…
Reference in New Issue
Block a user