Ejemplo n.º 1
0
        private DebuggerAction HandleLoadDllDebugEvent(DEBUG_EVENT debugEvent)
        {
            var info    = debugEvent.InterpretDebugInfoAs <LOAD_DLL_DEBUG_INFO>();
            var process = GetProcessById((int)debugEvent.dwProcessId);
            var thread  = process.GetThreadById((int)debugEvent.dwThreadId);

            // LOAD_DLL_DEBUG_INFO.lpImageName is a char** or a wchar_t**, which can be null.
            string name = null;

            try
            {
                if (info.lpImageName != IntPtr.Zero)
                {
                    var buffer = new byte[8];
                    process.ReadMemory(info.lpImageName, buffer, 0, IntPtr.Size);
                    var ptr = new IntPtr(BitConverter.ToInt64(buffer, 0));

                    if (ptr != IntPtr.Zero)
                    {
                        name = process.ReadZeroTerminatedString(ptr, info.fUnicode == 0);
                    }
                }
            }
            catch (Win32Exception)
            {
                // Reading failed, possibly due to an invalid pointer address. Set to no name instead.
                name = null;
            }

            var library = new DebuggeeLibrary(process, name, info.lpBaseOfDll);

            process.AddLibrary(library);

            var eventArgs = new DebuggeeLibraryEventArgs(thread, library);

            OnLibraryLoaded(eventArgs);

            return(eventArgs.NextAction);
        }
Ejemplo n.º 2
0
 internal void RemoveLibrary(DebuggeeLibrary library)
 {
     _libraries.Remove(library.BaseOfLibrary);
 }
Ejemplo n.º 3
0
 internal void AddLibrary(DebuggeeLibrary library)
 {
     _libraries.Add(library.BaseOfLibrary, library);
 }