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