[
  {
    "path": ".gitattributes",
    "content": "# Auto detect text files and perform LF normalization\n* text=auto\n"
  },
  {
    "path": ".gitignore",
    "content": "*.exe\n*.dll\n*.pdb\n*.sys\n*.ink\n*.txt\n*.log\ntest/\n\n\n## Ignore Visual Studio temporary files, build results, and\n## files generated by popular Visual Studio add-ons.\n##\n## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore\n\n# User-specific files\n*.rsuser\n*.suo\n*.user\n*.userosscache\n*.sln.docstates\n\n# User-specific files (MonoDevelop/Xamarin Studio)\n*.userprefs\n\n# Mono auto generated files\nmono_crash.*\n\n# Build results\n[Dd]ebug/\n[Dd]ebugPublic/\n[Rr]elease/\n[Rr]eleases/\nx64/\nx86/\n[Ww][Ii][Nn]32/\n[Aa][Rr][Mm]/\n[Aa][Rr][Mm]64/\nbld/\n[Bb]in/\n[Oo]bj/\n[Ll]og/\n[Ll]ogs/\n\n# Visual Studio 2015/2017 cache/options directory\n.vs/\n# Uncomment if you have tasks that create the project's static files in wwwroot\n#wwwroot/\n\n# Visual Studio 2017 auto generated files\nGenerated\\ Files/\n\n# MSTest test Results\n[Tt]est[Rr]esult*/\n[Bb]uild[Ll]og.*\n\n# NUnit\n*.VisualState.xml\nTestResult.xml\nnunit-*.xml\n\n# Build Results of an ATL Project\n[Dd]ebugPS/\n[Rr]eleasePS/\ndlldata.c\n\n# Benchmark Results\nBenchmarkDotNet.Artifacts/\n\n# .NET Core\nproject.lock.json\nproject.fragment.lock.json\nartifacts/\n\n# ASP.NET Scaffolding\nScaffoldingReadMe.txt\n\n# StyleCop\nStyleCopReport.xml\n\n# Files built by Visual Studio\n*_i.c\n*_p.c\n*_h.h\n*.ilk\n*.meta\n*.obj\n*.iobj\n*.pch\n*.pdb\n*.ipdb\n*.pgc\n*.pgd\n*.rsp\n*.sbr\n*.tlb\n*.tli\n*.tlh\n*.tmp\n*.tmp_proj\n*_wpftmp.csproj\n*.log\n*.vspscc\n*.vssscc\n.builds\n*.pidb\n*.svclog\n*.scc\n\n# Chutzpah Test files\n_Chutzpah*\n\n# Visual C++ cache files\nipch/\n*.aps\n*.ncb\n*.opendb\n*.opensdf\n*.sdf\n*.cachefile\n*.VC.db\n*.VC.VC.opendb\n\n# Visual Studio profiler\n*.psess\n*.vsp\n*.vspx\n*.sap\n\n# Visual Studio Trace Files\n*.e2e\n\n# TFS 2012 Local Workspace\n$tf/\n\n# Guidance Automation Toolkit\n*.gpState\n\n# ReSharper is a .NET coding add-in\n_ReSharper*/\n*.[Rr]e[Ss]harper\n*.DotSettings.user\n\n# TeamCity is a build add-in\n_TeamCity*\n\n# DotCover is a Code Coverage Tool\n*.dotCover\n\n# AxoCover is a Code Coverage Tool\n.axoCover/*\n!.axoCover/settings.json\n\n# Coverlet is a free, cross platform Code Coverage Tool\ncoverage*.json\ncoverage*.xml\ncoverage*.info\n\n# Visual Studio code coverage results\n*.coverage\n*.coveragexml\n\n# NCrunch\n_NCrunch_*\n.*crunch*.local.xml\nnCrunchTemp_*\n\n# MightyMoose\n*.mm.*\nAutoTest.Net/\n\n# Web workbench (sass)\n.sass-cache/\n\n# Installshield output folder\n[Ee]xpress/\n\n# DocProject is a documentation generator add-in\nDocProject/buildhelp/\nDocProject/Help/*.HxT\nDocProject/Help/*.HxC\nDocProject/Help/*.hhc\nDocProject/Help/*.hhk\nDocProject/Help/*.hhp\nDocProject/Help/Html2\nDocProject/Help/html\n\n# Click-Once directory\npublish/\n\n# Publish Web Output\n*.[Pp]ublish.xml\n*.azurePubxml\n# Note: Comment the next line if you want to checkin your web deploy settings,\n# but database connection strings (with potential passwords) will be unencrypted\n*.pubxml\n*.publishproj\n\n# Microsoft Azure Web App publish settings. Comment the next line if you want to\n# checkin your Azure Web App publish settings, but sensitive information contained\n# in these scripts will be unencrypted\nPublishScripts/\n\n# NuGet Packages\n*.nupkg\n# NuGet Symbol Packages\n*.snupkg\n# The packages folder can be ignored because of Package Restore\n**/[Pp]ackages/*\n# except build/, which is used as an MSBuild target.\n!**/[Pp]ackages/build/\n# Uncomment if necessary however generally it will be regenerated when needed\n#!**/[Pp]ackages/repositories.config\n# NuGet v3's project.json files produces more ignorable files\n*.nuget.props\n*.nuget.targets\n\n# Microsoft Azure Build Output\ncsx/\n*.build.csdef\n\n# Microsoft Azure Emulator\necf/\nrcf/\n\n# Windows Store app package directories and files\nAppPackages/\nBundleArtifacts/\nPackage.StoreAssociation.xml\n_pkginfo.txt\n*.appx\n*.appxbundle\n*.appxupload\n\n# Visual Studio cache files\n# files ending in .cache can be ignored\n*.[Cc]ache\n# but keep track of directories ending in .cache\n!?*.[Cc]ache/\n\n# Others\nClientBin/\n~$*\n*~\n*.dbmdl\n*.dbproj.schemaview\n*.jfm\n*.pfx\n*.publishsettings\norleans.codegen.cs\n\n# Including strong name files can present a security risk\n# (https://github.com/github/gitignore/pull/2483#issue-259490424)\n#*.snk\n\n# Since there are multiple workflows, uncomment next line to ignore bower_components\n# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)\n#bower_components/\n\n# RIA/Silverlight projects\nGenerated_Code/\n\n# Backup & report files from converting an old project file\n# to a newer Visual Studio version. Backup files are not needed,\n# because we have git ;-)\n_UpgradeReport_Files/\nBackup*/\nUpgradeLog*.XML\nUpgradeLog*.htm\nServiceFabricBackup/\n*.rptproj.bak\n\n# SQL Server files\n*.mdf\n*.ldf\n*.ndf\n\n# Business Intelligence projects\n*.rdl.data\n*.bim.layout\n*.bim_*.settings\n*.rptproj.rsuser\n*- [Bb]ackup.rdl\n*- [Bb]ackup ([0-9]).rdl\n*- [Bb]ackup ([0-9][0-9]).rdl\n\n# Microsoft Fakes\nFakesAssemblies/\n\n# GhostDoc plugin setting file\n*.GhostDoc.xml\n\n# Node.js Tools for Visual Studio\n.ntvs_analysis.dat\nnode_modules/\n\n# Visual Studio 6 build log\n*.plg\n\n# Visual Studio 6 workspace options file\n*.opt\n\n# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)\n*.vbw\n\n# Visual Studio LightSwitch build output\n**/*.HTMLClient/GeneratedArtifacts\n**/*.DesktopClient/GeneratedArtifacts\n**/*.DesktopClient/ModelManifest.xml\n**/*.Server/GeneratedArtifacts\n**/*.Server/ModelManifest.xml\n_Pvt_Extensions\n\n# Paket dependency manager\n.paket/paket.exe\npaket-files/\n\n# FAKE - F# Make\n.fake/\n\n# CodeRush personal settings\n.cr/personal\n\n# Python Tools for Visual Studio (PTVS)\n__pycache__/\n*.pyc\n\n# Cake - Uncomment if you are using it\n# tools/**\n# !tools/packages.config\n\n# Tabs Studio\n*.tss\n\n# Telerik's JustMock configuration file\n*.jmconfig\n\n# BizTalk build output\n*.btp.cs\n*.btm.cs\n*.odx.cs\n*.xsd.cs\n\n# OpenCover UI analysis results\nOpenCover/\n\n# Azure Stream Analytics local run output\nASALocalRun/\n\n# MSBuild Binary and Structured Log\n*.binlog\n\n# NVidia Nsight GPU debugger configuration file\n*.nvuser\n\n# MFractors (Xamarin productivity tool) working folder\n.mfractor/\n\n# Local History for Visual Studio\n.localhistory/\n\n# BeatPulse healthcheck temp database\nhealthchecksdb\n\n# Backup folder for Package Reference Convert tool in Visual Studio 2017\nMigrationBackup/\n\n# Ionide (cross platform F# VS Code tools) working folder\n.ionide/\n\n# Fody - auto-generated XML schema\nFodyWeavers.xsd"
  },
  {
    "path": "ControlPanel/ControlPanel.cpp",
    "content": "#include \"ControlPanel.h\"\n\nControlPanel::ControlPanel(QWidget* parent)\n\t: QWidget(parent),\n\t//initialize strings\n\tprotectedServiceName(\"KernelHiddenExecute\"),\n\tprotectedServiceDisplayName(\"Kernel Hidden Execute\"),\n\t//protectedDriverPath(\".\\\\sys\\\\protected.sys\"),\n\tprotectedDeviceName(\"\\\\\\\\.\\\\KernelHiddenExecute\"),\n\tprotectedDriverControl(),\n\tmalwareServiceName(\"KernelHiddenExecuteMalware\"),\n\tmalwareServiceDisplayName(\"Kernel Hidden Execute Malware\"),\n\t//malwareDriverPath(\".\\\\sys\\\\malware.sys\"),\n\tmalwareDeviceName(\"\\\\\\\\.\\\\KernelHiddenExecuteMalware\"),\n\tmalwareDriverControl(),\n\t//initialize bool variables\n\tinitialized(false)\n\t//isSafeProcExecuted1(false),\n\t//isUnsafeProcExecuted1(false),\n\t//isAttacked(false),\n\t//isSafeProcExecuted2(false),\n\t//isUnsafeProcExecuted2(false)\n{\n\tui.setupUi(this);\n\n\t//initialize buttons connection\n\tconnect(ui.initBtn, &QPushButton::clicked, this, &ControlPanel::initialize);\n\tconnect(ui.attackBtn, &QPushButton::clicked, this, &ControlPanel::attack);\n\tconnect(ui.unsafeProcBtn, &QPushButton::clicked, this, &ControlPanel::normalProcedure);\n\tconnect(ui.safeProcBtn, &QPushButton::clicked, this, &ControlPanel::protectedProcedure);\n\n\t//fix relative path\n\tQDir protectedDriverDir(\"./sys/KernelHiddenExecute.sys\");\n\tprotectedDriverPath = protectedDriverDir.absolutePath().replace(QString(\"/\"), QString(\"\\\\\"));\n\n\tQDir malwareDriverDir(\"./sys/KernelHiddenExecuteMalware.sys\");\n\tmalwareDriverPath = malwareDriverDir.absolutePath().replace(QString(\"/\"), QString(\"\\\\\"));\n\n\t//add helper text\n\tui.helperTextBrowser->clear();\n\tui.helperTextBrowser->append(\"гʼ\");\n\tui.helperTextBrowser->append(\"·ʾʼ״̬\");\n}\n\nvoid ControlPanel::initialize()\n{\n\tqDebug() << \"initialize\";\n\tif (initialized)\n\t{\n\t\treturn;\n\t}\n\t//initialize service control manager\n\tui.outputTextBrowser->append(\"ʼʼSCM\");\n\tif (Services::init() == false)\n\t{\n\t\tui.outputTextBrowser->append(\"SCMʼʧ\");\n\t\treturn;\n\t}\n\tui.outputTextBrowser->append(\"SCMʼɹ\");\n\n\t//load protected driver\n\t//TODO:FIX ABSOLUTE PATH\n\tui.outputTextBrowser->append(\"ʼرĳ\");\n\tif (!loadDriver(protectedDriverPath, protectedServiceName, protectedServiceDisplayName))\n\t{\n\t\treturn;\n\t}\n\n\t//load malware driver\n\tui.outputTextBrowser->append(\"ʼض\");\n\tif (!loadDriver(malwareDriverPath, malwareServiceName, malwareServiceDisplayName))\n\t{\n\t\treturn;\n\t}\n\n\t//open drivers handle\n\tui.outputTextBrowser->append(\"ʼӵĳ\");\n\tif (!protectedDriverControl.open(protectedDeviceName))\n\t{\n\t\tui.outputTextBrowser->append(\"ʧ\");\n\t\treturn;\n\t}\n\tui.outputTextBrowser->append(\"򿪳ɹ\");\n\n\tui.outputTextBrowser->append(\"ʼӵ\");\n\tif (!malwareDriverControl.open(malwareDeviceName))\n\t{\n\t\tui.outputTextBrowser->append(\"ʧ\");\n\t\treturn;\n\t}\n\tui.outputTextBrowser->append(\"򿪳ɹ\");\n\n\tinitialized = true;\n\n\t//scroll to next page\n\tui.controlStackedWidget->setCurrentIndex(1);\n\n\t//add helper text\n\tui.helperTextBrowser->clear();\n\tui.helperTextBrowser->append(\"ʼɹ\");\n\tui.helperTextBrowser->append(\"ȵϷť۲ִȻٽйٴεϷťٴι۲ִ\");\n}\n\nvoid ControlPanel::attack()\n{\n\tqDebug() << \"attack\";\n\tif (!malwareDriverControl.attack())\n\t{\n\t\tui.outputTextBrowser->append(\"ʧ\");\n\t\treturn;\n\t}\n\tui.outputTextBrowser->append(\"ɹ\");\n}\n\nvoid ControlPanel::normalProcedure()\n{\n\tqDebug() << \"normalProcedure\";\n\tui.outputTextBrowser->append(\"ʼʾδܱĹ\");\n\tui.outputTextBrowser->append(QString(\"ȡݣ\") + protectedDriverControl.unsafeRead());\n\tui.outputTextBrowser->append(QString(\"ִеĽ\") + protectedDriverControl.unsafeExec());\n}\n\nvoid ControlPanel::protectedProcedure()\n{\n\tqDebug() << \"protectedProcedure\";\n\tui.outputTextBrowser->append(\"ʼʾܱĹ\");\n\tui.outputTextBrowser->append(QString(\"ȡݣ\") + protectedDriverControl.safeRead());\n\tui.outputTextBrowser->append(QString(\"ִеĽ\") + protectedDriverControl.safeExec());\n}\n\nvoid ControlPanel::closeEvent(QCloseEvent* event)\n{\n\tqDebug() << \"closeEvent\";\n\tif (QMessageBox::question(this, \"˳\", \"ȷҪ˳\", QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)\n\t{\n\t\t//unload drivers\n\t\tmalwareDriverControl.close();\n\t\tprotectedDriverControl.close();\n\t\tunloadDriver(malwareServiceName);\n\t\tunloadDriver(protectedServiceName);\n\n\t\t//ui.outputTextBrowser->append(\"ж\");\n\t\t//QThread::sleep(2);\n\n\n\t\t//uninitialize SCM\n\t\tServices::uninit();\n\n\t\tevent->accept();\n\t}\n\telse\n\t{\n\t\tevent->ignore();\n\t}\n\n}\n\nbool ControlPanel::loadDriver(QString driverPath, QString serviceName, QString serviceDisplayName)\n{\n\tunsigned long registrationResult = Services::Register(driverPath,\n\t\tserviceName,\n\t\tserviceDisplayName,\n\t\t\"Demand\",\n\t\t\"Normal\");\n\tswitch (registrationResult) {\n\tcase ERROR_SERVICE_EXISTS:\n\t\tui.outputTextBrowser->append(\"Service registration failed. The service already exists.\");\n\t\tbreak;\n\n\tcase 1:\n\t\tui.outputTextBrowser->append(\"Service registration failed. Empty or invalid parameters have been provided.\");\n\t\treturn false;\n\n\tcase 0:\n\t\tui.outputTextBrowser->append(\"Service registration succeeded.\");\n\t\tbreak;\n\n\tdefault:\n\t\tui.outputTextBrowser->append(QString(\"Service registration failed. Error code %1.\").arg(registrationResult));\n\t\treturn false;\n\t}\n\n\tunsigned long startResult = Services::Start(serviceName);\n\n\tswitch (startResult) {\n\tcase 1:\n\t\tui.outputTextBrowser->append(\"Starting service failed.\");\n\t\treturn false;\n\n\tcase ERROR_SHARING_VIOLATION:\n\t\tui.outputTextBrowser->append(\"The process cannot access the file because it is being used by another process.\");\n\t\treturn false;\n\n\tcase ERROR_SERVICE_DOES_NOT_EXIST:\n\t\tui.outputTextBrowser->append(\"The specified service does not exist as an installed service.\");\n\t\treturn false;\n\n\tcase ERROR_SERVICE_ALREADY_RUNNING:\n\t\tui.outputTextBrowser->append(\"An instance of the service is already running.\");\n\t\tbreak;\n\n\tcase 0:\n\t\tui.outputTextBrowser->append(\"Service started.\");\n\t\tbreak;\n\n\tdefault:\n\t\tui.outputTextBrowser->append(QString(\"Starting service failed. Error code %1.\").arg(startResult));\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\nbool ControlPanel::unloadDriver(QString serviceName)\n{\n\t//if (!initialized)\n\t//{\n\t//\treturn false;\n\t//}\n\n\tunsigned long stopResult = Services::Stop(serviceName);\n\n\tswitch (stopResult) {\n\tcase 1:\n\t\tui.outputTextBrowser->append(\"Stopping service failed.\");\n\t\tbreak;\n\n\tcase ERROR_SERVICE_NOT_ACTIVE:\n\t\tui.outputTextBrowser->append(\"The service has not been started.\");\n\t\tbreak;\n\n\tcase ERROR_SERVICE_DOES_NOT_EXIST:\n\t\tui.outputTextBrowser->append(\"The specified service does not exist as an installed service.\");\n\t\tbreak;\n\n\tcase 0:\n\t\tui.outputTextBrowser->append(\"Service stopped.\");\n\t\tbreak;\n\n\tdefault:\n\t\tui.outputTextBrowser->append(QString(\"Stopping service failed. Error code %1.\").arg(stopResult));\n\t\tbreak;\n\t}\n\n\tunsigned long unregistrationResult = Services::Unregister(serviceName);\n\tbool unregResult = false;\n\n\tswitch (unregistrationResult) {\n\tcase 1:\n\t\tui.outputTextBrowser->append(\"Service unregistration failed.\");\n\t\tunregResult = false;\n\t\tbreak;\n\n\tcase ERROR_SERVICE_DOES_NOT_EXIST:\n\t\tui.outputTextBrowser->append(\"The specified service does not exist as an installed service.\");\n\t\tunregResult = false;\n\t\tbreak;\n\n\tcase 0:\n\t\tui.outputTextBrowser->append(\"Service unregistration succeeded.\");\n\t\tunregResult = true;\n\t\tbreak;\n\n\tdefault:\n\t\tui.outputTextBrowser->append(QString(\"Service unregistration failed. Error code %1.\").arg(unregistrationResult));\n\t\tunregResult = false;\n\t\tbreak;\n\t}\n\t//initialized = false;\n\treturn unregResult;\n}\n"
  },
  {
    "path": "ControlPanel/ControlPanel.h",
    "content": "#pragma once\n#pragma execution_character_set(\"utf-8\")\n\n#include <QtWidgets/QWidget>\n#include <QPushButton>\n#include <QDebug>\n#include <QCloseEvent>\n#include <QMessageBox>\n#include <QDir>\n#include \"ui_ControlPanel.h\"\n#include \"dlcommon.h\"\n#include \"dlservices.h\"\n#include \"dldrivers.h\"\n#include \"dlioctl.h\"\n\nclass ControlPanel : public QWidget\n{\n\tQ_OBJECT\n\npublic:\n\tControlPanel(QWidget *parent = Q_NULLPTR);\n\npublic slots:\n\tvoid initialize();\n\tvoid attack();\n\tvoid normalProcedure();\n\tvoid protectedProcedure();\n\nprotected:\n\tvoid closeEvent(QCloseEvent * event);\nprivate:\n\tUi::ControlPanelClass ui;\n\tbool initialized;\n\t//bool isSafeProcExecuted1;\n\t//bool isUnsafeProcExecuted1;\n\t//bool isAttacked;\n\t//bool isSafeProcExecuted2;\n\t//bool isUnsafeProcExecuted2;\n\tQString protectedServiceName;\n\tQString protectedServiceDisplayName;\n\tQString protectedDriverPath;\n\tQString protectedDeviceName;\n\tProtectedDriverControl protectedDriverControl;\n\tQString malwareServiceName;\n\tQString malwareServiceDisplayName;\n\tQString malwareDriverPath;\n\tQString malwareDeviceName;\n\tMalwareDriverControl malwareDriverControl;\n\n\tbool loadDriver(QString driverPath, QString serviceName, QString serviceDisplayName);\n\tbool unloadDriver(QString serviceName);\n};\n"
  },
  {
    "path": "ControlPanel/ControlPanel.qrc",
    "content": "<RCC>\n    <qresource prefix=\"/\">\n        <file>resources/malware.png</file>\n        <file>resources/safeProcedure.png</file>\n        <file>resources/unsafeProcedure.png</file>\n        <file>resources/start.png</file>\n    </qresource>\n</RCC>\n"
  },
  {
    "path": "ControlPanel/ControlPanel.ui",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ui version=\"4.0\">\n <class>ControlPanelClass</class>\n <widget class=\"QWidget\" name=\"ControlPanelClass\">\n  <property name=\"geometry\">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>846</width>\n    <height>540</height>\n   </rect>\n  </property>\n  <property name=\"windowTitle\">\n   <string>ControlPanel</string>\n  </property>\n  <layout class=\"QVBoxLayout\" name=\"verticalLayout_3\">\n   <item>\n    <widget class=\"QWidget\" name=\"widget\" native=\"true\">\n     <layout class=\"QHBoxLayout\" name=\"horizontalLayout_3\">\n      <item>\n       <widget class=\"QStackedWidget\" name=\"controlStackedWidget\">\n        <property name=\"currentIndex\">\n         <number>0</number>\n        </property>\n        <widget class=\"QWidget\" name=\"loaderPage\">\n         <layout class=\"QHBoxLayout\" name=\"horizontalLayout\">\n          <item>\n           <spacer name=\"horizontalSpacer\">\n            <property name=\"orientation\">\n             <enum>Qt::Horizontal</enum>\n            </property>\n            <property name=\"sizeHint\" stdset=\"0\">\n             <size>\n              <width>40</width>\n              <height>20</height>\n             </size>\n            </property>\n           </spacer>\n          </item>\n          <item>\n           <widget class=\"QToolButton\" name=\"initBtn\">\n            <property name=\"text\">\n             <string>初始化</string>\n            </property>\n            <property name=\"icon\">\n             <iconset resource=\"ControlPanel.qrc\">\n              <normaloff>:/resources/start.png</normaloff>:/resources/start.png</iconset>\n            </property>\n            <property name=\"iconSize\">\n             <size>\n              <width>128</width>\n              <height>128</height>\n             </size>\n            </property>\n            <property name=\"toolButtonStyle\">\n             <enum>Qt::ToolButtonTextUnderIcon</enum>\n            </property>\n            <property name=\"autoRaise\">\n             <bool>true</bool>\n            </property>\n           </widget>\n          </item>\n          <item>\n           <spacer name=\"horizontalSpacer_2\">\n            <property name=\"orientation\">\n             <enum>Qt::Horizontal</enum>\n            </property>\n            <property name=\"sizeHint\" stdset=\"0\">\n             <size>\n              <width>40</width>\n              <height>20</height>\n             </size>\n            </property>\n           </spacer>\n          </item>\n         </layout>\n        </widget>\n        <widget class=\"QWidget\" name=\"procedurePage\">\n         <layout class=\"QVBoxLayout\" name=\"verticalLayout_4\">\n          <item>\n           <widget class=\"QWidget\" name=\"widget_2\" native=\"true\">\n            <layout class=\"QHBoxLayout\" name=\"horizontalLayout_2\">\n             <item>\n              <widget class=\"QToolButton\" name=\"unsafeProcBtn\">\n               <property name=\"text\">\n                <string>不安全的过程</string>\n               </property>\n               <property name=\"icon\">\n                <iconset resource=\"ControlPanel.qrc\">\n                 <normaloff>:/resources/unsafeProcedure.png</normaloff>:/resources/unsafeProcedure.png</iconset>\n               </property>\n               <property name=\"iconSize\">\n                <size>\n                 <width>72</width>\n                 <height>72</height>\n                </size>\n               </property>\n               <property name=\"toolButtonStyle\">\n                <enum>Qt::ToolButtonTextUnderIcon</enum>\n               </property>\n               <property name=\"autoRaise\">\n                <bool>true</bool>\n               </property>\n              </widget>\n             </item>\n             <item>\n              <widget class=\"QToolButton\" name=\"safeProcBtn\">\n               <property name=\"text\">\n                <string>安全的过程</string>\n               </property>\n               <property name=\"icon\">\n                <iconset resource=\"ControlPanel.qrc\">\n                 <normaloff>:/resources/safeProcedure.png</normaloff>:/resources/safeProcedure.png</iconset>\n               </property>\n               <property name=\"iconSize\">\n                <size>\n                 <width>72</width>\n                 <height>72</height>\n                </size>\n               </property>\n               <property name=\"toolButtonStyle\">\n                <enum>Qt::ToolButtonTextUnderIcon</enum>\n               </property>\n               <property name=\"autoRaise\">\n                <bool>true</bool>\n               </property>\n              </widget>\n             </item>\n            </layout>\n           </widget>\n          </item>\n          <item>\n           <widget class=\"QWidget\" name=\"widget_3\" native=\"true\">\n            <layout class=\"QHBoxLayout\" name=\"horizontalLayout_4\">\n             <item>\n              <widget class=\"QToolButton\" name=\"attackBtn\">\n               <property name=\"text\">\n                <string>开始攻击</string>\n               </property>\n               <property name=\"icon\">\n                <iconset resource=\"ControlPanel.qrc\">\n                 <normaloff>:/resources/malware.png</normaloff>:/resources/malware.png</iconset>\n               </property>\n               <property name=\"iconSize\">\n                <size>\n                 <width>72</width>\n                 <height>72</height>\n                </size>\n               </property>\n               <property name=\"toolButtonStyle\">\n                <enum>Qt::ToolButtonTextUnderIcon</enum>\n               </property>\n               <property name=\"autoRaise\">\n                <bool>true</bool>\n               </property>\n              </widget>\n             </item>\n            </layout>\n           </widget>\n          </item>\n         </layout>\n        </widget>\n       </widget>\n      </item>\n      <item>\n       <widget class=\"QWidget\" name=\"helperWidget\" native=\"true\">\n        <layout class=\"QVBoxLayout\" name=\"verticalLayout_2\">\n         <item>\n          <widget class=\"QLabel\" name=\"helperLabel\">\n           <property name=\"text\">\n            <string>帮助：</string>\n           </property>\n          </widget>\n         </item>\n         <item>\n          <widget class=\"QTextBrowser\" name=\"helperTextBrowser\"/>\n         </item>\n        </layout>\n       </widget>\n      </item>\n     </layout>\n    </widget>\n   </item>\n   <item>\n    <widget class=\"QWidget\" name=\"outputWidget\" native=\"true\">\n     <layout class=\"QVBoxLayout\" name=\"verticalLayout\">\n      <item>\n       <widget class=\"QLabel\" name=\"outputLabel\">\n        <property name=\"text\">\n         <string>状态输出：</string>\n        </property>\n       </widget>\n      </item>\n      <item>\n       <widget class=\"QTextBrowser\" name=\"outputTextBrowser\"/>\n      </item>\n     </layout>\n    </widget>\n   </item>\n  </layout>\n </widget>\n <layoutdefault spacing=\"6\" margin=\"11\"/>\n <resources>\n  <include location=\"ControlPanel.qrc\"/>\n </resources>\n <connections/>\n</ui>\n"
  },
  {
    "path": "ControlPanel/ControlPanel.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"16.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{2C7AEAC4-25F4-4C9D-842D-5C001D2BBA71}</ProjectGuid>\n    <Keyword>QtVS_v303</Keyword>\n    <WindowsTargetPlatformVersion Condition=\"'$(Configuration)|$(Platform)' == 'Debug|Win32'\">10.0.19041.0</WindowsTargetPlatformVersion>\n    <WindowsTargetPlatformVersion Condition=\"'$(Configuration)|$(Platform)' == 'Release|Win32'\">10.0.19041.0</WindowsTargetPlatformVersion>\n    <QtMsBuild Condition=\"'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\\qt.targets')\">$(MSBuildProjectDirectory)\\QtMsBuild</QtMsBuild>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>Application</ConfigurationType>\n    <PlatformToolset>v142</PlatformToolset>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>Application</ConfigurationType>\n    <PlatformToolset>v142</PlatformToolset>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <Target Name=\"QtMsBuildNotFound\" BeforeTargets=\"CustomBuild;ClCompile\" Condition=\"!Exists('$(QtMsBuild)\\qt.targets') or !Exists('$(QtMsBuild)\\qt.props')\">\n    <Message Importance=\"High\" Text=\"QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.\" />\n  </Target>\n  <ImportGroup Label=\"ExtensionSettings\" />\n  <ImportGroup Label=\"Shared\" />\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)' == 'Debug|Win32'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)' == 'Release|Win32'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt_defaults.props')\">\n    <Import Project=\"$(QtMsBuild)\\qt_defaults.props\" />\n  </ImportGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|Win32'\">\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|Win32'\">\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <Link>\n      <UACExecutionLevel>RequireAdministrator</UACExecutionLevel>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <Link>\n      <UACExecutionLevel>RequireAdministrator</UACExecutionLevel>\n    </Link>\n  </ItemDefinitionGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|Win32'\" Label=\"QtSettings\">\n    <QtInstall>msvc2017</QtInstall>\n    <QtModules>core;gui;widgets</QtModules>\n    <QtBuildConfig>debug</QtBuildConfig>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|Win32'\" Label=\"QtSettings\">\n    <QtInstall>msvc2017</QtInstall>\n    <QtModules>core;gui;widgets</QtModules>\n    <QtBuildConfig>release</QtBuildConfig>\n    <QMakeCodeLines>\n    </QMakeCodeLines>\n  </PropertyGroup>\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.props')\">\n    <Import Project=\"$(QtMsBuild)\\qt.props\" />\n  </ImportGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)' == 'Debug|Win32'\" Label=\"Configuration\">\n    <ClCompile>\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n      <Optimization>Disabled</Optimization>\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)' == 'Release|Win32'\" Label=\"Configuration\">\n    <ClCompile>\n      <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <DebugInformationFormat>None</DebugInformationFormat>\n      <Optimization>MaxSpeed</Optimization>\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <GenerateDebugInformation>false</GenerateDebugInformation>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <QtRcc Include=\"ControlPanel.qrc\" />\n    <QtUic Include=\"ControlPanel.ui\" />\n    <QtMoc Include=\"ControlPanel.h\" />\n    <ClCompile Include=\"ControlPanel.cpp\" />\n    <ClCompile Include=\"dlcommon.cpp\" />\n    <ClCompile Include=\"dlioctl.cpp\" />\n    <ClCompile Include=\"dlservices.cpp\" />\n    <ClCompile Include=\"main.cpp\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"dlcommon.h\" />\n    <ClInclude Include=\"dlconfig.h\" />\n    <ClInclude Include=\"dlioctl.h\" />\n    <ClInclude Include=\"dlservices.h\" />\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Condition=\"Exists('$(QtMsBuild)\\qt.targets')\">\n    <Import Project=\"$(QtMsBuild)\\qt.targets\" />\n  </ImportGroup>\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>"
  },
  {
    "path": "ControlPanel/ControlPanel.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\n    </Filter>\n    <Filter Include=\"Form Files\">\n      <UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>\n      <Extensions>ui</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}</UniqueIdentifier>\n      <Extensions>qrc;*</Extensions>\n      <ParseFiles>false</ParseFiles>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <QtRcc Include=\"ControlPanel.qrc\">\n      <Filter>Resource Files</Filter>\n    </QtRcc>\n    <QtUic Include=\"ControlPanel.ui\">\n      <Filter>Resource Files</Filter>\n    </QtUic>\n    <QtMoc Include=\"ControlPanel.h\">\n      <Filter>Header Files</Filter>\n    </QtMoc>\n    <ClCompile Include=\"ControlPanel.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"main.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"dlcommon.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"dlservices.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"dlioctl.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"dlcommon.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"dlservices.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"dlconfig.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"dlioctl.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "ControlPanel/dlcommon.cpp",
    "content": "/*\n    This file is part of driver-loader\n    Copyright (C) 2017 @maldevel\n\n    driver-loader - Load a Windows Kernel Driver.\n    https://github.com/maldevel/driver-loader\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n    For more see the file 'LICENSE' for copying permission.\n*/\n\n#include \"dlcommon.h\"\n#include <QDebug>\n\nstatic HANDLE processHeap;\n\n//retrieve a handle to the default heap of this process\nvoid Common::init(void) {\n    processHeap = GetProcessHeap();\n}\n\n//HeapAlloc wrapper\n//allocate a block of memory from a heap\nvoid *Common::hAlloc(SIZE_T size) {\n    if (processHeap == NULL || size <= 0) return NULL;\n\n    return HeapAlloc(processHeap, HEAP_ZERO_MEMORY, size);\n}\n\n//HeapReAlloc wrapper\nvoid *Common::hReAlloc(void *mem, SIZE_T size) {\n    if (processHeap == NULL || mem == NULL || size <= 0) return NULL;\n\n    return HeapReAlloc(processHeap, HEAP_ZERO_MEMORY, mem, size);\n}\n\n//free a memory block allocated from a heap by the HeapAlloc\nvoid Common::hFree(void *mem) {\n    if (processHeap == NULL || mem == NULL) return;\n\n    HeapFree(processHeap, 0, mem);\n    mem = NULL;\n}\n\nvoid Common::ConsoleLog(QString log) {\n    if (log == NULL) return;\n\n    if (DEBUG) {\n        qDebug() << log;\n    }\n}\n"
  },
  {
    "path": "ControlPanel/dlcommon.h",
    "content": "#pragma once\n\n/*\n    This file is part of driver-loader\n    Copyright (C) 2017 @maldevel\n\n    driver-loader - Load a Windows Kernel Driver.\n    https://github.com/maldevel/driver-loader\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n    For more see the file 'LICENSE' for copying permission.\n*/\n\n#include \"dlconfig.h\"\n\n#include <Windows.h>\n#include <QString>\n\n//#define TRUE 1\n//#define FALSE 0\n\nnamespace Common {\n    //initialize common lib stuff\n    void init(void);\n\n    //Allocates a block of memory from a heap.\n    void *hAlloc(SIZE_T size);\n\n    //Reallocates a block of memory from a heap.\n    void *hReAlloc(void *mem, SIZE_T size);\n\n    //free a memory block allocated from a heap by the hAlloc\n    void hFree(void *mem);\n\n    //console.log\n    void ConsoleLog(QString log);\n}\n"
  },
  {
    "path": "ControlPanel/dlconfig.h",
    "content": "#pragma once\n\n/*\n    This file is part of driver-loader\n    Copyright (C) 2017 @maldevel\n\n    driver-loader - Load a Windows Kernel Driver.\n    https://github.com/maldevel/driver-loader\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n    For more see the file 'LICENSE' for copying permission.\n*/\n\n//#define APP_VERSION \"1.0\"\n//#define APP_DATE    \"March, 2017\"\n#define DEBUG   1\n\n"
  },
  {
    "path": "ControlPanel/dldrivers.cpp",
    "content": "/*\n    This file is part of driver-loader\n    Copyright (C) 2017 @maldevel\n\n    driver-loader - Load a Windows Kernel Driver.\n    https://github.com/maldevel/driver-loader\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n    For more see the file 'LICENSE' for copying permission.\n*/\n\n#include \"dldrivers.h\"\n#include \"dlcommon.h\"\n#include <Windows.h>\n#include <Shlwapi.h>\n\nstatic BOOL _fileExists(const char *filename) {\n    if (filename == NULL)return FALSE;\n\n    return PathFileExistsA(filename);\n}\n\nQString Drivers::GetFileVersion(QString fName) {\n    if (fName == NULL || !_fileExists(fName.toStdString().c_str())) return \"\";\n\n    DWORD handle;\n    DWORD size = 0;\n    void *buffer = 0;\n    VS_FIXEDFILEINFO *lpBuffer = 0;\n    unsigned int len = 0;\n    QString fVersion = 0;\n\n    if ((size = GetFileVersionInfoSizeA(fName.toStdString().c_str(), &handle)) == FALSE) {\n        return \"\";\n    }\n\n    if ((buffer = Common::hAlloc(size)) == NULL) {\n        return \"\";\n    }\n\n    if (GetFileVersionInfoA(fName.toStdString().c_str(), handle, size, buffer) == FALSE) {\n        Common::hFree(buffer);\n        return \"\";\n    }\n\n    if (VerQueryValue(buffer, QString(\"\\\\\").toStdWString().c_str(), (void **)&lpBuffer, &len) == FALSE) {\n        Common::hFree(buffer);\n        return \"\";\n    }\n\n    fVersion = QString(\"%1.%2.%3.%4\")\n               .arg(HIWORD(lpBuffer->dwFileVersionMS))\n               .arg(LOWORD(lpBuffer->dwFileVersionMS))\n               .arg(HIWORD(lpBuffer->dwFileVersionLS))\n               .arg(LOWORD(lpBuffer->dwFileVersionLS));\n\n    Common::hFree(buffer);\n\n    return fVersion;\n}\n\nunsigned long Drivers::GetDriverFileSize(QString fName) {\n    if (fName == NULL || !_fileExists(fName.toStdString().c_str())) return 0;\n\n    HANDLE hFile;\n    unsigned long size = 0;\n    unsigned long sizeHigh = 0;\n\n    if ((hFile = CreateFileA(fName.toStdString().c_str(), GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) {\n        return 0;\n    }\n\n    if ((size = GetFileSize(hFile,  NULL)) == INVALID_FILE_SIZE) {\n        if (GetLastError() == NO_ERROR) {\n            if ((size = GetFileSize(hFile,  &sizeHigh)) != INVALID_FILE_SIZE) {\n                CloseHandle(hFile);\n                return sizeHigh;\n            }\n        }\n\n        CloseHandle(hFile);\n        return 0;\n    }\n\n    CloseHandle(hFile);\n\n    return size;\n}\n\nQString Drivers::GetFileLastWriteTime(QString fName) {\n    if (fName == NULL || !_fileExists(fName.toStdString().c_str())) return 0;\n\n    HANDLE hFile;\n    FILETIME ftCreate, ftAccess, ftWrite;\n    SYSTEMTIME stUTC, stLocal;\n    QString day = \"\";\n    QString month = \"\";\n\n    if ((hFile = CreateFileA(fName.toStdString().c_str(), GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) {\n        return \"\";\n    }\n\n    if (GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite) == 0) {\n        CloseHandle(hFile);\n        return \"\";\n    }\n\n    if (FileTimeToSystemTime(&ftWrite, &stUTC) == 0) {\n        CloseHandle(hFile);\n        return \"\";\n    }\n\n    if (SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal) == 0) {\n        CloseHandle(hFile);\n        return \"\";\n    }\n\n    switch (stLocal.wDayOfWeek) {\n        case 0:\n            day = \"Sunday\";\n            break;\n        case 1:\n            day = \"Monday\";\n            break;\n        case 2:\n            day = \"Tuesday\";\n            break;\n        case 3:\n            day = \"Wednesday\";\n            break;\n        case 4:\n            day = \"Thursday\";\n            break;\n        case 5:\n            day = \"Friday\";\n            break;\n        case 6:\n            day = \"Saturday\";\n            break;\n    };\n\n    switch (stLocal.wMonth) {\n        case 1:\n            month = \"January\";\n            break;\n        case 2:\n            month = \"February\";\n            break;\n        case 3:\n            month = \"March\";\n            break;\n        case 4:\n            month = \"April\";\n            break;\n        case 5:\n            month = \"May\";\n            break;\n        case 6:\n            month = \"June\";\n            break;\n        case 7:\n            month = \"July\";\n            break;\n        case 8:\n            month = \"August\";\n            break;\n        case 9:\n            month = \"September\";\n            break;\n        case 10:\n            month = \"October\";\n            break;\n        case 11:\n            month = \"November\";\n            break;\n        case 12:\n            month = \"December\";\n            break;\n    };\n\n    CloseHandle(hFile);\n\n    return QString(\"%1, %2 %3, %4 %5:%6:%7\")\n           .arg(day)\n           .arg(month)\n           .arg(stLocal.wDay)\n           .arg(stLocal.wYear)\n           .arg(stLocal.wHour)\n           .arg(stLocal.wMinute)\n           .arg(stLocal.wSecond);\n}\n"
  },
  {
    "path": "ControlPanel/dldrivers.h",
    "content": "#pragma once\n\n/*\n    This file is part of driver-loader\n    Copyright (C) 2017 @maldevel\n\n    driver-loader - Load a Windows Kernel Driver.\n    https://github.com/maldevel/driver-loader\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n    For more see the file 'LICENSE' for copying permission.\n*/\n\n#include <QString>\n\nnamespace Drivers {\n    //get driver file version\n    QString GetFileVersion(QString fName);\n\n    //get driver file size in bytes\n    unsigned long GetDriverFileSize(QString fName);\n\n    //get driver file last-write time\n    QString GetFileLastWriteTime(QString fName);\n}\n"
  },
  {
    "path": "ControlPanel/dlioctl.cpp",
    "content": "#include \"dlioctl.h\"\n\nProtectedDriverControl::ProtectedDriverControl()\n\t:hDevice(INVALID_HANDLE_VALUE)\n{\n}\n\nProtectedDriverControl::~ProtectedDriverControl()\n{\n\tclose();\n}\n\nbool ProtectedDriverControl::open(QString deviceName)\n{\n\thDevice = CreateFile(deviceName.toStdWString().c_str(),\n\t\tGENERIC_WRITE | GENERIC_READ,\n\t\t0,\n\t\tNULL,\n\t\tOPEN_EXISTING,\n\t\t0,\n\t\tNULL);\n\tif (hDevice == INVALID_HANDLE_VALUE)\n\t{\n\t\treturn false;\n\t}\n\treturn true;\n}\n\nvoid ProtectedDriverControl::close()\n{\n\tif (hDevice != INVALID_HANDLE_VALUE)\n\t{\n\t\tCloseHandle(hDevice);\n\t}\n\thDevice = INVALID_HANDLE_VALUE;\n}\n\nQString ProtectedDriverControl::safeRead()\n{\n\tif (hDevice == INVALID_HANDLE_VALUE)\n\t{\n\t\treturn QString(\"INVALID_HANDLE_VALUE\");\n\t}\n\n\tDWORD returnedBytes = 0;\n\tconst int bufferSize = 64;\n\tchar outputBuffer[bufferSize] = {};\n\n\tif (!DeviceIoControl(hDevice, IOCTL_SAFE_READ, NULL, 0, outputBuffer, bufferSize, &returnedBytes, 0))\n\t{\n\t\treturn QString(\"DeviceIoControl failed\");\n\t}\n\treturn QString(outputBuffer);\n}\n\nQString ProtectedDriverControl::safeExec()\n{\n\tif (hDevice == INVALID_HANDLE_VALUE)\n\t{\n\t\treturn QString(\"INVALID_HANDLE_VALUE\");\n\t}\n\n\tDWORD returnedBytes = 0;\n\tconst int bufferSize = 64;\n\tchar inputBuffer[bufferSize] = \"wrongPassword\";\n\tchar outputBuffer[bufferSize] = {};\n\n\n\tif (!DeviceIoControl(hDevice, IOCTL_SAFE_EXEC, inputBuffer, bufferSize, outputBuffer, bufferSize, &returnedBytes, 0))\n\t{\n\t\treturn QString(\"DeviceIoControl failed\");\n\t}\n\treturn QString(*(int*)outputBuffer ? \"verification success\" : \"verification failed\");\n}\n\nQString ProtectedDriverControl::unsafeRead()\n{\n\tif (hDevice == INVALID_HANDLE_VALUE)\n\t{\n\t\treturn QString(\"INVALID_HANDLE_VALUE\");\n\t}\n\n\tDWORD returnedBytes = 0;\n\tconst int bufferSize = 64;\n\tchar outputBuffer[bufferSize] = {};\n\n\tif (!DeviceIoControl(hDevice, IOCTL_UNSAFE_READ, NULL, 0, outputBuffer, bufferSize, &returnedBytes, 0))\n\t{\n\t\treturn QString(\"DeviceIoControl failed\");\n\t}\n\treturn QString(outputBuffer);\n}\n\nQString ProtectedDriverControl::unsafeExec()\n{\n\tif (hDevice == INVALID_HANDLE_VALUE)\n\t{\n\t\treturn QString(\"INVALID_HANDLE_VALUE\");\n\t}\n\n\tDWORD returnedBytes = 0;\n\tconst int bufferSize = 64;\n\tchar inputBuffer[bufferSize] = \"wrongPassword\";\n\tchar outputBuffer[bufferSize] = {};\n\n\n\tif (!DeviceIoControl(hDevice, IOCTL_UNSAFE_EXEC, inputBuffer, bufferSize, outputBuffer, bufferSize, &returnedBytes, 0))\n\t{\n\t\treturn QString(\"DeviceIoControl failed\");\n\t}\n\treturn QString(*(int*)outputBuffer ? \"verification success\" : \"verification failed\");\n}\n\nMalwareDriverControl::MalwareDriverControl()\n\t:hDevice(INVALID_HANDLE_VALUE)\n{\n}\n\nMalwareDriverControl::~MalwareDriverControl()\n{\n\tclose();\n}\n\nbool MalwareDriverControl::open(QString deviceName)\n{\n\thDevice = CreateFile(deviceName.toStdWString().c_str(),\n\t\tGENERIC_WRITE | GENERIC_READ,\n\t\t0,\n\t\tNULL,\n\t\tOPEN_EXISTING,\n\t\t0,\n\t\tNULL);\n\tif (hDevice == INVALID_HANDLE_VALUE)\n\t{\n\t\treturn false;\n\t}\n\treturn true;\n}\n\nvoid MalwareDriverControl::close()\n{\n\tif (hDevice != INVALID_HANDLE_VALUE)\n\t{\n\t\tCloseHandle(hDevice);\n\t}\n\thDevice = INVALID_HANDLE_VALUE;\n}\n\nbool MalwareDriverControl::attack()\n{\n\tif (hDevice == INVALID_HANDLE_VALUE)\n\t{\n\t\treturn false;\n\t}\n\n\tDWORD returnedBytes = 0;\n\tconst int bufferSize = 64;\n\tchar outputBuffer[bufferSize] = {};\n\n\tif (!DeviceIoControl(hDevice, IOCTL_ATTACK, NULL, 0, outputBuffer, bufferSize, &returnedBytes, 0))\n\t{\n\t\treturn false;\n\t}\n\treturn (bool)*(int*)outputBuffer;\n}\n"
  },
  {
    "path": "ControlPanel/dlioctl.h",
    "content": "#pragma once\n\n#include <Windows.h>\n#include <QString>\n\n#define IOCTL_SAFE_READ\tCTL_CODE(FILE_DEVICE_UNKNOWN, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)\n#define IOCTL_SAFE_EXEC\tCTL_CODE(FILE_DEVICE_UNKNOWN, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)\n#define IOCTL_UNSAFE_READ\tCTL_CODE(FILE_DEVICE_UNKNOWN, 0x802, METHOD_BUFFERED, FILE_ANY_ACCESS)\n#define IOCTL_UNSAFE_EXEC\tCTL_CODE(FILE_DEVICE_UNKNOWN, 0x803, METHOD_BUFFERED, FILE_ANY_ACCESS)\n\nclass ProtectedDriverControl\n{\npublic:\n\tProtectedDriverControl();\n\t~ProtectedDriverControl();\n\n\tbool open(QString deviceName);\n\tvoid close();\n\tQString safeRead();\n\tQString safeExec();\n\n\tQString unsafeRead();\n\tQString unsafeExec();\n\nprivate:\n\tHANDLE hDevice;\n};\n\n#define IOCTL_ATTACK\tCTL_CODE(FILE_DEVICE_UNKNOWN, 0x810, METHOD_BUFFERED, FILE_ANY_ACCESS)\n\nclass MalwareDriverControl\n{\npublic:\n\tMalwareDriverControl();\n\t~MalwareDriverControl();\n\n\tbool open(QString deviceName);\n\tvoid close();\n\tbool attack();\n\nprivate:\n\tHANDLE hDevice;\n};"
  },
  {
    "path": "ControlPanel/dlservices.cpp",
    "content": "/*\n    This file is part of driver-loader\n    Copyright (C) 2017 @maldevel\n\n    driver-loader - Load a Windows Kernel Driver.\n    https://github.com/maldevel/driver-loader\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n    For more see the file 'LICENSE' for copying permission.\n*/\n\n#include \"dlservices.h\"\n\nstatic SC_HANDLE scManager;\n\nbool Services::init(void) {\n    scManager = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_ALL_ACCESS);\n    if (scManager == NULL) {\n        return false;\n    }\n\n    return true;\n}\n\nSC_HANDLE Services::Open(QString service) {\n    if (service == NULL || scManager == NULL || service.trimmed().isEmpty() ||\n            service.trimmed().length() > 256) return NULL;\n\n    return OpenServiceA(scManager, service.toStdString().c_str(), SERVICE_ALL_ACCESS);\n}\n\nvoid Services::uninit(void) {\n    if (scManager == NULL) return;\n\n    CloseServiceHandle(scManager);\n}\n\nunsigned long Services::Register(QString driver, QString serviceName, QString displayName,\n                                 QString startTypeStr, QString error) {\n    if (driver == NULL || serviceName == NULL || scManager == NULL ||\n            displayName == NULL || startTypeStr == NULL || error == NULL ||\n            driver.trimmed().isEmpty() || serviceName.trimmed().isEmpty() ||\n            displayName.trimmed().isEmpty() || startTypeStr.trimmed().isEmpty() ||\n            error.trimmed().isEmpty() || serviceName.trimmed().length() > 256 ||\n            displayName.trimmed().length() > 256) return 1;\n\n    SC_HANDLE scService;\n    unsigned long startType = SERVICE_DEMAND_START;\n    unsigned long errorControl = SERVICE_ERROR_NORMAL;\n\n    //\"Automatic\" \"Boot\" \"Demand\" \"Disabled\" \"System\"\n    if (startTypeStr.trimmed().compare(\"Automatic\", Qt::CaseSensitive) == 0) {\n        startType = SERVICE_AUTO_START;\n    } else if (startTypeStr.trimmed().compare(\"Boot\", Qt::CaseSensitive) == 0) {\n        startType = SERVICE_BOOT_START;\n    } else if (startTypeStr.trimmed().compare(\"Demand\", Qt::CaseSensitive) == 0) {\n        startType = SERVICE_DEMAND_START;\n    } else if (startTypeStr.trimmed().compare(\"Disabled\", Qt::CaseSensitive) == 0) {\n        startType = SERVICE_DISABLED;\n    } else if (startTypeStr.trimmed().compare(\"System\", Qt::CaseSensitive) == 0) {\n        startType = SERVICE_SYSTEM_START;\n    }\n\n    //\"Critical\" \"Ignore\" \"Normal\" \"Severe\"\n    if (error.trimmed().compare(\"Critical\", Qt::CaseSensitive) == 0) {\n        errorControl = SERVICE_ERROR_CRITICAL;\n    } else if (error.trimmed().compare(\"Ignore\", Qt::CaseSensitive) == 0) {\n        errorControl = SERVICE_ERROR_IGNORE;\n    } else if (error.trimmed().compare(\"Normal\", Qt::CaseSensitive) == 0) {\n        errorControl = SERVICE_ERROR_NORMAL;\n    } else if (error.trimmed().compare(\"Severe\", Qt::CaseSensitive) == 0) {\n        errorControl = SERVICE_ERROR_SEVERE;\n    }\n\n    if ((scService = CreateServiceA(scManager, serviceName.trimmed().toStdString().c_str(),\n                                    displayName.trimmed().toStdString().c_str(),\n                                    SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER,\n                                    startType, errorControl,\n                                    driver.trimmed().toStdString().c_str(),\n                                    NULL, NULL, NULL, NULL, NULL)) == NULL) {\n        return GetLastError();\n    }\n\n    CloseServiceHandle(scService);\n\n    return 0;\n}\n\nunsigned long Services::Unregister(QString service) {\n    if (service == NULL || scManager == NULL || service.trimmed().isEmpty() ||\n            service.trimmed().length() > 256) return 1;\n\n    SC_HANDLE srvHandle;\n    unsigned long error = 0;\n\n    if ((srvHandle = Open(service)) == NULL) {\n        return GetLastError();\n    }\n\n    if ((error = Stop(srvHandle)) != 0) {\n        if (error != ERROR_SERVICE_NOT_ACTIVE) {\n            CloseServiceHandle(srvHandle);\n            return error;\n        }\n    }\n\n    if (DeleteService(srvHandle) == 0) {\n        CloseServiceHandle(srvHandle);\n        return GetLastError();\n    }\n\n    CloseServiceHandle(srvHandle);\n\n    return 0;\n}\n\nunsigned long Services::Start(SC_HANDLE service) {\n    if (service == NULL || scManager == NULL) return 1;\n\n    if (StartService(service, 0, NULL) == 0) {\n        return GetLastError();\n    }\n\n    return 0;\n}\n\nunsigned long Services::Start(QString service) {\n    if (service == NULL || scManager == NULL || service.trimmed().isEmpty() ||\n            service.trimmed().length() > 256) return 1;\n\n    unsigned long error = 0;\n\n    SC_HANDLE srvHandle;\n\n    if ((srvHandle = Open(service)) == NULL) {\n        return GetLastError();\n    }\n\n    if ((error = Start(srvHandle)) != 0) {\n        CloseServiceHandle(srvHandle);\n        return error;\n    }\n\n    CloseServiceHandle(srvHandle);\n\n    return 0;\n}\n\nunsigned long Services::Stop(SC_HANDLE service) {\n    if (service == NULL || scManager == NULL) return 1;\n\n    SERVICE_STATUS serviceStatus;\n\n    if (ControlService(service, SERVICE_CONTROL_STOP, &serviceStatus) == 0) {\n        return GetLastError();\n    }\n\n    return 0;\n}\n\nunsigned long Services::Stop(QString service) {\n    if (service == NULL || scManager == NULL || service.trimmed().isEmpty() ||\n            service.trimmed().length() > 256) return 1;\n\n    SC_HANDLE srvHandle;\n    unsigned long error = 0;\n\n    if ((srvHandle = Open(service)) == NULL) {\n        return GetLastError();\n    }\n\n    if ((error = Stop(srvHandle)) != 0) {\n        CloseServiceHandle(srvHandle);\n        return error;\n    }\n\n    CloseServiceHandle(srvHandle);\n    return 0;\n}\n"
  },
  {
    "path": "ControlPanel/dlservices.h",
    "content": "#pragma once\n\n/*\n    This file is part of driver-loader\n    Copyright (C) 2017 @maldevel\n\n    driver-loader - Load a Windows Kernel Driver.\n    https://github.com/maldevel/driver-loader\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n    For more see the file 'LICENSE' for copying permission.\n*/\n\n#include <Windows.h>\n#include <QString>\n\nnamespace Services {\n    //initialize services lib stuff\n    bool init(void);\n\n    //un-initialize services lib stuff\n    void uninit(void);\n\n    //register a new service (install)\n    unsigned long Register(QString driver, QString serviceName, QString displayName, QString startType, QString error);\n\n    //unregister a service (uninstall)\n    unsigned long Unregister(QString service);\n\n    //start a service\n    unsigned long Start(SC_HANDLE service);\n\n    //start a service\n    unsigned long Start(QString service);\n\n    //stop a service\n    unsigned long Stop(SC_HANDLE service);\n\n    //stop a service\n    unsigned long Stop(QString service);\n\n    //open handle to service\n    SC_HANDLE Open(QString service);\n}\n\n"
  },
  {
    "path": "ControlPanel/main.cpp",
    "content": "#include \"ControlPanel.h\"\n#include <QtWidgets/QApplication>\n#include <regex>\n#include <string>\nusing namespace std;\n\nint execmd(char* cmd, char* result) {\n\tchar buffer[128];                         //建                        \n\tFILE* pipe = _popen(cmd, \"r\");            //򿪹ִܵ \n\tif (!pipe)\n\t\treturn 0;                      //0ʾʧ \n\n\twhile (!feof(pipe)) {\n\t\tif (fgets(buffer, 128, pipe)) {             //ܵresult \n\t\t\tstrcat(result, buffer);\n\t\t}\n\t}\n\t_pclose(pipe);                            //رչܵ \n\treturn 1;                                 //1ʾгɹ \n}\n\nint main(int argc, char *argv[])\n{\n    QApplication a(argc, argv);\n\n\tchar buffer[128];\n\texecmd(\"VER\", buffer);\n\tstring tempStr = string(buffer);\n\tsmatch subFormulaMatch;\n\tregex pattern(R\"(\\d+\\.\\d+\\.(\\d+))\");\n\tregex_search(tempStr, subFormulaMatch, pattern);\n\tif (subFormulaMatch.size()==2&&stoi(subFormulaMatch[1].str()) > 7601)\n\t{\n\t\tQMessageBox::critical(nullptr, \"ش\", \"ֵ֧ϵͳ汾\");\n\t\treturn 0;\n\t}\n\n    ControlPanel w;\n    w.show();\n    return a.exec();\n}\n"
  },
  {
    "path": "KernelHiddenExcute/Head.h",
    "content": "#pragma once\n\n#include <ntifs.h>\n#include <ntddk.h>\n#include <stdlib.h>\n#include <windef.h>\n#include <ntimage.h>\n#include <intrin.h>\n\n#include \"MyDebugPrint.h\"\n#include \"PhysicalMemoryOperation.h\"\n#include \"SectionOperation.h\"\n#include \"HiddenExecute.h\"\n#include \"HiddenCallApiTransfer.h\"\n#include \"HiddenFunctions.h\"\n\n\n#define\tDEVICE_NAME\tL\"\\\\Device\\\\KernelHiddenExcute\"\n#define LINK_NAME\tL\"\\\\DosDevices\\\\Global\\\\KernelHiddenExcute\"\n\n#define IOCTL_TEST\tCTL_CODE(FILE_DEVICE_UNKNOWN, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS) \n\nPHIDDEN_PAGE_RECORD g_pHiddenPageRecord = NULL;"
  },
  {
    "path": "KernelHiddenExcute/HiddenCallApiTransfer.h",
    "content": "#pragma once\n#include \"Head.h\"\n\n/*********************************************************\nfunction:\t\tSimulateApi\ndescription:\n**********************************************************/\nNTSTATUS SimulateApi(ULONG64 param1)\n{\n\tMyPrint(_TitleAndFunc\"param1:%16IX\\n\", param1);\n\treturn STATUS_SUCCESS;\n}\n\n/*********************************************************\nfunction:\t\tApiTransfer_SimulateApi\ndescription:\ttest of call apis in the hidden apis\n**********************************************************/\n\nNTSTATUS ApiTransfer_SimulateApi(PHIDDEN_PAGE_RECORD pHiddenPageRecord, ULONG64 param1)\n{\n\t//BOOL\t\tIsIrqlChanged = FALSE;\n\tNTSTATUS\tStatus;\n\n\t/*\n\tif (HighestIrql < HIDDEN_IRQL)\n\t{\n\tChangeIrql(HighestIrql);\n\tIsIrqlChanged = TRUE;\n\t}\n\t*/\n\n\tContextHiddenToOriginal(pHiddenPageRecord);\n\n\tStatus = SimulateApi(param1);\n\n\tContextOriginalToHidden(pHiddenPageRecord);\n\n\t/*\n\tif (IsIrqlChanged)\n\tChangeIrql(HIDDEN_IRQL);\n\t*/\n\n\treturn Status;\n}"
  },
  {
    "path": "KernelHiddenExcute/HiddenExecute.h",
    "content": "#pragma once\n#include \"Head.h\"\n\n/*********************************************************\ndescription:\nnotice!!!\trun in IRQL >= DPC_LEVEL\n\t\t\tcall apis maybe due to lower irql\n\nin order to hidden real code in the non-mapped physical pages,and clear original codes\nbefore call the hidden functions,we should map the physical pages to correct position.\nif we have to call windows api in our hidden functions,we should call the transfer functions(not hidden)\n\nfeatures of transfer functions:check & change irql,restore & rewrite page table(pte),call specific apis\n\nreserve the physical pages by Api:MmMarkPhysicalMemoryAsBad,prevent the allocation of our physical pages space\n\n**********************************************************/\n\n#define SECTION_NAME_HIDDEN\t\t\t\".hidden\"\n\n#define HIDDEN_IRQL\t\t\t\t\tDISPATCH_LEVEL\n#define ChangeIrql(x)\t\t\t\tWriteCR8(x)\n#define ClearPageTableFlag(x)\t\tClearCR3Flag(x)\n#define HIDDEN_PAGE_RECORD_LENGTH\t0x1000\n#define MAX_HIDDEN_PAGE_COUNT\t\t126\t\t\t\t\t//      (4096 - 40) / (4 * 8) = 126.75\n\ntypedef struct _MMPTE\n{\n\tstruct /* bitfield */\n\t{\n\t\t/* 0x0000 */ unsigned __int64 Valid : 1; /* bit position: 0 */\n\t\t/* 0x0000 */ unsigned __int64 Dirty1 : 1; /* bit position: 1 */\n\t\t/* 0x0000 */ unsigned __int64 Owner : 1; /* bit position: 2 */\n\t\t/* 0x0000 */ unsigned __int64 WriteThrough : 1; /* bit position: 3 */\n\t\t/* 0x0000 */ unsigned __int64 CacheDisable : 1; /* bit position: 4 */\n\t\t/* 0x0000 */ unsigned __int64 Accessed : 1; /* bit position: 5 */\n\t\t/* 0x0000 */ unsigned __int64 Dirty : 1; /* bit position: 6 */\n\t\t/* 0x0000 */ unsigned __int64 LargePage : 1; /* bit position: 7 */\n\t\t/* 0x0000 */ unsigned __int64 Global : 1; /* bit position: 8 */\n\t\t/* 0x0000 */ unsigned __int64 CopyOnWrite : 1; /* bit position: 9 */\n\t\t/* 0x0000 */ unsigned __int64 Unused : 1; /* bit position: 10 */\n\t\t/* 0x0000 */ unsigned __int64 Write : 1; /* bit position: 11 */\n\t\t/* 0x0000 */ unsigned __int64 PageFrameNumber : 36; /* bit position: 12 */\n\t\t/* 0x0000 */ unsigned __int64 reserved1 : 4; /* bit position: 48 */\n\t\t/* 0x0000 */ unsigned __int64 SoftwareWsIndex : 11; /* bit position: 52 */\n\t\t/* 0x0000 */ unsigned __int64 NoExecute : 1; /* bit position: 63 */\n\t}; /* bitfield */\n} MMPTE, *PMMPTE; /* size: 0x0008 */\n\ntypedef struct _SPECIFIC_HIDDEN_PAGE_RECORD\n{\n\tPVOID\t\tpHiddenBase;\n\tPMMPTE\t\tpPTE;\n\tULONG64\t\tOriginalPfn;\n\tULONG64\t\tHiddenPfn;\n}SPECIFIC_HIDDEN_PAGE_RECORD, *PSPECIFIC_HIDDEN_PAGE_RECORD;\n\ntypedef struct _HIDDEN_PAGE_RECORD\n{\n\tBOOL\t\t\t\t\t\t\tIsHidden;\n\tKIRQL\t\t\t\t\t\t\tOriginalIrql;\n\tBOOL\t\t\t\t\t\t\tIsIrqlChanged;\n\tKSPIN_LOCK\t\t\t\t\t\tSpinLock;\n\tULONG64\t\t\t\t\t\t\tCount;\n\tSPECIFIC_HIDDEN_PAGE_RECORD\t\tRecord[MAX_HIDDEN_PAGE_COUNT - 1];\n}HIDDEN_PAGE_RECORD, *PHIDDEN_PAGE_RECORD;\n\n\n\nPHYSICAL_OP_CR3\t\t\tg_PhysicalOpCR3 = { 0 };\nBOOL\t\t\t\t\tg_IsHiddenOpInit = FALSE;\n\nNTSYSAPI NTSTATUS MmMarkPhysicalMemoryAsBad(IN PPHYSICAL_ADDRESS, IN OUT PLARGE_INTEGER);\nNTSYSAPI NTSTATUS MmMarkPhysicalMemoryAsGood(IN PPHYSICAL_ADDRESS, IN OUT PLARGE_INTEGER);\n\n/*********************************************************\nfunction:\t\tInitializeHiddenPageRecordStructure\ndescription:\tinitialize the structure:initialize spin lock & set count to zero\ncalls:\t\t\tExAllocatePool\n\t\t\t\tKeInitializeSpinLock\n\t\t\t\tCreatePhysicalOpCR3BySystemCR3\n**********************************************************/\nNTSTATUS InitializeHiddenPageRecordStructure(PHIDDEN_PAGE_RECORD* ppHiddenPageRecord)\n{\n\t//check the init state\n\tif (g_IsHiddenOpInit)\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\tPHIDDEN_PAGE_RECORD pHiddenPageRecord = NULL;\n\tpHiddenPageRecord = (PHIDDEN_PAGE_RECORD)ExAllocatePool(NonPagedPool, HIDDEN_PAGE_RECORD_LENGTH);\n\t*ppHiddenPageRecord = pHiddenPageRecord;\n\n\tMyPrint(_TitleAndFunc\"pHiddenPageRecord:%16IX\\n\", pHiddenPageRecord);\n\tif (pHiddenPageRecord != NULL)\n\t{\n\t\t//set count to zero\n\t\tpHiddenPageRecord->Count = 0;\n\t\t//initialize spin lock\n\t\tKeInitializeSpinLock(&pHiddenPageRecord->SpinLock);\n\n\t\t//initialize physical memory context\n\t\tCreatePhysicalOpCR3BySystemCR3(GetCR3ByPID(4), &g_PhysicalOpCR3);\n\n\t\t//change init state\n\t\tg_IsHiddenOpInit = TRUE;\n\n\t\treturn STATUS_SUCCESS;\n\t}\n\telse {\n\t\treturn STATUS_UNSUCCESSFUL;\n\t}\n}\n\n/*********************************************************\nfunction:\t\tFreeHiddenPageRecordStructure\ndescription:\tfree the structure and set pHiddenPageRecord to zero\ncalls:\t\t\tExFreePool\n**********************************************************/\nNTSTATUS FreeHiddenPageRecordStructure(PHIDDEN_PAGE_RECORD pHiddenPageRecord)\n{\n\t//check the init state\n\tif (!g_IsHiddenOpInit)\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\tif (pHiddenPageRecord != NULL)\n\t{\n\t\t//free hidden operation structure\n\t\tExFreePool(pHiddenPageRecord);\n\t\tpHiddenPageRecord = NULL;\n\n\t\t//free physical operation structure\n\t\tFreePhysicalOpCR3(&g_PhysicalOpCR3);\n\n\t\t//change the init state\n\t\tg_IsHiddenOpInit = FALSE;\n\n\t\treturn STATUS_SUCCESS;\n\t}\n\telse {\n\t\treturn STATUS_UNSUCCESSFUL;\n\t}\n}\n\n/*********************************************************\nfunction:\t\tpPTEPFNtoPhysicalAddress\ndescription:\ttranslate pfn number to physical address\n**********************************************************/\nPVOID pPTEPFNtoPhysicalAddress(ULONG64 PFN)\n{\n\treturn (PVOID)(PFN << 12);\n}\n\n/*********************************************************\nfunction:\t\tpPhysicalAddresstoPTEPFN\ndescription:\ttranslate physical address to pfn number\n**********************************************************/\nULONG64 pPhysicalAddresstoPTEPFN(PVOID PhysicalAddressBase)\n{\n\treturn (ULONG64)PhysicalAddressBase >> 12;\n}\n\n/*********************************************************\nfunction:\t\tpGetSpecificAddresspPTEPhysical\ndescription:\tget the pointer of pPTEPhysical\ncalls:\t\t\tContextVirtualToPhysical\nClearPageTableFlag\nContextPhysicalToVirtual\n**********************************************************/\nPMMPTE pGetSpecificAddresspPTEPhysical(ULONG64 CR3, PVOID pPageBase)\n{\n\t//analyse the params\n\tPMMVA\t\tpAddressInfo = (PMMVA)&pPageBase;\n\tPVOID\t\tpPML4T = (PVOID)ClearCR3Flag(CR3);\n\tPMMPTE\t\tpPML4E = NULL;\n\tPVOID\t\tpPDPT = NULL;\n\tPMMPTE\t\tpPDPTE = NULL;\n\tPVOID\t\tpPDT = NULL;\n\tPMMPTE\t\tpPDE = NULL;\n\tPVOID\t\tpPT = NULL;\n\tPMMPTE\t\tpPTE = NULL;\n\n\t//switch to physical context\n\tContextVirtualToPhysical(&g_PhysicalOpCR3);\n\n\tpPML4E = (PMMPTE)((ULONG64)pPML4T + pAddressInfo->PML4T*ENTRY_SIZE);\n\tif (!pPML4E->Valid)\n\t\tgoto Lable_Error;\n\tpPDPT = (PVOID)ClearPageTableFlag(*(PULONG64)pPML4E);\n\n\tpPDPTE = (PMMPTE)((ULONG64)pPDPT + pAddressInfo->PDPT*ENTRY_SIZE);\n\tif (pPDPTE->LargePage || !pPDPTE->Valid)\n\t\tgoto Lable_Error;\n\tpPDT = (PVOID)ClearPageTableFlag(*(PULONG64)pPDPTE);\n\n\tpPDE = (PMMPTE)((ULONG64)pPDT + pAddressInfo->PDT*ENTRY_SIZE);\n\tif (pPDE->LargePage || !pPDE->Valid)\n\t\tgoto Lable_Error;\n\tpPT = (PVOID)ClearPageTableFlag(*(PULONG64)pPDE);\n\n\tpPTE = (PMMPTE)((ULONG64)pPT + pAddressInfo->PT*ENTRY_SIZE);\n\tif (!pPTE->Valid)\n\t\tgoto Lable_Error;\n\n\tContextPhysicalToVirtual(&g_PhysicalOpCR3);\n\t//look up the page table finished\n\tMyPrint(_TitleAndFunc\"pPTE:%16IX\\n\", pPTE);\n\treturn pPTE;\n\nLable_Error:\n\tContextPhysicalToVirtual(&g_PhysicalOpCR3);\n\treturn NULL;\n}\n\n/*********************************************************\nfunction:\t\tpGetSpecificAddressPhysicalForR3\ndescription:\tjust for E language\n**********************************************************/\n#define PHYSICAL_OFFSET\t0x8000000000\n#define NUM_1G\t\t\t0x40000000\n#define NUM_2M\t\t\t0x200000\nPVOID pGetSpecificAddressPhysicalForR3(ULONG64 CR3, PVOID pVirtual)\n{\n\t//analyse the params\n\tPMMVA\t\tpAddressInfo = (PMMVA)&pVirtual;\n\tPVOID\t\tpPML4T = (PVOID)ClearCR3Flag(CR3);\n\tPMMPTE\t\tpPML4E = NULL;\n\tPVOID\t\tpPDPT = NULL;\n\tPMMPTE\t\tpPDPTE = NULL;\n\tPVOID\t\tpPDT = NULL;\n\tPMMPTE\t\tpPDE = NULL;\n\tPVOID\t\tpPT = NULL;\n\tPMMPTE\t\tpPTE = NULL;\n\tPVOID\t\tpPhysicalBase = NULL;\n\tPVOID\t\tpPhysical = NULL;\n\tPVOID\t\tpPhysicalR3 = NULL;\n\n\tpPML4E = (PMMPTE)((ULONG64)pPML4T + pAddressInfo->PML4T*ENTRY_SIZE + PHYSICAL_OFFSET);\n\tif (!pPML4E->Valid)\n\t\treturn NULL;\n\tpPDPT = (PVOID)ClearPageTableFlag(*(PULONG64)pPML4E);\n\n\tpPDPTE = (PMMPTE)((ULONG64)pPDPT + pAddressInfo->PDPT*ENTRY_SIZE + PHYSICAL_OFFSET);\n\tif (!pPDPTE->Valid)\n\t\treturn NULL;\n\tif (pPDPTE->LargePage)\n\t\tgoto Lable_PDPTE_LargePage;\n\tpPDT = (PVOID)ClearPageTableFlag(*(PULONG64)pPDPTE);\n\n\tpPDE = (PMMPTE)((ULONG64)pPDT + pAddressInfo->PDT*ENTRY_SIZE + PHYSICAL_OFFSET);\n\tif (!pPDE->Valid)\n\t\treturn NULL;\n\tif (pPDE->LargePage)\n\t\tgoto Lable_PDE_LargePage;\n\tpPT = (PVOID)ClearPageTableFlag(*(PULONG64)pPDE);\n\n\tpPTE = (PMMPTE)((ULONG64)pPT + pAddressInfo->PT*ENTRY_SIZE + PHYSICAL_OFFSET);\n\tif (!pPTE->Valid)\n\t\treturn NULL;\n\tpPhysicalBase = (PVOID)ClearPageTableFlag(*(PULONG64)pPTE);\n\n\tpPhysical = (PVOID)((ULONG64)pPhysicalBase + pAddressInfo->Offset);\n\tpPhysicalR3 = (PVOID)((ULONG64)pPhysical + PHYSICAL_OFFSET);\n\treturn pPhysicalR3;\n\nLable_PDPTE_LargePage:\n\tpPhysicalBase = (PVOID)(((PMMPDPTE)pPDPTE)->PageFrameNumber*NUM_1G);\n\tpPhysical = (PVOID)((ULONG64)pPhysicalBase + ((PMMVA_PDPTE_LARGE)pAddressInfo)->Offset);\n\tpPhysicalR3 = (PVOID)((ULONG64)pPhysical + PHYSICAL_OFFSET);\n\treturn pPhysicalR3;\n\nLable_PDE_LargePage:\n\tpPhysicalBase = (PVOID)(((PMMPDE)pPDE)->PageFrameNumber*NUM_2M);\n\tpPhysical = (PVOID)((ULONG64)pPhysicalBase + ((PMMVA_PDE_LARGE)pAddressInfo)->Offset);\n\tpPhysicalR3 = (PVOID)((ULONG64)pPhysical + PHYSICAL_OFFSET);\n\treturn pPhysicalR3;\n}\n/*********************************************************\nfunction:\t\tAddHiddenPageRecord\ndescription:\tadd a record element to the structure\n\t\t\t\tinclude get pte physical address of the specific page and record the pfn\n\t\t\t\treserve a physical page by api:MmAllocateNonCachedMemory and MmMarkPhysicalMemoryAsBad\n\t\t\t\tthen free the page\n\ncalls:\t\t\tKeAcquireSpinLock\n\t\t\t\tpGetSpecificAddresspPTEPhysical\n\t\t\t\tContextVirtualToPhysical\n\t\t\t\tContextPhysicalToVirtual\n\t\t\t\tMmAllocateNonCachedMemory\n\t\t\t\tMmGetPhysicalAddress\n\t\t\t\tpPhysicalAddresstoPTEPFN\n\t\t\t\tMmFreeNonCachedMemory\n\t\t\t\tMmMarkPhysicalMemoryAsBad\n\t\t\t\tKeReleaseSpinLock\n**********************************************************/\nNTSTATUS AddHiddenPageRecord(ULONG64 CR3, PVOID pHiddenPageBase, PHIDDEN_PAGE_RECORD pHiddenPageRecord)\n{\n\tKIRQL\t\tEntryIrql;\n\tNTSTATUS\tStatus = STATUS_UNSUCCESSFUL;\n\t//prevent mulit-thread change the page record count\n\tKeAcquireSpinLock(&pHiddenPageRecord->SpinLock, &EntryIrql);\n\n\t//check count\n\tMyPrint(_TitleAndFunc\"pHiddenPageRecord->Count:%16IX\\n\", pHiddenPageRecord->Count);\n\tif (pHiddenPageRecord->Count == MAX_HIDDEN_PAGE_COUNT)\n\t\tgoto Lable_Error;\n\n\t//add pPTE record\n\tPSPECIFIC_HIDDEN_PAGE_RECORD\tpCurrentRecord = &pHiddenPageRecord->Record[pHiddenPageRecord->Count];\n\n\tpCurrentRecord->pPTE = pGetSpecificAddresspPTEPhysical(CR3, pHiddenPageBase);\n\tMyPrint(_TitleAndFunc\"pCurrentRecord->pPTE:%16IX\\n\", pCurrentRecord->pPTE);\n\tif (pCurrentRecord->pPTE == NULL)\n\t\tgoto Lable_Error;\n\t\n\t//add hidden virtual address record\n\tpCurrentRecord->pHiddenBase = pHiddenPageBase;\n\tMyPrint(_TitleAndFunc\"pCurrentRecord->pHiddenBase:%16IX\\n\", pCurrentRecord->pHiddenBase);\n\n\t//add original pfn record\n\tContextVirtualToPhysical(&g_PhysicalOpCR3);\n\tpCurrentRecord->OriginalPfn = pCurrentRecord->pPTE->PageFrameNumber;\n\tContextPhysicalToVirtual(&g_PhysicalOpCR3);\n\n\tMyPrint(_TitleAndFunc\"pCurrentRecord->OriginalPfn:%16IX\\n\", pCurrentRecord->OriginalPfn);\n\n\t//add hidden pfn record \n\t//allocate memory\n\t//record the physical address\n\t//then free the memory and mark it as bad\n\tPVOID\tTemporaryVirtual = MmAllocateNonCachedMemory(PAGE_SIZE);\n\tif (TemporaryVirtual == NULL)\n\t\tgoto Lable_Error;\n\n\tPHYSICAL_ADDRESS\tTemporaryPhysical = MmGetPhysicalAddress(TemporaryVirtual);\n\tLARGE_INTEGER\t\tPhysicalLength = { 0 };\n\tPhysicalLength.QuadPart = PAGE_SIZE;\n\n\tpCurrentRecord->HiddenPfn = pPhysicalAddresstoPTEPFN((PVOID)(TemporaryPhysical.QuadPart));\n\tMyPrint(_TitleAndFunc\"pCurrentRecord->HiddenPfn:%16IX\\n\", pCurrentRecord->HiddenPfn);\n\n\tMmFreeNonCachedMemory(TemporaryVirtual, PAGE_SIZE);\n\t\n\tStatus = MmMarkPhysicalMemoryAsBad(&TemporaryPhysical, &PhysicalLength);\n\n\t//copy codes to the new non-mapped physical address\n\tContextVirtualToPhysical(&g_PhysicalOpCR3);\n\tRtlCopyMemory((PVOID)(TemporaryPhysical.QuadPart),\n\t\tpCurrentRecord->pHiddenBase,\n\t\tPAGE_SIZE\n\t);\n\tContextPhysicalToVirtual(&g_PhysicalOpCR3);\n\n\t//check the mark state\n\tif (!NT_SUCCESS(Status))\n\t\tgoto Lable_Error;\n\n\t//the last step:count +1\n\tpHiddenPageRecord->Count++;\n\n\t//release spin lock\n\tKeReleaseSpinLock(&pHiddenPageRecord->SpinLock, EntryIrql);\n\treturn STATUS_SUCCESS;\n\nLable_Error:\n\tKeReleaseSpinLock(&pHiddenPageRecord->SpinLock, EntryIrql);\n\treturn STATUS_UNSUCCESSFUL;\n}\n\n/*********************************************************\nfunction:\t\tRemoveAndRestoreAllHiddenPageRecord\ndescription:\tremove and restore all the records of the structure\n\t\t\t\tinclude mark hidden physical memory as good,\n\t\t\t\tchange mapping relations,\n\t\t\t\tand invalid the specific TLB\n\ncalls:\t\t\tKeAcquireSpinLock\n\t\t\t\tpPTEPFNtoPhysicalAddress\n\t\t\t\tMmMarkPhysicalMemoryAsGood\n\t\t\t\tContextVirtualToPhysical\n\t\t\t\tContextPhysicalToVirtual\n\t\t\t\t__invlpg\n\t\t\t\tKeReleaseSpinLock\n**********************************************************/\nNTSTATUS RemoveAndRestoreAllHiddenPageRecord(PHIDDEN_PAGE_RECORD pHiddenPageRecord)\n{\n\tKIRQL\t\tEntryIrql;\n\tNTSTATUS\tStatus = STATUS_UNSUCCESSFUL;\n\t//prevent mulit-thread change the page record count\n\tKeAcquireSpinLock(&pHiddenPageRecord->SpinLock, &EntryIrql);\n\n\t//assert we have elements\n\tif (pHiddenPageRecord->Count == 0)\n\t\tgoto Lable_Error;\n\n\t//restore all records and mark all the hidden physical memory as good\n\tPSPECIFIC_HIDDEN_PAGE_RECORD\tpCurrentRecord = NULL;\n\tPHYSICAL_ADDRESS\t\t\t\tCurrentHiddenPhysical = { 0 };\n\tLARGE_INTEGER\t\t\t\t\tPhysicalLength = { 0 };\n\n\tPhysicalLength.QuadPart = PAGE_SIZE;\n\n\tfor (int i = 0; i < pHiddenPageRecord->Count; i++)\n\t{\n\t\tpCurrentRecord = &pHiddenPageRecord->Record[i];\n\t\tCurrentHiddenPhysical.QuadPart = (ULONG64)pPTEPFNtoPhysicalAddress(pCurrentRecord->HiddenPfn);\n\n\t\t//mark it as good\n\t\tMmMarkPhysicalMemoryAsGood(&CurrentHiddenPhysical, &PhysicalLength);\n\n\t\t//restore all page mapping relations\n\t\tContextVirtualToPhysical(&g_PhysicalOpCR3);\n\t\tpCurrentRecord->pPTE->PageFrameNumber = pCurrentRecord->OriginalPfn;\n\t\tContextPhysicalToVirtual(&g_PhysicalOpCR3);\n\n\t\t//invalid the TLB of current hidden address\n\t\t__invlpg(pCurrentRecord->pHiddenBase);\n\t}\n\n\t//set count to zero\n\tpHiddenPageRecord->Count = 0;\n\n\t//release spin lock\n\tKeReleaseSpinLock(&pHiddenPageRecord->SpinLock, EntryIrql);\n\treturn STATUS_SUCCESS;\n\nLable_Error:\n\tKeReleaseSpinLock(&pHiddenPageRecord->SpinLock, EntryIrql);\n\treturn STATUS_UNSUCCESSFUL;\n}\n\n/*********************************************************\nfunction:\t\tContextOriginalToHidden\ndescription:\tswitch to hidden code,so that we can call our hidden functions\n\ncalls:\t\t\tKeGetCurrentIrql\n\t\t\t\tKeRaiseIrqlToDpcLevel\n\t\t\t\t_disable\n\t\t\t\tKeAcquireSpinLock\n\t\t\t\tContextVirtualToPhysical\n\t\t\t\tContextPhysicalToVirtual\n\t\t\t\t__invlpg\n\t\t\t\tKeReleaseSpinLock\n**********************************************************/\nNTSTATUS ContextOriginalToHidden(PHIDDEN_PAGE_RECORD pHiddenPageRecord)\n{\n\tKIRQL\t\tEntryIrql;\n\tNTSTATUS\tStatus = STATUS_UNSUCCESSFUL;\n\n\t//record original irql\n\tpHiddenPageRecord->OriginalIrql = KeGetCurrentIrql();\n\tMyPrint(_TitleAndFunc\"pHiddenPageRecord->OriginalIrql:%16IX\\n\", pHiddenPageRecord->OriginalIrql);\n\n\t//assert irql >= dispatch level\n\tif (pHiddenPageRecord->OriginalIrql < DISPATCH_LEVEL)\n\t{\n\t\tpHiddenPageRecord->IsIrqlChanged = TRUE;\n\t\tKeRaiseIrqlToDpcLevel();\n\t}\n\n\t//disable task switch interrupt(maskable)\n\t_disable();\n\n\t//prevent mulit-thread change the page record count\n\tKeAcquireSpinLock(&pHiddenPageRecord->SpinLock, &EntryIrql);\n\n\t//assert we have elements\n\tif (pHiddenPageRecord->Count == 0)\n\t\tgoto Lable_Error;\n\n\t//check the initialize state and current hidden state\n\tif (!g_IsHiddenOpInit || pHiddenPageRecord->IsHidden)\n\t\tgoto Lable_Error;\n\n\t//restore all records and mark all the hidden physical memory as good\n\tPSPECIFIC_HIDDEN_PAGE_RECORD\tpCurrentRecord = NULL;\n\n\tfor (int i = 0; i < pHiddenPageRecord->Count; i++)\n\t{\n\t\tpCurrentRecord = &pHiddenPageRecord->Record[i];\n\n\t\t//change all page mapping relations\n\t\tContextVirtualToPhysical(&g_PhysicalOpCR3);\n\t\tpCurrentRecord->pPTE->PageFrameNumber = pCurrentRecord->HiddenPfn;\n\t\tContextPhysicalToVirtual(&g_PhysicalOpCR3);\n\n\t\t//invalid the TLB of current hidden address\n\t\t__invlpg(pCurrentRecord->pHiddenBase);\n\t}\n\n\tKeReleaseSpinLock(&pHiddenPageRecord->SpinLock, EntryIrql);\n\n\t//change the flag IsHidden\n\tpHiddenPageRecord->IsHidden = TRUE;\n\treturn STATUS_SUCCESS;\n\nLable_Error:\n\tKeReleaseSpinLock(&pHiddenPageRecord->SpinLock, EntryIrql);\n\treturn STATUS_UNSUCCESSFUL;\n}\n\n/*********************************************************\nfunction:\t\tContextOriginalToHidden\ndescription:\tswitch to hidden code,so that we can call our hidden functions\n\ncalls:\t\t\tKeAcquireSpinLock\n\t\t\t\tContextVirtualToPhysical\n\t\t\t\tContextPhysicalToVirtual\n\t\t\t\t__invlpg\n\t\t\t\tKeReleaseSpinLock\n\t\t\t\t_enable\n\t\t\t\tKeLowerIrql\n**********************************************************/\nNTSTATUS ContextHiddenToOriginal(PHIDDEN_PAGE_RECORD pHiddenPageRecord)\n{\n\tKIRQL\t\tEntryIrql;\n\tNTSTATUS\tStatus = STATUS_UNSUCCESSFUL;\n\n\t//prevent mulit-thread change the page record count\n\tKeAcquireSpinLock(&pHiddenPageRecord->SpinLock, &EntryIrql);\n\n\t//assert we have elements\n\tif (pHiddenPageRecord->Count == 0)\n\t\tgoto Lable_Error;\n\n\t//check the initialize state and current hidden state\n\tif (!g_IsHiddenOpInit || !pHiddenPageRecord->IsHidden)\n\t\tgoto Lable_Error;\n\n\t//restore all records and mark all the hidden physical memory as good\n\tPSPECIFIC_HIDDEN_PAGE_RECORD\tpCurrentRecord = NULL;\n\n\tfor (int i = 0; i < pHiddenPageRecord->Count; i++)\n\t{\n\t\tpCurrentRecord = &pHiddenPageRecord->Record[i];\n\n\t\t//change all page mapping relations\n\t\tContextVirtualToPhysical(&g_PhysicalOpCR3);\n\t\tpCurrentRecord->pPTE->PageFrameNumber = pCurrentRecord->OriginalPfn;\n\t\tContextPhysicalToVirtual(&g_PhysicalOpCR3);\n\n\t\t//invalid the TLB of current hidden address\n\t\t__invlpg(pCurrentRecord->pHiddenBase);\n\t}\n\n\tKeReleaseSpinLock(&pHiddenPageRecord->SpinLock, EntryIrql);\n\n\t//enable task switch interrupt(maskable)\n\t_enable();\n\n\t//restore irql\n\tMyPrint(_TitleAndFunc\"pHiddenPageRecord->IsIrqlChanged:%16IX\\n\", pHiddenPageRecord->IsIrqlChanged);\n\tif (pHiddenPageRecord->IsIrqlChanged)\n\t{\n\t\tKeLowerIrql(pHiddenPageRecord->OriginalIrql);\n\n\t\t//restore the flag IsIrqlChanged\n\t\tpHiddenPageRecord->IsIrqlChanged = FALSE;\n\t}\n\n\t//change the flag IsHidden\n\tpHiddenPageRecord->IsHidden = FALSE;\n\treturn STATUS_SUCCESS;\n\nLable_Error:\n\tKeReleaseSpinLock(&pHiddenPageRecord->SpinLock, EntryIrql);\n\treturn STATUS_UNSUCCESSFUL;\n}\n\n/*********************************************************\nfunction:\t\tGetPagesCountByLength\ndescription:\tget pages count by length\t\n**********************************************************/\nULONG64 GetPagesCountByLength(ULONG64 Length)\n{\n\tif ((Length & 0xFFF) == 0)\n\t\treturn (Length >> 12);\n\telse\n\t\treturn (Length >> 12) + 1;\n}\n\n/*********************************************************\nfunction:\t\tAddHiddenSection\ndescription:\tadd hidden address by the offered section name\n\t\t\t\tif all the calls of AddHiddenPageRecord are successful,return STATUS_SUCCESS\ncalls:\t\t\tGetSegmentStartAddress\n\t\t\t\tGetSegmentLength\n\t\t\t\tGetPagesCountByLength\n\t\t\t\tAddHiddenPageRecord\n**********************************************************/\nNTSTATUS AddHiddenSection(ULONG64 SystemCR3, PDRIVER_OBJECT pDriverObj, PCHAR pSegName, PHIDDEN_PAGE_RECORD pHiddenPageRecord)\n{\n\t//analyse number of pages of the section \n\tPVOID\t\tpSectionStart = (PVOID)GetSegmentStartAddress(pDriverObj, pSegName);\n\tULONG64\t\tSectionLength = GetSegmentLength(pDriverObj, pSegName);\n\tULONG64\t\tPagesCount = GetPagesCountByLength(SectionLength);\n\tPVOID\t\tpCurrentPage = NULL;\n\tNTSTATUS\tStatus = STATUS_UNSUCCESSFUL;\n\n\tMyPrint(_TitleAndFunc\"pSectionStart:%16IX\\n\", pSectionStart);\n\tMyPrint(_TitleAndFunc\"SectionLength:%16IX\\n\", SectionLength);\n\tMyPrint(_TitleAndFunc\"PagesCount:%16IX\\n\", PagesCount);\n\n\t//call AddHiddenPageRecord to record the hidden info\n\tfor (int i = 0; i < PagesCount; i++)\n\t{\n\t\tpCurrentPage = (PVOID)((ULONG64)pSectionStart + i*PAGE_SIZE);\n\t\tStatus = AddHiddenPageRecord(SystemCR3, pCurrentPage, pHiddenPageRecord);\n\n\t\t//make sure all the records are successful\n\t\tif (!NT_SUCCESS(Status))\n\t\t\treturn Status;\n\t}\n\n\treturn STATUS_SUCCESS;\n}\n\n\n"
  },
  {
    "path": "KernelHiddenExcute/HiddenFunctions.h",
    "content": "#pragma once\n#include \"Head.h\"\n\n#pragma code_seg(SECTION_NAME_HIDDEN)\n\nNTSTATUS HiddenFunctionA(PHIDDEN_PAGE_RECORD pHiddenPageRecord)\n{\n\tNTSTATUS Status = STATUS_UNSUCCESSFUL;\n\n\tStatus = ApiTransfer_SimulateApi(pHiddenPageRecord, 0xFAFAFAFAFAFAFAFA);\n\n\treturn Status;\n}\n\n#pragma code_seg()"
  },
  {
    "path": "KernelHiddenExcute/KernelHiddenExcute.inf",
    "content": ";\n; KernelHiddenExcute.inf\n;\n\n[Version]\nSignature=\"$WINDOWS NT$\"\nClass=System\nClassGuid={4d36e97d-e325-11ce-bfc1-08002be10318}\nProvider=XYLab\nDriverVer=\nCatalogFile=KernelHiddenExcute.inf.cat\n\n;[DestinationDirs]\n;DefaultDestDir = 12\n\n\n;[SourceDisksNames]\n;1 = %DiskName%,,,\"\"\n\n;[SourceDisksFiles]\n\n\n;[Manufacturer]\n;%ManufacturerName%=Standard,NT$ARCH$\n\n;[Standard.NT$ARCH$]\n\n\n[Strings]\nManufacturerName=\"XYLab\"\nClassName=\"\"\nDiskName=\"KernelHiddenExcute Source Disk\"\n"
  },
  {
    "path": "KernelHiddenExcute/KernelHiddenExcute.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"12.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|ARM\">\n      <Configuration>Debug</Configuration>\n      <Platform>ARM</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|ARM\">\n      <Configuration>Release</Configuration>\n      <Platform>ARM</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|ARM64\">\n      <Configuration>Debug</Configuration>\n      <Platform>ARM64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|ARM64\">\n      <Configuration>Release</Configuration>\n      <Platform>ARM64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{B6DD98D0-0343-41DD-94FC-542035EE9B88}</ProjectGuid>\n    <TemplateGuid>{dd38f7fc-d7bd-488b-9242-7d8754cde80d}</TemplateGuid>\n    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\n    <MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>\n    <Configuration>Debug</Configuration>\n    <Platform Condition=\"'$(Platform)' == ''\">Win32</Platform>\n    <RootNamespace>KernelHiddenExcute</RootNamespace>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\n    <TargetVersion>Windows7</TargetVersion>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n    <DriverTargetPlatform>Desktop</DriverTargetPlatform>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\n    <TargetVersion>Windows7</TargetVersion>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n    <DriverTargetPlatform>Desktop</DriverTargetPlatform>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM64'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM64'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n    <EnableInf2cat>false</EnableInf2cat>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n    <EnableInf2cat>false</EnableInf2cat>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM64'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM64'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <ClCompile>\n      <WarningLevel>Level3</WarningLevel>\n    </ClCompile>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <ClCompile>\n      <WarningLevel>Level3</WarningLevel>\n    </ClCompile>\n    <Link>\n      <OptimizeReferences>false</OptimizeReferences>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <Inf Include=\"KernelHiddenExcute.inf\" />\n  </ItemGroup>\n  <ItemGroup>\n    <FilesToPackage Include=\"$(TargetPath)\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"main.c\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"Head.h\" />\n    <ClInclude Include=\"HiddenCallApiTransfer.h\" />\n    <ClInclude Include=\"HiddenExecute.h\" />\n    <ClInclude Include=\"HiddenFunctions.h\" />\n    <ClInclude Include=\"MyDebugPrint.h\" />\n    <ClInclude Include=\"PhysicalMemoryOperation.h\" />\n    <ClInclude Include=\"SectionOperation.h\" />\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>"
  },
  {
    "path": "KernelHiddenExcute/KernelHiddenExcute.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\n    </Filter>\n    <Filter Include=\"Driver Files\">\n      <UniqueIdentifier>{8E41214B-6785-4CFE-B992-037D68949A14}</UniqueIdentifier>\n      <Extensions>inf;inv;inx;mof;mc;</Extensions>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <Inf Include=\"KernelHiddenExcute.inf\">\n      <Filter>Driver Files</Filter>\n    </Inf>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"main.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"Head.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"MyDebugPrint.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"PhysicalMemoryOperation.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"HiddenExecute.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"HiddenCallApiTransfer.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"SectionOperation.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"HiddenFunctions.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "KernelHiddenExcute/MyDebugPrint.h",
    "content": "#pragma once\n\n#include \"Head.h\"\n\n\n\n#define _DBG_PRINT\n#define PRINT_NAME \"XYLab\"\n\n\n#define _Title \"[\"##PRINT_NAME##\"] \"\n#define _Func \"[\"##__FUNCTION__##\"] \"\n#define _TitleAndFunc \"[\"##PRINT_NAME##\"] \"##\"[\"##__FUNCTION__##\"] \" \n\n#ifdef _DBG_PRINT\n//#define MyPrint(_x_) DbgPrint _x_\n#define MyPrint(...) DbgPrint(__VA_ARGS__)\n#else\n//#define MyPrint(_x_)\n#define MyPrint(...)\n#endif\n"
  },
  {
    "path": "KernelHiddenExcute/PhysicalMemoryOperation.h",
    "content": "#pragma once\n#include \"Head.h\"\n\nBOOL\tg_IsPhysicalOpInit = FALSE;\nHANDLE\tg_SectionHandle = NULL;\n\n#define\tPAGE_TABLE_SIZE\t\t\t0x1000\n#define\tCR3_FLAG_ALL_BITS\t\t\t0xFFF0000000000FFF\n#define\tPAGE_TABLE_PML4T_FLAG\t0x867\t//1000 0110 0111\n#define\tPAGE_TABLE_PDPT_FLAG\t0x9E7\t//1001 1110 0111\n#define VA_SYSTEM_START\t\t\t0xFFFF080000000000 //IA64\n#define MAX_ENTRY_COUNT\t\t\t512\n#define ENTRY_SIZE\t\t\t\tsizeof(ULONG64)\n\ntypedef struct _PHYSICAL_OP_CR3\n{\n\tPVOID\tpAllocVA_PML4T;\n\tPVOID\tpAllocPA_PML4T;\n\n\tPVOID\tpAllocVA_PDPT;\n\tPVOID\tpAllocPA_PDPT;\n\n\tPVOID\tpSystemPML4TMap;\n\n\tULONG64\tCR3Generated;\n\tULONG64 CR3System;\n\n\tULONG64 CR3BeforeSwitch;\n\tBOOL\tIsContextSwitched;\n\tBOOL\tIsIrqlChanged;\n\tKIRQL\tOriginalIrql;//available if the IsIrqlChanged is true\n}PHYSICAL_OP_CR3, *PPHYSICAL_OP_CR3;\n\n\n\ntypedef struct _MMPDPTE\n{\n\tstruct /* bitfield */\n\t{\n\t\t/* 0x0000 */ unsigned __int64 Valid : 1; /* bit position: 0 */\n\t\t/* 0x0000 */ unsigned __int64 Dirty1 : 1; /* bit position: 1 */\n\t\t/* 0x0000 */ unsigned __int64 Owner : 1; /* bit position: 2 */\n\t\t/* 0x0000 */ unsigned __int64 WriteThrough : 1; /* bit position: 3 */\n\t\t/* 0x0000 */ unsigned __int64 CacheDisable : 1; /* bit position: 4 */\n\t\t/* 0x0000 */ unsigned __int64 Accessed : 1; /* bit position: 5 */\n\t\t/* 0x0000 */ unsigned __int64 Dirty : 1; /* bit position: 6 */\n\t\t/* 0x0000 */ unsigned __int64 LargePage : 1; /* bit position: 7 */\n\t\t/* 0x0000 */ unsigned __int64 Global : 1; /* bit position: 8 */\n\t\t/* 0x0000 */ unsigned __int64 CopyOnWrite : 1; /* bit position: 9 */\n\t\t/* 0x0000 */ unsigned __int64 Unused : 1; /* bit position: 10 */\n\t\t/* 0x0000 */ unsigned __int64 Write : 1; /* bit position: 11 */\n\t\t/* 0x0000 */ unsigned __int64 reserved0 : 18; /* bit position: 12 */\n\t\t/* 0x0000 */ unsigned __int64 PageFrameNumber : 18; /* bit position: 30 */\n\t\t/* 0x0000 */ unsigned __int64 reserved1 : 4; /* bit position: 48 */\n\t\t/* 0x0000 */ unsigned __int64 SoftwareWsIndex : 11; /* bit position: 52 */\n\t\t/* 0x0000 */ unsigned __int64 NoExecute : 1; /* bit position: 63 */\n\t}; /* bitfield */\n} MMPDPTE, *PMMPDPTE; /* size: 0x0008 */\n\ntypedef struct _MMPDE\n{\n\tstruct /* bitfield */\n\t{\n\t\t/* 0x0000 */ unsigned __int64 Valid : 1; /* bit position: 0 */\n\t\t/* 0x0000 */ unsigned __int64 Dirty1 : 1; /* bit position: 1 */\n\t\t/* 0x0000 */ unsigned __int64 Owner : 1; /* bit position: 2 */\n\t\t/* 0x0000 */ unsigned __int64 WriteThrough : 1; /* bit position: 3 */\n\t\t/* 0x0000 */ unsigned __int64 CacheDisable : 1; /* bit position: 4 */\n\t\t/* 0x0000 */ unsigned __int64 Accessed : 1; /* bit position: 5 */\n\t\t/* 0x0000 */ unsigned __int64 Dirty : 1; /* bit position: 6 */\n\t\t/* 0x0000 */ unsigned __int64 LargePage : 1; /* bit position: 7 */\n\t\t/* 0x0000 */ unsigned __int64 Global : 1; /* bit position: 8 */\n\t\t/* 0x0000 */ unsigned __int64 CopyOnWrite : 1; /* bit position: 9 */\n\t\t/* 0x0000 */ unsigned __int64 Unused : 1; /* bit position: 10 */\n\t\t/* 0x0000 */ unsigned __int64 Write : 1; /* bit position: 11 */\n\t\t/* 0x0000 */ unsigned __int64 reserved0 : 9; /* bit position: 12 */\n\t\t/* 0x0000 */ unsigned __int64 PageFrameNumber : 27; /* bit position: 21 */\n\t\t/* 0x0000 */ unsigned __int64 reserved1 : 4; /* bit position: 48 */\n\t\t/* 0x0000 */ unsigned __int64 SoftwareWsIndex : 11; /* bit position: 52 */\n\t\t/* 0x0000 */ unsigned __int64 NoExecute : 1; /* bit position: 63 */\n\t}; /* bitfield */\n} MMPDE, *PMMPDE; /* size: 0x0008 */\n\ntypedef struct _MMVA\n{\n\tstruct /* bitfield */\n\t{\n\t\t/* 0x0000 */ unsigned __int64 Offset : 12;\n\t\t/* 0x0000 */ unsigned __int64 PT : 9;\n\t\t/* 0x0000 */ unsigned __int64 PDT : 9;\n\t\t/* 0x0000 */ unsigned __int64 PDPT : 9;\n\t\t/* 0x0000 */ unsigned __int64 PML4T : 9;\n\t\t/* 0x0000 */ unsigned __int64 Partition : 16; //User:0x0000 System:0xFFFF\n\t}; /* bitfield */\n} MMVA, *PMMVA; /* size: 0x0008 */\n\ntypedef struct _MMVA_PDPTE_LARGE\n{\n\tstruct /* bitfield */\n\t{\n\t\t/* 0x0000 */ unsigned __int64 Offset : 30;\n\t\t/* 0x0000 */ unsigned __int64 PDPT : 9;\n\t\t/* 0x0000 */ unsigned __int64 PML4T : 9;\n\t\t/* 0x0000 */ unsigned __int64 Partition : 16; //User:0x0000 System:0xFFFF\n\t}; /* bitfield */\n} MMVA_PDPTE_LARGE, *PMMVA_PDPTE_LARGE; /* size: 0x0008 */\n\ntypedef struct _MMVA_PDE_LARGE\n{\n\tstruct /* bitfield */\n\t{\n\t\t/* 0x0000 */ unsigned __int64 Offset : 21;\n\t\t/* 0x0000 */ unsigned __int64 PDT : 9;\n\t\t/* 0x0000 */ unsigned __int64 PDPT : 9;\n\t\t/* 0x0000 */ unsigned __int64 PML4T : 9;\n\t\t/* 0x0000 */ unsigned __int64 Partition : 16; //User:0x0000 System:0xFFFF\n\t}; /* bitfield */\n} MMVA_PDE_LARGE, *PMMVA_PDE_LARGE; /* size: 0x0008 */\n\n/*********************************************************\nfunction:\t\tOpenPhysicalMemory\n\t\t\t\tpMapPhysicalMemoryPre\n\t\t\t\tMapPhysicalMemory\n\t\t\t\tUnmapPhysicalMemory\ndescription:\tuse map view of section to map physical address to virtual address\n**********************************************************/\nHANDLE OpenPhysicalMemory()\n{\n\tUNICODE_STRING\t\tphysmemString;\n\tOBJECT_ATTRIBUTES\tattributes;\n\tWCHAR\t\t\t\tphysmemName[] = L\"\\\\device\\\\physicalmemory\";\n\tNTSTATUS\t\t\tstatus;\n\tHANDLE\t\t\t\tphysmem;\n\tRtlInitUnicodeString(&physmemString, physmemName);\n\tInitializeObjectAttributes(&attributes, &physmemString, OBJ_CASE_INSENSITIVE, NULL, NULL);\n\tstatus = ZwOpenSection(&physmem, SECTION_ALL_ACCESS, &attributes);\n\tif (!NT_SUCCESS(status))\n\t{\n\t\treturn NULL;\n\t}\n\treturn physmem;\n}\nBOOLEAN pMapPhysicalMemoryPre(HANDLE hMemory, PDWORD64 pDwAddress, PSIZE_T pSize, PDWORD64 pDwVirtualAddress)\n{\n\tNTSTATUS ntStatus;\n\n\tLARGE_INTEGER viewBase;\n\t*pDwVirtualAddress = 0;\n\tviewBase.QuadPart = *pDwAddress;\n\tntStatus = ZwMapViewOfSection(hMemory, (HANDLE)-1, (void**)pDwVirtualAddress, 0L, *pSize, &viewBase, pSize, ViewShare, 0, PAGE_READWRITE | PAGE_NOCACHE);\n\tif (!NT_SUCCESS(ntStatus))\n\t\treturn FALSE;\n\t//*pDwAddress = viewBase.QuadPart;\n\treturn TRUE;\n}\nPVOID MapPhysicalMemory(PVOID PA, SIZE_T Size)\n{\n\tULONGLONG DwAddress = (ULONG64)PA;\n\tULONGLONG DwVirtualAddress = 0;\n\tBOOLEAN status = pMapPhysicalMemoryPre(g_SectionHandle, &DwAddress, &Size, &DwVirtualAddress);\n\treturn (status == TRUE) ? (PVOID)DwVirtualAddress : NULL;\n}\nBOOLEAN UnmapPhysicalMemory(PVOID VA)\n{\n\tif (!ZwUnmapViewOfSection((HANDLE)-1, VA))\n\t\treturn TRUE;\n\telse\n\t\treturn FALSE;\n}\n\n/*********************************************************\nfunction:\t\tGetCR3Flag\ndescription:\tget cr3 flag, only save the flag bits\n**********************************************************/\nULONG64 GetCR3Flag(ULONG64 CR3)\n{\n\treturn (CR3 & CR3_FLAG_ALL_BITS);\n}\n\n/*********************************************************\nfunction:\t\tClearCR3Flag\ndescription:\tclear cr3 flag, only clear the flag bits\n**********************************************************/\nULONG64 ClearCR3Flag(ULONG64 CR3)\n{\n\treturn (CR3 & ~CR3_FLAG_ALL_BITS);\n}\n\n/*********************************************************\nfunction:\t\tpPrintPhysicalOpStructure\ndescription:\tprint the structure elements\n**********************************************************/\nVOID pPrintPhysicalOpStructure(PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\tMyPrint(_TitleAndFunc\"[PrintStart]\\n\");\n\n\tMyPrint(_TitleAndFunc\"pPhysicalOpCR3->pAllocVA_PML4T:%16IX\\n\", pPhysicalOpCR3->pAllocVA_PML4T);\n\tMyPrint(_TitleAndFunc\"pPhysicalOpCR3->pAllocPA_PML4T:%16IX\\n\", pPhysicalOpCR3->pAllocPA_PML4T);\n\n\tMyPrint(_TitleAndFunc\"pPhysicalOpCR3->pAllocVA_PDPT:%16IX\\n\", pPhysicalOpCR3->pAllocVA_PDPT);\n\tMyPrint(_TitleAndFunc\"pPhysicalOpCR3->pAllocPA_PDPT:%16IX\\n\", pPhysicalOpCR3->pAllocPA_PDPT);\n\n\tMyPrint(_TitleAndFunc\"pPhysicalOpCR3->pSystemPML4TMap:%16IX\\n\", pPhysicalOpCR3->pSystemPML4TMap);\n\n\tMyPrint(_TitleAndFunc\"pPhysicalOpCR3->CR3Generated:%16IX\\n\", pPhysicalOpCR3->CR3Generated);\n\n\tMyPrint(_TitleAndFunc\"[PrintEnd]\\n\");\n}\n\n/*********************************************************\nfunction:\t\tpFreePhysicalOpPageTableMemory\ndescription:\tto free the allocated memory (PML4T and PDPT page table) with null pointer check\n**********************************************************/\nNTSTATUS pFreePhysicalOpPageTableMemory(PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\tif (pPhysicalOpCR3->pAllocVA_PML4T != NULL)\n\t{\n\t\tMmFreeNonCachedMemory(pPhysicalOpCR3->pAllocVA_PML4T, PAGE_TABLE_SIZE);\n\t\tpPhysicalOpCR3->pAllocVA_PML4T = NULL;\n\t\tpPhysicalOpCR3->pAllocPA_PML4T = NULL;\n\t}\n\n\tif (pPhysicalOpCR3->pAllocVA_PDPT != NULL)\n\t{\n\t\tMmFreeNonCachedMemory(pPhysicalOpCR3->pAllocVA_PDPT, PAGE_TABLE_SIZE);\n\t\tpPhysicalOpCR3->pAllocVA_PDPT = NULL;\n\t\tpPhysicalOpCR3->pAllocPA_PDPT = NULL;\n\t}\n\t\t\n\treturn STATUS_SUCCESS;\n}\n\n\n/*********************************************************\nfunction:\t\tpAllocPhysicalOpPageTableMemory\ndescription:\tto allocate memory (PML4T and PDPT page table)\n\t\t\t\tif the allocate procduce failed,it can free all the allocated pages\ncalls:\t\t\tMmAllocateNonCachedMemory\n\t\t\t\tMmGetPhysicalAddress\n\t\t\t\tpFreePhysicalOpPageTableMemory\n**********************************************************/\nNTSTATUS pAllocPhysicalOpPageTableMemory(PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\t//PML4T\n\tpPhysicalOpCR3->pAllocVA_PML4T = MmAllocateNonCachedMemory(PAGE_TABLE_SIZE);\n\t//check allocate state\n\tif (pPhysicalOpCR3->pAllocVA_PML4T == NULL)\n\t\tgoto Lable_Error;\n\tpPhysicalOpCR3->pAllocPA_PML4T = (PVOID)MmGetPhysicalAddress(pPhysicalOpCR3->pAllocVA_PML4T).QuadPart;\n\n\n\t//PDPT\n\tpPhysicalOpCR3->pAllocVA_PDPT = MmAllocateNonCachedMemory(PAGE_TABLE_SIZE);\n\t//check allocate state\n\tif (pPhysicalOpCR3->pAllocVA_PDPT == NULL)\n\t\tgoto Lable_Error;\n\tpPhysicalOpCR3->pAllocPA_PDPT = (PVOID)MmGetPhysicalAddress(pPhysicalOpCR3->pAllocVA_PDPT).QuadPart;\n\n\n\treturn STATUS_SUCCESS;\nLable_Error:\n\t//free allocated memory\n\tpFreePhysicalOpPageTableMemory(pPhysicalOpCR3);\n\treturn STATUS_UNSUCCESSFUL;\n}\n\n/*********************************************************\nfunction:\t\tpMapPML4T\ndescription:\tmap the system cr3(pml4t) to virtual address\ncalls:\t\t\tClearCR3Flag\n\t\t\t\tOpenPhysicalMemory\n\t\t\t\tMapPhysicalMemory\n**********************************************************/\nNTSTATUS pMapSystemPML4T(ULONG64 SystemCR3, PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\tULONG64 SystemCR3NonFlag = ClearCR3Flag(SystemCR3);\n\tPVOID\tpSystemPML4T = (PVOID)SystemCR3NonFlag;\n\n\tif (g_SectionHandle == NULL)\n\t\tg_SectionHandle = OpenPhysicalMemory();\n\n\tpPhysicalOpCR3->pSystemPML4TMap = MapPhysicalMemory(pSystemPML4T, PAGE_TABLE_SIZE);\n\n\treturn pPhysicalOpCR3->pSystemPML4TMap == NULL ? STATUS_UNSUCCESSFUL : STATUS_SUCCESS;\n}\n\n/*********************************************************\nfunction:\t\tpUnmapSystemPML4T\ndescription:\tunmap the system cr3(pml4t)\ncalls:\t\t\tOpenPhysicalMemory\n\t\t\t\tUnmapPhysicalMemory\n**********************************************************/\nNTSTATUS pUnmapSystemPML4T(PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\tif (g_SectionHandle == NULL)\n\t\tg_SectionHandle = OpenPhysicalMemory();\n\n\tBOOL\tState = UnmapPhysicalMemory(pPhysicalOpCR3->pSystemPML4TMap);\n\tif (State)\n\t\tpPhysicalOpCR3->pSystemPML4TMap = NULL;\n\n\tif (g_SectionHandle != NULL)\n\t\tZwClose(g_SectionHandle);\n\n\treturn !State ? STATUS_UNSUCCESSFUL : STATUS_SUCCESS;\n}\n\n/*********************************************************\nfunction:\t\tpFillGeneratedPML4TandPDPT\ndescription:\tfill the pml4t table,genarate the first large page entry and copy the system space map\n\t\t\t\tfill the pdpt table point to the physical address,every PDPTE point to a 1G-byte page(512G in total)\ncalls:\t\t\tRtlCopyMemory\n**********************************************************/\nNTSTATUS pFillGeneratedPML4TandPDPT(PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\t//copy the system space map\n\tPVOID\t\tpSystemStart = (PVOID)VA_SYSTEM_START;\n\tULONG64\t\tSystemPML4TStart = ((PMMVA)&pSystemStart)->PML4T;\n\n\tMyPrint(_TitleAndFunc\"SystemPML4TStart:%16X\\n\", SystemPML4TStart);\n\tRtlCopyMemory((PVOID)((ULONG64)pPhysicalOpCR3->pAllocVA_PML4T + SystemPML4TStart*ENTRY_SIZE),\n\t\t(PVOID)((ULONG64)pPhysicalOpCR3->pSystemPML4TMap + SystemPML4TStart*ENTRY_SIZE),\n\t\t(MAX_ENTRY_COUNT - SystemPML4TStart)*ENTRY_SIZE\n\t);\n\n\t//make the first address point to my PDPT table\n\t*(PULONG64)pPhysicalOpCR3->pAllocVA_PML4T = (ULONG64)pPhysicalOpCR3->pAllocPA_PDPT | PAGE_TABLE_PML4T_FLAG;\n\n\t//fill the PDPT page table\n\t//add flag\n\tULONG64 CurrentPDPTEntry = PAGE_TABLE_PDPT_FLAG;\n\tfor (int i = 0; i < MAX_ENTRY_COUNT; i++)\n\t{\n\t\t//change pfn\n\t\t((PMMPDPTE)&CurrentPDPTEntry)->PageFrameNumber = i;\n\t\t//\n\t\t*(PULONG64)((ULONG64)pPhysicalOpCR3->pAllocVA_PDPT + i*ENTRY_SIZE) = CurrentPDPTEntry;\n\t}\n\treturn STATUS_SUCCESS;\n}\n/*********************************************************\nfunction:\t\tCreatePhysicalOpCR3BySystemCR3\ndescription:\tto initialize the physical memory operation structure\ncalls:\t\t\tpAllocPhysicalOpPageTableMemory\n\t\t\t\tpMapSystemPML4T\n\t\t\t\tpFillGeneratedPML4TandPDPT\n\t\t\t\tpMapPML4T\n\t\t\t\tGetCR3Flag\n**********************************************************/\nNTSTATUS CreatePhysicalOpCR3BySystemCR3(ULONG64 SystemCR3, PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\t//check the init state\n\tif (g_IsPhysicalOpInit)\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\n\t//allocate page table memory and fill the structure\n\tif (!NT_SUCCESS(pAllocPhysicalOpPageTableMemory(pPhysicalOpCR3)))\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\t//map pSystemPML4T to virtual address and fill the structure\n\tif (!NT_SUCCESS(pMapSystemPML4T(SystemCR3, pPhysicalOpCR3)))\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\t//fill PML4T and PDPT page table\n\tif (!NT_SUCCESS(pFillGeneratedPML4TandPDPT(pPhysicalOpCR3)))\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\t//generate new cr3 for reading the physical memory and add cr3 flag\n\tULONG64\tSystemCR3Flag = GetCR3Flag(SystemCR3);\n\tpPhysicalOpCR3->CR3Generated = (ULONG64)pPhysicalOpCR3->pAllocPA_PML4T | SystemCR3Flag;\n\n\t//fill the structure part:CR3System\n\tpPhysicalOpCR3->CR3System = SystemCR3;\n\n\t//print structure\n\tpPrintPhysicalOpStructure(pPhysicalOpCR3);\n\n\tg_IsPhysicalOpInit = TRUE;\n\treturn STATUS_SUCCESS;\n}\n\n\n/*********************************************************\nfunction:\t\tFreePhysicalOpCR3\ndescription:\tto uninitialize the physical memory operation structure\ncalls:\t\t\tpUnmapSystemPML4T\n\t\t\t\tpFreePhysicalOpPageTableMemory\n\t\t\t\tRtlZeroMemory\n**********************************************************/\nNTSTATUS FreePhysicalOpCR3(PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\t//check the init state\n\tif (!g_IsPhysicalOpInit)\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\t//unmap pSystemPML4T\n\tpUnmapSystemPML4T(pPhysicalOpCR3);\n\n\t//free allocated memory\n\tpFreePhysicalOpPageTableMemory(pPhysicalOpCR3);\n\n\t//clear generated cr3 and recorded system cr3\n\tpPhysicalOpCR3->CR3Generated = 0;\n\tpPhysicalOpCR3->CR3System = 0;\n\n\t//print structure\n\tpPrintPhysicalOpStructure(pPhysicalOpCR3);\n\n\t// set the structure to zero,avoid some bugs\n\tRtlZeroMemory((PVOID)pPhysicalOpCR3, sizeof(PHYSICAL_OP_CR3));\n\n\n\tg_IsPhysicalOpInit = FALSE;\n\treturn STATUS_SUCCESS;\n}\n\n/*********************************************************\nfunction:\t\tContextVirtualToPhysical\ndescription:\traise irql and switch to generated cr3\n**********************************************************/\nNTSTATUS ContextVirtualToPhysical(PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\t//check the initialize state and current context\n\tif (!g_IsPhysicalOpInit || pPhysicalOpCR3->IsContextSwitched)\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\t//assert irql >= dispatch level\n\tpPhysicalOpCR3->OriginalIrql = KeGetCurrentIrql();\n\tif (pPhysicalOpCR3->OriginalIrql < DISPATCH_LEVEL)\n\t{\n\t\tpPhysicalOpCR3->IsIrqlChanged = TRUE;\n\t\tKeRaiseIrqlToDpcLevel();\n\t}\n\n\n\t//disable task switch interrupt(maskable)\n\t_disable();\n\n\t\n\t//record and switch cr3\n\tpPhysicalOpCR3->CR3BeforeSwitch = __readcr3();\n\t__writecr3(pPhysicalOpCR3->CR3Generated);\n\n\t//change the flag IsContextSwitched\n\tpPhysicalOpCR3->IsContextSwitched = TRUE;\n\treturn STATUS_SUCCESS;\n}\n\n/*********************************************************\nfunction:\t\tContextPhysicalToVirtual\ndescription:\tlower irql and switch to system cr3\n**********************************************************/\nNTSTATUS ContextPhysicalToVirtual(PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\t//check the initialize state and current context\n\tif (!g_IsPhysicalOpInit || !pPhysicalOpCR3->IsContextSwitched)\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\t//restore cr3\n\t__writecr3(pPhysicalOpCR3->CR3BeforeSwitch);\n\n\t//enable task switch interrupt(maskable)\n\t_enable();\n\n\t//restore irql\n\tif (pPhysicalOpCR3->IsIrqlChanged)\n\t{\n\t\tKeLowerIrql(pPhysicalOpCR3->OriginalIrql);\n\n\t\t//restore the flag IsIrqlChanged\n\t\tpPhysicalOpCR3->IsIrqlChanged = FALSE;\n\t}\n\n\t//change the flag IsContextSwitched\n\tpPhysicalOpCR3->IsContextSwitched = FALSE;\n\treturn STATUS_SUCCESS;\n}\n\n\n/*********************************************************\nfunction:\t\tGetCR3ByEprocess\ndescription:\tget cr3 by eprocess\n**********************************************************/\nULONG64 GetCR3ByEprocess(PEPROCESS pEProc)\n{\n\tif (pEProc == NULL)\n\t\treturn 0;\n\n\t//get dirbase\n\tULONG64\tDirBase = *(PULONG64)((ULONG64)pEProc + 0x028);\n\treturn DirBase;\n}\n\n/*********************************************************\nfunction:\t\tGetEProcess\ndescription:\tget eprocess by pid\n**********************************************************/\nPEPROCESS GetEProcess(ULONG64 PID)\n{\n\tPEPROCESS\t\tpEProc = NULL;\n\n\t//check pid\n\tif (PID == 0)\n\t\treturn 0;\n\n\t//get eprocess\n\tif (!NT_SUCCESS(PsLookupProcessByProcessId((HANDLE)PID, (PEPROCESS*)&pEProc)))\n\t\treturn 0;\n\n\t//dereference\n\tif (pEProc != NULL)\n\t\tObDereferenceObject((PVOID)pEProc);\n\n\treturn pEProc;\n}\n\n/*********************************************************\nfunction:\t\tGetCR3ByPID\ndescription:\tget cr3 by pid\ncalls:\t\t\tGetEProcess\n\t\t\t\tGetCR3ByEprocess\n**********************************************************/\nULONG64 GetCR3ByPID(ULONG64 PID)\n{\n\treturn GetCR3ByEprocess(GetEProcess(PID));\n}"
  },
  {
    "path": "KernelHiddenExcute/SectionOperation.h",
    "content": "#pragma once\n#include \"Head.h\"\n\ntypedef struct _LDR_DATA_TABLE_ENTRY64\n{\n\tLIST_ENTRY64    InLoadOrderLinks;\n\tLIST_ENTRY64    InMemoryOrderLinks;\n\tLIST_ENTRY64    InInitializationOrderLinks;\n\tPVOID            DllBase;\n\tPVOID            EntryPoint;\n\tULONG            SizeOfImage;\n\tUNICODE_STRING    FullDllName;\n\tUNICODE_STRING     BaseDllName;\n\tULONG            Flags;\n\tUSHORT            LoadCount;\n\tUSHORT            TlsIndex;\n\tPVOID            SectionPointer;\n\tULONG            CheckSum;\n\tPVOID            LoadedImports;\n\tPVOID            EntryPointActivationContext;\n\tPVOID            PatchInformation;\n\tLIST_ENTRY64    ForwarderLinks;\n\tLIST_ENTRY64    ServiceTagLinks;\n\tLIST_ENTRY64    StaticLinks;\n\tPVOID            ContextInformation;\n\tULONG64            OriginalBase;\n\tLARGE_INTEGER    LoadTime;\n} LDR_DATA_TABLE_ENTRY64, *PLDR_DATA_TABLE_ENTRY64;\n\nPIMAGE_SECTION_HEADER GetSegmentHeadPointer(PDRIVER_OBJECT pDriverObj, PCHAR pSegName)\n{\n\tPLDR_DATA_TABLE_ENTRY64\t\tentry = (PLDR_DATA_TABLE_ENTRY64)pDriverObj->DriverSection;\n\tPUCHAR\t\t\t\t\t\tpJumpDrvBase = (PUCHAR)entry->DllBase;\n\tPIMAGE_DOS_HEADER\t\t\tpDosHead;\n\tPIMAGE_NT_HEADERS\t\t\tpNtHead;\n\tPIMAGE_SECTION_HEADER\t\tpSecHead;\n\tBOOL\t\t\t\t\t\tbFinded = FALSE;\n\n\tpDosHead = (PIMAGE_DOS_HEADER)pJumpDrvBase;\n\tif (pDosHead->e_magic != IMAGE_DOS_SIGNATURE)\n\t{\n\t\tMyPrint((\"[\" PRINT_NAME \"] DosHead Error\\n\"));\n\t\treturn 0;\n\t}\n\tpNtHead = (PIMAGE_NT_HEADERS)\\\n\t\t((LONG_PTR)pDosHead + pDosHead->e_lfanew);\n\tif (pNtHead->Signature != IMAGE_NT_SIGNATURE)\n\t{\n\t\tMyPrint((\"[\" PRINT_NAME \"] NtHead Error\\n\"));\n\t\treturn 0;\n\t}\n\tpSecHead = IMAGE_FIRST_SECTION(pNtHead);\n\tfor (int i = 0; i < pNtHead->FileHeader.NumberOfSections; i++)\n\t{\n\t\tif (strcmp((const char*)(pSecHead->Name), pSegName) == 0)\n\t\t{\n\t\t\tbFinded = TRUE;\n\t\t\tbreak;\n\t\t}\n\t\tpSecHead++;\n\t}\n\tif (bFinded == FALSE)\n\t{\n\t\tMyPrint((\"[\" PRINT_NAME \"] SecHead Error\\n\"));\n\t\treturn 0;\n\t}\n\n\treturn pSecHead;\n}\n\nULONG64 GetDriverBaseAddress(PDRIVER_OBJECT pDriverObj, PCHAR pSegName)\n{\n\tPLDR_DATA_TABLE_ENTRY64\t\tentry = (PLDR_DATA_TABLE_ENTRY64)pDriverObj->DriverSection;\n\tPUCHAR\t\t\t\t\t\tpJumpDrvBase = (PUCHAR)entry->DllBase;\n\treturn (ULONG64)pJumpDrvBase;\n}\nULONG64 GetSegmentAddressPointer(PDRIVER_OBJECT pDriverObj, PCHAR pSegName)\n{\n\tPIMAGE_SECTION_HEADER pSecHead = GetSegmentHeadPointer(pDriverObj, pSegName);\n\treturn (ULONG64)&(pSecHead->VirtualAddress);\n}\nULONG64 GetSegmentLengthPointer(PDRIVER_OBJECT pDriverObj, PCHAR pSegName)\n{\n\tPIMAGE_SECTION_HEADER pSecHead = GetSegmentHeadPointer(pDriverObj, pSegName);\n\treturn (ULONG64)&(pSecHead->Misc.VirtualSize);\n}\nULONG64 GetSegmentRawDataAddressPointer(PDRIVER_OBJECT pDriverObj, PCHAR pSegName)\n{\n\tPIMAGE_SECTION_HEADER pSecHead = GetSegmentHeadPointer(pDriverObj, pSegName);\n\treturn (ULONG64)&(pSecHead->PointerToRawData);\n}\nULONG64 GetSegmentRawDataLengthPointer(PDRIVER_OBJECT pDriverObj, PCHAR pSegName)\n{\n\tPIMAGE_SECTION_HEADER pSecHead = GetSegmentHeadPointer(pDriverObj, pSegName);\n\treturn (ULONG64)&(pSecHead->SizeOfRawData);\n}\n\nULONG64 GetSegmentStartAddress(PDRIVER_OBJECT pDriverObj, PCHAR pSegName)\n{\n\tULONG64 pDriverBase = GetDriverBaseAddress(pDriverObj, pSegName);\n\tULONG64 pSegmentAddress = GetSegmentAddressPointer(pDriverObj, pSegName);\n\treturn pDriverBase + *(PULONG32)pSegmentAddress;\n}\n\nULONG64 GetSegmentEndAddress(PDRIVER_OBJECT pDriverObj, PCHAR pSegName)\n{\n\tULONG64 pDriverBase = GetDriverBaseAddress(pDriverObj, pSegName);\n\tULONG64 pSegmentAddress = GetSegmentAddressPointer(pDriverObj, pSegName);\n\tULONG64 pSegmentLength = GetSegmentLengthPointer(pDriverObj, pSegName);\n\treturn pDriverBase + *(PULONG32)pSegmentAddress + *(PULONG32)pSegmentLength;\n}\n\nULONG64 GetSegmentLength(PDRIVER_OBJECT pDriverObj, PCHAR pSegName)\n{\n\tULONG64 pDriverBase = GetDriverBaseAddress(pDriverObj, pSegName);\n\tULONG64 pSegmentAddress = GetSegmentAddressPointer(pDriverObj, pSegName);\n\tULONG64 pSegmentLength = GetSegmentLengthPointer(pDriverObj, pSegName);\n\treturn *(PULONG32)pSegmentLength;\n}"
  },
  {
    "path": "KernelHiddenExcute/main.c",
    "content": "#include \"Head.h\"\n\nNTSTATUS DispatchCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp)\n{\n\tpIrp->IoStatus.Status = STATUS_SUCCESS;\n\tpIrp->IoStatus.Information = 0;\n\tIoCompleteRequest(pIrp, IO_NO_INCREMENT);\n\treturn STATUS_SUCCESS;\n}\n\nNTSTATUS DispatchClose(PDEVICE_OBJECT pDevObj, PIRP pIrp)\n{\n\tpIrp->IoStatus.Status = STATUS_SUCCESS;\n\tpIrp->IoStatus.Information = 0;\n\tIoCompleteRequest(pIrp, IO_NO_INCREMENT);\n\treturn STATUS_SUCCESS;\n}\n\nNTSTATUS DispatchIoctl(PDEVICE_OBJECT pDevObj, PIRP pIrp)\n{\n\tNTSTATUS status = STATUS_INVALID_DEVICE_REQUEST;\n\tPIO_STACK_LOCATION pIrpStack = IoGetCurrentIrpStackLocation(pIrp);\n\tULONG uIoControlCode = pIrpStack->Parameters.DeviceIoControl.IoControlCode;\n\tPVOID pIoBuffer = pIrp->AssociatedIrp.SystemBuffer;\n\tULONG uInSize = pIrpStack->Parameters.DeviceIoControl.InputBufferLength;\n\tULONG uOutSize = pIrpStack->Parameters.DeviceIoControl.OutputBufferLength;\n\tswitch (uIoControlCode)\n\t{\n\tcase IOCTL_TEST:\n\t{\n\t\tDWORD dw;\n\t\tmemcpy(&dw, pIoBuffer, sizeof(dw));\n\t\tdw++;\n\t\tmemcpy(pIoBuffer, &dw, sizeof(dw));\n\t\tstatus = STATUS_SUCCESS;\n\t\tbreak;\n\t}\n\t}\n\tif (status == STATUS_SUCCESS)\n\t\tpIrp->IoStatus.Information = uOutSize;\n\telse\n\t\tpIrp->IoStatus.Information = 0;\n\tpIrp->IoStatus.Status = status;\n\tIoCompleteRequest(pIrp, IO_NO_INCREMENT);\n\treturn status;\n}\n\nVOID DriverUnload(PDRIVER_OBJECT pDriverObj)\n{\n\tUNICODE_STRING strLink;\n\t//do sth...\n\tMyPrint(_TitleAndFunc\"Exit\\n\");\n\n\tRemoveAndRestoreAllHiddenPageRecord(g_pHiddenPageRecord);\n\tFreeHiddenPageRecordStructure(g_pHiddenPageRecord);\n\n\t//delete device and symbolic link\n\tRtlInitUnicodeString(&strLink, LINK_NAME);\n\tIoDeleteSymbolicLink(&strLink);\n\tIoDeleteDevice(pDriverObj->DeviceObject);\n}\nVOID WriteEnable()\n{\n\tUINT64 cr0 = __readcr0();\n\tcr0 &= 0xfffffffffffeffff;\n\t__writecr0(cr0);\n\t_disable();\n}\nVOID WriteDisable()\n{\n\tUINT64 cr0 = __readcr0();\n\tcr0 |= 0x10000;\n\t_enable();\n\t__writecr0(cr0);\n}\nNTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObj, PUNICODE_STRING pRegistryString)\n{\n\tNTSTATUS status = STATUS_SUCCESS;\n\tPDEVICE_OBJECT pDevObj = NULL;\n\tUNICODE_STRING ustrDeviceName;\n\tUNICODE_STRING ustrLinkName;\n\t//set dispatch functions\n\tpDriverObj->DriverUnload = DriverUnload;\n\tpDriverObj->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DispatchIoctl;\n\tpDriverObj->MajorFunction[IRP_MJ_CREATE] = DispatchCreate;\n\tpDriverObj->MajorFunction[IRP_MJ_CLOSE] = DispatchClose;\n\t//create device\n\tRtlInitUnicodeString(&ustrDeviceName, DEVICE_NAME);\n\tstatus = IoCreateDevice(pDriverObj, 0, &ustrDeviceName, FILE_DEVICE_UNKNOWN, 0, FALSE, &pDevObj);\n\tif (!NT_SUCCESS(status))\n\t{\n\t\treturn status;\n\t}\n\t//create symbolic link\n\tRtlInitUnicodeString(&ustrLinkName, LINK_NAME);\n\tstatus = IoCreateSymbolicLink(&ustrLinkName, &ustrDeviceName);\n\tif (!NT_SUCCESS(status))\n\t{\n\t\tIoDeleteDevice(pDevObj);\n\t\treturn status;\n\t}\n\t//do sth...\n\tMyPrint(_TitleAndFunc \"Entry\\n\");\n\n\tInitializeHiddenPageRecordStructure(&g_pHiddenPageRecord);\n\tAddHiddenSection(GetCR3ByPID(4), pDriverObj, SECTION_NAME_HIDDEN, g_pHiddenPageRecord);\n\n\tWriteEnable();\n\tRtlZeroMemory((PVOID)HiddenFunctionA, 10);\n\tWriteDisable();\n\n\tContextOriginalToHidden(g_pHiddenPageRecord);\n\n\tHiddenFunctionA(g_pHiddenPageRecord);\n\n\tContextHiddenToOriginal(g_pHiddenPageRecord);\n\n\treturn status;\n}"
  },
  {
    "path": "KernelHiddenExecute/DebugPrintEx.h",
    "content": "#pragma once\n\n#include <ntddk.h>\n\n//switch\n#define _DBG_PRINT\n\n#define PRINT_NAME \"XYLab\"\n\n\n#define _Title \"[\"##PRINT_NAME##\"] \"\n#define _Func \"[\"##__FUNCTION__##\"] \"\n#define _TitleAndFunc \"[\"##PRINT_NAME##\"] \"##\"[\"##__FUNCTION__##\"] \" \n\n#ifdef _DBG_PRINT\n//#define MyPrint(_x_) DbgPrint _x_\n#define MyPrint(...) DbgPrint(__VA_ARGS__)\n#else\n//#define MyPrint(_x_)\n#define MyPrint(...)\n#endif"
  },
  {
    "path": "KernelHiddenExecute/HiddenCallApiTransfer.c",
    "content": "#include \"HiddenCallApiTransfer.h\"\n\n\n//////////////////////////////////////////////////////////////////////////\n//functions\n\n/*********************************************************\nfunction:\t\tSimulateApi\ndescription:\n**********************************************************/\nNTSTATUS SimulateApi(ULONG64 param1)\n{\n\tMyPrint(_TitleAndFunc\"param1:%16IX\\n\", param1);\n\treturn STATUS_SUCCESS;\n}\n\n/*********************************************************\nfunction:\t\tApiTransfer_SimulateApi\ndescription:\ttest of call apis in the hidden apis\n**********************************************************/\n\nNTSTATUS ApiTransfer_SimulateApi(PHIDDEN_PAGE_RECORD pHiddenPageRecord, ULONG64 param1)\n{\n\t//BOOL\t\tIsIrqlChanged = FALSE;\n\tNTSTATUS\tStatus;\n\n\t/*\n\tif (HighestIrql < HIDDEN_IRQL)\n\t{\n\tChangeIrql(HighestIrql);\n\tIsIrqlChanged = TRUE;\n\t}\n\t*/\n\n\tContextHiddenToOriginal(pHiddenPageRecord);\n\n\tStatus = SimulateApi(param1);\n\n\tContextOriginalToHidden(pHiddenPageRecord);\n\n\t/*\n\tif (IsIrqlChanged)\n\tChangeIrql(HIDDEN_IRQL);\n\t*/\n\n\treturn Status;\n}\n"
  },
  {
    "path": "KernelHiddenExecute/HiddenCallApiTransfer.h",
    "content": "#pragma once\n\n#include <ntddk.h>\n#include <windef.h>\n\n#include \"DebugPrintEx.h\"\n#include \"HiddenExecute.h\"\n\n\n//////////////////////////////////////////////////////////////////////////\n//prototypes\n\nNTSTATUS SimulateApi(ULONG64 param1);\nNTSTATUS ApiTransfer_SimulateApi(PHIDDEN_PAGE_RECORD pHiddenPageRecord, ULONG64 param1);"
  },
  {
    "path": "KernelHiddenExecute/HiddenExecute.c",
    "content": "#include \"HiddenExecute.h\"\n\n//////////////////////////////////////////////////////////////////////////\n//global variables\nPHYSICAL_OP_CR3\t\t\tg_PhysicalOpCR3 = { 0 };\nBOOL\t\t\t\t\tg_IsHiddenOpInit = FALSE;\n\n\n//////////////////////////////////////////////////////////////////////////\n//functions\n\n/*********************************************************\nfunction:\t\tInitializeHiddenPageRecordStructure\ndescription:\tinitialize the structure:initialize spin lock & set count to zero\ncalls:\t\t\tExAllocatePool\n\t\t\t\tKeInitializeSpinLock\n\t\t\t\tCreatePhysicalOpCR3BySystemCR3\n**********************************************************/\nNTSTATUS InitializeHiddenPageRecordStructure(PHIDDEN_PAGE_RECORD* ppHiddenPageRecord)\n{\n\t//check the init state\n\tif (g_IsHiddenOpInit)\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\tPHIDDEN_PAGE_RECORD pHiddenPageRecord = NULL;\n\tpHiddenPageRecord = (PHIDDEN_PAGE_RECORD)ExAllocatePool(NonPagedPool, HIDDEN_PAGE_RECORD_LENGTH);\n\tif (!pHiddenPageRecord)\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\tRtlZeroMemory(pHiddenPageRecord, HIDDEN_PAGE_RECORD_LENGTH);\n\t*ppHiddenPageRecord = pHiddenPageRecord;\n\n\tMyPrint(_TitleAndFunc\"pHiddenPageRecord:%16IX\\n\", pHiddenPageRecord);\n\tif (pHiddenPageRecord != NULL)\n\t{\n\t\t//set count to zero\n\t\tpHiddenPageRecord->Count = 0;\n\t\t//initialize spin lock\n\t\tKeInitializeSpinLock(&pHiddenPageRecord->SpinLock);\n\n\t\t//initialize physical memory context\n\t\tCreatePhysicalOpCR3BySystemCR3(GetCR3ByPID(4), &g_PhysicalOpCR3);\n\n\t\t//change init state\n\t\tg_IsHiddenOpInit = TRUE;\n\n\t\treturn STATUS_SUCCESS;\n\t}\n\telse {\n\t\treturn STATUS_UNSUCCESSFUL;\n\t}\n}\n\n/*********************************************************\nfunction:\t\tFreeHiddenPageRecordStructure\ndescription:\tfree the structure and set pHiddenPageRecord to zero\ncalls:\t\t\tExFreePool\n**********************************************************/\nNTSTATUS FreeHiddenPageRecordStructure(PHIDDEN_PAGE_RECORD pHiddenPageRecord)\n{\n\t//check the init state\n\tif (!g_IsHiddenOpInit)\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\tif (pHiddenPageRecord != NULL)\n\t{\n\t\t//free hidden operation structure\n\t\tExFreePool(pHiddenPageRecord);\n\t\tpHiddenPageRecord = NULL;\n\n\t\t//free physical operation structure\n\t\tFreePhysicalOpCR3(&g_PhysicalOpCR3);\n\n\t\t//change the init state\n\t\tg_IsHiddenOpInit = FALSE;\n\n\t\treturn STATUS_SUCCESS;\n\t}\n\telse {\n\t\treturn STATUS_UNSUCCESSFUL;\n\t}\n}\n\n/*********************************************************\nfunction:\t\tpPTEPFNtoPhysicalAddress\ndescription:\ttranslate pfn number to physical address\n**********************************************************/\nPVOID pPTEPFNtoPhysicalAddress(ULONG64 PFN)\n{\n\treturn (PVOID)(PFN << 12);\n}\n\n/*********************************************************\nfunction:\t\tpPhysicalAddresstoPTEPFN\ndescription:\ttranslate physical address to pfn number\n**********************************************************/\nULONG64 pPhysicalAddresstoPTEPFN(PVOID PhysicalAddressBase)\n{\n\treturn (ULONG64)PhysicalAddressBase >> 12;\n}\n\n/*********************************************************\nfunction:\t\tpGetSpecificAddresspPTEPhysical\ndescription:\tget the pointer of pPTEPhysical\ncalls:\t\t\tContextVirtualToPhysical\nClearPageTableFlag\nContextPhysicalToVirtual\n**********************************************************/\nPMMPTE pGetSpecificAddresspPTEPhysical(ULONG64 CR3, PVOID pPageBase)\n{\n\t//analyse the params\n\tPMMVA\t\tpAddressInfo = (PMMVA)&pPageBase;\n\tPVOID\t\tpPML4T = (PVOID)ClearCR3Flag(CR3);\n\tPMMPTE\t\tpPML4E = NULL;\n\tPVOID\t\tpPDPT = NULL;\n\tPMMPTE\t\tpPDPTE = NULL;\n\tPVOID\t\tpPDT = NULL;\n\tPMMPTE\t\tpPDE = NULL;\n\tPVOID\t\tpPT = NULL;\n\tPMMPTE\t\tpPTE = NULL;\n\n\t//switch to physical context\n\tContextVirtualToPhysical(&g_PhysicalOpCR3);\n\n\tpPML4E = (PMMPTE)((ULONG64)pPML4T + pAddressInfo->PML4T * ENTRY_SIZE);\n\tif (!pPML4E->Valid)\n\t\tgoto Lable_Error;\n\tpPDPT = (PVOID)ClearPageTableFlag(*(PULONG64)pPML4E);\n\n\tpPDPTE = (PMMPTE)((ULONG64)pPDPT + pAddressInfo->PDPT * ENTRY_SIZE);\n\tif (pPDPTE->LargePage || !pPDPTE->Valid)\n\t\tgoto Lable_Error;\n\tpPDT = (PVOID)ClearPageTableFlag(*(PULONG64)pPDPTE);\n\n\tpPDE = (PMMPTE)((ULONG64)pPDT + pAddressInfo->PDT * ENTRY_SIZE);\n\tif (pPDE->LargePage || !pPDE->Valid)\n\t\tgoto Lable_Error;\n\tpPT = (PVOID)ClearPageTableFlag(*(PULONG64)pPDE);\n\n\tpPTE = (PMMPTE)((ULONG64)pPT + pAddressInfo->PT * ENTRY_SIZE);\n\tif (!pPTE->Valid)\n\t\tgoto Lable_Error;\n\n\tContextPhysicalToVirtual(&g_PhysicalOpCR3);\n\t//look up the page table finished\n\tMyPrint(_TitleAndFunc\"pPTE:%16IX\\n\", pPTE);\n\treturn pPTE;\n\nLable_Error:\n\tContextPhysicalToVirtual(&g_PhysicalOpCR3);\n\treturn NULL;\n}\n\n/*********************************************************\nfunction:\t\tpGetSpecificAddressPhysicalForR3\ndescription:\tjust for E language\n**********************************************************/\n#define PHYSICAL_OFFSET\t0x8000000000\n#define NUM_1G\t\t\t0x40000000\n#define NUM_2M\t\t\t0x200000\nPVOID pGetSpecificAddressPhysicalForR3(ULONG64 CR3, PVOID pVirtual)\n{\n\t//analyse the params\n\tPMMVA\t\tpAddressInfo = (PMMVA)&pVirtual;\n\tPVOID\t\tpPML4T = (PVOID)ClearCR3Flag(CR3);\n\tPMMPTE\t\tpPML4E = NULL;\n\tPVOID\t\tpPDPT = NULL;\n\tPMMPTE\t\tpPDPTE = NULL;\n\tPVOID\t\tpPDT = NULL;\n\tPMMPTE\t\tpPDE = NULL;\n\tPVOID\t\tpPT = NULL;\n\tPMMPTE\t\tpPTE = NULL;\n\tPVOID\t\tpPhysicalBase = NULL;\n\tPVOID\t\tpPhysical = NULL;\n\tPVOID\t\tpPhysicalR3 = NULL;\n\n\tpPML4E = (PMMPTE)((ULONG64)pPML4T + pAddressInfo->PML4T * ENTRY_SIZE + PHYSICAL_OFFSET);\n\tif (!pPML4E->Valid)\n\t\treturn NULL;\n\tpPDPT = (PVOID)ClearPageTableFlag(*(PULONG64)pPML4E);\n\n\tpPDPTE = (PMMPTE)((ULONG64)pPDPT + pAddressInfo->PDPT * ENTRY_SIZE + PHYSICAL_OFFSET);\n\tif (!pPDPTE->Valid)\n\t\treturn NULL;\n\tif (pPDPTE->LargePage)\n\t\tgoto Lable_PDPTE_LargePage;\n\tpPDT = (PVOID)ClearPageTableFlag(*(PULONG64)pPDPTE);\n\n\tpPDE = (PMMPTE)((ULONG64)pPDT + pAddressInfo->PDT * ENTRY_SIZE + PHYSICAL_OFFSET);\n\tif (!pPDE->Valid)\n\t\treturn NULL;\n\tif (pPDE->LargePage)\n\t\tgoto Lable_PDE_LargePage;\n\tpPT = (PVOID)ClearPageTableFlag(*(PULONG64)pPDE);\n\n\tpPTE = (PMMPTE)((ULONG64)pPT + pAddressInfo->PT * ENTRY_SIZE + PHYSICAL_OFFSET);\n\tif (!pPTE->Valid)\n\t\treturn NULL;\n\tpPhysicalBase = (PVOID)ClearPageTableFlag(*(PULONG64)pPTE);\n\n\tpPhysical = (PVOID)((ULONG64)pPhysicalBase + pAddressInfo->Offset);\n\tpPhysicalR3 = (PVOID)((ULONG64)pPhysical + PHYSICAL_OFFSET);\n\treturn pPhysicalR3;\n\nLable_PDPTE_LargePage:\n\tpPhysicalBase = (PVOID)(((PMMPDPTE)pPDPTE)->PageFrameNumber * NUM_1G);\n\tpPhysical = (PVOID)((ULONG64)pPhysicalBase + ((PMMVA_PDPTE_LARGE)pAddressInfo)->Offset);\n\tpPhysicalR3 = (PVOID)((ULONG64)pPhysical + PHYSICAL_OFFSET);\n\treturn pPhysicalR3;\n\nLable_PDE_LargePage:\n\tpPhysicalBase = (PVOID)(((PMMPDE)pPDE)->PageFrameNumber * NUM_2M);\n\tpPhysical = (PVOID)((ULONG64)pPhysicalBase + ((PMMVA_PDE_LARGE)pAddressInfo)->Offset);\n\tpPhysicalR3 = (PVOID)((ULONG64)pPhysical + PHYSICAL_OFFSET);\n\treturn pPhysicalR3;\n}\n/*********************************************************\nfunction:\t\tAddHiddenPageRecord\ndescription:\tadd a record element to the structure\n\t\t\t\tinclude get pte physical address of the specific page and record the pfn\n\t\t\t\treserve a physical page by api:MmAllocateNonCachedMemory and MmMarkPhysicalMemoryAsBad\n\t\t\t\tthen free the page\n\ncalls:\t\t\tKeAcquireSpinLock\n\t\t\t\tpGetSpecificAddresspPTEPhysical\n\t\t\t\tContextVirtualToPhysical\n\t\t\t\tContextPhysicalToVirtual\n\t\t\t\tMmAllocateNonCachedMemory\n\t\t\t\tMmGetPhysicalAddress\n\t\t\t\tpPhysicalAddresstoPTEPFN\n\t\t\t\tMmFreeNonCachedMemory\n\t\t\t\tMmMarkPhysicalMemoryAsBad\n\t\t\t\tKeReleaseSpinLock\n**********************************************************/\nNTSTATUS AddHiddenPageRecord(ULONG64 CR3, PVOID pHiddenPageBase, PHIDDEN_PAGE_RECORD pHiddenPageRecord)\n{\n\tKIRQL\t\tEntryIrql;\n\tNTSTATUS\tStatus = STATUS_UNSUCCESSFUL;\n\t//prevent mulit-thread change the page record count\n\tKeAcquireSpinLock(&pHiddenPageRecord->SpinLock, &EntryIrql);\n\n\t//check count\n\tMyPrint(_TitleAndFunc\"pHiddenPageRecord->Count:%16IX\\n\", pHiddenPageRecord->Count);\n\tif (pHiddenPageRecord->Count == MAX_HIDDEN_PAGE_COUNT)\n\t\tgoto Lable_Error;\n\n\t//add pPTE record\n\tPSPECIFIC_HIDDEN_PAGE_RECORD\tpCurrentRecord = &pHiddenPageRecord->Record[pHiddenPageRecord->Count];\n\n\tpCurrentRecord->pPTE = pGetSpecificAddresspPTEPhysical(CR3, pHiddenPageBase);\n\tMyPrint(_TitleAndFunc\"pCurrentRecord->pPTE:%16IX\\n\", pCurrentRecord->pPTE);\n\tif (pCurrentRecord->pPTE == NULL)\n\t\tgoto Lable_Error;\n\n\t//add hidden virtual address record\n\tpCurrentRecord->pHiddenBase = pHiddenPageBase;\n\tMyPrint(_TitleAndFunc\"pCurrentRecord->pHiddenBase:%16IX\\n\", pCurrentRecord->pHiddenBase);\n\n\t//add original pfn record\n\tContextVirtualToPhysical(&g_PhysicalOpCR3);\n\tpCurrentRecord->OriginalPfn = pCurrentRecord->pPTE->PageFrameNumber;\n\tContextPhysicalToVirtual(&g_PhysicalOpCR3);\n\n\tMyPrint(_TitleAndFunc\"pCurrentRecord->OriginalPfn:%16IX\\n\", pCurrentRecord->OriginalPfn);\n\n\t//add hidden pfn record \n\t//allocate memory\n\t//record the physical address\n\t//then free the memory and mark it as bad\n\tPVOID\tTemporaryVirtual = MmAllocateNonCachedMemory(PAGE_SIZE);\n\tif (TemporaryVirtual == NULL)\n\t\tgoto Lable_Error;\n\n\tPHYSICAL_ADDRESS\tTemporaryPhysical = MmGetPhysicalAddress(TemporaryVirtual);\n\tLARGE_INTEGER\t\tPhysicalLength = { 0 };\n\tPhysicalLength.QuadPart = PAGE_SIZE;\n\n\tpCurrentRecord->HiddenPfn = pPhysicalAddresstoPTEPFN((PVOID)(TemporaryPhysical.QuadPart));\n\tMyPrint(_TitleAndFunc\"pCurrentRecord->HiddenPfn:%16IX\\n\", pCurrentRecord->HiddenPfn);\n\n\tMmFreeNonCachedMemory(TemporaryVirtual, PAGE_SIZE);\n\n\tStatus = MmMarkPhysicalMemoryAsBad(&TemporaryPhysical, &PhysicalLength);\n\n\t//copy codes to the new non-mapped physical address\n\tContextVirtualToPhysical(&g_PhysicalOpCR3);\n\tRtlCopyMemory((PVOID)(TemporaryPhysical.QuadPart),\n\t\tpCurrentRecord->pHiddenBase,\n\t\tPAGE_SIZE\n\t);\n\tContextPhysicalToVirtual(&g_PhysicalOpCR3);\n\n\t//check the mark state\n\tif (!NT_SUCCESS(Status))\n\t\tgoto Lable_Error;\n\n\t//the last step:count +1\n\tpHiddenPageRecord->Count++;\n\n\t//release spin lock\n\tKeReleaseSpinLock(&pHiddenPageRecord->SpinLock, EntryIrql);\n\treturn STATUS_SUCCESS;\n\nLable_Error:\n\tKeReleaseSpinLock(&pHiddenPageRecord->SpinLock, EntryIrql);\n\treturn STATUS_UNSUCCESSFUL;\n}\n\n/*********************************************************\nfunction:\t\tRemoveAndRestoreAllHiddenPageRecord\ndescription:\tremove and restore all the records of the structure\n\t\t\t\tinclude mark hidden physical memory as good,\n\t\t\t\tchange mapping relations,\n\t\t\t\tand invalid the specific TLB\n\ncalls:\t\t\tKeAcquireSpinLock\n\t\t\t\tpPTEPFNtoPhysicalAddress\n\t\t\t\tMmMarkPhysicalMemoryAsGood\n\t\t\t\tContextVirtualToPhysical\n\t\t\t\tContextPhysicalToVirtual\n\t\t\t\t__invlpg\n\t\t\t\tKeReleaseSpinLock\n**********************************************************/\nNTSTATUS RemoveAndRestoreAllHiddenPageRecord(PHIDDEN_PAGE_RECORD pHiddenPageRecord)\n{\n\tKIRQL\t\tEntryIrql;\n\tNTSTATUS\tStatus = STATUS_UNSUCCESSFUL;\n\t//prevent mulit-thread change the page record count\n\tKeAcquireSpinLock(&pHiddenPageRecord->SpinLock, &EntryIrql);\n\n\t//assert we have elements\n\tif (pHiddenPageRecord->Count == 0)\n\t\tgoto Lable_Error;\n\n\t//restore all records and mark all the hidden physical memory as good\n\tPSPECIFIC_HIDDEN_PAGE_RECORD\tpCurrentRecord = NULL;\n\tPHYSICAL_ADDRESS\t\t\t\tCurrentHiddenPhysical = { 0 };\n\tLARGE_INTEGER\t\t\t\t\tPhysicalLength = { 0 };\n\n\tPhysicalLength.QuadPart = PAGE_SIZE;\n\n\tfor (int i = 0; i < pHiddenPageRecord->Count; i++)\n\t{\n\t\tpCurrentRecord = &pHiddenPageRecord->Record[i];\n\t\tCurrentHiddenPhysical.QuadPart = (ULONG64)pPTEPFNtoPhysicalAddress(pCurrentRecord->HiddenPfn);\n\n\t\t//mark it as good\n\t\tMmMarkPhysicalMemoryAsGood(&CurrentHiddenPhysical, &PhysicalLength);\n\n\t\t//restore all page mapping relations\n\t\tContextVirtualToPhysical(&g_PhysicalOpCR3);\n\t\tpCurrentRecord->pPTE->PageFrameNumber = pCurrentRecord->OriginalPfn;\n\t\tContextPhysicalToVirtual(&g_PhysicalOpCR3);\n\n\t\t//invalid the TLB of current hidden address\n\t\t__invlpg(pCurrentRecord->pHiddenBase);\n\t}\n\n\t//set count to zero\n\tpHiddenPageRecord->Count = 0;\n\n\t//release spin lock\n\tKeReleaseSpinLock(&pHiddenPageRecord->SpinLock, EntryIrql);\n\treturn STATUS_SUCCESS;\n\nLable_Error:\n\tKeReleaseSpinLock(&pHiddenPageRecord->SpinLock, EntryIrql);\n\treturn STATUS_UNSUCCESSFUL;\n}\n\n/*********************************************************\nfunction:\t\tContextOriginalToHidden\ndescription:\tswitch to hidden code,so that we can call our hidden functions\n\ncalls:\t\t\tKeGetCurrentIrql\n\t\t\t\tKeRaiseIrqlToDpcLevel\n\t\t\t\t_disable\n\t\t\t\tKeAcquireSpinLock\n\t\t\t\tContextVirtualToPhysical\n\t\t\t\tContextPhysicalToVirtual\n\t\t\t\t__invlpg\n\t\t\t\tKeReleaseSpinLock\n**********************************************************/\nNTSTATUS ContextOriginalToHidden(PHIDDEN_PAGE_RECORD pHiddenPageRecord)\n{\n\tKIRQL\t\tEntryIrql;\n\tNTSTATUS\tStatus = STATUS_UNSUCCESSFUL;\n\n\t//record original irql\n\tpHiddenPageRecord->OriginalIrql = KeGetCurrentIrql();\n\tMyPrint(_TitleAndFunc\"pHiddenPageRecord->OriginalIrql:%16IX\\n\", pHiddenPageRecord->OriginalIrql);\n\n\t//assert irql >= dispatch level\n\tif (pHiddenPageRecord->OriginalIrql < DISPATCH_LEVEL)\n\t{\n\t\tpHiddenPageRecord->IsIrqlChanged = TRUE;\n\t\tKeRaiseIrqlToDpcLevel();\n\t}\n\n\t//disable task switch interrupt(maskable)\n\t_disable();\n\n\t//prevent mulit-thread change the page record count\n\tKeAcquireSpinLock(&pHiddenPageRecord->SpinLock, &EntryIrql);\n\n\t//assert we have elements\n\tif (pHiddenPageRecord->Count == 0)\n\t\tgoto Lable_Error;\n\n\t//check the initialize state and current hidden state\n\tif (!g_IsHiddenOpInit || pHiddenPageRecord->IsHidden)\n\t\tgoto Lable_Error;\n\n\t//restore all records and mark all the hidden physical memory as good\n\tPSPECIFIC_HIDDEN_PAGE_RECORD\tpCurrentRecord = NULL;\n\n\tfor (int i = 0; i < pHiddenPageRecord->Count; i++)\n\t{\n\t\tpCurrentRecord = &pHiddenPageRecord->Record[i];\n\n\t\t//change all page mapping relations\n\t\tContextVirtualToPhysical(&g_PhysicalOpCR3);\n\t\tpCurrentRecord->pPTE->PageFrameNumber = pCurrentRecord->HiddenPfn;\n\t\tContextPhysicalToVirtual(&g_PhysicalOpCR3);\n\n\t\t//invalid the TLB of current hidden address\n\t\t__invlpg(pCurrentRecord->pHiddenBase);\n\t}\n\n\tKeReleaseSpinLock(&pHiddenPageRecord->SpinLock, EntryIrql);\n\n\t//change the flag IsHidden\n\tpHiddenPageRecord->IsHidden = TRUE;\n\treturn STATUS_SUCCESS;\n\nLable_Error:\n\tKeReleaseSpinLock(&pHiddenPageRecord->SpinLock, EntryIrql);\n\treturn STATUS_UNSUCCESSFUL;\n}\n\n/*********************************************************\nfunction:\t\tContextOriginalToHidden\ndescription:\tswitch to hidden code,so that we can call our hidden functions\n\ncalls:\t\t\tKeAcquireSpinLock\n\t\t\t\tContextVirtualToPhysical\n\t\t\t\tContextPhysicalToVirtual\n\t\t\t\t__invlpg\n\t\t\t\tKeReleaseSpinLock\n\t\t\t\t_enable\n\t\t\t\tKeLowerIrql\n**********************************************************/\nNTSTATUS ContextHiddenToOriginal(PHIDDEN_PAGE_RECORD pHiddenPageRecord)\n{\n\tKIRQL\t\tEntryIrql;\n\tNTSTATUS\tStatus = STATUS_UNSUCCESSFUL;\n\n\t//prevent mulit-thread change the page record count\n\tKeAcquireSpinLock(&pHiddenPageRecord->SpinLock, &EntryIrql);\n\n\t//assert we have elements\n\tif (pHiddenPageRecord->Count == 0)\n\t\tgoto Lable_Error;\n\n\t//check the initialize state and current hidden state\n\tif (!g_IsHiddenOpInit || !pHiddenPageRecord->IsHidden)\n\t\tgoto Lable_Error;\n\n\t//restore all records and mark all the hidden physical memory as good\n\tPSPECIFIC_HIDDEN_PAGE_RECORD\tpCurrentRecord = NULL;\n\n\tfor (int i = 0; i < pHiddenPageRecord->Count; i++)\n\t{\n\t\tpCurrentRecord = &pHiddenPageRecord->Record[i];\n\n\t\t//change all page mapping relations\n\t\tContextVirtualToPhysical(&g_PhysicalOpCR3);\n\t\tpCurrentRecord->pPTE->PageFrameNumber = pCurrentRecord->OriginalPfn;\n\t\tContextPhysicalToVirtual(&g_PhysicalOpCR3);\n\n\t\t//invalid the TLB of current hidden address\n\t\t__invlpg(pCurrentRecord->pHiddenBase);\n\t}\n\n\tKeReleaseSpinLock(&pHiddenPageRecord->SpinLock, EntryIrql);\n\n\t//enable task switch interrupt(maskable)\n\t_enable();\n\n\t//restore irql\n\tMyPrint(_TitleAndFunc\"pHiddenPageRecord->IsIrqlChanged:%16IX\\n\", pHiddenPageRecord->IsIrqlChanged);\n\tif (pHiddenPageRecord->IsIrqlChanged)\n\t{\n\t\tKeLowerIrql(pHiddenPageRecord->OriginalIrql);\n\n\t\t//restore the flag IsIrqlChanged\n\t\tpHiddenPageRecord->IsIrqlChanged = FALSE;\n\t}\n\n\t//change the flag IsHidden\n\tpHiddenPageRecord->IsHidden = FALSE;\n\treturn STATUS_SUCCESS;\n\nLable_Error:\n\tKeReleaseSpinLock(&pHiddenPageRecord->SpinLock, EntryIrql);\n\treturn STATUS_UNSUCCESSFUL;\n}\n\n/*********************************************************\nfunction:\t\tGetPagesCountByLength\ndescription:\tget pages count by length\n**********************************************************/\nULONG64 GetPagesCountByLength(ULONG64 Length)\n{\n\tif ((Length & 0xFFF) == 0)\n\t\treturn (Length >> 12);\n\telse\n\t\treturn (Length >> 12) + 1;\n}\n\n/*********************************************************\nfunction:\t\tAddHiddenSection\ndescription:\tadd hidden address by the offered section name\n\t\t\t\tif all the calls of AddHiddenPageRecord are successful,return STATUS_SUCCESS\ncalls:\t\t\tGetSegmentStartAddress\n\t\t\t\tGetSegmentLength\n\t\t\t\tGetPagesCountByLength\n\t\t\t\tAddHiddenPageRecord\n**********************************************************/\nNTSTATUS AddHiddenSection(ULONG64 SystemCR3, PDRIVER_OBJECT pDriverObj, PCHAR pSegName, PHIDDEN_PAGE_RECORD pHiddenPageRecord)\n{\n\t//analyse number of pages of the section \n\tPVOID\t\tpSectionStart = (PVOID)GetSegmentStartAddress(pDriverObj, pSegName);\n\tULONG64\t\tSectionLength = GetSegmentLength(pDriverObj, pSegName);\n\tULONG64\t\tPagesCount = GetPagesCountByLength(SectionLength);\n\tPVOID\t\tpCurrentPage = NULL;\n\tNTSTATUS\tStatus = STATUS_UNSUCCESSFUL;\n\n\tMyPrint(_TitleAndFunc\"pSectionStart:%16IX\\n\", pSectionStart);\n\tMyPrint(_TitleAndFunc\"SectionLength:%16IX\\n\", SectionLength);\n\tMyPrint(_TitleAndFunc\"PagesCount:%16IX\\n\", PagesCount);\n\n\t//call AddHiddenPageRecord to record the hidden info\n\tfor (int i = 0; i < PagesCount; i++)\n\t{\n\t\tpCurrentPage = (PVOID)((ULONG64)pSectionStart + i * PAGE_SIZE);\n\t\tStatus = AddHiddenPageRecord(SystemCR3, pCurrentPage, pHiddenPageRecord);\n\n\t\t//make sure all the records are successful\n\t\tif (!NT_SUCCESS(Status))\n\t\t\treturn Status;\n\t}\n\n\treturn STATUS_SUCCESS;\n}"
  },
  {
    "path": "KernelHiddenExecute/HiddenExecute.h",
    "content": "#pragma once\n\n/*********************************************************\ndescription:\nnotice!!!\trun in IRQL >= DPC_LEVEL\n\t\t\tcall apis maybe due to lower irql\n\nin order to hidden real code in the non-mapped physical pages,and clear original codes\nbefore call the hidden functions,we should map the physical pages to correct position.\nif we have to call windows api in our hidden functions,we should call the transfer functions(not hidden)\n\nfeatures of transfer functions:check & change irql,restore & rewrite page table(pte),call specific apis\n\nreserve the physical pages by Api:MmMarkPhysicalMemoryAsBad,prevent the allocation of our physical pages space\n\n**********************************************************/\n\n#include <ntddk.h>\n#include <windef.h>\n\n#include \"DebugPrintEx.h\"\n#include \"PhysicalMemoryOperation.h\"\n#include \"SectionOperation.h\"\n\n\n//////////////////////////////////////////////////////////////////////////\n//macro utilities\n\n#define ChangeIrql(x)\t\t\t\tWriteCR8(x)\n#define ClearPageTableFlag(x)\t\tClearCR3Flag(x)\n\n\n//////////////////////////////////////////////////////////////////////////\n//constants and macros\n\n#define SECTION_NAME_HIDDEN_INSTRUCTIONS\t\".hi\"\n#define SECTION_NAME_HIDDEN_DATA\t\t\t\".hd\"\n#define HIDDEN_IRQL\t\t\t\t\t\t\tDISPATCH_LEVEL\n#define HIDDEN_PAGE_RECORD_LENGTH\t\t\t0x1000\n#define MAX_HIDDEN_PAGE_COUNT\t\t\t\t126\t\t\t\t\t//      (4096 - 40) / (4 * 8) = 126.75\n\n\n//////////////////////////////////////////////////////////////////////////\n//types\n\ntypedef struct _MMPTE\n{\n\tstruct /* bitfield */\n\t{\n\t\t/* 0x0000 */ unsigned __int64 Valid : 1; /* bit position: 0 */\n\t\t/* 0x0000 */ unsigned __int64 Dirty1 : 1; /* bit position: 1 */\n\t\t/* 0x0000 */ unsigned __int64 Owner : 1; /* bit position: 2 */\n\t\t/* 0x0000 */ unsigned __int64 WriteThrough : 1; /* bit position: 3 */\n\t\t/* 0x0000 */ unsigned __int64 CacheDisable : 1; /* bit position: 4 */\n\t\t/* 0x0000 */ unsigned __int64 Accessed : 1; /* bit position: 5 */\n\t\t/* 0x0000 */ unsigned __int64 Dirty : 1; /* bit position: 6 */\n\t\t/* 0x0000 */ unsigned __int64 LargePage : 1; /* bit position: 7 */\n\t\t/* 0x0000 */ unsigned __int64 Global : 1; /* bit position: 8 */\n\t\t/* 0x0000 */ unsigned __int64 CopyOnWrite : 1; /* bit position: 9 */\n\t\t/* 0x0000 */ unsigned __int64 Unused : 1; /* bit position: 10 */\n\t\t/* 0x0000 */ unsigned __int64 Write : 1; /* bit position: 11 */\n\t\t/* 0x0000 */ unsigned __int64 PageFrameNumber : 36; /* bit position: 12 */\n\t\t/* 0x0000 */ unsigned __int64 reserved1 : 4; /* bit position: 48 */\n\t\t/* 0x0000 */ unsigned __int64 SoftwareWsIndex : 11; /* bit position: 52 */\n\t\t/* 0x0000 */ unsigned __int64 NoExecute : 1; /* bit position: 63 */\n\t}; /* bitfield */\n} MMPTE, * PMMPTE; /* size: 0x0008 */\n\ntypedef struct _SPECIFIC_HIDDEN_PAGE_RECORD\n{\n\tPVOID\t\tpHiddenBase;\n\tPMMPTE\t\tpPTE;\n\tULONG64\t\tOriginalPfn;\n\tULONG64\t\tHiddenPfn;\n}SPECIFIC_HIDDEN_PAGE_RECORD, * PSPECIFIC_HIDDEN_PAGE_RECORD;\n\ntypedef struct _HIDDEN_PAGE_RECORD\n{\n\tBOOL\t\t\t\t\t\t\tIsHidden;\n\tKIRQL\t\t\t\t\t\t\tOriginalIrql;\n\tBOOL\t\t\t\t\t\t\tIsIrqlChanged;\n\tKSPIN_LOCK\t\t\t\t\t\tSpinLock;\n\tULONG64\t\t\t\t\t\t\tCount;\n\tSPECIFIC_HIDDEN_PAGE_RECORD\t\tRecord[MAX_HIDDEN_PAGE_COUNT - 1];\n}HIDDEN_PAGE_RECORD, * PHIDDEN_PAGE_RECORD;\n\n\n//////////////////////////////////////////////////////////////////////////\n//prototypes\n\n//undocumented kernel functions\nNTSYSAPI NTSTATUS MmMarkPhysicalMemoryAsBad(IN PPHYSICAL_ADDRESS, IN OUT PLARGE_INTEGER);\nNTSYSAPI NTSTATUS MmMarkPhysicalMemoryAsGood(IN PPHYSICAL_ADDRESS, IN OUT PLARGE_INTEGER);\n\n//functions\nNTSTATUS InitializeHiddenPageRecordStructure(PHIDDEN_PAGE_RECORD* ppHiddenPageRecord);\nNTSTATUS FreeHiddenPageRecordStructure(PHIDDEN_PAGE_RECORD pHiddenPageRecord);\n\n//private functions\nPVOID pPTEPFNtoPhysicalAddress(ULONG64 PFN);\nULONG64 pPhysicalAddresstoPTEPFN(PVOID PhysicalAddressBase);\nPMMPTE pGetSpecificAddresspPTEPhysical(ULONG64 CR3, PVOID pPageBase);\nPVOID pGetSpecificAddressPhysicalForR3(ULONG64 CR3, PVOID pVirtual);\nULONG64 GetPagesCountByLength(ULONG64 Length);\n\n//public functions\n//add page(s) to the hidden records\nNTSTATUS AddHiddenPageRecord(ULONG64 CR3, PVOID pHiddenPageBase, PHIDDEN_PAGE_RECORD pHiddenPageRecord);\nNTSTATUS AddHiddenSection(ULONG64 SystemCR3, PDRIVER_OBJECT pDriverObj, PCHAR pSegName, PHIDDEN_PAGE_RECORD pHiddenPageRecord);\nNTSTATUS RemoveAndRestoreAllHiddenPageRecord(PHIDDEN_PAGE_RECORD pHiddenPageRecord);\n//context swap\nNTSTATUS ContextOriginalToHidden(PHIDDEN_PAGE_RECORD pHiddenPageRecord);\nNTSTATUS ContextHiddenToOriginal(PHIDDEN_PAGE_RECORD pHiddenPageRecord);"
  },
  {
    "path": "KernelHiddenExecute/HiddenFunctions.c",
    "content": "#include \"HiddenFunctions.h\"\n\n\n//////////////////////////////////////////////////////////////////////////\n//functions\n\n//#pragma code_seg(SECTION_NAME_HIDDEN_INSTRUCTIONS)\n//NTSTATUS HiddenFunctionA(PHIDDEN_PAGE_RECORD pHiddenPageRecord)\n//{\n//\tNTSTATUS Status = STATUS_UNSUCCESSFUL;\n//\n//\tStatus = ApiTransfer_SimulateApi(pHiddenPageRecord, 0xFAFAFAFAFAFAFAFA);\n//\n//\treturn Status;\n//}\n//#pragma code_seg()\n\n#pragma code_seg(SECTION_NAME_HIDDEN_INSTRUCTIONS)\nBOOL HiddenFunction(PCHAR checkStr)\n{\n\tif (!checkStr)\n\t{\n\t\treturn FALSE;\n\t}\n\tCHAR validStr[64] = \"strongPassword\";\n\treturn strcmp(validStr, checkStr) == 0;//we are going to modify the equal operator\n}\n#pragma code_seg()\nBOOL UnsafeFunction(PCHAR checkStr)\n{\n\tif (!checkStr)\n\t{\n\t\treturn FALSE;\n\t}\n\tCHAR validStr[64] = \"strongPassword\";\n\treturn strcmp(validStr, checkStr) == 0;\n}\n\n#pragma data_seg(SECTION_NAME_HIDDEN_DATA)  \nchar HiddenData[4096] = \"normal data\";//we are going to hack the data\n#pragma data_seg() \n\nchar UnsafeData[4096] = \"normal data\";\n\n"
  },
  {
    "path": "KernelHiddenExecute/HiddenFunctions.h",
    "content": "#pragma once\n\n#include <ntddk.h>\n#include <windef.h>\n\n#include \"DebugPrintEx.h\"\n#include \"HiddenExecute.h\"\n#include \"HiddenCallApiTransfer.h\"\n\n//////////////////////////////////////////////////////////////////////////\n//prototypes\n\n//NTSTATUS HiddenFunctionA(PHIDDEN_PAGE_RECORD pHiddenPageRecord);\nBOOL HiddenFunction(PCHAR checkStr);\nBOOL UnsafeFunction(PCHAR checkStr);"
  },
  {
    "path": "KernelHiddenExecute/KernelHiddenExecute.inf",
    "content": ";\n; KernelHiddenExecute.inf\n;\n\n[Version]\nSignature=\"$WINDOWS NT$\"\nClass=System\nClassGuid={4d36e97d-e325-11ce-bfc1-08002be10318}\nProvider=XYLab\nDriverVer=\nCatalogFile=KernelHiddenExecute.cat\nPnpLockDown=1\n\n;[DestinationDirs]\n;DefaultDestDir = 12\n\n\n;[SourceDisksNames]\n;1 = %DiskName%,,,\"\"\n\n;[SourceDisksFiles]\n\n\n;[Manufacturer]\n;%ManufacturerName%=Standard,NT$ARCH$\n\n;[Standard.NT$ARCH$]\n\n\n[Strings]\nManufacturerName=\"XYLab\"\nClassName=\"\"\nDiskName=\"KernelHiddenExecute Source Disk\"\n"
  },
  {
    "path": "KernelHiddenExecute/KernelHiddenExecute.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"12.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|ARM\">\n      <Configuration>Debug</Configuration>\n      <Platform>ARM</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|ARM\">\n      <Configuration>Release</Configuration>\n      <Platform>ARM</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|ARM64\">\n      <Configuration>Debug</Configuration>\n      <Platform>ARM64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|ARM64\">\n      <Configuration>Release</Configuration>\n      <Platform>ARM64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}</ProjectGuid>\n    <TemplateGuid>{dd38f7fc-d7bd-488b-9242-7d8754cde80d}</TemplateGuid>\n    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\n    <MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>\n    <Configuration>Debug</Configuration>\n    <Platform Condition=\"'$(Platform)' == ''\">Win32</Platform>\n    <RootNamespace>KernelHiddenExecute</RootNamespace>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\n    <TargetVersion>Windows7</TargetVersion>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n    <DriverTargetPlatform>Desktop</DriverTargetPlatform>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\n    <TargetVersion>Windows7</TargetVersion>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n    <DriverTargetPlatform>Desktop</DriverTargetPlatform>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM64'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM64'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n    <EnableInf2cat>false</EnableInf2cat>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n    <EnableInf2cat>false</EnableInf2cat>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM64'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM64'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <ClCompile>\n      <WarningLevel>Level4</WarningLevel>\n    </ClCompile>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <ClCompile>\n      <TreatWarningAsError>false</TreatWarningAsError>\n    </ClCompile>\n    <Link>\n      <TreatLinkerWarningAsErrors>false</TreatLinkerWarningAsErrors>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <ClCompile>\n      <WarningLevel>Level4</WarningLevel>\n    </ClCompile>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <ClCompile>\n      <TreatWarningAsError>false</TreatWarningAsError>\n    </ClCompile>\n    <Link>\n      <TreatLinkerWarningAsErrors>false</TreatLinkerWarningAsErrors>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <Inf Include=\"KernelHiddenExecute.inf\" />\n  </ItemGroup>\n  <ItemGroup>\n    <FilesToPackage Include=\"$(TargetPath)\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"HiddenCallApiTransfer.c\" />\n    <ClCompile Include=\"HiddenExecute.c\" />\n    <ClCompile Include=\"HiddenFunctions.c\" />\n    <ClCompile Include=\"main.c\" />\n    <ClCompile Include=\"PhysicalMemoryOperation.c\" />\n    <ClCompile Include=\"SectionOperation.c\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"DebugPrintEx.h\" />\n    <ClInclude Include=\"HiddenCallApiTransfer.h\" />\n    <ClInclude Include=\"HiddenExecute.h\" />\n    <ClInclude Include=\"HiddenFunctions.h\" />\n    <ClInclude Include=\"main.h\" />\n    <ClInclude Include=\"PhysicalMemoryOperation.h\" />\n    <ClInclude Include=\"SectionOperation.h\" />\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>"
  },
  {
    "path": "KernelHiddenExecute/KernelHiddenExecute.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\n    </Filter>\n    <Filter Include=\"Driver Files\">\n      <UniqueIdentifier>{8E41214B-6785-4CFE-B992-037D68949A14}</UniqueIdentifier>\n      <Extensions>inf;inv;inx;mof;mc;</Extensions>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <Inf Include=\"KernelHiddenExecute.inf\">\n      <Filter>Driver Files</Filter>\n    </Inf>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"main.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"PhysicalMemoryOperation.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"SectionOperation.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"HiddenExecute.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"HiddenCallApiTransfer.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"HiddenFunctions.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"main.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"DebugPrintEx.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"PhysicalMemoryOperation.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"SectionOperation.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"HiddenExecute.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"HiddenCallApiTransfer.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"HiddenFunctions.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "KernelHiddenExecute/PhysicalMemoryOperation.c",
    "content": "#include \"PhysicalMemoryOperation.h\"\n\n\n//////////////////////////////////////////////////////////////////////////\n//global variables\n\nBOOL\tg_IsPhysicalOpInit = FALSE;\nHANDLE\tg_SectionHandle = NULL;\n\n\n//////////////////////////////////////////////////////////////////////////\n//functions\n\n/*********************************************************\nfunction:\t\tOpenPhysicalMemory\n\t\t\t\tpMapPhysicalMemoryPre\n\t\t\t\tMapPhysicalMemory\n\t\t\t\tUnmapPhysicalMemory\ndescription:\tuse map view of section to map physical address to virtual address\n**********************************************************/\nHANDLE OpenPhysicalMemory()\n{\n\tUNICODE_STRING\t\tphysmemString;\n\tOBJECT_ATTRIBUTES\tattributes;\n\tWCHAR\t\t\t\tphysmemName[] = L\"\\\\device\\\\physicalmemory\";\n\tNTSTATUS\t\t\tstatus;\n\tHANDLE\t\t\t\tphysmem;\n\tRtlInitUnicodeString(&physmemString, physmemName);\n\tInitializeObjectAttributes(&attributes, &physmemString, OBJ_CASE_INSENSITIVE, NULL, NULL);\n\tstatus = ZwOpenSection(&physmem, SECTION_ALL_ACCESS, &attributes);\n\tif (!NT_SUCCESS(status))\n\t{\n\t\treturn NULL;\n\t}\n\treturn physmem;\n}\nBOOLEAN pMapPhysicalMemoryPre(HANDLE hMemory, PDWORD64 pDwAddress, PSIZE_T pSize, PDWORD64 pDwVirtualAddress)\n{\n\tNTSTATUS ntStatus;\n\n\tLARGE_INTEGER viewBase;\n\t*pDwVirtualAddress = 0;\n\tviewBase.QuadPart = *pDwAddress;\n\tntStatus = ZwMapViewOfSection(hMemory, (HANDLE)-1, (void**)pDwVirtualAddress, 0L, *pSize, &viewBase, pSize, ViewShare, 0, PAGE_READWRITE | PAGE_NOCACHE);\n\tif (!NT_SUCCESS(ntStatus))\n\t\treturn FALSE;\n\t//*pDwAddress = viewBase.QuadPart;\n\treturn TRUE;\n}\nPVOID MapPhysicalMemory(PVOID PA, SIZE_T Size)\n{\n\tULONGLONG DwAddress = (ULONG64)PA;\n\tULONGLONG DwVirtualAddress = 0;\n\tBOOLEAN status = pMapPhysicalMemoryPre(g_SectionHandle, &DwAddress, &Size, &DwVirtualAddress);\n\treturn (status == TRUE) ? (PVOID)DwVirtualAddress : NULL;\n}\nBOOLEAN UnmapPhysicalMemory(PVOID VA)\n{\n\tif (!ZwUnmapViewOfSection((HANDLE)-1, VA))\n\t\treturn TRUE;\n\telse\n\t\treturn FALSE;\n}\n\n/*********************************************************\nfunction:\t\tGetCR3Flag\ndescription:\tget cr3 flag, only save the flag bits\n**********************************************************/\nULONG64 GetCR3Flag(ULONG64 CR3)\n{\n\treturn (CR3 & CR3_FLAG_ALL_BITS);\n}\n\n/*********************************************************\nfunction:\t\tClearCR3Flag\ndescription:\tclear cr3 flag, only clear the flag bits\n**********************************************************/\nULONG64 ClearCR3Flag(ULONG64 CR3)\n{\n\treturn (CR3 & ~CR3_FLAG_ALL_BITS);\n}\n\n/*********************************************************\nfunction:\t\tpPrintPhysicalOpStructure\ndescription:\tprint the structure elements\n**********************************************************/\nVOID pPrintPhysicalOpStructure(PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\tMyPrint(_TitleAndFunc\"[PrintStart]\\n\");\n\n\tMyPrint(_TitleAndFunc\"pPhysicalOpCR3->pAllocVA_PML4T:%16IX\\n\", pPhysicalOpCR3->pAllocVA_PML4T);\n\tMyPrint(_TitleAndFunc\"pPhysicalOpCR3->pAllocPA_PML4T:%16IX\\n\", pPhysicalOpCR3->pAllocPA_PML4T);\n\n\tMyPrint(_TitleAndFunc\"pPhysicalOpCR3->pAllocVA_PDPT:%16IX\\n\", pPhysicalOpCR3->pAllocVA_PDPT);\n\tMyPrint(_TitleAndFunc\"pPhysicalOpCR3->pAllocPA_PDPT:%16IX\\n\", pPhysicalOpCR3->pAllocPA_PDPT);\n\n\tMyPrint(_TitleAndFunc\"pPhysicalOpCR3->pSystemPML4TMap:%16IX\\n\", pPhysicalOpCR3->pSystemPML4TMap);\n\n\tMyPrint(_TitleAndFunc\"pPhysicalOpCR3->CR3Generated:%16IX\\n\", pPhysicalOpCR3->CR3Generated);\n\n\tMyPrint(_TitleAndFunc\"[PrintEnd]\\n\");\n}\n\n/*********************************************************\nfunction:\t\tpFreePhysicalOpPageTableMemory\ndescription:\tto free the allocated memory (PML4T and PDPT page table) with null pointer check\n**********************************************************/\nNTSTATUS pFreePhysicalOpPageTableMemory(PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\tif (pPhysicalOpCR3->pAllocVA_PML4T != NULL)\n\t{\n\t\tMmFreeNonCachedMemory(pPhysicalOpCR3->pAllocVA_PML4T, PAGE_TABLE_SIZE);\n\t\tpPhysicalOpCR3->pAllocVA_PML4T = NULL;\n\t\tpPhysicalOpCR3->pAllocPA_PML4T = NULL;\n\t}\n\n\tif (pPhysicalOpCR3->pAllocVA_PDPT != NULL)\n\t{\n\t\tMmFreeNonCachedMemory(pPhysicalOpCR3->pAllocVA_PDPT, PAGE_TABLE_SIZE);\n\t\tpPhysicalOpCR3->pAllocVA_PDPT = NULL;\n\t\tpPhysicalOpCR3->pAllocPA_PDPT = NULL;\n\t}\n\n\treturn STATUS_SUCCESS;\n}\n\n\n/*********************************************************\nfunction:\t\tpAllocPhysicalOpPageTableMemory\ndescription:\tto allocate memory (PML4T and PDPT page table)\n\t\t\t\tif the allocate procduce failed,it can free all the allocated pages\ncalls:\t\t\tMmAllocateNonCachedMemory\n\t\t\t\tMmGetPhysicalAddress\n\t\t\t\tpFreePhysicalOpPageTableMemory\n**********************************************************/\nNTSTATUS pAllocPhysicalOpPageTableMemory(PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\t//PML4T\n\tpPhysicalOpCR3->pAllocVA_PML4T = MmAllocateNonCachedMemory(PAGE_TABLE_SIZE);\n\t//check allocate state\n\tif (pPhysicalOpCR3->pAllocVA_PML4T == NULL)\n\t\tgoto Lable_Error;\n\tpPhysicalOpCR3->pAllocPA_PML4T = (PVOID)MmGetPhysicalAddress(pPhysicalOpCR3->pAllocVA_PML4T).QuadPart;\n\n\n\t//PDPT\n\tpPhysicalOpCR3->pAllocVA_PDPT = MmAllocateNonCachedMemory(PAGE_TABLE_SIZE);\n\t//check allocate state\n\tif (pPhysicalOpCR3->pAllocVA_PDPT == NULL)\n\t\tgoto Lable_Error;\n\tpPhysicalOpCR3->pAllocPA_PDPT = (PVOID)MmGetPhysicalAddress(pPhysicalOpCR3->pAllocVA_PDPT).QuadPart;\n\n\n\treturn STATUS_SUCCESS;\nLable_Error:\n\t//free allocated memory\n\tpFreePhysicalOpPageTableMemory(pPhysicalOpCR3);\n\treturn STATUS_UNSUCCESSFUL;\n}\n\n/*********************************************************\nfunction:\t\tpMapPML4T\ndescription:\tmap the system cr3(pml4t) to virtual address\ncalls:\t\t\tClearCR3Flag\n\t\t\t\tOpenPhysicalMemory\n\t\t\t\tMapPhysicalMemory\n**********************************************************/\nNTSTATUS pMapSystemPML4T(ULONG64 SystemCR3, PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\tULONG64 SystemCR3NonFlag = ClearCR3Flag(SystemCR3);\n\tPVOID\tpSystemPML4T = (PVOID)SystemCR3NonFlag;\n\n\tif (g_SectionHandle == NULL)\n\t\tg_SectionHandle = OpenPhysicalMemory();\n\n\tpPhysicalOpCR3->pSystemPML4TMap = MapPhysicalMemory(pSystemPML4T, PAGE_TABLE_SIZE);\n\n\treturn pPhysicalOpCR3->pSystemPML4TMap == NULL ? STATUS_UNSUCCESSFUL : STATUS_SUCCESS;\n}\n\n/*********************************************************\nfunction:\t\tpUnmapSystemPML4T\ndescription:\tunmap the system cr3(pml4t)\ncalls:\t\t\tOpenPhysicalMemory\n\t\t\t\tUnmapPhysicalMemory\n**********************************************************/\nNTSTATUS pUnmapSystemPML4T(PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\tif (g_SectionHandle == NULL)\n\t\tg_SectionHandle = OpenPhysicalMemory();\n\n\tBOOL\tState = UnmapPhysicalMemory(pPhysicalOpCR3->pSystemPML4TMap);\n\tif (State)\n\t\tpPhysicalOpCR3->pSystemPML4TMap = NULL;\n\n\tif (g_SectionHandle != NULL)\n\t\tZwClose(g_SectionHandle);\n\n\treturn !State ? STATUS_UNSUCCESSFUL : STATUS_SUCCESS;\n}\n\n/*********************************************************\nfunction:\t\tpFillGeneratedPML4TandPDPT\ndescription:\tfill the pml4t table,genarate the first large page entry and copy the system space map\n\t\t\t\tfill the pdpt table point to the physical address,every PDPTE point to a 1G-byte page(512G in total)\ncalls:\t\t\tRtlCopyMemory\n**********************************************************/\nNTSTATUS pFillGeneratedPML4TandPDPT(PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\t//copy the system space map\n\tPVOID\t\tpSystemStart = (PVOID)VA_SYSTEM_START;\n\tULONG64\t\tSystemPML4TStart = ((PMMVA)&pSystemStart)->PML4T;\n\n\tMyPrint(_TitleAndFunc\"SystemPML4TStart:%16X\\n\", SystemPML4TStart);\n\tRtlCopyMemory((PVOID)((ULONG64)pPhysicalOpCR3->pAllocVA_PML4T + SystemPML4TStart * ENTRY_SIZE),\n\t\t(PVOID)((ULONG64)pPhysicalOpCR3->pSystemPML4TMap + SystemPML4TStart * ENTRY_SIZE),\n\t\t(MAX_ENTRY_COUNT - SystemPML4TStart) * ENTRY_SIZE\n\t);\n\n\t//make the first address point to my PDPT table\n\t*(PULONG64)pPhysicalOpCR3->pAllocVA_PML4T = (ULONG64)pPhysicalOpCR3->pAllocPA_PDPT | PAGE_TABLE_PML4T_FLAG;\n\n\t//fill the PDPT page table\n\t//add flag\n\tULONG64 CurrentPDPTEntry = PAGE_TABLE_PDPT_FLAG;\n\tfor (int i = 0; i < MAX_ENTRY_COUNT; i++)\n\t{\n\t\t//change pfn\n\t\t((PMMPDPTE)&CurrentPDPTEntry)->PageFrameNumber = i;\n\t\t//\n\t\t*(PULONG64)((ULONG64)pPhysicalOpCR3->pAllocVA_PDPT + i * ENTRY_SIZE) = CurrentPDPTEntry;\n\t}\n\treturn STATUS_SUCCESS;\n}\n/*********************************************************\nfunction:\t\tCreatePhysicalOpCR3BySystemCR3\ndescription:\tto initialize the physical memory operation structure\ncalls:\t\t\tpAllocPhysicalOpPageTableMemory\n\t\t\t\tpMapSystemPML4T\n\t\t\t\tpFillGeneratedPML4TandPDPT\n\t\t\t\tpMapPML4T\n\t\t\t\tGetCR3Flag\n**********************************************************/\nNTSTATUS CreatePhysicalOpCR3BySystemCR3(ULONG64 SystemCR3, PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\t//check the init state\n\tif (g_IsPhysicalOpInit)\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\n\t//allocate page table memory and fill the structure\n\tif (!NT_SUCCESS(pAllocPhysicalOpPageTableMemory(pPhysicalOpCR3)))\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\t//map pSystemPML4T to virtual address and fill the structure\n\tif (!NT_SUCCESS(pMapSystemPML4T(SystemCR3, pPhysicalOpCR3)))\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\t//fill PML4T and PDPT page table\n\tif (!NT_SUCCESS(pFillGeneratedPML4TandPDPT(pPhysicalOpCR3)))\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\t//generate new cr3 for reading the physical memory and add cr3 flag\n\tULONG64\tSystemCR3Flag = GetCR3Flag(SystemCR3);\n\tpPhysicalOpCR3->CR3Generated = (ULONG64)pPhysicalOpCR3->pAllocPA_PML4T | SystemCR3Flag;\n\n\t//fill the structure part:CR3System\n\tpPhysicalOpCR3->CR3System = SystemCR3;\n\n\t//print structure\n\tpPrintPhysicalOpStructure(pPhysicalOpCR3);\n\n\tg_IsPhysicalOpInit = TRUE;\n\treturn STATUS_SUCCESS;\n}\n\n\n/*********************************************************\nfunction:\t\tFreePhysicalOpCR3\ndescription:\tto uninitialize the physical memory operation structure\ncalls:\t\t\tpUnmapSystemPML4T\n\t\t\t\tpFreePhysicalOpPageTableMemory\n\t\t\t\tRtlZeroMemory\n**********************************************************/\nNTSTATUS FreePhysicalOpCR3(PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\t//check the init state\n\tif (!g_IsPhysicalOpInit)\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\t//unmap pSystemPML4T\n\tpUnmapSystemPML4T(pPhysicalOpCR3);\n\n\t//free allocated memory\n\tpFreePhysicalOpPageTableMemory(pPhysicalOpCR3);\n\n\t//clear generated cr3 and recorded system cr3\n\tpPhysicalOpCR3->CR3Generated = 0;\n\tpPhysicalOpCR3->CR3System = 0;\n\n\t//print structure\n\tpPrintPhysicalOpStructure(pPhysicalOpCR3);\n\n\t// set the structure to zero,avoid some bugs\n\tRtlZeroMemory((PVOID)pPhysicalOpCR3, sizeof(PHYSICAL_OP_CR3));\n\n\n\tg_IsPhysicalOpInit = FALSE;\n\treturn STATUS_SUCCESS;\n}\n\n/*********************************************************\nfunction:\t\tContextVirtualToPhysical\ndescription:\traise irql and switch to generated cr3\n**********************************************************/\nNTSTATUS ContextVirtualToPhysical(PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\t//check the initialize state and current context\n\tif (!g_IsPhysicalOpInit || pPhysicalOpCR3->IsContextSwitched)\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\t//assert irql >= dispatch level\n\tpPhysicalOpCR3->OriginalIrql = KeGetCurrentIrql();\n\tif (pPhysicalOpCR3->OriginalIrql < DISPATCH_LEVEL)\n\t{\n\t\tpPhysicalOpCR3->IsIrqlChanged = TRUE;\n\t\tKeRaiseIrqlToDpcLevel();\n\t}\n\n\n\t//disable task switch interrupt(maskable)\n\t_disable();\n\n\n\t//record and switch cr3\n\tpPhysicalOpCR3->CR3BeforeSwitch = __readcr3();\n\t__writecr3(pPhysicalOpCR3->CR3Generated);\n\n\t//change the flag IsContextSwitched\n\tpPhysicalOpCR3->IsContextSwitched = TRUE;\n\treturn STATUS_SUCCESS;\n}\n\n/*********************************************************\nfunction:\t\tContextPhysicalToVirtual\ndescription:\tlower irql and switch to system cr3\n**********************************************************/\nNTSTATUS ContextPhysicalToVirtual(PPHYSICAL_OP_CR3 pPhysicalOpCR3)\n{\n\t//check the initialize state and current context\n\tif (!g_IsPhysicalOpInit || !pPhysicalOpCR3->IsContextSwitched)\n\t\treturn STATUS_UNSUCCESSFUL;\n\n\t//restore cr3\n\t__writecr3(pPhysicalOpCR3->CR3BeforeSwitch);\n\n\t//enable task switch interrupt(maskable)\n\t_enable();\n\n\t//restore irql\n\tif (pPhysicalOpCR3->IsIrqlChanged)\n\t{\n\t\tKeLowerIrql(pPhysicalOpCR3->OriginalIrql);\n\n\t\t//restore the flag IsIrqlChanged\n\t\tpPhysicalOpCR3->IsIrqlChanged = FALSE;\n\t}\n\n\t//change the flag IsContextSwitched\n\tpPhysicalOpCR3->IsContextSwitched = FALSE;\n\treturn STATUS_SUCCESS;\n}\n\n\n/*********************************************************\nfunction:\t\tGetCR3ByEprocess\ndescription:\tget cr3 by eprocess\n**********************************************************/\nULONG64 GetCR3ByEprocess(PEPROCESS pEProc)\n{\n\tif (pEProc == NULL)\n\t\treturn 0;\n\n\t//get dirbase\n\tULONG64\tDirBase = *(PULONG64)((ULONG64)pEProc + 0x028);\n\treturn DirBase;\n}\n\n/*********************************************************\nfunction:\t\tGetEProcess\ndescription:\tget eprocess by pid\n**********************************************************/\nPEPROCESS GetEProcess(ULONG64 PID)\n{\n\tPEPROCESS\t\tpEProc = NULL;\n\n\t//check pid\n\tif (PID == 0)\n\t\treturn 0;\n\n\t//get eprocess\n\tif (!NT_SUCCESS(PsLookupProcessByProcessId((HANDLE)PID, (PEPROCESS*)&pEProc)))\n\t\treturn 0;\n\n\t//dereference\n\tif (pEProc != NULL)\n\t\tObDereferenceObject((PVOID)pEProc);\n\n\treturn pEProc;\n}\n\n/*********************************************************\nfunction:\t\tGetCR3ByPID\ndescription:\tget cr3 by pid\ncalls:\t\t\tGetEProcess\n\t\t\t\tGetCR3ByEprocess\n**********************************************************/\nULONG64 GetCR3ByPID(ULONG64 PID)\n{\n\treturn GetCR3ByEprocess(GetEProcess(PID));\n}"
  },
  {
    "path": "KernelHiddenExecute/PhysicalMemoryOperation.h",
    "content": "#pragma once\n\n#include <ntddk.h>\n//#include <ntifs.h>\n#include <windef.h>\n#include <intrin.h>\n\n#include \"DebugPrintEx.h\"\n\n\n//////////////////////////////////////////////////////////////////////////\n//constants and macros\n\n#define\tPAGE_TABLE_SIZE\t\t\t0x1000\n#define\tCR3_FLAG_ALL_BITS\t\t\t0xFFF0000000000FFF\n#define\tPAGE_TABLE_PML4T_FLAG\t0x867\t//1000 0110 0111\n#define\tPAGE_TABLE_PDPT_FLAG\t0x9E7\t//1001 1110 0111\n#define VA_SYSTEM_START\t\t\t0xFFFF080000000000 //IA64\n#define MAX_ENTRY_COUNT\t\t\t512\n#define ENTRY_SIZE\t\t\t\tsizeof(ULONG64)\n\n\n//////////////////////////////////////////////////////////////////////////\n//types\n\ntypedef struct _PHYSICAL_OP_CR3\n{\n\tPVOID\tpAllocVA_PML4T;\n\tPVOID\tpAllocPA_PML4T;\n\n\tPVOID\tpAllocVA_PDPT;\n\tPVOID\tpAllocPA_PDPT;\n\n\tPVOID\tpSystemPML4TMap;\n\n\tULONG64\tCR3Generated;\n\tULONG64 CR3System;\n\n\tULONG64 CR3BeforeSwitch;\n\tBOOL\tIsContextSwitched;\n\tBOOL\tIsIrqlChanged;\n\tKIRQL\tOriginalIrql;//available if the IsIrqlChanged is true\n}PHYSICAL_OP_CR3, * PPHYSICAL_OP_CR3;\n\ntypedef struct _MMPDPTE\n{\n\tstruct /* bitfield */\n\t{\n\t\t/* 0x0000 */ unsigned __int64 Valid : 1; /* bit position: 0 */\n\t\t/* 0x0000 */ unsigned __int64 Dirty1 : 1; /* bit position: 1 */\n\t\t/* 0x0000 */ unsigned __int64 Owner : 1; /* bit position: 2 */\n\t\t/* 0x0000 */ unsigned __int64 WriteThrough : 1; /* bit position: 3 */\n\t\t/* 0x0000 */ unsigned __int64 CacheDisable : 1; /* bit position: 4 */\n\t\t/* 0x0000 */ unsigned __int64 Accessed : 1; /* bit position: 5 */\n\t\t/* 0x0000 */ unsigned __int64 Dirty : 1; /* bit position: 6 */\n\t\t/* 0x0000 */ unsigned __int64 LargePage : 1; /* bit position: 7 */\n\t\t/* 0x0000 */ unsigned __int64 Global : 1; /* bit position: 8 */\n\t\t/* 0x0000 */ unsigned __int64 CopyOnWrite : 1; /* bit position: 9 */\n\t\t/* 0x0000 */ unsigned __int64 Unused : 1; /* bit position: 10 */\n\t\t/* 0x0000 */ unsigned __int64 Write : 1; /* bit position: 11 */\n\t\t/* 0x0000 */ unsigned __int64 reserved0 : 18; /* bit position: 12 */\n\t\t/* 0x0000 */ unsigned __int64 PageFrameNumber : 18; /* bit position: 30 */\n\t\t/* 0x0000 */ unsigned __int64 reserved1 : 4; /* bit position: 48 */\n\t\t/* 0x0000 */ unsigned __int64 SoftwareWsIndex : 11; /* bit position: 52 */\n\t\t/* 0x0000 */ unsigned __int64 NoExecute : 1; /* bit position: 63 */\n\t}; /* bitfield */\n} MMPDPTE, * PMMPDPTE; /* size: 0x0008 */\n\ntypedef struct _MMPDE\n{\n\tstruct /* bitfield */\n\t{\n\t\t/* 0x0000 */ unsigned __int64 Valid : 1; /* bit position: 0 */\n\t\t/* 0x0000 */ unsigned __int64 Dirty1 : 1; /* bit position: 1 */\n\t\t/* 0x0000 */ unsigned __int64 Owner : 1; /* bit position: 2 */\n\t\t/* 0x0000 */ unsigned __int64 WriteThrough : 1; /* bit position: 3 */\n\t\t/* 0x0000 */ unsigned __int64 CacheDisable : 1; /* bit position: 4 */\n\t\t/* 0x0000 */ unsigned __int64 Accessed : 1; /* bit position: 5 */\n\t\t/* 0x0000 */ unsigned __int64 Dirty : 1; /* bit position: 6 */\n\t\t/* 0x0000 */ unsigned __int64 LargePage : 1; /* bit position: 7 */\n\t\t/* 0x0000 */ unsigned __int64 Global : 1; /* bit position: 8 */\n\t\t/* 0x0000 */ unsigned __int64 CopyOnWrite : 1; /* bit position: 9 */\n\t\t/* 0x0000 */ unsigned __int64 Unused : 1; /* bit position: 10 */\n\t\t/* 0x0000 */ unsigned __int64 Write : 1; /* bit position: 11 */\n\t\t/* 0x0000 */ unsigned __int64 reserved0 : 9; /* bit position: 12 */\n\t\t/* 0x0000 */ unsigned __int64 PageFrameNumber : 27; /* bit position: 21 */\n\t\t/* 0x0000 */ unsigned __int64 reserved1 : 4; /* bit position: 48 */\n\t\t/* 0x0000 */ unsigned __int64 SoftwareWsIndex : 11; /* bit position: 52 */\n\t\t/* 0x0000 */ unsigned __int64 NoExecute : 1; /* bit position: 63 */\n\t}; /* bitfield */\n} MMPDE, * PMMPDE; /* size: 0x0008 */\n\ntypedef struct _MMVA\n{\n\tstruct /* bitfield */\n\t{\n\t\t/* 0x0000 */ unsigned __int64 Offset : 12;\n\t\t/* 0x0000 */ unsigned __int64 PT : 9;\n\t\t/* 0x0000 */ unsigned __int64 PDT : 9;\n\t\t/* 0x0000 */ unsigned __int64 PDPT : 9;\n\t\t/* 0x0000 */ unsigned __int64 PML4T : 9;\n\t\t/* 0x0000 */ unsigned __int64 Partition : 16; //User:0x0000 System:0xFFFF\n\t}; /* bitfield */\n} MMVA, * PMMVA; /* size: 0x0008 */\n\ntypedef struct _MMVA_PDPTE_LARGE\n{\n\tstruct /* bitfield */\n\t{\n\t\t/* 0x0000 */ unsigned __int64 Offset : 30;\n\t\t/* 0x0000 */ unsigned __int64 PDPT : 9;\n\t\t/* 0x0000 */ unsigned __int64 PML4T : 9;\n\t\t/* 0x0000 */ unsigned __int64 Partition : 16; //User:0x0000 System:0xFFFF\n\t}; /* bitfield */\n} MMVA_PDPTE_LARGE, * PMMVA_PDPTE_LARGE; /* size: 0x0008 */\n\ntypedef struct _MMVA_PDE_LARGE\n{\n\tstruct /* bitfield */\n\t{\n\t\t/* 0x0000 */ unsigned __int64 Offset : 21;\n\t\t/* 0x0000 */ unsigned __int64 PDT : 9;\n\t\t/* 0x0000 */ unsigned __int64 PDPT : 9;\n\t\t/* 0x0000 */ unsigned __int64 PML4T : 9;\n\t\t/* 0x0000 */ unsigned __int64 Partition : 16; //User:0x0000 System:0xFFFF\n\t}; /* bitfield */\n} MMVA_PDE_LARGE, * PMMVA_PDE_LARGE; /* size: 0x0008 */\n\n\n//////////////////////////////////////////////////////////////////////////\n//prototypes\n\n//windows API\nNTKERNELAPI\nNTSTATUS\nPsLookupProcessByProcessId(\n\t_In_ HANDLE ProcessId,\n\t_Outptr_ PEPROCESS* Process\n);\n\n//operate physical memory via system API\nHANDLE OpenPhysicalMemory();\nBOOLEAN pMapPhysicalMemoryPre(HANDLE hMemory, PDWORD64 pDwAddress, PSIZE_T pSize, PDWORD64 pDwVirtualAddress);\nPVOID MapPhysicalMemory(PVOID PA, SIZE_T Size);\nBOOLEAN UnmapPhysicalMemory(PVOID VA);\n\n//get specific info from CR3 value\nULONG64 GetCR3Flag(ULONG64 CR3);\nULONG64 ClearCR3Flag(ULONG64 CR3);\n\n//get specific info from opaque eprocess struct\nULONG64 GetCR3ByEprocess(PEPROCESS pEProc);\nPEPROCESS GetEProcess(ULONG64 PID);\nULONG64 GetCR3ByPID(ULONG64 PID);\n\n//private functions\nVOID pPrintPhysicalOpStructure(PPHYSICAL_OP_CR3 pPhysicalOpCR3);\nNTSTATUS pFreePhysicalOpPageTableMemory(PPHYSICAL_OP_CR3 pPhysicalOpCR3);\nNTSTATUS pAllocPhysicalOpPageTableMemory(PPHYSICAL_OP_CR3 pPhysicalOpCR3);\nNTSTATUS pMapSystemPML4T(ULONG64 SystemCR3, PPHYSICAL_OP_CR3 pPhysicalOpCR3);\nNTSTATUS pUnmapSystemPML4T(PPHYSICAL_OP_CR3 pPhysicalOpCR3);\nNTSTATUS pFillGeneratedPML4TandPDPT(PPHYSICAL_OP_CR3 pPhysicalOpCR3);\n\n//public functions\nNTSTATUS CreatePhysicalOpCR3BySystemCR3(ULONG64 SystemCR3, PPHYSICAL_OP_CR3 pPhysicalOpCR3);\nNTSTATUS FreePhysicalOpCR3(PPHYSICAL_OP_CR3 pPhysicalOpCR3);\nNTSTATUS ContextVirtualToPhysical(PPHYSICAL_OP_CR3 pPhysicalOpCR3);\nNTSTATUS ContextPhysicalToVirtual(PPHYSICAL_OP_CR3 pPhysicalOpCR3);\n"
  },
  {
    "path": "KernelHiddenExecute/SectionOperation.c",
    "content": "#include \"SectionOperation.h\"\n\n\n//////////////////////////////////////////////////////////////////////////\n//functions\n\nPIMAGE_SECTION_HEADER GetSegmentHeadPointer(PDRIVER_OBJECT pDriverObj, PCHAR pSegName)\n{\n\tPLDR_DATA_TABLE_ENTRY64\t\tentry = (PLDR_DATA_TABLE_ENTRY64)pDriverObj->DriverSection;\n\tPUCHAR\t\t\t\t\t\tpJumpDrvBase = (PUCHAR)entry->DllBase;\n\tPIMAGE_DOS_HEADER\t\t\tpDosHead;\n\tPIMAGE_NT_HEADERS\t\t\tpNtHead;\n\tPIMAGE_SECTION_HEADER\t\tpSecHead;\n\tBOOL\t\t\t\t\t\tbFinded = FALSE;\n\n\tpDosHead = (PIMAGE_DOS_HEADER)pJumpDrvBase;\n\tif (pDosHead->e_magic != IMAGE_DOS_SIGNATURE)\n\t{\n\t\tMyPrint((\"[\" PRINT_NAME \"] DosHead Error\\n\"));\n\t\treturn 0;\n\t}\n\tpNtHead = (PIMAGE_NT_HEADERS)\\\n\t\t((LONG_PTR)pDosHead + pDosHead->e_lfanew);\n\tif (pNtHead->Signature != IMAGE_NT_SIGNATURE)\n\t{\n\t\tMyPrint((\"[\" PRINT_NAME \"] NtHead Error\\n\"));\n\t\treturn 0;\n\t}\n\tpSecHead = IMAGE_FIRST_SECTION(pNtHead);\n\tfor (int i = 0; i < pNtHead->FileHeader.NumberOfSections; i++)\n\t{\n\t\tif (strcmp((const char*)(pSecHead->Name), pSegName) == 0)\n\t\t{\n\t\t\tbFinded = TRUE;\n\t\t\tbreak;\n\t\t}\n\t\tpSecHead++;\n\t}\n\tif (bFinded == FALSE)\n\t{\n\t\tMyPrint((\"[\" PRINT_NAME \"] SecHead Error\\n\"));\n\t\treturn 0;\n\t}\n\n\treturn pSecHead;\n}\n\nULONG64 GetDriverBaseAddress(PDRIVER_OBJECT pDriverObj, PCHAR pSegName)\n{\n\tPLDR_DATA_TABLE_ENTRY64\t\tentry = (PLDR_DATA_TABLE_ENTRY64)pDriverObj->DriverSection;\n\tPUCHAR\t\t\t\t\t\tpJumpDrvBase = (PUCHAR)entry->DllBase;\n\treturn (ULONG64)pJumpDrvBase;\n}\nULONG64 GetSegmentAddressPointer(PDRIVER_OBJECT pDriverObj, PCHAR pSegName)\n{\n\tPIMAGE_SECTION_HEADER pSecHead = GetSegmentHeadPointer(pDriverObj, pSegName);\n\treturn (ULONG64) & (pSecHead->VirtualAddress);\n}\nULONG64 GetSegmentLengthPointer(PDRIVER_OBJECT pDriverObj, PCHAR pSegName)\n{\n\tPIMAGE_SECTION_HEADER pSecHead = GetSegmentHeadPointer(pDriverObj, pSegName);\n\treturn (ULONG64) & (pSecHead->Misc.VirtualSize);\n}\nULONG64 GetSegmentRawDataAddressPointer(PDRIVER_OBJECT pDriverObj, PCHAR pSegName)\n{\n\tPIMAGE_SECTION_HEADER pSecHead = GetSegmentHeadPointer(pDriverObj, pSegName);\n\treturn (ULONG64) & (pSecHead->PointerToRawData);\n}\nULONG64 GetSegmentRawDataLengthPointer(PDRIVER_OBJECT pDriverObj, PCHAR pSegName)\n{\n\tPIMAGE_SECTION_HEADER pSecHead = GetSegmentHeadPointer(pDriverObj, pSegName);\n\treturn (ULONG64) & (pSecHead->SizeOfRawData);\n}\n\nULONG64 GetSegmentStartAddress(PDRIVER_OBJECT pDriverObj, PCHAR pSegName)\n{\n\tULONG64 pDriverBase = GetDriverBaseAddress(pDriverObj, pSegName);\n\tULONG64 pSegmentAddress = GetSegmentAddressPointer(pDriverObj, pSegName);\n\treturn pDriverBase + *(PULONG32)pSegmentAddress;\n}\n\nULONG64 GetSegmentEndAddress(PDRIVER_OBJECT pDriverObj, PCHAR pSegName)\n{\n\tULONG64 pDriverBase = GetDriverBaseAddress(pDriverObj, pSegName);\n\tULONG64 pSegmentAddress = GetSegmentAddressPointer(pDriverObj, pSegName);\n\tULONG64 pSegmentLength = GetSegmentLengthPointer(pDriverObj, pSegName);\n\treturn pDriverBase + *(PULONG32)pSegmentAddress + *(PULONG32)pSegmentLength;\n}\n\nULONG64 GetSegmentLength(PDRIVER_OBJECT pDriverObj, PCHAR pSegName)\n{\n\tULONG64 pDriverBase = GetDriverBaseAddress(pDriverObj, pSegName);\n\tULONG64 pSegmentAddress = GetSegmentAddressPointer(pDriverObj, pSegName);\n\tULONG64 pSegmentLength = GetSegmentLengthPointer(pDriverObj, pSegName);\n\treturn *(PULONG32)pSegmentLength;\n}"
  },
  {
    "path": "KernelHiddenExecute/SectionOperation.h",
    "content": "#pragma once\n\n#include <ntddk.h>\n#include <ntimage.h>\n#include <windef.h>\n\n#include \"DebugPrintEx.h\"\n\n//////////////////////////////////////////////////////////////////////////\n//types\n\ntypedef struct _LDR_DATA_TABLE_ENTRY64\n{\n\tLIST_ENTRY64    InLoadOrderLinks;\n\tLIST_ENTRY64    InMemoryOrderLinks;\n\tLIST_ENTRY64    InInitializationOrderLinks;\n\tPVOID            DllBase;\n\tPVOID            EntryPoint;\n\tULONG            SizeOfImage;\n\tUNICODE_STRING    FullDllName;\n\tUNICODE_STRING     BaseDllName;\n\tULONG            Flags;\n\tUSHORT            LoadCount;\n\tUSHORT            TlsIndex;\n\tPVOID            SectionPointer;\n\tULONG            CheckSum;\n\tPVOID            LoadedImports;\n\tPVOID            EntryPointActivationContext;\n\tPVOID            PatchInformation;\n\tLIST_ENTRY64    ForwarderLinks;\n\tLIST_ENTRY64    ServiceTagLinks;\n\tLIST_ENTRY64    StaticLinks;\n\tPVOID            ContextInformation;\n\tULONG64            OriginalBase;\n\tLARGE_INTEGER    LoadTime;\n} LDR_DATA_TABLE_ENTRY64, * PLDR_DATA_TABLE_ENTRY64;\n\n\n//////////////////////////////////////////////////////////////////////////\n//prototypes\n\nPIMAGE_SECTION_HEADER GetSegmentHeadPointer(PDRIVER_OBJECT pDriverObj, PCHAR pSegName);\nULONG64 GetDriverBaseAddress(PDRIVER_OBJECT pDriverObj, PCHAR pSegName);\nULONG64 GetSegmentAddressPointer(PDRIVER_OBJECT pDriverObj, PCHAR pSegName);\nULONG64 GetSegmentLengthPointer(PDRIVER_OBJECT pDriverObj, PCHAR pSegName);\nULONG64 GetSegmentRawDataAddressPointer(PDRIVER_OBJECT pDriverObj, PCHAR pSegName);\nULONG64 GetSegmentRawDataLengthPointer(PDRIVER_OBJECT pDriverObj, PCHAR pSegName);\nULONG64 GetSegmentStartAddress(PDRIVER_OBJECT pDriverObj, PCHAR pSegName);\nULONG64 GetSegmentEndAddress(PDRIVER_OBJECT pDriverObj, PCHAR pSegName);\nULONG64 GetSegmentLength(PDRIVER_OBJECT pDriverObj, PCHAR pSegName);"
  },
  {
    "path": "KernelHiddenExecute/main.c",
    "content": "#include \"main.h\"\n\n\n//////////////////////////////////////////////////////////////////////////\n//global variables\n\nPHIDDEN_PAGE_RECORD g_pHiddenPageRecord = NULL;\n\n\n//////////////////////////////////////////////////////////////////////////\n//functions\n\nNTSTATUS DispatchCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp)\n{\n\tpIrp->IoStatus.Status = STATUS_SUCCESS;\n\tpIrp->IoStatus.Information = 0;\n\tIoCompleteRequest(pIrp, IO_NO_INCREMENT);\n\treturn STATUS_SUCCESS;\n}\n\nNTSTATUS DispatchClose(PDEVICE_OBJECT pDevObj, PIRP pIrp)\n{\n\tpIrp->IoStatus.Status = STATUS_SUCCESS;\n\tpIrp->IoStatus.Information = 0;\n\tIoCompleteRequest(pIrp, IO_NO_INCREMENT);\n\treturn STATUS_SUCCESS;\n}\n\nNTSTATUS DispatchIoctl(PDEVICE_OBJECT pDevObj, PIRP pIrp)\n{\n\tNTSTATUS status = STATUS_INVALID_DEVICE_REQUEST;\n\tPIO_STACK_LOCATION pIrpStack = IoGetCurrentIrpStackLocation(pIrp);\n\tULONG uIoControlCode = pIrpStack->Parameters.DeviceIoControl.IoControlCode;\n\tPVOID pIoBuffer = pIrp->AssociatedIrp.SystemBuffer;\n\tULONG uInSize = pIrpStack->Parameters.DeviceIoControl.InputBufferLength;\n\tULONG uOutSize = pIrpStack->Parameters.DeviceIoControl.OutputBufferLength;\n\tswitch (uIoControlCode)\n\t{\n\tcase IOCTL_SAFE_READ:\n\t{\n\t\tContextOriginalToHidden(g_pHiddenPageRecord);\n\t\tstrcpy(pIoBuffer, HiddenData);\n\t\tContextHiddenToOriginal(g_pHiddenPageRecord);\n\t\t//uOutSize = strlen(pIoBuffer);\n\t\tstatus = STATUS_SUCCESS;\n\t\tbreak;\n\t}\n\tcase IOCTL_UNSAFE_READ:\n\t{\n\t\tstrcpy(pIoBuffer, UnsafeData);\n\t\t//uOutSize = strlen(pIoBuffer);\n\t\tstatus = STATUS_SUCCESS;\n\t\tbreak;\n\t}\n\tcase IOCTL_SAFE_EXEC:\n\t{\n\t\tContextOriginalToHidden(g_pHiddenPageRecord);\n\t\tBOOL result = HiddenFunction(pIoBuffer);\n\t\tContextHiddenToOriginal(g_pHiddenPageRecord);\n\t\t*(PBOOL)pIoBuffer = result;\n\t\t//uOutSize = sizeof(BOOL);\n\t\tstatus = STATUS_SUCCESS;\n\t\tbreak;\n\t}\n\tcase IOCTL_UNSAFE_EXEC:\n\t{\n\t\tBOOL result = UnsafeFunction(pIoBuffer);\n\t\t*(PBOOL)pIoBuffer = result;\n\t\t//uOutSize = sizeof(BOOL);\n\t\tstatus = STATUS_SUCCESS;\n\t\tbreak;\n\t}\n\t}\n\tif (status == STATUS_SUCCESS)\n\t\tpIrp->IoStatus.Information = uOutSize;\n\telse\n\t\tpIrp->IoStatus.Information = 0;\n\tpIrp->IoStatus.Status = status;\n\tIoCompleteRequest(pIrp, IO_NO_INCREMENT);\n\treturn status;\n}\n\nVOID DriverUnload(PDRIVER_OBJECT pDriverObj)\n{\n\tUNICODE_STRING strLink;\n\t//do sth...\n\tMyPrint(_TitleAndFunc\"Exit\\n\");\n\n\tRemoveAndRestoreAllHiddenPageRecord(g_pHiddenPageRecord);\n\tFreeHiddenPageRecordStructure(g_pHiddenPageRecord);\n\n\t//delete device and symbolic link\n\tRtlInitUnicodeString(&strLink, LINK_NAME);\n\tIoDeleteSymbolicLink(&strLink);\n\tIoDeleteDevice(pDriverObj->DeviceObject);\n}\n//VOID WriteEnable()\n//{\n//\tUINT64 cr0 = __readcr0();\n//\tcr0 &= 0xfffffffffffeffff;\n//\t__writecr0(cr0);\n//\t_disable();\n//}\n//VOID WriteDisable()\n//{\n//\tUINT64 cr0 = __readcr0();\n//\tcr0 |= 0x10000;\n//\t_enable();\n//\t__writecr0(cr0);\n//}\nNTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObj, PUNICODE_STRING pRegistryString)\n{\n\tNTSTATUS status = STATUS_SUCCESS;\n\tPDEVICE_OBJECT pDevObj = NULL;\n\tUNICODE_STRING ustrDeviceName;\n\tUNICODE_STRING ustrLinkName;\n\t//set dispatch functions\n\tpDriverObj->DriverUnload = DriverUnload;\n\tpDriverObj->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DispatchIoctl;\n\tpDriverObj->MajorFunction[IRP_MJ_CREATE] = DispatchCreate;\n\tpDriverObj->MajorFunction[IRP_MJ_CLOSE] = DispatchClose;\n\t//create device\n\tRtlInitUnicodeString(&ustrDeviceName, DEVICE_NAME);\n\tstatus = IoCreateDevice(pDriverObj, 0, &ustrDeviceName, FILE_DEVICE_UNKNOWN, 0, FALSE, &pDevObj);\n\tif (!NT_SUCCESS(status))\n\t{\n\t\treturn status;\n\t}\n\t//create symbolic link\n\tRtlInitUnicodeString(&ustrLinkName, LINK_NAME);\n\tstatus = IoCreateSymbolicLink(&ustrLinkName, &ustrDeviceName);\n\tif (!NT_SUCCESS(status))\n\t{\n\t\tIoDeleteDevice(pDevObj);\n\t\treturn status;\n\t}\n\t//do sth...\n\tMyPrint(_TitleAndFunc \"Entry\\n\");\n\n\tInitializeHiddenPageRecordStructure(&g_pHiddenPageRecord);\n\tAddHiddenSection(GetCR3ByPID(4), pDriverObj, SECTION_NAME_HIDDEN_INSTRUCTIONS, g_pHiddenPageRecord);\n\tAddHiddenSection(GetCR3ByPID(4), pDriverObj, SECTION_NAME_HIDDEN_DATA, g_pHiddenPageRecord);\n\n\t//WriteEnable();\n\t//RtlZeroMemory((PVOID)HiddenFunctionA, 10);\n\t//WriteDisable();\n\n\t//ContextOriginalToHidden(g_pHiddenPageRecord);\n\n\t//HiddenFunctionA(g_pHiddenPageRecord);\n\n\t//ContextHiddenToOriginal(g_pHiddenPageRecord);\n\n\treturn status;\n}"
  },
  {
    "path": "KernelHiddenExecute/main.h",
    "content": "#pragma once\n\n#include <ntifs.h>\n#include <ntddk.h>\n#include <stdlib.h>\n#include <windef.h>\n#include <ntimage.h>\n#include <intrin.h>\n\n#include \"DebugPrintEx.h\"\n#include \"HiddenExecute.h\"\n#include \"HiddenCallApiTransfer.h\"\n#include \"HiddenFunctions.h\"\n\n\n//////////////////////////////////////////////////////////////////////////\n//constants and macros\n\n#define\tDEVICE_NAME\tL\"\\\\Device\\\\KernelHiddenExecute\"\n#define LINK_NAME\tL\"\\\\DosDevices\\\\Global\\\\KernelHiddenExecute\"\n\n#define IOCTL_SAFE_READ\tCTL_CODE(FILE_DEVICE_UNKNOWN, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)\n#define IOCTL_SAFE_EXEC\tCTL_CODE(FILE_DEVICE_UNKNOWN, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)\n#define IOCTL_UNSAFE_READ\tCTL_CODE(FILE_DEVICE_UNKNOWN, 0x802, METHOD_BUFFERED, FILE_ANY_ACCESS)\n#define IOCTL_UNSAFE_EXEC\tCTL_CODE(FILE_DEVICE_UNKNOWN, 0x803, METHOD_BUFFERED, FILE_ANY_ACCESS)\n\n\n//////////////////////////////////////////////////////////////////////////\n//prototypes\n\n//modify WD bit in the CR0\n//VOID WriteEnable();\n//VOID WriteDisable();\n\n//dispatch functions\nNTSTATUS DispatchCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp);\nNTSTATUS DispatchClose(PDEVICE_OBJECT pDevObj, PIRP pIrp);\nNTSTATUS DispatchIoctl(PDEVICE_OBJECT pDevObj, PIRP pIrp);\nVOID DriverUnload(PDRIVER_OBJECT pDriverObj);\n\n//driver entry\nNTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObj, PUNICODE_STRING pRegistryString);\n\n\n//////////////////////////////////////////////////////////////////////////\n//global variables\n\nextern char HiddenData[4096];\nextern char UnsafeData[4096];\n\n"
  },
  {
    "path": "KernelHiddenExecute.sln",
    "content": "﻿\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 16\nVisualStudioVersion = 16.0.30907.101\nMinimumVisualStudioVersion = 10.0.40219.1\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"KernelHiddenExecute\", \"KernelHiddenExecute\\KernelHiddenExecute.vcxproj\", \"{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}\"\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"ControlPanel\", \"ControlPanel\\ControlPanel.vcxproj\", \"{2C7AEAC4-25F4-4C9D-842D-5C001D2BBA71}\"\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"Malware\", \"Malware\\Malware.vcxproj\", \"{AEA72597-54BB-4720-916D-17F4B53F615D}\"\nEndProject\nGlobal\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n\t\tDebug|ARM = Debug|ARM\n\t\tDebug|ARM64 = Debug|ARM64\n\t\tDebug|x64 = Debug|x64\n\t\tDebug|x86 = Debug|x86\n\t\tRelease|ARM = Release|ARM\n\t\tRelease|ARM64 = Release|ARM64\n\t\tRelease|x64 = Release|x64\n\t\tRelease|x86 = Release|x86\n\tEndGlobalSection\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Debug|ARM.ActiveCfg = Debug|ARM\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Debug|ARM.Build.0 = Debug|ARM\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Debug|ARM.Deploy.0 = Debug|ARM\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Debug|ARM64.ActiveCfg = Debug|ARM64\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Debug|ARM64.Build.0 = Debug|ARM64\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Debug|ARM64.Deploy.0 = Debug|ARM64\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Debug|x64.Build.0 = Debug|x64\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Debug|x64.Deploy.0 = Debug|x64\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Debug|x86.ActiveCfg = Debug|Win32\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Debug|x86.Build.0 = Debug|Win32\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Debug|x86.Deploy.0 = Debug|Win32\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Release|ARM.ActiveCfg = Release|ARM\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Release|ARM.Build.0 = Release|ARM\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Release|ARM.Deploy.0 = Release|ARM\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Release|ARM64.ActiveCfg = Release|ARM64\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Release|ARM64.Build.0 = Release|ARM64\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Release|ARM64.Deploy.0 = Release|ARM64\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Release|x64.ActiveCfg = Release|x64\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Release|x64.Build.0 = Release|x64\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Release|x64.Deploy.0 = Release|x64\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Release|x86.ActiveCfg = Release|Win32\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Release|x86.Build.0 = Release|Win32\n\t\t{C9710F06-7BBB-4B03-9736-F7CA8D0B1759}.Release|x86.Deploy.0 = Release|Win32\n\t\t{2C7AEAC4-25F4-4C9D-842D-5C001D2BBA71}.Debug|ARM.ActiveCfg = Debug|Win32\n\t\t{2C7AEAC4-25F4-4C9D-842D-5C001D2BBA71}.Debug|ARM64.ActiveCfg = Debug|Win32\n\t\t{2C7AEAC4-25F4-4C9D-842D-5C001D2BBA71}.Debug|x64.ActiveCfg = Debug|Win32\n\t\t{2C7AEAC4-25F4-4C9D-842D-5C001D2BBA71}.Debug|x86.ActiveCfg = Debug|Win32\n\t\t{2C7AEAC4-25F4-4C9D-842D-5C001D2BBA71}.Debug|x86.Build.0 = Debug|Win32\n\t\t{2C7AEAC4-25F4-4C9D-842D-5C001D2BBA71}.Release|ARM.ActiveCfg = Release|Win32\n\t\t{2C7AEAC4-25F4-4C9D-842D-5C001D2BBA71}.Release|ARM64.ActiveCfg = Release|Win32\n\t\t{2C7AEAC4-25F4-4C9D-842D-5C001D2BBA71}.Release|x64.ActiveCfg = Release|Win32\n\t\t{2C7AEAC4-25F4-4C9D-842D-5C001D2BBA71}.Release|x86.ActiveCfg = Release|Win32\n\t\t{2C7AEAC4-25F4-4C9D-842D-5C001D2BBA71}.Release|x86.Build.0 = Release|Win32\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Debug|ARM.ActiveCfg = Debug|ARM\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Debug|ARM.Build.0 = Debug|ARM\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Debug|ARM.Deploy.0 = Debug|ARM\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Debug|ARM64.ActiveCfg = Debug|ARM64\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Debug|ARM64.Build.0 = Debug|ARM64\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Debug|ARM64.Deploy.0 = Debug|ARM64\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Debug|x64.Build.0 = Debug|x64\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Debug|x64.Deploy.0 = Debug|x64\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Debug|x86.ActiveCfg = Debug|Win32\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Debug|x86.Build.0 = Debug|Win32\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Debug|x86.Deploy.0 = Debug|Win32\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Release|ARM.ActiveCfg = Release|ARM\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Release|ARM.Build.0 = Release|ARM\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Release|ARM.Deploy.0 = Release|ARM\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Release|ARM64.ActiveCfg = Release|ARM64\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Release|ARM64.Build.0 = Release|ARM64\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Release|ARM64.Deploy.0 = Release|ARM64\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Release|x64.ActiveCfg = Release|x64\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Release|x64.Build.0 = Release|x64\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Release|x64.Deploy.0 = Release|x64\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Release|x86.ActiveCfg = Release|Win32\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Release|x86.Build.0 = Release|Win32\n\t\t{AEA72597-54BB-4720-916D-17F4B53F615D}.Release|x86.Deploy.0 = Release|Win32\n\tEndGlobalSection\n\tGlobalSection(SolutionProperties) = preSolution\n\t\tHideSolutionNode = FALSE\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityGlobals) = postSolution\n\t\tSolutionGuid = {CA87CDA3-6E95-4C2A-8FF5-255603FFBB5F}\n\tEndGlobalSection\nEndGlobal\n"
  },
  {
    "path": "LICENSE",
    "content": "GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "Malware/Attack.c",
    "content": "#include \"Attack.h\"\n\n\n//////////////////////////////////////////////////////////////////////////\n//global variables\n\nchar CodePattern[] = { 0x85 ,0xC0 ,0x75 ,0x09 ,0xC7 ,0x04 ,0x24 ,0x01 ,0x00 ,0x00 ,0x00 ,0xEB ,0x07  ,0xC7 ,0x04 ,0x24 ,0x00 ,0x00 ,0x00 ,0x00 ,0x8B ,0x04 ,0x24 };\nchar FakeCodePattern[] = { 0x85 ,0xC0 ,0x90 ,0x90 ,0xC7 ,0x04 ,0x24 ,0x01 ,0x00 ,0x00 ,0x00 ,0xEB ,0x07  ,0xC7 ,0x04 ,0x24 ,0x00 ,0x00 ,0x00 ,0x00 ,0x8B ,0x04 ,0x24 };\n\nchar DataPattern[] = \"normal data\";\nchar FakeDataPattern[] = \"hacked data\";\n\n\n//////////////////////////////////////////////////////////////////////////\n//functions\nVOID WriteEnable()\n{\n\tUINT64 cr0 = __readcr0();\n\tcr0 &= 0xfffffffffffeffff;\n\t__writecr0(cr0);\n\t_disable();\n}\nVOID WriteDisable()\n{\n\tUINT64 cr0 = __readcr0();\n\tcr0 |= 0x10000;\n\t_enable();\n\t__writecr0(cr0);\n}\n\n\nVOID cal_next(PCHAR str, PLONG_PTR next, LONG_PTR len)\n{\n\tnext[0] = -1;\n\tLONG_PTR k = -1;\n\tfor (LONG_PTR q = 1; q < len; q++)\n\t{\n\t\twhile (k > -1 && str[k + 1] != str[q])\n\t\t\tk = next[k];\n\t\tif (str[k + 1] == str[q])    ++k;\n\t\tnext[q] = k;\n\t}\n}\n\n\nPVOID KMP(PVOID str, LONG_PTR slen, PVOID ptr, LONG_PTR plen)\n{\n\t//int* next = new int[plen];\n\tPLONG_PTR next = (PLONG_PTR)ExAllocatePool(NonPagedPool, plen * sizeof(LONG_PTR));\n\tif (!next)\n\t{\n\t\treturn NULL;\n\t}\n\tcal_next((PCHAR)ptr, next, plen);\n\tLONG_PTR j = -1;\n\tfor (LONG_PTR i = 0; i < slen; i++)\n\t{\n\t\twhile (j > -1 && ((PCHAR)ptr)[j + 1] != ((PCHAR)str)[i]) {\n\t\t\tj = next[j];\n\t\t}\n\t\tif (((PCHAR)ptr)[j + 1] == ((PCHAR)str)[i])\n\t\t\tj = j + 1;\n\t\tif (j == plen - 1)\n\t\t{\n\t\t\tExFreePool(next);\n\t\t\treturn (PCHAR)str + i - plen + 1;\n\t\t}\n\t\t\t\n\t}\n\tExFreePool(next);\n\treturn NULL;\n}\n\nBOOL AttackCodeAndData(PDRIVER_OBJECT pDrvObj, PCHAR pSegName, PCHAR pPattern, SIZE_T len1, PCHAR pFake, SIZE_T len2)\n{\n\tPVOID pSectionStart = NULL;\n\tSIZE_T SectionLength = 0;\n\tpSectionStart = (PVOID)GetSegmentStartAddress(pDrvObj, pSegName);\n\tSectionLength = GetSegmentLength(pDrvObj, pSegName);\n\tif (!pSectionStart || !SectionLength)\n\t{\n\t\treturn FALSE;\n\t}\n\tPCHAR pModify = KMP(pSectionStart, SectionLength, pPattern, len1);\n\tif (!pModify)\n\t{\n\t\treturn FALSE;\n\t}\n\n\tif (pModify + len2 > (PCHAR)pSectionStart + SectionLength)\n\t{\n\t\treturn FALSE;\n\t}\n\n\tKIRQL irql = KeRaiseIrqlToDpcLevel();\n\tWriteEnable();\n\tmemcpy(pModify, pFake, len2);\n\tWriteEnable();\n\tKeLowerIrql(irql);\n\treturn TRUE;\n}\n\n\nNTSTATUS AttackDemoDriver(BOOL restore)\n{\n\tUNICODE_STRING targetDrvName;\n\tRtlInitUnicodeString(&targetDrvName, TARGET_DRV_NAME);\n\tNTSTATUS status = STATUS_UNSUCCESSFUL;\n\n\t//start reference\n\tPDRIVER_OBJECT pTargetDriverObj = NULL;\n\tstatus = ObReferenceObjectByName(&targetDrvName,\n\t\tOBJ_CASE_INSENSITIVE,\n\t\tNULL, FILE_ALL_ACCESS,\n\t\t*IoDriverObjectType,\n\t\tKernelMode, NULL,\n\t\t(PVOID*)&pTargetDriverObj);\n\n\tif (!NT_SUCCESS(status))\n\t{\n\t\tMyPrint(_TitleAndFunc\"Reference Faild :%X\\n\", status);\n\t\treturn status;\n\t}\n\n\tif (!restore)\n\t{\n\t\t//start attacking\n\t\t//attack code segment\n\t\tAttackCodeAndData(pTargetDriverObj,\n\t\t\tSECTION_NAME_HIDDEN_INSTRUCTIONS,\n\t\t\tCodePattern,\n\t\t\tsizeof(CodePattern),\n\t\t\tFakeCodePattern,\n\t\t\tsizeof(FakeCodePattern)\n\t\t);\n\t\tAttackCodeAndData(pTargetDriverObj,\n\t\t\tSECTION_NAME_NORMAL_INSTRUCTIONS,\n\t\t\tCodePattern,\n\t\t\tsizeof(CodePattern),\n\t\t\tFakeCodePattern,\n\t\t\tsizeof(FakeCodePattern)\n\t\t);\n\t\t//attack data segment\n\t\tAttackCodeAndData(pTargetDriverObj,\n\t\t\tSECTION_NAME_HIDDEN_DATA,\n\t\t\tDataPattern,\n\t\t\tsizeof(DataPattern),\n\t\t\tFakeDataPattern,\n\t\t\tsizeof(FakeDataPattern)\n\t\t);\n\t\tAttackCodeAndData(pTargetDriverObj,\n\t\t\tSECTION_NAME_NORMAL_DATA,\n\t\t\tDataPattern,\n\t\t\tsizeof(DataPattern),\n\t\t\tFakeDataPattern,\n\t\t\tsizeof(FakeDataPattern)\n\t\t);\n\t}\n\telse\n\t{\n\t\t//restore\n\t\tAttackCodeAndData(pTargetDriverObj,\n\t\t\tSECTION_NAME_HIDDEN_INSTRUCTIONS,\n\t\t\tFakeCodePattern,\n\t\t\tsizeof(FakeCodePattern),\n\t\t\tCodePattern,\n\t\t\tsizeof(CodePattern)\n\t\t);\n\t\tAttackCodeAndData(pTargetDriverObj,\n\t\t\tSECTION_NAME_NORMAL_INSTRUCTIONS,\n\t\t\tFakeCodePattern,\n\t\t\tsizeof(FakeCodePattern),\n\t\t\tCodePattern,\n\t\t\tsizeof(CodePattern)\n\t\t);\n\t\t//attack data segment\n\t\tAttackCodeAndData(pTargetDriverObj,\n\t\t\tSECTION_NAME_HIDDEN_DATA,\n\t\t\tFakeDataPattern,\n\t\t\tsizeof(FakeDataPattern),\n\t\t\tDataPattern,\n\t\t\tsizeof(DataPattern)\n\t\t);\n\t\tAttackCodeAndData(pTargetDriverObj,\n\t\t\tSECTION_NAME_NORMAL_DATA,\n\t\t\tFakeDataPattern,\n\t\t\tsizeof(FakeDataPattern),\n\t\t\tDataPattern,\n\t\t\tsizeof(DataPattern)\n\t\t);\n\t}\n\n\tObDereferenceObject(pTargetDriverObj);\n\treturn STATUS_SUCCESS;\n}"
  },
  {
    "path": "Malware/Attack.h",
    "content": "#pragma once\n\n#include <ntddk.h>\n#include <windef.h>\n#include <intrin.h>\n\n#include \"..\\KernelHiddenExecute\\DebugPrintEx.h\"\n#include \"..\\KernelHiddenExecute\\SectionOperation.h\"\n\n//////////////////////////////////////////////////////////////////////////\n//constants and macros\n\n#define TARGET_DRV_NAME\tL\"\\\\Driver\\\\KernelHiddenExecute\"\n#define SECTION_NAME_HIDDEN_INSTRUCTIONS\t\".hi\"\n#define SECTION_NAME_NORMAL_INSTRUCTIONS\t\".text\"\n#define SECTION_NAME_HIDDEN_DATA\t\t\t\".hd\"\n#define SECTION_NAME_NORMAL_DATA\t\t\t\".data\"\n\n//////////////////////////////////////////////////////////////////////////\n//prototypes\n\nNTSTATUS ObReferenceObjectByName\n(\n\tPUNICODE_STRING ObjectName,\n\tULONG Attributes,\n\tPACCESS_STATE AccessState,\n\tACCESS_MASK DesiredAccess,\n\tPOBJECT_TYPE ObjectType,\n\tKPROCESSOR_MODE AccessMode,\n\tPVOID ParseContext,\n\tPVOID* Object\n);\nextern POBJECT_TYPE* IoDriverObjectType;\n\n//modify WD bit in the CR0\nVOID WriteEnable();\nVOID WriteDisable();\n\n//KMP\nVOID cal_next(PCHAR str, PLONG_PTR next, LONG_PTR len);\nPVOID KMP(PVOID str, LONG_PTR slen, PVOID ptr, LONG_PTR plen);\n\n//attack\nBOOL AttackCodeAndData(PDRIVER_OBJECT pDrvObj, PCHAR pSegName, PCHAR pPattern, SIZE_T len1, PCHAR pFake, SIZE_T len2);\nNTSTATUS AttackDemoDriver(BOOL restore);\n"
  },
  {
    "path": "Malware/Malware.inf",
    "content": ";\n; Malware.inf\n;\n\n[Version]\nSignature=\"$WINDOWS NT$\"\nClass=System\nClassGuid={4d36e97d-e325-11ce-bfc1-08002be10318}\nProvider=XYLab\nDriverVer=\nCatalogFile=Malware.cat\nPnpLockDown=1\n\n;[DestinationDirs]\n;DefaultDestDir = 12\n\n\n;[SourceDisksNames]\n;1 = %DiskName%,,,\"\"\n\n;[SourceDisksFiles]\n\n\n;[Manufacturer]\n;%ManufacturerName%=Standard,NT$ARCH$\n\n;[Standard.NT$ARCH$]\n\n\n[Strings]\nManufacturerName=\"XYLab\"\nClassName=\"\"\nDiskName=\"Malware Source Disk\"\n"
  },
  {
    "path": "Malware/Malware.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"12.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|ARM\">\n      <Configuration>Debug</Configuration>\n      <Platform>ARM</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|ARM\">\n      <Configuration>Release</Configuration>\n      <Platform>ARM</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|ARM64\">\n      <Configuration>Debug</Configuration>\n      <Platform>ARM64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|ARM64\">\n      <Configuration>Release</Configuration>\n      <Platform>ARM64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{AEA72597-54BB-4720-916D-17F4B53F615D}</ProjectGuid>\n    <TemplateGuid>{dd38f7fc-d7bd-488b-9242-7d8754cde80d}</TemplateGuid>\n    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\n    <MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>\n    <Configuration>Debug</Configuration>\n    <Platform Condition=\"'$(Platform)' == ''\">Win32</Platform>\n    <RootNamespace>Malware</RootNamespace>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\n    <TargetVersion>Windows7</TargetVersion>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n    <DriverTargetPlatform>Desktop</DriverTargetPlatform>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\n    <TargetVersion>Windows7</TargetVersion>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n    <DriverTargetPlatform>Desktop</DriverTargetPlatform>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM64'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM64'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n    <DriverType>WDM</DriverType>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n    <EnableInf2cat>false</EnableInf2cat>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n    <EnableInf2cat>false</EnableInf2cat>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM64'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM64'\">\n    <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <ClCompile>\n      <TreatWarningAsError>false</TreatWarningAsError>\n    </ClCompile>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <ClCompile>\n      <TreatWarningAsError>false</TreatWarningAsError>\n    </ClCompile>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <Inf Include=\"Malware.inf\" />\n  </ItemGroup>\n  <ItemGroup>\n    <FilesToPackage Include=\"$(TargetPath)\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"..\\KernelHiddenExecute\\SectionOperation.c\" />\n    <ClCompile Include=\"Attack.c\" />\n    <ClCompile Include=\"main.c\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"..\\KernelHiddenExecute\\DebugPrintEx.h\" />\n    <ClInclude Include=\"..\\KernelHiddenExecute\\SectionOperation.h\" />\n    <ClInclude Include=\"Attack.h\" />\n    <ClInclude Include=\"main.h\" />\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>"
  },
  {
    "path": "Malware/Malware.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\n    </Filter>\n    <Filter Include=\"Driver Files\">\n      <UniqueIdentifier>{8E41214B-6785-4CFE-B992-037D68949A14}</UniqueIdentifier>\n      <Extensions>inf;inv;inx;mof;mc;</Extensions>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <Inf Include=\"Malware.inf\">\n      <Filter>Driver Files</Filter>\n    </Inf>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"main.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\KernelHiddenExecute\\SectionOperation.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"Attack.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"main.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\KernelHiddenExecute\\DebugPrintEx.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\KernelHiddenExecute\\SectionOperation.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"Attack.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "Malware/main.c",
    "content": "#include \"main.h\"\n\n\n//////////////////////////////////////////////////////////////////////////\n//functions\nNTSTATUS DispatchCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp)\n{\n\tpIrp->IoStatus.Status = STATUS_SUCCESS;\n\tpIrp->IoStatus.Information = 0;\n\tIoCompleteRequest(pIrp, IO_NO_INCREMENT);\n\treturn STATUS_SUCCESS;\n}\n\nNTSTATUS DispatchClose(PDEVICE_OBJECT pDevObj, PIRP pIrp)\n{\n\tpIrp->IoStatus.Status = STATUS_SUCCESS;\n\tpIrp->IoStatus.Information = 0;\n\tIoCompleteRequest(pIrp, IO_NO_INCREMENT);\n\treturn STATUS_SUCCESS;\n}\n\nNTSTATUS DispatchIoctl(PDEVICE_OBJECT pDevObj, PIRP pIrp)\n{\n\tNTSTATUS status = STATUS_INVALID_DEVICE_REQUEST;\n\tPIO_STACK_LOCATION pIrpStack = IoGetCurrentIrpStackLocation(pIrp);\n\tULONG uIoControlCode = pIrpStack->Parameters.DeviceIoControl.IoControlCode;\n\tPVOID pIoBuffer = pIrp->AssociatedIrp.SystemBuffer;\n\tULONG uInSize = pIrpStack->Parameters.DeviceIoControl.InputBufferLength;\n\tULONG uOutSize = pIrpStack->Parameters.DeviceIoControl.OutputBufferLength;\n\tswitch (uIoControlCode)\n\t{\n\tcase IOCTL_ATTACK:\n\t{\n\t\t*(PBOOL)pIoBuffer = (BOOL)NT_SUCCESS(AttackDemoDriver(FALSE));\n\t\t//uOutSize = sizeof(BOOL);\n\t\tstatus = STATUS_SUCCESS;\n\t\tbreak;\n\t}\n\t}\n\tif (status == STATUS_SUCCESS)\n\t\tpIrp->IoStatus.Information = uOutSize;\n\telse\n\t\tpIrp->IoStatus.Information = 0;\n\tpIrp->IoStatus.Status = status;\n\tIoCompleteRequest(pIrp, IO_NO_INCREMENT);\n\treturn status;\n}\n\nVOID DriverUnload(PDRIVER_OBJECT pDriverObj)\n{\n\tUNICODE_STRING strLink;\n\t//do sth...\n\tMyPrint(_TitleAndFunc\"Malware DriverUnload\\n\");\n\tAttackDemoDriver(TRUE);\n\t//delete device and symbolic link\n\tRtlInitUnicodeString(&strLink, LINK_NAME);\n\tIoDeleteSymbolicLink(&strLink);\n\tIoDeleteDevice(pDriverObj->DeviceObject);\n}\n\n\n\nNTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObj, PUNICODE_STRING pRegistryString)\n{\n\tNTSTATUS status = STATUS_SUCCESS;\n\tPDEVICE_OBJECT pDevObj = NULL;\n\tUNICODE_STRING ustrDeviceName;\n\tUNICODE_STRING ustrLinkName;\n\t//set dispatch functions\n\tpDriverObj->DriverUnload = DriverUnload;\n\tpDriverObj->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DispatchIoctl;\n\tpDriverObj->MajorFunction[IRP_MJ_CREATE] = DispatchCreate;\n\tpDriverObj->MajorFunction[IRP_MJ_CLOSE] = DispatchClose;\n\t//create device\n\tRtlInitUnicodeString(&ustrDeviceName, DEVICE_NAME);\n\tstatus = IoCreateDevice(pDriverObj, 0, &ustrDeviceName, FILE_DEVICE_UNKNOWN, 0, FALSE, &pDevObj);\n\tif (!NT_SUCCESS(status))\n\t{\n\t\treturn status;\n\t}\n\t//create symbolic link\n\tRtlInitUnicodeString(&ustrLinkName, LINK_NAME);\n\tstatus = IoCreateSymbolicLink(&ustrLinkName, &ustrDeviceName);\n\tif (!NT_SUCCESS(status))\n\t{\n\t\tIoDeleteDevice(pDevObj);\n\t\treturn status;\n\t}\n\t//do sth...\n\tMyPrint(_TitleAndFunc\"Malware DriverEntry\\n\");\n\treturn status;\n}"
  },
  {
    "path": "Malware/main.h",
    "content": "#pragma once\n\n#include <ntifs.h>\n#include <ntddk.h>\n#include <stdlib.h>\n#include <windef.h>\n#include <ntimage.h>\n#include <intrin.h>\n\n#include \"..\\KernelHiddenExecute\\DebugPrintEx.h\"\n#include \"Attack.h\"\n\n\n//////////////////////////////////////////////////////////////////////////\n//constants and macros\n\n#define\tDEVICE_NAME\tL\"\\\\Device\\\\KernelHiddenExecuteMalware\"\n#define LINK_NAME\tL\"\\\\DosDevices\\\\Global\\\\KernelHiddenExecuteMalware\"\n\n#define IOCTL_ATTACK\tCTL_CODE(FILE_DEVICE_UNKNOWN, 0x810, METHOD_BUFFERED, FILE_ANY_ACCESS)\n\n\n\n//////////////////////////////////////////////////////////////////////////\n//prototypes\n\n//dispatch functions\nNTSTATUS DispatchCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp);\nNTSTATUS DispatchClose(PDEVICE_OBJECT pDevObj, PIRP pIrp);\nNTSTATUS DispatchIoctl(PDEVICE_OBJECT pDevObj, PIRP pIrp);\nVOID DriverUnload(PDRIVER_OBJECT pDriverObj);\n\n//driver entry\nNTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObj, PUNICODE_STRING pRegistryString);\n"
  },
  {
    "path": "README.md",
    "content": "## Kernel Hidden Execute\n\nTo hide codes/data in the kernel address space.\n\n## System requirements\n\nWindows 7 or higher, 64-bit.\n\n## Mechanism\n\nUsing the method of modifying PTEs, switch specific PTEs to the hidden pages before executing hidden codes or reading hidden data, and switch back to the original page after executing or reading.\n\nIn order to hide real codes or data in the non-mapped physical pages, and clean original codes\n or data before calling the hidden functions, we should map the physical pages to correct position.\nIf we have to call windows API in our hidden functions, we should call the transfer functions(not hidden).\n\n### Features of transfer functions\n\n- check & change IRQL\n- restore & rewrite page table(PTEs)\n- call specific APIs\n\n## Develop environment\n\n- Visual Studio 2019\n- Windows SDK 10\n- Windows Driver Kit 10\n- QT5.12 for MSVC"
  }
]