ntdll: Implement a number of object functions from object manager
Vitaliy Margolen
wine-patch at kievinfo.com
Sat Sep 3 22:10:17 CDT 2005
Use new server object manager. Some of those functions are a pure guess. Some
i have pocked at on win2k. In this state it is enough to run sysinternals'
winobj with pretty good results <g>
This patch depends on a previous two server patches.
Vitaliy Margolen
changelog:
ntdll: Implement a number of object functions from object manager
-------------- next part --------------
Index: dlls/ntdll/ntdll.spec
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/ntdll.spec,v
retrieving revision 1.198
diff -u -p -r1.198 ntdll.spec
--- dlls/ntdll/ntdll.spec 19 Aug 2005 10:21:17 -0000 1.198
+++ dlls/ntdll/ntdll.spec 3 Sep 2005 23:49:05 -0000
@@ -195,7 +195,7 @@
# @ stub NtLockRegistryKey
@ stdcall NtLockVirtualMemory(long ptr ptr long)
# @ stub NtMakePermanentObject
-@ stub NtMakeTemporaryObject
+@ stdcall NtMakeTemporaryObject(long)
# @ stub NtMapUserPhysicalPages
# @ stub NtMapUserPhysicalPagesScatter
@ stdcall NtMapViewOfSection(long long ptr long long ptr ptr long long long)
@@ -1036,7 +1036,7 @@
# @ stub ZwLockRegistryKey
@ stdcall ZwLockVirtualMemory(long ptr ptr long) NtLockVirtualMemory
# @ stub ZwMakePermanentObject
-@ stub ZwMakeTemporaryObject
+@ stdcall ZwMakeTemporaryObject(long) NtMakeTemporaryObject
# @ stub ZwMapUserPhysicalPages
# @ stub ZwMapUserPhysicalPagesScatter
@ stdcall ZwMapViewOfSection(long long ptr long long ptr ptr long long long) NtMapViewOfSection
Index: dlls/ntdll/om.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/om.c,v
retrieving revision 1.35
diff -u -p -r1.35 om.c
--- dlls/ntdll/om.c 23 Aug 2005 18:43:51 -0000 1.35
+++ dlls/ntdll/om.c 3 Sep 2005 23:49:05 -0000
@@ -60,6 +60,26 @@ NTSTATUS WINAPI NtQueryObject(IN HANDLE
switch (info_class)
{
+ case ObjectBasicInformation:
+ {
+ POBJECT_BASIC_INFORMATION p = (POBJECT_BASIC_INFORMATION)ptr;
+
+ if (len < sizeof(*p)) return STATUS_INVALID_BUFFER_SIZE;
+
+ memset(p, 0, sizeof(*p));
+ SERVER_START_REQ( query_object )
+ {
+ req->handle = handle;
+ status = wine_server_call( req );
+ if (status == STATUS_SUCCESS)
+ {
+ p->Attributes = reply->attributes;
+ p->GrantedAccess = reply->access_mask;
+ p->PointerCount = reply->refcount;
+ }
+ }
+ SERVER_END_REQ;
+ }
case ObjectDataInformation:
{
OBJECT_DATA_INFORMATION* p = (OBJECT_DATA_INFORMATION*)ptr;
@@ -341,6 +361,33 @@ NTSTATUS WINAPI NtClose( HANDLE Handle )
return ret;
}
+/**************************************************************************
+ * NtMakeTemporaryObject [NTDLL.@]
+ * ZwMakeTemporaryObject [NTDLL.@]
+ *
+ * Make any object temporary if it was created as permanent.
+ *
+ * PARAMS
+ * Handle [I] handle an object
+ *
+ * RETURNS
+ * Success: ERROR_SUCCESS.
+ * Failure: An NTSTATUS error code.
+ */
+NTSTATUS WINAPI NtMakeTemporaryObject( HANDLE Handle )
+{
+ NTSTATUS ret;
+ TRACE("(%p): \n", Handle);
+
+ SERVER_START_REQ( make_temporary_object )
+ {
+ req->handle = Handle;
+ ret = wine_server_call( req );
+ }
+ SERVER_END_REQ;
+ return ret;
+}
+
/*
* Directory functions
*/
@@ -365,10 +412,24 @@ NTSTATUS WINAPI NtOpenDirectoryObject(
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes)
{
- FIXME("(%p,0x%08lx,%p): stub\n",
- DirectoryHandle, DesiredAccess, ObjectAttributes);
- dump_ObjectAttributes(ObjectAttributes);
- return 0;
+ NTSTATUS ret;
+ TRACE("(%p,0x%08lx)\n", DirectoryHandle, DesiredAccess);
+ if (TRACE_ON(ntdll)) dump_ObjectAttributes(ObjectAttributes);
+
+ if (!DirectoryHandle || !ObjectAttributes)
+ return STATUS_INVALID_PARAMETER;
+
+ SERVER_START_REQ(open_directory)
+ {
+ req->attributes = ObjectAttributes->Attributes;
+ req->access_mask = DesiredAccess;
+ wine_server_add_data(req, ObjectAttributes->ObjectName->Buffer,
+ ObjectAttributes->ObjectName->Length);
+ ret = wine_server_call( req );
+ *DirectoryHandle = reply->handle;
+ }
+ SERVER_END_REQ;
+ return ret;
}
/******************************************************************************
@@ -380,10 +441,24 @@ NTSTATUS WINAPI NtCreateDirectoryObject(
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes)
{
- FIXME("(%p,0x%08lx,%p),stub!\n",
- DirectoryHandle,DesiredAccess,ObjectAttributes);
- dump_ObjectAttributes(ObjectAttributes);
- return 0;
+ NTSTATUS ret;
+ TRACE("(%p,0x%08lx)\n", DirectoryHandle, DesiredAccess);
+ if (TRACE_ON(ntdll)) dump_ObjectAttributes(ObjectAttributes);
+
+ if (!DirectoryHandle || !ObjectAttributes)
+ return STATUS_INVALID_PARAMETER;
+
+ SERVER_START_REQ(create_directory)
+ {
+ req->attributes = ObjectAttributes->Attributes;
+ req->access_mask = DesiredAccess;
+ wine_server_add_data(req, ObjectAttributes->ObjectName->Buffer,
+ ObjectAttributes->ObjectName->Length);
+ ret = wine_server_call( req );
+ *DirectoryHandle = reply->handle;
+ }
+ SERVER_END_REQ;
+ return ret;
}
/******************************************************************************
@@ -414,10 +489,48 @@ NTSTATUS WINAPI NtQueryDirectoryObject(
IN OUT PULONG ObjectIndex,
OUT PULONG DataWritten OPTIONAL)
{
- FIXME("(%p,%p,0x%08lx,0x%08x,0x%08x,%p,%p) stub\n",
+ NTSTATUS ret;
+ ULONG count, len, reply_size;
+ TRACE("(%p,%p,0x%08lx,0x%08x,0x%08x,%p,%p)\n",
DirObjHandle, DirObjInformation, BufferLength, GetNextIndex,
IgnoreInputIndex, ObjectIndex, DataWritten);
- return 0xc0000000; /* We don't have any. Whatever. (Yet.) */
+
+ if (!ObjectIndex || !DirObjInformation)
+ return STATUS_INVALID_PARAMETER;
+
+ if (IgnoreInputIndex)
+ *ObjectIndex = 0;
+ SERVER_START_REQ(query_directory)
+ {
+ req->handle = DirObjHandle;
+ req->need_count = !GetNextIndex;
+ req->index = *ObjectIndex;
+ wine_server_set_reply( req, DirObjInformation, BufferLength );
+ if (!(ret = wine_server_call( req )))
+ {
+ count = reply->count;
+ len = reply->name_len;
+ reply_size = wine_server_reply_size(reply);
+ }
+ }
+ SERVER_END_REQ;
+ if (!ret)
+ {
+ if (GetNextIndex)
+ (*ObjectIndex)++;
+ else
+ *ObjectIndex = count-1;
+
+ if (DataWritten)
+ *DataWritten = reply_size;
+ DirObjInformation->ObjectName.Length = len;
+ DirObjInformation->ObjectName.MaximumLength = len;
+ DirObjInformation->ObjectName.Buffer = (WCHAR*)DirObjInformation->Data;
+ DirObjInformation->ObjectTypeName.Length = reply_size - len - sizeof(*DirObjInformation) + 1;
+ DirObjInformation->ObjectTypeName.MaximumLength = DirObjInformation->ObjectTypeName.Length;
+ DirObjInformation->ObjectTypeName.Buffer = (WCHAR*)(DirObjInformation->Data + len);
+ }
+ return ret;
}
/*
@@ -432,10 +545,24 @@ NTSTATUS WINAPI NtOpenSymbolicLinkObject
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes)
{
- FIXME("(%p,0x%08lx,%p) stub\n",
- LinkHandle, DesiredAccess, ObjectAttributes);
- dump_ObjectAttributes(ObjectAttributes);
- return STATUS_OBJECT_NAME_NOT_FOUND;
+ NTSTATUS ret;
+ TRACE("(%p,0x%08lx,%p)\n",LinkHandle, DesiredAccess, ObjectAttributes);
+ if (TRACE_ON(ntdll)) dump_ObjectAttributes(ObjectAttributes);
+
+ if (!LinkHandle || !ObjectAttributes)
+ return STATUS_INVALID_PARAMETER;
+
+ SERVER_START_REQ(open_symlink)
+ {
+ req->attributes = ObjectAttributes->Attributes;
+ req->access_mask = DesiredAccess;
+ wine_server_add_data(req, ObjectAttributes->ObjectName->Buffer,
+ ObjectAttributes->ObjectName->Length);
+ ret = wine_server_call( req );
+ *LinkHandle = reply->handle;
+ }
+ SERVER_END_REQ;
+ return ret;
}
/******************************************************************************
@@ -447,10 +574,28 @@ NTSTATUS WINAPI NtCreateSymbolicLinkObje
IN POBJECT_ATTRIBUTES ObjectAttributes,
IN PUNICODE_STRING Name)
{
- FIXME("(%p,0x%08lx,%p, %p) stub\n",
- SymbolicLinkHandle, DesiredAccess, ObjectAttributes, debugstr_us(Name));
- dump_ObjectAttributes(ObjectAttributes);
- return 0;
+ NTSTATUS ret;
+ TRACE("(%p,0x%08lx,%p, %s)\n",
+ SymbolicLinkHandle, DesiredAccess, ObjectAttributes, debugstr_us(Name));
+ if (TRACE_ON(ntdll)) dump_ObjectAttributes(ObjectAttributes);
+
+ if (!SymbolicLinkHandle || !ObjectAttributes || !Name)
+ return STATUS_INVALID_PARAMETER;
+
+ SERVER_START_REQ(create_symlink)
+ {
+ req->attributes = ObjectAttributes->Attributes;
+ req->access_mask = DesiredAccess;
+ req->symlink_name_len = ObjectAttributes->ObjectName->Length;
+ wine_server_add_data(req, ObjectAttributes->ObjectName->Buffer,
+ ObjectAttributes->ObjectName->Length);
+ wine_server_add_data(req, Name->Buffer,
+ Name->Length);
+ ret = wine_server_call( req );
+ *SymbolicLinkHandle = reply->handle;
+ }
+ SERVER_END_REQ;
+ return ret;
}
/******************************************************************************
@@ -461,10 +606,26 @@ NTSTATUS WINAPI NtQuerySymbolicLinkObjec
IN OUT PUNICODE_STRING LinkTarget,
OUT PULONG ReturnedLength OPTIONAL)
{
- FIXME("(%p,%p,%p) stub\n",
- LinkHandle, debugstr_us(LinkTarget), ReturnedLength);
+ NTSTATUS ret;
+ TRACE("(%p,%p,%p)\n", LinkHandle, debugstr_us(LinkTarget), ReturnedLength);
- return 0;
+ if (!LinkTarget)
+ return STATUS_INVALID_PARAMETER;
+
+ SERVER_START_REQ(query_symlink)
+ {
+ req->handle = LinkHandle;
+ wine_server_set_reply( req, LinkTarget->Buffer, LinkTarget->MaximumLength );
+ if (!(ret = wine_server_call( req )))
+ {
+ size_t len = wine_server_reply_size(reply);
+ LinkTarget->Length = len;
+ if (ReturnedLength)
+ *ReturnedLength = len;
+ }
+ }
+ SERVER_END_REQ;
+ return ret;
}
/******************************************************************************
Index: include/winternl.h
===================================================================
RCS file: /home/wine/wine/include/winternl.h,v
retrieving revision 1.162
diff -u -p -r1.162 winternl.h
--- include/winternl.h 16 Aug 2005 16:01:49 -0000 1.162
+++ include/winternl.h 3 Sep 2005 23:49:07 -0000
@@ -915,6 +915,20 @@ typedef struct _OBJECT_DATA_INFORMATION
BOOLEAN ProtectFromClose;
} OBJECT_DATA_INFORMATION, *POBJECT_DATA_INFORMATION;
+typedef struct _OBJECT_BASIC_INFORMATION {
+ ULONG Attributes;
+ ACCESS_MASK GrantedAccess;
+ ULONG HandleCount;
+ ULONG PointerCount;
+ ULONG PagedPoolUsage;
+ ULONG NonPagedPoolUsage;
+ ULONG Reserved[3];
+ ULONG NameInformationLength;
+ ULONG TypeInformationLength;
+ ULONG SecurityDescriptorLength;
+ LARGE_INTEGER CreateTime;
+} OBJECT_BASIC_INFORMATION, *POBJECT_BASIC_INFORMATION;
+
typedef struct _PROCESS_BASIC_INFORMATION {
#ifdef __WINESRC__
DWORD ExitStatus;
--- /dev/null 2005-03-19 12:36:14.000000000 -0700
+++ include/ddk/winddk.h 2005-09-03 16:48:14.000000000 -0600
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2005 Vitaliy Margolen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __WINDDK_H
+#define __WINDDK_H
+
+/*
+** System structures
+*/
+
+#define SYMBOLIC_LINK_QUERY 0x0001
+#define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
+
+#endif /* __WINDDK_H */
More information about the wine-patches
mailing list