From 45d0cf852c68706c8df0861762f62dcf4907e422 Mon Sep 17 00:00:00 2001 From: Emanuele Aliberti Date: Sun, 17 Apr 2005 17:50:48 +0000 Subject: [PATCH] sm info ssid - implemented svn path=/trunk/; revision=14651 --- reactos/subsys/system/sm/sm.c | 66 ++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 17 deletions(-) diff --git a/reactos/subsys/system/sm/sm.c b/reactos/subsys/system/sm/sm.c index fed4247c7a3..507da336e8a 100644 --- a/reactos/subsys/system/sm/sm.c +++ b/reactos/subsys/system/sm/sm.c @@ -148,31 +148,63 @@ SM_CMD_DECL(info) { int rc = EXIT_SUCCESS; NTSTATUS Status = STATUS_SUCCESS; - SM_BASIC_INFORMATION bi = {0,}; - ULONG ReturnDataLength = sizeof bi; + SM_INFORMATION_CLASS InformationClass = SmBasicInformation; + union { + SM_BASIC_INFORMATION bi; + SM_SUBSYSTEM_INFORMATION ssi; + } Info; + ULONG DataLength = 0; + ULONG ReturnDataLength = 0; + INT i = 0; + RtlZeroMemory (& Info, sizeof Info); + switch (argc) + { + case 2: /* sm info */ + InformationClass = SmBasicInformation; + DataLength = sizeof Info.bi; + break; + case 3: /* sm info id */ + InformationClass = SmSubSystemInformation; + DataLength = sizeof Info.ssi; + Info.ssi.SubSystemId = atol(argv[2]); + break; + default: + return EXIT_FAILURE; + break; + } Status = SmQueryInformation (hSmApiPort, - SmBasicInformation, - & bi, - sizeof bi, + InformationClass, + & Info, + DataLength, & ReturnDataLength); - if (STATUS_SUCCESS == Status) + if (STATUS_SUCCESS != Status) { - int i = 0; - + printf ("Status 0x%08lx\n", Status); + return EXIT_FAILURE; + } + switch (argc) + { + case 2: + printf ("SM SubSystem Directory\n\n"); printf ("SSID PID Flags\n"); - for (i = 0; i < bi.SubSystemCount; i ++) + printf ("---- -------- ------------\n"); + for (i = 0; i < Info.bi.SubSystemCount; i ++) { printf ("%04x %08lx %04x\n", - bi.SubSystem[i].Id, - bi.SubSystem[i].ProcessId, - bi.SubSystem[i].Flags); + Info.bi.SubSystem[i].Id, + Info.bi.SubSystem[i].ProcessId, + Info.bi.SubSystem[i].Flags); } - } - else - { - printf ("Status 0x%08lx\n", Status); - rc = EXIT_FAILURE; + break; + case 3: + printf ("SubSystem ID: %d\n", Info.ssi.SubSystemId); + printf (" Flags: %04x\n", Info.ssi.Flags); + printf (" Process ID: %ld\n", Info.ssi.ProcessId); + wprintf(L" NSRootNode: '%s'\n", Info.ssi.NameSpaceRootNode); + break; + default: + break; } return rc; } -- 2.17.1