internal static uint MsiRecordReadStream(int hRecord, uint iField, byte[] szDataBuf, ref uint cbDataBuf)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord))
     {
         return(NativeMethods.MsiRecordReadStream(hRecord, iField, szDataBuf, ref cbDataBuf));
     }
     else
     {
         lock (RemotableNativeMethods.remotingDelegate)
         {
             ClearData(requestBuf);
             unchecked
             {
                 WriteInt(requestBuf, 0, RemotableNativeMethods.GetRemoteHandle(hRecord));
                 WriteInt(requestBuf, 1, (int)iField);
                 WriteInt(requestBuf, 2, (int)cbDataBuf);
                 IntPtr resp;
                 remotingDelegate(RemoteMsiFunctionId.MsiRecordReadStream, requestBuf, out resp);
                 uint ret = (uint)ReadInt(resp, 0);
                 if (ret == 0)
                 {
                     cbDataBuf = (uint)ReadInt(resp, 2);
                     if (cbDataBuf > 0)
                     {
                         RemotableNativeMethods.ReadStream(resp, 1, szDataBuf, (int)cbDataBuf);
                     }
                 }
                 return(ret);
             }
         }
     }
 }
 internal static int MsiProcessMessage(int hInstall, uint eMessageType, int hRecord)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall))
     {
         return(NativeMethods.MsiProcessMessage(hInstall, eMessageType, hRecord));
     }
     else
     {
         lock (remotingDelegate)
         {
             // I don't understand why, but this particular function doesn't work
             // when using the static requestBuf -- some data doesn't make it through.
             // But it works when a fresh buffer is allocated here every call.
             IntPtr buf = Marshal.AllocHGlobal(
                 requestFieldSize * MAX_REQUEST_FIELDS);
             ClearData(buf);
             WriteInt(buf, 0, RemotableNativeMethods.GetRemoteHandle(hInstall));
             WriteInt(buf, 1, unchecked ((int)eMessageType));
             WriteInt(buf, 2, RemotableNativeMethods.GetRemoteHandle(hRecord));
             IntPtr resp;
             remotingDelegate(RemoteMsiFunctionId.MsiProcessMessage, buf, out resp);
             Marshal.FreeHGlobal(buf);
             return(ReadInt(resp, 0));
         }
     }
 }
        internal static uint MsiSummaryInfoGetProperty(int hSummaryInfo, uint uiProperty, out uint uiDataType, out int iValue, ref long ftValue, StringBuilder szValueBuf, ref uint cchValueBuf)
        {
            if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hSummaryInfo))
            {
                return(NativeMethods.MsiSummaryInfoGetProperty(hSummaryInfo, uiProperty, out uiDataType, out iValue, ref ftValue, szValueBuf, ref cchValueBuf));
            }
            else
            {
                lock (RemotableNativeMethods.remotingDelegate)
                {
                    ClearData(requestBuf);
                    WriteInt(requestBuf, 0, RemotableNativeMethods.GetRemoteHandle(hSummaryInfo));
                    WriteInt(requestBuf, 1, (int)uiProperty);
                    IntPtr resp;
                    remotingDelegate(RemoteMsiFunctionId.MsiSummaryInfoGetProperty, requestBuf, out resp);
                    unchecked
                    {
                        uint ret = (uint)ReadInt(resp, 0);
                        if (ret == 0)
                        {
                            uiDataType = (uint)ReadInt(resp, 1);
                            switch ((VarEnum)uiDataType)
                            {
                            case VarEnum.VT_I2:
                            case VarEnum.VT_I4:
                                iValue = ReadInt(resp, 2);
                                break;

                            case VarEnum.VT_FILETIME:
                                uint ftHigh = (uint)ReadInt(resp, 2);
                                uint ftLow  = (uint)ReadInt(resp, 3);
                                ftValue = ((long)ftHigh) << 32 | ((long)ftLow);
                                iValue  = 0;
                                break;

                            case VarEnum.VT_LPSTR:
                                ReadString(resp, 2, szValueBuf, ref cchValueBuf);
                                iValue = 0;
                                break;

                            default:
                                iValue = 0;
                                break;
                            }
                        }
                        else
                        {
                            uiDataType = 0;
                            iValue     = 0;
                        }
                        return(ret);
                    }
                }
            }
        }
 internal static uint MsiCloseHandle(int hAny)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hAny))
     {
         return(NativeMethods.MsiCloseHandle(hAny));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_III(
                    RemoteMsiFunctionId.MsiCloseHandle, RemotableNativeMethods.GetRemoteHandle(hAny), 0, 0));
     }
 }
 internal static uint MsiSetFeatureState(int hInstall, string szFeature, int iState)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall))
     {
         return(NativeMethods.MsiSetFeatureState(hInstall, szFeature, iState));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_ISI(
                    RemoteMsiFunctionId.MsiSetFeatureState,
                    RemotableNativeMethods.GetRemoteHandle(hInstall), szFeature, iState));
     }
 }
 internal static uint MsiEnumComponentCosts(int hInstall, string szComponent, uint dwIndex, int iState, StringBuilder lpDriveBuf, ref uint cchDriveBuf, out int iCost, out int iTempCost)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall))
     {
         return(NativeMethods.MsiEnumComponentCosts(hInstall, szComponent, dwIndex, iState, lpDriveBuf, ref cchDriveBuf, out iCost, out iTempCost));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_ISII_SII(
                    RemoteMsiFunctionId.MsiEvaluateCondition,
                    RemotableNativeMethods.GetRemoteHandle(hInstall),
                    szComponent, (int)dwIndex, iState, lpDriveBuf, ref cchDriveBuf, out iCost, out iTempCost));
     }
 }
        internal static int GetRemoteHandle(int handle)
        {
            if (handle == 0)
            {
                return(handle);
            }

            if (!RemotableNativeMethods.IsRemoteHandle(handle))
            {
                throw new InvalidOperationException("Handle does not have the remote bit set.");
            }

            return(handle ^ Int32.MinValue);
        }
        internal static int MakeRemoteHandle(int handle)
        {
            if (handle == 0)
            {
                return(handle);
            }

            if (RemotableNativeMethods.IsRemoteHandle(handle))
            {
                throw new InvalidOperationException("Handle already has the remote bit set.");
            }

            return(handle ^ Int32.MinValue);
        }
 internal static uint MsiRecordDataSize(int hRecord, uint iField)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord))
     {
         return(NativeMethods.MsiRecordDataSize(hRecord, iField));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_III(
                    RemoteMsiFunctionId.MsiRecordDataSize,
                    RemotableNativeMethods.GetRemoteHandle(hRecord),
                    (int)iField, 0));
     }
 }
