Leaked source code of windows server 2003
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.

154 lines
4.4 KiB

  1. #include <nt.h>
  2. #include <ntrtl.h>
  3. #include <nturtl.h>
  4. #include <windows.h>
  5. #include <winsock2.h>
  6. #include <wsipx.h>
  7. #include <svcguid.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <rpc.h>
  11. #include <rpcdce.h>
  12. GUID ServiceClassId = { /* 5b50962a-e5a5-11cf-a555-00c04fd8d4ac */
  13. 0x5b50962a,
  14. 0xe5a5,
  15. 0x11cf,
  16. {0xa5, 0x55, 0x00, 0xc0, 0x4f, 0xd8, 0xd4, 0xac}
  17. };
  18. GUID CLSID_ILSServicClass = { /* C9F17940-79A7-11d1-B008-00C04FC31FEE */
  19. 0xc9f17940,
  20. 0x79a7,
  21. 0x11d1,
  22. {0xb0, 0x8, 0x0, 0xc0, 0x4f, 0xc3, 0x1f, 0xee}
  23. };
  24. #define BUFFSIZE 3000
  25. _cdecl
  26. main(int argc, char **argv)
  27. {
  28. HANDLE hLib;
  29. WCHAR Buffer[BUFFSIZE];
  30. PWSAQUERYSETW Query = (PWSAQUERYSETW)Buffer;
  31. HANDLE hRnr;
  32. DWORD dwIp;
  33. DWORD dwQuerySize = BUFFSIZE;
  34. WSADATA wsaData;
  35. ANSI_STRING asServiceInstanceName;
  36. UNICODE_STRING usServiceInstanceName;
  37. WCHAR UnicodeStringBuf[1024];
  38. ANSI_STRING asContext;
  39. UNICODE_STRING usContext;
  40. WCHAR UnicodeStringBuf2[1024];
  41. AFPROTOCOLS lpAfpProtocols[3];
  42. usServiceInstanceName.Length = 0;
  43. usServiceInstanceName.MaximumLength = 1024;
  44. usServiceInstanceName.Buffer = UnicodeStringBuf;
  45. usContext.Length = 0;
  46. usContext.MaximumLength = 1024;
  47. usContext.Buffer = UnicodeStringBuf2;
  48. if ( argc != 2 )
  49. {
  50. printf( "\nUsage: rnrtst <Name>\n" );
  51. return( -1 );
  52. }
  53. RtlInitAnsiString( &asServiceInstanceName, argv[1] );
  54. RtlAnsiStringToUnicodeString( &usServiceInstanceName,
  55. &asServiceInstanceName,
  56. FALSE );
  57. WSAStartup(MAKEWORD(1, 1), &wsaData);
  58. memset(Query, 0, sizeof(*Query));
  59. Query->dwSize = sizeof(*Query);
  60. if ( usServiceInstanceName.Buffer[0] != L'*' )
  61. {
  62. Query->lpszServiceInstanceName = usServiceInstanceName.Buffer;
  63. }
  64. Query->lpServiceClassId = &CLSID_ILSServicClass;
  65. Query->lpVersion = 0;
  66. Query->dwNameSpace = NS_NTDS;
  67. Query->lpNSProviderId = 0;
  68. Query->lpszContext = NULL;
  69. Query->dwNumberOfProtocols = 3;
  70. lpAfpProtocols[0].iAddressFamily = AF_INET;
  71. lpAfpProtocols[0].iProtocol = PF_INET;
  72. lpAfpProtocols[1].iAddressFamily = AF_IPX;
  73. lpAfpProtocols[1].iProtocol = PF_IPX;
  74. lpAfpProtocols[2].iAddressFamily = AF_UNSPEC;
  75. lpAfpProtocols[2].iProtocol = PF_UNSPEC;
  76. Query->lpafpProtocols = lpAfpProtocols;
  77. if( WSALookupServiceBegin( Query,
  78. LUP_RETURN_NAME |
  79. LUP_RETURN_TYPE |
  80. LUP_RETURN_VERSION |
  81. LUP_RETURN_COMMENT |
  82. LUP_RETURN_ADDR |
  83. LUP_RETURN_BLOB,
  84. &hRnr ) == SOCKET_ERROR )
  85. {
  86. printf( "LookupBegin failed %d\n", GetLastError() );
  87. }
  88. while ( WSALookupServiceNext( hRnr,
  89. 0,
  90. &dwQuerySize,
  91. Query ) == NO_ERROR )
  92. {
  93. printf( "Next got: \n" );
  94. printf( " dwSize = %d\n",
  95. Query->dwSize );
  96. printf( " dwOutputFlags = %d\n",
  97. Query->dwOutputFlags );
  98. printf( " lpszServiceInstanceName = %ws\n",
  99. Query->lpszServiceInstanceName );
  100. if ( Query->lpVersion )
  101. {
  102. printf( " lpVersion->dwVersion = %d\n",
  103. Query->lpVersion->dwVersion );
  104. printf( " lpVersion->ecHow = %d\n",
  105. Query->lpVersion->ecHow );
  106. }
  107. if ( Query->lpszComment )
  108. {
  109. printf( " lpszComment = %ws\n",
  110. Query->lpszComment );
  111. }
  112. printf( " dwNameSpace = %d\n",
  113. Query->dwNameSpace );
  114. if ( Query->lpszContext )
  115. {
  116. printf( " lpszContext = %ws\n",
  117. Query->lpszContext );
  118. }
  119. printf( " dwNumberOfCsAddrs = %d\n",
  120. Query->dwNumberOfCsAddrs );
  121. }
  122. printf( "Next finished with %d\n", GetLastError() );
  123. if( WSALookupServiceEnd( hRnr ) )
  124. {
  125. printf( "ServiceEnd failed %d\n", GetLastError() );
  126. }
  127. WSACleanup();
  128. return(0);
  129. }