Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

225 lines
6.3 KiB

  1. //+============================================================================
  2. //
  3. // PropFwd.c
  4. //
  5. // This file provides (slow) forwarders of the NT4 property APIs
  6. // from NTDLL to OLE32. At one time, these APIs were used in both
  7. // kernel mode and user mode. They're now only used in user mode,
  8. // so all the property code has been cosolidated into ole32. Older
  9. // copies of Index Server (CI), however, still link to NTDLL, thus
  10. // the need for these forwarders.
  11. //
  12. //+============================================================================
  13. #include <pch.cxx>
  14. //#include "propvar.h"
  15. //#include "propstm.hxx"
  16. //+----------------------------------------------------------------------------
  17. //
  18. // Function: LoadOle32Export
  19. //
  20. // Synopsis: Load ole32.dll and get one of its exports.
  21. // Raises on error.
  22. //
  23. //+----------------------------------------------------------------------------
  24. PVOID
  25. LoadOle32Export( PVOID* Ole32, const PCHAR ProcedureName )
  26. {
  27. NTSTATUS Status;
  28. UNICODE_STRING Ole32DllName_U;
  29. STRING ProcedureNameString;
  30. PVOID ProcedureAddress = NULL;
  31. RtlInitUnicodeString( &Ole32DllName_U, L"ole32.dll" );
  32. Status = LdrLoadDll( NULL, NULL, &Ole32DllName_U, Ole32 );
  33. if( !NT_SUCCESS(Status) )
  34. RtlRaiseStatus( Status );
  35. RtlInitString( &ProcedureNameString, ProcedureName );
  36. Status = LdrGetProcedureAddress(
  37. *Ole32,
  38. &ProcedureNameString,
  39. 0,
  40. (PVOID*) &ProcedureAddress
  41. );
  42. if( !NT_SUCCESS(Status) )
  43. RtlRaiseStatus(Status);
  44. return( ProcedureAddress );
  45. }
  46. //+----------------------------------------------------------------------------
  47. //
  48. // Function: RtlConvertVariantToProperty
  49. //
  50. // Synopsis: Serialize a variant.
  51. //
  52. //+----------------------------------------------------------------------------
  53. typedef SERIALIZEDPROPERTYVALUE* (*PFNStgConvertVariantToProperty) (
  54. IN PROPVARIANT const *pvar,
  55. IN USHORT CodePage,
  56. OUT SERIALIZEDPROPERTYVALUE *pprop,
  57. IN OUT ULONG *pcb,
  58. IN PROPID pid,
  59. IN BOOLEAN fVariantVector,
  60. OPTIONAL OUT ULONG *pcIndirect);
  61. SERIALIZEDPROPERTYVALUE * PROPSYSAPI PROPAPI
  62. RtlConvertVariantToProperty(
  63. IN PROPVARIANT const *pvar,
  64. IN USHORT CodePage,
  65. OPTIONAL OUT SERIALIZEDPROPERTYVALUE *pprop,
  66. IN OUT ULONG *pcb,
  67. IN PROPID pid,
  68. IN BOOLEAN fVariantVector,
  69. OPTIONAL OUT ULONG *pcIndirect)
  70. {
  71. NTSTATUS Status;
  72. PVOID Ole32 = NULL;
  73. PFNStgConvertVariantToProperty ProcedureAddress;
  74. SERIALIZEDPROPERTYVALUE *ppropRet;
  75. __try
  76. {
  77. ProcedureAddress = (PFNStgConvertVariantToProperty)
  78. LoadOle32Export( &Ole32, "StgConvertVariantToProperty" );
  79. ppropRet = ProcedureAddress( pvar,
  80. CodePage,
  81. pprop,
  82. pcb,
  83. pid,
  84. fVariantVector,
  85. pcIndirect ); // Raises on error
  86. }
  87. __finally
  88. {
  89. if( NULL != Ole32 )
  90. LdrUnloadDll( Ole32 );
  91. }
  92. return (ppropRet );
  93. }
  94. //+----------------------------------------------------------------------------
  95. //
  96. // Function: RtlConvertPropertyToVariant
  97. //
  98. // Synopsis: De-serialize a variant.
  99. //
  100. //+----------------------------------------------------------------------------
  101. typedef BOOLEAN (* PFNStgConvertPropertyToVariant) (
  102. IN SERIALIZEDPROPERTYVALUE const *pprop,
  103. IN USHORT CodePage,
  104. OUT PROPVARIANT *pvar,
  105. IN PMemoryAllocator *pma);
  106. BOOLEAN PROPSYSAPI PROPAPI
  107. RtlConvertPropertyToVariant(
  108. IN SERIALIZEDPROPERTYVALUE const *pprop,
  109. IN USHORT CodePage,
  110. OUT PROPVARIANT *pvar,
  111. IN PMemoryAllocator *pma)
  112. {
  113. BOOLEAN Ret;
  114. NTSTATUS Status;
  115. PVOID Ole32 = NULL;
  116. STRING ProcedureName;
  117. PFNStgConvertPropertyToVariant ProcedureAddress;
  118. __try
  119. {
  120. ProcedureAddress = (PFNStgConvertPropertyToVariant)
  121. LoadOle32Export( &Ole32, "StgConvertPropertyToVariant" );
  122. Ret = ProcedureAddress( pprop, CodePage, pvar, pma ); // Raises on error
  123. }
  124. __finally
  125. {
  126. if( NULL != Ole32 )
  127. LdrUnloadDll( Ole32 );
  128. }
  129. return (Ret);
  130. }
  131. //+----------------------------------------------------------------------------
  132. //
  133. // Function: PropertyLengthAsVariant
  134. //
  135. // Synopsis: Returns the amount of external memory will need to be
  136. // allocated for this variant when RtlPropertyToVariant is called.
  137. //
  138. //+----------------------------------------------------------------------------
  139. typedef ULONG (*PFNStgPropertyLengthAsVariant)(
  140. IN SERIALIZEDPROPERTYVALUE const *pprop,
  141. IN ULONG cbprop,
  142. IN USHORT CodePage,
  143. IN BYTE flags);
  144. ULONG PROPSYSAPI PROPAPI
  145. PropertyLengthAsVariant(
  146. IN SERIALIZEDPROPERTYVALUE const *pprop,
  147. IN ULONG cbprop,
  148. IN USHORT CodePage,
  149. IN BYTE flags)
  150. {
  151. NTSTATUS Status;
  152. ULONG Length;
  153. PVOID Ole32 = NULL;
  154. STRING ProcedureName;
  155. PFNStgPropertyLengthAsVariant ProcedureAddress;
  156. __try
  157. {
  158. ProcedureAddress = (PFNStgPropertyLengthAsVariant)
  159. LoadOle32Export( &Ole32, "StgPropertyLengthAsVariant" );
  160. Length = ProcedureAddress( pprop, cbprop, CodePage, flags ); // Raises on error
  161. }
  162. __finally
  163. {
  164. if( NULL != Ole32 )
  165. LdrUnloadDll( Ole32 );
  166. }
  167. return( Length);
  168. }
  169. //+---------------------------------------------------------------------------
  170. //
  171. // Function: RtlSetUnicodeCallouts, public
  172. //
  173. // Synopsis: Set the Unicode conversion function pointers, used by
  174. // RtlConvertVarianttoProperty, RtlConvertPropertyToVariant,
  175. // and PropertyLengthAsVariant.
  176. //
  177. // These functions are no longer settable (they're defaulted by
  178. // ole32).
  179. //
  180. //---------------------------------------------------------------------------
  181. VOID PROPSYSAPI PROPAPI
  182. RtlSetUnicodeCallouts(
  183. IN UNICODECALLOUTS *pUnicodeCallouts)
  184. {
  185. return;
  186. }