Skip to content

Commit

Permalink
Add Environ () emulator
Browse files Browse the repository at this point in the history
Add Shell() interceptor
Add CreateObject() interceptor
  • Loading branch information
sbruyere committed Aug 7, 2024
1 parent e968fd8 commit 90a3928
Show file tree
Hide file tree
Showing 81 changed files with 35,994 additions and 75 deletions.
208 changes: 208 additions & 0 deletions Resources/samples/sample_11.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Sources/vbSparkle.Console/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"Sample_7": {
"commandName": "Project",
"commandLineArgs": "-p $(SolutionDir)\\Resources\\samples\\sample_7.txt"
"commandLineArgs": "-p $(SolutionDir)\\Resources\\samples\\sample_11.txt"
},
"Sample_10": {
"commandName": "Project",
Expand Down
2 changes: 1 addition & 1 deletion Sources/vbSparkle.Console/vbSparkle.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<StartupObject>vbSparkle.CLI.Program</StartupObject>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Authors>Sylvain Bruyere, Airbus CERT</Authors>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Linq;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Text;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Linq;
using System.Text;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text;
using vbSparkle.NativeMethods;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using vbSparkle.EvaluationObjects;
using vbSparkle.NativeMethods;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Text;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Text;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Text;
using vbSparkle.Options;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Text;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Text;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Text;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Text;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Linq;
using System.Text;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
104 changes: 103 additions & 1 deletion Sources/vbSparkle/LanguageStatements/Functions/VBMethod.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using MathNet.Symbolics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -112,6 +113,107 @@ public override DExpression Evaluate(params DExpression[] args)
return new DSimpleStringExpression(str, Encoding.Unicode, Context.Options);
}
}
public class VB_EnvironS : VbNativeFunction
{
public VB_EnvironS(IVBScopeObject context)
: base(context, "Environ$")
{
}

public override DExpression Evaluate(params DExpression[] args)
{
DExpression arg1 = args.FirstOrDefault();

string strArg;

if (!Converter.TryGetStringValue(arg1, out strArg))
{
return DefaultExpression(args);
}

return new DSimpleStringExpression($"%{strArg}%", Encoding.Unicode, Context.Options);
}
}

public class VB_Environ
: VbNativeFunction
{
public VB_Environ(IVBScopeObject context)
: base(context, "Environ")
{
}

public override DExpression Evaluate(params DExpression[] args)
{
DExpression arg1 = args.FirstOrDefault();

string strArg;

if (!Converter.TryGetStringValue(arg1, out strArg))
{
return DefaultExpression(args);
}

return new DSimpleStringExpression($"%{strArg}%", Encoding.Unicode, Context.Options);
}
}


public class VB_CreateObject
: VbNativeFunction
{
public VB_CreateObject(IVBScopeObject context)
: base(context, "CreateObject")
{
}

public override DExpression Evaluate(params DExpression[] args)
{
DExpression arg1 = args.FirstOrDefault();

string strArg;

if (!Converter.TryGetStringValue(arg1, out strArg))
{
return DefaultExpression(args);
}

if (Context?.Options?.CreateObjectObserver != null)
{
Context.Options.CreateObjectObserver.CreateObjectObserved.Add(strArg.Replace("\"\"", "\""));
}

return DefaultExpression(args);
}
}

public class VB_Shell
: VbNativeFunction
{
public VB_Shell(IVBScopeObject context)
: base(context, "Shell")
{
}

public override DExpression Evaluate(params DExpression[] args)
{
DExpression arg1 = args.FirstOrDefault();

string strArg;

if (!Converter.TryGetStringValue(arg1, out strArg))
{
return DefaultExpression(args);
}

if (Context?.Options?.ShellObserver != null)
{
Context.Options.ShellObserver.ShellObserved.Add(strArg.Replace("\"\"", "\""));
}

return DefaultExpression(args);
}
}

public class VB_Execute
: VbNativeFunction
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace vbSparkle
{
using vbSparkle;
//namespace vbSparkle
//{
public partial class VBScriptParser
{
public partial class LiteralContext : ILiteralContext
Expand All @@ -16,4 +16,4 @@ public partial class DelimitedLiteralContext : ILiteralContext

}
}
}
//}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using vbSparkle.EvaluationObjects;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
2 changes: 1 addition & 1 deletion Sources/vbSparkle/LanguageStatements/Literals/VbLtColor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using vbSparkle.EvaluationObjects;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
2 changes: 1 addition & 1 deletion Sources/vbSparkle/LanguageStatements/Literals/VbLtNull.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
2 changes: 1 addition & 1 deletion Sources/vbSparkle/LanguageStatements/Literals/VbLtOctal.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text;
using vbSparkle.EvaluationObjects;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using static vbSparkle.VBScriptParser;
using static VBScriptParser;

namespace vbSparkle
{
Expand Down
Loading

0 comments on commit 90a3928

Please sign in to comment.