ReactOS 0.4.16-dev-92-g0c2cdca
NtObjDirectory Struct Reference

NtObj file system directory-entry. More...

#include <ntobjfs.h>

Inheritance diagram for NtObjDirectory:
Collaboration diagram for NtObjDirectory:

Public Member Functions

 NtObjDirectory (LPCTSTR root_path)
 
 NtObjDirectory (Entry *parent, LPCTSTR path)
 
 ~NtObjDirectory ()
 
virtual void read_directory (int scan_flags=0)
 
virtual Entryfind_entry (const void *)
 
- Public Member Functions inherited from NtObjEntry
 NtObjEntry (Entry *parent, OBJECT_TYPE type)
 
- Public Member Functions inherited from Entry
virtual ~Entry ()
 
void free_subentries ()
 
void read_directory_base (SORT_ORDER sortOrder=SORT_NAME, int scan_flags=0)
 
Entryread_tree (const void *path, SORT_ORDER sortOrder=SORT_NAME, int scan_flags=0)
 
void sort_directory (SORT_ORDER sortOrder)
 
void smart_scan (SORT_ORDER sortOrder=SORT_NAME, int scan_flags=0)
 
int extract_icon (ICONCACHE_FLAGS flags=ICF_NORMAL)
 
int safe_extract_icon (ICONCACHE_FLAGS flags=ICF_NORMAL)
 
virtual void read_directory (int scan_flags=0)
 
virtual const voidget_next_path_component (const void *) const
 
virtual Entryfind_entry (const void *)
 
virtual bool get_path (PTSTR path, size_t path_count) const =0
 
virtual ShellPath create_absolute_pidl () const
 
virtual HRESULT GetUIObjectOf (HWND hWnd, REFIID riid, LPVOID *ppvOut)
 
virtual ShellFolder get_shell_folder () const
 
virtual BOOL launch_entry (HWND hwnd, UINT nCmdShow=SW_SHOWNORMAL)
 
virtual HRESULT do_context_menu (HWND hwnd, const POINT &pos, CtxMenuInterfaces &cm_ifs)
 

Additional Inherited Members

- Public Attributes inherited from NtObjEntry
OBJECT_TYPE _type
 
- Public Attributes inherited from Entry
Entry_next
 
Entry_down
 
Entry_up
 
bool _expanded
 
bool _scanned
 
int _level
 
WIN32_FIND_DATA _data
 
SFGAOF _shell_attribs
 
LPTSTR _display_name
 
LPTSTR _type_name
 
LPTSTR _content
 
ENTRY_TYPE _etype
 
int _icon_id
 
BY_HANDLE_FILE_INFORMATION _bhfi
 
bool _bhfi_valid
 
- Protected Member Functions inherited from NtObjEntry
 NtObjEntry (OBJECT_TYPE type)
 
virtual bool get_path (PTSTR path, size_t path_count) const
 
virtual BOOL launch_entry (HWND hwnd, UINT nCmdShow)
 
- Protected Member Functions inherited from Entry
 Entry (ENTRY_TYPE etype)
 
 Entry (Entry *parent, ENTRY_TYPE etype)
 
 Entry (const Entry &)
 
bool get_path_base (PTSTR path, size_t path_count, ENTRY_TYPE etype) const
 
- Protected Member Functions inherited from Directory
 Directory ()
 
virtual ~Directory ()
 
- Protected Attributes inherited from Directory
void_path
 

Detailed Description

NtObj file system directory-entry.

Definition at line 100 of file ntobjfs.h.

Constructor & Destructor Documentation

◆ NtObjDirectory() [1/2]

NtObjDirectory::NtObjDirectory ( LPCTSTR  root_path)
inline

Definition at line 102 of file ntobjfs.h.

104 {
105 _path = _tcsdup(root_path);
106 }
#define _tcsdup
Definition: tchar.h:625
@ DIRECTORY_OBJECT
Definition: ntobjfs.h:30
void * _path
Definition: entries.h:143
NtObj file system file-entry.
Definition: ntobjfs.h:86

