@@ -379,7 +379,7 @@ RegisterHelper(
379379 if (FindHelper (& pHelperAttributes -> guidHelper , pHelperListHead ) != NULL )
380380 {
381381 DPRINT1 ("The Helper has already been registered!\n" );
382- return 1 ;
382+ return ERROR_INVALID_PARAMETER ;
383383 }
384384
385385 pHelper = (PHELPER_ENTRY )HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY , sizeof (HELPER_ENTRY ));
@@ -395,7 +395,7 @@ RegisterHelper(
395395
396396 if (pguidParentHelper == NULL )
397397 {
398- if (pHelperListTail == NULL )
398+ if (( pHelperListHead == NULL ) && ( pHelperListTail == NULL ) )
399399 {
400400 pHelperListHead = pHelper ;
401401 pHelperListTail = pHelper ;
@@ -409,14 +409,15 @@ RegisterHelper(
409409 }
410410 else
411411 {
412+ CopyMemory (& pHelper -> ParentHelperGuid , pguidParentHelper , sizeof (GUID ));
412413 pParentHelper = FindHelper (pguidParentHelper , pHelperListHead );
413414 if (pParentHelper == NULL )
414415 {
415416 DPRINT ("Parent helper not found!\n" );
416417 return ERROR_INVALID_PARAMETER ;
417418 }
418419
419- if (pParentHelper -> pSubHelperHead == NULL && pParentHelper -> pSubHelperTail == NULL )
420+ if (( pParentHelper -> pSubHelperHead == NULL ) && ( pParentHelper -> pSubHelperTail == NULL ) )
420421 {
421422 pParentHelper -> pSubHelperHead = pHelper ;
422423 pParentHelper -> pSubHelperTail = pHelper ;
@@ -534,55 +535,46 @@ DeleteHelperCommand(
534535
535536static
536537VOID
537- PrintSubContext (
538- _In_ PCONTEXT_ENTRY pParentContext ,
538+ PrintHelpers (
539+ _In_ PHELPER_ENTRY pHelperListHead ,
539540 _In_ DWORD dwLevel )
540541{
541- PCONTEXT_ENTRY pContext ;
542542 PHELPER_ENTRY pHelper ;
543- WCHAR szPrefix [22 ];
543+ PCONTEXT_ENTRY pContext ;
544+ WCHAR szIndent [22 ];
544545 DWORD i ;
545546
546- DPRINT ("PrintSubContext(%p %lu)\n" , pParentContext , dwLevel );
547+ for (i = 0 ; i < min (dwLevel , 10 ) * 2 ; i ++ )
548+ szIndent [i ] = L' ' ;
549+ szIndent [dwLevel * 2 ] = UNICODE_NULL ;
547550
548- if (pParentContext == NULL )
549- return ;
550-
551- pContext = pParentContext -> pSubContextHead ;
552- while (pContext != NULL )
551+ pHelper = pHelperListHead ;
552+ while (pHelper != NULL )
553553 {
554- pHelper = FindHelper ( & pContext -> Guid , pHelperListHead );
555- if (pHelper != NULL )
554+ pContext = FindContextByGuid ( & pHelper -> Attributes . guidHelper );
555+ if (pContext )
556556 {
557- if (dwLevel > 10 )
558- dwLevel = 10 ;
559-
560- for (i = 0 ; i < dwLevel * 2 ; i ++ )
561- szPrefix [i ] = L' ' ;
562- szPrefix [dwLevel * 2 ] = UNICODE_NULL ;
563-
564- DPRINT ("Level %lu \"%S\" %S\n" , dwLevel , szPrefix , pContext -> pszContextName );
565-
566- ConPrintf (StdOut , L"{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X} %-16s %s%s\n" ,
567- pHelper -> Attributes .guidHelper .Data1 ,
568- pHelper -> Attributes .guidHelper .Data2 ,
569- pHelper -> Attributes .guidHelper .Data3 ,
570- pHelper -> Attributes .guidHelper .Data4 [0 ],
571- pHelper -> Attributes .guidHelper .Data4 [1 ],
572- pHelper -> Attributes .guidHelper .Data4 [2 ],
573- pHelper -> Attributes .guidHelper .Data4 [3 ],
574- pHelper -> Attributes .guidHelper .Data4 [4 ],
575- pHelper -> Attributes .guidHelper .Data4 [5 ],
576- pHelper -> Attributes .guidHelper .Data4 [6 ],
577- pHelper -> Attributes .guidHelper .Data4 [7 ],
578- pHelper -> pDllEntry -> pszShortName ,
579- szPrefix ,
580- pContext -> pszContextName );
557+ ConPrintf (StdOut ,
558+ L"{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X} %-16s %s%s\n" ,
559+ pHelper -> Attributes .guidHelper .Data1 ,
560+ pHelper -> Attributes .guidHelper .Data2 ,
561+ pHelper -> Attributes .guidHelper .Data3 ,
562+ pHelper -> Attributes .guidHelper .Data4 [0 ],
563+ pHelper -> Attributes .guidHelper .Data4 [1 ],
564+ pHelper -> Attributes .guidHelper .Data4 [2 ],
565+ pHelper -> Attributes .guidHelper .Data4 [3 ],
566+ pHelper -> Attributes .guidHelper .Data4 [4 ],
567+ pHelper -> Attributes .guidHelper .Data4 [5 ],
568+ pHelper -> Attributes .guidHelper .Data4 [6 ],
569+ pHelper -> Attributes .guidHelper .Data4 [7 ],
570+ pHelper -> pDllEntry -> pszShortName ,
571+ szIndent ,
572+ pContext -> pszContextName );
581573 }
582574
583- PrintSubContext ( pContext , dwLevel + 1 );
575+ PrintHelpers ( pHelper -> pSubHelperHead , dwLevel + 1 );
584576
585- pContext = pContext -> pNext ;
577+ pHelper = pHelper -> pNext ;
586578 }
587579}
588580
@@ -606,7 +598,7 @@ ShowHelperCommand(
606598 if (pRootContext == NULL )
607599 return ERROR_SUCCESS ;
608600
609- PrintSubContext ( pRootContext , 0 );
601+ PrintHelpers ( pHelperListHead , 0 );
610602
611603 return ERROR_SUCCESS ;
612604}
0 commit comments