在线看毛片视频-国产免费av在线-欧美日韩一区二区三区-国产成人无码av在线播放无广告-亚洲人va欧美va人人爽-国产第一草草-西班牙黄色片-四虎在线网站8848-最新av片免费网站入口-东京热无码中文字幕av专区-日本大人吃奶视频xxxx-欧美精品一区二区三区四区五区-国产片天天弄-国产免费内射又粗又爽密桃视频-欧美爱爱网站-日韩v欧美

當前位置:雨林木風下載站 > 技術開發教程 > 詳細頁面

實時偵測目錄中文件變化

實時偵測目錄中文件變化

更新時間:2022-05-16 文章作者:未知 信息來源:網絡 閱讀次數:

在WIN32下用DELPHI偵測目錄變化,可用WIN32提供的文件改變通知API來完成。FindFirstChangeNotification, FindNextChangeNotification,FindCloseChangeNotification。
在應用程序中調用這些函數時,產生一個監控這個變化的句柄,可用WAIT函數集來等待這個變化。這樣,當監控程序運行時,可以達到監控文件變化的動作。更進一步,可把此程序做成一個狀態區圖標(TRAY)來完成監控。

Windows在刪除、復制、移動、訪問文件時并不發送消息,當然截獲不到。要截取這些操作過程的唯一辦法就是截獲API,這又需要你編寫Vxd程序了,殺毒軟件都是這樣作的。你注意一下殺毒軟件一般都帶有一個vxd程序。光有vxd還不行,還需截獲文件API。還有另外一個辦法,就是CIH病毒采用的辦法,直接跳到系統零層去操作。具體辦法如下:
一、SIDT指令( 將中斷描述符表寄存器IDTR--64位寬,16~47Bit存有中斷描述符表IDT基地址--的內容存入指定地址單元)不是特權指令,就是說我們可以在Ring3下執行該指令,獲得IDT的基地址,從而修改IDT,增加一個中斷門安置我們的中斷服務,一旦Ring3程序中產生此中斷,VMM就會調用此中斷服務程序,而此中斷服務程序就運行在Ring0下了。這一點與在DOS下非常相似。

二、要實現對系統中所有文件I/O操作的實時監視,還要用到另一種關鍵技-FileHooking,通過掛接一個處理函數,截獲所有與文件I/O操作有關的系 統調用。Windows9x使用32位保護模式可安裝文件系統(IFS),由可安裝文件系統管理器(IFSManager)協調對文件系統和設備的訪問,它接收以Win32API函數調用形式向系統發出的文件I/O請求,再將請求轉給文件系統驅動程序FSD,由它調用低級別的IOS系統實現最終訪問。每個文件I/OAPI調用都有一個特定的FSD函數與之對應,IFSManager負責完成由API到FSD的參數裝配工作,在完成文件I/OAPI函數參數的裝配之后轉相應FSD執行之前,它會調用一個稱為FileSystemApiHookFunction的Hooker函數。通過安裝自己的Hooker函數,就可以截獲系統內所有對文件I/O的API調用,從而實現實時監控。
=========================================
procedure TForm1.Button2Click(Sender: TObject);
begin
  {establish a notification for file name changes on the selected directory}
  NotificationHandle := FindFirstChangeNotification(PChar(DirectoryListBox1.Directory), FALSE,FILE_NOTIFY_CHANGE_FILE_NAME);
  {if the notification was set up correctly, modify some UI elements...}
  if (NotificationHandle <> INVALID_HANDLE_VALUE) then
  begin
    Button1.Enabled := TRUE;
    Button2.Enabled := FALSE;
  end
  else
  begin
    {...otherwise indicate that there was an error}
    ShowMessage('There was an error setting the notification');
    Exit;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  dwResult: DWORD;         // holds the result of waiting on the notification
  Waiting: Boolean;        // loop control variable
