code:
package life.xchange.util

import life.xchange.AppProperties
import life.xchange.carefully
import life.xchange.rootDir
import java.nio.file.Files

private fun printStackTrace(e: Throwable, caption: String? = "", addLine: (String) -> Unit) {
  addLine("$caption: $e")
  e.stackTrace.filter { it.className.startsWith("life.xchange") }.forEach {
    addLine("  at $it")
  }
}

fun Throwable.helpfulStackTrace(addLine: (String) -> Unit) {
  printStackTrace(this@helpfulStackTrace, "${this@helpfulStackTrace::class.simpleName}: $message", addLine)

  val dejaVu = mutableSetOf(this@helpfulStackTrace)
  var cause = cause
  while (cause != null && cause !in dejaVu) {
    dejaVu.add(cause)
    printStackTrace(cause, "Caused by: ", addLine)
    cause = cause.cause
  }

  val osName = System.getProperty("os.name")
  val osVersion = System.getProperty("os.version")

  addLine("")
  addLine("The Mod Loader mod channel of the official Discord may be able to help with this.")
  addLine("")
  addLine("Loader Version: ${AppProperties.appVersion}")
  addLine("Operating System: $osName")
  addLine("OS Version: $osVersion")
  carefully {
    val fileStore = Files.getFileStore(rootDir)
    addLine("File System Format: ${fileStore.type()}")
  }
}

fun Throwable.helpfulStackTrace(): String = buildString {
  helpfulStackTrace(::appendLine)
}


code:
package life.xchange.util

import life.xchange.carefully
import java.io.BufferedInputStream
import java.io.BufferedOutputStream
import java.io.File
import java.io.FileOutputStream
import java.io.InputStream
import java.nio.file.*
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
import kotlin.io.path.*

fun Path.extractZipTo(dir: Path, onCopy: (Path) -> Unit = {}) {
  if (exists()) {
    ZipFile(toFile()).extractTo(dir, onCopy)
  }
}

fun ZipFile.extractTo(dir: Path, onCopy: (Path) -> Unit = {}) {
  dir.createDirectories()
  use { zipFile ->
    zipFile.entries().asSequence().filterNot(ZipEntry::isDirectory).forEach { zipEntry ->
      val path = dir.resolve(zipEntry.name)

      zipFile.copyEntryToPath(zipEntry, path)
      onCopy(path.relativeTo(dir))
    }
  }
}

fun ZipFile.copyEntryToPath(entry: ZipEntry, path: Path, replaceExisting: Boolean = true): Long {
  val options: Array<CopyOption> = when {
    replaceExisting -> arrayOf(StandardCopyOption.REPLACE_EXISTING)
    else -> emptyArray()
  }
  return getInputStream(entry).use { Files.copy(it, path, *options) }
}

fun File.download(inputStream: InputStream, onDownloadedBytes: (Long) -> Unit) {
  BufferedInputStream(inputStream).use { input ->
    BufferedOutputStream(FileOutputStream(this)).use { output ->
      val data = ByteArray(1024)
      var downloaded = 0L
      var x: Int

      while (input.read(data, 0, 1024).also { x = it } >= 0) {
        downloaded += x

        onDownloadedBytes(downloaded)

        output.write(data, 0, x)
      }
    }
  }
}

fun Path.setHidden() {
  carefully {
    Files.setAttribute(this, "dos:hidden", true, LinkOption.NOFOLLOW_LINKS)
  }
}

fun Path.walk(): Sequence<Path> = sequence {
  when {
    !exists() -> {}
    isDirectory() -> useDirectoryEntries { seq ->
      seq.sortedBy { it.name.lowercase() }.forEach { path -> yieldAll(path.walk()) }
    }
    else -> yield(this@walk)
  }
}

data class FileInfo(val path: String, val fileSize: Long)
fun Path.info() = FileInfo(normalize().toString(), if (exists()) fileSize() else 0)

private var supportsSoftLinks: Boolean? = null

// Try once to make a soft link and save whether the filesystem allowed it or not
fun Path.softOrHardLink(target: Path): Path = when (supportsSoftLinks) {
  true -> createSymbolicLinkPointingTo(target)
  false -> try {
    createLinkPointingTo(target)
  } catch (e: Exception) {
    when (e) {
      is FileSystemException, is UnsupportedOperationException -> throw LinksUnsupportedException(e)
      else -> throw e
    }
  }

  null -> try {
    createSymbolicLinkPointingTo(target).also { supportsSoftLinks = true }
  } catch (e: Exception) {
    when (e) {
      is FileSystemException, is SecurityException, is UnsupportedOperationException -> {
        supportsSoftLinks = false
        softOrHardLink(target)
      }
      else -> throw e
    }
  }
}

class LinksUnsupportedException(cause: Throwable?) : Exception("File links are not supported on this filesystem", cause)

repo_name: xchange/life

license: unknown


code:
package life.xchange.util

import kotlinx.serialization.json.Json
import java.io.InputStream
import java.io.InputStreamReader
import java.net.URL
import javax.net.ssl.HttpsURLConnection

object HTTPS {
  val json = Json { ignoreUnknownKeys = true }

  fun openConnection(url: String, requestMethod: String = "GET", connectTimeout: Int = 5_000, readTimeout: Int = 5_000): HttpsURLConnection =
    (URL(url).openConnection() as HttpsURLConnection).also {
      it.requestMethod = requestMethod

      it.connectTimeout = connectTimeout
      it.readTimeout = readTimeout
    }

  inline fun <T> useConnectionInputStream(url: String, block: (InputStream) -> T): T = with(openConnection(url)) {
    try {
      inputStream.use(block)
    } finally {
      disconnect()
    }
  }

  inline fun <reified T> getJsonResponse(url: String): T {
    val jsonText = useConnectionInputStream(url) {
      InputStreamReader(it).use(InputStreamReader::readText)
    }

    return json.decodeFromString<T>(jsonText)
  }
}


code:
package life.xchange.util

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import life.xchange.compatibility.Version

@Serializable
data class Release(
  val name: String,
  @SerialName("upcoming_release")
  val upcomingRelease: Boolean,
  val assets: Assets,
  val version: Version = Version(name.replaceFirst("v", "")),
)

@Serializable
data class Assets(
  val links: List<Asset>,
)

@Serializable
data class Asset(
  val name: String,
  @SerialName("direct_asset_url")
  val directAssetUrl: String,
  @SerialName("link_type")
  val linkType: String,
)


code:
package life.xchange.util

import java.util.*
import kotlin.math.pow

private object Sizes {
  val K = 2.0.pow(10).toLong()
  val M = 2.0.pow(20).toLong()
  val G = 2.0.pow(30).toLong()
  val T = 2.0.pow(40).toLong()
}

fun Long.divide(divisor: Long, places: Int) = this * 10.0.pow(places).toLong() / divisor / 10.0.pow(places)

val Long.sizeDisplay: String get() = when(this) {
  in Sizes.K until Sizes.M -> "${divide(Sizes.K, 1)} KB"
  in Sizes.M until Sizes.G -> "${divide(Sizes.M, 1)} MB"
  in Sizes.G until Sizes.T -> "${divide(Sizes.G, 1)} GB"
  in Sizes.T..Long.MAX_VALUE -> "${divide(Sizes.T, 1)} TB"
  else -> "$this B"
}

fun String.capitalize() = replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }

enum class ReplacingStatus { BeforeMatch, InMatch, AfterMatch }
data class ReplacementFromTo(val start: Regex, val end: Regex, val replacements: Sequence<String>, val onStatusChange: (ReplacingStatus) -> Unit = {})

class Replacer private constructor(private val string: String, private val iter: Iterator<ReplacementFromTo>, private val output: (String) -> Unit) {
  companion object {
    fun replace(string: String, replacements: List<ReplacementFromTo>, output: (String) -> Unit) {
      Replacer(string, replacements.iterator(), output).doReplace()
    }
  }

  private lateinit var rep: ReplacementFromTo
  private var status = ReplacingStatus.BeforeMatch

  private fun replaceFromBefore(line: String) {
    when {
      rep.start.containsMatchIn(line) -> {
        status = ReplacingStatus.InMatch.also(rep.onStatusChange)
        output(line.split(rep.start)[0])
        rep.replacements.forEach { output(it) }
        replaceFromIn(line)
      }

      else -> output(line)
    }
  }

  private fun replaceFromIn(line: String) {
    if (rep.end.containsMatchIn(line)) {
      val split = line.split(rep.end)[1]

      if (iter.hasNext()) {
        rep = iter.next()
        status = ReplacingStatus.BeforeMatch.also(rep.onStatusChange)
        replaceFromBefore(split)
      } else {
        status = ReplacingStatus.AfterMatch.also(rep.onStatusChange)
        output(split)
      }
    }
  }

  fun doReplace() {
    if (!iter.hasNext()) return string.lineSequence().forEach(output)

    rep = iter.next()

    string.lineSequence().forEach { line ->
      when (status) {
        ReplacingStatus.BeforeMatch -> replaceFromBefore(line)
        ReplacingStatus.InMatch -> replaceFromIn(line)
        ReplacingStatus.AfterMatch -> output(line)
      }
    }
  }
}


code:
package life.xchange.util

import life.xchange.compatibility.Version

