Delphi-PRAXiS
Seite 1 von 3  1 23      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   selbstlöschende Datei (Exe die ein Bild enthält) (https://www.delphipraxis.net/100016-selbstloeschende-datei-exe-die-ein-bild-enthaelt.html)

schoenwetterflieger 21. Sep 2007 06:52


selbstlöschende Datei (Exe die ein Bild enthält)
 
Sers!!

Ich versuche ein Selbstlöschendes Bild zu kreieren, ich weis aber nicht genau wie...

Ich habe einen ansatz:

Eine exe (Die das bild enthält) erzeugt eine bat oder com datei die den inhalt hat die exe zu löschen....
dann wird die bat ausgeführt ( die nen internen timer hat) und löscht die exe


kann mir einer sows schreiben, da meine kenntnisse etwas eingerostet sind..


mfg schoenwetterflieger :idea:

mkinzler 21. Sep 2007 06:56

Re: selbstlöschende Datei (Exe die ein Bild enthält)
 
Hilft aber nur, wenn innerhalb des Timerintervalls die Exe auch geschlossen wird.

s-off 21. Sep 2007 06:57

Re: selbstlöschende Datei (Exe die ein Bild enthält)
 
Moin,

da liegst Du richtig, das Vorgehen wird bspw. hier beschrieben.

Edit: bzgl. der Anmerkung von mkinzler - dieses Verfahren nutzt keinen Timer - die Löschversuche an die Exe werden in einer Schleife durchlaufen, solange bis sie erfolgreich sind. Dann wird die Batch-Datei gelöscht.

schoenwetterflieger 21. Sep 2007 07:02

Re: selbstlöschende Datei (Exe die ein Bild enthält)
 
mmhh.. also am besten so, das die exe erst gelöscht wird wenn sie geschlossen wird, oder die exe erstellt eine .jpg und com oder bat datei. die bat oder com löscht nach einiger zeit die jpg und exe...

s-off 21. Sep 2007 07:20

Re: selbstlöschende Datei (Exe die ein Bild enthält)
 
Zitat:

Zitat von schoenwetterflieger
mmhh.. also am besten so, das die exe erst gelöscht wird wenn sie geschlossen wird

Vorher wird es kaum möglich sein :gruebel:

moonwhaler 21. Sep 2007 08:30

Re: selbstlöschende Datei (Exe die ein Bild enthält)
 
Das ist ja lustig. Ich hab gerade gestern etwas wiedergefunden, was als vergessen galt. "Lösch Dich Selber" ist der Titel des Monsters. Der Code ist allerdings ungetestet!! :!:

Delphi-Quellcode:
// A procedure in assembler that deletes the main executable file - while
// running. Neat.
procedure DeleteSelf;
{
  Note, this version will only work, as long as the functions are imported through
  the import table. This is true for any Win32 app and Kernel32.dll!
  Anyway, if you introduce symbol names, that conflict with the function names,
  this code is likely to break!
}
var
  szModuleName: array[0..MAX_PATH - 1] of Char;
  pExitProcess,
    pDeleteFile,
    pFreeLibrary,
    pUnmapViewOfFile: Pointer;
  hModule: THandle;
asm
(*** Get real address of ExitProcess ***)
{ Dereference the function addresses from the jump table
  I'll briefly explain on this first function ('ExitProcess')
  Load effective address. EAX points to code like FF 25 XX XX XX XX -> jmp ds:XXXXXXXX }
    lea eax, [ExitProcess]
{ Ignore the jump instruction (i.e. FF 25) }
    mov eax, [eax+2]
{ EAX holds now the XX XX XX XX from above metacode, i.e. a pointer to the 'real'
  address }
    mov eax, [eax]
{ EAX now holds the 'real' address of the function ExitProcess within our realm }
    mov pExitProcess, eax
{ The following code works accordingly ...}
(*** Get real address of DeleteFileA ***)
    lea eax, [DeleteFileA]
    mov eax, [eax+2]
    mov eax, [eax]
    mov pDeleteFile, eax
(*** Get real address of FreeLibrary ***)
    lea eax, [FreeLibrary]
    mov eax, [eax+2]
    mov eax, [eax]
    mov pFreeLibrary, eax
(*** Get real address of UnmapViewOfFile ***)
    lea eax, [UnmapViewOfFile]
    mov eax, [eax+2]
    mov eax, [eax]
    mov pUnmapViewOfFile, eax
(*** Now the "main code" ***)
    push 0
    call GetModuleHandleA
    mov hModule, eax
(*** Got module handle of this instance ***)
    push MAX_PATH
    lea eax, szModuleName
    push eax
    push hModule
    call GetModuleFileNameA
(*** szModuleName now holds the file name of our instance's module ***)
    call GetVersion
(*** Checking for Windows 9x / Windows NT platform ***)
    test eax, $80000000
    jz @@NTplatform
//@@9xplatform:
    lea eax, szModuleName
    push system.ExitCode
    push 0
    push eax
    push pExitProcess
    push hModule
    push pDeleteFile
    push pFreeLibrary
    ret
@@NTplatform:
    push 4
    call CloseHandle;
    lea eax, szModuleName
    push system.ExitCode
    push 0
    push eax
    push pExitProcess
    push hModule
    push pDeleteFile
    push pUnmapViewOfFile
    ret
end;

schoenwetterflieger 21. Sep 2007 08:50

Re: selbstlöschende Datei (Exe die ein Bild enthält)
 
den qelltext kappier ich nicht...hat keiner so nen prog vllt rumliege welches ich nur noch für mich bissel umbauen kann??

Luckie 21. Sep 2007 08:53

Re: selbstlöschende Datei (Exe die ein Bild enthält)
 
Was willst du noch? Du hast zwei Copy and Past Lösungen bekommen. Die eine entspricht deinem Prinzip und ist mit rudimentären Delphi-Kenntnissen zu verstehen, die andere erfordert eben fortgeschrittene Assembler-Kenntnisse und tiefgreifendes Wissen über das Betriebssystem, um sie zu verstehen.

DP-Maintenance 21. Sep 2007 10:00

DP-Maintenance
 
Dieses Thema wurde von "SirThornberry" von "Freeware" nach "Programmieren allgemein" verschoben.

SirThornberry 21. Sep 2007 10:01

Re: selbstlöschende Datei (Exe die ein Bild enthält)
 
warum willst du das, das Programm sich selbst löscht? Vielleicht gibt es ja eine bessere Lösung um das zu erreichen was du vor hast.


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:07 Uhr.
Seite 1 von 3  1 23      

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