◆ NtObjDirectory() [2/2]

NtObjDirectory::NtObjDirectory ( Entry parent,
LPCTSTR  path 
)
inline

Definition at line 108 of file ntobjfs.h.

110 {
111 _path = _tcsdup(path);
112 }
r parent
Definition: btrfs.c:3010

◆ ~NtObjDirectory()

NtObjDirectory::~NtObjDirectory ( )
inline

Definition at line 114 of file ntobjfs.h.

115 {
116 free(_path);
117 _path = NULL;
118 }
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112

Member Function Documentation

◆ find_entry()

Entry * NtObjDirectory::find_entry ( const void p)
virtual

Reimplemented from Entry.

Definition at line 359 of file ntobjfs.cpp.

360{
362
363 for(Entry*entry=_down; entry; entry=entry->_next) {
364 LPCTSTR p = name;
365 LPCTSTR q = entry->_data.cFileName;
366
367 do {
368 if (!*p || *p==TEXT('\\') || *p==TEXT('/'))
369 return entry;
370 } while(tolower(*p++) == tolower(*q++));
371
372 p = name;
373 q = entry->_data.cAlternateFileName;
374
375 do {
376 if (!*p || *p==TEXT('\\') || *p==TEXT('/'))
377 return entry;
378 } while(tolower(*p++) == tolower(*q++));
379 }
380
381 return NULL;
382}
int tolower(int c)
Definition: utclib.c:902
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLfloat GLfloat p
Definition: glext.h:8902
uint32_t entry
Definition: isohybrid.c:63
#define TEXT(s)
Definition: k32.h:26
base of all file and directory entries
Definition: entries.h:83
Entry * _down
Definition: entries.h:93
Definition: name.c:39
const CHAR * LPCTSTR
Definition: xmlstorage.h:193

◆ read_directory()

void NtObjDirectory::read_directory ( int  scan_flags = 0)
virtual

Reimplemented from Entry.

Definition at line 173 of file ntobjfs.cpp.

