ntoskrnl.exe: add RtlInitializeGenericTableAvl/RtlInsertElementGenericTableAvl stubs (resend) (1/8)

Sebastian Lackner sebastian at fds-team.de
Tue Nov 10 18:51:02 CST 2015


On 09.11.2015 06:55, Austin English wrote:
> From 8ddf8d4bbdaf8a84b73740495d93035f18a15d20 Mon Sep 17 00:00:00 2001
> From: Austin English <austinenglish at gmail.com>
> Date: Sun, 8 Nov 2015 23:22:31 -0600
> Subject: [PATCH 1/8] ntoskrnl.exe: add
>  RtlInitializeGenericTableAvl/RtlInsertElementGenericTableAvl stubs (resend)
> 
> Signed-off-by: Austin English <austinenglish at gmail.com>
> ---
>  dlls/ntdll/ntdll.spec               |  4 +--
>  dlls/ntdll/rtl.c                    | 16 +++++++++++
>  dlls/ntoskrnl.exe/ntoskrnl.exe.spec |  4 +--
>  include/ddk/ntddk.h                 | 55 ++++++++++++++++++++++++++++++++++++-
>  4 files changed, 74 insertions(+), 5 deletions(-)
> 
> diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
> index 464b233..f9b31ff 100644
> --- a/dlls/ntdll/ntdll.spec
> +++ b/dlls/ntdll/ntdll.spec
> @@ -683,7 +683,7 @@
>  @ stdcall RtlInitializeCriticalSectionAndSpinCount(ptr long)
>  @ stdcall RtlInitializeCriticalSectionEx(ptr long long)
>  @ stdcall RtlInitializeGenericTable(ptr ptr ptr ptr ptr)
> -# @ stub RtlInitializeGenericTableAvl
> +@ stdcall RtlInitializeGenericTableAvl(ptr ptr ptr ptr ptr)
>  @ stdcall RtlInitializeHandleTable(long long ptr)
>  @ stub RtlInitializeRXact
>  # @ stub RtlInitializeRangeList
> @@ -693,7 +693,7 @@
>  @ stdcall RtlInitializeSid(ptr ptr long)
>  # @ stub RtlInitializeStackTraceDataBase
>  @ stub RtlInsertElementGenericTable
> -# @ stub RtlInsertElementGenericTableAvl
> +@ stdcall RtlInsertElementGenericTableAvl(ptr ptr long ptr)
>  @ cdecl -arch=x86_64 RtlInstallFunctionTableCallback(long long long ptr ptr wstr)
>  @ stdcall RtlInt64ToUnicodeString(int64 long ptr)
>  @ stdcall RtlIntegerToChar(long long long ptr)
> diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c
> index 8eb3e9f..0ca27c2 100644
> --- a/dlls/ntdll/rtl.c
> +++ b/dlls/ntdll/rtl.c
> @@ -1595,3 +1595,19 @@ void WINAPI RtlGetCurrentProcessorNumberEx(PROCESSOR_NUMBER *processor)
>      processor->Number = NtGetCurrentProcessorNumber();
>      processor->Reserved = 0;
>  }
> +
> +/***********************************************************************
> + *           RtlInitializeGenericTableAvl  (NTOSKRNL.EXE.@)

Your implementation is in NTDLL, so it would be better to write that in the comment above.

> + */
> +void WINAPI RtlInitializeGenericTableAvl(void *table, void *compare, void *allocate, void *free, void *context)

According to MSDN all those parameters are documented. You also added them to the include below,
why do you not use them here? We'll need them anyway sooner or later, when someone is going to
implement them.

> +{
> +    FIXME("%p %p %p %p %p: stub\n", table, compare, allocate, free, context);
> +}
> +
> +/***********************************************************************
> + *           RtlInsertElementGenericTableAvl  (NTOSKRNL.EXE.@)

NTOSKRNL -> NTDLL, as above.

> + */
> +void WINAPI RtlInsertElementGenericTableAvl(void *table, void *buffer, long size, BOOL *element)

I would also recommend to use the real types here. Especially "long" should be avoided because
it has a different size depending on the architecture. The correct type for the third parameter
seems to be CLONG = ULONG.

> +{
> +    FIXME("%p %p %lu %p: stub\n", table, buffer, size, element);

After fixing the types above, you'll have to replace %lu -> %u.

> +}
> diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
> index 1957a9a..7690268 100644
> --- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
> +++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
> @@ -1055,12 +1055,12 @@
>  @ stdcall RtlInitUnicodeString(ptr wstr) ntdll.RtlInitUnicodeString
>  @ stdcall RtlInitializeBitMap(ptr long long) ntdll.RtlInitializeBitMap
>  @ stdcall RtlInitializeGenericTable(ptr ptr ptr ptr ptr) ntdll.RtlInitializeGenericTable
> -@ stub RtlInitializeGenericTableAvl
> +@ stdcall RtlInitializeGenericTableAvl(ptr ptr ptr ptr ptr) ntdll.RtlInitializeGenericTableAvl
>  @ stub RtlInitializeRangeList
>  @ stdcall RtlInitializeSid(ptr ptr long) ntdll.RtlInitializeSid
>  @ stub RtlInitializeUnicodePrefix
>  @ stub RtlInsertElementGenericTable
> -@ stub RtlInsertElementGenericTableAvl
> +@ stdcall RtlInsertElementGenericTableAvl(ptr ptr long ptr) ntdll.RtlInsertElementGenericTableAvl
>  @ stub RtlInsertElementGenericTableFull
>  @ stub RtlInsertElementGenericTableFullAvl
>  @ stub RtlInsertUnicodePrefix
> diff --git a/include/ddk/ntddk.h b/include/ddk/ntddk.h
> index bccfd39..6f656a3 100644
> --- a/include/ddk/ntddk.h
> +++ b/include/ddk/ntddk.h
> @@ -149,6 +149,59 @@ typedef struct _KWAIT_BLOCK {
>      USHORT WaitType;
>  } KWAIT_BLOCK, *PKWAIT_BLOCK, *RESTRICTED_POINTER PRKWAIT_BLOCK;
>  
> +typedef struct _RTL_BALANCED_LINKS {
> +    struct _RTL_BALANCED_LINKS *parent;
> +    struct _RTL_BALANCED_LINKS *left_child;
> +    struct _RTL_BALANCED_LINKS *right_child;
> +    CHAR balance;
> +    UCHAR reserved[3];
> +} RTL_BALANCED_LINKS;
> +typedef RTL_BALANCED_LINKS *PRTL_BALANCED_LINKS;

