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.

62 lines
1.7 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1994-1995 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: leverage.c
  6. * Content: code to allow third parties to hook our wsock sp
  7. * History:
  8. * Date By Reason
  9. * ==== == ======
  10. * 8/30/96 andyco moved this code from dpsp.c for more better clean
  11. * 2/18/98 a-peterz Comment byte order for address and port parameters
  12. **************************************************************************/
  13. #include "dpsp.h"
  14. #undef DPF_MODNAME
  15. #define DPF_MODNAME "dpwsock helper functions- "
  16. // the functions below are exported from dpwsock so sp's sitting on
  17. // top of us can hook our enum routine (e.g. for Kali)
  18. // return the port of our enum socket (net byte order)
  19. HRESULT DPWS_GetEnumPort(IDirectPlaySP * pISP,LPWORD pPort)
  20. {
  21. SOCKADDR_IN6 sockaddr;
  22. int iAddrLen = sizeof(sockaddr);
  23. UINT err;
  24. DWORD dwDataSize = sizeof(GLOBALDATA);
  25. LPGLOBALDATA pgd;
  26. HRESULT hr;
  27. if (!pISP)
  28. {
  29. DPF_ERR("must pass in IDirectPlaySP pointer!");
  30. return E_FAIL;
  31. }
  32. // get the global data
  33. hr =pISP->lpVtbl->GetSPData(pISP,(LPVOID *)&pgd,&dwDataSize,DPGET_LOCAL);
  34. if (FAILED(hr) || (dwDataSize != sizeof(GLOBALDATA) ))
  35. {
  36. DPF_ERR("couldn't get SP data from DirectPlay - failing");
  37. ExitThread(0);
  38. return 0;
  39. }
  40. ASSERT(pPort);
  41. ASSERT(INVALID_SOCKET != pgd->sSystemStreamSocket);
  42. err = getsockname(pgd->sSystemStreamSocket,(SOCKADDR *)&sockaddr,&iAddrLen);
  43. if (SOCKET_ERROR == err)
  44. {
  45. err = WSAGetLastError();
  46. DPF(0,"GetEnumPort - getsockname - err = %d\n",err);
  47. return E_FAIL;
  48. }
  49. *pPort = sockaddr.sin6_port;
  50. return DP_OK;
  51. } // GetEnumPort