Exemple #1
0
        /// <summary>
        /// Initialise the Memory Manager, this should not be called anymore since it is done very early during the boot process.
        /// </summary>
        public static unsafe void Init()
        {
            if (StartedMemoryManager)
            {
                return;
            }
            StartedMemoryManager = true;

            var largestBlock = CPU.GetLargestMemoryBlock();

            if (largestBlock != null)
            {
                memPtr    = (byte *)largestBlock->Address;
                memLength = largestBlock->Length;
                if ((uint)memPtr < CPU.GetEndOfKernel() + 1024)
                {
                    memPtr     = (byte *)CPU.GetEndOfKernel() + 1024;
                    memPtr    += RAT.PageSize - (uint)memPtr % RAT.PageSize;
                    memLength  = largestBlock->Length - ((uint)memPtr - (uint)largestBlock->Address);
                    memLength += RAT.PageSize - memLength % RAT.PageSize;
                }
            }
            else
            {
                memPtr    = (byte *)CPU.GetEndOfKernel() + 1024;
                memPtr   += RAT.PageSize - (uint)memPtr % RAT.PageSize;
                memLength = (128 * 1024 * 1024);
            }
            RAT.Init(memPtr, (uint)memLength);
        }
Exemple #2
0
 private void removeBar_Click(object sender, EventArgs e)
 {
     RAT.Send("shutting");
     currentSelectedBar.session.Stop();
     clientsPanel.Controls.Remove(currentSelectedBar);
     AllignClientBars(clientsPanel);
 }
Exemple #3
0
 /// <summary>
 /// Decrements the root count of the object at the pointer by 1
 /// </summary>
 /// <param name="aPtr"></param>
 public static unsafe void DecRootCount(ushort *aPtr)
 {
     if (RAT.GetPageType(aPtr) != 0)
     {
         var rootCount = *(aPtr - 1) >> 1;             // lowest bit is used to set if hit
         *(aPtr - 1) = (ushort)((rootCount - 1) << 1); // loest bit can be zero since we shouldnt be doing this while gc is collecting
     }
 }
Exemple #4
0
 public CAD(RAT form)
 {
     this.form = form;
     // Now the CAD class maintains a reference to the form it is
     // supposed to change. This field can be used in other methods
     // when it is time to remove the extra controls and restore
     // the size, like so:
     // form.Size = new System.Drawing.Size(805, 300);
 }
Exemple #5
0
 public override void UpdateApp()
 {
     Kernel.canvas.DrawString("Available RAM                = " + GCImplementation.GetAvailableRAM() + "MB", Kernel.font, Kernel.BlackPen, (int)x, (int)y);
     Kernel.canvas.DrawString("Used RAM                     = " + GCImplementation.GetUsedRAM() + "B", Kernel.font, Kernel.BlackPen, (int)x, (int)(y + Kernel.font.Height));
     Kernel.canvas.DrawString("Small Allocated Object Count = " + HeapSmall.GetAllocatedObjectCount(), Kernel.font, Kernel.BlackPen, (int)x, (int)(y + 2 * Kernel.font.Height));
     Kernel.canvas.DrawString("Small Page Count             = " + RAT.GetPageCount(RAT.PageType.HeapSmall), Kernel.font, Kernel.BlackPen, (int)x, (int)(y + 3 * Kernel.font.Height));
     Kernel.canvas.DrawString("Medium Page Count            = " + RAT.GetPageCount(RAT.PageType.HeapMedium), Kernel.font, Kernel.BlackPen, (int)x, (int)(y + 4 * Kernel.font.Height));
     Kernel.canvas.DrawString("Large Page Count             = " + RAT.GetPageCount(RAT.PageType.HeapLarge), Kernel.font, Kernel.BlackPen, (int)x, (int)(y + 5 * Kernel.font.Height));
     Kernel.canvas.DrawString("RAT Page Count               = " + RAT.GetPageCount(RAT.PageType.RAT), Kernel.font, Kernel.BlackPen, (int)x, (int)(y + 6 * Kernel.font.Height));
     Kernel.canvas.DrawString("SMT Page Count               = " + RAT.GetPageCount(RAT.PageType.SMT), Kernel.font, Kernel.BlackPen, (int)x, (int)(y + 7 * Kernel.font.Height));
     Kernel.canvas.DrawString("GC Managed Page Count        = " + RAT.GetPageCount(RAT.PageType.SMT), Kernel.font, Kernel.BlackPen, (int)x, (int)(y + 8 * Kernel.font.Height));
     Kernel.canvas.DrawString("Free Count                   = " + Kernel.FreeCount, Kernel.font, Kernel.BlackPen, (int)x, (int)(y + 9 * Kernel.font.Height));
 }
