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.

87 lines
2.5 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. _cdecl
  20. main(int argc, char **argv)
  21. {
  22. DWORD ret;
  23. WSADATA wsaData;
  24. WSAQUERYSET QuerySet;
  25. CSADDR_INFO CSAddrInfo[2];
  26. SOCKADDR SocketAddress1;
  27. SOCKADDR SocketAddress2;
  28. RtlZeroMemory( (LPBYTE) &QuerySet, sizeof( WSAQUERYSET ) );
  29. RtlZeroMemory( (LPBYTE) &CSAddrInfo[0], sizeof( CSADDR_INFO ) );
  30. RtlZeroMemory( (LPBYTE) &CSAddrInfo[1], sizeof( CSADDR_INFO ) );
  31. SocketAddress1.sa_family = AF_INET;
  32. RtlFillMemory( (LPBYTE) &SocketAddress1.sa_data, 14, 2 );
  33. SocketAddress2.sa_family = AF_IPX;
  34. RtlFillMemory( (LPBYTE) &SocketAddress2.sa_data, 14, 6 );
  35. CSAddrInfo[0].LocalAddr.iSockaddrLength = sizeof( SOCKADDR );
  36. CSAddrInfo[0].LocalAddr.lpSockaddr = &SocketAddress1;
  37. CSAddrInfo[0].RemoteAddr.iSockaddrLength = sizeof( SOCKADDR );
  38. CSAddrInfo[0].RemoteAddr.lpSockaddr = &SocketAddress1;
  39. CSAddrInfo[0].iSocketType = SOCK_RAW;
  40. CSAddrInfo[0].iProtocol = PF_INET;
  41. CSAddrInfo[1].LocalAddr.iSockaddrLength = sizeof( SOCKADDR );
  42. CSAddrInfo[1].LocalAddr.lpSockaddr = &SocketAddress2;
  43. CSAddrInfo[1].RemoteAddr.iSockaddrLength = sizeof( SOCKADDR );
  44. CSAddrInfo[1].RemoteAddr.lpSockaddr = &SocketAddress2;
  45. CSAddrInfo[1].iSocketType = SOCK_STREAM;
  46. CSAddrInfo[1].iProtocol = PF_IPX;
  47. QuerySet.dwSize = sizeof( WSAQUERYSET );
  48. QuerySet.lpServiceClassId = &ServiceClassId;
  49. QuerySet.lpszServiceInstanceName = ServiceInstanceName;
  50. QuerySet.dwNameSpace = NS_NTDS;
  51. QuerySet.dwNumberOfCsAddrs = 2;
  52. QuerySet.lpcsaBuffer = &CSAddrInfo;
  53. WSAStartup( MAKEWORD(1, 1), &wsaData );
  54. ret = WSASetService( &QuerySet,
  55. RNRSERVICE_DEREGISTER,
  56. SERVICE_MULTIPLE );
  57. if ( ret )
  58. {
  59. printf("Error: WSASetService returned 0x%X\n", ret );
  60. printf(" GetLastError returned 0x%X\n", GetLastError() );
  61. WSACleanup();
  62. return -1;
  63. }
  64. printf( "SetService was successful.\n" );
  65. WSACleanup();
  66. return(0);
  67. }