Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Dateisystem-Hooks (https://www.delphipraxis.net/99432-dateisystem-hooks.html)

PeterPanino 12. Sep 2007 01:37


Dateisystem-Hooks
 
Hallo, ich bin auf der Suche nach einer Möglichkeit, Dateisystem-Hooks zu installieren, um bei der Änderung/Erzeugung/Löschung von beliebigen Dateien im Dateisystem benachrichtigt zu werden.

Hier habe ich etwas gefunden, das aber in C geschrieben ist:

Another example of file system hooks (CLIB)

Wer weiß, wie man das nach Delphi Win32 übersetzen könnte?

hoika 12. Sep 2007 06:29

Re: Dateisystem-Hooks
 
Hallo,

dir ist schon klar, dass es in Deinem Bsp hier um Novell-Netware geht ?

Was du brauchst, ist ein sogenannter Filter-Treiber fürs Dateiystem.
Ob du allerdings in Delphi dafür Bsp-e findest,
glaube ich nicht.

Warum reciht das normale Notification für bestimmte Verzeichnisse nicht ?


Heiko
PS:
Genauso einen Treiber hatte damals Sony bei Ihrem Rootkit benutzt.
Naja, und Virenscanner benutzen sowas auch.

Mordilion 12. Sep 2007 08:23

Re: Dateisystem-Hooks
 
Also mir ist eigentlich bekannt, dass es auch ohne Treiber geht.

Du musst nur herausfinden wie du die Windows-API-Funktionen Hookst. Also müsstest du alle CreateFile-API-Funktionen, etc. hooken und dann sollte es gehen.

Hatte mal vor ewigkeiten das selbe Prinzip für den Netzwerkverkehr gemacht. Habe allerdings den Source nicht mehr.


Gruß
Mordi

Nuclear-Ping 12. Sep 2007 10:25

Re: Dateisystem-Hooks
 
Liste der Anhänge anzeigen (Anzahl: 1)
Vielleicht hilft dir das weiter: http://assarbad.net/en/stuff/tutorials/hooks/

JediVCL hat auch ein paar Hook-Units dabei (JvShellHook, JvWinHook, ...).

Im Anhang hab ich dir mal 'ne Unit dran gehangen, die ich vor Jahren mal im Netz irgendwo gefunden hab. Ich glaub das war von irgendeinem Hook-Tutorial von Assarbad oder so (kann mich auch grad täuschen).
Hab damit mal rumgespielt und mal angeguckt. Entsprechend sieht sie auch aus, hoffe sie compiled noch durch. :D Naja, zum Prinzip verstehen sollte es reichen.

PeterPanino 12. Sep 2007 15:19

Re: Dateisystem-Hooks
 
Zitat:

Zitat von hoika
Warum reciht das normale Notification für bestimmte Verzeichnisse nicht ?

Weil dies nicht den Namen der betreffenden Datei zurückgibt.

suni 8. Okt 2007 06:23

Re: Dateisystem-Hooks
 
Liste der Anhänge anzeigen (Anzahl: 1)
Ist eine Gute idee das Projekt. Ich habe vor langer Zeit mal eine Komponente gefunden die sich TWatch nennt ,mit hilfe dieser Komponente ist es möglich das System auf Änderungen überwachen zu lassen :)
Ich hab dir mal eine RAR erstellt die du im Anhang findest...
Hoffe ich konnte mit meinem Beitrag hier im Forum auch mal etwas Helfen bzw ein Problem lösen...

Mfg
Sunni

Hier mal eine genauere Beschreibung der Komponente
Code:
The TWatch Component V1.10

I am very interested in any application
that uses this component (or any other application you wrote).
If so, mail me (not the program, just an URL or similar) !
(mail address below)

Installation:
=============
1. Copy the files Watch.pas and watch.dcr to the directory where
you store your components (or let it where it is)
2. In Delphi, select Component|Install Component. In the
following dialog enter the path and filename of
Watch.pas and hit OK.
3. Now the TWatch Component is available in the
Component palette under Bome.
4. Load watchdll.dpr into Delphi and compile it. It creates
the dll "watchdll.dll".
5. This library must be in the search path or in the directory of
the program in which you want to use TWatch. The dll is loaded
and unloaded dynamically when needed, in order to prevent Delphi
to load it when installing the component.

Description
===========
This component enables you to track some system events.
Currently implemented are Shell events (i.e. Activation,
Creation, Closure of Applications), and Keyboard events
(when something is typed in another application) and
Mouse events (everything what the mouse does).

The shell events have one drawback: The name parameter is
identical for all instances of a watched program. You
can only use the Handle parameter of the event to distinguish
different instances of the same application.

This component is designed for Delphi 2, 3, 4. It is not tested
with Delphi 5.

Note: the source for watchdll.dll is in the project watchdll.dpr.

How to use it
=============
Be sure that only one instance/program uses this component
at any time. You can use TOneInstance for that instance,
you can download that from [url]http://www.bome.com/[/url] in the
delphi components area.

Different to previous versions of this component, you
must now call the Start and Stop methods in order to
start / stop watching of a specific type.

Your main program MUST make sure that this component is
freed properly. The easiest way of doing this is to put a
line like "Watch1.Free;" in the main forms OnClose or OnDestroy
event handler. Delphi seems to "forget" to free components'
when closing the application.

Properties:
- NotifyOwnEvents: Whether an event shall be sent when
the own application receives a shell event
- RepeatedEvents: When you activate different windows
of the same application, each time an
event is sent. If you set this to false,
only the first event will be sent.

Events:
- OnActivateShellWindow: Occurs when the shell window is activated
(i.e. the desktop)
- OnWindowActivated: Occurs when any program is activated
- OnWindowCreated: Occurs when a program starts
- OnWindowDestroyed: Occurs when a program closes
- OnKeyNative: A raw key event, occurs everytime something with the
keyboard happens.
- OnMouseDown: Occurs when a mouse button is pressed
- OnMouseMove: Occurs when the mouse moves
- OnMouseUp: Occurs when a mouse button is released

Note on Mouse events:
Even if they contain the ShiftState, the Shift and Ctrl values will
never be set, regardless whether these keys are actually pressed
or not. You could combine it with a key hook to generate the "right"
mouse events.

ideas for enhancements:
- make it usable for multiple applications...
- of course, add the other hooks
- use toAscii in order to get an Ascii-Character of a key
- let the dll get some information about the window
in which are typed the keys
- possibility to change messages before they are processed by the
watched application
- let the dll change specific things while in context
of another program e.g. add to every menu an own menu...
or just get some information about that program

Copyright
=========
(c) 1997-2000 by Florian Bömers

send any comments, proposals, enhancements etc. to:
[email]delphi@bome.com[/email]


new versions on:
[url]http://www.bome.com/[/url]

sk0r 8. Okt 2007 07:48

Re: Dateisystem-Hooks
 
Ich glaube das geht, indem du im explorer folgende APIs hookst:

ZwCreateFile
ZwOpenFile
ZwQueryDirectoryFile


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:29 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