-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathntobjx_c.cpp
62 lines (54 loc) · 1.7 KB
/
ntobjx_c.cpp
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
60
61
62
#include <Windows.h>
#include <tchar.h>
#include <cstdio>
#include <atlbase.h>
#include <atlstr.h>
#include <delayimp.h>
#include "objmgr.hpp"
EXTERN_C int __cdecl DelayLoadError(LPCTSTR lpszFormat, ...)
{
va_list args;
va_start(args, lpszFormat);
return _vtprintf(lpszFormat, args);
};
using NtObjMgr::Directory;
using NtObjMgr::GenericObject;
using NtObjMgr::SymbolicLink;
void PrintDirectory(Directory& current, ATL::CString Prefix = _T(""))
{
for (size_t i = 0; i < current.size(); i++)
{
GenericObject* entry = current[i];
SymbolicLink const* symlink = dynamic_cast<SymbolicLink const*>(entry);
Directory* directory = dynamic_cast<Directory*>(entry);
if (directory)
{
CString newPrefix(Prefix + _T(" "));
_tprintf(_T("%s%ws [%ws]\n"), Prefix.GetString(), directory->name().GetString(), directory->type().GetString());
PrintDirectory(*directory, newPrefix);
}
else if (symlink)
{
_tprintf(_T("%s%ws [%ws] -> %ws\n"), Prefix.GetString(), symlink->name().GetString(), symlink->type().GetString(), symlink->target().GetString());
}
else
{
_tprintf(_T("%s%ws [%ws]\n"), Prefix.GetString(), entry->name().GetString(), entry->type().GetString());
}
}
}
#if TEST_RES_MAPPING
# include "objtypes.h"
#endif
int _tmain(int /*argc*/, _TCHAR** /*argv*/)
{
Directory objmgr_root;
PrintDirectory(objmgr_root);
#if TEST_RES_MAPPING
for (size_t i = 0; i < sizeof(resIconTypeMapping) / sizeof(resIconTypeMapping[0]); i++)
{
_tprintf(_T("%ws [%u]\n"), resIconTypeMapping[i].typeName, resIconTypeMapping[i].resId);
}
#endif
return 0;
}