예제 #1
0
        /// <summary>
        /// Copies a memory block from one location to another.
        /// </summary>
        /// <param name="destination">A pointer to the starting address of the move destination.</param>
        /// <param name="source">A pointer to the starting address of the block of memory to be moved.</param>
        /// <param name="length">The size of the memory block to move, in bytes.</param>
        public void CopyMemoryImpl(IntPtr destination, IntPtr source, IntPtr length)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent("kernel32.dll", "CopyMemory");
            evt.Data.Add("destination", destination);
            evt.Data.Add("source", source);
            evt.Data.Add("length", length);

            try
            {
                UnsafeNativeMethods.CopyMemory(destination, source, length);
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }
        }
예제 #2
0
        /// <summary>
        /// Allocates a new locally unique identifier.
        /// </summary>
        /// <param name="pLuid">Pointer to a <see cref="DotRas.Luid"/> structure that upon return, receives the generated LUID instance.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int AllocateLocallyUniqueIdImpl(IntPtr pLuid)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.AdvApi32Dll, "AllocateLocallyUniqueId");
            evt.Data.Add("pLuid", pLuid);

            int retval = 0;

            try
            {
                bool ret = SafeNativeMethods.AllocateLocallyUniqueId(pLuid);
                if (!ret)
                {
                    retval = Marshal.GetLastWin32Error();
                    evt.ResultCode = retval;
                }
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }            

            return retval;
        }
