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.

118 lines
2.7 KiB

  1. /**
  2. *** Copyright (C) 1996-97 Intel Corporation. All rights reserved.
  3. ***
  4. *** The information and source code contained herein is the exclusive
  5. *** property of Intel Corporation and may not be disclosed, examined
  6. *** or reproduced in whole or in part without explicit written authorization
  7. *** from the company.
  8. **/
  9. /*++
  10. Copyright (c) 1995 Intel Corporation
  11. Module Name:
  12. lpcmove.c
  13. Abstract:
  14. This module implements functions to support the efficient movement
  15. of LPC message blocks.
  16. There is a corresponding .s version that is hand optimized.
  17. Need to evaluate and install one or the other.
  18. Author:
  19. Roy D'Souza (rdsouza) 5-May-96
  20. Revision History:
  21. --*/
  22. #include "lpcp.h"
  23. VOID
  24. LpcpMoveMessage (
  25. OUT PPORT_MESSAGE DstMsg,
  26. IN PPORT_MESSAGE SrcMsg,
  27. IN PUCHAR SrcMsgData,
  28. IN ULONG MsgType OPTIONAL,
  29. IN PCLIENT_ID ClientId OPTIONAL
  30. )
  31. /*++
  32. Routine Description:
  33. This function moves an LPC message block and optionally sets the message
  34. type and client id to the specified values.
  35. Arguments:
  36. DstMsg - Supplies a pointer to the destination message.
  37. SrcMsg - Supplies a pointer to the source message.
  38. SrcMsgData - Supplies a pointer to the source message data to
  39. copy to destination.
  40. MsgType - If non-zero, then store in type field of the
  41. destination message.
  42. ClientId - If non-NULL, then points to a ClientId to copy to
  43. the destination message.
  44. Return Value:
  45. None
  46. --*/
  47. {
  48. ULONG NumberDwords;
  49. //
  50. // Extract the data length and copy over the first dword
  51. //
  52. *((PULONG)DstMsg)++ = NumberDwords = *((PULONG)SrcMsg)++;
  53. NumberDwords = ((0x0000FFFF & NumberDwords) + 3) >> 2;
  54. //
  55. // Set the message type properly and update the second dword
  56. //
  57. *((PULONG)DstMsg)++ = MsgType == 0 ? *((PULONG)SrcMsg)++ :
  58. *((PULONG)SrcMsg)++ & 0xFFFF0000 | MsgType & 0xFFFF;
  59. //
  60. // Set the ClientId appropriately and update the third dword
  61. //
  62. *((PULONG_PTR)DstMsg)++ = ClientId == NULL ? *((PULONG_PTR)SrcMsg) :
  63. *((PULONG_PTR)ClientId)++;
  64. ((PULONG_PTR)SrcMsg)++;
  65. *((PULONG_PTR)DstMsg)++ = ClientId == NULL ? *((PULONG_PTR)SrcMsg) :
  66. *((PULONG_PTR)ClientId);
  67. ((PULONG_PTR)SrcMsg)++;
  68. //
  69. // Update the final two longwords in the header
  70. //
  71. *((PULONG_PTR)DstMsg)++ = *((PULONG_PTR)SrcMsg)++;
  72. *((PULONG_PTR)DstMsg)++ = *((PULONG_PTR)SrcMsg)++;
  73. //
  74. // Copy the data
  75. //
  76. if (NumberDwords > 0) {
  77. RtlCopyMemory(DstMsg, SrcMsgData, NumberDwords*sizeof(ULONG));
  78. }
  79. }