Exemple #1
0
        public Helper(KProcess process, InjectedLibrary dll)
        {
            m_process = process;
            m_dll = dll;

            m_replaceImportAddress = m_process.GetProcAddress(dll.Module, "ReplaceImportAddress");
        }
Exemple #2
0
 public InjectedLibrary(KProcess process, IntPtr module)
 {
     m_process = process;
     m_module = module;
 }
Exemple #3
0
        private KernelResult CreateSession(
            bool isLight,
            ulong namePtr,
            out int serverSessionHandle,
            out int clientSessionHandle)
        {
            serverSessionHandle = 0;
            clientSessionHandle = 0;

            KProcess currentProcess = _system.Scheduler.GetCurrentProcess();

            KResourceLimit resourceLimit = currentProcess.ResourceLimit;

            KernelResult result = KernelResult.Success;

            if (resourceLimit != null && !resourceLimit.Reserve(LimitableResource.Session, 1))
            {
                return(KernelResult.ResLimitExceeded);
            }

            if (isLight)
            {
                KLightSession session = new KLightSession(_system);

                result = currentProcess.HandleTable.GenerateHandle(session.ServerSession, out serverSessionHandle);

                if (result == KernelResult.Success)
                {
                    result = currentProcess.HandleTable.GenerateHandle(session.ClientSession, out clientSessionHandle);

                    if (result != KernelResult.Success)
                    {
                        currentProcess.HandleTable.CloseHandle(serverSessionHandle);

                        serverSessionHandle = 0;
                    }
                }

                session.ServerSession.DecrementReferenceCount();
                session.ClientSession.DecrementReferenceCount();
            }
            else
            {
                KSession session = new KSession(_system);

                result = currentProcess.HandleTable.GenerateHandle(session.ServerSession, out serverSessionHandle);

                if (result == KernelResult.Success)
                {
                    result = currentProcess.HandleTable.GenerateHandle(session.ClientSession, out clientSessionHandle);

                    if (result != KernelResult.Success)
                    {
                        currentProcess.HandleTable.CloseHandle(serverSessionHandle);

                        serverSessionHandle = 0;
                    }
                }

                session.ServerSession.DecrementReferenceCount();
                session.ClientSession.DecrementReferenceCount();
            }

            return(result);
        }
        public int Add(KProcess process, object data)
        {
            IdDictionary dict = _dictByProcess.GetOrAdd(process, (key) => new IdDictionary());

            return(dict.Add(data));
        }