Exemplo n.º 10
0
 internal static uint MsiRecordSetInteger(int hRecord, uint iField, int iValue)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord))
     {
         return(NativeMethods.MsiRecordSetInteger(hRecord, iField, iValue));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_III(
                    RemoteMsiFunctionId.MsiRecordSetInteger,
                    RemotableNativeMethods.GetRemoteHandle(hRecord),
                    (int)iField,
                    iValue));
     }
 }
Exemplo n.º 11
0
 internal static uint MsiSetProperty(int hInstall, string szName, string szValue)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall))
     {
         return(NativeMethods.MsiSetProperty(hInstall, szName, szValue));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_ISS(
                    RemoteMsiFunctionId.MsiSetProperty,
                    RemotableNativeMethods.GetRemoteHandle(hInstall),
                    szName,
                    szValue));
     }
 }
Exemplo n.º 12
0
 internal static uint MsiVerifyDiskSpace(int hInstall)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall))
     {
         return(NativeMethods.MsiVerifyDiskSpace(hInstall));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_III(
                    RemoteMsiFunctionId.MsiVerifyDiskSpace,
                    RemotableNativeMethods.GetRemoteHandle(hInstall),
                    0,
                    0));
     }
 }
Exemplo n.º 13
0
 internal static uint MsiSetTargetPath(int hInstall, string szFolder, string szFolderPath)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall))
     {
         return(NativeMethods.MsiSetTargetPath(hInstall, szFolder, szFolderPath));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_ISS(
                    RemoteMsiFunctionId.MsiSetTargetPath,
                    RemotableNativeMethods.GetRemoteHandle(hInstall),
                    szFolder,
                    szFolderPath));
     }
 }
