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.

137 lines
4.8 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. WCHAR ServiceInstanceName[] = L"GlennC on GLENNC_PRO";
  19. WCHAR ServiceInstanceComment[] = L"This is a service added via Rnr over LDAP";
  20. _cdecl
  21. main(int argc, char **argv)
  22. {
  23. DWORD ret;
  24. WSAVERSION Version;
  25. WSADATA wsaData;
  26. WSAQUERYSET QuerySet;
  27. CSADDR_INFO CSAddrInfo[6];
  28. SOCKADDR SocketAddress1;
  29. SOCKADDR SocketAddress2;
  30. SOCKADDR SocketAddress3;
  31. SOCKADDR SocketAddress4;
  32. SOCKADDR SocketAddress5;
  33. RtlZeroMemory( (LPBYTE) &QuerySet, sizeof( WSAQUERYSET ) );
  34. RtlZeroMemory( (LPBYTE) &CSAddrInfo[0], sizeof( CSADDR_INFO ) );
  35. RtlZeroMemory( (LPBYTE) &CSAddrInfo[1], sizeof( CSADDR_INFO ) );
  36. RtlZeroMemory( (LPBYTE) &CSAddrInfo[2], sizeof( CSADDR_INFO ) );
  37. RtlZeroMemory( (LPBYTE) &CSAddrInfo[3], sizeof( CSADDR_INFO ) );
  38. RtlZeroMemory( (LPBYTE) &CSAddrInfo[4], sizeof( CSADDR_INFO ) );
  39. RtlZeroMemory( (LPBYTE) &CSAddrInfo[5], sizeof( CSADDR_INFO ) );
  40. SocketAddress1.sa_family = AF_UNIX;
  41. RtlFillMemory( (LPBYTE) &SocketAddress1.sa_data, 14, 1 );
  42. SocketAddress2.sa_family = AF_INET;
  43. RtlFillMemory( (LPBYTE) &SocketAddress2.sa_data, 14, 2 );
  44. SocketAddress3.sa_family = AF_IPX;
  45. RtlFillMemory( (LPBYTE) &SocketAddress3.sa_data, 14, 6 );
  46. SocketAddress4.sa_family = AF_ISO;
  47. RtlFillMemory( (LPBYTE) &SocketAddress4.sa_data, 14, 7 );
  48. SocketAddress5.sa_family = AF_ECMA;
  49. RtlFillMemory( (LPBYTE) &SocketAddress5.sa_data, 14, 8 );
  50. CSAddrInfo[0].LocalAddr.iSockaddrLength = sizeof( SOCKADDR );
  51. CSAddrInfo[0].LocalAddr.lpSockaddr = &SocketAddress2;
  52. CSAddrInfo[0].RemoteAddr.iSockaddrLength = sizeof( SOCKADDR );
  53. CSAddrInfo[0].RemoteAddr.lpSockaddr = &SocketAddress2;
  54. CSAddrInfo[0].iSocketType = SOCK_RAW;
  55. CSAddrInfo[0].iProtocol = PF_INET;
  56. CSAddrInfo[1].LocalAddr.iSockaddrLength = sizeof( SOCKADDR );
  57. CSAddrInfo[1].LocalAddr.lpSockaddr = &SocketAddress2;
  58. CSAddrInfo[1].RemoteAddr.iSockaddrLength = sizeof( SOCKADDR );
  59. CSAddrInfo[1].RemoteAddr.lpSockaddr = &SocketAddress2;
  60. CSAddrInfo[1].iSocketType = SOCK_STREAM;
  61. CSAddrInfo[1].iProtocol = PF_INET;
  62. CSAddrInfo[2].LocalAddr.iSockaddrLength = sizeof( SOCKADDR );
  63. CSAddrInfo[2].LocalAddr.lpSockaddr = &SocketAddress1;
  64. CSAddrInfo[2].RemoteAddr.iSockaddrLength = sizeof( SOCKADDR );
  65. CSAddrInfo[2].RemoteAddr.lpSockaddr = &SocketAddress1;
  66. CSAddrInfo[2].iSocketType = SOCK_STREAM;
  67. CSAddrInfo[2].iProtocol = PF_UNIX;
  68. CSAddrInfo[3].LocalAddr.iSockaddrLength = sizeof( SOCKADDR );
  69. CSAddrInfo[3].LocalAddr.lpSockaddr = &SocketAddress3;
  70. CSAddrInfo[3].RemoteAddr.iSockaddrLength = 0;
  71. CSAddrInfo[3].RemoteAddr.lpSockaddr = NULL;
  72. CSAddrInfo[3].iSocketType = SOCK_STREAM;
  73. CSAddrInfo[3].iProtocol = PF_IPX;
  74. CSAddrInfo[4].LocalAddr.iSockaddrLength = sizeof( SOCKADDR );
  75. CSAddrInfo[4].LocalAddr.lpSockaddr = &SocketAddress4;
  76. CSAddrInfo[4].RemoteAddr.iSockaddrLength = 0;
  77. CSAddrInfo[4].RemoteAddr.lpSockaddr = NULL;
  78. CSAddrInfo[4].iSocketType = SOCK_STREAM;
  79. CSAddrInfo[4].iProtocol = PF_ISO;
  80. CSAddrInfo[5].LocalAddr.iSockaddrLength = sizeof( SOCKADDR );
  81. CSAddrInfo[5].LocalAddr.lpSockaddr = &SocketAddress5;
  82. CSAddrInfo[5].RemoteAddr.iSockaddrLength = sizeof( SOCKADDR );
  83. CSAddrInfo[5].RemoteAddr.lpSockaddr = &SocketAddress5;
  84. CSAddrInfo[5].iSocketType = SOCK_STREAM;
  85. CSAddrInfo[5].iProtocol = PF_ECMA;
  86. QuerySet.dwSize = sizeof( WSAQUERYSET );
  87. QuerySet.lpServiceClassId = &ServiceClassId;
  88. QuerySet.lpszServiceInstanceName = ServiceInstanceName;
  89. QuerySet.lpszComment = ServiceInstanceComment;
  90. QuerySet.lpVersion = &Version;
  91. QuerySet.lpVersion->dwVersion = 5;
  92. QuerySet.lpVersion->ecHow = COMP_NOTLESS;
  93. QuerySet.dwNameSpace = NS_NTDS;
  94. QuerySet.dwNumberOfCsAddrs = 6;
  95. QuerySet.lpcsaBuffer = &CSAddrInfo;
  96. WSAStartup( MAKEWORD(1, 1), &wsaData );
  97. ret = WSASetService( &QuerySet,
  98. RNRSERVICE_REGISTER,
  99. SERVICE_MULTIPLE );
  100. if ( ret )
  101. {
  102. printf("Error: WSASetService returned 0x%X\n", ret );
  103. printf(" GetLastError returned 0x%X\n", GetLastError() );
  104. WSACleanup();
  105. return -1;
  106. }
  107. printf( "SetService was successful.\n" );
  108. WSACleanup();
  109. return(0);
  110. }