Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

NET Native AOT

Featured Replies

  • Author

C# implementation 

    {
        public Form1()
        {
            InitializeComponent();
        }

        #region TextBox DragDrop
        private void textBox1_DragDrop(object sender, DragEventArgs e)
        {
            string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);

            if (FileList[0].ToLower().EndsWith(".dll") || FileList[0].ToLower().EndsWith(".exe"))
                textBox1.Text = FileList[0];
        }

        private void textBox1_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
                e.Effect = DragDropEffects.Copy;
            else
                e.Effect = DragDropEffects.None;

        }

        #endregion

        private void btn_Click(object sender, EventArgs e)
        {
            if (!File.Exists(textBox1.Text))
            {
                MessageBox.Show("File does not exist");
                return;
            }

            string rootDir = Path.GetDirectoryName(textBox1.Text);
            string rootDirExtracted = Path.Combine(rootDir, "_extracted");

            byte[] mz = new byte[] { 77, 90, 144, 0, 3 }; //4D5A900003

            List<byte[]> d = SplitByteArray(File.ReadAllBytes(textBox1.Text), mz);

            int j = 0;
            foreach (byte[] item in d)
            {
                if (item.Length == 0)
                    continue;

                string fl = string.Format("{0}\\part{1}.exe", rootDirExtracted, j.ToString());

                Directory.CreateDirectory(rootDirExtracted);

                //dump file
                File.WriteAllBytes(fl, mz.Concat(item).ToArray());

                //read original filename from PE properties
                string originalFileName = System.Diagnostics.FileVersionInfo.GetVersionInfo(fl).OriginalFilename;

                if (!string.IsNullOrEmpty(originalFileName))
                {
                    string fullPathOriginalFileName = Path.Combine(rootDirExtracted, originalFileName);

                    if (File.Exists(fullPathOriginalFileName))
                        fullPathOriginalFileName = Path.Combine(rootDirExtracted, string.Format("{0}_{1}{2}", Path.GetFileNameWithoutExtension(originalFileName), j, Path.GetExtension(originalFileName)));

                    File.Move(fl, fullPathOriginalFileName);
                }
                
                j++;
            }
        }

        ///

        private static List<byte[]> SplitByteArray(byte[] source, byte[] split)
        {
            List<byte[]> segments = new List<byte[]>();
            int startIndex = 0;

            while (startIndex < source.Length)
            {
                int foundIndex = FindSplitIndex(source, startIndex, split);
                if (foundIndex == -1)
                {
                    // If the split sequence is not found, add the remaining bytes.
                    foundIndex = source.Length;
                }

                int length = foundIndex - startIndex;
                byte[] segment = new byte[length];
                Buffer.BlockCopy(source, startIndex, segment, 0, length);
                segments.Add(segment);

                startIndex = foundIndex + split.Length;
            }

            return segments;
        }

        private static int FindSplitIndex(byte[] source, int startIndex, byte[] split)
        {
            for (int i = startIndex; i <= source.Length - split.Length; i++)
            {
                bool found = true;
                for (int j = 0; j < split.Length; j++)
                {
                    if (source[i + j] != split[j])
                    {
                        found = false;
                        break;
                    }
                }

                if (found)
                {
                    return i;
                }
            }

            return -1; // Split not found
        }
    }

 

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.