Exemplo n.º 14
0
 internal static uint MsiSetInstallLevel(int hInstall, int iInstallLevel)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall))
     {
         return(NativeMethods.MsiSetInstallLevel(hInstall, iInstallLevel));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_III(
                    RemoteMsiFunctionId.MsiSetInstallLevel,
                    RemotableNativeMethods.GetRemoteHandle(hInstall),
                    iInstallLevel,
                    0));
     }
 }
Exemplo n.º 15
0
 internal static uint MsiSetFeatureAttributes(int hInstall, string szFeature, uint dwAttributes)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall))
     {
         return(NativeMethods.MsiSetFeatureAttributes(hInstall, szFeature, dwAttributes));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_ISI(
                    RemoteMsiFunctionId.MsiSetFeatureAttributes,
                    RemotableNativeMethods.GetRemoteHandle(hInstall),
                    szFeature,
                    (int)dwAttributes));
     }
 }
Exemplo n.º 16
0
 internal static uint MsiRecordSetString(int hRecord, uint iField, string szValue)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord))
     {
         return(NativeMethods.MsiRecordSetString(hRecord, iField, szValue));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_IIS(
                    RemoteMsiFunctionId.MsiRecordSetString,
                    RemotableNativeMethods.GetRemoteHandle(hRecord),
                    (int)iField,
                    szValue));
     }
 }
Exemplo n.º 17
0
 internal static int MsiGetLanguage(int hInstall)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall))
     {
         return(NativeMethods.MsiGetLanguage(hInstall));
     }
     else
     {
         return(unchecked ((int)RemotableNativeMethods.MsiFunc_III(
                               RemoteMsiFunctionId.MsiGetLanguage,
                               RemotableNativeMethods.GetRemoteHandle(hInstall),
                               0,
                               0)));
     }
 }
Exemplo n.º 18
0
 internal static bool MsiGetMode(int hInstall, uint iRunMode)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall))
     {
         return(NativeMethods.MsiGetMode(hInstall, iRunMode));
     }
     else
     {
         return(0 != RemotableNativeMethods.MsiFunc_III(
                    RemoteMsiFunctionId.MsiGetMode,
                    RemotableNativeMethods.GetRemoteHandle(hInstall),
                    (int)iRunMode,
                    0));
     }
 }
Exemplo n.º 19
0
 internal static uint MsiEvaluateCondition(int hInstall, string szCondition)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall))
     {
         return(NativeMethods.MsiEvaluateCondition(hInstall, szCondition));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_ISI(
                    RemoteMsiFunctionId.MsiEvaluateCondition,
                    RemotableNativeMethods.GetRemoteHandle(hInstall),
                    szCondition,
                    0));
     }
 }
Exemplo n.º 20
0
 internal static uint MsiDatabaseIsTablePersistent(int hDatabase, string szTableName)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hDatabase))
     {
         return(NativeMethods.MsiDatabaseIsTablePersistent(hDatabase, szTableName));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_ISI(
                    RemoteMsiFunctionId.MsiDatabaseIsTablePersistent,
                    RemotableNativeMethods.GetRemoteHandle(hDatabase),
                    szTableName,
                    0));
     }
 }
Exemplo n.º 21
0
 internal static uint MsiRecordClearData(int hRecord)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord))
     {
         return(NativeMethods.MsiRecordClearData(hRecord));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_III(
                    RemoteMsiFunctionId.MsiRecordClearData,
                    RemotableNativeMethods.GetRemoteHandle(hRecord),
                    0,
                    0));
     }
 }
Exemplo n.º 22
0
 internal static bool MsiRecordIsNull(int hRecord, uint iField)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord))
     {
         return(NativeMethods.MsiRecordIsNull(hRecord, iField));
     }
     else
     {
         return(0 != RemotableNativeMethods.MsiFunc_III(
                    RemoteMsiFunctionId.MsiRecordIsNull,
                    RemotableNativeMethods.GetRemoteHandle(hRecord),
                    (int)iField,
                    0));
     }
 }