begin
  {setup the loop control for a continuous loop}
  Waiting := TRUE;
  {indicate that the application is waiting for the change notification to fire}
  Button1.Enabled := FALSE;
  StatusBar1.SimpleText := 'Now waiting for a filename change';
  Application.ProcessMessages;
  {enter the loop}
  while Waiting do
  begin
    {at this point, the application is suspended until the notification
     object is signaled that a filename change has occured in the
     selected directory (this includes file deletions)}
    dwResult := WaitForSingleObject(NotificationHandle,INFINITE);
    if (dwResult = WAIT_OBJECT_0) then

    begin
      {indicate that the notification object was signaled}
      ShowMessage('The selected directory signaled a filename change');

      {query the user to see if they wish to continue monitoring this
       directory}
      if Application.MessageBox('Do you wish to continue monitoring this directory?', 'Continue?', MB_ICONQUESTION or
                                MB_YESNO) = IDYES then

        {if the user wishes to continue monitoring the directory, reset
         the notification object and continue the loop...}
        FindNextChangeNotification(NotificationHandle)
      else
        {...otherwise break out of the loop}
        Waiting := FALSE;
    end;
  end;

  {close the notification object}
  FindCloseChangeNotification(NotificationHandle);

  {reset UI elements}

  Button1.Enabled := FALSE;
  Button2.Enabled := TRUE;
  StatusBar1.SimpleText := '';
  FileListBox1.Update;
end;
===========================================
下面是一個監視的控件:
unit dirnotify;

interface

uses
  Windows, Messages, SysUtils, Classes,
  Graphics, Controls, Forms, Dialogs;

type
  EDirNotificationError = class(Exception);

  TDirNotify = class;
  TNotifyFilter = (nfFileName, nfDirName, nfAttributes, nfSize, nfLastWrite,
    nfSecurity);
  TNotifyFilters = set of TNotifyFilter;

  TNotificationThread = class(TThread)
    Owner: TDirNotify;
    procedure Execute; override;
    procedure DoChange;
  end;

  TDirNotify = class(TComponent)
  private
    FEnabled: Boolean;
    FOnChange: TNotifyEvent;
    FNotificationThread: TNotificationThread;
    FPath: String;
    FWatchSubTree: Boolean;
    FFilter: TNotifyFilters;

    procedure SetEnabled( Value: Boolean );
    procedure SetOnChange( Value: TNotifyEvent );
    procedure SetPath( Value: String );
    procedure SetWatchSubTree( Value: Boolean );
    procedure SetFilter( Value: TNotifyFilters );

    procedure RecreateThread;

  protected
    procedure Change;
    procedure Loaded; override;

  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;

  published
    property Enabled: Boolean read FEnabled write SetEnabled default True;
    property OnChange: TNotifyEvent read FOnChange write SetOnChange;
    property Path: String read FPath write SetPath;
    property WatchSubTree: Boolean read FWatchSubTree write SetWatchSubTree;
    property Filter: TNotifyFilters read FFilter write SetFilter default [nfFileName, nfDirName, nfAttributes, nfLastWrite, nfSecurity];
  end;


procedure Register;

implementation

const
  LASTERRORTEXTLENGTH = 500;

var
  LastErrorText: array [0..LASTERRORTEXTLENGTH] of char;


function GetLastErrorText: PChar;
begin
  FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM,
    nil, GetLastError, 0, LastErrorText, LASTERRORTEXTLENGTH, nil );
  Result := LastErrorText;
end;


procedure TNotificationThread.Execute;
var
  h: THandle;
  nf: Longint;
  wst: LongBool;
begin
  nf := 0;
  if (nfFileName in Owner.Filter) then nf := FILE_NOTIFY_CHANGE_FILE_NAME;
  if (nfDirName in Owner.Filter) then nf := nf or FILE_NOTIFY_CHANGE_DIR_NAME;
  if (nfAttributes in Owner.Filter) then nf := nf or FILE_NOTIFY_CHANGE_ATTRIBUTES;
  if (nfSize in Owner.Filter) then nf := nf or FILE_NOTIFY_CHANGE_SIZE;
  if (nfLastWrite in Owner.Filter) then nf := nf or FILE_NOTIFY_CHANGE_LAST_WRITE;
  if (nfSecurity in Owner.Filter) then nf := nf or FILE_NOTIFY_CHANGE_SECURITY;

  // yeahh, this one is stupid but Win98 malfunctions in any other value than 0 or 1
  if Owner.FWatchSubTree then wst := Longbool(1)
  else wst := Longbool(0);

  h := FindFirstChangeNotification( Pointer(Owner.Path), wst, nf );
  if (h = INVALID_HANDLE_VALUE) then
    raise EDirNotificationError.Create( GetLastErrorText );

  repeat
    if (WaitForSingleObject( h, 1000 ) = WAIT_OBJECT_0) then
    begin
      Synchronize(DoChange);

      if not FindNextChangeNotification( h ) then
        raise EDirNotificationError.Create( GetLastErrorText );
    end;
  until Terminated;