val versionFinder: VersionFinder = GitGudReleasesAPIVersionFinder()

interface VersionFinder {
  fun getLatestVersion(): Version?
  val latestRelease: Release

  /**
   * Gets the latest release with progress logging.
   * @param logger A function that logs progress messages.
   * @return The latest release.
   */
  fun getLatestReleaseWithLogging(logger: (String) -> Unit): Release
}

class GitGudReleasesAPIVersionFinder : VersionFinder {
  companion object {
    const val RELEASES_API = "https://gitgud.io/api/v4/projects/19166/releases"
  }

  override fun getLatestVersion(): Version = latestRelease.version

  override val latestRelease: Release = HTTPS.getJsonResponse<List<Release>>(RELEASES_API).first { !it.upcomingRelease }

  override fun getLatestReleaseWithLogging(logger: (String) -> Unit): Release {
    logger("Connecting to GitGud API...")
    logger("Fetching release information...")

    val releases = HTTPS.getJsonResponse<List<Release>>(RELEASES_API)
    logger("Processing release data...")

    val latestRelease = releases.first { !it.upcomingRelease }
    logger("Found latest release: ${latestRelease.name}")

    return latestRelease
  }
}


Cute Pink Light

author: Ingo Steinke (openmindculture)

whiteBg: #FFFFFF

whiteText: #FFFFFF

background: pinkLightBg

selectedBackground: pinkMediumBg

hoverBackground: pinkDarkBg

foreground: purpleDarkText

disabledText: purpleLightText

selectionBackground: pinkDeepBg

selectionForeground: whiteText

underlineColor: purpleRedBorder

errorFocusColor: purpleRedFocusRect

Editor.background: whiteBg

Button.default.foreground: whiteText

color: whiteBg

ContrastBorderColor: purpleRedBorder

Panel.foreground: purpleDarkText

Panel.foreground.hover: purpleDarkText

Panel.hoverForeground: purpleDarkText

ScrollPane.background: whiteBg

ScrollPane.foreground: purpleDarkText

TextArea.foreground: purpleDarkText

TextField.background: whiteBg

TextField.foreground: purpleDarkText

TextField.inactiveForeground: purpleDarkText

Viewport.foreground: purpleDarkText

Checkbox.Foreground.Selected: pinkDeepBg


code:
package life.xchange.db

import life.xchange.compatibility.ModRelationship
import life.xchange.compatibility.Version
import org.jetbrains.exposed.sql.SizedCollection
import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation
import org.junit.jupiter.api.Order
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestMethodOrder
import kotlin.io.path.Path
import kotlin.test.*

@TestMethodOrder(OrderAnnotation::class)
class ModDatabaseTest {
  @Test
  @Order(1)
  fun `create mod`() {
    transaction {
      assertEquals(0, UnpackedMod.count())

      UnpackedMod.new {
        name = modName
        author = modAuthor
        version = modVersion
        enabled = false
      }
    }

    findMod { mod ->
      assertNotNull(mod)
      assertEquals(modName, mod.name)
      assertEquals(modAuthor, mod.author)
      assertEquals(modVersion, mod.version)
      assertFalse(mod.enabled)
    }
  }

  @Test
  @Order(2)
  fun `create file`() {
    findMod {
      assertNotNull(it)
      assertEquals(0, UnpackedModFile.count())

      UnpackedModFile.new {
        mod = it
        path = filePath
      }

      val files = it.files

      assertEquals(1, files.count())
      assertEquals(filePath, files.single().path)
    }
  }

  @Test
  @Order(3)
  fun `create passage`() {
    findMod {
      assertNotNull(it)
      assertEquals(0, UnpackedModPassage.count())

      UnpackedModPassage.new {
        mod = it
        name = passageName
        tags = listOf()
      }

      val passages = it.passages

      assertEquals(1, passages.count())
      assertEquals(passageName, passages.single().name)
    }
  }

  @Test
  @Order(4)
  fun `create reference`() {
    findMod {
      assertNotNull(it)
      assertEquals(0, ModReference.count())

      ModReference.new {
        mod = it
        otherModName = referencedName
        relationship = ModRelationship.COMPATIBLE
      }

      val references = it.references

      assertEquals(1, references.count())
      assertEquals(referencedName, references.single().otherModName)
    }
  }

  @Test
  @Order(5)
  fun `create profile`() {
    findMod {
      assertNotNull(it)
      assertEquals(0, ModProfile.count())

      transaction {
        ModProfile.new {
          name = profileName
          mods = SizedCollection(listOf(it))
        }
      }

      val profiles = it.profiles

      assertEquals(1, profiles.count())
      assertEquals(profileName, profiles.single().name)

      assertEquals(1, profiles.single().mods.count())
      assertEquals(it, profiles.single().mods.single())
    }
  }

  @Test
  @Order(6)
  fun `delete mod`() {
    transaction {
      assertEquals(1, UnpackedMod.count())
      assertEquals(1, UnpackedModFile.count())
      assertEquals(1, UnpackedModPassage.count())
      assertEquals(1, ModReference.count())
      assertEquals(1, ModProfile.count())
      assertEquals(1, ModProfileMods.selectAll().count())
    }

    findMod { it?.delete() }

    transaction {
      assertEquals(0, UnpackedMod.count())
      assertEquals(0, UnpackedModFile.count())
      assertEquals(0, UnpackedModPassage.count())
      assertEquals(0, ModReference.count())
      assertEquals(1, ModProfile.count())
      assertEquals(0, ModProfileMods.selectAll().count())
    }
  }

  companion object {
    private const val modName = "Test Mod"
    private const val referencedName = "Other Mod"
    private const val modAuthor = "Author"
    private const val passageName = "Mod Passage"
    private const val filePath = "Mod File"
    private const val profileName = "Profile"
    private val modVersion = Version("1.0")

    private fun findMod(block: (UnpackedMod?) -> Unit = {}): UnpackedMod? =
      transaction { UnpackedMod.find { UnpackedMods.name eq modName }.singleOrNull().also(block) }

    @JvmStatic
    @BeforeAll
    fun setupBaseGame() {
      ModDatabase.init(Path("mem:test"), 0, 0)
    }
  }
}


code:
package life.xchange.passage

import life.xchange.model.mod.PassageName
import life.xchange.ModProcessor
import life.xchange.db.ModDatabase
import life.xchange.upsertBaseGame
import org.jetbrains.exposed.sql.transactions.transaction
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test
import kotlin.io.path.Path

class ModLoaderIntegrationTest {
  @Test
  fun `add passage`() {
    val processor = ModProcessor()
    processor.initializeHtml("""
      <tw-passagedata pid="1" name="existing passage" tags="">
      This is an existing passage
      </tw-passagedata>
    """)
    processor.processTweeFile("FakeMod", """
      :: new passage
      This is a new passage
    """.trimIndent())
    val outputPassages = processor.passagesView
    Assertions.assertEquals(2, outputPassages.size)
    Assertions.assertEquals("This is an existing passage", outputPassages[PassageName("existing passage")]!!.contents.trim())
    Assertions.assertEquals("This is a new passage", outputPassages[PassageName("new passage")]!!.contents.trim())
  }

  @Test
  fun `replace passage`() {
    val processor = ModProcessor()
    processor.initializeHtml("""
      <tw-passagedata pid="1" name="existing passage" tags="">
      This is an existing passage
      </tw-passagedata>
    """)
    processor.processTweeFile("FakeMod", """
      :: existing passage
      This is a replaced passage
    """.trimIndent())
    val outputPassages = processor.passagesView
    Assertions.assertEquals(1, outputPassages.size)
    Assertions.assertEquals("This is a replaced passage", outputPassages[PassageName("existing passage")]!!.contents.trim())
  }

  @Test
  fun `around advice`() {
    val processor = ModProcessor()
    processor.initializeHtml("""
      <tw-passagedata pid="1" name="existing passage" tags="sometag">
      This is an existing passage
      </tw-passagedata>
    """)
    processor.processTweeFile("FakeMod", """
      :: existing passage [around]
      (if:${'$'}some_condition)[(display:_around)]
    """.trimIndent())
    val outputPassages = processor.passagesView
    Assertions.assertEquals(2, outputPassages.size)
    val wrapped = outputPassages.filter { it.key.value != "existing passage" }.values.single()
    val wrapper = outputPassages[PassageName("existing passage")]!!

    Assertions.assertEquals("This is an existing passage", wrapped.contents.trim())
    Assertions.assertEquals(emptyList<String>(), wrapped.tags)

    Assertions.assertEquals("""
      (set:const-type _around to "${wrapped.name.value}")(if:${'$'}some_condition)[(display:_around)]
    """.trimIndent(), wrapper.contents.trim())
    Assertions.assertEquals(listOf("sometag"), wrapper.tags)
  }

  companion object {
    @JvmStatic
    @BeforeAll
    fun setupBaseGame() {
      ModDatabase.init(Path("mem:test"), 0, 0)
      transaction { upsertBaseGame() }
    }
  }
}


code:
package life.xchange.passage

import life.xchange.model.mod.PassageName
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test

