Example #1
0
        private static void Execute(CreateAppFirewallResponse agent, byte[] request)
        {
            var buffer = new byte[512];
            var result = TcellAgentNative.AppFirewallInspect(agent.AppFirewallPtr ?? IntPtr.Zero, request, request.LongLength, buffer, buffer.LongLength);
            var apa    = JsonConvert.DeserializeObject <AppFirewallInspectResponse>(Encoding.UTF8.GetString(buffer, 0, result));

            if (!string.IsNullOrWhiteSpace(apa.Error))
            {
                throw new InvalidOperationException(apa.Error);
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            var pattern = ReadFile("pattern.json");
            var policy  = ReadFile("policy.json");
            var request = ReadFile("request.json");

            var buffer = new byte[512];
            var result = TcellAgentNative.AppFirewallInit(pattern, pattern.LongLength, policy, policy.LongLength, buffer, buffer.LongLength);
            var agent  = JsonConvert.DeserializeObject <CreateAppFirewallResponse>(Encoding.UTF8.GetString(buffer, 0, result));

            for (var i = 0U; i < NumberOfTimes; ++i)
            {
                var t = new Thread(() =>
                {
                    Execute(agent, request);
                });
                t.Start();
                t.Join();
            }
            TcellAgentNative.AppFirewallFree(agent.AppFirewallPtr.Value);
            Console.ReadKey();
        }