Exemplo n.º 23
0
 internal static uint MsiViewModify(int hView, int iModifyMode, int hRecord)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hView))
     {
         return(NativeMethods.MsiViewModify(hView, iModifyMode, hRecord));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_III(
                    RemoteMsiFunctionId.MsiViewModify,
                    RemotableNativeMethods.GetRemoteHandle(hView),
                    iModifyMode,
                    RemotableNativeMethods.GetRemoteHandle(hRecord)));
     }
 }
Exemplo n.º 24
0
 internal static uint MsiViewExecute(int hView, int hRecord)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hView))
     {
         return(NativeMethods.MsiViewExecute(hView, hRecord));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_III(
                    RemoteMsiFunctionId.MsiViewExecute,
                    RemotableNativeMethods.GetRemoteHandle(hView),
                    RemotableNativeMethods.GetRemoteHandle(hRecord),
                    0));
     }
 }
Exemplo n.º 25
0
 internal static uint MsiGetSourcePath(int hInstall, string szFolder, StringBuilder szPathBuf, ref uint cchPathBuf)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall))
     {
         return(NativeMethods.MsiGetSourcePath(hInstall, szFolder, szPathBuf, ref cchPathBuf));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_IS_S(
                    RemoteMsiFunctionId.MsiGetSourcePath,
                    RemotableNativeMethods.GetRemoteHandle(hInstall),
                    szFolder,
                    szPathBuf,
                    ref cchPathBuf));
     }
 }
Exemplo n.º 26
0
 internal static uint MsiGetComponentState(int hInstall, string szComponent, out int iInstalled, out int iAction)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall))
     {
         return(NativeMethods.MsiGetComponentState(hInstall, szComponent, out iInstalled, out iAction));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_IS_II(
                    RemoteMsiFunctionId.MsiGetComponentState,
                    RemotableNativeMethods.GetRemoteHandle(hInstall),
                    szComponent,
                    out iInstalled,
                    out iAction));
     }
 }
Exemplo n.º 27
0
 internal static uint MsiRecordGetString(int hRecord, uint iField, StringBuilder szValueBuf, ref uint cchValueBuf)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord))
     {
         return(NativeMethods.MsiRecordGetString(hRecord, iField, szValueBuf, ref cchValueBuf));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_II_S(
                    RemoteMsiFunctionId.MsiRecordGetString,
                    RemotableNativeMethods.GetRemoteHandle(hRecord),
                    (int)iField,
                    szValueBuf,
                    ref cchValueBuf));
     }
 }
Exemplo n.º 28
0
 internal static uint MsiFormatRecord(int hInstall, int hRecord, StringBuilder szResultBuf, ref uint cchResultBuf)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hRecord))
     {
         return(NativeMethods.MsiFormatRecord(hInstall, hRecord, szResultBuf, ref cchResultBuf));
     }
     else
     {
         return(RemotableNativeMethods.MsiFunc_II_S(
                    RemoteMsiFunctionId.MsiFormatRecord,
                    RemotableNativeMethods.GetRemoteHandle(hInstall),
                    RemotableNativeMethods.GetRemoteHandle(hRecord),
                    szResultBuf,
                    ref cchResultBuf));
     }
 }
Exemplo n.º 29
0
 internal static int MsiViewGetError(int hView, StringBuilder szColumnNameBuffer, ref uint cchBuf)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hView))
     {
         return(NativeMethods.MsiViewGetError(hView, szColumnNameBuffer, ref cchBuf));
     }
     else
     {
         return(unchecked ((int)RemotableNativeMethods.MsiFunc_II_S(
                               RemoteMsiFunctionId.MsiViewGetError,
                               RemotableNativeMethods.GetRemoteHandle(hView),
                               0,
                               szColumnNameBuffer,
                               ref cchBuf)));
     }
 }
Exemplo n.º 30
0
 internal static int MsiGetActiveDatabase(int hInstall)
 {
     if (!RemotingEnabled || !RemotableNativeMethods.IsRemoteHandle(hInstall))
     {
         return(NativeMethods.MsiGetActiveDatabase(hInstall));
     }
     else
     {
         int hDatabase = (int)RemotableNativeMethods.MsiFunc_III(
             RemoteMsiFunctionId.MsiGetActiveDatabase,
             RemotableNativeMethods.GetRemoteHandle(hInstall),
             0,
             0);
         return(RemotableNativeMethods.MakeRemoteHandle(hDatabase));
     }
 }