Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
9e326084
Commit
9e326084
authored
Aug 10, 2008
by
Rob Shearman
Committed by
Alexandre Julliard
Aug 18, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rpcrt4: Factorise conformant varying array functions into array_* functions.
This allows conformant varying array types to be marshalled/unmarshalled when embedded in a complex type.
parent
518242ef
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
82 deletions
+118
-82
ndr_marshall.c
dlls/rpcrt4/ndr_marshall.c
+118
-82
No files found.
dlls/rpcrt4/ndr_marshall.c
View file @
9e326084
...
...
@@ -2138,6 +2138,11 @@ static inline void array_compute_and_size_conformance(
ComputeConformance
(
pStubMsg
,
pMemory
,
pFormat
+
4
,
0
);
SizeConformance
(
pStubMsg
);
break
;
case
RPC_FC_CVARRAY
:
pFormat
=
ComputeConformance
(
pStubMsg
,
pMemory
,
pFormat
+
4
,
0
);
pFormat
=
ComputeVariance
(
pStubMsg
,
pMemory
,
pFormat
,
0
);
SizeConformance
(
pStubMsg
);
break
;
default:
ERR
(
"unknown array format 0x%x
\n
"
,
fc
);
RpcRaiseException
(
RPC_X_BAD_STUB_DATA
);
...
...
@@ -2168,6 +2173,22 @@ static inline void array_buffer_size(
EmbeddedPointerBufferSize
(
pStubMsg
,
pMemory
,
pFormat
);
break
;
case
RPC_FC_CVARRAY
:
esize
=
*
(
const
WORD
*
)(
pFormat
+
2
);
alignment
=
pFormat
[
1
]
+
1
;
pFormat
=
SkipConformance
(
pStubMsg
,
pFormat
+
4
);
pFormat
=
SkipConformance
(
pStubMsg
,
pFormat
);
SizeVariance
(
pStubMsg
);
ALIGN_LENGTH
(
pStubMsg
->
BufferLength
,
alignment
);
size
=
safe_multiply
(
esize
,
pStubMsg
->
ActualCount
);
safe_buffer_length_increment
(
pStubMsg
,
size
);
EmbeddedPointerBufferSize
(
pStubMsg
,
pMemory
,
pFormat
);
break
;
default:
ERR
(
"unknown array format 0x%x
\n
"
,
fc
);
RpcRaiseException
(
RPC_X_BAD_STUB_DATA
);
...
...
@@ -2184,6 +2205,11 @@ static inline void array_compute_and_write_conformance(
ComputeConformance
(
pStubMsg
,
pMemory
,
pFormat
+
4
,
0
);
WriteConformance
(
pStubMsg
);
break
;
case
RPC_FC_CVARRAY
:
pFormat
=
ComputeConformance
(
pStubMsg
,
pMemory
,
pFormat
+
4
,
0
);
pFormat
=
ComputeVariance
(
pStubMsg
,
pMemory
,
pFormat
,
0
);
WriteConformance
(
pStubMsg
);
break
;
default:
ERR
(
"unknown array format 0x%x
\n
"
,
fc
);
RpcRaiseException
(
RPC_X_BAD_STUB_DATA
);
...
...
@@ -2214,6 +2240,26 @@ static inline void array_write_variance_and_marshall(
EmbeddedPointerMarshall
(
pStubMsg
,
pMemory
,
pFormat
);
break
;
case
RPC_FC_CVARRAY
:
esize
=
*
(
const
WORD
*
)(
pFormat
+
2
);
alignment
=
pFormat
[
1
]
+
1
;
/* conformance */
pFormat
=
SkipConformance
(
pStubMsg
,
pFormat
+
4
);
/* variance */
pFormat
=
SkipConformance
(
pStubMsg
,
pFormat
);
WriteVariance
(
pStubMsg
);
ALIGN_POINTER_CLEAR
(
pStubMsg
->
Buffer
,
alignment
);
size
=
safe_multiply
(
esize
,
pStubMsg
->
ActualCount
);
pStubMsg
->
BufferMark
=
pStubMsg
->
Buffer
;
safe_copy_to_buffer
(
pStubMsg
,
pMemory
+
pStubMsg
->
Offset
,
size
);
EmbeddedPointerMarshall
(
pStubMsg
,
pMemory
,
pFormat
);
break
;
default:
ERR
(
"unknown array format 0x%x
\n
"
,
fc
);
RpcRaiseException
(
RPC_X_BAD_STUB_DATA
);
...
...
@@ -2231,6 +2277,10 @@ static inline ULONG array_read_conformance(
esize
=
*
(
const
WORD
*
)(
pFormat
+
2
);
pFormat
=
ReadConformance
(
pStubMsg
,
pFormat
+
4
);
return
safe_multiply
(
esize
,
pStubMsg
->
MaxCount
);
case
RPC_FC_CVARRAY
:
esize
=
*
(
const
WORD
*
)(
pFormat
+
2
);
pFormat
=
ReadConformance
(
pStubMsg
,
pFormat
+
4
);
return
safe_multiply
(
esize
,
pStubMsg
->
MaxCount
);
default:
ERR
(
"unknown array format 0x%x
\n
"
,
fc
);
RpcRaiseException
(
RPC_X_BAD_STUB_DATA
);
...
...
@@ -2243,9 +2293,10 @@ static inline void array_read_variance_and_unmarshall(
unsigned
char
fUseBufferMemoryServer
)
{
ULONG
bufsize
,
memsize
;
D
WORD
esize
;
WORD
esize
;
unsigned
char
alignment
;
unsigned
char
*
saved_buffer
;
ULONG
offset
;
switch
(
fc
)
{
...
...
@@ -2276,6 +2327,31 @@ static inline void array_read_variance_and_unmarshall(
if
(
*
ppMemory
!=
saved_buffer
)
memcpy
(
*
ppMemory
,
saved_buffer
,
bufsize
);
break
;
case
RPC_FC_CVARRAY
:
esize
=
*
(
const
WORD
*
)(
pFormat
+
2
);
alignment
=
pFormat
[
1
]
+
1
;
pFormat
=
SkipConformance
(
pStubMsg
,
pFormat
+
4
);
pFormat
=
ReadVariance
(
pStubMsg
,
pFormat
,
pStubMsg
->
MaxCount
);
ALIGN_POINTER
(
pStubMsg
->
Buffer
,
alignment
);
bufsize
=
safe_multiply
(
esize
,
pStubMsg
->
ActualCount
);
memsize
=
safe_multiply
(
esize
,
pStubMsg
->
MaxCount
);
offset
=
pStubMsg
->
Offset
;
if
(
!
fMustAlloc
&&
!*
ppMemory
)
fMustAlloc
=
TRUE
;
if
(
fMustAlloc
)
*
ppMemory
=
NdrAllocate
(
pStubMsg
,
memsize
);
saved_buffer
=
pStubMsg
->
BufferMark
=
pStubMsg
->
Buffer
;
safe_buffer_increment
(
pStubMsg
,
bufsize
);
EmbeddedPointerUnmarshall
(
pStubMsg
,
saved_buffer
,
*
ppMemory
,
pFormat
,
fMustAlloc
);
memcpy
(
*
ppMemory
+
offset
,
saved_buffer
,
bufsize
);
break
;
default:
ERR
(
"unknown array format 0x%x
\n
"
,
fc
);
RpcRaiseException
(
RPC_X_BAD_STUB_DATA
);
...
...
@@ -2285,7 +2361,7 @@ static inline void array_read_variance_and_unmarshall(
static
inline
void
array_memory_size
(
unsigned
char
fc
,
PMIDL_STUB_MESSAGE
pStubMsg
,
PFORMAT_STRING
pFormat
)
{
DWORD
size
;
ULONG
bufsize
,
mem
size
;
DWORD
esize
;
unsigned
char
alignment
;
...
...
@@ -2297,12 +2373,30 @@ static inline void array_memory_size(
pFormat
=
SkipConformance
(
pStubMsg
,
pFormat
+
4
);
size
=
safe_multiply
(
esize
,
pStubMsg
->
MaxCount
);
pStubMsg
->
MemorySize
+=
size
;
bufsize
=
memsize
=
safe_multiply
(
esize
,
pStubMsg
->
MaxCount
);
pStubMsg
->
MemorySize
+=
memsize
;
ALIGN_POINTER
(
pStubMsg
->
Buffer
,
alignment
);
pStubMsg
->
BufferMark
=
pStubMsg
->
Buffer
;
safe_buffer_increment
(
pStubMsg
,
bufsize
);
EmbeddedPointerMemorySize
(
pStubMsg
,
pFormat
);
break
;
case
RPC_FC_CVARRAY
:
esize
=
*
(
const
WORD
*
)(
pFormat
+
2
);
alignment
=
pFormat
[
1
]
+
1
;
pFormat
=
SkipConformance
(
pStubMsg
,
pFormat
+
4
);
pFormat
=
ReadVariance
(
pStubMsg
,
pFormat
,
pStubMsg
->
MaxCount
);
bufsize
=
safe_multiply
(
esize
,
pStubMsg
->
ActualCount
);
memsize
=
safe_multiply
(
esize
,
pStubMsg
->
MaxCount
);
pStubMsg
->
MemorySize
+=
memsize
;
ALIGN_POINTER
(
pStubMsg
->
Buffer
,
alignment
);
pStubMsg
->
BufferMark
=
pStubMsg
->
Buffer
;
safe_buffer_increment
(
pStubMsg
,
size
);
safe_buffer_increment
(
pStubMsg
,
buf
size
);
EmbeddedPointerMemorySize
(
pStubMsg
,
pFormat
);
break
;
...
...
@@ -2322,6 +2416,11 @@ static inline void array_free(
pFormat
=
ComputeConformance
(
pStubMsg
,
pMemory
,
pFormat
+
4
,
0
);
EmbeddedPointerFree
(
pStubMsg
,
pMemory
,
pFormat
);
break
;
case
RPC_FC_CVARRAY
:
pFormat
=
ComputeConformance
(
pStubMsg
,
pMemory
,
pFormat
+
4
,
0
);
pFormat
=
ComputeVariance
(
pStubMsg
,
pMemory
,
pFormat
,
0
);
EmbeddedPointerFree
(
pStubMsg
,
pMemory
,
pFormat
);
break
;
case
RPC_FC_C_CSTRING
:
case
RPC_FC_C_WSTRING
:
/* No embedded pointers so nothing to do */
...
...
@@ -3463,10 +3562,6 @@ unsigned char* WINAPI NdrConformantVaryingArrayMarshall( PMIDL_STUB_MESSAGE pStu
unsigned
char
*
pMemory
,
PFORMAT_STRING
pFormat
)
{
ULONG
bufsize
;
unsigned
char
alignment
=
pFormat
[
1
]
+
1
;
DWORD
esize
=
*
(
const
WORD
*
)(
pFormat
+
2
);
TRACE
(
"(%p, %p, %p)
\n
"
,
pStubMsg
,
pMemory
,
pFormat
);
if
(
pFormat
[
0
]
!=
RPC_FC_CVARRAY
)
...
...
@@ -3476,20 +3571,10 @@ unsigned char* WINAPI NdrConformantVaryingArrayMarshall( PMIDL_STUB_MESSAGE pStu
return
NULL
;
}
pFormat
=
ComputeConformance
(
pStubMsg
,
pMemory
,
pFormat
+
4
,
0
);
pFormat
=
ComputeVariance
(
pStubMsg
,
pMemory
,
pFormat
,
0
);
WriteConformance
(
pStubMsg
);
WriteVariance
(
pStubMsg
);
ALIGN_POINTER_CLEAR
(
pStubMsg
->
Buffer
,
alignment
);
bufsize
=
safe_multiply
(
esize
,
pStubMsg
->
ActualCount
);
pStubMsg
->
BufferMark
=
pStubMsg
->
Buffer
;
safe_copy_to_buffer
(
pStubMsg
,
pMemory
+
pStubMsg
->
Offset
,
bufsize
);
EmbeddedPointerMarshall
(
pStubMsg
,
pMemory
,
pFormat
);
array_compute_and_write_conformance
(
RPC_FC_CVARRAY
,
pStubMsg
,
pMemory
,
pFormat
);
array_write_variance_and_marshall
(
RPC_FC_CVARRAY
,
pStubMsg
,
pMemory
,
pFormat
);
return
NULL
;
}
...
...
@@ -3503,12 +3588,6 @@ unsigned char* WINAPI NdrConformantVaryingArrayUnmarshall( PMIDL_STUB_MESSAGE pS
PFORMAT_STRING
pFormat
,
unsigned
char
fMustAlloc
)
{
ULONG
bufsize
,
memsize
;
unsigned
char
alignment
=
pFormat
[
1
]
+
1
;
DWORD
esize
=
*
(
const
WORD
*
)(
pFormat
+
2
);
unsigned
char
*
saved_buffer
;
ULONG
offset
;
TRACE
(
"(%p, %p, %p, %d)
\n
"
,
pStubMsg
,
ppMemory
,
pFormat
,
fMustAlloc
);
if
(
pFormat
[
0
]
!=
RPC_FC_CVARRAY
)
...
...
@@ -3518,23 +3597,10 @@ unsigned char* WINAPI NdrConformantVaryingArrayUnmarshall( PMIDL_STUB_MESSAGE pS
return
NULL
;
}
pFormat
=
ReadConformance
(
pStubMsg
,
pFormat
+
4
);
pFormat
=
ReadVariance
(
pStubMsg
,
pFormat
,
pStubMsg
->
MaxCount
);
ALIGN_POINTER
(
pStubMsg
->
Buffer
,
alignment
);
bufsize
=
safe_multiply
(
esize
,
pStubMsg
->
ActualCount
);
memsize
=
safe_multiply
(
esize
,
pStubMsg
->
MaxCount
);
offset
=
pStubMsg
->
Offset
;
if
(
!*
ppMemory
||
fMustAlloc
)
*
ppMemory
=
NdrAllocate
(
pStubMsg
,
memsize
);
saved_buffer
=
pStubMsg
->
BufferMark
=
pStubMsg
->
Buffer
;
safe_buffer_increment
(
pStubMsg
,
bufsize
);
EmbeddedPointerUnmarshall
(
pStubMsg
,
saved_buffer
,
*
ppMemory
,
pFormat
,
fMustAlloc
);
memcpy
(
*
ppMemory
+
offset
,
saved_buffer
,
bufsize
);
array_read_conformance
(
RPC_FC_CVARRAY
,
pStubMsg
,
pFormat
);
array_read_variance_and_unmarshall
(
RPC_FC_CVARRAY
,
pStubMsg
,
ppMemory
,
pFormat
,
fMustAlloc
,
TRUE
/* fUseBufferMemoryServer */
);
return
NULL
;
}
...
...
@@ -3556,10 +3622,7 @@ void WINAPI NdrConformantVaryingArrayFree( PMIDL_STUB_MESSAGE pStubMsg,
return
;
}
pFormat
=
ComputeConformance
(
pStubMsg
,
pMemory
,
pFormat
+
4
,
0
);
pFormat
=
ComputeVariance
(
pStubMsg
,
pMemory
,
pFormat
,
0
);
EmbeddedPointerFree
(
pStubMsg
,
pMemory
,
pFormat
);
array_free
(
RPC_FC_CVARRAY
,
pStubMsg
,
pMemory
,
pFormat
);
}
...
...
@@ -3569,9 +3632,6 @@ void WINAPI NdrConformantVaryingArrayFree( PMIDL_STUB_MESSAGE pStubMsg,
void
WINAPI
NdrConformantVaryingArrayBufferSize
(
PMIDL_STUB_MESSAGE
pStubMsg
,
unsigned
char
*
pMemory
,
PFORMAT_STRING
pFormat
)
{
unsigned
char
alignment
=
pFormat
[
1
]
+
1
;
DWORD
esize
=
*
(
const
WORD
*
)(
pFormat
+
2
);
TRACE
(
"(%p, %p, %p)
\n
"
,
pStubMsg
,
pMemory
,
pFormat
);
if
(
pFormat
[
0
]
!=
RPC_FC_CVARRAY
)
...
...
@@ -3581,19 +3641,9 @@ void WINAPI NdrConformantVaryingArrayBufferSize( PMIDL_STUB_MESSAGE pStubMsg,
return
;
}
/* compute size */
pFormat
=
ComputeConformance
(
pStubMsg
,
pMemory
,
pFormat
+
4
,
0
);
/* compute length */
pFormat
=
ComputeVariance
(
pStubMsg
,
pMemory
,
pFormat
,
0
);
SizeConformance
(
pStubMsg
);
SizeVariance
(
pStubMsg
);
ALIGN_LENGTH
(
pStubMsg
->
BufferLength
,
alignment
);
safe_buffer_length_increment
(
pStubMsg
,
safe_multiply
(
esize
,
pStubMsg
->
ActualCount
));
EmbeddedPointerBufferSize
(
pStubMsg
,
pMemory
,
pFormat
);
array_compute_and_size_conformance
(
RPC_FC_CVARRAY
,
pStubMsg
,
pMemory
,
pFormat
);
array_buffer_size
(
RPC_FC_CVARRAY
,
pStubMsg
,
pMemory
,
pFormat
);
}
...
...
@@ -3603,10 +3653,6 @@ void WINAPI NdrConformantVaryingArrayBufferSize( PMIDL_STUB_MESSAGE pStubMsg,
ULONG
WINAPI
NdrConformantVaryingArrayMemorySize
(
PMIDL_STUB_MESSAGE
pStubMsg
,
PFORMAT_STRING
pFormat
)
{
ULONG
bufsize
,
memsize
;
unsigned
char
alignment
=
pFormat
[
1
]
+
1
;
DWORD
esize
=
*
(
const
WORD
*
)(
pFormat
+
2
);
TRACE
(
"(%p, %p)
\n
"
,
pStubMsg
,
pFormat
);
if
(
pFormat
[
0
]
!=
RPC_FC_CVARRAY
)
...
...
@@ -3616,18 +3662,8 @@ ULONG WINAPI NdrConformantVaryingArrayMemorySize( PMIDL_STUB_MESSAGE pStubMsg,
return
pStubMsg
->
MemorySize
;
}
pFormat
=
ReadConformance
(
pStubMsg
,
pFormat
+
4
);
pFormat
=
ReadVariance
(
pStubMsg
,
pFormat
,
pStubMsg
->
MaxCount
);
ALIGN_POINTER
(
pStubMsg
->
Buffer
,
alignment
);
bufsize
=
safe_multiply
(
esize
,
pStubMsg
->
ActualCount
);
memsize
=
safe_multiply
(
esize
,
pStubMsg
->
MaxCount
);
safe_buffer_increment
(
pStubMsg
,
bufsize
);
pStubMsg
->
MemorySize
+=
memsize
;
EmbeddedPointerMemorySize
(
pStubMsg
,
pFormat
);
array_read_conformance
(
RPC_FC_CVARRAY
,
pStubMsg
,
pFormat
);
array_memory_size
(
RPC_FC_CVARRAY
,
pStubMsg
,
pFormat
);
return
pStubMsg
->
MemorySize
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment