Мастера DELPHI, Delphi programming community Рейтинг@Mail.ru Титульная страница Поиск, карта сайта Написать письмо 
| Новости |
Новости сайта
Поиск |
Поиск по лучшим сайтам о Delphi
FAQ |
Огромная база часто задаваемых вопросов и, конечно же, ответы к ним ;)
Статьи |
Подборка статей на самые разные темы. Все о DELPHI
Книги |
Новинки книжного рынка
Новости VCL
Обзор свежих компонент со всего мира, по-русски!
|
| Форумы
Здесь вы можете задать свой вопрос и наверняка получите ответ
| ЧАТ |
Место для общения :)
Орешник
Коллекция курьезных вопросов из форумов
Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / rsdn.org

 
Чтобы не потерять эту дискуссию, сделайте закладку « предыдущая ветвь | форум | следующая ветвь »

Minimal System.pas and SysInit.pas for Win 7 [Delphi]


spawn89   (20.03.11 15:30

Hi smartly guys,
i need minimal Sys-Units.
I hope you can help me, cause the KOL System.pas and SysInit.pas is working on Windows 7.

System.pas:
unit System;

interface

procedure _HandleFinally;

type
 TGUID = record
   D1: LongWord;
   D2: Word;
   D3: Word;
   D4: array[0..7] of Byte;
 end;

 TDLLProc = procedure(Reason: Integer);
 TDLLProcEx = procedure(Reason: Integer; Reserved: Integer);

procedure _Halt0;

var
 ExitCode: Integer;

implementation

procedure _Halt0; assembler;
asm
 mov     eax, [ExitCode]
 leave
end;

procedure _HandleFinally; assembler;
asm
 mov     eax, True
end;

end.


SysInit.pas:
unit SysInit;

interface

var
 TlsIndex: Integer;
 TlsLast : Byte;
 PtrToNil: Pointer;

var
 HInstance: Cardinal; //Pointer;
 GetCommandLine: PAnsiChar;

procedure _InitExe;

implementation

procedure _InitExe; assembler;
asm
 mov     eax, [ebp+$08]
 mov     [HInstance], eax
 mov     eax, [ebp+$10]
 mov     [GetCommandLine], eax
end;

initialization
 _InitExe;

end.


My Processes with these System.pas and SysInit.pas always hang up after they finished their work.

Test-Project:
program HelloWorld;

function MessageBoxA(hWnd: Cardinal; lpText, lpCaption: Pchar; uType: Cardinal): Integer; stdcall; external 'user32.dll' name 'MessageBoxA';

begin
 MessageBoxA(0, 'Hello World', 'test', 0);
end.


After MessageBox closed the process remains in Task-Man. With KOL-Sys-Units it closes fine.
Please help me clever people.
Sorry for bad english and non existing russian. :(
Thanks!


kol   (21.03.11 22:31[1]

I do not have d2009, only 2010 and everything before d2009 but you have to understand that the delphi compiler relies on compiler magic for some lowlevel stuff. Thatr's why it is not so trivial to write the system units replacements. Basically what you have to do is trace manually all functions in the system unit that start with an underscore and trace back where it goes back into / comes out of the compiler without a reference in the sourcecode.

What you probably missed is the code that finalizes refcounted stuff (although you do not use it) and that code is not re-entrant and therefore, if you omit it, causes the crashes.


Dufa ©   (23.03.11 15:57[2]

Неудивительно, что приложение падает.. Сплошные ошибки.. Зачем нужны такие мини модули?


Thaddy ©   (23.03.11 16:05[3]

You should be able to find something on the internet.
At least for D5-D7 there were system replacements that only used winapi and gave executables very close to handcoded asm (about 2048 bytes) and written in delphi without objects.
It was very popular with malware authors and the site I got it from (Russian ;-) ) is closed! But the sources are still around.

In general: do not use overbloated new delphi versions. Use an old versionlike d5 or d7 or even d2/d3 for really small executables.


spawn89   (23.03.11 21:33[4]

I searched days... None of these i found worked on Windows 7... all XP and lower.
But i did it! I reduced your pretty KOL-Sys-Units and tryied tryied tryied ... ^^
Look here, tested on Win 89, XP, Vista and 7:
unit SysInit;

interface

procedure _InitExe(InitTable: Pointer);

var
 TlsIndex: Integer = -1;  
 TlsLast: Byte;    
const
 PtrToNil: Pointer = nil;

implementation

procedure _InitExe(InitTable: Pointer);
begin
end;

end.


unit System;

interface

procedure _Halt0;
procedure _HandleFinally;

type
 TGUID = record
   D1: LongWord;
   D2: Word;
   D3: Word;
   D4: array [0..7] of Byte;
 end;

var
 ExitCode: Integer = 0;
 
procedure ExitProcess(ExitCode: Integer); stdcall; external 'kernel32.dll' name 'ExitProcess';

implementation

procedure _Halt0;
begin
 ExitProcess(ExitCode);
end;

procedure _HandleFinally;
asm
end;

end.


Hell, 4KB in Delphi 2007 .. thats nice!

> It was very popular with malware authors and the site I got it from (Russian ;-) ) is closed!
Yeah!
We in Germany notice that Russian is worlds Delphis Hackers Heaven No. 1.
Not this arrogant closed source shit feeling like here. ;/


spawn89   (23.03.11 21:55[5]

Sorry for Doublepost, but can u Post the url to the malware forum?
I got some nice Web Archiever and Translators.

> Неудивительно, что приложение падает.. Сплошные ошибки.. Зачем нужны такие мини модули?
What Dufa © said? I dont get this. xD
"Why are Minis?" ٩(͡๏̯͡๏)۶


Jon ©   (24.03.11 00:11[6]

This may be of interest to you: http://www.delphibasics.info/home/delphibasicsarticles/smallapplicationsindelphibyn0v4


версия для печати

Написать ответ

Ваше имя (регистрация  E-mail 







Разрешается использование тегов форматирования текста:
<b>жирный</b> <i>наклонный</i> <u>подчеркнутый</u>,
а для выделения текста программ, используйте <code> ... </code>
и не забывайте закрывать теги! </b></i></u></code> :)


Наверх

  Рейтинг@Mail.ru     Титульная страница Поиск, карта сайта Написать письмо