Exemplo n.º 1
0
    public static ICorDebug DebugActiveSilverlightProcess(int processId, DebuggerCallBacks callBacks = null)
    {
        // Get all funcs exported by the coreclr's dbg shim.
        Silverlight.InitSLApi();

        // Enumerate all coreclr instances in the process
        string[]          fullPaths;
        EventWaitHandle[] continueStartupEvents;
        Silverlight.EnumerateCLRs((uint)processId, out fullPaths, out continueStartupEvents);
        int nSilverlight = fullPaths.Length;

        if (fullPaths == null || nSilverlight == 0)
        {
            return(null);
        }

        // for each coreclr instance found.....
        if (nSilverlight > 0)
        {
            // Attach to the first one
            // TODO are we leaking handles for the rest, do we care about which one?
            string slVersion = Silverlight.CreateVersionStringFromModule((uint)processId, fullPaths[0]);
            var    debugAPI  = Silverlight.CreateDebuggingInterfaceFromVersionEx(4, slVersion);
            debugAPI.Initialize();

            if (callBacks == null)
            {
                callBacks = new DebuggerCallBacks();
            }
            debugAPI.SetManagedHandler(callBacks);
            return(debugAPI);
        }

        return(null);
    }
        protected string EncryptPassword(string password)
        {
#if SILVERLIGHT
            return(Silverlight.GetSHA1Hash(password));
#else
            return(Convert.ToBase64String(SHA1.Create().ComputeHash(Encoding.ASCII.GetBytes(password))));
#endif
        }
Exemplo n.º 3
0
    private static ICorDebug CreateDebuggingInterfaceFromVersionEx(int iDebuggerVersion, string strDebuggeeVersion)
    {
        if (null == s_CreateDebuggingInterfaceFromVersionEx)
        {
            return(null);
        }
        ICorDebug ICorDbgIntf;
        int       ret;
        int       numTries = 0;

        do
        {
            Trace.WriteLine("In CreateDebuggingInterfaceFromVersionEx, numTries=" + numTries.ToString());
            ret = (int)s_CreateDebuggingInterfaceFromVersionEx(
                iDebuggerVersion,
                strDebuggeeVersion,
                out ICorDbgIntf
                );
            // CreateDebuggingInterfaceFromVersionEx uses the OS API CreateToolhelp32Snapshot which can return
            // ERROR_BAD_LENGTH or ERROR_PARTIAL_COPY. If we get either of those, we try wait 1/10th of a second
            // try again (that is the recommendation of the OS API owners)
            if (((int)HResult.E_BAD_LENGTH == ret) || ((int)HResult.E_PARTIAL_COPY == ret))
            {
                System.Threading.Thread.Sleep(100);
            }
            else
            {
                // else we've hit one of the HRESULTS that we shouldn't try again for, if the result isn't OK then the error will ge reported below
                break;
            }
            numTries++;
        }while (numTries < 10);

        // if we're not OK then throw an exception with the returned hResult
        if ((int)HResult.S_OK != ret)
        {
            throw new COMException("CreateDebuggingInterfaceFromVersionEx for debuggee version " + strDebuggeeVersion +
                                   " requesting interface version " + iDebuggerVersion +
                                   " failed returning " + Silverlight.HResultToString(ret), ret);
        }
        return(ICorDbgIntf);
    }
Exemplo n.º 4
0
    private static void EnumerateCLRs(UInt32 debuggeePid, out string[] fullPaths, out EventWaitHandle[] continueStartupEvents)
    {
        UInt32 elementCount;
        IntPtr pEventArray;
        IntPtr pStringArray;

        int ret;
        int numTries = 0;

        do
        {
            Trace.WriteLine(numTries > 0, "In EnumerateCLRs, numTries=" + numTries.ToString());
            ret = (int)s_EnumerateCLRs(
                debuggeePid,
                out pEventArray,
                out pStringArray,
                out elementCount
                );
            // EnumerateCLRs uses the OS API CreateToolhelp32Snapshot which can return
            // ERROR_BAD_LENGTH or ERROR_PARTIAL_COPY. If we get either of those, we try wait 1/10th of a second
            // try again (that is the recommendation of the OS API owners)
            if (((int)HResult.E_BAD_LENGTH == ret) || ((int)HResult.E_PARTIAL_COPY == ret))
            {
                System.Threading.Thread.Sleep(100);
            }
            else
            {
                break;
            }
            numTries++;
        } while (((int)HResult.S_OK != ret) && (numTries < 10));

        if ((int)HResult.S_OK != ret)
        {
            fullPaths             = new string[0];
            continueStartupEvents = new EventWaitHandle[0];
            return;
        }

        MarshalCLREnumeration(
            pEventArray,
            pStringArray,
            elementCount,
            out fullPaths,
            out continueStartupEvents);

        ret = (int)s_CloseCLREnumeration(
            pEventArray,
            pStringArray,
            elementCount);

        if ((int)HResult.S_OK != ret)
        {
            throw new COMException("CloseCLREnumeration failed for process PID=" + debuggeePid + ", HResult= " + Silverlight.HResultToString(ret), ret);
        }
    }
Exemplo n.º 5
0
    private static string CreateVersionStringFromModule(UInt32 debuggeePid, string clrPath)
    {
        UInt32 reqBufferSize = 0;

        // first call is getting the reqBufferSize
        s_CreateVersionStringFromModule(
            0,
            clrPath,
            null,
            0,
            out reqBufferSize);

        StringBuilder sb = new StringBuilder((int)reqBufferSize);

        // this call can fail because the underlying call uses CreateToolhelp32Snapshot
        //
        int ret;
        int numTries = 0;

        do
        {
            Trace.WriteLine("In CreateVersionStringFromModule, numTries=" + numTries.ToString());
            ret = (int)s_CreateVersionStringFromModule(
                debuggeePid,
                clrPath,
                sb,
                (UInt32)sb.Capacity,
                out reqBufferSize);
            // s_CreateVersionStringFromModule uses the OS API CreateToolhelp32Snapshot which can return
            // ERROR_BAD_LENGTH or ERROR_PARTIAL_COPY. If we get either of those, we try wait 1/10th of a second
            // try again (that is the recommendation of the OS API owners)
            if (((int)HResult.E_BAD_LENGTH == ret) || ((int)HResult.E_PARTIAL_COPY == ret))
            {
                System.Threading.Thread.Sleep(100);
            }
            else
            {
                break;
            }
            numTries++;
        } while (numTries < 10);

        if ((int)HResult.S_OK != ret)
        {
            throw new COMException("CreateVersionStringFromModule failed returning the following HResult: " + Silverlight.HResultToString(ret), ret);
        }

        return(sb.ToString());
    }
Exemplo n.º 6
0
        private void QueryPanelQueryConditionChanged(object sender, Silverlight.Events.QueryConditionChangedEventArgs e)
        {
            _beginDate = e.BeginTime;
            _endDate = e.EndTime;
            _accountType = e.AccountType;
            _consumer = e.Consumer;
            _keyword = e.Keyword;
            _accountCategory = e.AccountCategory;
            _showAccessorial = e.ShowAccessorial;

            QueryRecords();
        }