Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Herausfinden ob Prozess/Anwendung mit Delphi compiliert ist (https://www.delphipraxis.net/61982-herausfinden-ob-prozess-anwendung-mit-delphi-compiliert-ist.html)

Patrick 29. Jan 2006 11:07


Herausfinden ob Prozess/Anwendung mit Delphi compiliert ist
 
Hallo,

Ich möchte herausfinden, ob eine Anwendung mit Delphi compiliert wurde. Noch besser wäre es, wenn ich dies an einem Prozess erkennen könnte.

Ist das überhaupt möglich?

Assun 29. Jan 2006 11:16

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
Würde mich auch interessieren !

Gibt es vllt irgendwelche besonderen merkmale im Hexcode oder so, nach denen man suchen könnte ?

LoRd-MuldeR 29. Jan 2006 11:20

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
Wenn die Anwendung Forms enthält findest du die Delphi-Forms in den Resourcen der EXE wieder.
Das is auf jedenfall ein Merkmal...

DevilsCamp 29. Jan 2006 12:44

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
aber kein zwingendes.

Was aber, wenn es mit dem C-Builder compiliert wurde?

Rastaman 29. Jan 2006 12:46

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
Dann wurde es nicht mit Delphi kompiliert, und das war auch die Frage :roll:

//Edit: Ist auch nicht wirklich zwingend, wenn nonVCL.
Was aber immer vorhanden ist, wenn dus mit nem ResEditor anschaust, ist der "Ordner" "RCDATA\PACKAGEINFO".

Avax2k 29. Jan 2006 12:59

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
mit PEiD kann man herausfinden welcher Compiler für das Erstellen des Programmes benutzt wurde.

SirThornberry 29. Jan 2006 13:00

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
@Rastaman: darauf würde ich mich nicht verlassen. Wer nonVCL programmiert (damit die Anwendung kleiner ist) wird sich auch nicht davor scheuen überflüssige Ressourcen zu entfernen. Und der Hinweis mit dem C-Build war darauf bezogen das dann auch die Forms enthalten sind.

Rastaman 29. Jan 2006 13:50

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
Mmmh, wusste gar nicht dass man die entfernen kann und die exe läuft trotzdem noch :stupid:

DevilsCamp 29. Jan 2006 15:28

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
Zitat:

Zitat von SirThornberry
Und der Hinweis mit dem C-Build war darauf bezogen das dann auch die Forms enthalten sind.

Genau. Wenigstens einer hat verstanden, was ich meinte

ErazerZ 30. Jan 2006 00:47

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
hey,
ich hab da was heute gemacht, ich habs getestet mit ein paar delphi programmen und es scheint zu funktionieren, es ist ähnlich wie peid, prüft werte nach dem EntryPoint der datei und vergleicht sie mit fertigen signaturen, natürlich kann ich net versprechen das es immer funktioniert, jedoch hats hier mit Delphi6 + Delphi7 funktioniert, einwandfrei

Delphi-Quellcode:
const
  // 0 ist sozusagen der Joker, wenn man nicht weiß was für ein byte dannach folgt ..
  DelphiBorland: Array[0..5] of Byte = (
    $55, $8B, $EC, $83, $C4, $F4);

  BorlandDelphiComponent: Array[0..7] of Byte = (
    $C3, $E9, 0, 0, 0, $FF, $8D, $40);

  BorlandDelphiDLL: Array[0..22] of Byte = (
    $55, $8B, $EC, $83, $C4, $B4, $B8, 0, 0, 0
    , 0, $E8, 0, 0, 0, 0, $E8, 0, 0, 0
    , 0, $8D, $40);

  BorlandDelphi3: Array[0..40] of Byte = (
    $50, $6A, 0, $E8, 0, 0, $FF, $FF, $BA, 0
    , 0, 0, 0, $52, $89, $05, 0, 0, 0, 0
    , $89, $42, $04, $E8, 0, 0, 0, 0, $5A, $58
    , $E8, 0, 0, 0, 0, $C3, $55, $8B, $EC, $33
    , $C0);

  BorlandDelphi3_2: Array[0..176] of Byte = (
    $55, $8B, $EC, $83, $C4, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, $00);

  BorlandDelphi4_5: Array[0..49] of Byte = (
    $50, $6A, 0, $E8, 0, 0, $FF, $FF, $BA, 0
    , 0, 0, 0, $52, $89, $05, 0, 0, 0, 0
    , $89, $42, $04, $C7, $42, $08, 0, 0, 0, 0
    , $C7, $42, $0C, 0, 0, 0, 0, $E8, 0, 0
    , 0, 0, $5A, $58, $E8, 0, 0, 0, 0, $C3);

  BorlandDelphi4_5_2: Array[0..176] of Byte = (
    $55, $8B, $EC, $83, $C4, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, $20);

  BorlandDelphi4_5_3: Array[0..49] of Byte = (
    $50, $6A, $00, $E8, 0, 0, $FF, $FF, $BA, 0
    , 0, 0, 0, $52, $89, $05, 0, 0, 0, 0
    , $89, $42, $04, $C7, $42, $08, $00, $00, $00, $00
    , $C7, $42, $0C, $00, $00, $00, $00, $E8, 0, 0
    , 0, 0, $5A, $58, $E8, 0, 0, 0, 0, $C3);

  BorlandDelphi5_KOL: Array[0..38] of Byte = (
    $55, $8B, $EC, $83, $C4, $F0, $B8, 0, 0, $40
    , $00, $E8, 0, 0, $FF, $FF, $E8, 0, 0, $FF
    , $FF, $E8, 0, 0, $FF, $FF, $8B, $C0, $00, $00
    , $00, $00, $00, $00, $00, $00, $00, $00, $00);

  BorlandDelphi6_KOL: Array[0..47] of Byte = (
    $55, $8B, $EC, $83, $C4, $F0, $B8, 0, 0, $40
    , $00, $E8, 0, 0, $FF, $FF, $A1, 0, $72, $40
    , $00, $33, $D2, $E8, 0, 0, $FF, $FF, $A1, 0
    , $72, $40, $00, $8B, $00, $83, $C0, $14, $E8, 0
    , 0, $FF, $FF, $E8, 0, 0, $FF, $FF);

  DelphiBorland6_7: Array[0..87] of Byte = (
    $55, $8B, $EC, 0, $C4, 0, 0, 0, 0, 0     // 4ter wert geändert ..
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, $00, $00
    , $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
    , $00, $00, $00, $00, $00, $00, $00, $00);

  DelphiBorland6_7_2: Array[0..46] of Byte = (
    $53, $8B, $D8, $33, $C0, $A3, $00, 0, 0, 0
    , $06, $A0, $0E, $80, 0, 0, $0F, $FA, $30, 0
    , 0, 0, $0A, $10, 0, 0, 0, $0A, $30, 0
    , 0, 0, $03, $3C, $0A, $30, 0, 0, 0, $03
    , $3C, $0A, $30, 0, 0, 0, $E8);

  DelphiBorland6_7_3: Array[0..70] of Byte = (
    $55, $8B, $EC, $83, $C4, $F0, $B8, 0, 0, 0
    , 0, $E8, 0, 0, $FB, $FF, $A1, 0, 0, 0
    , 0, $8B, 0, $E8, 0, 0, $FF, $FF, $8B, $0D
    , 0, 0, 0, 0, $A1, 0, 0, 0, 0, $8B
    , $00, $8B, $15, 0, 0, 0, 0, $E8, 0, 0
    , $FF, $FF, $A1, 0, 0, 0, 0, $8B, 0, $E8
    , 0, 0, $FF, $FF, $E8, 0, 0, $FB, $FF, $8D
    , $40);

  DelphiBorland6_7_4: Array[0..31] of Byte = (
    $BA, 0, 0, 0, 0, $83, $7D, $0C, $01, $75
    , 0, $50, $52, $C6, $05, 0, 0, 0, 0, 0
    , $8B, $4D, $08, $89, $0D, 0, 0, 0, 0, $89
    , $4A, $04);

  DelphiBorland6: Array[0..29] of Byte = (
    $55, $8B, $EC, $83, $C4, $F0, $B8, 0, 0, $45
    , $00, $E8, 0, 0, 0, $FF, $A1, 0, 0, $45
    , $00, $8B, $00, $E8, 0, 0, $FF, $FF, $8B, $0D);

  DelphiBorland6_2: Array[0..46] of Byte = (
    $53, $8B, $D8, $33, $C0, $A3, 0, 0, 0, 0
    , $6A, $00, $E8, 0, 0, 0, $FF, $A3, 0, 0
    , 0, 0, $A1, 0, 0, 0, 0, $A3, 0, 0
    , 0, 0, $33, $C0, $A3, 0, 0, 0, 0, $33
    , $C0, $A3, 0, 0, 0, 0, $E8);

  DelphiBorland2: Array[0..44] of Byte = (
    $E8, 0, 0, 0, 0, $6A, 0, $E8, 0, 0
    , 0, 0, $89, $05, 0, 0, 0, 0, $E8, 0
    , 0, 0, 0, $89, $05, 0, 0, 0, 0, $C7
    , $05, 0, 0, 0, 0, $0A, 0, 0, 0, $B8
    , 0, 0, 0, 0, $C3);

function GetFieldOffset(const Struct; const Field): Cardinal;
begin
  Result := Cardinal(@Field) - Cardinal(@Struct);
end;

function GetImageFirstSection(NTHeader: PImageNtHeaders): PImageSectionHeader;
begin
  Result := PImageSectionHeader(Cardinal(NTHeader) + GetFieldOffset(NTHeader^, NTHeader^.OptionalHeader) + NTHeader^.FileHeader.SizeOfOptionalHeader);
end;

function CompareBytes(FirstBytes: Array of Byte; Signature: Array of Byte): Boolean;
var
  i: Integer;
  b: Boolean;
begin
  b := False;
  for i := 0 to sizeof(FirstBytes) -1 do
  begin
    if i >= sizeof(Signature) then
      break;
    if Signature[i] <> Byte(0) then
    begin
      if (FirstBytes[i] = Signature[i]) then
        b := True
      else
      begin
        b := False;
        break;
      end;
    end else
      continue;
  end;
  Result := b;
end;

function IsDelphiApplication(FileName: String): Boolean;
var
  b: Boolean;
  lpData: Pointer;
  i: Integer;
  hFile: THandle;
  DosHeader: PImageDosHeader;
  NtHeader: PImageNtHeaders;
  SectionHeader: PImageSectionHeader;
  dwReadBytes, dwFileSize, dwEP, dwFileEP: DWORD;
  FirstBytes: Array[0..200] of Byte;
begin
  Result := False;
  dwFileEP := 0;
  hFile := CreateFile(PChar(FileName), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, 0, 0);
  if hFile <> 0 then
  begin
    dwFileSize := GetFileSize(hFile, nil);
    lpData := GetMemory(dwFileSize);
    ReadFile(hFile, lpData^, dwFileSize, dwReadBytes, nil);
    if dwReadBytes = dwFileSize then
    begin
      DosHeader := lpData;
      if DosHeader.e_magic = IMAGE_DOS_SIGNATURE then
      begin
        NTHeader := Pointer(Integer(lpData) + DosHeader._lfanew);
        if NTHeader.Signature = IMAGE_NT_SIGNATURE then
        begin
          dwEP := StrToInt(FloatToStr(NtHeader.OptionalHeader.AddressOfEntryPoint));
          SectionHeader := GetImageFirstSection(NtHeader);
          for i := 0 to NTHeader.FileHeader.NumberOfSections -1 do
          begin
            if (dwEP >= SectionHeader.VirtualAddress) and (dwEP <= SectionHeader.VirtualAddress + SectionHeader.SizeOfRawData) then
            begin
              dwFileEP := dwEP - SectionHeader.VirtualAddress + SectionHeader.PointerToRawData;
            end;
            SectionHeader := Pointer(DWORD(SectionHeader) + sizeof(TImageSectionHeader));
          end;
        end;
        if dwFileEP <> 0 then
        begin
          SetFilePointer(hFile, dwFileEP, nil, FILE_BEGIN);
          ReadFile(hFile, FirstBytes, sizeof(FirstBytes), dwReadBytes, nil);
         
          b := CompareBytes(FirstBytes, DelphiBorland);
          if not b then
            b := CompareBytes(FirstBytes, BorlandDelphiComponent);
          if not b then
            b := CompareBytes(FirstBytes, BorlandDelphiDLL);
          if not b then
            b := CompareBytes(FirstBytes, BorlandDelphi3);
          if not b then
            b := CompareBytes(FirstBytes, BorlandDelphi3_2);
          if not b then
            b := CompareBytes(FirstBytes, BorlandDelphi4_5);
          if not b then
            b := CompareBytes(FirstBytes, BorlandDelphi4_5_2);
          if not b then
            b := CompareBytes(FirstBytes, BorlandDelphi4_5_3);
          if not b then
            b := CompareBytes(FirstBytes, BorlandDelphi5_KOL);
          if not b then
            b := CompareBytes(FirstBytes, BorlandDelphi6_KOL);
          if not b then
            b := CompareBytes(FirstBytes, DelphiBorland6_7);
          if not b then
            b := CompareBytes(FirstBytes, DelphiBorland6_7_2);
          if not b then
            b := CompareBytes(FirstBytes, DelphiBorland6_7_3);
          if not b then
            b := CompareBytes(FirstBytes, DelphiBorland6_7_4);
          if not b then
            b := CompareBytes(FirstBytes, DelphiBorland6);
          if not b then
            b := CompareBytes(FirstBytes, DelphiBorland6_2);
          if not b then
            b := CompareBytes(FirstBytes, DelphiBorland2);

          CloseHandle(hFile);
          Result := b;
        end else
          CloseHandle(hFile);
      end else
        CloseHandle(hFile);
    end else
      CloseHandle(hFile);
  end else
    CloseHandle(hFile);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
    if IsDelphiApplication(OpenDialog1.FileName) then
      ShowMessage('delphi programm')
    else
      ShowMessage('kein delphi programm');
end;
naja, ich geh mal pennen, ich schau noch ob ich es irgendwie verbessern kann

ps: die signaturen sind nicht von mir, sondern von netz irgendwo her (glaub war für peid, weiß net mehr genau)

cya, ErazerZ

DevilsCamp 30. Jan 2006 06:59

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
Bedeutet BorlandDelphi3_2, dass es die Signatur für Delphi 3 sein soll?

Garfield 30. Jan 2006 08:29

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
Zitat:

Zitat von DevilsCamp
Bedeutet BorlandDelphi3_2, dass es die Signatur für Delphi 3 sein soll?

Das dürfte das Update auf Delphi 3.2 sein.

DevilsCamp 30. Jan 2006 08:30

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
Interessant, dass mind. eins meiner Delphi 7 Anwendungen schon dort reagiert :D

Garfield 30. Jan 2006 09:24

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
Vielleicht ist DeDe von Interesse. Ist ein SDK dabei.

http://www.softpedia.com/get/Program...ers/DeDe.shtml

ErazerZ 30. Jan 2006 11:30

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
BorlandDelphi3_2 ist eine 2te variante des entrypoints, sind nicht immer alle gleich (anscheinend) wenn man zb. console anwendung und vcl vergleicht, bei delphi6 bis delphi7 gibt es 4 varianten, aber ich habs einfach nur übersetzt von anderen signaturen :D

Garfield 30. Jan 2006 12:04

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
Zitat:

Zitat von ErazerZ
BorlandDelphi3_2 ist eine 2te variante des entrypoints,

Dachte nur, das es passt, weil meine TestEXE mit Delphi 3.2 kompliliert war.

Zitat:

Zitat von ErazerZ
... sind nicht immer alle gleich (anscheinend) ...

Ein System sollte aber drin sein. :?

Ruediw 31. Jan 2006 21:56

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
Schau mal hier:
<Zitat von der webseite>
Freeware tool for application investigation



DAP Lite is a feature limited version of DAP Pro. It is absolutely freeware and can be used for getting general information on components in your applications: a class name, a parent, etc. You can distribute DAP Lite with your applications for your beta-testers. Using DAP Lite they will be able to send you more accurate and informative reports!

You can look at DAP Pro and DAP Lite screenshots to get more details on how to use these tools.
<Ende Zitat>

URL : http://www.devrace.com/en/dap/

http://www.devrace.com/en/dap/download/31-.php
DAP Lite 1.3 DAP Lite for Delphi 2-7, C++ Builder 1-6

Patrick 4. Feb 2006 11:28

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
Der Code von ErazerZ funktioniert gut, aber ein Problem habe ich noch: Er erkennt "Delphi 2005" auch als Delphi-Compiliertes Programm. Das soll er nicht. Wie kann ich die Delphi-Entwicklungsumgebung selbst ausschließen (für alle Versionen)?

Garfield 4. Feb 2006 18:37

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
Du kannst Dir ja das DeDe SDK ansehen. Da stand eine Variable wie Delphi_VersionString oder ähnlich drin.

XHelp 5. Feb 2006 21:33

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
Also bis jetzt habe ich einfach in der exe nach TApplication gesucht... ist eigentlich ein zeichen dafür, dass es mit delphi programmiert ist...

ErazerZ 5. Feb 2006 21:44

Re: Herausfinden ob Prozess/Anwendung mit Delphi compiliert
 
Zitat:

Zitat von XHelp
Also bis jetzt habe ich einfach in der exe nach TApplication gesucht... ist eigentlich ein zeichen dafür, dass es mit delphi programmiert ist...

nicht bei nonVCL programmen, und delphi2005 (den compiler selbst) kannst damit ausschließen das du vielleicht nach dem company namen prüfst oder so, aber ist auch net so sicher


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:08 Uhr.

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