能力值:
( LV13,RANK:290 )
30 楼
typedef LONG NTSTATUS ;
typedef struct _UNICODE_STRING {
USHORT Length;
USHORT MaximumLength;
PWSTR Buffer;
} UNICODE_STRING;
typedef UNICODE_STRING *PUNICODE_STRING;
typedef const UNICODE_STRING *PCUNICODE_STRING;
typedef struct _OBJECT_ATTRIBUTES {
ULONG Length;
HANDLE RootDirectory;
PUNICODE_STRING ObjectName;
ULONG Attributes;
PVOID SecurityDescriptor;
PVOID SecurityQualityOfService;
} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES;
typedef struct _IO_STATUS_BLOCK {
union {
NTSTATUS Status;
PVOID Pointer;
};
ULONG_PTR Information;
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; typedef NTSTATUS (*ZWDELETEFILE)( IN LPVOID );
typedef VOID (*RTLINITUNICODESTRING)( LPVOID, LPVOID ); typedef NTSTATUS (*ZWCREATEFILE)(
OUT PHANDLE ,
IN ACCESS_MASK ,
IN LPVOID ,
OUT LPVOID ,
IN PLARGE_INTEGER ,
IN ULONG ,
IN ULONG ,
IN ULONG ,
IN ULONG ,
IN PVOID ,
IN ULONG
);
typedef NTSTATUS (*ZWWRITEFILE)(
IN HANDLE ,
IN HANDLE OPTIONAL,
IN LPVOID OPTIONAL,
IN PVOID OPTIONAL,
OUT LPVOID ,
IN PVOID ,
IN ULONG ,
IN PLARGE_INTEGER OPTIONAL,
IN PULONG OPTIONAL
);
typedef NTSTATUS (*ZWCLOSE)(
IN HANDLE
); void CTestDlg::OnButton1()
{
HINSTANCE hNtDll;
ZWDELETEFILE ZwDeleteFile;
RTLINITUNICODESTRING RtlInitUnicodeString;
ZWCREATEFILE ZwCreateFile;
ZWWRITEFILE ZwWriteFile;
ZWCLOSE ZwClose;
hNtDll = LoadLibrary ("NTDLL");
if (!hNtDll)
return ;
ZwDeleteFile = (ZWDELETEFILE)GetProcAddress (hNtDll,"ZwDeleteFile");
RtlInitUnicodeString = (RTLINITUNICODESTRING)GetProcAddress (hNtDll,"RtlInitUnicodeString");
ZwCreateFile = (ZWCREATEFILE)GetProcAddress (hNtDll,"ZwCreateFile");
ZwWriteFile = (ZWWRITEFILE)GetProcAddress (hNtDll,"ZwWriteFile");
ZwClose = (ZWCLOSE)GetProcAddress (hNtDll,"ZwClose");
UNICODE_STRING ObjectName;
RtlInitUnicodeString(&ObjectName,L"\\??\\E:\\123.exe");//记得这里要有\\??\\在前面的,文件名必须是符号链接或者设备名 _asm sub esp,8 OBJECT_ATTRIBUTES ObjectAttributes = {
sizeof(OBJECT_ATTRIBUTES), // Length
NULL, // RootDirectory
&ObjectName, // ObjectName
0x00000040/*OBJ_CASE_INSENSITIVE*/, // Attributes
0, // SecurityDescriptor
NULL, // SecurityQualityOfService
};
HANDLE hFile;
PVOID content = "ForZwFileTest";
IO_STATUS_BLOCK IoStatusBlock;
ZwCreateFile(&hFile,
GENERIC_WRITE|SYNCHRONIZE|GENERIC_READ,
&ObjectAttributes,
&IoStatusBlock,
0,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_DELETE,
0x00000003/*FILE_OPEN_IF*/,
0x00000020/*FILE_SYNCHRONOUS_IO_NONALERT*/,
NULL,
0);
_asm sub esp,0x2c ZwWriteFile(hFile, 0, 0, 0, &IoStatusBlock, content, 12, NULL, NULL);
_asm sub esp,0x24
ZwClose(hFile);
_asm sub esp,0x4
ZwDeleteFile(&ObjectAttributes);
_asm sub esp,0x4
FreeLibrary (hNtDll);
}
能力值:
( LV13,RANK:290 )
31 楼
帮贴下删文件的代码,哈哈,,,,
能力值:
( LV2,RANK:10 )
32 楼
先call TerminateThread再 free dll
能力值:
( LV2,RANK:10 )
35 楼
收藏,学习咯