ReactOS 0.4.16-dev-197-g92996da
options.c
Go to the documentation of this file.
1/* NFSv4.1 client for Windows
2 * Copyright © 2012 The Regents of the University of Michigan
3 *
4 * Olga Kornievskaia <aglo@umich.edu>
5 * Casey Bodley <cbodley@umich.edu>
6 *
7 * This library is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2.1 of the License, or (at
10 * your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful, but
13 * without any warranty; without even the implied warranty of merchantability
14 * or fitness for a particular purpose. See the GNU Lesser General Public
15 * License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 */
21
22#include <windows.h>
23#include "options.h"
24
25
27 IN OUT PCONNECTION_INFO Connection,
29 OUT LPWSTR *ConnectionName)
30{
33
34 /* verify that this is a mount options buffer */
35 if (Options &&
36 Options->Zero == 0 &&
38 {
39 Connection->Options = Options;
41 }
42 else
43 {
44 Connection->Options = NULL;
46 }
47
48 Connection->Buffer = LocalAlloc(LMEM_ZEROINIT, size);
49 if (Connection->Buffer)
50 *ConnectionName = (LPWSTR)Connection->Buffer->Buffer;
51 else
53
54 return result;
55}
56
57#ifdef __REACTOS__
59#else
61#endif
63{
64 return sizeof(USHORT) + sizeof(USHORT) + sizeof(ULONG) +
65 Buffer->NameLength + Buffer->EaPadding + Buffer->EaLength;
66}
67
69 IN OUT PCONNECTION_INFO Connection)
70{
71 PCONNECTION_BUFFER Buffer = Connection->Buffer;
72 LPWSTR ConnectionName = (LPWSTR)Buffer->Buffer;
73
74 Buffer->NameLength = (USHORT)(wcslen(ConnectionName) + 1) * sizeof(WCHAR);
75
76 /* copy the EaBuffer after the end of ConnectionName */
77 if (Connection->Options && Connection->Options->Length)
78 {
79 PBYTE ptr = Buffer->Buffer + Buffer->NameLength;
80 /* add padding so EaBuffer starts on a ULONG boundary */
81 Buffer->EaPadding = (USHORT)
82 (sizeof(ULONG) - (SIZE_T)ptr % sizeof(ULONG)) % sizeof(ULONG);
83 Buffer->EaLength = Connection->Options->Length;
84 ptr += Buffer->EaPadding;
85
86 RtlCopyMemory(ptr, Connection->Options->Buffer, Buffer->EaLength);
87 }
88
89 Connection->BufferSize = (ULONG)ConnectionBufferSize(Buffer);
90}
91
93 IN PCONNECTION_INFO Connection)
94{
95 if (Connection->Buffer)
96 {
97 LocalFree(Connection->Buffer);
98 Connection->Buffer = NULL;
99 }
100 Connection->Options = NULL;
101 Connection->BufferSize = 0;
102}
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
void MarshalConnectionInfo(IN OUT PCONNECTION_INFO Connection)
Definition: options.c:68
DWORD InitializeConnectionInfo(IN OUT PCONNECTION_INFO Connection, IN PMOUNT_OPTION_BUFFER Options, OUT LPWSTR *ConnectionName)
Definition: options.c:26
static FORCEINLINE SIZE_T ConnectionBufferSize(IN PCONNECTION_BUFFER Buffer)
Definition: options.c:60
void FreeConnectionInfo(IN PCONNECTION_INFO Connection)
Definition: options.c:92
#define MAX_CONNECTION_BUFFER_SIZE(EaSize)
Definition: options.h:61
#define MOUNT_OPTION_BUFFER_SECRET
Definition: options.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
GLuint64EXT * result
Definition: glext.h:11304
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static PVOID ptr
Definition: dispmode.c:27
BYTE * PBYTE
Definition: pedump.c:66
unsigned short USHORT
Definition: pedump.c:61
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3534
#define FORCEINLINE
Definition: wdftypes.h:67
#define LMEM_ZEROINIT
Definition: winbase.h:400
#define WN_OUT_OF_MEMORY
Definition: winnetwk.h:125
#define WN_SUCCESS
Definition: winnetwk.h:111
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184