174{
175 CONTEXT("NtObjDirectory::read_directory()");
176
177 if (!g_NTDLL)
178 g_NTDLL = new NTDLL();
179
180 Entry* first_entry = NULL;
181 int level = _level + 1;
182
184
186#ifndef UNICODE
187 WCHAR wbuffer[MAX_PATH], *w=wbuffer;
188#endif
189
190 do {
191 *p++ = *path;
192#ifndef UNICODE
193 *w++ = *path;
194#endif
195 } while(*path++);
196 --p;
197#ifndef UNICODE
198 --w;
199#endif
200
201 DWORD idx;
202 HANDLE dir_handle;
203
204#ifdef UNICODE
205 if (NtOpenObject(_type, &dir_handle, 0, buffer))
206#else
207 if (NtOpenObject(_type, &dir_handle, 0, wbuffer))
208#endif
209 return;
210
211#ifdef UNICODE
212 if (p[-1] != '\\')
213 *p++ = '\\';
214#else
215 if (w[-1] != '\\')
216 *w++ = '\\';
217#endif
218
220
221 if (!(*g_NTDLL->NtQueryDirectoryObject)(dir_handle, info, 2048, TRUE, TRUE, &idx, NULL)) {
222 WIN32_FIND_DATA w32fd;
223 Entry* last = NULL;
224 Entry* entry;
225
226 do {
227 memset(&w32fd, 0, sizeof(WIN32_FIND_DATA));
228
229#ifdef UNICODE
230 if (info->name.string_ptr) {
231 info->name.string_ptr[info->name.string_len / sizeof(WCHAR)] = 0;
232 } else {
233 TCHAR empty_string_ptr[] = _T("");
234 info->name.string_ptr = empty_string_ptr;
235 }
236 if (info->type.string_ptr) {
237 info->type.string_ptr[info->type.string_len / sizeof(WCHAR)] = 0;
238 } else {
239 TCHAR empty_string_ptr[] = _T("");
240 info->type.string_ptr = empty_string_ptr;
241 }
242 lstrcpynW(p, info->name.string_ptr, COUNTOF(buffer));
243#else
244 WideCharToMultiByte(CP_ACP, 0, info->name.string_ptr, info->name.string_len, p, COUNTOF(buffer), 0, 0);
245#endif
246
247 lstrcpyn(w32fd.cFileName, p, sizeof(w32fd.cFileName) / sizeof(0[w32fd.cFileName]));
248
249 const LPCWSTR* tname = NTDLL::s_ObjectTypes;
251
252 for(; *tname; tname++)
253 if (!wcsncmp(info->type.string_ptr, *tname, 32))
254 {type=OBJECT_TYPE(tname-NTDLL::s_ObjectTypes); break;}
255
256 if (type == DIRECTORY_OBJECT) {
257 w32fd.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
258
259 entry = new NtObjDirectory(this, buffer);
260 }
261
262 else if (type == SYMBOLICLINK_OBJECT) {
263 w32fd.dwFileAttributes |= ATTRIBUTE_SYMBOLIC_LINK;
264
265 entry = NULL;
266
267#ifndef _NO_WIN_FS
268 if (*w32fd.cFileName>='A' &&*w32fd.cFileName<='Z' && w32fd.cFileName[1]==':')
269 if (!_tcsncmp(buffer,TEXT("\\??\\"),4) || // NT4
270 !_tcsncmp(buffer,TEXT("\\GLOBAL??"),9)) { // XP
271 w32fd.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
272 entry = new WinDirectory(this, w32fd.cFileName);
273 }
274#endif
275
276 if (!entry)
277 entry = new NtObjDirectory(this, buffer);
278 }
279
280 else if (type == KEY_OBJECT) {
281 w32fd.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
282
283 entry = new RegistryRoot(this, buffer);
284 }
285 else
286 entry = new NtObjEntry(this, type);
287
289
290#ifdef UNICODE
291 lstrcpyW(p, info->name.string_ptr);
292 if (!NtOpenObject(type, &handle, 0, buffer))
293#else
294 lstrcpyW(w, info->name.string_ptr);
295 if (!NtOpenObject(type, &handle, 0, wbuffer))
296#endif
297 {
299 DWORD read;
300
301 if (!(*g_NTDLL->NtQueryObject)(handle, 0/*ObjectBasicInformation*/, &object, sizeof(NtObject), &read)) {
302 memcpy(&w32fd.ftCreationTime, &object.creation_time, sizeof(FILETIME));
303
304 memset(&entry->_bhfi, 0, sizeof(BY_HANDLE_FILE_INFORMATION));
305 entry->_bhfi.nNumberOfLinks = object.reference_count - 1;
306 entry->_bhfi_valid = true;
307 }
308
309 if (type == SYMBOLICLINK_OBJECT) {
310 WCHAR wbuffer[_MAX_PATH];
311 UnicodeString link(_MAX_PATH, wbuffer);
312
314 int len = link.string_len/sizeof(WCHAR);
315 entry->_content = (LPTSTR) malloc((len+1)*sizeof(TCHAR));
316#ifdef UNICODE
317 wcsncpy_s(entry->_content, len+1, link, len);
318#else
319 U2nA(link, entry->_content, len);
320#endif
321 entry->_content[len] = '\0';
322 }
323 }
324
326 }
327
328 memcpy(&entry->_data, &w32fd, sizeof(WIN32_FIND_DATA));
329
330#ifdef UNICODE
331 entry->_type_name = _wcsdup(info->type.string_ptr);
332#else
333 char type_name[32];
334 WideCharToMultiByte(CP_ACP, 0, info->type.string_ptr, info->type.string_len, type_name, 32, 0, 0);
335 entry->_type_name = _strdup(type_name);
336#endif
337
338 if (!first_entry)
339 first_entry = entry;
340
341 if (last)
342 last->_next = entry;
343
344 entry->_level = level;
345
346 last = entry;
347 } while(!(*g_NTDLL->NtQueryDirectoryObject)(dir_handle, info, 2048, TRUE, FALSE, &idx, NULL));
348
349 last->_next = NULL;
350 }
351
352 (*g_NTDLL->NtClose)(dir_handle);
353
354 _down = first_entry;
355 _scanned = true;
356}
#define read
Definition: acwin.h:96
const WCHAR * link
Definition: db.cpp:997
#define _strdup
Definition: debug_ros.c:7
#define malloc
Definition: debug_ros.c:4
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int idx
Definition: utils.c:41
#define CP_ACP
Definition: compat.h:109
#define MAX_PATH
Definition: compat.h:34
#define lstrcpyW
Definition: compat.h:749
#define WideCharToMultiByte
Definition: compat.h:111
#define lstrcpynW
Definition: compat.h:738
#define ATTRIBUTE_SYMBOLIC_LINK
Definition: entries.h:62
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint level
Definition: gl.h:1546
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define _tcsncmp
Definition: tchar.h:1428
#define alloca
Definition: malloc.h:357
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define _MAX_PATH
Definition: utility.h:77
#define U2nA(s, d, l)
Definition: utility.h:129
#define COUNTOF(x)
Definition: utility.h:93
#define wcsncpy_s(d, l, s, n)
Definition: utility.h:202
static UINT UINT last
Definition: font.c:45
struct _CONTEXT CONTEXT
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
static DWORD NtOpenObject(OBJECT_TYPE type, PHANDLE phandle, DWORD access, LPCWSTR path)
Definition: ntobjenum.cpp:50
OBJECT_TYPE
Definition: ntobjenum.h:13
NTDLL * g_NTDLL
Definition: ntobjfs.cpp:132
OBJECT_TYPE
Definition: ntobjfs.h:29
@ KEY_OBJECT
Definition: ntobjfs.h:32
@ SYMBOLICLINK_OBJECT
Definition: ntobjfs.h:30
@ UNKNOWN_OBJECT_TYPE
Definition: ntobjfs.h:37
_Check_return_ _CRTIMP wchar_t *__cdecl _wcsdup(_In_z_ const wchar_t *_Str)
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define memset(x, y, z)
Definition: compat.h:39
int _level
Definition: entries.h:98
bool _scanned
Definition: entries.h:97
DynamicFct< DWORD(__stdcall *)(HANDLE, NtObjectInfo *, DWORD size, BOOL, BOOL, void *, void *)> NtQueryDirectoryObject
Definition: ntobjfs.cpp:104
DynamicFct< DWORD(__stdcall *)(HANDLE)> NtClose
Definition: ntobjfs.cpp:117
static const LPCWSTR s_ObjectTypes[]
Definition: ntobjfs.cpp:94
DynamicFct< DWORD(__stdcall *)(HANDLE, DWORD, NtObject *, DWORD size, DWORD *read)> NtQueryObject
Definition: ntobjfs.cpp:108
DynamicFct< DWORD(__stdcall *)(HANDLE, RtlUnicodeString *, DWORD *)> NtQuerySymbolicLinkObject
Definition: ntobjfs.cpp:107
NtObj file system directory-entry.
Definition: ntobjfs.h:101
OBJECT_TYPE _type
Definition: ntobjfs.h:89
Registry key entry.
Definition: regfs.h:64
Windows file system directory-entry.
Definition: winfs.h:46
#define _T(x)
Definition: vfdio.h:22
#define lstrcpyn
Definition: winbase.h:3875
char TCHAR
Definition: xmlstorage.h:189
__wchar_t WCHAR
Definition: xmlstorage.h:180
CHAR * LPTSTR
Definition: xmlstorage.h:192
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

The documentation for this struct was generated from the following files: