Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
2.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1997.
  5. //
  6. // File: testcli.c
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 4-18-97 RichardW Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #include <nt.h>
  18. #include <ntrtl.h>
  19. #include <nturtl.h>
  20. #include <wxlpc.h>
  21. char _hex[] = "0123456789abcdef" ;
  22. #define fromhex(x) _hex[x & 0xF]
  23. UCHAR GoodMatch[16] = { 0xf3, 0xd5, 0xae, 0xc5,
  24. 0x03, 0xa4, 0xde, 0x02,
  25. 0xb0, 0x74, 0xe2, 0xf9,
  26. 0xc2, 0x04, 0xd9, 0x06 };
  27. VOID
  28. DumpBits(
  29. CHAR * Data,
  30. CHAR * Tag
  31. )
  32. {
  33. ULONG i ;
  34. CHAR Text[ 80 ] ;
  35. CHAR Text2[ 80 ];
  36. PCHAR Str ;
  37. PCHAR Str2 ;
  38. Str = Text ;
  39. Str2 = Text2 ;
  40. for (i = 0 ; i < 16 ; i++ )
  41. {
  42. *Str = fromhex( (Data[i] >> 4) );
  43. Str++;
  44. *Str = fromhex( Data[i] );
  45. Str++;
  46. *Str = ' ';
  47. Str++ ;
  48. if ( Data[i] >= 32 && Data[i] < 128 )
  49. {
  50. *Str2++ = Data[i] ;
  51. }
  52. else
  53. {
  54. *Str2++ = '.';
  55. }
  56. }
  57. *Str++ = '\0';
  58. *Str2++ = '\0';
  59. DbgPrint( "%s\n", Tag );
  60. DbgPrint( "%s %s\n", Text, Text2 );
  61. }
  62. void __cdecl main (int argc, char *argv[])
  63. {
  64. HANDLE hWx ;
  65. NTSTATUS Status ;
  66. UCHAR Data[ 16 ];
  67. ULONG DataLen ;
  68. ULONG tries = 3;
  69. Status = WxConnect( &hWx );
  70. if ( !NT_SUCCESS( Status ) )
  71. {
  72. DbgPrint( "Failed to connect, %x\n", Status );
  73. return;
  74. }
  75. WxReportResults( hWx, STATUS_SUCCESS );
  76. return ;
  77. while ( tries-- )
  78. {
  79. Status = WxGetKeyData( hWx, WxPrompt, sizeof( Data ), Data, &DataLen );
  80. if ( !NT_SUCCESS( Status ) )
  81. {
  82. DbgPrint( "WxGetKeyData FAILED, %x\n", Status );
  83. NtClose( hWx );
  84. return;
  85. }
  86. DumpBits( Data, "WxGetKeyData returned:" );
  87. if ( RtlEqualMemory( Data, GoodMatch, 16 ) )
  88. {
  89. WxReportResults( hWx, STATUS_SUCCESS );
  90. NtClose( hWx );
  91. return;
  92. }
  93. WxReportResults( hWx, STATUS_UNSUCCESSFUL );
  94. DumpBits( GoodMatch, "Wanted");
  95. }
  96. NtClose( hWx );
  97. }