Example #1
0
        public virtual OllyScript LoadScript(IOdbgScriptHost host, string scriptFilename)
        {
            // If the script file is not a rooted path, first try looking at
            // the current directory. If there is no file there, try finding
            // it in the installation directory.
            var fsSvc = Services.RequireService <IFileSystemService>();

            if (!fsSvc.IsPathRooted(scriptFilename))
            {
                string curDir  = fsSvc.GetCurrentDirectory();
                var    absPath = Path.Combine(curDir, scriptFilename);
                if (fsSvc.FileExists(absPath))
                {
                    scriptFilename = absPath;
                }
                else
                {
                    var dir = Path.GetDirectoryName(GetType().Assembly.Location);
                    absPath        = Path.Combine(dir, scriptFilename);
                    scriptFilename = absPath;
                }
            }
            using (var parser = OllyScriptParser.FromFile(host, fsSvc, scriptFilename, null))
            {
                return(parser.ParseScript());
            }
        }
Example #2
0
        public static OllyScriptParser FromString(IOdbgScriptHost host, IFileSystemService fsSvc, string buff, string dir)
        {
            string curdir = Helper.pathfixup(Environment.CurrentDirectory, true);
            var    sdir   = dir ?? curdir;

            return(new OllyScriptParser(new StringReader(buff), sdir, host, fsSvc));
        }
Example #3
0
 public OllyScriptParser(TextReader rdr, string currentDir, IOdbgScriptHost host, IFileSystemService fsSvc)
 {
     this.host       = host;
     this.fsSvc      = fsSvc;
     this.script     = new OllyScript();
     this.currentDir = currentDir;
     this.lexerStack = new Stack <Lexer>();
     this.lexerStack.Push(new Lexer(rdr));
 }
Example #4
0
        public static OllyScriptParser FromFile(IOdbgScriptHost host, IFileSystemService fsSvc, string file, string dir = null)
        {
            string cdir   = Environment.CurrentDirectory;
            string curdir = Helper.pathfixup(cdir, true);
            string sdir;

            var path = Helper.pathfixup(file, false);

            if (!Path.IsPathRooted(path))
            {
                path = Path.Combine(cdir, path);
            }
            if (string.IsNullOrEmpty(dir))
            {
                sdir = Path.GetDirectoryName(path);
            }
            else
            {
                sdir = dir;
            }
            return(new OllyScriptParser(fsSvc.CreateStreamReader(path, Encoding.UTF8), sdir, host, fsSvc));
        }