1 /*
2  * Copyright 2004 Martin Fuchs
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18 
19 
20  //
21  // Explorer clone
22  //
23  // ntobjfs.h
24  //
25  // Martin Fuchs, 31.01.2004
26  //
27 
28 
29 enum OBJECT_TYPE {
30 	DIRECTORY_OBJECT, SYMBOLICLINK_OBJECT,
31 	MUTANT_OBJECT, SECTION_OBJECT, EVENT_OBJECT, SEMAPHORE_OBJECT,
32 	TIMER_OBJECT, KEY_OBJECT, EVENTPAIR_OBJECT, IOCOMPLETITION_OBJECT,
33 	DEVICE_OBJECT, FILE_OBJECT, CONTROLLER_OBJECT, PROFILE_OBJECT,
34 	TYPE_OBJECT, DESKTOP_OBJECT, WINDOWSTATION_OBJECT, DRIVER_OBJECT,
35 	TOKEN_OBJECT, PROCESS_OBJECT, THREAD_OBJECT, ADAPTER_OBJECT, PORT_OBJECT,
36 
37 	UNKNOWN_OBJECT_TYPE=-1
38 };
39 
40 struct RtlAnsiString {
41 	WORD	string_len;
42 	WORD	alloc_len;
43 	LPSTR	string_ptr;
44 };
45 
46 struct RtlUnicodeString {
47 	WORD	string_len;
48 	WORD	alloc_len;
49 	LPWSTR	string_ptr;
50 };
51 
52 struct NtObjectInfo {
53 	RtlUnicodeString name;
54 	RtlUnicodeString type;
55 	BYTE	padding[16];
56 };
57 
58 struct OpenStruct {
59 	DWORD	size;
60 	DWORD	_1;
61 	RtlUnicodeString* string;
62 	DWORD	_3;
63 	DWORD	_4;
64 	DWORD	_5;
65 };
66 
67 struct NtObject {
68 	DWORD	_0;
69 	DWORD	_1;
70 	DWORD	handle_count;
71 	DWORD	reference_count;
72 	DWORD	_4;
73 	DWORD	_5;
74 	DWORD	_6;
75 	DWORD	_7;
76 	DWORD	_8;
77 	DWORD	_9;
78 	DWORD	_A;
79 	DWORD	_B;
80 	FILETIME creation_time;
81 };
82 
83 
84  /// NtObj file system file-entry
85 struct NtObjEntry : public Entry
86 {
87 	NtObjEntry(Entry* parent, OBJECT_TYPE type) : Entry(parent, ET_NTOBJS), _type(type) {}
88 
89 	OBJECT_TYPE	_type;
90 
91 protected:
92 	NtObjEntry(OBJECT_TYPE type) : Entry(ET_NTOBJS), _type(type) {}
93 
94 	virtual bool get_path(PTSTR path, size_t path_count) const;
95 	virtual BOOL launch_entry(HWND hwnd, UINT nCmdShow);
96 };
97 
98 
99  /// NtObj file system directory-entry
100 struct NtObjDirectory : public NtObjEntry, public Directory
101 {
102 	NtObjDirectory(LPCTSTR root_path)
103 	 :	NtObjEntry(DIRECTORY_OBJECT)
104 	{
105 		_path = _tcsdup(root_path);
106 	}
107 
108 	NtObjDirectory(Entry* parent, LPCTSTR path)
109 	 :	NtObjEntry(parent, DIRECTORY_OBJECT)
110 	{
111 		_path = _tcsdup(path);
112 	}
113 
114 	~NtObjDirectory()
115 	{
116 		free(_path);
117 		_path = NULL;
118 	}
119 
120 	virtual void read_directory(int scan_flags=0);
121 	virtual Entry* find_entry(const void*);
122 };
123