end;


procedure TNotificationThread.DoChange;
begin
   Owner.Change;
end;


constructor TDirNotify.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);

  FEnabled := True;
  FFilter := [nfFileName];
end;


destructor TDirNotify.Destroy;
begin
  FNotificationThread.Free;
  inherited Destroy;
end;

procedure TDirNotify.Loaded;
begin
  inherited;

  RecreateThread;
end;


procedure TDirNotify.SetEnabled(Value: Boolean);
begin
  if Value <> FEnabled then
  begin
    FEnabled := Value;

    RecreateThread;
  end;
end;


procedure TDirNotify.SetPath( Value: String );
begin
  if Value <> FPath then
  begin
    FPath := Value;
    RecreateThread;
  end;
end;


procedure TDirNotify.SetWatchSubTree( Value: Boolean );
begin
  if Value <> FWatchSubTree then
  begin
    FWatchSubTree := Value;
    RecreateThread;
  end;
end;


procedure TDirNotify.SetFilter( Value: TNotifyFilters );
begin
  if Value <> FFilter then
  begin
    FFilter := Value;
    RecreateThread;
  end;
end;


procedure TDirNotify.SetOnChange(Value: TNotifyEvent);
begin
   FOnChange := Value;
end;


procedure TDirNotify.Change;
begin
   if Assigned(FOnChange) then
      FOnChange(Self);
end;


procedure TDirNotify.RecreateThread;
begin
  // destroy thread
  FNotificationThread.Free;
  FNotificationThread := nil;

  if FEnabled and not(csDesigning in ComponentState)
    and not(csLoading in ComponentState) and (FPath <> '') then
  begin
    // create thread
    FNotificationThread := TNotificationThread.Create(True);
    FNotificationThread.Owner := self;
    FNotificationThread.Resume;
  end;
end;


procedure Register;
begin
   RegisterComponents('System', [TDirNotify]);
end;

end. 

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

在线看毛片视频-国产免费av在线-欧美日韩一区二区三区-国产成人无码av在线播放无广告-亚洲人va欧美va人人爽-国产第一草草-西班牙黄色片-四虎在线网站8848-最新av片免费网站入口-东京热无码中文字幕av专区-日本大人吃奶视频xxxx-欧美精品一区二区三区四区五区-国产片天天弄-国产免费内射又粗又爽密桃视频-欧美爱爱网站-日韩v欧美
  • <li id="86scu"><menu id="86scu"></menu></li>
    <li id="86scu"></li>
    <button id="86scu"></button>
  • <s id="86scu"></s><button id="86scu"><menu id="86scu"></menu></button>
  • 波多野结衣之无限发射| 欧美激情国产精品日韩| 最新天堂中文在线| 成年人在线观看视频免费| 男人添女人下部高潮视频在观看| 在线观看av的网址| 国产乱子伦精品视频| 日本一区午夜艳熟免费| 国产情侣第一页| 久久久久久久久久网| 久久久一本二本三本| 激情网站五月天| www.这里只有精品| av影院在线播放| 黄色大片中文字幕| 欧美亚洲另类色图| 亚洲国产日韩欧美在线观看| 最近中文字幕一区二区| 色婷婷激情视频| 国产精品视频网站在线观看 | 久久午夜夜伦鲁鲁一区二区| 亚洲这里只有精品| 国产 国语对白 露脸| 精品国产一二三四区| 九九热精品在线播放| 男人的天堂成人| 黄www在线观看| 中文字幕日韩综合| 精品视频在线观看一区| www.99av.com| 日韩一级性生活片| 天天综合网日韩| 成人免费视频91| 狠狠干狠狠操视频| 分分操这里只有精品| 97超碰成人在线| 3d动漫一区二区三区| 五月天视频在线观看| 激情五月宗合网| 激情久久综合网| 亚洲精品无码久久久久久| 手机av在线网站| 国产精品视频一区二区三区四区五区| 亚洲黄色小视频在线观看| 麻豆映画在线观看| mm131亚洲精品| 2022亚洲天堂| www.xxx麻豆| 黄色一级视频播放| 天天干天天玩天天操| 日本日本19xxxⅹhd乱影响| 天堂av免费看| 国产又粗又猛大又黄又爽| 久久久精品麻豆| 国产欧美在线一区| 欧美日韩在线一| 久久久久久久久久伊人| 免费成人深夜夜行网站视频| 九一精品久久久| 欧美wwwwwww| 少妇网站在线观看| 狠狠躁狠狠躁视频专区| 欧洲av无码放荡人妇网站| 欧美久久久久久久久久久久久| 久久久久久久久网| 最新中文字幕久久| 亚洲成人动漫在线| www.18av.com| 国产又粗又猛又爽又黄的网站| 7777在线视频| 人妻激情另类乱人伦人妻 | 精品国产免费av| 国模无码视频一区二区三区| 黄色免费福利视频| 国产99久久九九精品无码| 欧美日韩第二页| 日韩肉感妇bbwbbwbbw| 五月天激情播播| 天天爱天天做天天操| 69精品丰满人妻无码视频a片| 91网站在线观看免费| 男女猛烈激情xx00免费视频| 97在线免费公开视频| 日本久久精品一区二区| 日韩av一卡二卡三卡| 黄色片免费网址| 日韩免费在线观看av| 久久久精品在线视频| 中日韩av在线播放| 国产日产欧美一区二区| 九一国产精品视频| 国产一级片黄色| japanese在线视频| 日韩a在线播放| 国产又粗又猛大又黄又爽| aa在线观看视频| 欧美视频国产视频| 欧美成人三级在线视频| 国产又黄又猛又粗| 777av视频| 两性午夜免费视频| 欧美一级黄色片视频| 精品嫩模一区二区三区| www日韩视频| 轻点好疼好大好爽视频| 亚洲理论中文字幕| 干日本少妇首页| 91.com在线| av不卡在线免费观看| 国产男女激情视频| 久草热视频在线观看| 天天爱天天做天天操| 中文字幕在线观看第三页| 999一区二区三区| 激情久久综合网| 男人插女人下面免费视频| 国产免费观看高清视频| 999久久欧美人妻一区二区| 女人高潮一级片| 国产一线二线三线在线观看| www.浪潮av.com| 日韩精品在线中文字幕| 欧美少妇在线观看| 午夜天堂在线视频| 熟妇人妻无乱码中文字幕真矢织江| 日韩av中文字幕第一页| 国产精品无码免费专区午夜| 日本一本草久p| 北条麻妃亚洲一区| 一级黄色片国产| 欧洲美女亚洲激情| www.成人黄色| 成人性做爰片免费视频| 日韩av影视大全| 日韩欧美色视频| 久久视频免费在线| youjizz.com在线观看| 99国产精品白浆在线观看免费| 国产成人一区二区三区别| 日本中文字幕一级片| 白白操在线视频| 人人妻人人添人人爽欧美一区| koreanbj精品视频一区| 凹凸日日摸日日碰夜夜爽1| 日韩手机在线观看视频| 国产一级做a爰片久久| 日韩欧美国产片| 国产资源第一页| 国产a级一级片| 中文字幕第17页| 欧美极品少妇无套实战| 日韩精品 欧美| 在线观看av日韩| 超薄肉色丝袜足j调教99| 免费拍拍拍网站| 99视频精品免费| avove在线观看| 日本精品一区二区三区四区| 亚洲视频第二页| 青青草成人免费在线视频| 国产自偷自偷免费一区| 日韩视频在线观看视频| 国产av国片精品| 欧美激情国内自拍| 免费无码毛片一区二三区| 久热精品在线播放| 日韩欧美精品免费| 色婷婷狠狠18| 熟女少妇在线视频播放| 熟女熟妇伦久久影院毛片一区二区| 国产日韩欧美精品在线观看| 一女二男3p波多野结衣| 欧美日韩成人免费视频| 91精品一区二区三区四区| 日本一本二本在线观看| 91免费国产精品| 日韩av片免费观看| 无码少妇一区二区三区芒果| 大荫蒂性生交片| 久久免费看毛片| 国产一二三四在线视频| 成人免费aaa| www.夜夜爱| 国内自拍中文字幕| 久久出品必属精品| 五月婷婷丁香色| www.色就是色| 日韩欧美xxxx| 国产l精品国产亚洲区久久| 91网站在线观看免费| 最新视频 - x88av| 欧美xxxxxbbbbb| www.cao超碰| 91pony九色| 性生生活大片免费看视频| 91网址在线播放| 美女在线视频一区二区| 亚洲欧美另类动漫| 奇米影音第四色| 国内自拍第二页|