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.

115 lines
4.0 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. //
  5. // File:
  6. //
  7. // Contents:
  8. //
  9. // History:
  10. //
  11. //---------------------------------------------------------------------------
  12. #include <stdio.h>
  13. #include <stddef.h>
  14. #include "hydrals.h"
  15. #include "license.h"
  16. void __RPC_USER
  17. LICENSE_REQUEST_TYPE_to_xmit( LICENSE_REQUEST_TYPE __RPC_FAR * pRequest,
  18. LICENSE_REQUEST_XMIT_TYPE __RPC_FAR * __RPC_FAR * pRequestXmit)
  19. {
  20. DWORD size;
  21. size = sizeof(LICENSE_REQUEST_XMIT_TYPE) +
  22. pRequest->pProductInfo->cbCompanyName +
  23. pRequest->pProductInfo->cbProductID +
  24. pRequest->cbEncryptedHwid;
  25. *pRequestXmit = (LICENSE_REQUEST_XMIT_TYPE *)midl_user_allocate(size);
  26. // copy request structure
  27. (*pRequestXmit)->dwLangId = pRequest->dwLanguageID;
  28. (*pRequestXmit)->dwPlatformId = pRequest->dwPlatformID;
  29. (*pRequestXmit)->cbEncryptedHwid = pRequest->cbEncryptedHwid;
  30. // copy product requested
  31. (*pRequestXmit)->dwVersion = pRequest->pProductInfo->dwVersion;
  32. (*pRequestXmit)->cbCompanyName = pRequest->pProductInfo->cbCompanyName;
  33. (*pRequestXmit)->cbProductId = pRequest->pProductInfo->cbProductID;
  34. memcpy( &((*pRequestXmit)->pbData[0]),
  35. pRequest->pProductInfo->pbCompanyName,
  36. pRequest->pProductInfo->cbCompanyName);
  37. memcpy( &((*pRequestXmit)->pbData[0]) + pRequest->pProductInfo->cbCompanyName,
  38. pRequest->pProductInfo->pbProductID,
  39. pRequest->pProductInfo->cbProductID);
  40. if(pRequest->cbEncryptedHwid)
  41. {
  42. memcpy( &((*pRequestXmit)->pbData[0]) + pRequest->pProductInfo->cbCompanyName + pRequest->pProductInfo->cbProductID,
  43. pRequest->pbEncryptedHwid,
  44. pRequest->cbEncryptedHwid);
  45. }
  46. }
  47. void __RPC_USER
  48. LICENSE_REQUEST_TYPE_from_xmit( LICENSE_REQUEST_XMIT_TYPE __RPC_FAR *pRequestXmit,
  49. LICENSE_REQUEST_TYPE __RPC_FAR * pRequest)
  50. {
  51. pRequest->cbEncryptedHwid = pRequestXmit->cbEncryptedHwid;
  52. pRequest->dwLanguageID = pRequestXmit->dwLangId;
  53. pRequest->dwPlatformID = pRequestXmit->dwPlatformId;
  54. pRequest->pProductInfo = (PProduct_Info)midl_user_allocate(sizeof(Product_Info));
  55. pRequest->pProductInfo->dwVersion = pRequestXmit->dwVersion;
  56. pRequest->pProductInfo->cbCompanyName = pRequestXmit->cbCompanyName;
  57. pRequest->pProductInfo->cbProductID = pRequestXmit->cbProductId;
  58. pRequest->pProductInfo->pbCompanyName = (PBYTE)midl_user_allocate(pRequestXmit->cbCompanyName+sizeof(CHAR));
  59. memcpy(pRequest->pProductInfo->pbCompanyName, &(pRequestXmit->pbData[0]), pRequestXmit->cbCompanyName);
  60. pRequest->pProductInfo->pbProductID = (PBYTE)midl_user_allocate(pRequestXmit->cbProductId+sizeof(CHAR));
  61. memcpy(pRequest->pProductInfo->pbProductID,
  62. &(pRequestXmit->pbData[0]) + pRequest->pProductInfo->cbCompanyName,
  63. pRequestXmit->cbProductId);
  64. if(pRequestXmit->cbEncryptedHwid)
  65. {
  66. pRequest->pbEncryptedHwid = (PBYTE)midl_user_allocate(pRequestXmit->cbEncryptedHwid);
  67. memcpy(pRequest->pbEncryptedHwid,
  68. &(pRequestXmit->pbData[0]) + pRequest->pProductInfo->cbCompanyName + pRequest->pProductInfo->cbProductID,
  69. pRequestXmit->cbEncryptedHwid);
  70. }
  71. else
  72. {
  73. pRequest->pbEncryptedHwid = NULL;
  74. }
  75. }
  76. void __RPC_USER
  77. LICENSE_REQUEST_TYPE_free_xmit(LICENSE_REQUEST_XMIT_TYPE __RPC_FAR *ptr)
  78. {
  79. midl_user_free(ptr);
  80. }
  81. void __RPC_USER
  82. LICENSE_REQUEST_TYPE_free_inst( LICENSE_REQUEST_TYPE __RPC_FAR *pRequest )
  83. {
  84. if(pRequest->pProductInfo)
  85. {
  86. if(pRequest->pbEncryptedHwid)
  87. midl_user_free(pRequest->pbEncryptedHwid);
  88. if(pRequest->pProductInfo->pbProductID)
  89. midl_user_free(pRequest->pProductInfo->pbProductID);
  90. if(pRequest->pProductInfo->pbCompanyName)
  91. midl_user_free(pRequest->pProductInfo->pbCompanyName);
  92. midl_user_free(pRequest->pProductInfo);
  93. }
  94. }