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)
9 /* INCLUDES *****************************************************************/
16 /* FUNCTIONS ***************************************************************/
18 UNICODE_STRING Old32Dll
= RTL_CONSTANT_STRING(L
"ole32.dll");
20 * Define those here to allow build. They don't need to be dereferenced
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.
26 typedef PVOID PPMemoryAllocator
;
27 typedef PVOID PSERIALIZEDPROPERTYVALUE
;
33 LoadOle32Export(PVOID
* BaseAddress
, const PCHAR ProcedureName
)
36 ANSI_STRING ExportName
;
37 PVOID ProcedureAddress
;
39 /* First load ole32.dll */
40 Status
= LdrLoadDll(NULL
, NULL
, &Old32Dll
, BaseAddress
);
41 if (!NT_SUCCESS(Status
))
43 RtlRaiseStatus(Status
);
46 RtlInitAnsiString(&ExportName
, ProcedureName
);
48 /* Look for the procedure */
49 Status
= LdrGetProcedureAddress(*BaseAddress
, &ExportName
,
50 0, &ProcedureAddress
);
51 if (!NT_SUCCESS(Status
))
53 RtlRaiseStatus(Status
);
56 /* Return its address */
57 return ProcedureAddress
;
65 PropertyLengthAsVariant(IN PSERIALIZEDPROPERTYVALUE pProp
,
71 PVOID BaseAddress
= NULL
;
72 ULONG (*ProcedureAddress
)(PSERIALIZEDPROPERTYVALUE
, ULONG
, USHORT
, BYTE
);
76 /* Simply call the appropriate Ole32 export */
77 ProcedureAddress
= LoadOle32Export(&BaseAddress
,
78 "StgPropertyLengthAsVariant");
80 Length
= ProcedureAddress(pProp
, cbProp
, CodePage
, bReserved
);
84 if (BaseAddress
!= NULL
)
86 LdrUnloadDll(BaseAddress
);
99 RtlConvertPropertyToVariant(IN PSERIALIZEDPROPERTYVALUE prop
,
101 OUT PROPVARIANT
* pvar
,
102 IN PPMemoryAllocator pma
)
104 BOOLEAN Success
= FALSE
;
105 PVOID BaseAddress
= NULL
;
106 BOOLEAN (*ProcedureAddress
)(PSERIALIZEDPROPERTYVALUE
, USHORT
, PROPVARIANT
*, PPMemoryAllocator
);
110 /* Simply call the appropriate Ole32 export */
111 ProcedureAddress
= LoadOle32Export(&BaseAddress
,
112 "StgConvertPropertyToVariant");
114 Success
= ProcedureAddress(prop
, CodePage
, pvar
, pma
);
118 if (BaseAddress
!= NULL
)
120 LdrUnloadDll(BaseAddress
);
131 PSERIALIZEDPROPERTYVALUE
133 RtlConvertVariantToProperty(IN
const PROPVARIANT
* pvar
,
135 OUT PSERIALIZEDPROPERTYVALUE pprop OPTIONAL
,
138 IN BOOLEAN fReserved
,
139 IN OUT PULONG pcIndirect OPTIONAL
)
141 PSERIALIZEDPROPERTYVALUE Serialized
= NULL
;
142 PVOID BaseAddress
= NULL
;
143 PSERIALIZEDPROPERTYVALUE (*ProcedureAddress
)(const PROPVARIANT
*, USHORT
, PSERIALIZEDPROPERTYVALUE
,
144 PULONG
, PROPID
, BOOLEAN
, PULONG
);
148 /* Simply call the appropriate Ole32 export */
149 ProcedureAddress
= LoadOle32Export(&BaseAddress
,
150 "StgConvertVariantToProperty");
152 Serialized
= ProcedureAddress(pvar
, CodePage
, pprop
, pcb
, pid
, fReserved
, pcIndirect
);
156 if (BaseAddress
!= NULL
)
158 LdrUnloadDll(BaseAddress
);