Skip to content

Commit

Permalink
Mwasplund/monitor (#51)
Browse files Browse the repository at this point in the history
* Add Detours submodule

* Create sample projects that perform detours

* Copy tracebld sample as a starting point

* Cleanup style and modernize code

* More style cleanup

* Cleanup real functions

* Move to sub files

* Create event logger to start to cleanup sending events back to parent

* Cleanup and start logging more

* Cleanup some more logging

* Delete Handle functions

* Stop sending down the std input handles

* Remove open files tracker

* Remove file names tracker

* Remove proc and evn trackers

* Remove logging

* So much print stuff

* Cleanup naming

* Switch to sending event types

* Move system libraries into the resolve tools task

* Add system and architecture

* Add support for x86 builds

* Modernize the monitor app

* Move to detour folder

* Delete out

* Cleanup and switch to sync read calls

* Switch to path

* Fix rundll load issue where the exported function is called....

* Move to shared project and create callback

* Add file names

* Rename log sample and move to file

* Move build runner into a new execute folder

* New new names

* Start to switch over to new detoured process and cleanup process usage

* Switch over to using new detoured process runtime

* Update build history to store the entire operation state

* Start to track usage

* Update relative paths for library references

* Fix wrong wrong

* fix git toml11

* Add all interresting callbacks to the detours

* Read all file api override messages

* Finish mapping event listener messages

* Implement System access tracker

* Hook up real detour monitoring of input/outputs

Co-authored-by: Matthew Asplund <[email protected]>
  • Loading branch information
mwasplund and Matthew Asplund authored Aug 3, 2020
1 parent d8ff7b5 commit 15f0411
Show file tree
Hide file tree
Showing 200 changed files with 14,406 additions and 1,798 deletions.
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
url = https://github.com/mwasplund/Json11.git
[submodule "Dependencies/toml11"]
path = Dependencies/toml11
url = https://github.com/mwasplund/toml11.gits
url = https://github.com/mwasplund/toml11.git
[submodule "Dependencies/cpp-httplib"]
path = Dependencies/cpp-httplib
url = https://github.com/mwasplund/cpp-httplib.git
Expand All @@ -28,3 +28,6 @@
[submodule "Dependencies/Opal"]
path = Dependencies/Opal
url = https://github.com/mwasplund/Opal.git
[submodule "Dependencies/Detours"]
path = Dependencies/Detours
url = https://github.com/mwasplund/Detours.git
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"string_view": "cpp",
"complex": "cpp",
"*.inc": "cpp",
"compare": "cpp"
"compare": "cpp",
"cwctype": "cpp"
}
}
1 change: 1 addition & 0 deletions Dependencies/Detours
Submodule Detours added at 51cf82
2 changes: 1 addition & 1 deletion Dependencies/SoupSyntax
2 changes: 1 addition & 1 deletion Dependencies/cpp-httplib
Submodule cpp-httplib updated 1 files
+6 −6 Recipe.toml
36 changes: 18 additions & 18 deletions Docs/Samples/Simple-Build-Extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Version = "1.0.0"
Dependencies = [
"[email protected]",
"[email protected]",
"Soup.Build.Extensions@0.3.0",
"Soup.Build.Utilities@0.3.0",
]
Source = [
Expand Down Expand Up @@ -63,7 +63,7 @@ namespace SimpleBuildExtension
Soup::Build::ApiCallResult Execute(
Soup::Build::IBuildState& buildState) noexcept override final
{
auto buildStateWrapper = Soup::Build::Extensions::BuildStateWrapper(buildState);
auto buildStateWrapper = Soup::Build::Utilities::BuildStateWrapper(buildState);
try
{
Expand All @@ -83,20 +83,20 @@ namespace SimpleBuildExtension
/// <summary>
/// The Core Execute task
/// </summary>
void Execute(Soup::Build::Extensions::BuildStateWrapper& buildState)
void Execute(Soup::Build::Utilities::BuildStateWrapper& buildState)
{
buildState.LogHighPriority("Running After Build!");
}
private:
static Soup::Build::Extensions::StringList _runBeforeList;
static Soup::Build::Extensions::StringList _runAfterList;
static Soup::Build::Utilities::StringList _runBeforeList;
static Soup::Build::Utilities::StringList _runAfterList;
};
Soup::Build::Extensions::StringList AfterBuildTask::_runBeforeList =
Soup::Build::Extensions::StringList();
Soup::Build::Extensions::StringList AfterBuildTask::_runAfterList =
Soup::Build::Extensions::StringList({
Soup::Build::Utilities::StringList AfterBuildTask::_runBeforeList =
Soup::Build::Utilities::StringList();
Soup::Build::Utilities::StringList AfterBuildTask::_runAfterList =
Soup::Build::Utilities::StringList({
"Build",
});
}
Expand Down Expand Up @@ -145,7 +145,7 @@ namespace SimpleBuildExtension
Soup::Build::ApiCallResult Execute(
Soup::Build::IBuildState& buildState) noexcept override final
{
auto buildStateWrapper = Soup::Build::Extensions::BuildStateWrapper(buildState);
auto buildStateWrapper = Soup::Build::Utilities::BuildStateWrapper(buildState);
try
{
Expand All @@ -165,7 +165,7 @@ namespace SimpleBuildExtension
/// <summary>
/// The Core Execute task
/// </summary>
void Execute(Soup::Build::Extensions::BuildStateWrapper& buildState)
void Execute(Soup::Build::Utilities::BuildStateWrapper& buildState)
{
buildState.LogHighPriority("Running Before Build!");
auto rootTable = buildState.GetActiveState();
Expand All @@ -180,16 +180,16 @@ namespace SimpleBuildExtension
}
private:
static Soup::Build::Extensions::StringList _runBeforeList;
static Soup::Build::Extensions::StringList _runAfterList;
static Soup::Build::Utilities::StringList _runBeforeList;
static Soup::Build::Utilities::StringList _runAfterList;
};
Soup::Build::Extensions::StringList BeforeBuildTask::_runBeforeList =
Soup::Build::Extensions::StringList({
Soup::Build::Utilities::StringList BeforeBuildTask::_runBeforeList =
Soup::Build::Utilities::StringList({
"Build",
});
Soup::Build::Extensions::StringList BeforeBuildTask::_runAfterList =
Soup::Build::Extensions::StringList();
Soup::Build::Utilities::StringList BeforeBuildTask::_runAfterList =
Soup::Build::Utilities::StringList();
}
```

Expand All @@ -200,7 +200,7 @@ The Cpp file that implements the predefined `RegisterBuildExtension` C method to
import Opal;
import Soup.Build;
import Soup.Build.Extensions;
import Soup.Build.Utilities;
#include "AfterBuildTask.h"
#include "BeforeBuildTask.h"
Expand Down
16 changes: 8 additions & 8 deletions Samples/SimpleBuildExtension/Extension/AfterBuildTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace SimpleBuildExtension
Soup::Build::ApiCallResult Execute(
Soup::Build::IBuildState& buildState) noexcept override final
{
auto buildStateWrapper = Soup::Build::Extensions::BuildStateWrapper(buildState);
auto buildStateWrapper = Soup::Build::Utilities::BuildStateWrapper(buildState);

try
{
Expand All @@ -58,20 +58,20 @@ namespace SimpleBuildExtension
/// <summary>
/// The Core Execute task
/// </summary>
void Execute(Soup::Build::Extensions::BuildStateWrapper& buildState)
void Execute(Soup::Build::Utilities::BuildStateWrapper& buildState)
{
buildState.LogHighPriority("Running After Build!");
}

private:
static Soup::Build::Extensions::StringList _runBeforeList;
static Soup::Build::Extensions::StringList _runAfterList;
static Soup::Build::Utilities::StringList _runBeforeList;
static Soup::Build::Utilities::StringList _runAfterList;
};

Soup::Build::Extensions::StringList AfterBuildTask::_runBeforeList =
Soup::Build::Extensions::StringList();
Soup::Build::Extensions::StringList AfterBuildTask::_runAfterList =
Soup::Build::Extensions::StringList({
Soup::Build::Utilities::StringList AfterBuildTask::_runBeforeList =
Soup::Build::Utilities::StringList();
Soup::Build::Utilities::StringList AfterBuildTask::_runAfterList =
Soup::Build::Utilities::StringList({
"Build",
});
}
16 changes: 8 additions & 8 deletions Samples/SimpleBuildExtension/Extension/BeforeBuildTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace SimpleBuildExtension
Soup::Build::ApiCallResult Execute(
Soup::Build::IBuildState& buildState) noexcept override final
{
auto buildStateWrapper = Soup::Build::Extensions::BuildStateWrapper(buildState);
auto buildStateWrapper = Soup::Build::Utilities::BuildStateWrapper(buildState);

try
{
Expand All @@ -58,7 +58,7 @@ namespace SimpleBuildExtension
/// <summary>
/// The Core Execute task
/// </summary>
void Execute(Soup::Build::Extensions::BuildStateWrapper& buildState)
void Execute(Soup::Build::Utilities::BuildStateWrapper& buildState)
{
buildState.LogHighPriority("Running Before Build!");
auto rootTable = buildState.GetActiveState();
Expand All @@ -73,14 +73,14 @@ namespace SimpleBuildExtension
}

private:
static Soup::Build::Extensions::StringList _runBeforeList;
static Soup::Build::Extensions::StringList _runAfterList;
static Soup::Build::Utilities::StringList _runBeforeList;
static Soup::Build::Utilities::StringList _runAfterList;
};

Soup::Build::Extensions::StringList BeforeBuildTask::_runBeforeList =
Soup::Build::Extensions::StringList({
Soup::Build::Utilities::StringList BeforeBuildTask::_runBeforeList =
Soup::Build::Utilities::StringList({
"Build",
});
Soup::Build::Extensions::StringList BeforeBuildTask::_runAfterList =
Soup::Build::Extensions::StringList();
Soup::Build::Utilities::StringList BeforeBuildTask::_runAfterList =
Soup::Build::Utilities::StringList();
}
2 changes: 1 addition & 1 deletion Samples/SimpleBuildExtension/Extension/Recipe.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Version = "1.0.0"
Dependencies = [
"[email protected]",
"[email protected]",
"Soup.Build.Extensions@0.3.0",
"Soup.Build.Utilities@0.3.0",
]

Source = [
Expand Down
2 changes: 1 addition & 1 deletion Samples/SimpleBuildExtension/Extension/Register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Opal;
import Soup.Build;
import Soup.Build.Extensions;
import Soup.Build.Utilities;

#include "AfterBuildTask.h"
#include "BeforeBuildTask.h"
Expand Down
24 changes: 24 additions & 0 deletions Scripts/Build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@echo off
SET Flavor=%1
SET ScriptsDir=%~dp0
SET SourceDir=%ScriptsDir%..\Source
SET ClientCLIDir=%SourceDir%\Client\CLI
SET DetoursDir=%SourceDir%\Monitor\Detours
SET BinaryDirectorPath=out\bin\MSVC\%Flavor%\win32
SET ClientCLIBinaryDirectory=%ClientCLIDir%\%BinaryDirectorPath%
SET DetoursBinaryDirectory=%DetoursDir%\%BinaryDirectorPath%
REM - Build the host
echo soup build %ClientCLIDir% -flavor %Flavor%
call soup build %ClientCLIDir% -flavor %Flavor%
if %ERRORLEVEL% NEQ 0 exit /B %ERRORLEVEL%
REM - Build Each version of the detours dll
echo soup build %DetoursDir% -architecture x64 -flavor %Flavor%
call soup build %DetoursDir% -architecture x64 -flavor %Flavor%
if %ERRORLEVEL% NEQ 0 exit /B %ERRORLEVEL%
echo copy %DetoursBinaryDirectory%\x64\Monitor.Detours.dll %ClientCLIBinaryDirectory%\x64\Monitor.Detours.64.dll
copy %DetoursBinaryDirectory%\x64\Monitor.Detours.dll %ClientCLIBinaryDirectory%\x64\Monitor.Detours.64.dll > nul
echo soup build %DetoursDir% -architecture x86 -flavor %Flavor%
call soup build %DetoursDir% -architecture x86 -flavor %Flavor%
if %ERRORLEVEL% NEQ 0 exit /B %ERRORLEVEL%
echo copy %DetoursBinaryDirectory%\x86\Monitor.Detours.dll %ClientCLIBinaryDirectory%\x64\Monitor.Detours.32.dll
copy %DetoursBinaryDirectory%\x86\Monitor.Detours.dll %ClientCLIBinaryDirectory%\x64\Monitor.Detours.32.dll > nul
71 changes: 69 additions & 2 deletions Scripts/alltest.cmd
Original file line number Diff line number Diff line change
@@ -1,28 +1,95 @@
@echo off
SET ScriptsDir=%~dp0
SET SourceDir=%ScriptsDir%..\Source\
SET SourceDir=%ScriptsDir%..\Source

pushd %SourceDir%\Build\Extensions.UnitTests\
echo %SourceDir%\Build\Execute.UnitTests\
pushd %SourceDir%\Build\Execute.UnitTests\
if %ERRORLEVEL% NEQ 0 exit /B %ERRORLEVEL%
call soup build
if %ERRORLEVEL% NEQ 0 (
popd
exit /B %ERRORLEVEL%
)
call soup run
if %ERRORLEVEL% NEQ 0 (
echo Failed
popd
exit /B %ERRORLEVEL%
)
popd

echo %SourceDir%\Build\Utilities.UnitTests\
pushd %SourceDir%\Build\Utilities.UnitTests\
if %ERRORLEVEL% NEQ 0 exit /B %ERRORLEVEL%
call soup build
if %ERRORLEVEL% NEQ 0 (
popd
exit /B %ERRORLEVEL%
)
call soup run
if %ERRORLEVEL% NEQ 0 (
popd
exit /B %ERRORLEVEL%
)
popd

echo %SourceDir%\Extensions\Compiler\Core.UnitTests\
pushd %SourceDir%\Extensions\Compiler\Core.UnitTests\
if %ERRORLEVEL% NEQ 0 exit /B %ERRORLEVEL%
call soup build
if %ERRORLEVEL% NEQ 0 (
popd
exit /B %ERRORLEVEL%
)
call soup run
if %ERRORLEVEL% NEQ 0 (
popd
exit /B %ERRORLEVEL%
)
popd

echo %SourceDir%\Extensions\Compiler\Clang.UnitTests\
pushd %SourceDir%\Extensions\Compiler\Clang.UnitTests\
if %ERRORLEVEL% NEQ 0 exit /B %ERRORLEVEL%
call soup build
if %ERRORLEVEL% NEQ 0 (
popd
exit /B %ERRORLEVEL%
)
call soup run
if %ERRORLEVEL% NEQ 0 (
echo Failed
popd
exit /B %ERRORLEVEL%
)
popd

echo %SourceDir%\Extensions\Compiler\MSVC.UnitTests\
pushd %SourceDir%\Extensions\Compiler\MSVC.UnitTests\
if %ERRORLEVEL% NEQ 0 exit /B %ERRORLEVEL%
call soup build
if %ERRORLEVEL% NEQ 0 (
popd
exit /B %ERRORLEVEL%
)
call soup run
if %ERRORLEVEL% NEQ 0 (
popd
exit /B %ERRORLEVEL%
)
popd

echo %SourceDir%\Client\Core.UnitTests\
pushd %SourceDir%\Client\Core.UnitTests\
if %ERRORLEVEL% NEQ 0 exit /B %ERRORLEVEL%
call soup build
if %ERRORLEVEL% NEQ 0 (
popd
exit /B %ERRORLEVEL%
)
call soup run
if %ERRORLEVEL% NEQ 0 (
popd
exit /B %ERRORLEVEL%
)
popd
8 changes: 0 additions & 8 deletions Scripts/soup

This file was deleted.

3 changes: 2 additions & 1 deletion Scripts/soup.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SET OutDir=%ClientDir%\out
SET BinaryDir=%OutDir%\bin
SET RunDir=%OutDir%\run
REM - Use a copy of the final binary in case we are re-buiding itself
xcopy /s /Y %BinaryDir%\MSVC\Release\* %RunDir%\ > nul
rmdir /S /Q %RunDir%
xcopy /s /Y %BinaryDir%\MSVC\release\win32\x64\* %RunDir%\ > nul
copy %ClientDir%\LocalUserConfig.json %RunDir%\LocalUserConfig.json > nul
%RunDir%\Soup.exe %*
3 changes: 2 additions & 1 deletion Scripts/soupd.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SET OutDir=%ClientDir%\out
SET BinaryDir=%OutDir%\bin
SET RunDir=%OutDir%\run
REM - Use a copy of the final binary in case we are re-buiding itself
xcopy /s /Y %BinaryDir%\MSVC\Debug\* %RunDir%\ > nul
rmdir /S /Q %RunDir%
xcopy /s /Y %BinaryDir%\MSVC\debug\win32\x64\* %RunDir%\ > nul
copy %ClientDir%\LocalUserConfig.json %RunDir%\LocalUserConfig.json > nul
%RunDir%\Soup.exe %*
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions Source/Build/Contracts/Recipe.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Name = "Soup.Build"
Description = """The core Soup Build Contracts used to define
the stable Binary Interface layer between the Build Evaluation
engine and the Extensions."""
Version = "0.3.0"
Dependencies = [
"../../../Dependencies/Opal/Source/",
# "[email protected]",
]

Public = "Module.cpp"
Loading

0 comments on commit 15f0411

Please sign in to comment.