Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi aus system.pas: used to hack the result to force a failure.. (https://www.delphipraxis.net/71543-aus-system-pas-used-hack-result-force-failure.html)

heri 16. Jun 2006 18:04


aus system.pas: used to hack the result to force a failure..
 
Ich habe durch Zufall folgendes im BDS\4.0\source\Win32\rtl\sys\system.pas entdeckt:

Delphi-Quellcode:
function _InitUnitPrep: Int64;
var
  SystemTime: TSystemTime;
  FileTime: TFileTime;
  Days: Int64;
begin
  GetLocalTime(SystemTime);
  SystemTimeToFileTime(SystemTime, FileTime);

    // used to hack the result to force a failure for testing:
  Days := 1000000000 div 100;
  Days := Days * 3600;
  Days := Days * 24;
  Days := Days * 31;
  Days := 0;

  Result := Int64(FileTime) + Days;
//  Dec(InitContext.InitTable^.UnitCount);
end;
nur aus reiner Neugier - hat jemand eine Idee was das "used to hack the result to force a failure" bedeutet?
schon interessant was man so alles im source von delphi entdeckt :)

[edit=r_kerber]Delphi-Tags eingefügt. Das nächste Mal bitte selbst daran denken. Mfg, r_kerber[/edit]

Dax 16. Jun 2006 18:11

Re: aus system.pas: used to hack the result to force a failu
 
Vielleicht erhofften die sich, einen Overflow zu produzieren um Lücken Int64-Mul-Code zu finden :)

Union 17. Jun 2006 10:30

Re: aus system.pas: used to hack the result to force a failu
 
Die Kommentare zu der Funktion solltest Du auch lesen - Diese wird nur bei der Trial-Version mitcompiliert und sorgt dafür, dass die damit erstellten Anwendungen nur für eine bestimmte Dauer lauffähig sind.
Delphi-Quellcode:
SExpiredMsg =
  'Dieses Modul wurde mit Demo-Version von Delphi compiliert.'+#10+
  'Die Demo-Version ist abgelaufen.'+#10;

Amnon82 17. Jun 2006 23:08

Re: aus system.pas: used to hack the result to force a failu
 
@Heri: Wer nur die Hälfte rauskopiert, verstehts selber nicht ;)

Delphi-Quellcode:
{***********************************************************}
{$IFDEF TRIAL_EDITION}
{
   This code is used as part of the timeout test for
   applications built with trial editions of the product. It provides
    the current local time in a format native to the platform in question.

    The linker will generate a checksum of _InitUnitPrep that it will
    place into linked units. The code generated for _InitUnitPrep must
    not contain fixups actually in the image, as this could alter the
    code at load time, invalidating the checksum. Take great care to
    make sure that this code is entirely position independent on all
    platforms and circumstances to avoid a serious problem!
}
{$IFDEF MSWINDOWS}
type
  TSystemTime = record
    wYear: Word;
    wMonth: Word;
    wDayOfWeek: Word;
    wDay: Word;
    wHour: Word;
    wMinute: Word;
    wSecond: Word;
    wMilliseconds: Word;
  end;
  TFileTime = record
        LowTime: Integer;
        HighTime: Integer;
  end;


procedure GetLocalTime(var lpSystemTime: TSystemTime); stdcall; external 'kernel32.dll' name 'GetLocalTime';
procedure SystemTimeToFileTime(const lpSystemTime: TSystemTime; var Dest: TFileTime); stdcall; external 'kernel32.dll' name 'SystemTimeToFileTime';

function _InitUnitPrep: Int64;
var
  SystemTime: TSystemTime;
  FileTime: TFileTime;
  Days: Int64;
begin
  GetLocalTime(SystemTime);
  SystemTimeToFileTime(SystemTime, FileTime);

    // used to hack the result to force a failure for testing:
  Days := 1000000000 div 100;
  Days := Days * 3600;
  Days := Days * 24;
  Days := Days * 31;
  Days := 0;

  Result := Int64(FileTime) + Days;
//  Dec(InitContext.InitTable^.UnitCount);
end;
{$ENDIF}
{$IFDEF LINUX}

function _InitUnitPrep: Integer;
var
  Days: Integer;
begin
  Days := 0;   // used to hack the result to force a failure for testing
    Result := _time(nil) + Days;
end;
{$ENDIF}

resourcestring
{$IFDEF LINUX}
  SExpiredMsg =
  'This module was compiled with a trial version of Kylix.'+#10+
  'The trial period has expired.'+#10;
{$ENDIF}
{$IFDEF MSWINDOWS}
  SExpiredMsg =
  'This module was compiled with a trial version of Delphi.'+#13+#10+
  'The trial period has expired.'+#13+#10;
{$ENDIF}
var
  ExpiredMsg: String;

procedure _Expired;
{$IFDEF MSWINDOWS}
var
  Dummy: Cardinal;
begin
  ExpiredMsg := LoadResString(@SExpiredMsg);
  if IsConsole then
    WriteFile(GetStdHandle(STD_ERROR_HANDLE), PChar(ExpiredMsg), Length(ExpiredMsg), Dummy, nil)
  else
    MessageBox(0, PChar(ExpiredMsg), errCaption, 0);
{$ENDIF}
{$IFDEF LINUX}
begin
  ExpiredMsg := LoadResString(@SExpiredMsg);
  __write(2, PChar(ExpiredMsg), Length(ExpiredMsg));
{$ENDIF}
  Halt(232);
end;

{$ENDIF}   //TRIAL_EDITION
btw. Die Trial- und Personal-Versionen haben nur die compilte System.dcu

Zitat:

This code is used as part of the timeout test for
applications built with trial editions of the product.
... as part of ... anscheinend hat sich Borland noch was anderes einfallen lassen ;)

Ich würd mal nach 'TRIAL_EDITION' in den Sources suchen ... :coder2:

Sascha L 18. Jun 2006 08:01

Re: aus system.pas: used to hack the result to force a failu
 
Eine der sinnvollsten Code-Zeilen, die ich seit langem gesehen habe:

Delphi-Quellcode:
// used to hack the result to force a failure for testing:
  Days := 1000000000 div 100;
:D

himitsu 18. Jun 2006 08:19

Re: aus system.pas: used to hack the result to force a failu
 
Es hat doch keiner behauptet, daß diese Zeilen "sinnvoll" sein sollen, die sollen halt nur (irgendwie) nach 'ner Weile 'nen Fehler auslösen, in den mit 'ner Trial-Version erstellten Programmen.

Ich kann zwar an diesen paar Zeilen nicht erkennen, wie/wann/was/wo da irgendwann mal ein Fehler auftreten sollte.

PS: konnte bisher nur derartig

Zitat:

Zitat von Amnon82
Ich würd mal nach 'TRIAL_EDITION' in den Sources suchen ... :coder2:

Du meinst dat in System und SysInit?

Na ja, 's war ja och wahrscheinlich, dat "nur" darin was ist ... dies sind ja die einzigen Units, welche immer eingebunden werden ^^


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:46 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz