mirror of https://github.com/tongzx/nt5src
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.2 KiB
45 lines
1.2 KiB
#include <nt.h>
|
|
#include <ntrtl.h>
|
|
#include <nturtl.h>
|
|
#include <windows.h>
|
|
#include <tchar.h> // for wprintf
|
|
#include <winsafer.h>
|
|
#include "..\..\saferp.h" // for CodeAuthzFullyQualifyFilename
|
|
|
|
|
|
int __cdecl wmain(int argc, wchar_t *argv[])
|
|
{
|
|
NTSTATUS Status;
|
|
HANDLE hFile;
|
|
UNICODE_STRING UnicodeResult;
|
|
|
|
|
|
if (argc != 2) {
|
|
wprintf(L"Invalid syntax. No filename supplied.\n");
|
|
return -1;
|
|
}
|
|
hFile = CreateFile(argv[1], GENERIC_READ, FILE_SHARE_READ, NULL,
|
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
if (!hFile || hFile == INVALID_HANDLE_VALUE) {
|
|
wprintf(L"Unable to open file: %s\n", argv[1]);
|
|
return -1;
|
|
}
|
|
|
|
Status = CodeAuthzFullyQualifyFilename(
|
|
hFile, FALSE, argv[1], &UnicodeResult);
|
|
|
|
CloseHandle(hFile);
|
|
|
|
if (!NT_SUCCESS(Status)) {
|
|
wprintf(L"Unable to canonicalize filename: %s\n", argv[1]);
|
|
}
|
|
|
|
wprintf(L"Supplied filename: %s\n", argv[1]);
|
|
wprintf(L"Canonocalized result: %*s\n",
|
|
UnicodeResult.Length / sizeof(WCHAR), UnicodeResult.Buffer);
|
|
|
|
RtlFreeUnicodeString(&UnicodeResult);
|
|
|
|
return 0;
|
|
}
|
|
|