ReactOS  0.4.15-dev-1206-g731eddf
options.c File Reference
#include <windows.h>
#include "options.h"
Include dependency graph for options.c:

Go to the source code of this file.

Functions

DWORD InitializeConnectionInfo (IN OUT PCONNECTION_INFO Connection, IN PMOUNT_OPTION_BUFFER Options, OUT LPWSTR *ConnectionName)
 
static FORCEINLINE SIZE_T ConnectionBufferSize (IN PCONNECTION_BUFFER Buffer)
 
void MarshalConnectionInfo (IN OUT PCONNECTION_INFO Connection)
 
void FreeConnectionInfo (IN PCONNECTION_INFO Connection)
 

Function Documentation

◆ ConnectionBufferSize()

static FORCEINLINE SIZE_T ConnectionBufferSize ( IN PCONNECTION_BUFFER  Buffer)
static

Definition at line 60 of file options.c.

63 {
64  return sizeof(USHORT) + sizeof(USHORT) + sizeof(ULONG) +
65  Buffer->NameLength + Buffer->EaPadding + Buffer->EaLength;
66 }
Definition: bufpool.h:45
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1

Referenced by MarshalConnectionInfo().

◆ FreeConnectionInfo()

void FreeConnectionInfo ( IN PCONNECTION_INFO  Connection)

Definition at line 92 of file options.c.

94 {
95  if (Connection->Buffer)
96  {
97  LocalFree(Connection->Buffer);
98  Connection->Buffer = NULL;
99  }
100  Connection->Options = NULL;
101  Connection->BufferSize = 0;
102 }
smooth NULL
Definition: ftsmooth.c:416
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577

Referenced by NPAddConnection3().

◆ InitializeConnectionInfo()

DWORD InitializeConnectionInfo ( IN OUT PCONNECTION_INFO  Connection,
IN PMOUNT_OPTION_BUFFER  Options,
OUT LPWSTR ConnectionName 
)

Definition at line 26 of file options.c.

30 {
32  SIZE_T size;
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 }
#define WN_SUCCESS
Definition: winnetwk.h:111
enum OPTION_FLAGS Options
Definition: stats.c:44
smooth NULL
Definition: ftsmooth.c:416
#define MAX_CONNECTION_BUFFER_SIZE(EaSize)
Definition: options.h:61
GLsizeiptr size
Definition: glext.h:5919
#define LMEM_ZEROINIT
Definition: winbase.h:356
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MOUNT_OPTION_BUFFER_SECRET
Definition: options.h:26
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define WN_OUT_OF_MEMORY
Definition: winnetwk.h:125
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
WCHAR * LPWSTR
Definition: xmlstorage.h:184
GLuint64EXT * result
Definition: glext.h:11304

Referenced by NPAddConnection3().

◆ MarshalConnectionInfo()

void MarshalConnectionInfo ( IN OUT PCONNECTION_INFO  Connection)

Definition at line 68 of file options.c.

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 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
static PVOID ptr
Definition: dispmode.c:27
Definition: bufpool.h:45
static FORCEINLINE SIZE_T ConnectionBufferSize(IN PCONNECTION_BUFFER Buffer)
Definition: options.c:60
__wchar_t WCHAR
Definition: xmlstorage.h:180
ULONG_PTR SIZE_T
Definition: typedefs.h:80
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
BYTE * PBYTE
Definition: pedump.c:66
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by NPAddConnection3().