예제 #3
0
        /// <summary>
        /// Retrieves information on the current status of the specified remote access connection handle.
        /// </summary>
        /// <param name="handle">The handle to check.</param>
        /// <param name="connectionStatus">Pointer to a <see cref="NativeMethods.RASCONNSTATUS"/> structure that upon return contains the status information for the handle specified by <paramref name="handle"/>.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int GetConnectStatus(RasHandle handle, IntPtr connectionStatus)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasGetConnectStatus");
            evt.Data.Add("handle", handle);
            evt.Data.Add("connectionStatus", connectionStatus);

            int result = 0;

            try
            {
                result = SafeNativeMethods.RasGetConnectStatus(handle, connectionStatus);
                evt.ResultCode = result;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #4
0
        /// <summary>
        /// Store user-specific Extensible Authentication Protocol (EAP) information for the specified phone book entry in the registry.
        /// </summary>
        /// <param name="handle">The handle to a primary or impersonation access token.</param>
        /// <param name="phoneBookPath">The full path and filename of a phone book file. If this parameter is a null reference (<b>Nothing</b> in Visual Basic), the default phone book is used.</param>
        /// <param name="entryName">The entry name to validate.</param>
        /// <param name="eapData">Pointer to a buffer that receives the retrieved EAP data for the user.</param>
        /// <param name="sizeOfEapData">On input specifies the size in bytes of the buffer pointed to by <paramref name="eapData"/>, upon output receives the size of the buffer needed to contain the EAP data.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int SetEapUserData(IntPtr handle, string phoneBookPath, string entryName, IntPtr eapData, int sizeOfEapData)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasSetEapUserData");
            evt.Data.Add("handle", handle);
            evt.Data.Add("phoneBookPath", phoneBookPath);
            evt.Data.Add("entryName", entryName);
            evt.Data.Add("eapData", eapData);
            evt.Data.Add("sizeOfEapData", sizeOfEapData);

            int result = 0;

            try
            {
                result = UnsafeNativeMethods.RasSetEapUserData(handle, phoneBookPath, entryName, eapData, sizeOfEapData);
                evt.ResultCode = result;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #5
0
        /// <summary>
        /// Sets the value of an AutoDial parameter.
        /// </summary>
        /// <param name="key">The parameter whose value to set.</param>
        /// <param name="value">A pointer containing the new value of the parameter.</param>
        /// <param name="bufferSize">The size of the buffer.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int SetAutodialParam(NativeMethods.RASADP key, IntPtr value, int bufferSize)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasSetAutodialParam");
            evt.Data.Add("key", key);
            evt.Data.Add("value", value);
            evt.Data.Add("bufferSize", bufferSize);

            int result = 0;

            try
            {
                result = UnsafeNativeMethods.RasSetAutodialParam(key, value, bufferSize);
                evt.ResultCode = result;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #6
0
        /// <summary>
        /// Updates an address in the AutoDial mapping database.
        /// </summary>
        /// <param name="address">The address for which information is being updated.</param>
        /// <param name="reserved">Reserved. This value must be zero.</param>
        /// <param name="addresses">Pointer to an array of <see cref="NativeMethods.RASAUTODIALENTRY"/> structures.</param>
        /// <param name="bufferSize">Upon return, contains the size in bytes of the buffer specified by <paramref name="addresses"/>. Upon return contains the number of bytes required to successfully complete the call.</param>
        /// <param name="count">Upon return, contains the number of phone book entries written to the buffer specified by <paramref name="addresses"/>.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int SetAutodialAddress(string address, int reserved, IntPtr addresses, int bufferSize, int count)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasSetAutodialAddress");
            evt.Data.Add("address", address);
            evt.Data.Add("reserved", reserved);
            evt.Data.Add("addresses", addresses);
            evt.Data.Add("bufferSize", bufferSize);
            evt.Data.Add("count", count);

            int result = 0;

            try
            {
                result = UnsafeNativeMethods.RasSetAutodialAddress(address, reserved, addresses, bufferSize, count);
                evt.ResultCode = result;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #7
0
        /// <summary>
        /// Displays the main dial-up networking dialog box.
        /// </summary>
        /// <param name="phoneBookPath">The full path and filename of a phone book file. If this parameter is a null reference, the default phone book is used.</param>
        /// <param name="entryName">The name of the phone book entry to initially highlight.</param>
        /// <param name="info">An <see cref="NativeMethods.RASPBDLG"/> structure containing additional input/output parameters.</param>
        /// <returns><b>true</b> if the user dials an entry successfully, otherwise <b>false</b>.</returns>
        public bool PhonebookDlg(string phoneBookPath, string entryName, ref NativeMethods.RASPBDLG info)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasPhonebookDlg");
            evt.Data.Add("phoneBookPath", phoneBookPath);
            evt.Data.Add("entryName", entryName);
            evt.Data.Add("info", info);

            bool result = false;

            try
            {
                result = UnsafeNativeMethods.RasPhonebookDlg(phoneBookPath, entryName, ref info);
                evt.ResultCode = result ? 1 : 0;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #8
0
        /// <summary>
        /// Retrieves the value of an AutoDial parameter.
        /// </summary>
        /// <param name="value">An <see cref="RasGetAutodialParamParams"/> containing call data.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int GetAutodialParam(RasGetAutodialParamParams value)
        {
            if (value == null)
            {
                ThrowHelper.ThrowArgumentNullException("value");
            }

            int bufferSize = value.BufferSize;

            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasGetAutodialParam");
            evt.Data.Add("key", value.Key);
            evt.Data.Add("address", value.Address);
            evt.Data.Add("bufferSize-IN", bufferSize);

            int result = 0;

            try
            {
                result = UnsafeNativeMethods.RasGetAutodialParam(value.Key, value.Address, ref bufferSize);
                evt.ResultCode = result;
                evt.Data.Add("bufferSize-OUT", bufferSize);

                value.BufferSize = bufferSize;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }
            
            return result;
        }
예제 #9
0
        /// <summary>
        /// Retrieves a connection handle for a subentry of a multilink connection.
        /// </summary>
        /// <param name="handle">The handle to the connection.</param>
        /// <param name="subEntryId">The one-based index of the subentry to whose handle to retrieve.</param>
        /// <param name="result">Upon return, contains the handle to the subentry connection.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int GetSubEntryHandle(RasHandle handle, int subEntryId, out IntPtr result)
        {
            result = IntPtr.Zero;

            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasGetSubEntryHandle");
            evt.Data.Add("handle", handle);
            evt.Data.Add("subEntryId", subEntryId);
            evt.Data.Add("result-IN", result);

            int ret = 0;

            try
            {
                ret = SafeNativeMethods.RasGetSubEntryHandle(handle, subEntryId, out result);
                evt.ResultCode = ret;
                evt.Data.Add("result-OUT", result);
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return ret;
        }
예제 #10
0
        /// <summary>
        /// Obtains information about a remote access projection operation for all RAS connections on the local client.
        /// </summary>
        /// <param name="handle">The handle to the connection.</param>
        /// <param name="projection">Pointer to a <see cref="NativeMethods.RAS_PROJECTION_INFO"/> structure that receives the projection information for the RAS connections.</param>
        /// <param name="bufferSize">On input specifies the size in bytes of the buffer pointed to by <paramref name="projection"/>, upon output receives the size of the buffer needed to contain the projection information.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int GetProjectionInfoEx(RasHandle handle, IntPtr projection, ref IntPtr bufferSize)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasGetProjectionInfoEx");
            evt.Data.Add("handle", handle);
            evt.Data.Add("projection", projection);
            evt.Data.Add("bufferSize-IN", bufferSize);

            int result = 0;

            try
            {
                result = SafeNativeMethods.RasGetProjectionInfoEx(handle, projection, ref bufferSize);
                evt.ResultCode = result;
                evt.Data.Add("bufferSize-OUT", bufferSize);
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #11
0
        /// <summary>
        /// Retrieves accumulated statistics for the specified link in a RAS multilink connection.
        /// </summary>
        /// <param name="handle">The handle to the connection.</param>
        /// <param name="subEntryId">The subentry index that corresponds to the link for which to retrieve statistics.</param>
        /// <param name="statistics">Pointer to a <see cref="NativeMethods.RAS_STATS"/> structure which will receive the statistics.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int GetLinkStatistics(RasHandle handle, int subEntryId, IntPtr statistics)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasGetLinkStatistics");
            evt.Data.Add("handle", handle);
            evt.Data.Add("subEntryId", subEntryId);
            evt.Data.Add("statistics", statistics);

            int result = 0;

            try
            {
                result = SafeNativeMethods.RasGetLinkStatistics(handle, subEntryId, statistics);
                evt.ResultCode = result;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #12
0
        /// <summary>
        /// Returns an error message string for a specified RAS error value.
        /// </summary>
        /// <param name="errorCode">The error value of interest.</param>
        /// <param name="result">Required. The buffer that will receive the error string.</param>
        /// <param name="bufferSize">Specifies the size, in characters, of the buffer pointed to by <paramref name="result"/>.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int GetErrorString(int errorCode, string result, int bufferSize)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasGetErrorString");
            evt.Data.Add("errorCode", errorCode);
            evt.Data.Add("result", result);
            evt.Data.Add("bufferSize", bufferSize);

            int ret = 0;

            try
            {
                ret = SafeNativeMethods.RasGetErrorString(errorCode, result, bufferSize);
                evt.ResultCode = ret;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return ret;
        }
예제 #13
0
        /// <summary>
        /// Retrieves Extensible Authentication Protocol (EAP) identity information for the current user.
        /// </summary>
        /// <param name="phoneBookPath">The full path and filename of a phone book file. If this parameter is a null reference, the default phone book is used.</param>
        /// <param name="entryName">The name of an existing entry within the phone book.</param>
        /// <param name="flags">Specifies any flags that qualify the authentication process.</param>
        /// <param name="hwnd">Handle to the parent window for the UI dialog.</param>
        /// <param name="identity">Pointer to a buffer that upon return contains the EAP user identity information.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int GetEapUserIdentity(string phoneBookPath, string entryName, NativeMethods.RASEAPF flags, IntPtr hwnd, ref IntPtr identity)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasGetEapUserIdentity");
            evt.Data.Add("phoneBookPath", phoneBookPath);
            evt.Data.Add("entryName", entryName);
            evt.Data.Add("flags", flags);
            evt.Data.Add("hwnd", hwnd);
            evt.Data.Add("identity-IN", identity);

            int result = 0;

            try
            {
                result = SafeNativeMethods.RasGetEapUserIdentity(phoneBookPath, entryName, flags, hwnd, ref identity);
                evt.ResultCode = result;
                evt.Data.Add("identity-OUT", identity);
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #14
0
        /// <summary>
        /// Retrieves user-specific Extensible Authentication Protocol (EAP) information for the specified phone book entry.
        /// </summary>
        /// <param name="value">An <see cref="RasGetEapUserDataParams"/> containing call data.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        /// <exception cref="System.ArgumentNullException"><paramref name="value"/> is a null reference (<b>Nothing</b> in Visual Basic).</exception>
        public int GetEapUserData(RasGetEapUserDataParams value)
        {
            if (value == null)
            {
                ThrowHelper.ThrowArgumentNullException("value");
            }

            IntPtr bufferSize = value.BufferSize;

            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasGetEapUserData");
            evt.Data.Add("userToken", value.UserToken);
            evt.Data.Add("phoneBookPath", value.PhoneBookPath);
            evt.Data.Add("entryName", value.EntryName);
            evt.Data.Add("address", value.Address);
            evt.Data.Add("bufferSize-IN", bufferSize);

            int result = 0;

            try
            {
                result = SafeNativeMethods.RasGetEapUserData(value.UserToken, value.PhoneBookPath, value.EntryName, value.Address, ref bufferSize);
                evt.ResultCode = result;
                evt.Data.Add("bufferSize-OUT", bufferSize);

                value.BufferSize = bufferSize;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #15
0
        /// <summary>
        /// Retrieves country/region specific dialing information from the Windows telephony list of countries/regions.
        /// </summary>
        /// <param name="countries">Pointer to a <see cref="NativeMethods.RASCTRYINFO"/> structure that upon output receives the country/region dialing information.</param>
        /// <param name="bufferSize">Pointer to a variable that, on input, specifies the size, in bytes, of the buffer pointed to by <paramref name="countries"/>.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int GetCountryInfo(IntPtr countries, ref IntPtr bufferSize)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasGetCountryInfo");
            evt.Data.Add("countries", countries);
            evt.Data.Add("bufferSize-IN", bufferSize);

            int result = 0;

            try
            {
                result = SafeNativeMethods.RasGetCountryInfo(countries, ref bufferSize);
                evt.ResultCode = result;
                evt.Data.Add("bufferSize-OUT", bufferSize);
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #16
0
        /// <summary>
        /// Retrieves information about the entries associated with a network address in the AutoDial mapping database.
        /// </summary>
        /// <param name="value">An <see cref="RasGetAutodialAddressParams"/> containing call data.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int GetAutodialAddress(RasGetAutodialAddressParams value)
        {
            if (value == null)
            {
                ThrowHelper.ThrowArgumentNullException("value");
            }

            IntPtr bufferSize = value.BufferSize;
            IntPtr count = value.Count;

            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasGetAutodialAddress");
            evt.Data.Add("autodialAddress", value.AutodialAddress);
            evt.Data.Add("reserved", value.Reserved);
            evt.Data.Add("address", value.Address);
            evt.Data.Add("bufferSize-IN", bufferSize);
            evt.Data.Add("count-IN", count);

            int result = 0;

            try
            {
                result = UnsafeNativeMethods.RasGetAutodialAddress(value.AutodialAddress, value.Reserved, value.Address, ref bufferSize, ref count);
                evt.ResultCode = result;
                evt.Data.Add("bufferSize-OUT", bufferSize);
                evt.Data.Add("count-OUT", count);

                value.BufferSize = bufferSize;
                value.Count = count;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #17
0
        /// <summary>
        /// Indicates whether the AutoDial feature is enabled for a specific TAPI dialing location.
        /// </summary>
        /// <param name="value">An <see cref="RasGetAutodialEnableParams"/> containing call data.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int GetAutodialEnable(RasGetAutodialEnableParams value)
        {
            if (value == null)
            {
                ThrowHelper.ThrowArgumentNullException("value");
            }

            bool enabled = value.Enabled;

            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasGetAutodialEnable");
            evt.Data.Add("enabled-IN", enabled);

            int result = 0;

            try
            {
                result = UnsafeNativeMethods.RasGetAutodialEnable(value.DialingLocation, ref enabled);
                evt.ResultCode = result;
                evt.Data.Add("enabled-OUT", enabled);

                value.Enabled = enabled;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }
            
            return result;
        }
예제 #18
0
        /// <summary>
        /// Terminates a remote access connection.
        /// </summary>
        /// <param name="handle">The handle to terminate.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int HangUp(RasHandle handle)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasHangUp");
            evt.Data.Add("handle", handle);

            int result = 0;

            try
            {
                result = SafeNativeMethods.RasHangUp(handle);
                evt.ResultCode = result;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #19
0
        /// <summary>
        /// Retrieves information for an existing phone book entry.
        /// </summary>
        /// <param name="phoneBookPath">The full path and filename of a phone book file. If this parameter is a null reference (<b>Nothing</b> in Visual Basic), the default phone book is used.</param>
        /// <param name="entryName">The name of an existing entry within the phone book.</param>
        /// <param name="entry">Pointer to a buffer that, upon return, contains a <see cref="NativeMethods.RASENTRY"/> structure containing entry information.</param>
        /// <param name="bufferSize">Specifies the size of the <paramref name="entry"/> buffer.</param>
        /// <param name="deviceInfo">The parameter is not used.</param>
        /// <param name="deviceInfoSize">The parameter is not used.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int GetEntryProperties(string phoneBookPath, string entryName, IntPtr entry, ref IntPtr bufferSize, IntPtr deviceInfo, IntPtr deviceInfoSize)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasGetEntryProperties");
            evt.Data.Add("phoneBookPath", phoneBookPath);
            evt.Data.Add("entryName", entryName);
            evt.Data.Add("entry", entry);
            evt.Data.Add("bufferSize-IN", bufferSize);
            evt.Data.Add("deviceInfo", deviceInfo);
            evt.Data.Add("deviceInfoSize", deviceInfoSize);

            int result = 0;

            try
            {
                result = UnsafeNativeMethods.RasGetEntryProperties(phoneBookPath, entryName, entry, ref bufferSize, deviceInfo, deviceInfoSize);
                evt.ResultCode = result;
                evt.Data.Add("bufferSize-OUT", bufferSize);
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #20
0
        /// <summary>
        /// Creates and displays a configurable dialog box that accepts credentials from a user.
        /// </summary>
        /// <param name="uiInfo">Pointer to a <see cref="NativeMethods.CREDUI_INFO"/> structure that contains information for customizing the appearance of the dialog box.</param>
        /// <param name="targetName">The name of the target for the credentials.</param>
        /// <param name="reserved">Reserved for future use.</param>
        /// <param name="authError">Specifies why the credential dialog box is needed.</param>
        /// <param name="userName">A string that contains the username for the credentials.</param>
        /// <param name="userNameMaxChars">The maximum number of characters that can be copied to <paramref name="userName"/> including the terminating null character.</param>
        /// <param name="password">A string that contains the password for the credentials.</param>
        /// <param name="passwordMaxChars">The maximum number of characters that can be copied to <paramref name="password"/> including the terminating null character.</param>
        /// <param name="saveChecked">Specifies the initial state of the save checkbox and receives the state of the save checkbox after the user has responded to the dialog.</param>
        /// <param name="flags">Specifies special behavior for this function.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int PromptForCredentials(IntPtr uiInfo, string targetName, IntPtr reserved, int authError, StringBuilder userName, int userNameMaxChars, StringBuilder password, int passwordMaxChars, ref bool saveChecked, NativeMethods.CREDUI_FLAGS flags)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.CredUIDll, "CredUIPromptForCredentials");
            evt.Data.Add("uiInfo", uiInfo);
            evt.Data.Add("targetName", targetName);
            evt.Data.Add("reserved", reserved);
            evt.Data.Add("authError", authError);
            evt.Data.Add("userName", userName);
            evt.Data.Add("userNameMaxChars", userNameMaxChars);
            evt.Data.Add("password", "********");
            evt.Data.Add("passwordMaxChars", passwordMaxChars);
            evt.Data.Add("saveChecked-IN", saveChecked);
            evt.Data.Add("flags", flags);

            int result = 0;

            try
            {
                result = SafeNativeMethods.CredUIPromptForCredentials(uiInfo, targetName, reserved, authError, userName, userNameMaxChars, password, passwordMaxChars, ref saveChecked, flags);
                evt.ResultCode = result;
                evt.Data.Add("saveChecked-OUT", saveChecked);
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #21
0
        /// <summary>
        /// Renames an existing entry in a phone book.
        /// </summary>
        /// <param name="phoneBookPath">The full path and filename of a phone book. If this parameter is a null reference (<b>Nothing</b> in Visual Basic), the default phone book is used.</param>
        /// <param name="oldEntryName">The name of the entry to rename.</param>
        /// <param name="newEntryName">The new name of the entry.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int RenameEntry(string phoneBookPath, string oldEntryName, string newEntryName)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasRenameEntry");
            evt.Data.Add("phoneBookPath", phoneBookPath);
            evt.Data.Add("oldEntryName", oldEntryName);
            evt.Data.Add("newEntryName", newEntryName);

            int result = 0;

            try
            {
                result = UnsafeNativeMethods.RasRenameEntry(phoneBookPath, oldEntryName, newEntryName);
                evt.ResultCode = result;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #22
0
        /// <summary>
        /// Specifies an event object that the system sets to the signaled state when a RAS connection changes.
        /// </summary>
        /// <param name="handle">The handle to the connection.</param>
        /// <param name="eventHandle">The handle of an event object.</param>
        /// <param name="flags">Specifies the RAS event that causes the system to signal the event specified by the <paramref name="eventHandle"/> parameter.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int RegisterConnectionNotification(RasHandle handle, SafeHandle eventHandle, NativeMethods.RASCN flags)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasConnectionNotification");
            evt.Data.Add("handle", handle);
            evt.Data.Add("eventHandle", eventHandle);
            evt.Data.Add("flags", flags);

            int result = 0;

            try
            {
                result = SafeNativeMethods.RasConnectionNotification(handle, eventHandle, flags);
                evt.ResultCode = result;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #23
0
        /// <summary>
        /// Enables or disables the AutoDial feature for a specific TAPI dialing location.
        /// </summary>
        /// <param name="dialingLocation">The TAPI dialing location to update.</param>
        /// <param name="enabled"><b>true</b> to enable the AutoDial feature, otherwise <b>false</b> to disable it.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int SetAutodialEnable(int dialingLocation, bool enabled)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasSetAutodialEnable");
            evt.Data.Add("dialingLocation", dialingLocation);
            evt.Data.Add("enabled", enabled);

            int result = 0;

            try
            {
                result = UnsafeNativeMethods.RasSetAutodialEnable(dialingLocation, enabled);
                evt.ResultCode = result;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #24
0
        /// <summary>
        /// Indicates whether the entry name is valid for the phone book specified.
        /// </summary>
        /// <param name="phoneBookPath">The full path and filename of a phone book file. If this parameter is a null reference (<b>Nothing</b> in Visual Basic), the default phone book is used.</param>
        /// <param name="entryName">The entry name to validate.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int ValidateEntryName(string phoneBookPath, string entryName)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasValidateEntryName");
            evt.Data.Add("phoneBookPath", phoneBookPath);
            evt.Data.Add("entryName", entryName);

            int result = 0;

            try
            {
                result = SafeNativeMethods.RasValidateEntryName(phoneBookPath, entryName);
                evt.ResultCode = result;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #25
0
        /// <summary>
        /// Sets the user credentials for a phone book entry.
        /// </summary>
        /// <param name="phoneBookPath">The full path and filename of a phone book. If this parameter is a null reference (<b>Nothing</b> in Visual Basic), the default phone book is used.</param>
        /// <param name="entryName">The name of the entry whose credentials to set.</param>
        /// <param name="credentials">Pointer to an <see cref="NativeMethods.RASCREDENTIALS"/> object containing user credentials.</param>
        /// <param name="clearCredentials"><b>true</b> clears existing credentials by setting them to an empty string, otherwise <b>false</b>.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int SetCredentials(string phoneBookPath, string entryName, IntPtr credentials, bool clearCredentials)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasSetCredentials");
            evt.Data.Add("phoneBookPath", phoneBookPath);
            evt.Data.Add("entryName", entryName);
            evt.Data.Add("credentials", credentials);
            evt.Data.Add("clearCredentials", clearCredentials);

            int result = 0;

            try
            {
                result = UnsafeNativeMethods.RasSetCredentials(phoneBookPath, entryName, credentials, clearCredentials);
                evt.ResultCode = result;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #26
0
        /// <summary>
        /// Deletes a subentry from the specified phone book entry.
        /// </summary>
        /// <param name="phoneBookPath">The full path and filename of a phone book file. If this parameter is a null reference, the default phone book is used.</param>
        /// <param name="entryName">The name of the entry to be deleted.</param>
        /// <param name="subEntryId">The one-based index of the subentry to delete.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int DeleteSubEntry(string phoneBookPath, string entryName, int subEntryId)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasDeleteSubEntry");
            evt.Data.Add("phoneBookPath", phoneBookPath);
            evt.Data.Add("entryName", entryName);
            evt.Data.Add("subEntryId", subEntryId);

            int result = 0;

            try
            {
                result = UnsafeNativeMethods.RasDeleteSubEntry(phoneBookPath, entryName, subEntryId);
                evt.ResultCode = result;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #27
0
        /// <summary>
        /// Sets the subentry connection information of a specified phone book entry.
        /// </summary>
        /// <param name="phoneBookPath">The full path and filename of a phone book file. If this parameter is a null reference (<b>Nothing</b> in Visual Basic), the default phone book is used.</param>
        /// <param name="entryName">The name of an existing entry within the phone book.</param>
        /// <param name="index">The one-based index of the subentry to set.</param>
        /// <param name="subentry">Pointer to a buffer that, upon return, contains a <see cref="NativeMethods.RASSUBENTRY"/> structure containing subentry information.</param>
        /// <param name="bufferSize">Specifies the size of the <paramref name="subentry"/> buffer.</param>
        /// <param name="deviceConfig">The parameter is not used.</param>
        /// <param name="deviceConfigSize">The parameter is not used.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int SetSubEntryProperties(string phoneBookPath, string entryName, int index, IntPtr subentry, int bufferSize, IntPtr deviceConfig, int deviceConfigSize)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasSetSubEntryProperties");
            evt.Data.Add("phoneBookPath", phoneBookPath);
            evt.Data.Add("entryName", entryName);
            evt.Data.Add("index", index);
            evt.Data.Add("subentry", subentry);
            evt.Data.Add("bufferSize", bufferSize);
            evt.Data.Add("deviceConfig", deviceConfig);
            evt.Data.Add("deviceConfigSize", deviceConfigSize);

            int result = 0;

            try
            {
                result = UnsafeNativeMethods.RasSetSubEntryProperties(phoneBookPath, entryName, index, subentry, bufferSize, deviceConfig, deviceConfigSize);
                evt.ResultCode = result;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #28
0
        /// <summary>
        /// Lists all entry names in a remote access phone-book.
        /// </summary>
        /// <param name="reserved">Reserved; this parameter must be a null reference.</param>
        /// <param name="phoneBookPath">The full path and filename of a phone book file. If this parameter is a null reference, the default phone book is used.</param>
        /// <param name="entryName">Pointer to a buffer that, on output, receives an array of <see cref="NativeMethods.RASENTRYNAME"/> structures.</param>
        /// <param name="bufferSize">Upon return, contains the size in bytes of the buffer specified by <paramref name="entryName"/>. Upon return contains the number of bytes required to successfully complete the call.</param>
        /// <param name="count">Upon return, contains the number of phone book entries written to the buffer specified by <paramref name="entryName"/>.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int EnumEntries(IntPtr reserved, string phoneBookPath, IntPtr entryName, ref IntPtr bufferSize, ref IntPtr count)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasEnumEntries");
            evt.Data.Add("reserved", reserved);
            evt.Data.Add("phoneBookPath", phoneBookPath);
            evt.Data.Add("entryName", entryName);
            evt.Data.Add("bufferSize-IN", bufferSize);
            evt.Data.Add("count-IN", count);

            int result = 0;

            try
            {
                result = UnsafeNativeMethods.RasEnumEntries(reserved, phoneBookPath, entryName, ref bufferSize, ref count);
                evt.ResultCode = result;
                evt.Data.Add("bufferSize-OUT", bufferSize);
                evt.Data.Add("count-OUT", count);
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #29
0
        /// <summary>
        /// Updates the tunnel endpoints of an Internet Key Exchange (IKEv2) connection.
        /// </summary>
        /// <param name="handle">The handle to the connection.</param>
        /// <param name="updateData">Pointer to a <see cref="NativeMethods.RASUPDATECONN"/> structure that contains the new tunnel endpoints for the connection.</param>
        /// <returns>If the function succeeds, the return value is zero.</returns>
        public int UpdateConnection(RasHandle handle, IntPtr updateData)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasUpdateConnection");
            evt.Data.Add("handle", handle);
            evt.Data.Add("updateData", updateData);

            int result = 0;

            try
            {
                result = UnsafeNativeMethods.RasUpdateConnection(handle, updateData);
                evt.ResultCode = result;
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }

            return result;
        }
예제 #30
0
        /// <summary>
        /// Frees the memory buffer returned by the <see cref="SafeNativeMethods.RasGetEapUserIdentity"/> method.
        /// </summary>
        /// <param name="identity">Pointer to the <see cref="NativeMethods.RASEAPUSERIDENTITY"/> structure.</param>
        public void FreeEapUserIdentity(IntPtr identity)
        {
            PInvokeCallTraceEvent evt = new PInvokeCallTraceEvent(NativeMethods.RasApi32Dll, "RasFreeEapUserIdentity");
            evt.Data.Add("identity", identity);

            try
            {
                SafeNativeMethods.RasFreeEapUserIdentity(identity);
            }
            finally
            {
                DiagnosticTrace.Default.TraceEvent(TraceEventType.Verbose, evt);
            }
        }