delphi 在瑞星2010全保护下创建文件夹


本文整理自网络,侵删。

 program createfolder;

uses
Windows;

const
DIRECTORY_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED or $F;
FILE_CREATE = $00000002;
FILE_DIRECTORY_FILE = $00000001;
OBJ_CASE_INSENSITIVE = $00000040;

type
NTSTATUS = ULONG;

PUnicodeString = ^TUnicodeString;
TUnicodeString = packed record
Length: Word;
MaximumLength: Word;
Buffer: PWideChar;
end;
UNICODE_STRING = TUnicodeString;
PUNICODE_STRING = ^UNICODE_STRING;

PLargeInteger = ^TLargeInteger;
TLargeInteger = packed record
LowPart: Cardinal;
HighPart: Integer;
end;

PObjectAttributes = ^TObjectAttributes;
TObjectAttributes = packed record
Length: Cardinal;
RootDirectory: THandle;
ObjectName: PUNICODE_STRING;
Attributes: Cardinal;
SecurityDescriptor: Pointer;
SecurityQualityOfService: Pointer;
end;
OBJECT_ATTRIBUTES = ^TObjectAttributes;
POBJECT_ATTRIBUTES = ^OBJECT_ATTRIBUTES;

PIoStatusBlock = ^TIoStatusBlock;
TIoStatusBlock = packed record
Status: NTSTATUS;
Information: Cardinal; //ULONG_PTR
end;
IO_STATUS_BLOCK = TIoStatusBlock;
procedure RtlInitUnicodeString (var Buffer: TUnicodeString;Source: PWideChar); stdcall;external 'ntdll.dll' name 'RtlInitUnicodeString';

function createrixing(Filefname:PWideChar): bool;
var
hmod, hFile: dword;
FileAccess: ulong;
stat: integer;
FileAttr, FileShare, CreateDispos, CreateOptions: ulong;
oba: TObjectAttributes;
iosb: IO_STATUS_BLOCK;
pNtCreateFile, pUniName: pointer;
uniname: UNICODE_STRING;
begin
result := false;
hmod := GetModuleHandle('ntdll.dll');
pNtCreateFile := GetProcAddress(hmod, 'NtCreateFile');
FileAccess := DIRECTORY_ALL_ACCESS;
FileAttr := FILE_ATTRIBUTE_NORMAL;
FileShare := FILE_SHARE_READ or FILE_SHARE_WRITE;
CreateDispos := FILE_CREATE;
CreateOptions := FILE_DIRECTORY_FILE;
RtlInitUnicodeString(uniname, Filefname);
oba.Length := SizeOf(TObjectAttributes);
oba.RootDirectory := 0;
oba.Attributes :=OBJ_CASE_INSENSITIVE;
oba.ObjectName := @UniName;
oba.SecurityDescriptor := nil;
oba.SecurityQualityOfService := nil;
asm
push 0
push 0
push CreateOptions
push CreateDispos
push FileShare
push FileAttr
push 0
lea eax , iosb
push eax
lea eax ,oba
push eax
push FileAccess
lea eax ,hFile
push eax
call pNtCreateFile
mov stat , eax
end;
if (stat <> 0) then result := false else result := true;
end;
begin
if not (createrixing('\??\C:\Program Files\Rising\Rav\lpk.dll')) then messagebox(0, pchar('文件夹创建失败'), '提示', 0) else
messagebox(0, pchar('创建成功'), '提示', 0)
end.

相关阅读 >>

Delphi 与360

Delphi远程注入dll方法

winapi 字符及字符串函数(3): charupper - 字符或字符串转大写

Delphi 读取全网站链接

Delphi xe2 硬盘序列号

Delphi 资源文件管理 resources and images

Delphi整理八(对话框)

Delphi 调用外部 dll 中的函数(2. 晚绑定)

通过崩溃地址找错误行数之Delphi

cvcode.pas

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...