From c2cb29627703d7cbcff9edef0fa22ec9a14eb790 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Tue, 6 Mar 2007 16:33:26 -0800 Subject: [PATCH] ntdll: Implement NtAllocateLocallyUniqueId with server call. --- dlls/ntdll/nt.c | 23 +++++++++++++---------- include/wine/server_protocol.h | 22 +++++++++++++++++++++- server/protocol.def | 12 ++++++++++++ server/request.h | 2 ++ server/token.c | 9 +++++++++ server/trace.c | 18 ++++++++++++++++++ tools/make_requests | 1 + 7 files changed, 76 insertions(+), 11 deletions(-) diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c index ce3c31a33ed..4158f4ee4d7 100644 --- a/dlls/ntdll/nt.c +++ b/dlls/ntdll/nt.c @@ -1090,25 +1090,28 @@ NTSTATUS WINAPI NtShutdownSystem(SHUTDOWN_ACTION Action) /****************************************************************************** * NtAllocateLocallyUniqueId (NTDLL.@) - * - * FIXME: the server should do that */ NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID Luid) { - static LUID luid = { SE_MAX_WELL_KNOWN_PRIVILEGE, 0 }; + NTSTATUS status; - FIXME("%p\n", Luid); + TRACE("%p\n", Luid); if (!Luid) return STATUS_ACCESS_VIOLATION; - luid.LowPart++; - if (luid.LowPart==0) - luid.HighPart++; - Luid->HighPart = luid.HighPart; - Luid->LowPart = luid.LowPart; + SERVER_START_REQ( allocate_locally_unique_id ) + { + status = wine_server_call( req ); + if (!status) + { + Luid->LowPart = reply->luid.low_part; + Luid->HighPart = reply->luid.high_part; + } + } + SERVER_END_REQ; - return STATUS_SUCCESS; + return status; } /****************************************************************************** diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 02851dc55fc..db9309a91e5 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -187,6 +187,12 @@ typedef struct unsigned short attr; } char_info_t; +typedef struct +{ + unsigned int low_part; + int high_part; +} luid_t; + #define MAX_ACL_LEN 65535 struct security_descriptor @@ -4005,6 +4011,17 @@ struct get_token_impersonation_level_reply }; +struct allocate_locally_unique_id_request +{ + struct request_header __header; +}; +struct allocate_locally_unique_id_reply +{ + struct reply_header __header; + luid_t luid; +}; + + enum request { REQ_new_process, @@ -4224,6 +4241,7 @@ enum request REQ_query_symlink, REQ_get_object_info, REQ_get_token_impersonation_level, + REQ_allocate_locally_unique_id, REQ_NB_REQUESTS }; @@ -4448,6 +4466,7 @@ union generic_request struct query_symlink_request query_symlink_request; struct get_object_info_request get_object_info_request; struct get_token_impersonation_level_request get_token_impersonation_level_request; + struct allocate_locally_unique_id_request allocate_locally_unique_id_request; }; union generic_reply { @@ -4670,8 +4689,9 @@ union generic_reply struct query_symlink_reply query_symlink_reply; struct get_object_info_reply get_object_info_reply; struct get_token_impersonation_level_reply get_token_impersonation_level_reply; + struct allocate_locally_unique_id_reply allocate_locally_unique_id_reply; }; -#define SERVER_PROTOCOL_VERSION 279 +#define SERVER_PROTOCOL_VERSION 280 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/server/protocol.def b/server/protocol.def index d88bbe89c82..f3175a386cb 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -203,6 +203,12 @@ typedef struct unsigned short attr; } char_info_t; +typedef struct +{ + unsigned int low_part; + int high_part; +} luid_t; + #define MAX_ACL_LEN 65535 struct security_descriptor @@ -2870,3 +2876,9 @@ enum message_type @REPLY int impersonation_level; /* impersonation level of the impersonation token */ @END + +/* Allocate a locally-unique identifier */ +@REQ(allocate_locally_unique_id) +@REPLY + luid_t luid; +@END diff --git a/server/request.h b/server/request.h index b24d7c7a9e4..44bab110071 100644 --- a/server/request.h +++ b/server/request.h @@ -327,6 +327,7 @@ DECL_HANDLER(open_symlink); DECL_HANDLER(query_symlink); DECL_HANDLER(get_object_info); DECL_HANDLER(get_token_impersonation_level); +DECL_HANDLER(allocate_locally_unique_id); #ifdef WANT_REQUEST_HANDLERS @@ -550,6 +551,7 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] = (req_handler)req_query_symlink, (req_handler)req_get_object_info, (req_handler)req_get_token_impersonation_level, + (req_handler)req_allocate_locally_unique_id, }; #endif /* WANT_REQUEST_HANDLERS */ diff --git a/server/token.c b/server/token.c index 278b6d173ff..3fc6bc3acf4 100644 --- a/server/token.c +++ b/server/token.c @@ -365,6 +365,15 @@ static inline void allocate_luid( LUID *luid ) *luid = prev_luid_value; } +DECL_HANDLER( allocate_locally_unique_id ) +{ + LUID luid; + + allocate_luid( &luid ); + reply->luid.low_part = luid.LowPart; + reply->luid.high_part = luid.HighPart; +} + static inline void luid_and_attr_from_privilege( LUID_AND_ATTRIBUTES *out, const struct privilege *in) { out->Luid = in->luid; diff --git a/server/trace.c b/server/trace.c index 56cc7f678a5..01c873fbad8 100644 --- a/server/trace.c +++ b/server/trace.c @@ -239,6 +239,11 @@ static void dump_apc_result( const apc_result_t *result ) fputc( '}', stderr ); } +static void dump_luid( const luid_t *luid ) +{ + fprintf( stderr, "%d.%u", luid->high_part, luid->low_part ); +} + static void dump_context( const CONTEXT *context ) { #ifdef __i386__ @@ -3454,6 +3459,16 @@ static void dump_get_token_impersonation_level_reply( const struct get_token_imp fprintf( stderr, " impersonation_level=%d", req->impersonation_level ); } +static void dump_allocate_locally_unique_id_request( const struct allocate_locally_unique_id_request *req ) +{ +} + +static void dump_allocate_locally_unique_id_reply( const struct allocate_locally_unique_id_reply *req ) +{ + fprintf( stderr, " luid=" ); + dump_luid( &req->luid ); +} + static const dump_func req_dumpers[REQ_NB_REQUESTS] = { (dump_func)dump_new_process_request, (dump_func)dump_get_new_process_info_request, @@ -3672,6 +3687,7 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = { (dump_func)dump_query_symlink_request, (dump_func)dump_get_object_info_request, (dump_func)dump_get_token_impersonation_level_request, + (dump_func)dump_allocate_locally_unique_id_request, }; static const dump_func reply_dumpers[REQ_NB_REQUESTS] = { @@ -3892,6 +3908,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = { (dump_func)dump_query_symlink_reply, (dump_func)dump_get_object_info_reply, (dump_func)dump_get_token_impersonation_level_reply, + (dump_func)dump_allocate_locally_unique_id_reply, }; static const char * const req_names[REQ_NB_REQUESTS] = { @@ -4112,6 +4129,7 @@ static const char * const req_names[REQ_NB_REQUESTS] = { "query_symlink", "get_object_info", "get_token_impersonation_level", + "allocate_locally_unique_id", }; static const struct diff --git a/tools/make_requests b/tools/make_requests index 9f110f97475..8cbe5390183 100755 --- a/tools/make_requests +++ b/tools/make_requests @@ -44,6 +44,7 @@ my %formats = "char_info_t" => "&dump_char_info", "apc_call_t" => "&dump_apc_call", "apc_result_t" => "&dump_apc_result", + "luid_t" => "&dump_luid", ); my @requests = ();