mirror of
https://github.com/reactos/reactos.git
synced 2024-10-04 16:36:11 +00:00
- don't sort registry hives
- fix for memory corruption problem svn path=/trunk/; revision=7945
This commit is contained in:
parent
77721fee4b
commit
df1d5b7032
|
@ -3,7 +3,7 @@
|
|||
<tr>
|
||||
<td><address style="align: right;"><small>
|
||||
ROS Explorer Source Code Documentation
|
||||
<br>generated on 25.01.2004 by <a href="http://www.doxygen.org/index.html">
|
||||
<br>generated on 31.01.2004 by <a href="http://www.doxygen.org/index.html">
|
||||
<img src="doxygen.png" alt="doxygen" align="middle" border=0>
|
||||
</small></address>
|
||||
</td>
|
||||
|
|
|
@ -167,6 +167,11 @@ static int compareType(const WIN32_FIND_DATA* fd1, const WIN32_FIND_DATA* fd2)
|
|||
}
|
||||
|
||||
|
||||
static int compareNothing(const void* arg1, const void* arg2)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int compareName(const void* arg1, const void* arg2)
|
||||
{
|
||||
const WIN32_FIND_DATA* fd1 = &(*(Entry**)arg1)->_data;
|
||||
|
@ -247,6 +252,7 @@ static int compareDate(const void* arg1, const void* arg2)
|
|||
|
||||
|
||||
static int (*sortFunctions[])(const void* arg1, const void* arg2) = {
|
||||
compareNothing, // SORT_NONE
|
||||
compareName, // SORT_NAME
|
||||
compareExt, // SORT_EXT
|
||||
compareSize, // SORT_SIZE
|
||||
|
@ -256,30 +262,32 @@ static int (*sortFunctions[])(const void* arg1, const void* arg2) = {
|
|||
|
||||
void Entry::sort_directory(SORT_ORDER sortOrder)
|
||||
{
|
||||
Entry* entry = _down;
|
||||
Entry** array, **p;
|
||||
int len;
|
||||
if (sortOrder != SORT_NONE) {
|
||||
Entry* entry = _down;
|
||||
Entry** array, **p;
|
||||
int len;
|
||||
|
||||
len = 0;
|
||||
for(entry=_down; entry; entry=entry->_next)
|
||||
++len;
|
||||
|
||||
if (len) {
|
||||
array = (Entry**) alloca(len*sizeof(Entry*));
|
||||
|
||||
p = array;
|
||||
len = 0;
|
||||
for(entry=_down; entry; entry=entry->_next)
|
||||
*p++ = entry;
|
||||
++len;
|
||||
|
||||
// call qsort with the appropriate compare function
|
||||
qsort(array, len, sizeof(array[0]), sortFunctions[sortOrder]);
|
||||
if (len) {
|
||||
array = (Entry**) alloca(len*sizeof(Entry*));
|
||||
|
||||
_down = array[0];
|
||||
p = array;
|
||||
for(entry=_down; entry; entry=entry->_next)
|
||||
*p++ = entry;
|
||||
|
||||
for(p=array; --len; p++)
|
||||
p[0]->_next = p[1];
|
||||
// call qsort with the appropriate compare function
|
||||
qsort(array, len, sizeof(array[0]), sortFunctions[sortOrder]);
|
||||
|
||||
(*p)->_next = 0;
|
||||
_down = array[0];
|
||||
|
||||
for(p=array; --len; p++)
|
||||
(*p)->_next = p[1];
|
||||
|
||||
(*p)->_next = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ enum ENTRY_TYPE {
|
|||
};
|
||||
|
||||
enum SORT_ORDER {
|
||||
SORT_NONE,
|
||||
SORT_NAME,
|
||||
SORT_EXT,
|
||||
SORT_SIZE,
|
||||
|
|
|
@ -100,7 +100,7 @@ FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info)
|
|||
|
||||
const ShellChildWndInfo& shell_info = static_cast<const ShellChildWndInfo&>(info);
|
||||
_root._entry = new ShellDirectory(Desktop(), DesktopFolderPath(), hwnd);
|
||||
entry = _root._entry->read_tree((LPCTSTR)&*shell_info._shell_path, SORT_NAME/*_sortOrder*/);
|
||||
entry = _root._entry->read_tree((LPCTSTR)&*shell_info._shell_path, SORT_NAME);
|
||||
}
|
||||
else
|
||||
#ifdef __WINE__
|
||||
|
@ -115,7 +115,7 @@ FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info)
|
|||
lstrcpy(_root._fs, TEXT("unixfs"));
|
||||
lstrcpy(_root._path, TEXT("/"));
|
||||
_root._entry = new UnixDirectory(_root._path);
|
||||
entry = _root._entry->read_tree(info._path, SORT_NAME/*_sortOrder*/);
|
||||
entry = _root._entry->read_tree(info._path, SORT_NAME);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -129,7 +129,7 @@ FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info)
|
|||
lstrcpy(_root._fs, TEXT("NTOBJ"));
|
||||
lstrcpy(_root._path, drv);
|
||||
_root._entry = new NtObjDirectory(_root._path);
|
||||
entry = _root._entry->read_tree(info._path, SORT_NAME/*_sortOrder*/);
|
||||
entry = _root._entry->read_tree(info._path, SORT_NAME);
|
||||
}
|
||||
else if (info._etype == ET_REGISTRY)
|
||||
{
|
||||
|
@ -141,7 +141,7 @@ FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info)
|
|||
lstrcpy(_root._fs, TEXT("Registry"));
|
||||
lstrcpy(_root._path, drv);
|
||||
_root._entry = new RegistryRoot();
|
||||
entry = _root._entry->read_tree(info._path, SORT_NAME/*_sortOrder*/);
|
||||
entry = _root._entry->read_tree(info._path, SORT_NONE);
|
||||
}
|
||||
else //if (info._etype == ET_WINDOWS)
|
||||
{
|
||||
|
@ -152,7 +152,7 @@ FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info)
|
|||
GetVolumeInformation(drv, _root._volname, _MAX_FNAME, 0, 0, &_root._fs_flags, _root._fs, _MAX_DIR);
|
||||
lstrcpy(_root._path, drv);
|
||||
_root._entry = new WinDirectory(_root._path);
|
||||
entry = _root._entry->read_tree(info._path, SORT_NAME/*_sortOrder*/);
|
||||
entry = _root._entry->read_tree(info._path, SORT_NAME);
|
||||
}
|
||||
|
||||
if (info._etype != ET_SHELL)
|
||||
|
|
|
@ -149,23 +149,23 @@ struct UnicodeString : public RtlUnicodeString {
|
|||
};
|
||||
|
||||
|
||||
static DWORD NtOpenObject(OBJECT_TYPE type, HANDLE* phandle, DWORD flags, LPCWSTR path/*, BOOL xflag=FALSE*/)
|
||||
static DWORD NtOpenObject(OBJECT_TYPE type, HANDLE* phandle, DWORD access, LPCWSTR path/*, BOOL xflag=FALSE*/)
|
||||
{
|
||||
UnicodeString ustr(path);
|
||||
OpenStruct open_struct = {sizeof(OpenStruct), 0x00, &ustr, 0x40};
|
||||
|
||||
if (type==SYMBOLICLINK_OBJECT || type==DIRECTORY_OBJECT)
|
||||
flags |= 1; //@@ ENUMERATE
|
||||
access |= FILE_LIST_DIRECTORY;
|
||||
|
||||
/* if (xflag)
|
||||
flags |= 0x80000000; */
|
||||
access |= GENERIC_READ; */
|
||||
|
||||
DWORD retx;
|
||||
DWORD ioStatusBlock[2]; // IO_STATUS_BLOCK
|
||||
|
||||
if (type>=DIRECTORY_OBJECT && type<=IOCOMPLETITION_OBJECT)
|
||||
return g_NTDLL->_ObjectOpenFunctions[type](phandle, flags|0x20000, &open_struct);
|
||||
return g_NTDLL->_ObjectOpenFunctions[type](phandle, access|STANDARD_RIGHTS_READ, &open_struct);
|
||||
else if (type == FILE_OBJECT)
|
||||
return (*g_NTDLL->NtOpenFile)(phandle, flags, &open_struct, &retx, 7, 0);
|
||||
return (*g_NTDLL->NtOpenFile)(phandle, access, &open_struct, ioStatusBlock, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, 0/*OpenOptions*/);
|
||||
else
|
||||
return ERROR_INVALID_FUNCTION;
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ void NtObjDirectory::read_directory(int scan_flags)
|
|||
--w;
|
||||
#endif
|
||||
|
||||
DWORD idx1, idx2;
|
||||
DWORD idx;
|
||||
HANDLE dir_handle;
|
||||
|
||||
#ifdef UNICODE
|
||||
|
@ -218,9 +218,9 @@ void NtObjDirectory::read_directory(int scan_flags)
|
|||
#endif
|
||||
|
||||
if (_type == DIRECTORY_OBJECT) {
|
||||
NtObjectInfo* info = (NtObjectInfo*)alloca(0x800);
|
||||
NtObjectInfo* info = (NtObjectInfo*)alloca(2048);
|
||||
|
||||
if (!(*g_NTDLL->NtQueryDirectoryObject)(dir_handle, info, 0x800, TRUE, TRUE, &idx1, &idx2)) {
|
||||
if (!(*g_NTDLL->NtQueryDirectoryObject)(dir_handle, info, 2048, TRUE, TRUE, &idx, NULL)) {
|
||||
WIN32_FIND_DATA w32fd;
|
||||
Entry* last = NULL;
|
||||
Entry* entry;
|
||||
|
@ -288,7 +288,7 @@ void NtObjDirectory::read_directory(int scan_flags)
|
|||
NtObject object;
|
||||
DWORD read;
|
||||
|
||||
if (!(*g_NTDLL->NtQueryObject)(handle, 0, &object, sizeof(NtObject), &read)) {
|
||||
if (!(*g_NTDLL->NtQueryObject)(handle, 0/*ObjectBasicInformation*/, &object, sizeof(NtObject), &read)) {
|
||||
memcpy(&w32fd.ftCreationTime, &object.creation_time, sizeof(FILETIME));
|
||||
|
||||
memset(&entry->_bhfi, 0, sizeof(BY_HANDLE_FILE_INFORMATION));
|
||||
|
@ -313,7 +313,7 @@ void NtObjDirectory::read_directory(int scan_flags)
|
|||
entry->_level = level;
|
||||
|
||||
last = entry;
|
||||
} while(!(*g_NTDLL->NtQueryDirectoryObject)(dir_handle, info, 0x800, TRUE, FALSE, &idx1, &idx2));
|
||||
} while(!(*g_NTDLL->NtQueryDirectoryObject)(dir_handle, info, 2048, TRUE, FALSE, &idx, NULL));
|
||||
|
||||
last->_next = NULL;
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ RegDirectory::RegDirectory(Entry* parent, LPCTSTR path, HKEY hKeyRoot)
|
|||
|
||||
void RegistryRoot::read_directory(int scan_flags)
|
||||
{
|
||||
Entry *entry, *last;
|
||||
Entry *entry, *last, *first_entry;
|
||||
int level = _level + 1;
|
||||
|
||||
_data.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
|
||||
|
@ -251,7 +251,7 @@ void RegistryRoot::read_directory(int scan_flags)
|
|||
_tcscpy(entry->_data.cFileName, TEXT("HKEY_CURRENT_USER"));
|
||||
entry->_level = level;
|
||||
|
||||
_down = entry;
|
||||
first_entry = entry;
|
||||
last = entry;
|
||||
|
||||
entry = new RegDirectory(this, TEXT("\\"), HKEY_LOCAL_MACHINE);
|
||||
|
@ -297,4 +297,7 @@ void RegistryRoot::read_directory(int scan_flags)
|
|||
last = entry;
|
||||
*/
|
||||
last->_next = NULL;
|
||||
|
||||
_down = first_entry;
|
||||
_scanned = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue