如题

解决方案 »

  1.   

    library Project1; { Important note about DLL memory management: ShareMem must be the 
      first unit in your library's USES clause AND your project's (select 
      Project-View Source) USES clause if your DLL exports any procedures or 
      functions that pass strings as parameters or function results. This 
      applies to all strings passed to and from your DLL--even those that 
      are nested in records and classes. ShareMem is the interface unit to 
      the BORLNDMM.DLL shared memory manager, which must be deployed along 
      with your DLL. To avoid using BORLNDMM.DLL, pass string information 
      using PChar or ShortString parameters. } uses 
      SysUtils, 
      Classes, 
      Windows, 
      variants, 
      Isapi4 in 'Isapi4.pas'; 
      {$R *.res} 
    function GetFilterVersion(var pVer:THTTP_FILTER_VERSION):BOOL;stdcall; 
    begin 
    pVer.dwFlags:=(SF_NOTIFY_NONSECURE_PORT or SF_NOTIFY_SEND_RAW_DATA 
                  or SF_NOTIFY_END_OF_REQUEST or SF_NOTIFY_ORDER_DEFAULT); pVer.dwFilterVersion:=HTTP_FILTER_REVISION; 
    pVer.lpszFilterDesc[0]:='A'; 
    pVer.lpszFilterDesc[1]:=#0; 
    result:=true;//初始化成功 
    end; function HttpFilterProc(var pfc:THTTP_FILTER_CONTEXT;Notificationtype:DWORD;pvNotification:Pointer):DWORD;stdcall; 
    var 
    p:PHTTP_FILTER_RAW_DATA; 
    i,tmpI:integer; 
    pc:pchar; 
    sList : TStringList; f:textfile;//与TP中text类型相同 
      tmp:string; 
    Buffer,pszContent:pchar; 
    NewContent,OldContent:string; 
    begin 
      if Notificationtype=$80 then 
      //是SF_NOTIFY_END_OF_REQUEST将pFilterContext复位 
      begin 
        pfc.pFilterContext:=nil; 
      end 
      else 
      begin 
        p:=PHTTP_FILTER_RAW_DATA(pvNotification); 
        pc:=p^.pvInData;  
        try 
          OldContent:=pc; 
          //pszContent := PChar(@PChar(pfc.pFilterContext)[HeaderLen]); 
          NewContent:=stringreplace(OldContent,'123456','******',[rfReplaceAll]); 
          //NewContent:=OldContent; 
          Buffer := pfc.AllocMem(pfc, p^.cbInBuffer+1, 0); 
          ZeroMemory(Buffer,p^.cbInBuffer); 
          CopyMemory(Buffer, pchar(NewContent),length(NewContent));       with HTTP_FILTER_RAW_DATA(pvNotification^) do 
            begin 
            pvInData := Buffer; 
            cbInData := p^.cbInBuffer; 
            cbInBuffer := p^.cbInBuffer+1; 
            end; 
        except 
          on E: Exception do 
          begin 
            assignfile(f,'c:\tmp.txt');//TP中的assign 
            append(f); 
            writeln(f,pc); 
            writeln(f,e.Message); 
            closefile(f); 
          end; 
        end;   
      end;  result:=SF_STATUS_REQ_NEXT_NOTIFICATION; end; 
    exports                
      GetFilterVersion, 
      HttpFilterProc; begin 
    end.
      

  2.   


    昨晚上刚好也找到了这段代码,谢谢了,但是还没解决,因为SF_NOTIFY_SEND_RAW_DATA 事件可能触发好几次,不知道在什么情况下才算完成或者说还有几次SF_NOTIFY_SEND_RAW_DATA 事件