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.

147 lines
4.2 KiB

  1. title "LPC Move Message Support"
  2. ;++
  3. ;
  4. ; Copyright (c) 2000 Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; lpcmove.asm
  9. ;
  10. ; Abstract:
  11. ;
  12. ; This module implements functions to support the efficient movement of
  13. ; LPC Message blocks
  14. ;
  15. ; Author:
  16. ;
  17. ; David N. Cutler (davec) 25-Jun-2000
  18. ;
  19. ; Environment:
  20. ;
  21. ; Kernel mode only.
  22. ;
  23. ;--
  24. include ksamd64.inc
  25. subttl "Move Message"
  26. ;++
  27. ;
  28. ; VOID
  29. ; LpcpMoveMessage (
  30. ; OUT PPORT_MESSAGE DstMsg,
  31. ; IN PPORT_MESSAGE SrcMsg,
  32. ; IN PUCHAR SrcMsgData,
  33. ; IN ULONG MsgType OPTIONAL,
  34. ; IN PCLIENT_ID ClientId OPTIONAL
  35. ; )
  36. ;
  37. ; Routine Description:
  38. ;
  39. ; This function moves an LPC message block and optionally sets the message
  40. ; type and client id to the specified values.
  41. ;
  42. ; Arguments:
  43. ;
  44. ; DstMsg (rcx) - Supplies pointer to the destination message.
  45. ;
  46. ; SrcMsg (rdx) - Supplies a pointer to the source message.
  47. ;
  48. ; SrcMsgData (r8) - Supplies a pointer to the source message data to copy
  49. ; to destination.
  50. ;
  51. ; MsgType (r9) - If nonzero, then store in type field on the destination
  52. ; message.
  53. ;
  54. ; ClientId (40[rsp]) - If nonNULL, then supplies a pointer to a client id
  55. ; to copy to the desination message.
  56. ;
  57. ; Return Value:
  58. ;
  59. ; None.
  60. ;
  61. ;--
  62. MvFrame struct
  63. SavedRdi dq ? ; saved register RDI
  64. SavedRsi dq ? ; saved register RSI
  65. Fill dq ? ; fill to 8 mod 16
  66. MvFrame ends
  67. ClientId equ ((sizeof MvFrame) + (5 * 8)) ; offset to client id parameter
  68. NESTED_ENTRY LpcpMoveMessage, _PAGE
  69. push_reg rsi ; save nonvolatile registers
  70. push_reg rdi ;
  71. alloc_stack (sizeof MvFrame - (2 * 8)) ; allocate stack frame
  72. END_PROLOGUE
  73. mov rdi, rcx ; set destination address
  74. mov rsi, rdx ; set source address
  75. ;
  76. ; Copy the message length.
  77. ;
  78. mov eax, PmLength[rsi] ; copy message length
  79. mov PmLength[rdi], eax ;
  80. ;
  81. ; Round the message length up and compute message length in dwords.
  82. ;
  83. lea rcx, 3[rax] ; round length to dwords
  84. and rcx, 0fffch ;
  85. shr rcx, 2 ;
  86. ;
  87. ; Copy data offset and message id. If the specified message id is nonzero,
  88. ; then insert the specified message id.
  89. ;
  90. mov eax, PmZeroInit[rsi] ; get data offset and message type
  91. test r9w, r9w ; test if message type specified
  92. cmovnz ax, r9w ; if nz, set specified message id
  93. mov PmZeroInit[rdi], eax ; set offset and message type
  94. ;
  95. ; Copy the client id. If the specified client id pointer is nonNULL, then
  96. ; insert the specified client id. Otherwise, copy the client id from the
  97. ; source message.
  98. ;
  99. lea rax, PmClientId[rsi] ; get source client id address
  100. mov rdx, ClientId[rsp] ; get specified client id address
  101. test rdx, rdx ; check if client id specified
  102. cmovz rdx, rax ; if z, set source client id address
  103. mov rax, CidUniqueProcess[rdx] ; copy low part of client id
  104. mov PmProcess[rdi], rax ;
  105. mov rax, CidUniqueThread[rdx] ; copy high part of client id
  106. mov PmThread[rdi], rax ;
  107. ;
  108. ; Copy the message id and the client view size.
  109. ;
  110. mov eax, PmMessageId[rsi] ; copy message id
  111. mov PmMessageId[rdi], eax ;
  112. mov rax, PmClientViewSize[rsi] ; copy view size
  113. mov PmClientViewSize[rdi], rax ;
  114. ;
  115. ; Copy the message data.
  116. ;
  117. mov rsi, r8 ; set address of source
  118. lea rdi, PortMessageLength[rdi] ; set address of destination
  119. rep movsd ; Copy the data portion of message
  120. add rsp, sizeof MvFrame - (2 * 8) ; deallocate stack frame
  121. pop rdi ; restore nonvolatile register
  122. pop rsi ;
  123. ret ; return
  124. NESTED_END LpcpMoveMessage, _PAGE
  125. end