ReactOS  0.4.15-dev-1152-g6c94e4f
propvar.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS system libraries
4  * FILE: lib/rtl/propvar.c
5  * PURPOSE: Native properties and variants API
6  * PROGRAMMER: Pierre Schweitzer (pierre@reactos.org)
7  */
8 
9 /* INCLUDES *****************************************************************/
10 
11 #include <rtl.h>
12 
13 #define NDEBUG
14 #include <debug.h>
15 
16 /* FUNCTIONS ***************************************************************/
17 
19 /* FIXME: (or not)
20  * Define those here to allow build. They don't need to be dereferenced
21  * so it's OK.
22  * Furthermore till Vista those Ole32 API were private so those defines
23  * should be made in a private header
24  * Finally, having those defined that way allows to write that code plain C.
25  */
28 
29 /*
30  * @implemented
31  */
32 PVOID
33 LoadOle32Export(PVOID * BaseAddress, const PCHAR ProcedureName)
34 {
36  ANSI_STRING ExportName;
37  PVOID ProcedureAddress;
38 
39  /* First load ole32.dll */
41  if (!NT_SUCCESS(Status))
42  {
44  }
45 
46  RtlInitAnsiString(&ExportName, ProcedureName);
47 
48  /* Look for the procedure */
50  0, &ProcedureAddress);
51  if (!NT_SUCCESS(Status))
52  {
54  }
55 
56  /* Return its address */
57  return ProcedureAddress;
58 }
59 
60 /*
61  * @implemented
62  */
63 ULONG
64 NTAPI
66  IN ULONG cbProp,
67  IN USHORT CodePage,
68  IN BYTE bReserved)
69 {
70  ULONG Length = 0;
72  ULONG (*ProcedureAddress)(PSERIALIZEDPROPERTYVALUE, ULONG, USHORT, BYTE);
73 
74  _SEH2_TRY
75  {
76  /* Simply call the appropriate Ole32 export */
77  ProcedureAddress = LoadOle32Export(&BaseAddress,
78  "StgPropertyLengthAsVariant");
79 
80  Length = ProcedureAddress(pProp, cbProp, CodePage, bReserved);
81  }
83  {
84  if (BaseAddress != NULL)
85  {
87  }
88  }
89  _SEH2_END;
90 
91  return Length;
92 }
93 
94 /*
95  * @implemented
96  */
97 BOOLEAN
98 NTAPI
100  IN USHORT CodePage,
101  OUT PROPVARIANT * pvar,
102  IN PPMemoryAllocator pma)
103 {
106  BOOLEAN (*ProcedureAddress)(PSERIALIZEDPROPERTYVALUE, USHORT, PROPVARIANT*, PPMemoryAllocator);
107 
108  _SEH2_TRY
109  {
110  /* Simply call the appropriate Ole32 export */
111  ProcedureAddress = LoadOle32Export(&BaseAddress,
112  "StgConvertPropertyToVariant");
113 
114  Success = ProcedureAddress(prop, CodePage, pvar, pma);
115  }
117  {
118  if (BaseAddress != NULL)
119  {
121  }
122  }
123  _SEH2_END;
124 
125  return Success;
126 }
127 
128 /*
129  * @implemented
130  */
132 NTAPI
133 RtlConvertVariantToProperty(IN const PROPVARIANT * pvar,
134  IN USHORT CodePage,
136  IN OUT PULONG pcb,
137  IN PROPID pid,
138  IN BOOLEAN fReserved,
139  IN OUT PULONG pcIndirect OPTIONAL)
140 {
141  PSERIALIZEDPROPERTYVALUE Serialized = NULL;
143  PSERIALIZEDPROPERTYVALUE (*ProcedureAddress)(const PROPVARIANT*, USHORT, PSERIALIZEDPROPERTYVALUE,
145 
146  _SEH2_TRY
147  {
148  /* Simply call the appropriate Ole32 export */
149  ProcedureAddress = LoadOle32Export(&BaseAddress,
150  "StgConvertVariantToProperty");
151 
152  Serialized = ProcedureAddress(pvar, CodePage, pprop, pcb, pid, fReserved, pcIndirect);
153  }
155  {
156  if (BaseAddress != NULL)
157  {
159  }
160  }
161  _SEH2_END;
162 
163  return Serialized;
164 }
165 
166 
167 /* EOF */
signed char * PCHAR
Definition: retypes.h:7
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3835
#define IN
Definition: typedefs.h:39
DECLSPEC_NORETURN NTSYSAPI VOID NTAPI RtlRaiseStatus(_In_ NTSTATUS Status)
UNICODE_STRING Old32Dll
Definition: propvar.c:18
PVOID PPMemoryAllocator
Definition: propvar.c:26
LONG NTSTATUS
Definition: precomp.h:26
static const CLSID IPropertyStorage UINT *static const PROPSPEC PROPVARIANT *static UINT const PROPSPEC PROPVARIANT PROPID
Definition: shellole.c:77
_SEH2_TRY
Definition: create.c:4226
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
PVOID PSERIALIZEDPROPERTYVALUE
Definition: propvar.c:27
NTSTATUS NTAPI LdrGetProcedureAddress(IN PVOID BaseAddress, IN PANSI_STRING Name, IN ULONG Ordinal, OUT PVOID *ProcedureAddress)
Definition: ldrapi.c:823
unsigned char BOOLEAN
PSERIALIZEDPROPERTYVALUE NTAPI RtlConvertVariantToProperty(IN const PROPVARIANT *pvar, IN USHORT CodePage, OUT PSERIALIZEDPROPERTYVALUE pprop OPTIONAL, IN OUT PULONG pcb, IN PROPID pid, IN BOOLEAN fReserved, IN OUT PULONG pcIndirect OPTIONAL)
Definition: propvar.c:133
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN NTAPI RtlConvertPropertyToVariant(IN PSERIALIZEDPROPERTYVALUE prop, IN USHORT CodePage, OUT PROPVARIANT *pvar, IN PPMemoryAllocator pma)
Definition: propvar.c:99
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Status
Definition: gdiplustypes.h:24
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS NTAPI DECLSPEC_HOTPATCH LdrLoadDll(IN PWSTR SearchPath OPTIONAL, IN PULONG DllCharacteristics OPTIONAL, IN PUNICODE_STRING DllName, OUT PVOID *BaseAddress)
Definition: ldrapi.c:310
unsigned char BYTE
Definition: xxhash.c:193
NTSTATUS NTAPI LdrUnloadDll(IN PVOID BaseAddress)
Definition: ldrapi.c:1322
_SEH2_END
Definition: create.c:4400
unsigned short USHORT
Definition: pedump.c:61
ULONG NTAPI PropertyLengthAsVariant(IN PSERIALIZEDPROPERTYVALUE pProp, IN ULONG cbProp, IN USHORT CodePage, IN BYTE bReserved)
Definition: propvar.c:65
_SEH2_FINALLY
Definition: create.c:4371
unsigned int * PULONG
Definition: retypes.h:1
#define BOOLEAN
Definition: pedump.c:73
#define OUT
Definition: typedefs.h:40
PVOID LoadOle32Export(PVOID *BaseAddress, const PCHAR ProcedureName)
Definition: propvar.c:33
unsigned int ULONG
Definition: retypes.h:1
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68