本帖最后由 冥界3大法王 于 2021-5-10 22:43 编辑
[Delphi] 纯文本查看 复制代码
[size=14px]unit Unit1;[/size]
[size=14px]
[/size]
[size=14px]interface[/size]
[size=14px]
[/size]
[size=14px]uses[/size]
[size=14px] Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,[/size]
[size=14px] System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,[/size]
[size=14px] Vcl.StdCtrls;[/size]
[size=14px]
[/size]
[size=14px]const[/size]
[size=14px] OBJ_CASE_INSENSITIVE = $00000040;[/size]
[size=14px] STATUS_SUCCESS = $00000000;[/size]
[size=14px]
[/size]
[size=14px]type[/size]
[size=14px] NTSTATUS = DWORD;[/size]
[size=14px]
[/size]
[size=14px] PVOID = Pointer;[/size]
[size=14px]
[/size]
[size=14px] PUnicodeString = ^TUnicodeString;[/size]
[size=14px]
[/size]
[size=14px] TUnicodeString = packed record[/size]
[size=14px] Length: Word;[/size]
[size=14px] MaximumLength: Word;[/size]
[size=14px] Buffer: PWideChar;[/size]
[size=14px] end;[/size]
[size=14px]
[/size]
[size=14px] UNICODE_STRING = TUnicodeString;[/size]
[size=14px]
[/size]
[size=14px] PUNICODE_STRING = ^UNICODE_STRING;[/size]
[size=14px]
[/size]
[size=14px] POBJECT_ATTRIBUTES = ^TOBJECT_ATTRIBUTES;[/size]
[size=14px]
[/size]
[size=14px] TOBJECT_ATTRIBUTES = record[/size]
[size=14px] Length: Cardinal;[/size]
[size=14px] RootDirectory: THANDLE;[/size]
[size=14px] ObjectName: PUNICODE_STRING;[/size]
[size=14px] Attributes: Dword;[/size]
[size=14px] SecurityDescriptor: pointer; // Points to type SECURITY_DESCRIPTOR[/size]
[size=14px] SecurityQualityOfService: pointer; // Points to type SECURITY_QUALITY_OF_SERVICE[/size]
[size=14px] end;[/size]
[size=14px]
[/size]
[size=14px]type[/size]
[size=14px] TForm1 = class(TForm)[/size]
[size=14px] Button1: TButton;[/size]
[size=14px] procedure Button1Click(Sender: TObject);[/size]
[size=14px] private[/size]
[size=14px] { Private declarations }[/size]
[size=14px] public[/size]
[size=14px] { Public declarations }[/size]
[size=14px] end;[/size]
[size=14px]
[/size]
[size=14px]var[/size]
[size=14px] Form1: TForm1;[/size]
[size=14px]
[/size]
[size=14px]implementation[/size]
[size=14px]
[/size]
[size=14px]{$R *.dfm}[/size]
[size=14px]
[/size]
[size=14px]procedure RtlInitUnicodeString(var Buffer: TUnicodeString; Source: PWideChar); stdcall; external 'ntdll.dll';[/size]
[size=14px]
[/size]
[size=14px]function ZwDeleteFile(ObjectAttributes: POBJECT_ATTRIBUTES): NTSTATUS; stdcall; external 'ntdll.dll';[/size]
[size=14px]
[/size]
[size=14px]procedure InitializeObjectAttributes(pAttributes: POBJECT_ATTRIBUTES; n: PUNICODE_STRING; a: Cardinal; r: THANDLE; s: pointer);[/size]
[size=14px]begin[/size]
[size=14px] pAttributes^.Length := SizeOf(TOBJECT_ATTRIBUTES);[/size]
[size=14px] pAttributes^.RootDirectory := r;[/size]
[size=14px] pAttributes^.Attributes := a;[/size]
[size=14px] pAttributes^.ObjectName := n;[/size]
[size=14px] pAttributes^.SecurityDescriptor := s;[/size]
[size=14px] pAttributes^.SecurityQualityOfService := nil;[/size]
[size=14px]end;[/size]
[size=14px]
[/size]
[size=14px]procedure TForm1.Button1Click(Sender: TObject);[/size]
[size=14px]var[/size]
[size=14px] at: UNICODE_STRING;[/size]
[size=14px] oa: TOBJECT_ATTRIBUTES;[/size]
[size=14px]begin[/size]
[size=14px] RtlInitUnicodeString(at, '\??\C:\0.txt');[/size]
[size=14px] InitializeObjectAttributes(@oa, @at, OBJ_CASE_INSENSITIVE, 0, 0);[/size]
[size=14px] ZwDeleteFile(@oa);[/size]
[size=14px]end;[/size]
[size=14px]
[/size]
[size=14px]end.[/size]
|