示例#1
0
        internal FileStream(FileHandle handle)
        {
            Handle = handle;
            // TODO: Store Target in FileHandle
            var targetProcessId = SysCalls.GetProcessIDForCommand(SysCallTarget.OpenFile);

            ReadBuffer  = ApplicationRuntime.RequestMessageBuffer(4096, targetProcessId);
            WriteBuffer = ApplicationRuntime.RequestMessageBuffer(4096, targetProcessId);
        }
示例#2
0
文件: Program.cs 项目: djlw78/abanu
        private static void StartProc(string name)
        {
            var fileServiceProc = SysCalls.GetProcessIDForCommand(SysCallTarget.GetFileLength);
            var nameBuf         = SysCalls.RequestMessageBuffer(4096, fileServiceProc);
            var length          = SysCalls.GetFileLength(nameBuf, name);

            if (length < 0)
            {
                return;
            }

            Console.WriteLine("Loading App: " + name);
            Console.WriteLine("Length: " + length.ToString());

            var targetProcessStartProc = SysCalls.GetProcessIDForCommand(SysCallTarget.CreateMemoryProcess);
            var fileBuf = ApplicationRuntime.RequestMessageBuffer(length, targetProcessStartProc);

            var transferBuf = new byte[4096];

            using (var handle = File.Open(name))
            {
                int pos = 0;

                SysCalls.SetThreadPriority(30);
                while (true)
                {
                    var gotBytes = handle.Read(transferBuf, 0, transferBuf.Length);

                    if (gotBytes <= 0)
                    {
                        break;
                    }

                    fileBuf.Write(transferBuf, 0, pos, gotBytes);
                    pos += gotBytes;

                    //for (var i = 0; i < gotBytes; i++)
                    //{
                    //    fileBuf.SetByte(pos++, transferBuf[i]);
                    //}
                }
                SysCalls.SetThreadPriority(0);

                Console.WriteLine("CreateProc...");
                var procId = SysCalls.CreateMemoryProcess(fileBuf.Region, (uint)length);
                var cmdProcId_SetStandartInputOutput = SysCalls.GetProcessIDForCommand(SysCallTarget.SetStandartInputOutput);
                var buf2 = SysCalls.RequestMessageBuffer(4096, cmdProcId_SetStandartInputOutput);
                SysCalls.SetStandartInputOutput(procId, FileHandle.StandaradInput, "/tmp/tmp_fifo", buf2);

                SysCalls.StartProcess(procId);
            }
        }