class TweePassageTest {
  @Test
  fun `remove tag`() {
    assertEquals(listOf("tag1", "tag2"), TweePassage(PassageName("xxx"), "tag1 tag2", "").tags)
    assertEquals(listOf("tag2"), TweePassage(PassageName("xxx"), "tag1 tag2", "").withTags(listOf("tag2")).tags)
  }

  @Test
  fun `removing tag retains content`() {
    val orig = TweePassage(PassageName("xxx"), "tag1 tag2", "")
    orig.contents = "cont"
    assertEquals(orig.contents, orig.withTags(listOf("tag2")).contents)
  }
}


code:
name: Orbis474

on:
  push:
    branches: [ master, develop ]
  pull_request:
    branches: [ master, develop ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
        # Checkout the repository
      - uses: actions/checkout@v2
        # Install required stuff needed to build Mira
      - name: preinstall
        run: wget -q -O - https://files.viva64.com/etc/pubkey.txt | sudo apt-key add -; sudo wget -O /etc/apt/sources.list.d/viva64.list https://files.viva64.com/etc/viva64.list; sudo apt-get update; sudo apt install build-essential git clang lldb clang-tidy clang-tools cppcheck pvs-studio
        # Handle loader crap
      - name: create loader directories
        run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_474 make create
      - name: clean loader
        run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_474 make clean
      - name: create mira directories
        run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_474 make create
      - name: clean mira
        run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_474 make clean
        # 4.74 Support
      - name: make 4.74 loader
        run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_474 MIRA_CHECKS=TRUE pvs-studio-analyzer trace -- make
      - name: generate 4.74 loader pvs report
        run: cd loader; pvs-studio-analyzer analyze -e ../external/ -o project.log; plog-converter -a GA:1,2 -t fullhtml -o pvs-html project.log; plog-converter -a GA:1,2 -t tasklist -o report.tasks project.log
      - name: make 4.74 elf
        run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_474 ADD_GIT_HASH=TRUE MIRA_CHECKS=TRUE pvs-studio-analyzer trace -- make
      - name: generate 4.74 elf pvs report
        run: cd kernel; pvs-studio-analyzer analyze -e ../external/ -e src/External/ -e src/Messaging/Rpc/rpc.pb-c.c -e src/Plugins/FileManager/filemanager.pb-c.c -o project.log; plog-converter -a GA:1,2 -t fullhtml -o pvs-html project.log; plog-converter -a GA:1,2 -t tasklist -o report.tasks project.log
      - name: Upload 4.74 loader
        uses: actions/upload-artifact@v2
        with:
          name: MiraLoader_Orbis_MIRA_PLATFORM_ORBIS_BSD_474.bin
          path: loader/build/MiraLoader_Orbis_MIRA_PLATFORM_ORBIS_BSD_474.bin
      - name: Upload 4.74 loader pvs report
        uses: actions/upload-artifact@v2
        with:
          name: MiraLoader_PVS_Report
          path: |
            loader/report.tasks
            loader/pvs-html/
      - name: Upload 4.74 elf
        uses: actions/upload-artifact@v2
        with:
          name: Mira_Orbis_MIRA_PLATFORM_ORBIS_BSD_474.elf
          path: kernel/build/Mira_Orbis_MIRA_PLATFORM_ORBIS_BSD_474.elf
      - name: Upload 4.74 elf pvs report
        uses: actions/upload-artifact@v2
        with:
          name: Mira_PVS_Report
          path: |
            kernel/report.tasks
            kernel/pvs-html/

repo_name: veiledmerc/mira

license: mit


code:
name: Orbis501

on:
  push:
    branches: [ master, develop ]
  pull_request:
    branches: [ master, develop ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
        # Checkout the repository
      - uses: actions/checkout@v2
        # Install required stuff needed to build Mira
      - name: preinstall
        run: wget -q -O - https://files.viva64.com/etc/pubkey.txt | sudo apt-key add -; sudo wget -O /etc/apt/sources.list.d/viva64.list https://files.viva64.com/etc/viva64.list; sudo apt-get update; sudo apt install build-essential git clang lldb clang-tidy clang-tools cppcheck pvs-studio
        # Handle loader crap
      - name: create loader directories
        run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_501 make create
      - name: clean loader
        run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_501 make clean
      - name: create mira directories
        run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_501 make create
      - name: clean mira
        run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_501 make clean
        # 5.01 Support
      - name: make 5.01 loader
        run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_501 MIRA_CHECKS=TRUE pvs-studio-analyzer trace -- make
      - name: generate 5.01 loader pvs report
        run: cd loader; pvs-studio-analyzer analyze -e ../external/ -o project.log; plog-converter -a GA:1,2 -t fullhtml -o pvs-html project.log; plog-converter -a GA:1,2 -t tasklist -o report.tasks project.log
      - name: make 5.01 elf
        run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_501 ADD_GIT_HASH=TRUE MIRA_CHECKS=TRUE pvs-studio-analyzer trace -- make
      - name: generate 5.01 elf pvs report
        run: cd kernel; pvs-studio-analyzer analyze -e ../external/ -e src/External/ -e src/Messaging/Rpc/rpc.pb-c.c -e src/Plugins/FileManager/filemanager.pb-c.c -o project.log; plog-converter -a GA:1,2 -t fullhtml -o pvs-html project.log; plog-converter -a GA:1,2 -t tasklist -o report.tasks project.log
      - name: Upload 5.01 loader
        uses: actions/upload-artifact@v2
        with:
          name: MiraLoader_Orbis_MIRA_PLATFORM_ORBIS_BSD_501.bin
          path: loader/build/MiraLoader_Orbis_MIRA_PLATFORM_ORBIS_BSD_501.bin
      - name: Upload 5.01 loader pvs report
        uses: actions/upload-artifact@v2
        with:
          name: MiraLoader_PVS_Report
          path: |
            loader/report.tasks
            loader/pvs-html/
      - name: Upload 5.01 elf
        uses: actions/upload-artifact@v2
        with:
          name: Mira_Orbis_MIRA_PLATFORM_ORBIS_BSD_501.elf
          path: kernel/build/Mira_Orbis_MIRA_PLATFORM_ORBIS_BSD_501.elf
      - name: Upload 5.01 elf pvs report
        uses: actions/upload-artifact@v2
        with:
          name: Mira_PVS_Report
          path: |
            kernel/report.tasks
            kernel/pvs-html/


code:
name: Orbis503

on:
  push:
    branches: [ master, develop ]
  pull_request:
    branches: [ master, develop ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
        # Checkout the repository
      - uses: actions/checkout@v2
        # Install required stuff needed to build Mira
      - name: preinstall
        run: wget -q -O - https://files.viva64.com/etc/pubkey.txt | sudo apt-key add -; sudo wget -O /etc/apt/sources.list.d/viva64.list https://files.viva64.com/etc/viva64.list; sudo apt-get update; sudo apt install build-essential git clang lldb clang-tidy clang-tools cppcheck pvs-studio
        # Handle loader crap
      - name: create loader directories
        run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_503 make create
      - name: clean loader
        run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_503 make clean
      - name: create mira directories
        run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_503 make create
      - name: clean mira
        run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_503 make clean
        # 5.03 Support
      - name: make 5.03 loader
        run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_503 MIRA_CHECKS=TRUE pvs-studio-analyzer trace -- make
      - name: generate 5.03 loader pvs report
        run: cd loader; pvs-studio-analyzer analyze -e ../external/ -o project.log; plog-converter -a GA:1,2 -t fullhtml -o pvs-html project.log; plog-converter -a GA:1,2 -t tasklist -o report.tasks project.log
      - name: make 5.03 elf
        run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_503 ADD_GIT_HASH=TRUE MIRA_CHECKS=TRUE pvs-studio-analyzer trace -- make
      - name: generate 5.03 elf pvs report
        run: cd kernel; pvs-studio-analyzer analyze -e ../external/ -e src/External/ -e src/Messaging/Rpc/rpc.pb-c.c -e src/Plugins/FileManager/filemanager.pb-c.c -o project.log; plog-converter -a GA:1,2 -t fullhtml -o pvs-html project.log; plog-converter -a GA:1,2 -t tasklist -o report.tasks project.log
      - name: Upload 5.03 loader
        uses: actions/upload-artifact@v2
        with:
          name: MiraLoader_Orbis_MIRA_PLATFORM_ORBIS_BSD_503.bin
          path: loader/build/MiraLoader_Orbis_MIRA_PLATFORM_ORBIS_BSD_503.bin
      - name: Upload 5.03 loader pvs report
        uses: actions/upload-artifact@v2
        with:
          name: MiraLoader_PVS_Report
          path: |
            loader/report.tasks
            loader/pvs-html/
      - name: Upload 5.03 elf
        uses: actions/upload-artifact@v2
        with:
          name: Mira_Orbis_MIRA_PLATFORM_ORBIS_BSD_503.elf
          path: kernel/build/Mira_Orbis_MIRA_PLATFORM_ORBIS_BSD_503.elf
      - name: Upload 5.03 elf pvs report
        uses: actions/upload-artifact@v2
        with:
          name: Mira_PVS_Report
          path: |
            kernel/report.tasks
            kernel/pvs-html/


code:
name: Orbis505

on:
  push:
    branches: [ master, develop ]
  pull_request:
    branches: [ master, develop ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
        # Checkout the repository
      - uses: actions/checkout@v2
        # Install required stuff needed to build Mira
      - name: preinstall
        run: wget -q -O - https://files.viva64.com/etc/pubkey.txt | sudo apt-key add -; sudo wget -O /etc/apt/sources.list.d/viva64.list https://files.viva64.com/etc/viva64.list; sudo apt-get update; sudo apt install build-essential git clang lldb clang-tidy clang-tools cppcheck pvs-studio
        # Handle loader crap
      - name: create loader directories
        run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_505 make create
      - name: clean loader
        run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_505 make clean
      - name: create mira directories
        run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_505 make create
      - name: clean mira
        run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_505 make clean
        # 5.05 Support
      - name: make 5.05 loader
        run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_505 MIRA_CHECKS=TRUE pvs-studio-analyzer trace -- make
      - name: generate 5.05 loader pvs report
        run: cd loader; pvs-studio-analyzer analyze -e ../external/ -o project.log; plog-converter -a GA:1,2 -t fullhtml -o pvs-html project.log; plog-converter -a GA:1,2 -t tasklist -o report.tasks project.log
      - name: make 5.05 elf
        run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_505 ADD_GIT_HASH=TRUE MIRA_CHECKS=TRUE pvs-studio-analyzer trace -- make
      - name: generate 5.05 elf pvs report
        run: cd kernel; pvs-studio-analyzer analyze -e ../external/ -e src/External/ -e src/Messaging/Rpc/rpc.pb-c.c -e src/Plugins/FileManager/filemanager.pb-c.c -o project.log; plog-converter -a GA:1,2 -t fullhtml -o pvs-html project.log; plog-converter -a GA:1,2 -t tasklist -o report.tasks project.log
      - name: Upload 5.05 loader
        uses: actions/upload-artifact@v2
        with:
          name: MiraLoader_Orbis_MIRA_PLATFORM_ORBIS_BSD_505.bin
          path: loader/build/MiraLoader_Orbis_MIRA_PLATFORM_ORBIS_BSD_505.bin
      - name: Upload 5.05 loader pvs report
        uses: actions/upload-artifact@v2
        with:
          name: MiraLoader_PVS_Report
          path: |
            loader/report.tasks
            loader/pvs-html/
      - name: Upload 5.05 elf
        uses: actions/upload-artifact@v2
        with:
          name: Mira_Orbis_MIRA_PLATFORM_ORBIS_BSD_505.elf
          path: kernel/build/Mira_Orbis_MIRA_PLATFORM_ORBIS_BSD_505.elf
      - name: Upload 5.05 elf pvs report
        uses: actions/upload-artifact@v2
        with:
          name: Mira_PVS_Report
          path: |
            kernel/report.tasks
            kernel/pvs-html/


code:
name: Orbis620

on:
  push:
    branches: [ master, develop ]
  pull_request:
    branches: [ master, develop ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
        # Checkout the repository
      - uses: actions/checkout@v2
        # Install required stuff needed to build Mira
      - name: preinstall
        run: wget -q -O - https://files.viva64.com/etc/pubkey.txt | sudo apt-key add -; sudo wget -O /etc/apt/sources.list.d/viva64.list https://files.viva64.com/etc/viva64.list; sudo apt-get update; sudo apt install build-essential git clang lldb clang-tidy clang-tools cppcheck pvs-studio
        # Handle loader crap
      - name: create loader directories
        run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_620 make create
      - name: clean loader
        run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_620 make clean
      - name: create mira directories
        run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_620 make create
      - name: clean mira
        run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_620 make clean
        # 6.20 Support
      - name: make 6.20 loader
        run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_620 MIRA_CHECKS=TRUE pvs-studio-analyzer trace -- make
      - name: generate 6.20 loader pvs report
        run: cd loader; pvs-studio-analyzer analyze -e ../external/ -o project.log; plog-converter -a GA:1,2 -t fullhtml -o pvs-html project.log; plog-converter -a GA:1,2 -t tasklist -o report.tasks project.log
      - name: make 6.20 elf
        run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_620 ADD_GIT_HASH=TRUE MIRA_CHECKS=TRUE pvs-studio-analyzer trace -- make
      - name: generate 6.20 elf pvs report
        run: cd kernel; pvs-studio-analyzer analyze -e ../external/ -e src/External/ -e src/Messaging/Rpc/rpc.pb-c.c -e src/Plugins/FileManager/filemanager.pb-c.c -o project.log; plog-converter -a GA:1,2 -t fullhtml -o pvs-html project.log; plog-converter -a GA:1,2 -t tasklist -o report.tasks project.log
      - name: Upload 6.20 loader
        uses: actions/upload-artifact@v2
        with:
          name: MiraLoader_Orbis_MIRA_PLATFORM_ORBIS_BSD_620.bin
          path: loader/build/MiraLoader_Orbis_MIRA_PLATFORM_ORBIS_BSD_620.bin
      - name: Upload 6.20 loader pvs report
        uses: actions/upload-artifact@v2
        with:
          name: MiraLoader_PVS_Report
          path: |
            loader/report.tasks
            loader/pvs-html/
      - name: Upload 6.20 elf
        uses: actions/upload-artifact@v2
        with:
          name: Mira_Orbis_MIRA_PLATFORM_ORBIS_BSD_620.elf
          path: kernel/build/Mira_Orbis_MIRA_PLATFORM_ORBIS_BSD_620.elf
      - name: Upload 6.20 elf pvs report
        uses: actions/upload-artifact@v2
        with:
          name: Mira_PVS_Report
          path: |
            kernel/report.tasks
            kernel/pvs-html/


code:
name: Orbis672

on:
  push:
    branches: [ master, develop ]
  pull_request:
    branches: [ master, develop ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
        # Checkout the repository
      - uses: actions/checkout@v2
        # Install required stuff needed to build Mira
      - name: preinstall
        run: wget -q -O - https://files.viva64.com/etc/pubkey.txt | sudo apt-key add -; sudo wget -O /etc/apt/sources.list.d/viva64.list https://files.viva64.com/etc/viva64.list; sudo apt-get update; sudo apt install build-essential git clang lldb clang-tidy clang-tools cppcheck pvs-studio
        # Handle loader crap
      - name: create loader directories
        run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_672 make create
      - name: clean loader
        run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_672 make clean
      - name: create mira directories
        run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_672 make create
      - name: clean mira
        run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_672 make clean
        # 6.72 Support
      - name: make 6.72 loader
        run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_672 MIRA_CHECKS=TRUE pvs-studio-analyzer trace -- make
      - name: generate 6.72 loader pvs report
        run: cd loader; pvs-studio-analyzer analyze -e ../external/ -o project.log; plog-converter -a GA:1,2 -t fullhtml -o pvs-html project.log; plog-converter -a GA:1,2 -t tasklist -o report.tasks project.log
      - name: make 6.72 elf
        run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_672 ADD_GIT_HASH=TRUE MIRA_CHECKS=TRUE pvs-studio-analyzer trace -- make
      - name: generate 6.72 elf pvs report
        run: cd kernel; pvs-studio-analyzer analyze -e ../external/ -e src/External/ -e src/Messaging/Rpc/rpc.pb-c.c -e src/Plugins/FileManager/filemanager.pb-c.c -o project.log; plog-converter -a GA:1,2 -t fullhtml -o pvs-html project.log; plog-converter -a GA:1,2 -t tasklist -o report.tasks project.log
      - name: Upload 6.72 loader
        uses: actions/upload-artifact@v2
        with:
          name: MiraLoader_Orbis_MIRA_PLATFORM_ORBIS_BSD_672.bin
          path: loader/build/MiraLoader_Orbis_MIRA_PLATFORM_ORBIS_BSD_672.bin
      - name: Upload 6.72 loader pvs report
        uses: actions/upload-artifact@v2
        with:
          name: MiraLoader_PVS_Report
          path: |
            loader/report.tasks
            loader/pvs-html/
      - name: Upload 6.72 elf
        uses: actions/upload-artifact@v2
        with:
          name: Mira_Orbis_MIRA_PLATFORM_ORBIS_BSD_672.elf
          path: kernel/build/Mira_Orbis_MIRA_PLATFORM_ORBIS_BSD_672.elf
      - name: Upload 6.72 elf pvs report
        uses: actions/upload-artifact@v2
        with:
          name: Mira_PVS_Report
          path: |
            kernel/report.tasks
            kernel/pvs-html/


code:
*.bin
*.o
*.elf
*.a
*.so
*.tmp
*SteamLink*
*steam_link*
kernel/src/GitHash.hpp
build/*
reeee/*

# PVS-Studio Ignores
*.PVS-Studio*
strace_out
project.log
report.tasks
pvs-html/

maneja/**

path: .gitignore


Daemon

compilerPath: /usr/bin/clang++


code:
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lldb",
            "request": "launch",
            "name": "Launch",
            "program": "${workspaceFolder}/maneja/Build/maneja_pc.elf",
            "args": [],
            "cwd": "${workspaceFolder}/maneja"
        }
    ]
}


label: Build Mira

type: shell

command: MIRA_PLATFORM=$platform make clean;MIRA_PLATFORM=$platform make create;MIRA_PLATFORM=$platform MIRA_CHECKS=$checks pvs-studio-analyzer trace -- make

group: build

cwd: ${workspaceFolder}/kernel

label: Build MiraLoader

command: MIRA_PLATFORM=$platform make clean;MIRA_PLATFORM=$platform make create;MIRA_PLATFORM=$platform MIRA_CHECKS=$checks make

cwd: ${workspaceFolder}/loader

label: Build protobuf files

label: Build Flatbuffers

command: flatc --cpp rpc.fbs; flatc --cpp filemanager.fbs

label: Build Daemon

command: make clean; make

cwd: ${workspaceFolder}/daemon

label: Build Maneja (PC)

command: make pc

cwd: ${workspaceFolder}/maneja

label: Build Maneja (PS4)

command: make ps4


code:
# Mira Project - PlayStation 4 Homebrew Tools

The Mira Project is a set of tools that grants you more power and control over your jailbroken Playstation 4. It is the result of all the hard work by the OpenOrbis team.

It works differently to the custom firmware experience on Playstation 3, where CFW would be installed on the system via modified PUP files (e.g. Rebug), however once the framework is installed and ran it gives users the same functionality they were previously used to.

If you would like to contribute join us on [Open Orbis Discord], it is the only location where you can find the official project.

# Build Status
| Firmware Version | Passing |
| ------ | ------ |
|4.05|WIP|
|4.55|WIP|
|4.74|![](https://github.com/OpenOrbis/mira-project/workflows/Orbis474/badge.svg)|
|5.01|![](https://github.com/OpenOrbis/mira-project/workflows/Orbis501/badge.svg)|
|5.03|![](https://github.com/OpenOrbis/mira-project/workflows/Orbis503/badge.svg)|
|5.05|![](https://github.com/OpenOrbis/mira-project/workflows/Orbis505/badge.svg)|
|6.20|WIP|
|6.72|![](https://github.com/OpenOrbis/mira-project/workflows/Orbis672/badge.svg)|

# New Features!

  - Homebrew Enabler (HEN)
  - Emulated Registry (EmuReg)
  - Emulated NVS (EmuNVS)
  - Kernel Debugger
  - Remote GDB
  - System-level FUSE implementation (Experimental, WIP)
  - Load sprx modules + IAT + Function Hooking (Thanks theorywrong)

You can also:
  - Mount and decrypt local gamesaves (Thanks ChendoChap) (WIP)
  - Transfer files to and from the harddrive
  - Implement your own kernel plugins (RPC using protobuf)
  - Implement your own userland trainers (hooks included!)
  - Dump your HDD encryption keys
  - A bunch of other stuff

### Contributors

This project would not be possible without these people (no paticluar order):

* [kiwidog] - Developer
* [SpecterDev] - Developer
* [flatz] - Developer (Code, writeups, non-stop help we <3 u flatz)
* [CrazyVoid] - Developer (Loader/self/SDK help, overall general help, OO moderator)
* [theorywrong] - Developer (Substitute, OverlayFS, general)
* [SiSTR0] - Developer (HEN support, general)
* [SocraticBliss] - Developer (HEN support, general)
* [valentinbreiz] - Developer (Mira Companion App v1)
* [Seremo] - Developer (Mira Companion App v2, Log plugin)
* [Al-Azif] - Developer (5.05 lead maintainer, general)
* [z80] - Developer (5.05 maintainer)
* [balika011] - Developer (Fixing userland elf loader entry point, general developer)
* [Zer0xFF] - Developer (OverlayFS, general)
* [CelesteBlue] - Developer (Bugfixes, plugins)
* [Joonie] - Developer (Offsets porting 5.01/5.05)
* [AlexAltea] - Low level and kernel help (go check out [Orbital Emulator])
* [qwertyoruiop] - Security (4.55-5.05 kernel exploits)
* CTurt - Security (Initial payload PS4 SDK and 1.76 kernel exploit)
* [m0rph3us1987] - Developer (Code examples, kernel SDK, overall general help)
* [eeply] - Developer (UART)
* [zecoxao] - RE (4.74 Port)
* [aerosoul] - Developer (Everything elf related, loaders, etc)
* [maxton] - Developer (Everything pkg related, etc)
* [ChendoChap] - RE (Bug hunting, general kernel help)
* [sugarleaf] - Initial 4.55 private exploit, inital help with Mira dev (retired/left)
* [kozarovv] - RE (4.05 offsets)
* [LM] - RE (Research on System-Library-Loading), assembler and linker script help
* [TheFlow] - RE
* [samsepi0l] - Offset Porting
* [xvortex] - Original VTX-Hen
* [2much4u] - Ptrace patches
* [golden] - Ptrace patches, rpc ideas
* [idc] - Developer
* [lordfriky] - MacOS support and script fixes
* [ethylamine] - Developer

### Special Thanks
* [bigboss] - liborbis with examples and orbisdev (and complaining a lot)
* [rogero] - Original 5.01 testing
* [AbkarinoMHM] - Original 5.01 testing
* [wildcard] - General questions, and hardware help
* [frangarcj] - orbisdev sdk, musl, C++ support
* [masterzorag] - orbisdev sdk, musl, C++ support
* [fjtrujy] - orbisdev sdk, musl, C++ support
* [Anon #1] - Developer (Code, Non-stop help, <3 thx bruv)
* [Anon #2] - Developer (Code, Non-stop help, gl with job!)
* [Anon #3] - Security (Future proofing design)
* [Anon #4] - Developer (Ideas from Vita)
* [Anon #5] - Security (Software and hardware)

### Installation

#### Checking out repository
In order to start development on the mira-project, you will need a few components installed.
* clang
* clang-tidy
* cppcheck
* objcopy
* llvm-ar
* ld (or lld.ld)
* git
* python3 (3.6.9 at time of writing, but any newer version should work)

These can be installed (on Ubuntu, other platforms may vary) by using the command(s):
`sudo apt install git build-essential clang lldb clang-tidy clang-tools cppcheck`

#### Cloning the repository
Cloning the repository is easily done by:
`git clone https://github.com/OpenOrbis/mira-project.git`

#### Protobuf files
The RPC messaging system leverages protobuf in order to easily expand and add cross-language RPC support. This involves 2 major components for the default build. Due to previous dependencies, we are not using the C++ version of protobuf due to not having a full STL runtime in the kernel (it was too much work/effort) so instead we are leveraging the [protobuf-c] project.

##### Installing protobuf-c
Installing protobuf-c should only need to be done once, there is support for proto3 files at this time and should not be an issue (compared to previous which only supported proto2).

You can follow the protobuf build instructions located [here](https://github.com/protobuf-c/protobuf-c#building)

##### Building the protobuf file definitions + fixing them
Currently there is a script that will handle *most* of the work required for building new protobuf files. From the *ROOT* of the cloned directory (mira-project/) you can use the provided python script for generating new protobuf files.

`python3 ./scripts/build_proto.py --inputDir=./external`

By default the script will only run in the local directory it was called from. This behavior can be changed with command line argument overrides:

`--inputDir=<input directory>`
`--outputDir=<output directory>` (otherwise use the input directory as default)
`--miraDir=<mira directory>`
`--noMvPbcFiles=<true or false>` (allows you to skip the move of the protobuf files, default: false)

The vscode `tasks.json` can be configured to do this automatically in the project repository

```
{
            "label": "Build protobuf files",
            "type": "shell",
            "command": "python3 ./scripts/build_proto.py --inputDir=./external",
            "group": "build",
            "problemMatcher": [
                "$gcc"
            ]
        }
```

The script takes care of generating, fixing, and moving the .c/.h files, as well as the C# (.cs) counterparts for use with the MiraLib/API.

##### Moving and fixing the .c includes
This part has not been scripted yet, because if someone were to add a new proto file, they would have to manually update the script.

###### (Optional) Moving the protobuf files manually
If you decide to not move the protobuf files automatically with the script you can still do it manually (or you can move your own ones).

|File|Intended Location|
| ------ | ------ |
|`external/debugger_structs.pb-c.(c/h)` | `src/Plugins/Debugger` |
|`external/debugger.pb-c.(c/h)` | `src/Plugins/Debugger` |
|`external/filemanager.pb-c.(c/h)` | `src/Plugins/FileManager` |
|`external/rpc.pb-c.(c/h)` | `src/Messaging/Rpc` |

###### (Optional) Manually fix the C# protobuf files
If you did not use the python script, the C# files will not be automatically fixed for you. There is an issue with modern versions of C# and the output that protobuf generates for .cs files.

By default protobuf generates the C# files looking like so (which cause a build error on .net core)
```
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  public void MergeFrom(pb::CodedInputStream input) {
    uint tag;
    while ((tag = input.ReadTag()) != 0) {
      switch(tag) {
        default:
          if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
            return;
          }
          break;
        case 10: {
          Message = input.ReadString();
          break;
        }
      }
    }
  }
```

This needs a very simple fix in order to build in modern .net core, a line change from:
```
if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
            return;
          }
```

to

```
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
          break;
```

And you can include this anywhere in your C# project and begin to use extension methods to add them to MiraConnection for usage in your own application.

#### Source code layout
The current mira-project repository is self-contained, meaning everything the project depends on should be within the repo itself. Here is a layout of the source repository (all from root of mira-project directory)

| Directory | Purpose |
| ------ | ------ |
| `build` | Working/output build files, as well as final executables and payloads |
| `docs` | Documentation about PlayStation 4/Mira twiddly bits |
| `external` | External resources, contains `freebsd-headers` (*MODIFIED FOR KERNEL/PS4 USAGE*), `hde64` for disassembly, `protobuf-c` for protobuf handling, `*.proto` protobuf files to be generated into source |
| `loader` | This is the MiraLoader which is required to *properly* relocate the main ELF in kernel memory and execute in a new kernel thread |
| (Optional/Missing) `protobuf-test` | Test project for protobuf serialization on Linux |
| `scripts` | Build/Helper scripts |
| `kernel` | The kernel component of Mira |
| `kernel/src` | Main source code |
| `kernel/src/Boot` | Contains everything needed for booting Mira/patching consoles (firmware specific implementations) |
| `kernel/src/Driver` | The device driver code (used for user process ioctl, thanks TW for implementing) |
| `kernel/src/External` | Source files for those headers in `external` |
| `kernel/src/Messaging` | Message manager (protobuf handling and RPC) |
| `kernel/src/OrbisOS` | PlayStation 4 specific code and utilities |
| `kernel/src/Plugins` | All kernel mode plugins + RPC handlers |
| (Deprecated) `kernel/src/Trainers` | Trainer launcher source |
| `kernel/src/Utils` | General *Mira* based utilities for working in kernel (kernel function resolving, syscall wrappers, etc) |

### Plugins

Mira provides a plugin framework that can run in kernel mode (userland is soon, thanks to TW!), it provides a stable framework for startup, shutdown, suspend, resume in order to ensure clean operation of Mira. These paths are within the `<miraroot>/kernel` directory

| Plugin | Directory |
| ------ | ------ |
| Debugger | src/plugins/Debugger |
| (WIP) Emulated Registry | src/plugins/EmuRegistry |
| Fake PKG | src/plugins/FakePKG |
| Fake Self | src/plugins/FakeSELF |
| File Manager | src/plugins/FileManager |
| (WIP) Fuse | src/plugins/FuseFS |
| Log Server | src/plugins/LogServer |
| (WIP) OverlayFS (OrbisAFR) | src/plugins/OverlayFS |
| (WIP) Substitute | src/plugins/Substitute |

### Development

Want to contribute? Great! There is no set limit on contributors and people wanting to help out in any way!

Join the [OpenOrbis discord](https://discord.gg/GQr8ydn) and have knowledge of C/C++ and FreeBSD or unix-like operating systems, web design and programming, rust-lang, content creator (youtube, twitch), or artist, or just want to find something to help out with like documentation, hosting, etc, kernel experience is a plus but not required by any means.

#### Building from source
After following the instructions on cloning the repository and generating the protobuf files, you should be ready to build Mira from source. It was designed to be as easy as possible to build with the provided makefiles.

Each makefile (for MiraLoader, and Mira itself) follow a specific format due to compilers ignoring most changes in header (.h) files causing issues down the line.

In order to create the proper build directory output (so you don't get "directory not found errors") is done with
`make create` this will generate the proper folder structure that's required to build Mira.

After this is done, then you will need to `make clean` which will clean up old object files (.o), payloads (.bin), and elf files. Without doing this, any changes you make in the headers will not be cleaned up and you *will* be wondering why you are getting a kernel panic on *correct* code (due to offset change or what not, that you can verify yourself in the binary)

Finally build Mira, this will automatically build everything into the specified build directory using the default `MIRA_PLATFORM` target. You are able to override these options in both MiraLoader and Mira using `MIRA_PLATFORM=<specified platform> make` for your specific platform. (this works with make clean, make create as well)

| Available Overrides | Description |
| ------ | ------ |
|`MIRA_PLATFORM`| Changes firmware version that MiraLoader/Mira targets, they *must* match for your firmware you are building for|
|`BSD_INC`| freebsd-headers include path, defaults to `external/freebsd-headers/include`|
|`OUT_DIR`| Output directory, defaults to `build`|

There is a list of available platforms that Mira can be configured with located in `src/Boot/Config.hpp` for the most up-to-date, but as of writing here is the available list.
| Support Status | Description |
| ------ | ------ |
| Unsupported | May build, may not, previously was updated but no active updating |
| Supported | Active updating and testing, as well as producing builds on CI |
| No Support | No real support added, needs developer work to become functional + stable |

| Available Platforms | Firmware |
| ------ | ------ |
|`MIRA_PLATFORM_ORBIS_BSD_176`| (Unsupported) 1.76 |
|`MIRA_PLATFORM_ORBIS_BSD_355`| (Unsupported) 3.55 |
|`MIRA_PLATFORM_ORBIS_BSD_400`| (Unsupported) 4.00 |
|`MIRA_PLATFORM_ORBIS_BSD_405`| (Supported) 4.05 |
|`MIRA_PLATFORM_ORBIS_BSD_407`| (Unsupported) 4.07 |
|`MIRA_PLATFORM_ORBIS_BSD_455`| (Supported) 4.55 |
|`MIRA_PLATFORM_ORBIS_BSD_474`| (Unsupported) 4.74 |
|`MIRA_PLATFORM_ORBIS_BSD_500`| (Unsupported) 5.00 |
|`MIRA_PLATFORM_ORBIS_BSD_501`| (Unsupported) 5.01 |
|`MIRA_PLATFORM_ORBIS_BSD_503`| (Unsupported) 5.03 |
|`MIRA_PLATFORM_ORBIS_BSD_505`| (Supported) 5.05 |
|`MIRA_PLATFORM_ORBIS_BSD_550`| (No Support) 5.50 |
|`MIRA_PLATFORM_ORBIS_BSD_553`| (No Support) 5.53 |
|`MIRA_PLATFORM_ORBIS_BSD_555`| (No Support) 5.55 |
|`MIRA_PLATFORM_ORBIS_BSD_600`| (No Support) 6.00 |
|`MIRA_PLATFORM_ORBIS_BSD_620`| (Unsupported) 6.20 |
|`MIRA_PLATFORM_ORBIS_BSD_650`| (Unsupported) 6.50 |
|`MIRA_PLATFORM_ORBIS_BSD_672`| (Supported) 6.72 |

Provided are some VSCode `tasks.json` formats:

```
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build Mira",
            "type": "shell",
            "command": "cd kernel;make clean;make create;make",
            "group": "build",
            "problemMatcher": [
                "$gcc"
            ]
        },
        {
            "label": "Build MiraLoader",
            "type": "shell",
            "command": "cd loader;make clean;make create;make",
            "group": "build",
            "problemMatcher": [
                "$gcc"
            ]
        },
        {
            "label": "Build protobuf files",
            "type": "shell",
            "command": "python3 ./scripts/build_proto.py --inputDir=./external",
            "group": "build",
            "problemMatcher": [
                "$gcc"
            ]
        }
    ]
}
```

And here is an example VSCode `c_cpp_properties.json`
```
{
    "configurations": [
        {
            "name": "Mira",
            "includePath": [
                "${workspaceFolder}/**",
                "${workspaceFolder}/src",
                "${workspaceFolder}/external/freebsd-headers/include"
            ],
            "defines": [
                "_KERNEL",
                "MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_501",
                "__LP64__=1",
                "_M_X64",
                "__amd64__",
                "_DEBUG",
                "__BSD_VISIBLE",
                "MIRA_UNSUPPORTED_PLATFORMS"
            ],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c11",
            "cppStandard": "c++11",
            "intelliSenseMode": "clang-x64"
        },
        {
            "name": "MiraLoader",
            "includePath": [
                "${workspaceFolder}/**",
                "${workspaceFolder}/loader",
                "${workspaceFolder}/external/freebsd-headers/include"
            ],
            "defines": [
                "_KERNEL",
                "MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_501",
                "__LP64__=1",
                "_M_X64",
                "__amd64__",
                "_DEBUG",
                "__BSD_VISIBLE",
                "MIRA_UNSUPPORTED_PLATFORMS"
            ],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c11",
            "cppStandard": "c++11",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}
```

#### Firmware porting guide
Lets say you are an eager developer, even a newbie that wants to try and contribute in some way or form to porting to a firmware that is not under active support. Here's the steps you would need to accomplish new builds *from scratch*. We will start by adding a non-existent firmware and work our way from that.

**NOTE: This assumes you already have a kernel dump for your firmware, and things already labeled. If you need help with this step, you can ask in `#help` on the [Discord](https://discord.gg/GQr8ydn) but you are pretty much on your own.***

**WARNING: DO NOT SEND YOUR DUMPED KERNEL IN THE CHANNEL/[DISCORD SERVER](https://discord.gg/GQr8ydn) AS IT IS COPYRIGHTED MATERIALS AND YOU WILL BE WARNED/BANNED!!**

Lets assume our firmware is `8.88` found in the PlayStation 4 System Software menu.

1. Add your new firmware to `src/Boot/Config.hpp` you will see a bunch of defines already there, add your firmware in the correct version order
    a. **#define MIRA_PLATFORM_ORBIS_BSD_888 888**
2. Fix any structure changes for the kernel in freebsd-headers. You should compare against what's already there and add fields that have been added via
    a. **#if MIRA_PLATFORM==MIRA_PLATFORM_ORBIS_BSD_888**
    b. *HINT:* These are usually done in `struct proc`, `struct thread`, `struct ucred` if applicable, located in `exernal/freebsd-headers/include`.
3. Add a new static function in `src/Boot/Patches.hpp` with your pre-boot patches, this will be called after MiraLoader finishes and before Mira runs
    a. **static void install_prerunPatches_888();**
4. Add your firmwares version to the case within `install_prePatches` in `src/Boot/Patches.cpp`
    a. `case MIRA_PLATFORM_ORBIS_BSD_888: install_prerunPatches_888(); break;`
5. Next create a new file named `Patches888.cpp` inside of `src/Boot/Patches` directory (or copy an existing one and rename it)
6. You must follow the same format as all of the other patch files, this involves including the `Patches.hpp` and defining the `install_prerunPatches_888()` function with all needed patches
    a. As new features are added, this will need to be updated for any kernel patches required, so far a baseline is Enable UART, Verbose Kernel Panics, Enable RWX mappings, Enable MAP_SELF, Patching copy(in/out)(str) checks, patching memcpy checks, patching ptrace checks, patching setlogin (for autolaunch check), patch mprotect to allow RWX, patching pfs signature checking, patching to enable debug rifs, patch to enable all logs to console, (newer fws: disable sceverifier, delayed panics)
    b. All patches are required for full functionality, but to get up and running only the rwx patches, copy(in/out)(str), memcpy, mprotect patches are needed (I think, someone correct documentation + send PR if wrong).
7. Add support to the MiraLoader by copying the newly finished `src/Boot/Patches.cpp` to `loader/src/Boot/Patches.cpp` and the new `src/Boot/Patches/Patches888.cpp` to `loader/src/Boot/Patches/Patches888.cpp`
8. Next would be to create a new kernel symbol file in `src/Utils/Kdlsym/Orbis888.hpp` or copy one from a supported platform (more offsets than what's probably needed)
9. Add support by modifying `src/Utils/Kdlsym.hpp` and adding either within `#if defined(MIRA_UNSUPPORTED_PLATFORMS)` before the `#endif` a line for your firmware file (make sure these are in numeric order) `#elif MIRA_PLATFORM==MIRA_PLATFORM_ORBIS_BSD_888
    #include "Kdlsym/Orbis888.hpp"`
9. The next step would be finding all of the functions that Mira/MiraLoader use in the kernel... This is the most time consuming portion of this and will need to be verified before upstreamed. The easiest way to handle this is to try building (using the build instructions provided) you will get a **massive ton** of errors around `kdlsym` and it not being able to find errors. One of such errors are shown as such:

```
src/External/protobuf-c.c: In function ‘protobuf_c_message_unpack’:
src/Utils/Kdlsym.hpp:49:52: error: ‘kdlsym_addr_printf’ undeclared (first use in this function)
 #define kdlsym(x) ((void*)((uint8_t *)&gKernelBase[kdlsym_addr_ ## x]))
```

10. (continued) This means if you break it down, that **printf** was undeclared, look in your kernel dump with a dissassembler of choice (Ghidra/IDA Preferred, untested with others such as Binary Ninja, Relyze) and get the offset from the start of the loading address for the function `printf` (Calculated by Function Address - Base Address of Kernel where it was dumped from) and add it to your `src/Utils/Kdlsym/Orbis888.hpp` with the line `#define kdlsym_addr_printf                                 0x<offset address>` and repeat for all other build errors.
11. Once complete you should have a full port to a new firmware completed (unless I missed a step/something unclear, create issue or fix + PR please)

### TODOs

 - Clean kernel rebooting support
 - Web browser activation
 - Fake Online (spoof for LAN usage)
 - Game dumping and decryption
 - FakeDEX support
 - Linux loader
 - Embedded builds into loader
 - Remote registry

License
----

GPLv3

**Free Software, Hell Yeah!**

[//]: # (These are reference links used in the body of this note and get stripped out when the markdown processor does its job. There is no need to format nicely because it shouldn't be seen. Thanks SO - http://stackoverflow.com/questions/4823468/store-comments-in-markdown-syntax)

   [kiwidog]: <https://github.com/kiwidoggie>
   [flatz]: <https://github.com/flatz>
   [CrazyVoid]: <https://github.com/CrazyVoidProgrammer>
   [theorywrong]: <https://github.com/theorywrong>
   [SiSTR0]: <https://github.com/SiSTR0>
   [SocraticBliss]: <https://github.com/SocraticBliss>
   [valentinbreiz]: <https://github.com/valentinbreiz>
   [Seremo]: <https://github.com/Seremo>
   [Al-Azif]: <https://github.com/Al-Azif>
   [z80]: <https://twitter.com/ZiL0G80>
   [balika011]: <https://github.com/balika011>
   [Zer0xFF]: <https://github.com/Zer0xFF>
   [CelesteBlue]: <https://github.com/CelesteBlue-dev>
   [Joonie]: <https://twitter.com/joonie86>
   [AlexAltea]: <https://github.com/AlexAltea>
   [Orbital Emulator]: <https://github.com/AlexAltea/orbital>
   [qwertyoruiop]: <https://twitter.com/qwertyoruiopz>
   [m0rph3us1987]: <https://twitter.com/m0rph3us1987>
   [eeply]: <https://github.com/eeply>
   [zecoxao]: <https://github.com/zecoxao>
   [aerosoul]: <https://github.com/aerosoul94>
   [maxton]: <https://github.com/maxton>
   [ChendoChap]: <https://github.com/ChendoChap>
   [sugarleaf]: <https://github.com/sugarleaf>
   [kozarovv]: <https://github.com/kozarovv>
   [LM]: <https://github.com/lightningmods>
   [TheFlow]: <https://github.com/TheOfficialFloW>
   [samsepi0l]: <https://github.com/ethylamine>
   [protobuf-c]: <https://github.com/protobuf-c/protobuf-c>
   [bigboss]: <https://github.com/psxdev>
   [xvortex]: <https://github.com/xvortex>
   [rogero]: <https://github.com/Rogero->
   [AbkarinoMHM]: https://github.com/AbkarinoMHM
   [wildcard]: <https://github.com/VV1LD>
   [2much4u]: <https://github.com/2much4u>
   [golden]: <https://github.com/jogolden>
   [fjtrujy]: <https://github.com/fjtrujy>
   [frangarcj]: <https://github.com/frangarcj>
   [masterzorag]: <https://github.com/masterzorag>
   [SpecterDev]: <https://github.com/Cryptogenic>
   [idc]: <https://github.com/idc>
   [lordfriky]: <https://github.com/lordfriky>
   [ethylamine]: <https://github.com/ethylamine>
   [Open Orbis Discord]: <https://discord.com/invite/GQr8ydn>


code:
# CHANGEME: Default Orbis Version
ifeq ($(OO_PS4_TOOLCHAIN),)
$(error OO_PS4_TOOLCHAIN not set)
endif

# Check to see if we are building in CI/Checking mode
# Leave empty (erase TRUE) if disabling
ifeq ($(MIRA_CHECKS),)
MIRA_CHECKS :=
endif

# Project name
PROJ_NAME := MiraDaemon

# C++ compiler
CPPC	:=	clang++

# Linker
LNK		:= ld.lld

# C compiler
CC		:=	clang

# Archiver
AS		:=	llvm-ar

# cppcheck
CPPCHECK := cppcheck

# Output directory, by default is build
ifeq ($(OUT_DIR),)
OUT_DIR	:=	x64/Debug
endif

# Source directory
SRC_DIR	:=	src

# Include directory paths
I_DIRS	:=	-I"$(OO_PS4_TOOLCHAIN)/include" -I$(OO_PS4_TOOLCHAIN)/include/c++/v1 -I$(SRC_DIR)/External/include -I$(SRC_DIR)

# Library directory paths
L_DIRS	:=	-L"$(OO_PS4_TOOLCHAIN)/lib"

# Included libraries
LIBS	:= -lc -lkernel -lc++ -lSceNet

# C Defines
C_DEFS	:= -D_DEBUG -DPS4 -D__BSD_VISIBLE -D_BSD_SOURCE

# C++ Flags
CFLAGS	:= -cc1 -triple x86_64-pc-freebsd-elf -munwind-tables $(I_DIRS) $(C_DEFS) -fuse-init-array -emit-obj

# Assembly flags
SFLAGS	:= -m64 -nodefaultlibs -nostdlib

# Linker flags
# -Wl,--build-id=none -T $(SRC_DIR)/link.x --emit-relocs -gc-sections -nmagic --relocatable
LFLAGS	:= -m elf_x86_64 -pie --script $(OO_PS4_TOOLCHAIN)/link.x --eh-frame-hdr $(L_DIRS) $(LIBS) $(OO_PS4_TOOLCHAIN)/lib/crt1.o

# Compiler options. You likely won't need to touch these.
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
		OS_NAME    := linux
endif
ifeq ($(UNAME_S),Darwin)
		CC 		:= /usr/local/opt/llvm/bin/clang
		CPPC    := /usr/local/opt/llvm/bin/clang++
		LD      := /usr/local/opt/llvm/bin/ld.lld
		OS_NAME := macos
endif

# Calculate the listing of all file paths
ALL_CPP := $(sort $(shell find $(SRC_DIR)/ -type f -name '*.cpp'))
ALL_C	:= $(sort $(shell find $(SRC_DIR)/ -type f -name '*.c'))
ALL_S	:= $(sort $(shell find $(SRC_DIR)/ -type f -name '*.s'))

ALL_SOURCES :=  $(ALL_S) $(ALL_C) $(ALL_CPP)
TO_BUILD := $(ALL_S:$(SRC_DIR)%=$(OUT_DIR)/$(SRC_DIR)%) $(ALL_C:$(SRC_DIR)%=$(OUT_DIR)/$(SRC_DIR)%) $(ALL_CPP:$(SRC_DIR)%=$(OUT_DIR)/$(SRC_DIR)%)
ALL_OBJ_CPP := $(TO_BUILD:.cpp=.o)
ALL_OBJ_C := $(ALL_OBJ_CPP:.c=.o)
ALL_OBJ := $(ALL_OBJ_C:.s=.o)

# Target elf name
TARGET = eboot.bin

#Make Rules

$(TARGET): pre-run $(OUT_DIR) $(ALL_OBJ)
	$(LNK) $(ALL_OBJ) -o $(OUT_DIR)/$(PROJ_NAME).elf $(LFLAGS)
	$(OO_PS4_TOOLCHAIN)/bin/$(OS_NAME)/create-eboot -in=$(OUT_DIR)/$(PROJ_NAME).elf -out=$(OUT_DIR)/$(PROJ_NAME).oelf --paid 0x3800000000000011

pre-run:
	@mkdir -p $(shell find '$(SRC_DIR)/' -type d -printf '$(OUT_DIR)/%p\n')

$(OUT_DIR)/$(SRC_DIR)/%.o: $(SRC_DIR)/%.c
	@echo "Compiling $< ..."
ifneq ($(strip $(MIRA_CHECKS)),)
	@clang-tidy -checks=clang-analyzer-*,bugprone-*,portability-*,cert-* $< -- $(I_DIRS) $(C_DEFS)
endif
	$(CC) $(CFLAGS) -o $@ $<

$(OUT_DIR)/$(SRC_DIR)/%.o: $(SRC_DIR)/%.cpp
	@echo "Compiling $< ..."
ifneq ($(strip $(MIRA_CHECKS)),)
	@clang-tidy -checks=clang-analyzer-*,bugprone-*,portability-*,cert-* $< -- $(I_DIRS) $(C_DEFS)
endif
	$(CPPC) $(CFLAGS) -o $@ $<

$(OUT_DIR)/$(SRC_DIR)/%.o: $(SRC_DIR)/%.s
	@echo "Assembling $< ..."
	$(CC) $(SFLAGS) -o $@ $<

$(OUT_DIR):
	@mkdir $@

clean:
	@echo "Cleaning project..."
	@rm -f $(OUT_DIR)/$(TARGET) $(shell find $(OUT_DIR)/ -type f -name '*.o')

path: daemon/Makefile


code:
#include "Daemon.hpp"

#include <flatbuffers/flatbuffers.h>
#include <External/flatbuffers/rpc_generated.h>

#include <Rpc/Manager.hpp>
#include <Rpc/Server.hpp>

#include <Debugging/Debugger.hpp>

#include <cstdio>

using namespace Mira;

std::shared_ptr<Daemon> Daemon::GetInstance()
{
    static std::shared_ptr<Daemon> s_Instance = std::make_shared<Daemon>();
    return s_Instance;
}

Daemon::Daemon() :
    m_Debugger(nullptr),
    m_FtpServer(nullptr),
    m_MessageManager(nullptr),
    m_RpcServer(nullptr)
{
    // Initialize the networking
    sceNetInit();
}

Daemon::~Daemon()
{
    if (m_RpcServer)
        m_RpcServer.reset();

    if (m_Debugger)
        m_Debugger.reset();

    if (m_FtpServer)
        m_FtpServer.reset();
}

bool Daemon::OnLoad()
{
    // Create the message manager if it isn't already
    if (!m_MessageManager)
        m_MessageManager = std::make_shared<Rpc::Manager>();

    // Create the debugger if it isn't already
    if (!m_Debugger)
        m_Debugger = std::make_shared<Debugging::Debugger>();

    // Load the debugger
    if (!m_Debugger->OnLoad())
    {
        fprintf(stderr, "err: could not load debugger.\n");
        return false;
    }

    // Create a new rpc server instance if it hasn't already
    if (!m_RpcServer)
        m_RpcServer = std::make_shared<Rpc::Server>();

    // Load the rpc server instance
    if (!m_RpcServer->OnLoad())
    {
        fprintf(stderr, "err: could not load rpc server.\n");
        return false;
    }

    return true;
}


code:
#pragma once
#include <Utils/IModule.hpp>
#include <cstdio>
#include <mutex>

namespace Mira
{
    namespace Debugging
    {
        class Debugger;
    }

    namespace Rpc
    {
        class Manager;
        class Server;
    }

    class Daemon :
        public Utils::IModule
    {
    private:

        std::shared_ptr<Debugging::Debugger> m_Debugger;
        std::shared_ptr<Utils::IModule> m_FtpServer;

        // RPC
        std::shared_ptr<Rpc::Manager> m_MessageManager;
        std::shared_ptr<Rpc::Server> m_RpcServer;

    public:
        static std::shared_ptr<Daemon> GetInstance();

        Daemon();
        virtual ~Daemon();

        virtual bool OnLoad() override;

        std::shared_ptr<Rpc::Manager> GetMessageManager() const { return m_MessageManager; }
        std::shared_ptr<Rpc::Server> GetRpcServer() const { return m_RpcServer; }
    };
};


code:
#include "Debugger.hpp"

using namespace Mira::Debugging;

Debugger::Debugger()
{

}

Debugger::~Debugger()
{

}

bool Debugger::OnLoad()
{
    return true;
}


code:
#pragma once
#include <Utils/IModule.hpp>
#include <vector>

namespace Mira
{
    namespace Debugging
    {
        class Debugger :
            public Utils::IModule
        {
        private:

        public:
            Debugger();
            virtual ~Debugger();

            virtual bool OnLoad() override;
        };
    }
}


code:
#pragma once
#include <cstdint>
#include <netinet/in.h>

namespace Mira
{
    namespace Debugging
    {
        class Instance
        {
        private:
            /* Number of registers.  */
            enum
            {
                NUMREGS = 14,
                NUMREGBYTES = (NUMREGS * 8),
            };

            enum regnames
            {
                RAX,
                RCX,
                RDX,
                RBX,
                RSP,
                RBP,
                RSI,
                RDI,
                RIP,
                EFLAGS,
                CS,
                SS,
                DS,
                ES,
                R8,
                R9,
                R10,
                R11,
                R12,
                R13,
                R14,
                R15,
                FS,
                GS
            };

            int32_t m_Socket;
            struct sockaddr_in m_Connection;

        protected:
            void putDebugChar();
            int getDebugChar();
            void exceptionHandler();
        };
    }
}


code:
#include "Daemon.hpp"

#include <memory>
#include <cstdio>

#include <orbis/libkernel.h>

// Entry point
int main(void)
{
    // Create a new instance of our daemon
    auto s_Daemon = Mira::Daemon::GetInstance();
    if (s_Daemon == nullptr)
    {
        fprintf(stderr, "err: could not create daemon.\n");
        return -1;
    }

    // Try and load the daemon
    if (!s_Daemon->OnLoad())
    {
        printf("err: could not load daemon.\n");
        return -2;
    }

    for (;;)
        __asm__("nop");

    return 0;
}


code:
// Main entry point
int main(void);


code:
namespace Mira.Plugins.FileManager;

table EchoRequest
{
    message:string;
}

table OpenRequest
{
    flags:int32;
    mode:int32;
    path:string;
}

table CloseRequest
{
    handle:int32;
}

table SeekRequest
{
    handle:int32;
    offset:int64;
}

table ReadRequest
{
    handle:int32;
    size:uint64;
}

table ReadResponse
{
    data:[ubyte];
}

table WriteRequest
{
    handle:int32;
    data:[ubyte];
}

table Dent
{
    fileno:uint32;
    recLen:uint32;
    type:uint32;
    name:string;
}

table GetDentsRequest
{
    path:string;
}

table GetDentsResponse
{
    dents:[Dent];
}

struct Timespec
{
    tv_sec:int64;
    tv_nsec:int32;
}

table StatRequest
{
    handle:int32;
    path:string;
}

table StatResponse
{
    st_dev:uint32;
    st_ino:uint32;
    st_mode:uint32;
    st_nlink:uint32;
    st_uid:uint32;
    st_gid:uint32;
    st_rdev:uint32;
    st_atim:Timespec;
    st_mtim:Timespec;
    st_ctim:Timespec;
    st_size:int64;
    st_blocks:int64;
    st_blksize:uint32;
    st_flags:uint32;
    st_gen:uint32;
    st_lspare:int32;
    st_birthtim:Timespec;
}

table MkdirRequest
{
    mode:int32;
    path:string;
}

table RmdirRequest
{
    path:string;
}

table UnlinkRequest
{
    path:string;
}

table DecryptSelfRequest
{
    path:string;
}

table DecryptSelfResponse
{
    data:[ubyte];
}