diff --git a/include/toksvc/toksvc.h b/include/toksvc/toksvc.h index 334b370..c6a6c57 100644 --- a/include/toksvc/toksvc.h +++ b/include/toksvc/toksvc.h @@ -120,7 +120,12 @@ enum toks_warning_level { TOKS_WARNING_LEVEL_NONE, }; -struct _nt_guid; +struct toks_uuid { + uint32_t data1; + uint16_t data2; + uint16_t data3; + unsigned char data4[8]; +}; struct toks_source_version { int major; @@ -134,7 +139,7 @@ struct toks_token_string{ }; struct toks_service_info { - struct _nt_guid uuid; + struct toks_uuid uuid; int32_t syspid; int32_t systid; int32_t ctrlpid; @@ -163,7 +168,7 @@ struct toks_common_ctx { uint64_t actflags; uint64_t fmtflags; int32_t loglevel; - const struct _nt_guid * uuid; + const struct toks_uuid * uuid; void * hroot; const char * sysroot; const char * logfile; @@ -208,9 +213,9 @@ toks_api int toks_output_error_record (const struct toks_driver_ctx *, const s toks_api int toks_output_error_vector (const struct toks_driver_ctx *); /* helper api */ -toks_api int toks_uuid_from_path (const char *, struct _nt_guid *); -toks_api int toks_string_to_guid (const char (*)[40], struct _nt_guid *); -toks_api void toks_guid_to_string (const struct _nt_guid *, char (*)[40]); +toks_api int toks_uuid_from_path (const char *, struct toks_uuid *); +toks_api int toks_string_to_uuid (const char (*)[40], struct toks_uuid *); +toks_api void toks_uuid_to_string (const struct toks_uuid *, char (*)[40]); /* package info */ toks_api const struct toks_source_version * toks_source_version(void); diff --git a/src/client/toks_client_connect.c b/src/client/toks_client_connect.c index e3dddfd..ca06103 100644 --- a/src/client/toks_client_connect.c +++ b/src/client/toks_client_connect.c @@ -28,7 +28,7 @@ int32_t toks_client_connect(struct toks_driver_ctx * dctx) 1}; ntapi->tt_guid_to_string_utf16( - toks_get_driver_uuid(dctx), + toks_get_driver_guid(dctx), &guid); name.strlen = sizeof(guid); diff --git a/src/driver/toks_driver_ctx.c b/src/driver/toks_driver_ctx.c index efcfc86..8164323 100644 --- a/src/driver/toks_driver_ctx.c +++ b/src/driver/toks_driver_ctx.c @@ -373,7 +373,7 @@ static int32_t toks_set_tmpfs_from_uuid(struct toks_driver_ctx_impl * ctx) /* instance-specific tmpfs root */ ntapi->tt_guid_to_string_utf16( - &ctx->uuid, + &ctx->guid, &guidstr); path.maxlen = 0; @@ -778,7 +778,7 @@ int toks_get_driver_ctx( if (uuid) { ntapi->tt_guid_copy( - &ctx->uuid, + &ctx->guid, &svcguid); } else if (cctx.drvflags & TOKS_DRIVER_ROOT_UUID) { @@ -792,11 +792,11 @@ int toks_get_driver_ctx( } ntapi->tt_guid_copy( - &ctx->uuid, + &ctx->guid, &svcguid); } else { ntapi->tt_guid_copy( - &ctx->uuid, + &ctx->guid, &ctx->rtdata->srv_guid); } @@ -841,6 +841,7 @@ int toks_get_driver_ctx( ctx->rtdata->hlog = hlog ? hlog : ctx->rtdata->hlog; toks_set_driver_refstr(&ctx->ctx,refstr); + toks_guid_to_uuid(&ctx->guid,&ctx->uuid); if (cctx.drvflags & TOKS_DRIVER_MODE_SERVER) { if ((status = toks_set_tmpfs_from_uuid(ctx))) { @@ -867,7 +868,7 @@ int toks_get_driver_ctx( if (!(ctx->tokens = toks_calloc(atokens,sizeof(*ctx->tokens)))) return toks_get_driver_ctx_fail(meta); - if (toks_daemon_init(&toks_daemon_ctx,&ctx->uuid)) + if (toks_daemon_init(&toks_daemon_ctx,&ctx->guid)) return toks_get_driver_ctx_fail(meta); } diff --git a/src/helper/toks_guid_string.c b/src/helper/toks_guid_string.c index 46ab01d..0ee7133 100644 --- a/src/helper/toks_guid_string.c +++ b/src/helper/toks_guid_string.c @@ -14,24 +14,35 @@ #include "toksvc_driver_impl.h" #include "toksvc_nolibc_impl.h" -int toks_string_to_guid(const char (*guidstr)[40], struct _nt_guid * uuid) +int toks_string_to_uuid(const char (*guidstr)[40], struct toks_uuid * uuid) { + int32_t status; + struct _nt_guid guid; + toks_init(); - return ntapi->tt_string_to_guid_utf8( - guidstr[0],uuid); + status = ntapi->tt_string_to_guid_utf8( + guidstr[0],&guid); + + if (status == NT_STATUS_SUCCESS) + toks_guid_to_uuid(&guid,uuid); + + return status; } -void toks_guid_to_string(const struct _nt_guid * uuid, char (*guidstr)[40]) +void toks_uuid_to_string(const struct toks_uuid * uuid, char (*guidstr)[40]) { struct _nt_guid_str_utf8 buf; void * addr; char * ch; + struct _nt_guid guid; toks_init(); + toks_uuid_to_guid(uuid,&guid); + ntapi->tt_guid_to_string_utf8( - uuid,&buf); + &guid,&buf); addr = &buf.lbrace; ch = addr; diff --git a/src/helper/toks_uuid_from_path.c b/src/helper/toks_uuid_from_path.c index 34fc83a..d8f5d04 100644 --- a/src/helper/toks_uuid_from_path.c +++ b/src/helper/toks_uuid_from_path.c @@ -22,7 +22,7 @@ static int32_t toks_uuid_path_open(void ** hfile, const char * path) : NT_STATUS_SUCCESS; } -int toks_uuid_from_path(const char * path, struct _nt_guid * uuid) +int toks_uuid_from_path(const char * path, struct toks_uuid * uuid) { int32_t status; void * hfile; diff --git a/src/internal/toksvc_driver_impl.h b/src/internal/toksvc_driver_impl.h index a18939e..630d2d2 100644 --- a/src/internal/toksvc_driver_impl.h +++ b/src/internal/toksvc_driver_impl.h @@ -78,9 +78,42 @@ struct toks_driver_ctx_impl { int tsyspid; int ctrlpid; int csyspid; - nt_guid uuid; + struct toks_uuid uuid; + struct _nt_guid guid; }; +static inline void toks_uuid_to_guid(const struct toks_uuid * uuid, struct _nt_guid * guid) +{ + guid->data1 = uuid->data1; + guid->data2 = uuid->data2; + guid->data3 = uuid->data3; + + guid->data4[0] = uuid->data4[0]; + guid->data4[1] = uuid->data4[1]; + guid->data4[2] = uuid->data4[2]; + guid->data4[3] = uuid->data4[3]; + guid->data4[4] = uuid->data4[4]; + guid->data4[5] = uuid->data4[5]; + guid->data4[6] = uuid->data4[6]; + guid->data4[7] = uuid->data4[7]; +} + +static inline void toks_guid_to_uuid(const struct _nt_guid * guid, struct toks_uuid * uuid) +{ + uuid->data1 = guid->data1; + uuid->data2 = guid->data2; + uuid->data3 = guid->data3; + + uuid->data4[0] = guid->data4[0]; + uuid->data4[1] = guid->data4[1]; + uuid->data4[2] = guid->data4[2]; + uuid->data4[3] = guid->data4[3]; + uuid->data4[4] = guid->data4[4]; + uuid->data4[5] = guid->data4[5]; + uuid->data4[6] = guid->data4[6]; + uuid->data4[7] = guid->data4[7]; +} + static inline struct toks_driver_ctx_impl * toks_get_driver_ictx(const struct toks_driver_ctx * dctx) { uintptr_t addr; @@ -198,13 +231,20 @@ static inline struct _nt_port_keys * toks_get_driver_keys(const struct toks_driv return &ictx->keys; } -static inline const nt_guid * toks_get_driver_uuid(const struct toks_driver_ctx * dctx) +static inline const struct toks_uuid * toks_get_driver_uuid(const struct toks_driver_ctx * dctx) { struct toks_driver_ctx_impl * ictx; ictx = toks_get_driver_ictx(dctx); return &ictx->uuid; } +static inline const struct _nt_guid * toks_get_driver_guid(const struct toks_driver_ctx * dctx) +{ + struct toks_driver_ctx_impl * ictx; + ictx = toks_get_driver_ictx(dctx); + return &ictx->guid; +} + static inline int toks_get_driver_nwaiters(const struct toks_driver_ctx * dctx) { struct toks_driver_ctx_impl * ictx; diff --git a/src/log/toks_log_service_info.c b/src/log/toks_log_service_info.c index 656011d..d57edc3 100644 --- a/src/log/toks_log_service_info.c +++ b/src/log/toks_log_service_info.c @@ -28,7 +28,7 @@ void toks_log_service_info(struct toks_daemon_ctx * dctx) toks_log_get_arbitrary_process_name( &cid,path,sizeof(path)); - toks_guid_to_string(drvctx->cctx->uuid,&uuid); + toks_uuid_to_string(drvctx->cctx->uuid,&uuid); toks_log_header( drvctx, diff --git a/src/service/toks_service_start.c b/src/service/toks_service_start.c index 9b32935..03fd43a 100644 --- a/src/service/toks_service_start.c +++ b/src/service/toks_service_start.c @@ -85,7 +85,7 @@ static int toks_spawn_impl( *pearg++ = logbuf; if (cctx->uuid) { - toks_guid_to_string(cctx->uuid,&guidstr); + toks_uuid_to_string(cctx->uuid,&guidstr); *pearg++ = "-u"; *pearg++ = guidstr; }