Advertisement
Advertisement
| 06.17.2008 at 11:45AM PDT, ID: 23492776 | Points: 50 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: |
#define STATUS_SUCCESS 0x00000000L
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;
typedef OBJECT_ATTRIBUTES *POBJECT_ATTRIBUTES;
typedef NTSTATUS (NTAPI *LPNTDELETEFILE)(IN POBJECT_ATTRIBUTES objectAttributes);
BOOL NtDeleteFileForced(LPTSTR lpszDeletePath) {
HMODULE hModuleNt;
NTSTATUS lNtStatus;
LPNTDELETEFILE NtDeleteFile;
OBJECT_ATTRIBUTES tagObjectAttributes;
UNICODE_STRING tagUnicodeString;
hModuleNt = GetModuleHandle(TEXT("NTDLL.DLL"));
if (!hModuleNt) {
return FALSE;
}
NtDeleteFile = (LPNTDELETEFILE)GetProcAddress(hModuleNt, "NtDeleteFile");
if (!NtDeleteFile) {
return FALSE;
}
ZeroMemory(&tagUnicodeString, sizeof(UNICODE_STRING));
ZeroMemory(&tagObjectAttributes, sizeof(OBJECT_ATTRIBUTES));
tagUnicodeString.Length = lstrlen(lpszDeletePath);
tagUnicodeString.MaximumLength = MAX_PATH;
tagUnicodeString.Buffer = lpszDeletePath;
tagObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
tagObjectAttributes.ObjectName = &tagUnicodeString;
lNtStatus = NtDeleteFile(&tagObjectAttributes);
if (lNtStatus != STATUS_SUCCESS) {
return FALSE;
}
return TRUE;
}
int _tmain(int argc, LPCTSTR *argv[]) {
NtDeleteFileForced(TEXT("C:\\TEST\\testing.txt"));
ExitProcess(TRUE);
}
|