2005-09-08 00:09:32 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
|
|
|
* FILE: lib/rtl/propvar.c
|
|
|
|
* PURPOSE: Native properties and variants API
|
2012-06-24 14:11:55 +00:00
|
|
|
* PROGRAMMER: Pierre Schweitzer (pierre@reactos.org)
|
2001-06-17 20:05:10 +00:00
|
|
|
*/
|
2005-09-08 00:09:32 +00:00
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
|
|
|
#include <rtl.h>
|
|
|
|
|
2005-06-19 22:50:59 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
2001-06-17 20:05:10 +00:00
|
|
|
|
2005-09-08 00:09:32 +00:00
|
|
|
/* FUNCTIONS ***************************************************************/
|
|
|
|
|
2012-06-24 14:11:55 +00:00
|
|
|
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;
|
|
|
|
|
2003-07-11 13:50:23 +00:00
|
|
|
/*
|
2012-06-24 14:11:55 +00:00
|
|
|
* @implemented
|
2003-07-11 13:50:23 +00:00
|
|
|
*/
|
2012-06-24 14:11:55 +00:00
|
|
|
PVOID
|
|
|
|
LoadOle32Export(PVOID * BaseAddress, const PCHAR ProcedureName)
|
2001-06-17 20:05:10 +00:00
|
|
|
{
|
2012-06-24 14:11:55 +00:00
|
|
|
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;
|
2001-06-17 20:05:10 +00:00
|
|
|
}
|
|
|
|
|
2003-07-11 13:50:23 +00:00
|
|
|
/*
|
2012-06-24 14:11:55 +00:00
|
|
|
* @implemented
|
2003-07-11 13:50:23 +00:00
|
|
|
*/
|
2012-06-24 14:11:55 +00:00
|
|
|
ULONG
|
2005-10-19 17:03:38 +00:00
|
|
|
NTAPI
|
2012-06-24 14:11:55 +00:00
|
|
|
PropertyLengthAsVariant(IN PSERIALIZEDPROPERTYVALUE pProp,
|
|
|
|
IN ULONG cbProp,
|
|
|
|
IN USHORT CodePage,
|
|
|
|
IN BYTE bReserved)
|
2001-06-17 20:05:10 +00:00
|
|
|
{
|
2012-06-24 16:23:28 +00:00
|
|
|
ULONG Length = 0;
|
2012-06-24 14:11:55 +00:00
|
|
|
PVOID BaseAddress = NULL;
|
|
|
|
ULONG (*ProcedureAddress)(PSERIALIZEDPROPERTYVALUE, ULONG, USHORT, BYTE);
|
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
/* Simply call the appropriate Ole32 export */
|
|
|
|
ProcedureAddress = LoadOle32Export(&BaseAddress,
|
|
|
|
"StgPropertyLengthAsVariant");
|
|
|
|
|
2012-06-24 16:23:28 +00:00
|
|
|
Length = ProcedureAddress(pProp, cbProp, CodePage, bReserved);
|
2012-06-24 14:11:55 +00:00
|
|
|
}
|
|
|
|
_SEH2_FINALLY
|
|
|
|
{
|
|
|
|
if (BaseAddress != NULL)
|
|
|
|
{
|
|
|
|
LdrUnloadDll(BaseAddress);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
2012-06-24 16:23:28 +00:00
|
|
|
return Length;
|
2001-06-17 20:05:10 +00:00
|
|
|
}
|
|
|
|
|
2003-07-11 13:50:23 +00:00
|
|
|
/*
|
2012-06-24 14:11:55 +00:00
|
|
|
* @implemented
|
2003-07-11 13:50:23 +00:00
|
|
|
*/
|
2001-06-17 20:05:10 +00:00
|
|
|
BOOLEAN
|
2005-10-19 17:03:38 +00:00
|
|
|
NTAPI
|
2012-06-24 14:11:55 +00:00
|
|
|
RtlConvertPropertyToVariant(IN PSERIALIZEDPROPERTYVALUE prop,
|
|
|
|
IN USHORT CodePage,
|
|
|
|
OUT PROPVARIANT * pvar,
|
|
|
|
IN PPMemoryAllocator pma)
|
2001-06-17 20:05:10 +00:00
|
|
|
{
|
2012-06-24 14:11:55 +00:00
|
|
|
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;
|
2001-06-17 20:05:10 +00:00
|
|
|
}
|
|
|
|
|
2003-07-11 13:50:23 +00:00
|
|
|
/*
|
2012-06-24 14:11:55 +00:00
|
|
|
* @implemented
|
2003-07-11 13:50:23 +00:00
|
|
|
*/
|
2012-06-24 14:11:55 +00:00
|
|
|
PSERIALIZEDPROPERTYVALUE
|
2005-10-19 17:03:38 +00:00
|
|
|
NTAPI
|
2012-06-24 14:11:55 +00:00
|
|
|
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)
|
2001-06-17 20:05:10 +00:00
|
|
|
{
|
2012-06-24 14:11:55 +00:00
|
|
|
PSERIALIZEDPROPERTYVALUE Serialized = NULL;
|
|
|
|
PVOID BaseAddress = NULL;
|
|
|
|
PSERIALIZEDPROPERTYVALUE (*ProcedureAddress)(const PROPVARIANT*, USHORT, PSERIALIZEDPROPERTYVALUE,
|
|
|
|
PULONG, PROPID, BOOLEAN, PULONG);
|
|
|
|
|
|
|
|
_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;
|
2001-06-17 20:05:10 +00:00
|
|
|
}
|
|
|
|
|
2005-05-09 01:43:25 +00:00
|
|
|
|
2001-06-17 20:05:10 +00:00
|
|
|
/* EOF */
|