Author: pschweitzer
Date: Sun Jun 24 14:11:55 2012
New Revision: 56795
URL:
http://svn.reactos.org/svn/reactos?rev=56795&view=rev
Log:
[RTL]
Implement RtlConvertVariantToProperty, RtlConvertPropertyToVariant,
PropertyLengthAsVariant
Those are just wrappers around Ole32 functions.
Modified:
trunk/reactos/lib/rtl/propvar.c
Modified: trunk/reactos/lib/rtl/propvar.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/propvar.c?rev=5679…
==============================================================================
--- trunk/reactos/lib/rtl/propvar.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/propvar.c [iso-8859-1] Sun Jun 24 14:11:55 2012
@@ -3,7 +3,7 @@
* PROJECT: ReactOS system libraries
* FILE: lib/rtl/propvar.c
* PURPOSE: Native properties and variants API
- * PROGRAMMER:
+ * PROGRAMMER: Pierre Schweitzer (pierre(a)reactos.org)
*/
/* INCLUDES *****************************************************************/
@@ -15,66 +15,152 @@
/* FUNCTIONS ***************************************************************/
+UNICODE_STRING Old32Dll = RTL_CONSTANT_STRING(L"ole32.dll");
+/* FIXME: (or not)
+ * Define those here to allow build. They don't need to be dereferenced
+ * so it's OK.
+ * Furthermore till Vista those Ole32 API were private so those defines
+ * should be made in a private header
+ * Finally, having those defined that way allows to write that code plain C.
+ */
+typedef PVOID PPMemoryAllocator;
+typedef PVOID PSERIALIZEDPROPERTYVALUE;
+
/*
- * @unimplemented
+ * @implemented
*/
-NTSTATUS
-NTAPI
-PropertyLengthAsVariant (
- DWORD Unknown0,
- DWORD Unknown1,
- DWORD Unknown2,
- DWORD Unknown3
- )
+PVOID
+LoadOle32Export(PVOID * BaseAddress, const PCHAR ProcedureName)
{
- return (STATUS_NOT_IMPLEMENTED);
+ NTSTATUS Status;
+ ANSI_STRING ExportName;
+ PVOID ProcedureAddress;
+
+ /* First load ole32.dll */
+ Status = LdrLoadDll(NULL, NULL, &Old32Dll, BaseAddress);
+ if (!NT_SUCCESS(Status))
+ {
+ RtlRaiseStatus(Status);
+ }
+
+ RtlInitAnsiString(&ExportName, ProcedureName);
+
+ /* Look for the procedure */
+ Status = LdrGetProcedureAddress(*BaseAddress, &ExportName,
+ 0, &ProcedureAddress);
+ if (!NT_SUCCESS(Status))
+ {
+ RtlRaiseStatus(Status);
+ }
+
+ /* Return its address */
+ return ProcedureAddress;
}
/*
- * @unimplemented
+ * @implemented
+ */
+ULONG
+NTAPI
+PropertyLengthAsVariant(IN PSERIALIZEDPROPERTYVALUE pProp,
+ IN ULONG cbProp,
+ IN USHORT CodePage,
+ IN BYTE bReserved)
+{
+ BOOLEAN Success = FALSE;
+ PVOID BaseAddress = NULL;
+ ULONG (*ProcedureAddress)(PSERIALIZEDPROPERTYVALUE, ULONG, USHORT, BYTE);
+
+ _SEH2_TRY
+ {
+ /* Simply call the appropriate Ole32 export */
+ ProcedureAddress = LoadOle32Export(&BaseAddress,
+ "StgPropertyLengthAsVariant");
+
+ Success = ProcedureAddress(pProp, cbProp, CodePage, bReserved);
+ }
+ _SEH2_FINALLY
+ {
+ if (BaseAddress != NULL)
+ {
+ LdrUnloadDll(BaseAddress);
+ }
+ }
+ _SEH2_END;
+
+ return Success;
+}
+
+/*
+ * @implemented
*/
BOOLEAN
NTAPI
-RtlCompareVariants (
- DWORD Unknown0,
- DWORD Unknown1,
- DWORD Unknown2
- )
+RtlConvertPropertyToVariant(IN PSERIALIZEDPROPERTYVALUE prop,
+ IN USHORT CodePage,
+ OUT PROPVARIANT * pvar,
+ IN PPMemoryAllocator pma)
{
- return (FALSE);
+ BOOLEAN Success = FALSE;
+ PVOID BaseAddress = NULL;
+ BOOLEAN (*ProcedureAddress)(PSERIALIZEDPROPERTYVALUE, USHORT, PROPVARIANT*,
PPMemoryAllocator);
+
+ _SEH2_TRY
+ {
+ /* Simply call the appropriate Ole32 export */
+ ProcedureAddress = LoadOle32Export(&BaseAddress,
+ "StgConvertPropertyToVariant");
+
+ Success = ProcedureAddress(prop, CodePage, pvar, pma);
+ }
+ _SEH2_FINALLY
+ {
+ if (BaseAddress != NULL)
+ {
+ LdrUnloadDll(BaseAddress);
+ }
+ }
+ _SEH2_END;
+
+ return Success;
}
/*
- * @unimplemented
+ * @implemented
*/
-BOOLEAN
+PSERIALIZEDPROPERTYVALUE
NTAPI
-RtlConvertPropertyToVariant (
- DWORD Unknown0,
- DWORD Unknown1,
- DWORD Unknown2,
- DWORD Unknown3
- )
+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)
{
- return (FALSE);
-}
+ PSERIALIZEDPROPERTYVALUE Serialized = NULL;
+ PVOID BaseAddress = NULL;
+ PSERIALIZEDPROPERTYVALUE (*ProcedureAddress)(const PROPVARIANT*, USHORT,
PSERIALIZEDPROPERTYVALUE,
+ PULONG, PROPID, BOOLEAN, PULONG);
-/*
- * @unimplemented
- */
-NTSTATUS
-NTAPI
-RtlConvertVariantToProperty (
- DWORD Unknown0,
- DWORD Unknown1,
- DWORD Unknown2,
- DWORD Unknown3,
- DWORD Unknown4,
- DWORD Unknown5,
- DWORD Unknown6
- )
-{
- return (STATUS_NOT_IMPLEMENTED);
+ _SEH2_TRY
+ {
+ /* Simply call the appropriate Ole32 export */
+ ProcedureAddress = LoadOle32Export(&BaseAddress,
+ "StgConvertVariantToProperty");
+
+ Serialized = ProcedureAddress(pvar, CodePage, pprop, pcb, pid, fReserved,
pcIndirect);
+ }
+ _SEH2_FINALLY
+ {
+ if (BaseAddress != NULL)
+ {
+ LdrUnloadDll(BaseAddress);
+ }
+ }
+ _SEH2_END;
+
+ return Serialized;
}