Not sure which headers you are using, but basically all of the information I found says
those struct members should be called "Parent", "LeftChild", "RightChild", and so on.
Did you rename them? Please note that this doesn't work, the header files should be
compatible with Windows.

> +
> +struct _RTL_AVL_TABLE;
> +
> +typedef enum _RTL_GENERIC_COMPARE_RESULTS {
> +    generic_less_than,
> +    generic_greater_than,
> +    generic_qual
> +} RTL_GENERIC_COMPARE_RESULTS;

Same here, it should probably be "GenericLessThan", "GenericGreaterThan", and so on.
> +
> +RTL_GENERIC_COMPARE_RESULTS WINAPI RTL_AVL_COMPARE_ROUTINE (
> +    struct _RTL_AVL_TABLE *table,
> +    void *struct1,
> +    void *struct2
> +);

There is no need to keep the formatting the same. Something like:

RTL_GENERIC_COMPARE_RESULTS WINAPI RTL_AVL_COMPARE_ROUTINE(struct _RTL_AVL_TABLE *, void *, void *);

Would also work, for example. You could even merge it with the line below:

typedef RTL_GENERIC_COMPARE_RESULTS (WINAPI *PRTL_AVL_COMPARE_ROUTINE)(struct _RTL_AVL_TABLE *, void *, void *);

> +
> +typedef enum RTL_AVL_COMPARE_ROUTINE *PRTL_AVL_COMPARE_ROUTINE;

RTL_AVL_COMPARE_ROUTINE is not an enumeration.

> +
> +void WINAPI RTL_AVL_ALLOCATE_ROUTINE (
> +    struct _RTL_AVL_TABLE *table,
> +    LONG size
> +);
> +
> +typedef enum RTL_AVL_ALLOCATE_ROUTINE *PRTL_AVL_ALLOCATE_ROUTINE;
> +
> +void WINAPI RTL_AVL_FREE_ROUTINE (
> +    struct _RTL_AVL_TABLE *table,
> +    void *buffer
> +);
> +
> +typedef enum RTL_AVL_FREE_ROUTINE *PRTL_AVL_FREE_ROUTINE;
> +
> +typedef struct _RTL_AVL_TABLE {
> +    RTL_BALANCED_LINKS balanced_root;
> +    void *ordered_pointer;
> +    ULONG which_ordered_element;
> +    ULONG number_generic_table_elements;
> +    ULONG tree_depth;
> +    PRTL_BALANCED_LINKS restart_key;
> +    ULONG delete_count;
> +    PRTL_AVL_COMPARE_ROUTINE compare_routine;
> +    PRTL_AVL_ALLOCATE_ROUTINE allocate_routine;
> +    PRTL_AVL_FREE_ROUTINE free_routine;
> +    void *table_context;
> +} RTL_AVL_TABLE, *PRTL_AVL_TABLE;

The struct members of RTL_AVL_TABLE also don't match my header files.

> +
>  typedef VOID (WINAPI *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)(PVOID,PVOID);
>  typedef VOID (WINAPI *PDRIVER_REINITIALIZE)(PDRIVER_OBJECT,PVOID,ULONG);
>  typedef VOID (WINAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)(PUNICODE_STRING,HANDLE,PIMAGE_INFO);
> @@ -160,5 +213,5 @@ NTSTATUS  WINAPI IoQueryDeviceDescription(PINTERFACE_TYPE,PULONG,PCONFIGURATION_
>  void      WINAPI IoRegisterDriverReinitialization(PDRIVER_OBJECT,PDRIVER_REINITIALIZE,PVOID);
>  NTSTATUS  WINAPI IoRegisterShutdownNotification(PDEVICE_OBJECT);
>  NTSTATUS  WINAPI PsSetLoadImageNotifyRoutine(PLOAD_IMAGE_NOTIFY_ROUTINE);
> -
> +void      WINAPI RtlInitializeGenericTableAvl(PRTL_AVL_TABLE, PRTL_AVL_COMPARE_ROUTINE, PRTL_AVL_ALLOCATE_ROUTINE, PRTL_AVL_FREE_ROUTINE, VOID *);

Is there any reason why you only add one of both functions?

>  #endif
> -- 2.6.2
> 

BTW: You could also think about moving all those definitions to winternl.h. It already contains
definitions for many other Rtl* functions, and those AVL tree functions are probably also useful
for other parts of Wine, in the long term - not just for ntoskrnl.




More information about the wine-devel mailing list