https://git.reactos.org/?p=reactos.git;a=commitdiff;h=141daf4de84fba27c121c…
commit 141daf4de84fba27c121c3cc4324cb6290c52596
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sat Oct 29 00:26:41 2022 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sat Oct 29 17:36:09 2022 +0200
[CSRLIB] Add comments regarding the calculation of the data and total message lengths
in CsrClientCallServer().
---
subsystems/csr/csrlib/connect.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/subsystems/csr/csrlib/connect.c b/subsystems/csr/csrlib/connect.c
index c93f80075d7..9765ac19a75 100644
--- a/subsystems/csr/csrlib/connect.c
+++ b/subsystems/csr/csrlib/connect.c
@@ -386,10 +386,13 @@ CsrClientCallServer(
/* Fill out the Port Message Header */
ApiMessage->Header.u2.ZeroInit = 0;
- ApiMessage->Header.u1.s1.TotalLength = (CSHORT)DataLength +
- sizeof(CSR_API_MESSAGE) - sizeof(ApiMessage->Data); //
FIELD_OFFSET(CSR_API_MESSAGE, Data) + DataLength;
+ /* DataLength = user_data_size + anything between
+ * header and data, including intermediate padding */
ApiMessage->Header.u1.s1.DataLength = (CSHORT)DataLength +
- FIELD_OFFSET(CSR_API_MESSAGE, Data) - sizeof(ApiMessage->Header); //
ApiMessage->Header.u1.s1.TotalLength - sizeof(PORT_MESSAGE);
+ FIELD_OFFSET(CSR_API_MESSAGE, Data) - sizeof(ApiMessage->Header);
+ /* TotalLength = header_size + DataLength + any structure trailing padding */
+ ApiMessage->Header.u1.s1.TotalLength = (CSHORT)DataLength +
+ sizeof(CSR_API_MESSAGE) - sizeof(ApiMessage->Data);
/* Fill out the CSR Header */
ApiMessage->ApiNumber = ApiNumber;