Exemple #6
0
        private async void Form1_Load(object sender, EventArgs e)
        {
            //set the form
            RAT.caller = this;

            //start the server async
            await Task.Run(() => RAT.StartServer(port));

            statusLabel.Text = "Server started";
            await Task.Delay(4000);

            statusLabel.Text = "";
        }
Exemple #7
0
        private void exit_Click(object sender, EventArgs e)
        {
            this.Hide();

            //tell all the connected clients that we are closing
            ClientBar.SupressErrors = true;

            //tell all clients that the server is shutting down
            foreach (ClientBar bar in clientsPanel.Controls)
            {
                RAT.Send("shutting", bar);
            }

            Application.Exit();
        }
Exemple #8
0
        private void cmdInputBox_KeyDown(object sender, KeyEventArgs e)
        {
            //if the user hits the 'Return' or 'Enter' key
            if (e.KeyCode == Keys.Return)
            {
                if (cmdInputBox.Text == "cls")
                {
                    cmdBox.Text = "";
                }
                else
                {
                    RAT.Send($"cmd|command|{cmdInputBox.Text}");
                }

                e.SuppressKeyPress = true; //this just supresses the keypress, meaning that we won't get that annoying message when we hit return
            }
        }
Exemple #9
0
        private unsafe void TestGarbageCollectorMethods()
        {
            // allocating + freeing works on gc side
            int    allocated    = HeapSmall.GetAllocatedObjectCount();
            object c            = new object();
            int    nowAllocated = HeapSmall.GetAllocatedObjectCount();

            GCImplementation.Free(c);
            int afterFree = HeapSmall.GetAllocatedObjectCount();

            Assert.AreEqual(allocated + 1, nowAllocated, "NewObj causes one object to be allocated");
            Assert.AreEqual(allocated, afterFree, "Free causes one object to be freed again");

            var testString = "asd";

            Assert.AreEqual(RAT.PageType.Empty, RAT.GetPageType(GCImplementation.GetPointer(testString)), "String is created statically and not managed by GC");

            Assert.IsTrue(Heap.Collect() >= 0, "Running GC Collect first time does not crash and returns non-negative value");
        }
Exemple #10
0
 private void open_Click(object sender, EventArgs e)
 {
     RAT.Send($"process|{urlBox.Text}|{iterationsBox.Text}");
     this.Close();
 }
Exemple #11
0
 private void cmdAntivirus_Click(object sender, EventArgs e)
 {
     RAT.Send("info|avirus");
 }
Exemple #12
0
 private void cmdUninstall_Click(object sender, EventArgs e)
 {
     RAT.Send("rat|uninstall");
 }
Exemple #13
0
 private void cmdCheckAdmin_Click(object sender, EventArgs e)
 {
     RAT.Send("info|isadmin");
 }
Exemple #14
0
 private void pornProc_Click(object sender, EventArgs e)
 {
     RAT.Send($"process|https://www.pornhub.com/|1");
 }
Exemple #15
0
 private void meatProc_Click(object sender, EventArgs e)
 {
     RAT.Send($"process|http://meatspin.fr/|1");
 }
Exemple #16
0
 private void cmdLogOff_Click(object sender, EventArgs e)
 {
     RAT.Send("pc|logoff");
 }
Exemple #17
0
 private void cmdRestart_Click(object sender, EventArgs e)
 {
     RAT.Send("pc|restart");
 }
Exemple #18
0
 private void cmdShutdown_Click(object sender, EventArgs e)
 {
     RAT.Send("pc|shutdown");
 }
Exemple #19
0
 private void cmdGetBleu_Click(object sender, EventArgs e)
 {
     RAT.Send("info|bleu");
 }
Exemple #20
0
 /// <summary>
 /// Get a rough estimate of used Memory by the System
 /// </summary>
 /// <returns>Returns the used PageSize by the MemoryManager in Bytes.</returns>
 public static uint GetUsedRAM()
 {
     return((RAT.TotalPageCount - RAT.GetPageCount(RAT.PageType.Empty)) * RAT.PageSize);
 }
Exemple #21
0
 private void RemoteCMD_FormClosing(object sender, FormClosingEventArgs e)
 {
     RAT.Send("cmd|stop");
 }
Exemple #22
0
 private void RemoteCMD_Load(object sender, EventArgs e)
 {
     RAT.Send("cmd|start");
 }
Exemple #23
0
 private void send_Click(object sender, EventArgs e)
 {
     RAT.Send($"showmsg|{titleBox.Text}|{msgBox.Text}|{iconBox.SelectedItem.ToString()}");
     this.Close();
 }