keow-cvs-commits Mailing List for Kernel Emulation on Windows
Status: Alpha
Brought to you by:
paul-sf
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(136) |
Oct
(24) |
Nov
(11) |
Dec
|
---|
Update of /cvsroot/keow/keow/keow-kernel/KeowKernel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10093/keow-kernel/KeowKernel Modified Files: ConstantMapping.cpp DevConsole.cpp FilesystemProc.cpp IOHFile.cpp IOHNtConsole.cpp IOHNull.cpp IOHPipe.cpp IOHRandom.cpp IOHStaticData.cpp KeowKernel.dsp Process.cpp Process.h SysCalls.cpp SysCalls.h linux_includes.h sys_io.cpp sys_mem.cpp sys_mount.cpp sys_net.cpp sys_perms.cpp sys_process.cpp sys_rtsig.cpp sys_sys.cpp Added Files: SocketCalls.cpp SocketCalls.h Log Message: No longer using real kernel headers. Far too many conflicts with windows headers using same #defines. Index: sys_mount.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/sys_mount.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sys_mount.cpp 10 Oct 2005 05:51:55 -0000 1.3 --- sys_mount.cpp 22 Nov 2005 06:52:25 -0000 1.4 *************** *** 51,55 **** || filesystemtype.length()==0) { ! ctx.Eax = EINVAL; return; } --- 51,55 ---- || filesystemtype.length()==0) { ! ctx.Eax = -linux::EINVAL; return; } *************** *** 63,72 **** if(attr==INVALID_FILE_ATTRIBUTES) { ! ctx.Eax = ENOTDIR; return; } if((attr&FILE_ATTRIBUTE_DIRECTORY)==0) { ! ctx.Eax = ENOTDIR; return; } --- 63,72 ---- if(attr==INVALID_FILE_ATTRIBUTES) { ! ctx.Eax = -linux::ENOTDIR; return; } if((attr&FILE_ATTRIBUTE_DIRECTORY)==0) { ! ctx.Eax = -linux::ENOTDIR; return; } *************** *** 80,84 **** if(source.length()==0 || source[1]==':' && source[2]==0) { //just drive letter, need path: eg. C: bad, C:\ is ok ! ctx.Eax = ENOTDIR; return; } --- 80,84 ---- if(source.length()==0 || source[1]==':' && source[2]==0) { //just drive letter, need path: eg. C: bad, C:\ is ok ! ctx.Eax = -linux::ENOTDIR; return; } *************** *** 86,95 **** if(attr==INVALID_FILE_ATTRIBUTES) { ! ctx.Eax = ENOTDIR; return; } if((attr&FILE_ATTRIBUTE_DIRECTORY)==0) { ! ctx.Eax = ENOTDIR; return; } --- 86,95 ---- if(attr==INVALID_FILE_ATTRIBUTES) { ! ctx.Eax = -linux::ENOTDIR; return; } if((attr&FILE_ATTRIBUTE_DIRECTORY)==0) { ! ctx.Eax = -linux::ENOTDIR; return; } *************** *** 123,127 **** else { ! ctx.Eax = ENODEV; //filesystem type not supported return; } --- 123,127 ---- else { ! ctx.Eax = -linux::ENODEV; //filesystem type not supported return; } *************** *** 139,143 **** if(target.length()==0) { ! ctx.Eax = -EINVAL; return; } --- 139,143 ---- if(target.length()==0) { ! ctx.Eax = -linux::EINVAL; return; } *************** *** 167,171 **** //nothing found ! ctx.Eax = -EINVAL; } --- 167,171 ---- //nothing found ! ctx.Eax = -linux::EINVAL; } Index: FilesystemProc.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/FilesystemProc.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** FilesystemProc.cpp 30 Oct 2005 01:20:17 -0000 1.7 --- FilesystemProc.cpp 22 Nov 2005 06:52:24 -0000 1.8 *************** *** 457,461 **** ,0 //nswap %lu\x0a, ,0 //cnswap %lu\x0a, ! ,SIGCHLD //exit_signal %d\x0a, ,0 //processor %d\x0a, ) ); --- 457,461 ---- ,0 //nswap %lu\x0a, ,0 //cnswap %lu\x0a, ! ,linux::SIGCHLD //exit_signal %d\x0a, ,0 //processor %d\x0a, ) ); Index: IOHStaticData.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/IOHStaticData.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IOHStaticData.cpp 10 Oct 2005 05:51:55 -0000 1.3 --- IOHStaticData.cpp 22 Nov 2005 06:52:25 -0000 1.4 *************** *** 111,117 **** if(m_DataType==File) ! s->st_mode |= S_IFREG; //regular file else ! s->st_mode |= S_IFDIR; //directory s->st_nlink = 1;//fi.nNumberOfLinks; --- 111,117 ---- if(m_DataType==File) ! s->st_mode |= linux::S_IFREG; //regular file else ! s->st_mode |= linux::S_IFDIR; //directory s->st_nlink = 1;//fi.nNumberOfLinks; *************** *** 125,129 **** ! s->st_size = m_DataLength; s->st_blksize = 512; //block size for efficient IO --- 125,129 ---- ! s->st_size = Length(); s->st_blksize = 512; //block size for efficient IO *************** *** 152,156 **** default: ktrace("IMPLEMENT sys_ioctl 0x%lx for IOHStaticData\n", request); ! dwRet = -ENOSYS; break; } --- 152,156 ---- default: ktrace("IMPLEMENT sys_ioctl 0x%lx for IOHStaticData\n", request); ! dwRet = -linux::ENOSYS; break; } Index: IOHRandom.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/IOHRandom.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IOHRandom.cpp 1 Nov 2005 17:49:10 -0000 1.1 --- IOHRandom.cpp 22 Nov 2005 06:52:25 -0000 1.2 *************** *** 64,68 **** return false; ! IOHandler::BasicStat64(s, S_IFCHR); return true; --- 64,68 ---- return false; ! IOHandler::BasicStat64(s, linux::S_IFCHR); return true; Index: KeowKernel.dsp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/KeowKernel.dsp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** KeowKernel.dsp 1 Nov 2005 17:49:10 -0000 1.6 --- KeowKernel.dsp 22 Nov 2005 06:52:25 -0000 1.7 *************** *** 44,48 **** # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c ! # ADD CPP /nologo /MT /W3 /GR /GX /Zi /O2 /I "..\kernel-headers-2.4.24-1\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX"includes.h" /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 --- 44,48 ---- # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c ! # ADD CPP /nologo /MT /W3 /GR /GX /Zi /O2 /I ".\linux-abi" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX"includes.h" /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 *************** *** 75,79 **** # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c ! # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "..\kernel-headers-2.4.24-1\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FR /YX"includes.h" /FD /GZ /c # SUBTRACT CPP /X # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 --- 75,79 ---- # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c ! # ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I ".\linux-abi" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FR /YX"includes.h" /FD /GZ /c # SUBTRACT CPP /X # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 *************** *** 196,199 **** --- 196,203 ---- # Begin Source File + SOURCE=.\SocketCalls.cpp + # End Source File + # Begin Source File + SOURCE=.\String.cpp # End Source File *************** *** 348,351 **** --- 352,359 ---- # Begin Source File + SOURCE=.\SocketCalls.h + # End Source File + # Begin Source File + SOURCE=.\String.h # End Source File --- NEW FILE: SocketCalls.cpp --- /* * Copyright 2005 Paul Walker * * GNU General Public License * * This file is part of: Kernel Emulation on Windows (keow) * * Keow is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Keow is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Keow; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ // SocketCalls.cpp: implementation of the SocketCalls class. // ////////////////////////////////////////////////////////////////////// #include "includes.h" #include "SocketCalls.h" ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// // This section was cobbled from the linux kernel net/socket.c function sys_socketcall /* Argument list sizes for sys_socketcall */ #define AL(x) ((x) * sizeof(unsigned long)) static unsigned char nargs[18]={AL(0),AL(3),AL(3),AL(3),AL(2),AL(3), AL(3),AL(3),AL(4),AL(4),AL(4),AL(6), AL(6),AL(2),AL(5),AL(5),AL(3),AL(3)}; #undef AL void SocketCalls::sys_socketcall(CONTEXT &ctx) { unsigned long a[6]; unsigned long a0,a1; int err; DWORD call = ctx.Ebx; if(call<1||call>linux::SYS_RECVMSG) { ctx.Eax=-linux::EINVAL; return; } //get all the possible arguments if(!P->ReadMemory(a, (ADDR)ctx.Ecx, nargs[call])) { ctx.Eax=-linux::EFAULT; return; } a0=a[0]; a1=a[1]; switch(call) { case linux::SYS_SOCKET: err = sys_socket(a0,a1,a[2]); break; case linux::SYS_BIND: err = sys_bind(a0,(struct sockaddr __user *)a1, a[2]); break; case linux::SYS_CONNECT: err = sys_connect(a0, (struct sockaddr __user *)a1, a[2]); break; case linux::SYS_LISTEN: err = sys_listen(a0,a1); break; case linux::SYS_ACCEPT: err = sys_accept(a0,(struct sockaddr __user *)a1, (int __user *)a[2]); break; case linux::SYS_GETSOCKNAME: err = sys_getsockname(a0,(struct sockaddr __user *)a1, (int __user *)a[2]); break; case linux::SYS_GETPEERNAME: err = sys_getpeername(a0, (struct sockaddr __user *)a1, (int __user *)a[2]); break; case linux::SYS_SOCKETPAIR: err = sys_socketpair(a0,a1, a[2], (int __user *)a[3]); break; case linux::SYS_SEND: err = sys_send(a0, (void __user *)a1, a[2], a[3]); break; case linux::SYS_SENDTO: err = sys_sendto(a0,(void __user *)a1, a[2], a[3], (struct sockaddr __user *)a[4], a[5]); break; case linux::SYS_RECV: err = sys_recv(a0, (void __user *)a1, a[2], a[3]); break; case linux::SYS_RECVFROM: err = sys_recvfrom(a0, (void __user *)a1, a[2], a[3], (struct sockaddr __user *)a[4], (int __user *)a[5]); break; case linux::SYS_SHUTDOWN: err = sys_shutdown(a0,a1); break; case linux::SYS_SETSOCKOPT: err = sys_setsockopt(a0, a1, a[2], (char __user *)a[3], a[4]); break; case linux::SYS_GETSOCKOPT: err = sys_getsockopt(a0, a1, a[2], (char __user *)a[3], (int __user *)a[4]); break; case linux::SYS_SENDMSG: err = sys_sendmsg(a0, (struct msghdr __user *) a1, a[2]); break; case linux::SYS_RECVMSG: err = sys_recvmsg(a0, (struct msghdr __user *) a1, a[2]); break; default: err = -linux::EINVAL; break; } ctx.Eax = err; } ////////////////////////////////////////////////////////////////////// Index: IOHFile.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/IOHFile.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IOHFile.cpp 15 Oct 2005 21:34:41 -0000 1.5 --- IOHFile.cpp 22 Nov 2005 06:52:24 -0000 1.6 *************** *** 135,144 **** if(m_Path.IsSymbolicLink()) ! s->st_mode |= S_IFLNK; else if(fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ! s->st_mode |= S_IFDIR; else ! s->st_mode |= S_IFREG; //regular file /* #define S_IFMT 00170000 --- 135,144 ---- if(m_Path.IsSymbolicLink()) ! s->st_mode |= linux::S_IFLNK; else if(fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ! s->st_mode |= linux::S_IFDIR; else ! s->st_mode |= linux::S_IFREG; //regular file /* #define S_IFMT 00170000 *************** *** 226,230 **** default: ktrace("IMPLEMENT sys_ioctl 0x%lx for IOHFile\n", request); ! return -ENOSYS; } } --- 226,230 ---- default: ktrace("IMPLEMENT sys_ioctl 0x%lx for IOHFile\n", request); ! return -linux::ENOSYS; } } Index: IOHNull.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/IOHNull.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IOHNull.cpp 24 Sep 2005 06:57:08 -0000 1.3 --- IOHNull.cpp 22 Nov 2005 06:52:25 -0000 1.4 *************** *** 75,79 **** return false; ! IOHandler::BasicStat64(s, S_IFCHR); return true; --- 75,79 ---- return false; ! IOHandler::BasicStat64(s, linux::S_IFCHR); return true; Index: sys_perms.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/sys_perms.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sys_perms.cpp 30 Oct 2005 01:20:17 -0000 1.3 --- sys_perms.cpp 22 Nov 2005 06:52:25 -0000 1.4 *************** *** 82,86 **** int euid = ctx.Ecx; ! ctx.Eax = -EPERM; if(ruid != -1) --- 82,86 ---- int euid = ctx.Ecx; ! ctx.Eax = -linux::EPERM; if(ruid != -1) *************** *** 120,124 **** int egid = ctx.Ecx; ! ctx.Eax = -EPERM; if(rgid != -1) --- 120,124 ---- int egid = ctx.Ecx; ! ctx.Eax = -linux::EPERM; if(rgid != -1) Index: linux_includes.h =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/linux_includes.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** linux_includes.h 30 Oct 2005 01:20:17 -0000 1.3 --- linux_includes.h 22 Nov 2005 06:52:25 -0000 1.4 *************** *** 25,98 **** #define LINUX_INCLUDES_H - #pragma pack(push,1) - - - //all vars in own namespace to ease co-existence with windows ones - namespace linux { - - //get kernel stuff - #define __KERNEL__ - - //for use to skip things we don't want - #define __KERNEL_EMULATION_ON_WINDOWS__ - - - //gcc specific stuff to alter - #define __signed__ signed - #define __inline__ inline - #define __const__ const - - #define __extension__ - #define __attribute__ - #define __aligned__ - - - #define __WORDSIZE 32 - - //usr/include/fcntl.h - /* Values for the second argument to access. - These may be OR'd together. */ - # define R_OK 4 /* Test for read permission. */ - # define W_OK 2 /* Test for write permission. */ - # define X_OK 1 /* Test for execute permission. */ - # define F_OK 0 /* Test for existence. */ - - - typedef __int64 __s64; - typedef unsigned __int64 __u64; - typedef __int64 __kernel_loff_t; - typedef __kernel_loff_t loff_t; - - struct mmap_arg_struct { - unsigned long addr; - unsigned long len; - unsigned long prot; - unsigned long flags; - unsigned long fd; - unsigned long offset; - }; - - - #include <linux/types.h> - #include <linux/unistd.h> - #include <linux/errno.h> - #include <linux/ioctl.h> - #include <linux/signal.h> - #include <linux/stat.h> - #include <linux/elf.h> - #include <linux/fcntl.h> - #include <linux/uio.h> - #include <linux/mman.h> - #include <linux/termios.h> - #include <linux/resource.h> - #include <linux/reboot.h> - #include <linux/sys.h> - #include <linux/dirent.h> - #include <linux/wait.h> - #include <asm-i386/ucontext.h> - #include <linux/user.h> - #include <linux/utime.h> ! }; --- 25,31 ---- #define LINUX_INCLUDES_H ! #include "linux/defines.h" ! #include "linux/types.h" *************** *** 100,104 **** //bit manipulation helpers for fd_set etc //based on linux kernel versions ! inline void LINUX_FD_SET(int fd, linux::fd_set * pSet) { __asm { push ebx --- 33,37 ---- //bit manipulation helpers for fd_set etc //based on linux kernel versions ! inline void KEOW_FD_SET(int fd, linux::fd_set * pSet) { __asm { push ebx *************** *** 109,113 **** } } ! inline void LINUX_FD_CLR(int fd, linux::fd_set * pSet) { __asm { push ebx --- 42,46 ---- } } ! inline void KEOW_FD_CLR(int fd, linux::fd_set * pSet) { __asm { push ebx *************** *** 118,122 **** } } ! inline BYTE LINUX_FD_ISSET(int fd, linux::fd_set * pSet) { BYTE result; __asm { --- 51,55 ---- } } ! inline BYTE KEOW_FD_ISSET(int fd, linux::fd_set * pSet) { BYTE result; __asm { *************** *** 130,135 **** return result; } ! inline void LINUX_FD_ZERO(linux::fd_set * pSet) { ! memset(pSet, 0, __FDSET_LONGS); } /* --- 63,68 ---- return result; } ! inline void KEOW_FD_ZERO(linux::fd_set * pSet) { ! memset(pSet, 0, linux::__FDSET_LONGS); } /* *************** *** 160,170 **** */ - //should get a 2.6 header set for this: - ///usr/include/elf.h: - #define AT_SYSINFO 32 - #define AT_SYSINFO_EHDR 33 - - - #pragma pack(pop) #endif // LINUX_INCLUDES_H --- 93,96 ---- Index: DevConsole.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/DevConsole.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DevConsole.cpp 15 Oct 2005 21:34:41 -0000 1.5 --- DevConsole.cpp 22 Nov 2005 06:52:24 -0000 1.6 *************** *** 60,69 **** //default stty info ! m_TermIOs.c_iflag = IGNBRK|IGNPAR|IXOFF|ISIG; m_TermIOs.c_oflag = 0; ! m_TermIOs.c_cflag = CS8; ! m_TermIOs.c_lflag = ECHO; ! m_TermIOs.c_line = N_TTY; memset(m_TermIOs.c_cc, 0, sizeof(m_TermIOs.c_cc)); StringCbCopy((char*)m_TermIOs.c_cc, sizeof(m_TermIOs.c_cc), INIT_C_CC); //default special chars from kernel files --- 60,77 ---- //default stty info ! m_TermIOs.c_iflag = linux::IGNBRK|linux::IGNPAR|linux::IXOFF|linux::ISIG; m_TermIOs.c_oflag = 0; ! m_TermIOs.c_cflag = linux::CS8; ! m_TermIOs.c_lflag = linux::ECHO; ! m_TermIOs.c_line = linux::N_TTY; memset(m_TermIOs.c_cc, 0, sizeof(m_TermIOs.c_cc)); + + /* intr=^C quit=^\ erase=del kill=^U + eof=^D vtime=\0 vmin=\1 sxtc=\0 + start=^Q stop=^S susp=^Z eol=\0 + reprint=^R discard=^U werase=^W lnext=^V + eol2=\0 + */ + #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" StringCbCopy((char*)m_TermIOs.c_cc, sizeof(m_TermIOs.c_cc), INIT_C_CC); //default special chars from kernel files *************** *** 168,175 **** //#define IXOFF 0010000 //#define IMAXBEL 0020000 ! if((m_TermIOs.c_iflag & ISTRIP)) *p &= 0x3F; //make 7-bit ! if((m_TermIOs.c_iflag & IGNCR) && *p==CR) { //discard from buffer --- 176,183 ---- //#define IXOFF 0010000 //#define IMAXBEL 0020000 ! if((m_TermIOs.c_iflag & linux::ISTRIP)) *p &= 0x3F; //make 7-bit ! if((m_TermIOs.c_iflag & linux::IGNCR) && *p==CR) { //discard from buffer *************** *** 179,183 **** } ! if((m_TermIOs.c_iflag & INLCR) && *p==NL) { //insert char --- 187,191 ---- } ! if((m_TermIOs.c_iflag & linux::INLCR) && *p==NL) { //insert char *************** *** 189,193 **** } else ! if((m_TermIOs.c_iflag & ICRNL) && *p==CR) { for(DWORD j=dwRead-1; j>i; --j) --- 197,201 ---- } else ! if((m_TermIOs.c_iflag & linux::ICRNL) && *p==CR) { for(DWORD j=dwRead-1; j>i; --j) *************** *** 198,202 **** } ! if((m_TermIOs.c_iflag & IUCLC)) *p = tolower(*p); --- 206,210 ---- } ! if((m_TermIOs.c_iflag & linux::IUCLC)) *p = tolower(*p); *************** *** 219,225 **** //#define IEXTEN 0100000 bool bSigSent = false; ! if(m_TermIOs.c_lflag & ISIG) { ! if(*p==m_TermIOs.c_cc[VINTR]) { //send to all foreground processes in the process group on this terminal --- 227,233 ---- //#define IEXTEN 0100000 bool bSigSent = false; ! if(m_TermIOs.c_lflag & linux::ISIG) { ! if(*p==m_TermIOs.c_cc[linux::VINTR]) { //send to all foreground processes in the process group on this terminal *************** *** 233,237 **** && p2->m_bIsInForeground) { ! p2->SendSignal(SIGINT); bSigSent = true; } --- 241,245 ---- && p2->m_bIsInForeground) { ! p2->SendSignal(linux::SIGINT); bSigSent = true; } *************** *** 256,264 **** //VEOL2 } ! if(m_TermIOs.c_lflag & ECHO) { if(!bSigSent) { ! if(m_TermIOs.c_lflag & ECHOE) WriteFile(m_hConsoleWrite, "\b \b", 3, &dwWritten, NULL); //backspace-space-backspace else --- 264,272 ---- //VEOL2 } ! if(m_TermIOs.c_lflag & linux::ECHO) { if(!bSigSent) { ! if(m_TermIOs.c_lflag & linux::ECHOE) WriteFile(m_hConsoleWrite, "\b \b", 3, &dwWritten, NULL); //backspace-space-backspace else *************** *** 290,307 **** switch(request) { ! case TCGETS: //get stty stuff //send to process P->WriteMemory((ADDR)data, sizeof(m_TermIOs), &m_TermIOs); break; ! case TCSETSW: //flush output //console io never buffered, so not required //...fall through... ! case TCSETSF: //flush input & output //(done in console process) //...fall through... ! case TCSETS: //set stty stuff { //do this in kernel --- 298,315 ---- switch(request) { ! case linux::TCGETS: //get stty stuff //send to process P->WriteMemory((ADDR)data, sizeof(m_TermIOs), &m_TermIOs); break; ! case linux::TCSETSW: //flush output //console io never buffered, so not required //...fall through... ! case linux::TCSETSF: //flush input & output //(done in console process) //...fall through... ! case linux::TCSETS: //set stty stuff { //do this in kernel *************** *** 313,321 **** break; ! case TIOCGPGRP: //get process group { if(!data) { ! dwRet = -EFAULT; break; } --- 321,329 ---- break; ! case linux::TIOCGPGRP: //get process group { if(!data) { ! dwRet = -linux::EFAULT; break; } *************** *** 323,331 **** } break; ! case TIOCSPGRP: //set process group { if(!data) { ! dwRet = -EFAULT; break; } --- 331,339 ---- } break; ! case linux::TIOCSPGRP: //set process group { if(!data) { ! dwRet = -linux::EFAULT; break; } *************** *** 334,338 **** break; ! case TIOCGWINSZ: //get window size { linux::winsize rec; --- 342,346 ---- break; ! case linux::TIOCGWINSZ: //get window size { linux::winsize rec; *************** *** 344,348 **** } break; ! case TIOCSWINSZ: //set window size { linux::winsize rec; --- 352,356 ---- } break; ! case linux::TIOCSWINSZ: //set window size { linux::winsize rec; *************** *** 355,359 **** break; ! case TCXONC: //TODO: dwRet = 0; break; --- 363,367 ---- break; ! case linux::TCXONC: //TODO: dwRet = 0; break; *************** *** 361,365 **** default: ktrace("IMPLEMENT sys_ioctl 0x%lx for DevConsole\n", request); ! dwRet = -ENOSYS; break; } --- 369,373 ---- default: ktrace("IMPLEMENT sys_ioctl 0x%lx for DevConsole\n", request); ! dwRet = -linux::ENOSYS; break; } Index: sys_net.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/sys_net.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sys_net.cpp 1 Nov 2005 17:49:10 -0000 1.3 --- sys_net.cpp 22 Nov 2005 06:52:25 -0000 1.4 *************** *** 36,42 **** void SysCalls::sys_socketcall(CONTEXT &ctx) { ! ktrace("IMPLEMENT sys_socketcall (unix domain socket?, not inet?)\n"); ! P->DumpContext(ctx); ! ctx.Eax = -ENOSYS; } --- 36,40 ---- void SysCalls::sys_socketcall(CONTEXT &ctx) { ! SocketCalls::sys_socketcall(ctx); } Index: sys_io.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/sys_io.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** sys_io.cpp 30 Oct 2005 01:41:24 -0000 1.8 --- sys_io.cpp 22 Nov 2005 06:52:25 -0000 1.9 *************** *** 47,51 **** if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -EBADF; return; } --- 47,51 ---- if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 54,63 **** if(ioh == NULL) { ! ctx.Eax = -EBADF; return; } if(!ioh->Write((void*)ctx.Ecx, ctx.Edx, &ctx.Eax)) ctx.Eax = -Win32ErrToUnixError(SysCallDll::GetLastError()); } --- 54,74 ---- if(ioh == NULL) { ! ctx.Eax = -linux::EBADF; return; } if(!ioh->Write((void*)ctx.Ecx, ctx.Edx, &ctx.Eax)) + { + DWORD err = SysCallDll::GetLastError(); ctx.Eax = -Win32ErrToUnixError(SysCallDll::GetLastError()); + switch(err) + { + case ERROR_BROKEN_PIPE: + case ERROR_NO_DATA: //pipe is being closed + case ERROR_PIPE_NOT_CONNECTED: + P->SendSignal(linux::SIGPIPE); + break; + } + } } *************** *** 77,81 **** if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -EBADF; return; } --- 88,92 ---- if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 84,88 **** if(ioh == NULL) { ! ctx.Eax = -EBADF; return; } --- 95,99 ---- if(ioh == NULL) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 96,100 **** --- 107,120 ---- if(!ioh->Write(iov.iov_base, iov.iov_len, &done)) { + DWORD err = SysCallDll::GetLastError(); ctx.Eax = -Win32ErrToUnixError(SysCallDll::GetLastError()); + switch(err) + { + case ERROR_BROKEN_PIPE: + case ERROR_NO_DATA: //pipe is being closed + case ERROR_PIPE_NOT_CONNECTED: + P->SendSignal(linux::SIGPIPE); + break; + } return; } *************** *** 122,126 **** if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -EBADF; return; } --- 142,146 ---- if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 129,133 **** if(ioh == NULL) { ! ctx.Eax = -EBADF; return; } --- 149,153 ---- if(ioh == NULL) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 160,164 **** //read is ok if access already succeeded ! if( (check & W_OK) && (attr&FILE_ATTRIBUTE_READONLY) ) ok = 0; --- 180,184 ---- //read is ok if access already succeeded ! if( (check & linux::W_OK) && (attr&FILE_ATTRIBUTE_READONLY) ) ok = 0; *************** *** 166,170 **** ctx.Eax = 0; else ! ctx.Eax = -EACCES; } --- 186,190 ---- ctx.Eax = 0; else ! ctx.Eax = -linux::EACCES; } *************** *** 193,214 **** if(fd==-1) { ! ctx.Eax = -EMFILE; //too many open files return; } //calc flags ! if((access&O_ACCMODE) == O_WRONLY) win32access = GENERIC_WRITE; else ! if((access&O_ACCMODE) == O_RDONLY) win32access = GENERIC_READ; else win32access = GENERIC_READ|GENERIC_WRITE; ! if(access & O_EXCL) win32share = 0; else win32share = FILE_SHARE_READ|FILE_SHARE_WRITE; disposition = OPEN_EXISTING; ! if(access & O_CREAT) disposition = OPEN_ALWAYS; flags = 0; --- 213,234 ---- if(fd==-1) { ! ctx.Eax = -linux::EMFILE; //too many open files return; } //calc flags ! if((access&linux::O_ACCMODE) == linux::O_WRONLY) win32access = GENERIC_WRITE; else ! if((access&linux::O_ACCMODE) == linux::O_RDONLY) win32access = GENERIC_READ; else win32access = GENERIC_READ|GENERIC_WRITE; ! if(access & linux::O_EXCL) win32share = 0; else win32share = FILE_SHARE_READ|FILE_SHARE_WRITE; disposition = OPEN_EXISTING; ! if(access & linux::O_CREAT) disposition = OPEN_ALWAYS; flags = 0; *************** *** 219,223 **** if(ioh==NULL) { ! ctx.Eax = -ENXIO; //no device available? return; } --- 239,243 ---- if(ioh==NULL) { ! ctx.Eax = -linux::ENXIO; //no device available? return; } *************** *** 236,245 **** //more flags ! if(access & O_TRUNC) { ioh->Seek(0, FILE_BEGIN); ioh->Truncate(); } ! if(access & O_APPEND) { ioh->Seek(0, FILE_END); --- 256,265 ---- //more flags ! if(access & linux::O_TRUNC) { ioh->Seek(0, FILE_BEGIN); ioh->Truncate(); } ! if(access & linux::O_APPEND) { ioh->Seek(0, FILE_END); *************** *** 263,267 **** if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -EBADF; return; } --- 283,287 ---- if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 270,274 **** if(ioh == NULL) { ! ctx.Eax = -EBADF; return; } --- 290,294 ---- if(ioh == NULL) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 308,312 **** if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -EBADF; return; } --- 328,332 ---- if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 315,319 **** if(ioh == NULL) { ! ctx.Eax = -EBADF; return; } --- 335,339 ---- if(ioh == NULL) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 365,369 **** if((attr&FILE_ATTRIBUTE_DIRECTORY) == 0) { ! ctx.Eax = -ENOTDIR; return; } --- 385,389 ---- if((attr&FILE_ATTRIBUTE_DIRECTORY) == 0) { ! ctx.Eax = -linux::ENOTDIR; return; } *************** *** 388,392 **** if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -EBADF; return; } --- 408,412 ---- if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 396,400 **** || !instanceof(ioh,IOHFile)) { ! ctx.Eax = -EBADF; return; } --- 416,420 ---- || !instanceof(ioh,IOHFile)) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 411,415 **** if((attr&FILE_ATTRIBUTE_DIRECTORY) == 0) { ! ctx.Eax = -ENOTDIR; return; } --- 431,435 ---- if((attr&FILE_ATTRIBUTE_DIRECTORY) == 0) { ! ctx.Eax = -linux::ENOTDIR; return; } *************** *** 438,442 **** if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -EBADF; return; } --- 458,462 ---- if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 445,475 **** if(ioh == NULL) { ! ctx.Eax = -EBADF; return; } ! ctx.Eax = -EINVAL; switch(ctx.Ecx) { ! case F_GETFD: /* get close_on_exec */ ctx.Eax = ioh->GetInheritable() ? 0 : 1; break; ! case F_SETFD: /* set/clear close_on_exec */ ioh->SetInheritable(ctx.Edx==0); ctx.Eax = 0; break; ! case F_GETFL: /* get file->f_flags */ ctx.Eax = ioh->GetFlags(); break; ! case F_SETFL: /* set file->f_flags */ ioh->SetFlags(ctx.Edx); ctx.Eax = 0; break; ! case F_DUPFD: /* like dup2() but use any fd<=arg and close-on-exec flag of copy is off */ { int maxfd = ctx.Edx; --- 465,495 ---- if(ioh == NULL) { ! ctx.Eax = -linux::EBADF; return; } ! ctx.Eax = -linux::EINVAL; switch(ctx.Ecx) { ! case linux::F_GETFD: /* get close_on_exec */ ctx.Eax = ioh->GetInheritable() ? 0 : 1; break; ! case linux::F_SETFD: /* set/clear close_on_exec */ ioh->SetInheritable(ctx.Edx==0); ctx.Eax = 0; break; ! case linux::F_GETFL: /* get file->f_flags */ ctx.Eax = ioh->GetFlags(); break; ! case linux::F_SETFL: /* set file->f_flags */ ioh->SetFlags(ctx.Edx); ctx.Eax = 0; break; ! case linux::F_DUPFD: /* like dup2() but use any fd<=arg and close-on-exec flag of copy is off */ { int maxfd = ctx.Edx; *************** *** 481,490 **** if(fdnew==-1) { ! ctx.Eax = -EMFILE; //too many open files return; } if(fdnew > maxfd) { ! ctx.Eax = EINVAL; return; } --- 501,510 ---- if(fdnew==-1) { ! ctx.Eax = -linux::EMFILE; //too many open files return; } if(fdnew > maxfd) { ! ctx.Eax = linux::EINVAL; return; } *************** *** 502,506 **** default: ktrace("IMPLEMENT sys_fcntl 0x%lx\n", ctx.Ecx); ! ctx.Eax = -ENOSYS; break; } --- 522,526 ---- default: ktrace("IMPLEMENT sys_fcntl 0x%lx\n", ctx.Ecx); ! ctx.Eax = -linux::ENOSYS; break; } *************** *** 523,527 **** if(fdnew==-1) { ! ctx.Eax = -EMFILE; //too many open files return; } --- 543,547 ---- if(fdnew==-1) { ! ctx.Eax = -linux::EMFILE; //too many open files return; } *************** *** 550,554 **** if(fdold<0 || fdold>MAX_OPEN_FILES) { ! ctx.Eax = -EBADF; return; } --- 570,574 ---- if(fdold<0 || fdold>MAX_OPEN_FILES) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 557,561 **** if(ioh_old == NULL) { ! ctx.Eax = -EBADF; return; } --- 577,581 ---- if(ioh_old == NULL) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 565,569 **** if(fdnew<0 || fdnew>MAX_OPEN_FILES || fdnew==fdold) { ! ctx.Eax = -EBADF; return; } --- 585,589 ---- if(fdnew<0 || fdnew>MAX_OPEN_FILES || fdnew==fdold) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 605,609 **** if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -EBADF; return; } --- 625,629 ---- if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 614,618 **** if(ioh == NULL) { ! ctx.Eax = -EBADF; return; } --- 634,638 ---- if(ioh == NULL) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 656,660 **** if(ioh==NULL) { ! ctx.Eax = -ENOMEM; return; } --- 676,680 ---- if(ioh==NULL) { ! ctx.Eax = -linux::ENOMEM; return; } *************** *** 690,694 **** if(ioh==NULL) { ! ctx.Eax = -ENOMEM; return; } --- 710,714 ---- if(ioh==NULL) { ! ctx.Eax = -linux::ENOMEM; return; } *************** *** 721,725 **** if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -EBADF; return; } --- 741,745 ---- if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 728,732 **** if(ioh == NULL) { ! ctx.Eax = -EBADF; return; } --- 748,752 ---- if(ioh == NULL) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 763,767 **** if(ioh==NULL) { ! ctx.Eax = -ENOMEM; return; } --- 783,787 ---- if(ioh==NULL) { ! ctx.Eax = -linux::ENOMEM; return; } *************** *** 797,801 **** if(ioh==NULL) { ! ctx.Eax = -ENOMEM; return; } --- 817,821 ---- if(ioh==NULL) { ! ctx.Eax = -linux::ENOMEM; return; } *************** *** 828,832 **** if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -EBADF; return; } --- 848,852 ---- if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 835,839 **** if(ioh == NULL) { ! ctx.Eax = -EBADF; return; } --- 855,859 ---- if(ioh == NULL) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 865,874 **** if(GetFileAttributes(p.GetWin32Path())==INVALID_FILE_ATTRIBUTES) { ! ctx.Eax = -ENOENT; //no file } else if(!p.IsSymbolicLink()) { ! ctx.Eax = -EINVAL; //not a link } else --- 885,894 ---- if(GetFileAttributes(p.GetWin32Path())==INVALID_FILE_ATTRIBUTES) { ! ctx.Eax = -linux::ENOENT; //no file } else if(!p.IsSymbolicLink()) { ! ctx.Eax = -linux::EINVAL; //not a link } else *************** *** 952,961 **** if(attr==INVALID_FILE_ATTRIBUTES) { ! ctx.Eax = -ENOENT; return; } if(attr & FILE_ATTRIBUTE_DIRECTORY) { ! ctx.Eax = -EISDIR; return; } --- 972,981 ---- if(attr==INVALID_FILE_ATTRIBUTES) { ! ctx.Eax = -linux::ENOENT; return; } if(attr & FILE_ATTRIBUTE_DIRECTORY) { ! ctx.Eax = -linux::EISDIR; return; } *************** *** 1022,1026 **** if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -EBADF; return; } --- 1042,1046 ---- if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 1029,1048 **** if(ioh == NULL) { ! ctx.Eax = -EBADF; return; } DWORD method; ! if(whence==SEEK_SET) method=FILE_BEGIN; else ! if(whence==SEEK_END) method=FILE_END; else ! if(whence==SEEK_CUR) method=FILE_CURRENT; else { ! ctx.Eax = -EINVAL; return; } --- 1049,1068 ---- if(ioh == NULL) { ! ctx.Eax = -linux::EBADF; return; } DWORD method; ! if(whence==linux::_SEEK_SET) method=FILE_BEGIN; else ! if(whence==linux::_SEEK_END) method=FILE_END; else ! if(whence==linux::_SEEK_CUR) method=FILE_CURRENT; else { ! ctx.Eax = -linux::EINVAL; return; } *************** *** 1073,1077 **** if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -EBADF; return; } --- 1093,1097 ---- if(fd<0 || fd>MAX_OPEN_FILES) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 1080,1084 **** if(ioh == NULL) { ! ctx.Eax = -EBADF; return; } --- 1100,1104 ---- if(ioh == NULL) { ! ctx.Eax = -linux::EBADF; return; } *************** *** 1095,1099 **** else { ! ctx.Eax = -EINVAL; return; } --- 1115,1119 ---- else { ! ctx.Eax = -linux::EINVAL; return; } *************** *** 1121,1127 **** linux::fd_set ReadRequest, WriteRequest, ExceptRequest; ! LINUX_FD_ZERO(&ReadRequest); ! LINUX_FD_ZERO(&WriteRequest); ! LINUX_FD_ZERO(&ExceptRequest); if(pReadFds) P->ReadMemory(&ReadRequest, (ADDR)pReadFds, sizeof(ReadRequest)); --- 1141,1147 ---- linux::fd_set ReadRequest, WriteRequest, ExceptRequest; ! KEOW_FD_ZERO(&ReadRequest); ! KEOW_FD_ZERO(&WriteRequest); ! KEOW_FD_ZERO(&ExceptRequest); if(pReadFds) P->ReadMemory(&ReadRequest, (ADDR)pReadFds, sizeof(ReadRequest)); *************** *** 1132,1138 **** linux::fd_set ReadResults, WriteResults, ExceptResults; ! LINUX_FD_ZERO(&ReadResults); ! LINUX_FD_ZERO(&WriteResults); ! LINUX_FD_ZERO(&ExceptResults); --- 1152,1158 ---- linux::fd_set ReadResults, WriteResults, ExceptResults; ! KEOW_FD_ZERO(&ReadResults); ! KEOW_FD_ZERO(&WriteResults); ! KEOW_FD_ZERO(&ExceptResults); *************** *** 1156,1177 **** for(int fd=0; fd<numFds; ++fd) { ! if( LINUX_FD_ISSET(fd, &ReadRequest) && P->m_OpenFiles[fd]!=NULL && P->m_OpenFiles[fd]->CanRead() ) { ! LINUX_FD_SET(fd, &ReadResults); foundData = true; } ! if( LINUX_FD_ISSET(fd, &WriteRequest) && P->m_OpenFiles[fd]!=NULL && P->m_OpenFiles[fd]->CanWrite() ) { ! LINUX_FD_SET(fd, &WriteResults); foundData = true; } ! if( LINUX_FD_ISSET(fd, &ExceptRequest) && P->m_OpenFiles[fd]!=NULL && P->m_OpenFiles[fd]->HasException() ) { ! LINUX_FD_SET(fd, &ExceptResults); foundData = true; } --- 1176,1197 ---- for(int fd=0; fd<numFds; ++fd) { ! if( KEOW_FD_ISSET(fd, &ReadRequest) && P->m_OpenFiles[fd]!=NULL && P->m_OpenFiles[fd]->CanRead() ) { ! KEOW_FD_SET(fd, &ReadResults); foundData = true; } ! if( KEOW_FD_ISSET(fd, &WriteRequest) && P->m_OpenFiles[fd]!=NULL && P->m_OpenFiles[fd]->CanWrite() ) { ! KEOW_FD_SET(fd, &WriteResults); foundData = true; } ! if( KEOW_FD_ISSET(fd, &ExceptRequest) && P->m_OpenFiles[fd]!=NULL && P->m_OpenFiles[fd]->HasException() ) { ! KEOW_FD_SET(fd, &ExceptResults); foundData = true; } Index: sys_sys.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/sys_sys.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** sys_sys.cpp 1 Nov 2005 17:49:10 -0000 1.5 --- sys_sys.cpp 22 Nov 2005 06:52:25 -0000 1.6 *************** *** 117,121 **** if(!pRLim) { ! ctx.Eax = -EFAULT; return; } --- 117,121 ---- if(!pRLim) { ! ctx.Eax = -linux::EFAULT; return; } *************** *** 124,162 **** switch(ctx.Ebx) { ! case RLIMIT_CPU: /* CPU time in ms */ ! RLim.rlim_cur = RLim.rlim_max = RLIM_INFINITY; break; ! case RLIMIT_FSIZE: /* Maximum filesize */ ! RLim.rlim_cur = RLim.rlim_max = RLIM_INFINITY; break; ! case RLIMIT_DATA: /* max data size */ ! RLim.rlim_cur = RLim.rlim_max = RLIM_INFINITY; break; ! case RLIMIT_STACK: /* max stack size */ RLim.rlim_cur = RLim.rlim_max = P->m_KeowUserStackTop - P->m_KeowUserStackBase; break; ! case RLIMIT_CORE: /* max core file size */ ! RLim.rlim_cur = RLim.rlim_max = RLIM_INFINITY; break; ! case RLIMIT_RSS: /* max resident set size */ ! RLim.rlim_cur = RLim.rlim_max = RLIM_INFINITY; break; ! case RLIMIT_NPROC: /* max number of processes */ ! RLim.rlim_cur = RLim.rlim_max = RLIM_INFINITY; break; ! case RLIMIT_NOFILE: /* max number of open files */ RLim.rlim_cur = RLim.rlim_max = MAX_OPEN_FILES; break; ! case RLIMIT_MEMLOCK: /* max locked-in-memory address space */ RLim.rlim_cur = RLim.rlim_max = 0x70000000; break; ! case RLIMIT_AS: /* address space limit */ RLim.rlim_cur = RLim.rlim_max = 0x7000000; break; ! case RLIMIT_LOCKS: /* maximum file locks held */ ! RLim.rlim_cur = RLim.rlim_max = RLIM_INFINITY; break; default: ! ctx.Eax = -EINVAL; return; } --- 124,162 ---- switch(ctx.Ebx) { ! case linux::RLIMIT_CPU: /* CPU time in ms */ ! RLim.rlim_cur = RLim.rlim_max = linux::RLIM_INFINITY; break; ! case linux::RLIMIT_FSIZE: /* Maximum filesize */ ! RLim.rlim_cur = RLim.rlim_max = linux::RLIM_INFINITY; break; ! case linux::RLIMIT_DATA: /* max data size */ ! RLim.rlim_cur = RLim.rlim_max = linux::RLIM_INFINITY; break; ! case linux::RLIMIT_STACK: /* max stack size */ RLim.rlim_cur = RLim.rlim_max = P->m_KeowUserStackTop - P->m_KeowUserStackBase; break; ! case linux::RLIMIT_CORE: /* max core file size */ ! RLim.rlim_cur = RLim.rlim_max = linux::RLIM_INFINITY; break; ! case linux::RLIMIT_RSS: /* max resident set size */ ! RLim.rlim_cur = RLim.rlim_max = linux::RLIM_INFINITY; break; ! case linux::RLIMIT_NPROC: /* max number of processes */ ! RLim.rlim_cur = RLim.rlim_max = linux::RLIM_INFINITY; break; ! case linux::RLIMIT_NOFILE: /* max number of open files */ RLim.rlim_cur = RLim.rlim_max = MAX_OPEN_FILES; break; ! case linux::RLIMIT_MEMLOCK: /* max locked-in-memory address space */ RLim.rlim_cur = RLim.rlim_max = 0x70000000; break; ! case linux::RLIMIT_AS: /* address space limit */ RLim.rlim_cur = RLim.rlim_max = 0x7000000; break; ! case linux::RLIMIT_LOCKS: /* maximum file locks held */ ! RLim.rlim_cur = RLim.rlim_max = linux::RLIM_INFINITY; break; default: ! ctx.Eax = -linux::EINVAL; return; } *************** *** 175,179 **** if(!pRLim) { ! ctx.Eax = -EFAULT; return; } --- 175,179 ---- if(!pRLim) { ! ctx.Eax = -linux::EFAULT; return; } *************** *** 182,220 **** switch(ctx.Ebx) { ! case RLIMIT_CPU: /* CPU time in ms */ ! RLim.rlim_cur = RLim.rlim_max = RLIM_INFINITY; break; ! case RLIMIT_FSIZE: /* Maximum filesize */ ! RLim.rlim_cur = RLim.rlim_max = RLIM_INFINITY; break; ! case RLIMIT_DATA: /* max data size */ ! RLim.rlim_cur = RLim.rlim_max = RLIM_INFINITY; break; ! case RLIMIT_STACK: /* max stack size */ RLim.rlim_cur = RLim.rlim_max = P->m_KeowUserStackTop - P->m_KeowUserStackBase; break; ! case RLIMIT_CORE: /* max core file size */ ! RLim.rlim_cur = RLim.rlim_max = RLIM_INFINITY; break; ! case RLIMIT_RSS: /* max resident set size */ ! RLim.rlim_cur = RLim.rlim_max = RLIM_INFINITY; break; ! case RLIMIT_NPROC: /* max number of processes */ ! RLim.rlim_cur = RLim.rlim_max = RLIM_INFINITY; break; ! case RLIMIT_NOFILE: /* max number of open files */ RLim.rlim_cur = RLim.rlim_max = MAX_OPEN_FILES; break; ! case RLIMIT_MEMLOCK: /* max locked-in-memory address space */ RLim.rlim_cur = RLim.rlim_max = 0x70000000; break; ! case RLIMIT_AS: /* address space limit */ RLim.rlim_cur = RLim.rlim_max = 0x7000000; break; ! case RLIMIT_LOCKS: /* maximum file locks held */ ! RLim.rlim_cur = RLim.rlim_max = RLIM_INFINITY; break; default: ! ctx.Eax = -EINVAL; return; } --- 182,220 ---- switch(ctx.Ebx) { ! case linux::RLIMIT_CPU: /* CPU time in ms */ ! RLim.rlim_cur = RLim.rlim_max = linux::RLIM_INFINITY; break; ! case linux::RLIMIT_FSIZE: /* Maximum filesize */ ! RLim.rlim_cur = RLim.rlim_max = linux::RLIM_INFINITY; break; ! case linux::RLIMIT_DATA: /* max data size */ ! RLim.rlim_cur = RLim.rlim_max = linux::RLIM_INFINITY; break; ! case linux::RLIMIT_STACK: /* max stack size */ RLim.rlim_cur = RLim.rlim_max = P->m_KeowUserStackTop - P->m_KeowUserStackBase; break; ! case linux::RLIMIT_CORE: /* max core file size */ ! RLim.rlim_cur = RLim.rlim_max = linux::RLIM_INFINITY; break; ! case linux::RLIMIT_RSS: /* max resident set size */ ! RLim.rlim_cur = RLim.rlim_max = linux::RLIM_INFINITY; break; ! case linux::RLIMIT_NPROC: /* max number of processes */ ! RLim.rlim_cur = RLim.rlim_max = linux::RLIM_INFINITY; break; ! case linux::RLIMIT_NOFILE: /* max number of open files */ RLim.rlim_cur = RLim.rlim_max = MAX_OPEN_FILES; break; ! case linux::RLIMIT_MEMLOCK: /* max locked-in-memory address space */ RLim.rlim_cur = RLim.rlim_max = 0x70000000; break; ! case linux::RLIMIT_AS: /* address space limit */ RLim.rlim_cur = RLim.rlim_max = 0x7000000; break; ! case linux::RLIMIT_LOCKS: /* maximum file locks held */ ! RLim.rlim_cur = RLim.rlim_max = linux::RLIM_INFINITY; break; default: ! ctx.Eax = -linux::EINVAL; return; } *************** *** 232,253 **** void SysCalls::sys_reboot(CONTEXT &ctx) { ! ctx.Eax = -EINVAL; ! if(ctx.Ebx != LINUX_REBOOT_MAGIC1) return; ! if(ctx.Ecx != LINUX_REBOOT_MAGIC2 ! && ctx.Ecx != LINUX_REBOOT_MAGIC2A ! && ctx.Ecx != LINUX_REBOOT_MAGIC2B) return; switch(ctx.Edx) { ! case LINUX_REBOOT_CMD_RESTART: ! case LINUX_REBOOT_CMD_HALT: ! case LINUX_REBOOT_CMD_CAD_ON: ! case LINUX_REBOOT_CMD_CAD_OFF: ! case LINUX_REBOOT_CMD_POWER_OFF: ! case LINUX_REBOOT_CMD_RESTART2: ktrace("Implement me: Dummy reboot() - no action taken\n"); ctx.Eax = 0; --- 232,253 ---- void SysCalls::sys_reboot(CONTEXT &ctx) { ! ctx.Eax = -linux::EINVAL; ! if(ctx.Ebx != linux::LINUX_REBOOT_MAGIC1) return; ! if(ctx.Ecx != linux::LINUX_REBOOT_MAGIC2 ! && ctx.Ecx != linux::LINUX_REBOOT_MAGIC2A ! && ctx.Ecx != linux::LINUX_REBOOT_MAGIC2B) return; switch(ctx.Edx) { ! case linux::LINUX_REBOOT_CMD_RESTART: ! case linux::LINUX_REBOOT_CMD_HALT: ! case linux::LINUX_REBOOT_CMD_CAD_ON: ! case linux::LINUX_REBOOT_CMD_CAD_OFF: ! case linux::LINUX_REBOOT_CMD_POWER_OFF: ! case linux::LINUX_REBOOT_CMD_RESTART2: ktrace("Implement me: Dummy reboot() - no action taken\n"); ctx.Eax = 0; *************** *** 267,273 **** unsigned int sig = ctx.Ecx; ! if(sig>=_NSIG) { ! ctx.Eax = -EINVAL; return; } --- 267,273 ---- unsigned int sig = ctx.Ecx; ! if(sig>=linux::_NSIG) { ! ctx.Eax = -linux::EINVAL; return; } *************** *** 278,282 **** if(pid>0) { ! ctx.Eax = -ESRCH; Process * pDest = g_pKernelTable->FindProcess(pid); if(pDest!=NULL) --- 278,282 ---- if(pid>0) { ! ctx.Eax = -linux::ESRCH; Process * pDest = g_pKernelTable->FindProcess(pid); if(pDest!=NULL) *************** *** 374,389 **** switch(request) { ! case PTRACE_TRACEME: ktrace("ptrace PTRACE_TRACEME\n"); P->m_ptrace.OwnerPid = P->m_ParentPid; ! P->m_ptrace.Request = PTRACE_TRACEME; ctx.Eax = 0; break; ! case PTRACE_SYSCALL: { ktrace("ptrace PTRACE_SYSCALL pid %d\n", pid); ! pTraced->m_ptrace.Request = PTRACE_SYSCALL; ! if((int)data!=0 && (int)data!=SIGSTOP) pTraced->m_ptrace.new_signal = (int)data; ktrace("ptrace_syscall resuming pid %d\n",pid); --- 374,389 ---- switch(request) { ! case linux::PTRACE_TRACEME: ktrace("ptrace PTRACE_TRACEME\n"); P->m_ptrace.OwnerPid = P->m_ParentPid; ! P->m_ptrace.Request = linux::PTRACE_TRACEME; ctx.Eax = 0; break; ! case linux::PTRACE_SYSCALL: { ktrace("ptrace PTRACE_SYSCALL pid %d\n", pid); ! pTraced->m_ptrace.Request = linux::PTRACE_SYSCALL; ! if((int)data!=0 && (int)data!=linux::SIGSTOP) pTraced->m_ptrace.new_signal = (int)data; ktrace("ptrace_syscall resuming pid %d\n",pid); *************** *** 393,401 **** break; ! case PTRACE_CONT: { ktrace("ptrace PTRACE_CONT pid %d\n", pid); pTraced->m_ptrace.Request = 0; ! if((int)data!=0 && (int)data!=SIGSTOP) pTraced->m_ptrace.new_signal = (int)data; ktrace("ptrace_cont resuming pid %d\n",pid); --- 393,401 ---- break; ! case linux::PTRACE_CONT: { ktrace("ptrace PTRACE_CONT pid %d\n", pid); pTraced->m_ptrace.Request = 0; ! if((int)data!=0 && (int)data!=linux::SIGSTOP) pTraced->m_ptrace.new_signal = (int)data; ktrace("ptrace_cont resuming pid %d\n",pid); *************** *** 405,409 **** break; ! case PTRACE_PEEKUSR: { ktrace("ptrace PTRACE_PEEKUSR pid %d addr 0x%lx (reg %ld) data 0x%08lx\n", pid, addr, (DWORD)addr>>2, data); --- 405,409 ---- break; ! case linux::PTRACE_PEEKUSR: { ktrace("ptrace PTRACE_PEEKUSR pid %d addr 0x%lx (reg %ld) data 0x%08lx\n", pid, addr, (DWORD)addr>>2, data); *************** *** 411,415 **** if((unsigned long)addr > sizeof(linux::user)-3) { ! ctx.Eax = -EFAULT; break; } --- 411,415 ---- if((unsigned long)addr > sizeof(linux::user)-3) { ! ctx.Eax = -linux::EFAULT; break; } *************** *** 471,476 **** break; ! case PTRACE_PEEKTEXT: ! case PTRACE_PEEKDATA: { ktrace("ptrace PTRACE_PEEKDATA pid %d addr 0x%lx data 0x%08lx\n", pid, addr, data); --- 471,476 ---- break; ! case linux::PTRACE_PEEKTEXT: ! case linux::PTRACE_PEEKDATA: { ktrace("ptrace PTRACE_PEEKDATA pid %d addr 0x%lx data 0x%08lx\n", pid, addr, data); *************** *** 478,482 **** if(!pTraced->ReadMemory(&tmp, (ADDR)addr, sizeof(tmp))) { ! ctx.Eax = -EFAULT; } else --- 478,482 ---- if(!pTraced->ReadMemory(&tmp, (ADDR)addr, sizeof(tmp))) { ! ctx.Eax = -linux::EFAULT; } else *************** *** 489,495 **** break; ! case PTRACE_KILL: ktrace("ptrace PTRACE_KILL pid %d \n", pid); ! pTraced->SendSignal(SIGKILL); ResumeThread(pTraced->m_KernelThreadHandle); //need to wake kernel handler thread so it can die ctx.Eax = 0; --- 489,495 ---- break; ! case linux::PTRACE_KILL: ktrace("ptrace PTRACE_KILL pid %d \n", pid); ! pTraced->SendSignal(linux::SIGKILL); ResumeThread(pTraced->m_KernelThreadHandle); //need to wake kernel handler thread so it can die ctx.Eax = 0; *************** *** 498,502 **** default: ktrace("IMPLEMENT ptrace request %lx\n", ctx.Ebx); ! ctx.Eax = -ENOSYS; break; } --- 498,502 ---- default: ktrace("IMPLEMENT ptrace request %lx\n", ctx.Ebx); ! ctx.Eax = -linux::ENOSYS; break; } *************** *** 525,529 **** if(WaitForSingleObject(P->m_hWaitTerminatingEvent, msec) == WAIT_OBJECT_0) { ! ctx.Eax = -EINTR; } else --- 525,529 ---- if(WaitForSingleObject(P->m_hWaitTerminatingEvent, msec) == WAIT_OBJECT_0) { ! ctx.Eax = -linux::EINTR; } else Index: Process.h =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/Process.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Process.h 30 Oct 2005 01:20:17 -0000 1.7 --- Process.h 22 Nov 2005 06:52:25 -0000 1.8 *************** *** 44,48 **** #define MAX_OPEN_FILES 1024 #define MAX_PENDING_SIGNALS 128 ! #define MAX_SIGNALS _NSIG class Process --- 44,48 ---- #define MAX_OPEN_FILES 1024 #define MAX_PENDING_SIGNALS 128 ! #define MAX_SIGNALS linux::_NSIG class Process *************** *** 201,207 **** int m_CurrentSignal; int m_KilledBySig; ! bool m_PendingSignals[_NSIG]; linux::sigset_t m_SignalMask; ! linux::sigaction m_SignalAction[_NSIG]; //we save this stuff when calling signal handlers, so that we can return from the signal --- 201,207 ---- int m_CurrentSignal; int m_KilledBySig; ! bool m_PendingSignals[linux::_NSIG]; linux::sigset_t m_SignalMask; ! linux::sigaction m_SignalAction[linux::_NSIG]; //we save this stuff when calling signal handlers, so that we can return from the signal --- NEW FILE: SocketCalls.h --- /* * Copyright 2005 Paul Walker * * GNU General Public License * * This file is part of: Kernel Emulation on Windows (keow) * * Keow is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Keow is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Keow; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ // SocketCalls.h: interface for the SocketCalls class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_SOCKETCALLS_H__BEFB0766_48E6_4C88_A8C1_74FD826CD1DD__INCLUDED_) #define AFX_SOCKETCALLS_H__BEFB0766_48E6_4C88_A8C1_74FD826CD1DD__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 class SocketCalls { public: static void sys_socketcall(CONTEXT &ctx); static int sys_socket(int domain, int type, int protocol); static int sys_bind(int sockfd, linux::sockaddr *my_addr, linux::socklen_t addrlen); static int sys_connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen); static int sys_listen(a0,a1); static int sys_accept(a0,(struct sockaddr __user *)a1, (static int __user *)a[2]); static int sys_getsockname(a0,(struct sockaddr __user *)a1, (static int __user *)a[2]); static int sys_getpeername(a0, (struct sockaddr __user *)a1, (static int __user *)a[2]); static int sys_socketpair(a0,a1, a[2], (static int __user *)a[3]); static int sys_send(a0, (void __user *)a1, a[2], a[3]); static int sys_sendto(a0,(void __user *)a1, a[2], a[3], (struct sockaddr __user *)a[4], a[5]); static int sys_recv(a0, (void __user *)a1, a[2], a[3]); static int sys_recvfrom(a0, (void __user *)a1, a[2], a[3], (struct sockaddr __user *)a[4], (static int __user *)a[5]); static int sys_shutdown(a0,a1); static int sys_setsockopt(a0, a1, a[2], (char __user *)a[3], a[4]); static int sys_getsockopt(a0, a1, a[2], (char __user *)a[3], (static int __user *)a[4]); static int sys_sendmsg(a0, (struct msghdr __user *) a1, a[2]); static int sys_recvmsg(a0, (struct msghdr __user *) a1, a[2]); private: SocketCalls() {} }; #endif // !defined(AFX_SOCKETCALLS_H__BEFB0766_48E6_4C88_A8C1_74FD826CD1DD__INCLUDED_) Index: IOHNtConsole.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/IOHNtConsole.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IOHNtConsole.cpp 13 Oct 2005 06:52:11 -0000 1.4 --- IOHNtConsole.cpp 22 Nov 2005 06:52:25 -0000 1.5 *************** *** 86,90 **** return false; ! IOHandler::BasicStat64(s, S_IFCHR); //console is a character device return true; --- 86,90 ---- return false; ! IOHandler::BasicStat64(s, linux::S_IFCHR); //console is a character device return true; *************** *** 99,103 **** bool IOHNtConsole::Read(void* address, DWORD size, DWORD *pRead) { ! if(m_Flags&O_NONBLOCK) { //non-blocking - ensure we can do the read before doing it --- 99,103 ---- bool IOHNtConsole::Read(void* address, DWORD size, DWORD *pRead) { ! if(m_Flags&linux::O_NONBLOCK) { //non-blocking - ensure we can do the read before doing it Index: SysCalls.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/SysCalls.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SysCalls.cpp 1 Nov 2005 17:49:10 -0000 1.5 --- SysCalls.cpp 22 Nov 2005 06:52:25 -0000 1.6 *************** *** 29,34 **** #include "SysCalls.h" ! SysCalls::SYSCALL_HANDLER SysCalls::syscall_handlers[NR_syscalls]; ! const char* SysCalls::syscall_names[NR_syscalls]; // eax is the syscall number --- 29,34 ---- #include "SysCalls.h" ! SysCalls::SYSCALL_HANDLER SysCalls::syscall_handlers[linux::NR_syscalls]; ! const char* SysCalls::syscall_names[linux::NR_syscalls]; // eax is the syscall number *************** *** 43,47 **** { //default all syscalls to unhandled ! for(int i=0; i<NR_syscalls; ++i) syscall_handlers[i] = Unhandled; --- 43,47 ---- { //default all syscalls to unhandled ! for(int i=0; i<linux::NR_syscalls; ++i) syscall_handlers[i] = Unhandled; *************** *** 50,55 **** // #define DEF_SYSCALL(n) \ ! syscall_handlers[__NR_##n]=sys_##n; \ ! syscall_names[__NR_##n]=#n; DEF_SYSCALL(exit); --- 50,55 ---- // #define DEF_SYSCALL(n) \ ! syscall_handlers[linux::__NR_##n]=sys_##n; \ ! syscall_names[linux::__NR_##n]=#n; DEF_SYSCALL(exit); *************** *** 322,331 **** P->m_ptrace.ctx_valid = true; ! if(syscall < NR_syscalls) { ktrace("debug: syscall %d [%s] from @ 0x%08lx\n", ctx.Eax, syscall_names[ctx.Eax], ctx.Eip); if(P->m_ptrace.OwnerPid ! && P->m_ptrace.Request == PTRACE_SYSCALL ) { ktrace("stopping for ptrace on syscall entry eax=%d\n", syscall); --- 322,331 ---- P->m_ptrace.ctx_valid = true; ! if(syscall < linux::NR_syscalls) { ktrace("debug: syscall %d [%s] from @ 0x%08lx\n", ctx.Eax, syscall_names[ctx.Eax], ctx.Eip); if(P->m_ptrace.OwnerPid ! && P->m_ptrace.Request == linux::PTRACE_SYSCALL ) { ktrace("stopping for ptrace on syscall entry eax=%d\n", syscall); *************** *** 335,341 **** P->m_ptrace.Saved_Eax = syscall; ! P->m_ptrace.ctx.Eax = (DWORD)-ENOSYS; //this is what ptrace in the tracer sees as eax ! P->SendSignal(SIGTRAP); } --- 335,341 ---- P->m_ptrace.Saved_Eax = syscall; ! P->m_ptrace.ctx.Eax = (DWORD)-linux::ENOSYS; //this is what ptrace in the tracer sees as eax ! P->SendSignal(linux::SIGTRAP); } *************** *** 349,353 **** if(P->m_ptrace.OwnerPid ! && P->m_ptrace.Request == PTRACE_SYSCALL ) { ktrace("stopping for ptrace on syscall exit eax=%d, orig=%d\n", ctx.Eax, syscall); --- 349,353 ---- if(P->m_ptrace.OwnerPid ! && P->m_ptrace.Request == linux::PTRACE_SYSCALL ) { ktrace("stopping for ptrace on syscall exit eax=%d, orig=%d\n", ctx.Eax, syscall); *************** *** 359,363 **** P->m_ptrace.Saved_Eax = syscall; ! P->SendSignal(SIGTRAP); } } --- 359,363 ---- P->m_ptrace.Saved_Eax = syscall; ! P->SendSignal(linux::SIGTRAP); } } *************** *** 379,385 **** void SysCalls::Unhandled(CONTEXT &ctx) { ! ktrace("NOT IMPLEMENTED: syscall %d %s\n", ctx.Eax, ((int)ctx.Eax)<NR_syscalls?syscall_names[ctx.Eax]:"?"... [truncated message content] |
From: Paul <pa...@us...> - 2005-11-22 06:52:33
|
Update of /cvsroot/keow/keow/keow-kernel/KeowConsole In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10093/keow-kernel/KeowConsole Modified Files: KeowConsole.cpp KeowConsole.dsp Log Message: No longer using real kernel headers. Far too many conflicts with windows headers using same #defines. Index: KeowConsole.dsp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowConsole/KeowConsole.dsp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** KeowConsole.dsp 24 Sep 2005 06:57:08 -0000 1.3 --- KeowConsole.dsp 22 Nov 2005 06:52:24 -0000 1.4 *************** *** 43,47 **** # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c ! # ADD CPP /nologo /W3 /GX /Zi /O2 /I "..\kernel-headers-2.4.24-1\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX"sdxafx.h" /FD /c # ADD BASE RSC /l 0x1409 /d "NDEBUG" # ADD RSC /l 0x1409 /d "NDEBUG" --- 43,47 ---- # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c ! # ADD CPP /nologo /W3 /GX /Zi /O2 /I "..\KeowKernel\linux-abi" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX"sdxafx.h" /FD /c # ADD BASE RSC /l 0x1409 /d "NDEBUG" # ADD RSC /l 0x1409 /d "NDEBUG" *************** *** 67,71 **** # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c ! # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\kernel-headers-2.4.24-1\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX"sdxafx.h" /FD /GZ /c # ADD BASE RSC /l 0x1409 /d "_DEBUG" # ADD RSC /l 0x1409 /d "_DEBUG" --- 67,71 ---- # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c ! # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\KeowKernel\linux-abi" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX"sdxafx.h" /FD /GZ /c # ADD BASE RSC /l 0x1409 /d "_DEBUG" # ADD RSC /l 0x1409 /d "_DEBUG" Index: KeowConsole.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowConsole/KeowConsole.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** KeowConsole.cpp 13 Oct 2005 06:52:11 -0000 1.4 --- KeowConsole.cpp 22 Nov 2005 06:52:24 -0000 1.5 *************** *** 82,97 **** switch(dwRequestType) { ! case TCSETSW: //flush output //console io never buffered, so not required //...fall through... ! case TCSETSF: //flush input & output FlushConsoleInputBuffer(g_hConsoleInput); //...fall through... ! case TCSETS: //set stty stuff break; ! case TIOCGWINSZ: //get window size { linux::winsize rec; --- 82,97 ---- switch(dwRequestType) { ! case linux::TCSETSW: //flush output //console io never buffered, so not required //...fall through... ! case linux::TCSETSF: //flush input & output FlushConsoleInputBuffer(g_hConsoleInput); //...fall through... ! case linux::TCSETS: //set stty stuff break; ! case linux::TIOCGWINSZ: //get window size { linux::winsize rec; *************** *** 113,117 **** break; ! case TIOCSWINSZ: //set window size { linux::winsize rec; --- 113,117 ---- break; ! case linux::TIOCSWINSZ: //set window size { linux::winsize rec; |
From: Paul <pa...@us...> - 2005-11-22 06:52:33
|
Update of /cvsroot/keow/keow/keow-kernel/KeowKernel/linux-abi/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10093/keow-kernel/KeowKernel/linux-abi/linux Added Files: defines.h types.h Log Message: No longer using real kernel headers. Far too many conflicts with windows headers using same #defines. --- NEW FILE: types.h --- /* * Copyright 2005 Paul Walker * * GNU General Public License * * This file is part of: Kernel Emulation on Windows (keow) * * Keow is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Keow is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Keow; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* * This is an include file based on linux kernel sources. * It helps describe the user-kernel interface. * We have this rather than the actual kernel headers because * there are too many #defines that would conflict the windows * versions (which are often different values. eg AF_INET6 in sockets). * This is a pair with linux/defines.h */ #ifndef _LINUX_TYPES_H #define _LINUX_TYPES_H #pragma pack(push,1) //all linux structures are byte aligned? //all vars in own namespace to ease co-existence with windows ones namespace linux { typedef signed char __s8; typedef unsigned char __u8; typedef signed short __s16; typedef unsigned short __u16; typedef signed int __s32; typedef unsigned int __u32; typedef signed __int64 __s64; typedef unsigned __int64 __u64; typedef __int64 __kernel_loff_t; typedef __kernel_loff_t loff_t; typedef struct { unsigned long fds_bits [__FDSET_LONGS]; } __kernel_fd_set; typedef unsigned short __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned short __kernel_mode_t; typedef unsigned short __kernel_nlink_t; typedef long __kernel_off_t; typedef int __kernel_pid_t; typedef unsigned short __kernel_ipc_pid_t; typedef unsigned short __kernel_uid_t; typedef unsigned short __kernel_gid_t; typedef unsigned int __kernel_size_t; typedef int __kernel_ssize_t; typedef int __kernel_ptrdiff_t; typedef long __kernel_time_t; typedef long __kernel_suseconds_t; typedef long __kernel_clock_t; typedef int __kernel_daddr_t; typedef char * __kernel_caddr_t; typedef unsigned short __kernel_uid16_t; typedef unsigned short __kernel_gid16_t; typedef unsigned int __kernel_uid32_t; typedef unsigned int __kernel_gid32_t; typedef unsigned short __kernel_old_uid_t; typedef unsigned short __kernel_old_gid_t; typedef __kernel_fd_set fd_set; typedef __kernel_dev_t dev_t; typedef __kernel_ino_t ino_t; typedef __kernel_mode_t mode_t; typedef __kernel_nlink_t nlink_t; typedef __kernel_off_t off_t; typedef __kernel_pid_t pid_t; typedef __kernel_daddr_t daddr_t; //typedef __kernel_key_t key_t; typedef __kernel_suseconds_t suseconds_t; typedef __kernel_uid32_t uid_t; typedef __kernel_gid32_t gid_t; typedef __kernel_uid16_t uid16_t; typedef __kernel_gid16_t gid16_t; typedef __kernel_old_uid_t old_uid_t; typedef __kernel_old_gid_t old_gid_t; typedef __kernel_loff_t loff_t; typedef __kernel_size_t size_t; typedef __kernel_ssize_t ssize_t; typedef __kernel_ptrdiff_t ptrdiff_t; typedef __kernel_time_t time_t; typedef __kernel_clock_t clock_t; typedef __kernel_caddr_t caddr_t; typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned int u_int; typedef unsigned long u_long; typedef unsigned char unchar; typedef unsigned short ushort; typedef unsigned int uint; typedef unsigned long ulong; typedef __u8 u_int8_t; typedef __s8 int8_t; typedef __u16 u_int16_t; typedef __s16 int16_t; typedef __u32 u_int32_t; typedef __s32 int32_t; typedef __u8 uint8_t; typedef __u16 uint16_t; typedef __u32 uint32_t; typedef __u64 uint64_t; typedef __u64 u_int64_t; typedef __s64 int64_t; struct winsize { unsigned short ws_row; unsigned short ws_col; unsigned short ws_xpixel; unsigned short ws_ypixel; }; #define NCC 8 struct termio { unsigned short c_iflag; /* input mode flags */ unsigned short c_oflag; /* output mode flags */ unsigned short c_cflag; /* control mode flags */ unsigned short c_lflag; /* local mode flags */ unsigned char c_line; /* line discipline */ unsigned char c_cc[NCC]; /* control characters */ }; typedef unsigned char cc_t; typedef unsigned int speed_t; typedef unsigned int tcflag_t; #define NCCS 19 struct termios { tcflag_t c_iflag; /* input mode flags */ tcflag_t c_oflag; /* output mode flags */ tcflag_t c_cflag; /* control mode flags */ tcflag_t c_lflag; /* local mode flags */ cc_t c_line; /* line discipline */ cc_t c_cc[NCCS]; /* control characters */ }; /* 32-bit ELF base types. */ typedef __u32 Elf32_Addr; typedef __u16 Elf32_Half; typedef __u32 Elf32_Off; typedef __s32 Elf32_Sword; typedef __u32 Elf32_Word; #define EI_NIDENT 16 typedef struct elf32_hdr{ unsigned char e_ident[EI_NIDENT]; Elf32_Half e_type; Elf32_Half e_machine; Elf32_Word e_version; Elf32_Addr e_entry; /* Entry point */ Elf32_Off e_phoff; Elf32_Off e_shoff; Elf32_Word e_flags; Elf32_Half e_ehsize; Elf32_Half e_phentsize; Elf32_Half e_phnum; Elf32_Half e_shentsize; Elf32_Half e_shnum; Elf32_Half e_shstrndx; } Elf32_Ehdr; typedef struct elf32_phdr{ Elf32_Word p_type; Elf32_Off p_offset; Elf32_Addr p_vaddr; Elf32_Addr p_paddr; Elf32_Word p_filesz; Elf32_Word p_memsz; Elf32_Word p_flags; Elf32_Word p_align; } Elf32_Phdr; struct stat { unsigned short st_dev; unsigned short __pad1; unsigned long st_ino; unsigned short st_mode; unsigned short st_nlink; unsigned short st_uid; unsigned short st_gid; unsigned short st_rdev; unsigned short __pad2; unsigned long st_size; unsigned long st_blksize; unsigned long st_blocks; unsigned long st_atime; unsigned long __unused1; unsigned long st_mtime; unsigned long __unused2; unsigned long st_ctime; unsigned long __unused3; unsigned long __unused4; unsigned long __unused5; }; /* This matches struct stat64 in glibc2.1, hence the absolutely * insane amounts of padding around dev_t's. */ struct stat64 { unsigned short st_dev; unsigned char __pad0[10]; #define STAT64_HAS_BROKEN_ST_INO 1 unsigned long __st_ino; unsigned int st_mode; unsigned int st_nlink; unsigned long st_uid; unsigned long st_gid; unsigned short st_rdev; unsigned char __pad3[10]; //long long st_size; __s64 st_size; unsigned long st_blksize; unsigned long st_blocks; /* Number 512-byte blocks allocated. */ unsigned long __pad4; /* future possible st_blocks high bits */ unsigned long st_atime; unsigned long __pad5; unsigned long st_mtime; unsigned long __pad6; unsigned long st_ctime; unsigned long __pad7; /* will be high 32 bits of ctime someday */ //unsigned long long st_ino; __u64 st_ino; }; struct dirent { long d_ino; __kernel_off_t d_off; unsigned short d_reclen; char d_name[256]; /* We must not include limits.h! */ }; struct dirent64 { __u64 d_ino; __s64 d_off; unsigned short d_reclen; unsigned char d_type; char d_name[256]; }; /* Type of a signal handler. */ typedef void (*__sighandler_t)(int); #define SIG_DFL ((linux::__sighandler_t)0) /* default signal handling */ #define SIG_IGN ((linux::__sighandler_t)1) /* ignore signal */ #define SIG_ERR ((linux::__sighandler_t)-1) /* error return from signal */ typedef unsigned long old_sigset_t; /* at least 32 bits */ typedef struct { unsigned long sig[_NSIG_WORDS]; } sigset_t; struct old_sigaction { __sighandler_t sa_handler; old_sigset_t sa_mask; unsigned long sa_flags; void (*sa_restorer)(void); }; struct sigaction { __sighandler_t sa_handler; unsigned long sa_flags; void (*sa_restorer)(void); sigset_t sa_mask; /* mask last for extensibility */ }; typedef union sigval { int sival_int; void *sival_ptr; } sigval_t; #define SI_MAX_SIZE 128 #define SI_PAD_SIZE ((SI_MAX_SIZE/sizeof(int)) - 3) typedef struct siginfo { int si_signo; int si_errno; int si_code; union { int _pad[SI_PAD_SIZE]; /* kill() */ struct { pid_t _pid; /* sender's pid */ uid_t _uid; /* sender's uid */ } _kill; /* POSIX.1b timers */ struct { unsigned int _timer1; unsigned int _timer2; } _timer; /* POSIX.1b signals */ struct { pid_t _pid; /* sender's pid */ uid_t _uid; /* sender's uid */ sigval_t _sigval; } _rt; /* SIGCHLD */ struct { pid_t _pid; /* which child */ uid_t _uid; /* sender's uid */ int _status; /* exit code */ clock_t _utime; clock_t _stime; } _sigchld; /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ struct { void *_addr; /* faulting insn/memory ref. */ } _sigfault; /* SIGPOLL */ struct { int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ int _fd; } _sigpoll; } _sifields; } siginfo_t; struct flock { short l_type; short l_whence; off_t l_start; off_t l_len; pid_t l_pid; }; struct flock64 { short l_type; short l_whence; loff_t l_start; loff_t l_len; pid_t l_pid; }; struct iovec { void *iov_base; /* BSD uses caddr_t (1003.1g requires void *) */ __kernel_size_t iov_len; /* Must be size_t (1003.1g) */ }; struct timespec { time_t tv_sec; /* seconds */ long tv_nsec; /* nanoseconds */ }; struct timeval { time_t tv_sec; /* seconds */ suseconds_t tv_usec; /* microseconds */ }; struct timezone { int tz_minuteswest; /* minutes west of Greenwich */ int tz_dsttime; /* type of dst correction */ }; struct utimbuf { time_t actime; time_t modtime; }; struct mmap_arg_struct { //from kernel source tree 2.6.11 unsigned long addr; unsigned long len; unsigned long prot; unsigned long flags; unsigned long fd; unsigned long offset; }; struct rusage { struct timeval ru_utime; /* user time used */ struct timeval ru_stime; /* system time used */ long ru_maxrss; /* maximum resident set size */ long ru_ixrss; /* integral shared memory size */ long ru_idrss; /* integral unshared data size */ long ru_isrss; /* integral unshared stack size */ long ru_minflt; /* page reclaims */ long ru_majflt; /* page faults */ long ru_nswap; /* swaps */ long ru_inblock; /* block input operations */ long ru_oublock; /* block output operations */ long ru_msgsnd; /* messages sent */ long ru_msgrcv; /* messages received */ long ru_nsignals; /* signals received */ long ru_nvcsw; /* voluntary context switches */ long ru_nivcsw; /* involuntary " */ }; struct rlimit { unsigned long rlim_cur; unsigned long rlim_max; }; struct new_utsname { char sysname[65]; char nodename[65]; char release[65]; char version[65]; char machine[65]; char domainname[65]; }; struct user_i387_struct { long cwd; long swd; long twd; long fip; long fcs; long foo; long fos; long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ }; struct user_fxsr_struct { unsigned short cwd; unsigned short swd; unsigned short twd; unsigned short fop; long fip; long fcs; long foo; long fos; long mxcsr; long reserved; long st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */ long xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */ long padding[56]; }; struct user_regs_struct { long ebx, ecx, edx, esi, edi, ebp, eax; unsigned short ds, __ds, es, __es; unsigned short fs, __fs, gs, __gs; long orig_eax, eip; unsigned short cs, __cs; long eflags, esp; unsigned short ss, __ss; }; /* When the kernel dumps core, it starts by dumping the user struct - this will be used by gdb to figure out where the data and stack segments are within the file, and what virtual addresses to use. */ struct user{ /* We start with the registers, to mimic the way that "memory" is returned from the ptrace(3,...) function. */ struct user_regs_struct regs; /* Where the registers are actually stored */ /* ptrace does not yet supply these. Someday.... */ int u_fpvalid; /* True if math co-processor being used. */ /* for this mess. Not yet used. */ struct user_i387_struct i387; /* Math Co-processor registers. */ /* The rest of this junk is to help gdb figure out what goes where */ unsigned long int u_tsize; /* Text segment size (pages). */ unsigned long int u_dsize; /* Data segment size (pages). */ unsigned long int u_ssize; /* Stack segment size (pages). */ unsigned long start_code; /* Starting virtual address of text. */ unsigned long start_stack; /* Starting virtual address of stack area. This is actually the bottom of the stack, the top of the stack is always found in the esp register. */ long int signal; /* Signal that caused the core dump. */ int reserved; /* No longer used */ struct user_pt_regs * u_ar0; /* Used by gdb to help find the values for */ /* the registers. */ struct user_i387_struct* u_fpstate; /* Math Co-processor pointer. */ unsigned long magic; /* To uniquely identify a core file */ char u_comm[32]; /* User command that was responsible */ int u_debugreg[8]; }; struct sysinfo { long uptime; /* Seconds since boot */ unsigned long loads[3]; /* 1, 5, and 15 minute load averages */ unsigned long totalram; /* Total usable main memory size */ unsigned long freeram; /* Available memory size */ unsigned long sharedram; /* Amount of shared memory */ unsigned long bufferram; /* Memory used by buffers */ unsigned long totalswap; /* Total swap space size */ unsigned long freeswap; /* swap space still available */ unsigned short procs; /* Number of current processes */ unsigned short pad; /* explicit padding for m68k */ unsigned long totalhigh; /* Total high memory size */ unsigned long freehigh; /* Available high memory size */ unsigned int mem_unit; /* Memory unit size in bytes */ char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */ }; struct vm_area_struct; struct page; struct kiocb; struct sockaddr; struct msghdr; struct module; typedef int socklen_t; };//namespace #endif _LINUX_TYPES_H --- NEW FILE: defines.h --- /* * Copyright 2005 Paul Walker * * GNU General Public License * * This file is part of: Kernel Emulation on Windows (keow) * * Keow is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Keow is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Keow; if not, write to the Free Software [...979 lines suppressed...] SS_DISCONNECTING /* in process of disconnecting */ } socket_state; #define __SO_ACCEPTCON (1 << 16) /* performed a listen */ const int SOCK_ASYNC_NOSPACE =0; const int SOCK_ASYNC_WAITDATA =1; const int SOCK_NOSPACE =2; enum sock_type { _SOCK_STREAM = 1, _SOCK_DGRAM = 2, _SOCK_RAW = 3, _SOCK_RDM = 4, _SOCK_SEQPACKET = 5, _SOCK_PACKET = 10 }; }; |
From: Paul <pa...@us...> - 2005-11-22 06:52:33
|
Update of /cvsroot/keow/keow/keow-user/KeowUserSysCallsDll In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10093/keow-user/KeowUserSysCallsDll Modified Files: KeowUserSysCallsDll.dsp Log Message: No longer using real kernel headers. Far too many conflicts with windows headers using same #defines. Index: KeowUserSysCallsDll.dsp =================================================================== RCS file: /cvsroot/keow/keow/keow-user/KeowUserSysCallsDll/KeowUserSysCallsDll.dsp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** KeowUserSysCallsDll.dsp 24 Sep 2005 06:57:08 -0000 1.3 --- KeowUserSysCallsDll.dsp 22 Nov 2005 06:52:25 -0000 1.4 *************** *** 44,48 **** # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KEOWUSERSYSCALLSDLL_EXPORTS" /YX /FD /c ! # ADD CPP /nologo /MT /W3 /GX /Zi /O2 /I "../../keow-kernel\kernel-headers-2.4.24-1\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KEOWUSERSYSCALLSDLL_EXPORTS" /YX"includes.h" /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 --- 44,48 ---- # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KEOWUSERSYSCALLSDLL_EXPORTS" /YX /FD /c ! # ADD CPP /nologo /MT /W3 /GX /Zi /O2 /I "../../keow-kernel/KeowKernel/linux-abi" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KEOWUSERSYSCALLSDLL_EXPORTS" /YX"includes.h" /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 *************** *** 70,74 **** # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KEOWUSERSYSCALLSDLL_EXPORTS" /YX /FD /GZ /c ! # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../keow-kernel\kernel-headers-2.4.24-1\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KEOWUSERSYSCALLSDLL_EXPORTS" /YX"includes.h" /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 --- 70,74 ---- # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KEOWUSERSYSCALLSDLL_EXPORTS" /YX /FD /GZ /c ! # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../keow-kernel/KeowKernel/linux-abi" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KEOWUSERSYSCALLSDLL_EXPORTS" /YX"includes.h" /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 |
From: Paul <pa...@us...> - 2005-11-22 06:52:32
|
Update of /cvsroot/keow/keow In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10093 Modified Files: KernelEmulationOnWindows.opt Log Message: No longer using real kernel headers. Far too many conflicts with windows headers using same #defines. Index: KernelEmulationOnWindows.opt =================================================================== RCS file: /cvsroot/keow/keow/KernelEmulationOnWindows.opt,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 Binary files /tmp/cvswvjKR9 and /tmp/cvsZlQjbB differ |
From: Paul <pa...@us...> - 2005-11-22 06:52:32
|
Update of /cvsroot/keow/keow/keow-kernel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10093/keow-kernel Modified Files: README.txt Log Message: No longer using real kernel headers. Far too many conflicts with windows headers using same #defines. Index: README.txt =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/README.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** README.txt 22 Sep 2005 09:14:50 -0000 1.2 --- README.txt 22 Nov 2005 06:52:25 -0000 1.3 *************** *** 6,9 **** KeowConsole is a handler for console windows. Windows only allows one console per process, so we need an exe to start seperate processes per window. - - KernelIO is a static library that provides much of the interprocess IO between the kernel and the other processes. --- 6,7 ---- |
From: Paul <pa...@us...> - 2005-11-22 06:50:46
|
Update of /cvsroot/keow/keow/keow-kernel/KeowKernel/linux-abi/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9781/linux Log Message: Directory /cvsroot/keow/keow/keow-kernel/KeowKernel/linux-abi/linux added to the repository |
From: Paul <pa...@us...> - 2005-11-22 06:50:39
|
Update of /cvsroot/keow/keow/keow-kernel/KeowKernel/linux-abi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9757/linux-abi Log Message: Directory /cvsroot/keow/keow/keow-kernel/KeowKernel/linux-abi added to the repository |
From: Paul <pa...@us...> - 2005-11-01 17:49:31
|
Update of /cvsroot/keow/keow In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7680 Modified Files: KernelEmulationOnWindows.opt Log Message: add /dev/random. trying to fix why piping does not fail when pipe broken Index: KernelEmulationOnWindows.opt =================================================================== RCS file: /cvsroot/keow/keow/KernelEmulationOnWindows.opt,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 Binary files /tmp/cvsbZ0W85 and /tmp/cvsTknty1 differ |
Update of /cvsroot/keow/keow/keow-kernel/KeowKernel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7680/keow-kernel/KeowKernel Modified Files: ConstantMapping.cpp FilesystemDev.cpp FilesystemDev.h KeowKernel.dsp SysCalls.cpp sys_net.cpp sys_sys.cpp Added Files: IOHRandom.cpp IOHRandom.h Log Message: add /dev/random. trying to fix why piping does not fail when pipe broken Index: KeowKernel.dsp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/KeowKernel.dsp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** KeowKernel.dsp 30 Oct 2005 01:20:17 -0000 1.5 --- KeowKernel.dsp 1 Nov 2005 17:49:10 -0000 1.6 *************** *** 156,159 **** --- 156,163 ---- # Begin Source File + SOURCE=.\IOHRandom.cpp + # End Source File + # Begin Source File + SOURCE=.\IOHStaticData.cpp # End Source File *************** *** 300,303 **** --- 304,311 ---- # Begin Source File + SOURCE=.\IOHRandom.h + # End Source File + # Begin Source File + SOURCE=.\IOHStaticData.h # End Source File Index: FilesystemDev.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/FilesystemDev.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FilesystemDev.cpp 10 Oct 2005 05:51:55 -0000 1.5 --- FilesystemDev.cpp 1 Nov 2005 17:49:10 -0000 1.6 *************** *** 31,34 **** --- 31,35 ---- #include "IOHNull.h" #include "IOHNtConsole.h" + #include "IOHRandom.h" ////////////////////////////////////////////////////////////////////// *************** *** 40,43 **** --- 41,46 ---- AddFile("/tty", GetTtyHandler); AddFile("/null", GetNullHandler); + AddFile("/random", GetRandomHandler); + AddFile("/urandom", GetURandomHandler); } *************** *** 62,63 **** --- 65,75 ---- return new IOHNull(); } + + IOHandler* FilesystemDev::GetRandomHandler(Path& path) + { + return new IOHRandom(false); + } + IOHandler* FilesystemDev::GetURandomHandler(Path& path) + { + return new IOHRandom(true); + } Index: sys_sys.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/sys_sys.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sys_sys.cpp 30 Oct 2005 01:20:17 -0000 1.4 --- sys_sys.cpp 1 Nov 2005 17:49:10 -0000 1.5 *************** *** 549,550 **** --- 549,581 ---- } + + + /* + * int sysinfo(struct sysinfo *info) + */ + void SysCalls::sys_sysinfo(CONTEXT &ctx) + { + linux::sysinfo si; + + MEMORYSTATUS ms; + GlobalMemoryStatus(&ms); + + memset(&si, 0, sizeof(si)); + si.uptime = GetTickCount()/1000; + si.loads[0] = 0; //1, 5, and 15 minute load averages + si.loads[1] = 0; + si.loads[2] = 0; + si.totalram = ms.dwAvailPhys; + si.freeram = ms.dwTotalPhys; + si.sharedram = 0;/* Amount of shared memory */ + si.bufferram = 0; /* Memory used by buffers */ + si.totalswap = ms.dwTotalPageFile; + si.freeswap = ms.dwAvailPageFile; + si.procs = g_pKernelTable->m_Processes.size(); + si.totalhigh = 0; /* Total high memory size */ + si.freehigh = 0; /* Available high memory size */ + si.mem_unit = 4096; //same as page size??? + + P->WriteMemory((ADDR)ctx.Ebx, sizeof(si), &si); + ctx.Eax = 0; + } Index: sys_net.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/sys_net.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sys_net.cpp 22 Sep 2005 09:14:50 -0000 1.2 --- sys_net.cpp 1 Nov 2005 17:49:10 -0000 1.3 *************** *** 37,40 **** --- 37,41 ---- { ktrace("IMPLEMENT sys_socketcall (unix domain socket?, not inet?)\n"); + P->DumpContext(ctx); ctx.Eax = -ENOSYS; } --- NEW FILE: IOHRandom.h --- /* * Copyright 2005 Paul Walker * * GNU General Public License * * This file is part of: Kernel Emulation on Windows (keow) * * Keow is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Keow is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Keow; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ // IOHRandom.h: interface for the IOHRandom class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_IOHRandom_H__A82590CD_8CD7_4759_B40F_0563D597E0C6__INCLUDED_) #define AFX_IOHRandom_H__A82590CD_8CD7_4759_B40F_0563D597E0C6__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "IOHandler.h" class IOHRandom : public IOHandler { public: IOHRandom(bool urandom); virtual ~IOHRandom(); virtual bool Open(DWORD win32access, DWORD win32share, DWORD disposition, DWORD flags); virtual bool Close(); virtual DWORD ioctl(DWORD request, DWORD data); virtual bool Read(void* address, DWORD size, DWORD *pRead); virtual bool Write(void* address, DWORD size, DWORD *pWritten); virtual __int64 Length(); virtual __int64 Seek(__int64 offset, DWORD method); virtual void Truncate(); virtual IOHandler* Duplicate(); virtual bool Stat64(linux::stat64 * s); virtual bool CanRead(); virtual bool CanWrite(); virtual bool HasException(); private: BYTE m_RandomBytes[SIZE4k]; int m_LastGenerated; bool m_bIsURandom; void GenerateNumbers(int needed); }; #endif // !defined(AFX_IOHRandom_H__A82590CD_8CD7_4759_B40F_0563D597E0C6__INCLUDED_) --- NEW FILE: IOHRandom.cpp --- /* * Copyright 2005 Paul Walker * * GNU General Public License * * This file is part of: Kernel Emulation on Windows (keow) * * Keow is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Keow is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Keow; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ // IOHRandom.cpp: implementation of the // ////////////////////////////////////////////////////////////////////// #include "includes.h" #include "IOHRandom.h" ////////////////////////////////////////////////////////////////////// IOHRandom::IOHRandom(bool urandom) { m_bIsURandom = urandom; m_LastGenerated = GetTickCount() ^ (DWORD)this; //not very random! } IOHRandom::~IOHRandom() { } bool IOHRandom::Open(DWORD win32access, DWORD win32share, DWORD disposition, DWORD flags) { return true; } bool IOHRandom::Close() { return true; } IOHandler* IOHRandom::Duplicate() { IOHRandom * pC = new IOHRandom(m_bIsURandom); return pC; } bool IOHRandom::Stat64(linux::stat64 * s) { if(!s) return false; IOHandler::BasicStat64(s, S_IFCHR); return true; } DWORD IOHRandom::ioctl(DWORD request, DWORD data) { return 0; } bool IOHRandom::Read(void* address, DWORD size, DWORD *pRead) { ADDR addr = (ADDR)address; *pRead = size; while(size != 0) { int block = size>SIZE4k?SIZE4k:size; GenerateNumbers(block); P->WriteMemory(addr, block, m_RandomBytes); addr += block; size -= block; } return true; } bool IOHRandom::Write(void* address, DWORD size, DWORD *pWritten) { //swallow it *pWritten = size; return true; } bool IOHRandom::CanRead() { //always return true; } bool IOHRandom::CanWrite() { //cannot write to random number generator return false; } bool IOHRandom::HasException() { //always ok return false; } __int64 IOHRandom::Length() { return 0; } __int64 IOHRandom::Seek(__int64 offset, DWORD method) { return -1; } void IOHRandom::Truncate() { //do nothing } // ensure at least this many numbers in the buffer void IOHRandom::GenerateNumbers(int needed) { #ifdef _DEBUG if(needed > sizeof(m_RandomBytes)) DebugBreak(); #endif WORD * pRnd = (WORD*)m_RandomBytes; for(int i=0; i<needed; ++pRnd,i+=sizeof(*pRnd)) { // if(m_bIsURandom) should be better random - how? unsigned int seed = m_LastGenerated * GetTickCount() * g_pKernelTable->m_ForksSinceBoot * g_pKernelTable->m_Processes.size(); srand(seed); m_LastGenerated = rand(); *pRnd = m_LastGenerated; } } Index: SysCalls.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/SysCalls.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SysCalls.cpp 30 Oct 2005 01:20:17 -0000 1.4 --- SysCalls.cpp 1 Nov 2005 17:49:10 -0000 1.5 *************** *** 448,452 **** void SysCalls::sys_vm86old(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_swapoff(CONTEXT &ctx) {Unhandled(ctx);} - void SysCalls::sys_sysinfo(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_ipc(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_fsync(CONTEXT &ctx) {Unhandled(ctx);} --- 448,451 ---- Index: ConstantMapping.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/ConstantMapping.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ConstantMapping.cpp 22 Sep 2005 09:14:50 -0000 1.2 --- ConstantMapping.cpp 1 Nov 2005 17:49:10 -0000 1.3 *************** *** 96,99 **** --- 96,101 ---- case ERROR_BROKEN_PIPE: + case ERROR_NO_DATA: + case ERROR_PIPE_NOT_CONNECTED: return EIO; Index: FilesystemDev.h =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/FilesystemDev.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FilesystemDev.h 10 Oct 2005 05:51:55 -0000 1.4 --- FilesystemDev.h 1 Nov 2005 17:49:10 -0000 1.5 *************** *** 46,49 **** --- 46,51 ---- static IOHandler* GetTtyHandler(Path& path); static IOHandler* GetNullHandler(Path& path); + static IOHandler* GetRandomHandler(Path& path); + static IOHandler* GetURandomHandler(Path& path); }; |
From: Paul <pa...@us...> - 2005-11-01 17:49:31
|
Update of /cvsroot/keow/keow/keow-user/KeowUserSysCallsDll In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7680/keow-user/KeowUserSysCallsDll Modified Files: SysCallDll_User.cpp Log Message: add /dev/random. trying to fix why piping does not fail when pipe broken Index: SysCallDll_User.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-user/KeowUserSysCallsDll/SysCallDll_User.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SysCallDll_User.cpp 21 Oct 2005 19:03:37 -0000 1.4 --- SysCallDll_User.cpp 1 Nov 2005 17:49:10 -0000 1.5 *************** *** 169,172 **** --- 169,174 ---- SetLastError(0); //because we need to check it always and the call will not update it on success BOOL ok = ::WriteFile(h, buf, len, &dw, NULL); + if(!ok) + dw=0; RET(dw); } *************** *** 177,180 **** --- 179,184 ---- SetLastError(0); //because we need to check it always and the call will not update it on success BOOL ok = ::ReadFile(h, buf, len, &dw, NULL); + if(!ok) + dw=0; RET(dw); } |
From: Paul <pa...@us...> - 2005-10-30 01:41:32
|
Update of /cvsroot/keow/keow/keow-kernel/KeowKernel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9057/keow-kernel/KeowKernel Modified Files: Utils.h sys_io.cpp Log Message: Index: sys_io.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/sys_io.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** sys_io.cpp 30 Oct 2005 01:20:17 -0000 1.7 --- sys_io.cpp 30 Oct 2005 01:41:24 -0000 1.8 *************** *** 1310,1314 **** P->ReadMemory(×, (ADDR)ctx.Ecx, sizeof(times)); ! HANDLE hTmp = CreateFile(path.GetWin32Path(), FILE_WRITE_ATTRIBUTES, 0, 0, OPEN_EXISTING, 0, 0); if(hTmp==INVALID_HANDLE_VALUE) { --- 1310,1315 ---- P->ReadMemory(×, (ADDR)ctx.Ecx, sizeof(times)); ! DWORD attr = GetFileAttributes(path.GetWin32Path()); ! HANDLE hTmp = CreateFile(path.GetWin32Path(), FILE_WRITE_ATTRIBUTES, 0, 0, OPEN_EXISTING, (attr&FILE_ATTRIBUTE_DIRECTORY)?FILE_FLAG_BACKUP_SEMANTICS:0, 0); if(hTmp==INVALID_HANDLE_VALUE) { Index: Utils.h =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/Utils.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Utils.h 30 Oct 2005 01:20:17 -0000 1.4 --- Utils.h 30 Oct 2005 01:41:24 -0000 1.5 *************** *** 45,50 **** extern ULARGE_INTEGER Time1Jan1970; //conversion (1sec <--> 100ns) ! #define SECOND_TO_100NS(sec) (sec)*10000000L ! #define NS100_TO_SECOND(ns) (ns)/10000000L #define FILETIME_TO_TIME_T(t) (unsigned long)(NS100_TO_SECOND( ((ULARGE_INTEGER*)&t)->QuadPart - Time1Jan1970.QuadPart )) #define TIME_T_TO_FILETIME(tt,ft) ((ULARGE_INTEGER*)&ft)->QuadPart = (Time1Jan1970.QuadPart + SECOND_TO_100NS(tt)) --- 45,50 ---- extern ULARGE_INTEGER Time1Jan1970; //conversion (1sec <--> 100ns) ! #define SECOND_TO_100NS(sec) (((unsigned __int64)sec)*10000000L) ! #define NS100_TO_SECOND(ns) (((unsigned __int64)ns)/10000000L) #define FILETIME_TO_TIME_T(t) (unsigned long)(NS100_TO_SECOND( ((ULARGE_INTEGER*)&t)->QuadPart - Time1Jan1970.QuadPart )) #define TIME_T_TO_FILETIME(tt,ft) ((ULARGE_INTEGER*)&ft)->QuadPart = (Time1Jan1970.QuadPart + SECOND_TO_100NS(tt)) |
From: Paul <pa...@us...> - 2005-10-30 01:41:32
|
Update of /cvsroot/keow/keow In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9057 Modified Files: KernelEmulationOnWindows.opt Log Message: Index: KernelEmulationOnWindows.opt =================================================================== RCS file: /cvsroot/keow/keow/KernelEmulationOnWindows.opt,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 Binary files /tmp/cvscm24Vl and /tmp/cvsrItOAE differ |
Update of /cvsroot/keow/keow/keow-kernel/KeowKernel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5873/keow-kernel/KeowKernel Modified Files: FilesystemKeow.cpp FilesystemKeow.h FilesystemProc.cpp KeowKernel.dsp KernelTable.cpp KernelTable.h LegacyWindows.cpp LegacyWindows.h Path.cpp Path.h Process.cpp Process.h SysCalls.cpp Utils.h linux_includes.h sys_io.cpp sys_perms.cpp sys_process.cpp sys_sys.cpp Log Message: Index: Path.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/Path.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Path.cpp 15 Oct 2005 21:34:41 -0000 1.6 --- Path.cpp 30 Oct 2005 01:20:17 -0000 1.7 *************** *** 37,40 **** --- 37,41 ---- m_pFinalMountPoint=NULL; m_FollowSymLinks = FollowSymLinks; + m_NeedCalculation = true; *this = other; } *************** *** 43,46 **** --- 44,48 ---- m_pFinalMountPoint=NULL; m_FollowSymLinks = FollowSymLinks; + m_NeedCalculation = true; } Path::Path(string UnixPath, bool FollowSymLinks) *************** *** 48,51 **** --- 50,54 ---- m_FollowSymLinks = FollowSymLinks; m_pFinalMountPoint=NULL; + m_NeedCalculation = true; SetUnixPath(UnixPath); } *************** *** 54,57 **** --- 57,61 ---- m_FollowSymLinks = FollowSymLinks; m_pFinalMountPoint=NULL; + m_NeedCalculation = true; SetUnixPath(UnixPath); } *************** *** 69,72 **** --- 73,79 ---- m_strMountRealPath = other.m_strMountRealPath; m_strPathInMountPoint = other.m_strPathInMountPoint; + m_strWin32Path = other.m_strWin32Path; + m_strActualUnixPath = other.m_strActualUnixPath; + m_NeedCalculation = other.m_NeedCalculation; return *this; } *************** *** 89,92 **** --- 96,101 ---- AppendUnixPath(path); + m_NeedCalculation = true; + ktrace("path: %s\n", path.c_str()); ktrace(" --> %s\n", GetUnixPath().c_str()); *************** *** 99,102 **** --- 108,112 ---- { m_FollowSymLinks = follow; + m_NeedCalculation = true; } *************** *** 105,108 **** --- 115,119 ---- { AppendPath(m_PathStack, unixp); + m_NeedCalculation = true; } *************** *** 212,216 **** string Path::GetUnixPath() { ! TranverseMountPoints(); return m_strActualUnixPath; } --- 223,229 ---- string Path::GetUnixPath() { ! if(m_NeedCalculation) ! TranverseMountPoints(); ! return m_strActualUnixPath; } *************** *** 222,231 **** string Path::GetWin32Path() { ! TranverseMountPoints(); ! return GetFinalPath(); } string Path::GetPathInFilesystem() { return m_strPathInMountPoint; } --- 235,249 ---- string Path::GetWin32Path() { ! if(m_NeedCalculation) ! TranverseMountPoints(); ! ! return m_strWin32Path; } string Path::GetPathInFilesystem() { + if(m_NeedCalculation) + TranverseMountPoints(); + return m_strPathInMountPoint; } *************** *** 320,323 **** --- 338,345 ---- m_strActualUnixPath = string("/") + JoinList(FinalUnixPath, '/'); + m_strWin32Path = GetFinalPath(); + + //calculated + m_NeedCalculation = false; } *************** *** 358,362 **** bool Path::IsSymbolicLink() { ! TranverseMountPoints(); return m_pFinalMountPoint->GetFilesystem()->IsSymbolicLink( GetFinalPath() ); } --- 380,386 ---- bool Path::IsSymbolicLink() { ! if(m_NeedCalculation) ! TranverseMountPoints(); ! return m_pFinalMountPoint->GetFilesystem()->IsSymbolicLink( GetFinalPath() ); } *************** *** 366,369 **** --- 390,396 ---- Filesystem * Path::GetFinalFilesystem() { + if(m_NeedCalculation) + TranverseMountPoints(); + return m_pFinalMountPoint->GetFilesystem(); } Index: KernelTable.h =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/KernelTable.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** KernelTable.h 24 Sep 2005 21:37:07 -0000 1.3 --- KernelTable.h 30 Oct 2005 01:20:17 -0000 1.4 *************** *** 52,58 **** --- 52,62 ---- DWORD m_ForksSinceBoot; + string m_KernelVersion; + string m_KernelCpuType; + int m_DebugLevel; HANDLE m_hLogFile; + string m_KeowExeDir; string m_FilesystemRoot; MountPoint * m_pRootMountPoint; Index: sys_sys.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/sys_sys.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sys_sys.cpp 10 Oct 2005 05:51:55 -0000 1.3 --- sys_sys.cpp 30 Oct 2005 01:20:17 -0000 1.4 *************** *** 42,48 **** GetComputerName(U.sysname, &siz); StringCbCopy(U.nodename, sizeof(U.nodename), U.sysname); ! StringCbCopy(U.release, sizeof(U.release), "2.4.20"); //specs we are using are this (Sep 2005) StringCbCopy(U.version, sizeof(U.version), "keow"); ! StringCbCopy(U.machine, sizeof(U.machine), "i386"); //we need this value? U.domainname[0] = 0; --- 42,48 ---- GetComputerName(U.sysname, &siz); StringCbCopy(U.nodename, sizeof(U.nodename), U.sysname); ! StringCbCopy(U.release, sizeof(U.release), g_pKernelTable->m_KernelVersion.c_str()); StringCbCopy(U.version, sizeof(U.version), "keow"); ! StringCbCopy(U.machine, sizeof(U.machine), g_pKernelTable->m_KernelCpuType.c_str()); U.domainname[0] = 0; Index: KernelTable.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/KernelTable.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** KernelTable.cpp 15 Oct 2005 21:34:41 -0000 1.4 --- KernelTable.cpp 30 Oct 2005 01:20:17 -0000 1.5 *************** *** 42,45 **** --- 42,55 ---- m_LastPID = 0; + m_KernelVersion = "2.4.20"; //specs we are using are this (Sep 2005) + m_KernelCpuType = "i386"; //use miniumum value for now? + + char * dir = m_KeowExeDir.GetBuffer(MAX_PATH); + GetModuleFileName(NULL, dir, MAX_PATH); + char * slash = strrchr(dir, '\\'); + if(slash) + *slash=NULL; + m_KeowExeDir.ReleaseBuffer(); + GetSystemTime(&m_BootTime); m_ForksSinceBoot=0; Index: Path.h =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/Path.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Path.h 15 Oct 2005 21:34:41 -0000 1.6 --- Path.h 30 Oct 2005 01:20:17 -0000 1.7 *************** *** 83,86 **** --- 83,88 ---- string m_strActualUnixPath; bool m_FollowSymLinks; + bool m_NeedCalculation; + string m_strWin32Path; }; Index: Utils.h =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/Utils.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Utils.h 23 Oct 2005 20:44:59 -0000 1.3 --- Utils.h 30 Oct 2005 01:20:17 -0000 1.4 *************** *** 43,52 **** //unix time base - #define FILETIME_TO_TIME_T(t) (unsigned long)( (((ULARGE_INTEGER*)&t)->QuadPart - Time1Jan1970.QuadPart) / 10000000L) extern ULARGE_INTEGER Time1Jan1970; //c++ helper #define instanceof(var,type) (dynamic_cast<type*>(var) != 0) #endif // !defined(AFX_UTILS_H__23B86EDD_923F_42A7_94E3_68A42DB40A3D__INCLUDED_) --- 43,59 ---- //unix time base extern ULARGE_INTEGER Time1Jan1970; + //conversion (1sec <--> 100ns) + #define SECOND_TO_100NS(sec) (sec)*10000000L + #define NS100_TO_SECOND(ns) (ns)/10000000L + #define FILETIME_TO_TIME_T(t) (unsigned long)(NS100_TO_SECOND( ((ULARGE_INTEGER*)&t)->QuadPart - Time1Jan1970.QuadPart )) + #define TIME_T_TO_FILETIME(tt,ft) ((ULARGE_INTEGER*)&ft)->QuadPart = (Time1Jan1970.QuadPart + SECOND_TO_100NS(tt)) //c++ helper #define instanceof(var,type) (dynamic_cast<type*>(var) != 0) + //calculate byte offsets + #define offset_of(base,member) ( ((DWORD)&member) - ((DWORD)&base) ) + #endif // !defined(AFX_UTILS_H__23B86EDD_923F_42A7_94E3_68A42DB40A3D__INCLUDED_) Index: Process.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/Process.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Process.cpp 23 Oct 2005 20:44:59 -0000 1.8 --- Process.cpp 30 Oct 2005 01:20:17 -0000 1.9 *************** *** 51,54 **** --- 51,56 ---- m_saved_gid = 0; + m_umask = 022; //octal - default from "man 2 umask" + m_Pid = 0; m_ParentPid = 0; *************** *** 69,72 **** --- 71,75 ---- memset(&m_ElfLoadData, 0, sizeof(m_ElfLoadData)); memset(&m_ptrace, 0, sizeof(m_ptrace)); + m_LinuxGateDSO = m_LinuxGateVSyscall = NULL; memset(&m_OpenFiles, 0, sizeof(m_OpenFiles)); *************** *** 447,452 **** ! //read syscall data from dll (pointer in eax) ! ReadMemory(&SysCallAddr, (ADDR)ctx.Eax, sizeof(SysCallAddr)); #ifdef _DEBUG --- 450,455 ---- ! //read syscall data from dll ! ReadMemory(&SysCallAddr, (ADDR)ctx.Ebx, sizeof(SysCallAddr)); #ifdef _DEBUG *************** *** 502,505 **** --- 505,524 ---- LoadImage(m_ProcessFileImage, false); + //what new kernel call mechanism + string dso(g_pKernelTable->m_KeowExeDir); + dso += "\\keow-gate.dso"; + HANDLE hImg = CreateFile(dso, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); + struct linux::elf32_hdr ehdr; //ELF header + Process::ElfLoadData LoadData; + LoadData = m_ElfLoadData; + DWORD dummy; + ReadFile(hImg, &ehdr, sizeof(ehdr), &dummy, NULL); + if( LoadElfImage(hImg, &ehdr, &LoadData, true) == 0) + { + m_LinuxGateDSO = (DWORD)LoadData.image_base; + m_LinuxGateVSyscall = (DWORD)LoadData.start_addr; + } + CloseHandle(hImg); + //std in,out,err m_OpenFiles[0] = new IOHNtConsole(g_pKernelTable->m_pMainConsole); *************** *** 560,564 **** { //is this an INT 80 linux SYSCALL? ! //--Actually is it the replacement instruction that we placed there? WORD instruction; --- 579,584 ---- { //is this an INT 80 linux SYSCALL? ! //--Actually is it the replacement INT 4 instruction that we placed there? ! // Or is it a real overflow exception? WORD instruction; *************** *** 841,844 **** --- 861,927 ---- + bool Process::CanLoadImage(Path &img, bool LoadAsLibrary) + { + //can load it? + HANDLE hImg = CreateFile(img.GetWin32Path().c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); + if(hImg==INVALID_HANDLE_VALUE) + return false; + + + //Read the first chunk of the file + int buflen=1024; //plenty enough to understand the file - enough for elf header and also the 128 chars allowed for a #! shell script + DWORD dwRead; + BYTE * buf = new BYTE[buflen]; + memset(buf,0,buflen); + ReadFile(hImg, buf, buflen, &dwRead, 0); + + CloseHandle(hImg); + + //determine exe type + struct linux::elf32_hdr * pElf; //ELF header + pElf = (struct linux::elf32_hdr *)buf; + if(pElf->e_ident[EI_MAG0] == ELFMAG0 + && pElf->e_ident[EI_MAG1] == ELFMAG1 + && pElf->e_ident[EI_MAG2] == ELFMAG2 + && pElf->e_ident[EI_MAG3] == ELFMAG3) + { + return true; //loadable we think - should really test intepreter etc but we don't yet + } + else + if(buf[0]=='#' + && buf[1]=='!') + { + //yes - it is a shell script with a header + // eg: #! /bin/sh -x + //Use that program as the process and append our original args + + char * nl = strchr((char*)buf, 0x0a); + if(nl==NULL) + nl = (char*)&buf[buflen-1]; //use end of buffer + *nl = NULL; //line ends here + + //skip #! and any whitespace + char * interp = (char*)buf + 2; + while(*interp == ' ') + interp++; + + //process the command and arguments + list<string> arglist; + ParseCommandLine(interp, arglist); + + return CanLoadImage(Path(arglist[0]), false); //can load interpreter? + } + else + { + //unhandled file format + SetLastError(ERROR_BAD_FORMAT); + return false; + } + + //shouldn't get here + return false; + } + + DWORD Process::LoadElfImage(HANDLE hImg, struct linux::elf32_hdr * pElfHdr, ElfLoadData * pElfLoadData, bool LoadAsLibrary) { *************** *** 892,898 **** ktrace("using base address 0x%08lx\n", pBaseAddr); - pElfLoadData->Interpreter[0] = 0; pElfLoadData->start_addr = pElfHdr->e_entry + pBaseAddr; loadok=1; --- 975,981 ---- ktrace("using base address 0x%08lx\n", pBaseAddr); pElfLoadData->Interpreter[0] = 0; pElfLoadData->start_addr = pElfHdr->e_entry + pBaseAddr; + pElfLoadData->image_base = pBaseAddr; loadok=1; *************** *** 1235,1238 **** --- 1318,1323 ---- PUSH_AUX_VAL(AT_PHDR, (DWORD)m_ElfLoadData.phdr_addr) PUSH_AUX_VAL(AT_PAGESZ, 0x1000) //4K + // PUSH_AUX_VAL(AT_SYSINFO_EHDR, m_LinuxGateDSO) + // PUSH_AUX_VAL(AT_SYSINFO, m_LinuxGateVSyscall) PUSH_AUX_VAL(AT_NULL, 0) *************** *** 1554,1558 **** //put in the restorer code ! *((DWORD*)&asm_code[1]) = NewEsp + ((DWORD)&stack.SavedState.ctx - (DWORD)&stack); memcpy(stack.Restorer, asm_code, sizeof(asm_code)); --- 1639,1643 ---- //put in the restorer code ! *((DWORD*)&asm_code[1]) = NewEsp + offset_of(stack, stack.SavedState.ctx); memcpy(stack.Restorer, asm_code, sizeof(asm_code)); *************** *** 1576,1584 **** stack.SigInfo.si_code = SI_USER; ! stack.Arg_pSigInfo = (void*)(NewEsp + ((DWORD)&stack.SigInfo - (DWORD)&stack)); stack.Arg_pData = 0; } ! stack.ReturnAddress = NewEsp + ((DWORD)&stack.Restorer - (DWORD)&stack); //use restorer //in linux this is a call to sys_sigreturn ? --- 1661,1669 ---- stack.SigInfo.si_code = SI_USER; ! stack.Arg_pSigInfo = (void*)(NewEsp + offset_of(stack, stack.SigInfo)); stack.Arg_pData = 0; } ! stack.ReturnAddress = NewEsp + offset_of(stack, stack.Restorer); //use restorer //in linux this is a call to sys_sigreturn ? Index: linux_includes.h =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/linux_includes.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** linux_includes.h 22 Sep 2005 09:14:50 -0000 1.2 --- linux_includes.h 30 Oct 2005 01:20:17 -0000 1.3 *************** *** 92,95 **** --- 92,96 ---- #include <asm-i386/ucontext.h> #include <linux/user.h> + #include <linux/utime.h> }; *************** *** 159,162 **** --- 160,168 ---- */ + //should get a 2.6 header set for this: + ///usr/include/elf.h: + #define AT_SYSINFO 32 + #define AT_SYSINFO_EHDR 33 + #pragma pack(pop) Index: SysCalls.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/SysCalls.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SysCalls.cpp 13 Oct 2005 06:52:12 -0000 1.3 --- SysCalls.cpp 30 Oct 2005 01:20:17 -0000 1.4 *************** *** 392,400 **** */ - void SysCalls::sys_waitpid(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_creat(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_mknod(CONTEXT &ctx) {Unhandled(ctx);} - void SysCalls::sys_chmod(CONTEXT &ctx) {Unhandled(ctx);} - void SysCalls::sys_lchown(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_setuid(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_stime(CONTEXT &ctx) {Unhandled(ctx);} --- 392,397 ---- *************** *** 402,406 **** void SysCalls::sys_oldfstat(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_pause(CONTEXT &ctx) {Unhandled(ctx);} - void SysCalls::sys_utime(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_stty(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_gtty(CONTEXT &ctx) {Unhandled(ctx);} --- 399,402 ---- *************** *** 431,435 **** void SysCalls::sys_getgroups(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_setgroups(CONTEXT &ctx) {Unhandled(ctx);} - void SysCalls::sys_symlink(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_oldlstat(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_uselib(CONTEXT &ctx) {Unhandled(ctx);} --- 427,430 ---- *************** *** 438,443 **** void SysCalls::sys_truncate(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_ftruncate(CONTEXT &ctx) {Unhandled(ctx);} - void SysCalls::sys_fchmod(CONTEXT &ctx) {Unhandled(ctx);} - void SysCalls::sys_fchown(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_getpriority(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_setpriority(CONTEXT &ctx) {Unhandled(ctx);} --- 433,436 ---- *************** *** 504,508 **** void SysCalls::sys_pread(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_pwrite(CONTEXT &ctx) {Unhandled(ctx);} - void SysCalls::sys_chown(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_capget(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_capset(CONTEXT &ctx) {Unhandled(ctx);} --- 497,500 ---- *************** *** 515,527 **** void SysCalls::sys_truncate64(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_ftruncate64(CONTEXT &ctx) {Unhandled(ctx);} - void SysCalls::sys_lchown32(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_getgroups32(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_setgroups32(CONTEXT &ctx) {Unhandled(ctx);} - void SysCalls::sys_fchown32(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_setresuid32(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_getresuid32(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_setresgid32(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_getresgid32(CONTEXT &ctx) {Unhandled(ctx);} - void SysCalls::sys_chown32(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_setuid32(CONTEXT &ctx) {Unhandled(ctx);} void SysCalls::sys_setgid32(CONTEXT &ctx) {Unhandled(ctx);} --- 507,516 ---- Index: FilesystemKeow.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/FilesystemKeow.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FilesystemKeow.cpp 15 Oct 2005 21:34:41 -0000 1.4 --- FilesystemKeow.cpp 30 Oct 2005 01:20:17 -0000 1.5 *************** *** 45,53 **** } // // If lpszLinkFile is a shortcut then return the target it points to // otherwise return the original path // ! string FilesystemKeow::GetShortCutTarget(string& path) { HRESULT hres; --- 45,55 ---- } + + // // If lpszLinkFile is a shortcut then return the target it points to // otherwise return the original path // ! string FilesystemKeow::GetShortcutTarget(string& path) { HRESULT hres; *************** *** 159,163 **** // ! HRESULT FilesystemKeow::CreateLink(const string& LinkPath, const string& DestPath, const string& Description) { HRESULT hres; --- 161,165 ---- // ! HRESULT FilesystemKeow::CreateShortcut(const string& LinkTo, const string& TheShortcut, const string& Description) { HRESULT hres; *************** *** 172,176 **** // Set the path to the shortcut target and add the description. ! psl->SetPath(DestPath); psl->SetDescription(Description); --- 174,178 ---- // Set the path to the shortcut target and add the description. ! psl->SetPath(LinkTo); psl->SetDescription(Description); *************** *** 184,188 **** // Ensure that the string is Unicode. ! MultiByteToWideChar(CP_ACP, 0, LinkPath.c_str(), -1, (wchar_t*)wsz.GetBuffer(MAX_PATH), MAX_PATH); // TODO: Check return value from MultiByteWideChar to ensure success. --- 186,190 ---- // Ensure that the string is Unicode. ! MultiByteToWideChar(CP_ACP, 0, TheShortcut.c_str(), -1, (wchar_t*)wsz.GetBuffer(MAX_PATH), MAX_PATH); // TODO: Check return value from MultiByteWideChar to ensure success. *************** *** 214,218 **** bool FilesystemKeow::IsSymbolicLink(string& strPath) { ! string Dest = GetShortCutTarget(strPath); return !Dest.empty(); } --- 216,220 ---- bool FilesystemKeow::IsSymbolicLink(string& strPath) { ! string Dest = GetShortcutTarget(strPath); return !Dest.empty(); } *************** *** 224,228 **** //possibly a link, check it fully ! return GetShortCutTarget(strPath); } --- 226,230 ---- //possibly a link, check it fully ! return GetShortcutTarget(strPath); } *************** *** 236,237 **** --- 238,248 ---- return "keow"; } + + + bool FilesystemKeow::CreateSymbolicLink(string& OldPath, string& NewPath) + { + Path shortcut; + shortcut.SetUnixPath(NewPath+".lnk"); + HRESULT hr = CreateShortcut(OldPath, shortcut.GetWin32Path(), OldPath); + return SUCCEEDED(hr); + } Index: FilesystemKeow.h =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/FilesystemKeow.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FilesystemKeow.h 24 Sep 2005 21:37:07 -0000 1.3 --- FilesystemKeow.h 30 Oct 2005 01:20:17 -0000 1.4 *************** *** 49,55 **** virtual bool IsRelativePath(string& strPath); protected: ! static string GetShortCutTarget(string& path); ! static HRESULT CreateLink(const string& LinkPath, const string& DestPath, const string& Description); }; --- 49,57 ---- virtual bool IsRelativePath(string& strPath); + static bool CreateSymbolicLink(string& OldPath, string& NewPath); + protected: ! static string GetShortcutTarget(string& path); ! static HRESULT CreateShortcut(const string& LinkTo, const string& TheShortcut, const string& Description); }; Index: FilesystemProc.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/FilesystemProc.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** FilesystemProc.cpp 15 Oct 2005 21:34:41 -0000 1.6 --- FilesystemProc.cpp 30 Oct 2005 01:20:17 -0000 1.7 *************** *** 422,426 **** ,pp->m_Pid ,pp->m_ProcessFileImage.GetUnixPath().c_str() ! ,'R' //state, just using Running for now ,pp->m_ParentPid ,pp->m_ProcessGroupPID --- 422,426 ---- ,pp->m_Pid ,pp->m_ProcessFileImage.GetUnixPath().c_str() ! ,pp->IsSuspended()?'S':'R' //state, just sleeping or running at present ,pp->m_ParentPid ,pp->m_ProcessGroupPID *************** *** 496,500 **** IOHandler* FilesystemProc::Get_Pid_Status(Path& path, const char * pid) { ! return NULL; } --- 496,525 ---- IOHandler* FilesystemProc::Get_Pid_Status(Path& path, const char * pid) { ! Process * pp = PidStrToProcess(pid); ! if(pp==0) ! return NULL; ! ! IOHStaticData * ioh = new IOHStaticData(path, IOHStaticData::File, true); ! ! ! ioh->AddData( string::format("Name: %s\x0a", pp->m_ProcessFileImage.GetUnixPathElement(pp->m_ProcessFileImage.GetElementCount()-1).c_str()) ); ! ioh->AddData( string::format("State: %s\x0a", pp->IsSuspended()?"S (sleeping)":"R (runnable)") ); ! ioh->AddData( string::format("Tgid: %ld\x0a", pp->m_pControllingTty) ); //TODO this is WRONG! ! ioh->AddData( string::format("Pid: %ld\x0a", pp->m_Pid) ); ! ioh->AddData( string::format("PPid: %ld\x0a", pp->m_ParentPid) ); ! ioh->AddData( string::format("Uid: %ld %ld %ld %ld\x0a", pp->m_uid, pp->m_euid, pp->m_saved_uid, 0) ); //TODO which ones? ! ioh->AddData( string::format("Gid: %ld %ld %ld %ld\x0a", pp->m_gid, pp->m_egid, pp->m_saved_gid, 0) ); //TODO which ones? ! ioh->AddData( string::format("VmSize: %8ld kB\x0a", 1) ); ! ioh->AddData( string::format("VmLck: %8ld kB\x0a", 0) ); ! ioh->AddData( string::format("VmRSS: %8ld kB\x0a", 1) ); ! ioh->AddData( string::format("VmData: %8ld kB\x0a", 1) ); ! ioh->AddData( string::format("VmStk: %8ld kB\x0a", 1) ); ! ioh->AddData( string::format("VmExe: %8ld kB\x0a", 1) ); ! ioh->AddData( string::format("VmLib: %8ld kB\x0a", 1) ); ! ioh->AddData( string::format("SigPnd: 0000000000000000\x0a") ); ! ioh->AddData( string::format("SigBlk: 0000000000000000\x0a") ); ! ioh->AddData( string::format("SigIgn: 0000000000000000\x0a") ); ! ! return ioh; } Index: sys_perms.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/sys_perms.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sys_perms.cpp 22 Sep 2005 09:14:50 -0000 1.2 --- sys_perms.cpp 30 Oct 2005 01:20:17 -0000 1.3 *************** *** 159,160 **** --- 159,232 ---- sys_setregid(ctx); } + + + /* + * int chmod(const char *path, mode_t mode); + */ + void SysCalls::sys_chmod(CONTEXT &ctx) + { + ktrace("IMPLEMENT proper permissions changes\n"); + + //pretent we worked + ctx.Eax = 0; + } + + /* + * int fchmod(int fildes, mode_t mode); + */ + void SysCalls::sys_fchmod(CONTEXT &ctx) + { + ktrace("IMPLEMENT proper permissions changes\n"); + + //pretent we worked + ctx.Eax = 0; + } + + void SysCalls::sys_chown(CONTEXT &ctx) + { + ktrace("IMPLEMENT proper permissions changes\n"); + + //pretent we worked + ctx.Eax = 0; + } + + void SysCalls::sys_lchown(CONTEXT &ctx) + { + ktrace("IMPLEMENT proper permissions changes\n"); + + //pretent we worked + ctx.Eax = 0; + } + + void SysCalls::sys_fchown(CONTEXT &ctx) + { + ktrace("IMPLEMENT proper permissions changes\n"); + + //pretent we worked + ctx.Eax = 0; + } + + void SysCalls::sys_lchown32(CONTEXT &ctx) + { + ktrace("IMPLEMENT proper permissions changes\n"); + + //pretent we worked + ctx.Eax = 0; + } + + void SysCalls::sys_fchown32(CONTEXT &ctx) + { + ktrace("IMPLEMENT proper permissions changes\n"); + + //pretent we worked + ctx.Eax = 0; + } + + void SysCalls::sys_chown32(CONTEXT &ctx) + { + ktrace("IMPLEMENT proper permissions changes\n"); + + //pretent we worked + ctx.Eax = 0; + } + Index: Process.h =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/Process.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Process.h 23 Oct 2005 20:44:59 -0000 1.6 --- Process.h 30 Oct 2005 01:20:17 -0000 1.7 *************** *** 63,66 **** --- 63,67 ---- static Process* StartFork(Process * pParent); DWORD LoadImage(Path &img, bool LoadAsLibrary); + static bool CanLoadImage(Path &img, bool LoadAsLibrary); void DumpMemory(ADDR addr, DWORD len); *************** *** 161,164 **** --- 162,166 ---- DWORD phdr_phent; + ADDR image_base; ADDR start_addr; ADDR program_base, program_max; *************** *** 184,187 **** --- 186,191 ---- //info about what resources the stub can provide SysCallDll::RemoteAddrInfo SysCallAddr; + DWORD m_LinuxGateDSO; + DWORD m_LinuxGateVSyscall; DWORD m_ArgCnt, m_EnvCnt; Index: KeowKernel.dsp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/KeowKernel.dsp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** KeowKernel.dsp 15 Oct 2005 21:34:41 -0000 1.4 --- KeowKernel.dsp 30 Oct 2005 01:20:17 -0000 1.5 *************** *** 55,58 **** --- 55,63 ---- # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib shlwapi.lib /nologo /subsystem:windows /debug /machine:I386 /out:"..\..\Release/KeowKernel.exe" + # Begin Special Build Tool + SOURCE="$(InputPath)" + PostBuild_Desc=Copying data files + PostBuild_Cmds=copy keow-gate\keow-gate.dso ..\..\Release + # End Special Build Tool !ELSEIF "$(CFG)" == "KeowKernel - Win32 Debug" *************** *** 82,85 **** --- 87,95 ---- # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib shlwapi.lib /nologo /subsystem:windows /debug /machine:I386 /out:"..\..\Debug/KeowKernel.exe" /pdbtype:sept + # Begin Special Build Tool + SOURCE="$(InputPath)" + PostBuild_Desc=Copying data files + PostBuild_Cmds=copy keow-gate\keow-gate.dso ..\..\Debug + # End Special Build Tool !ENDIF Index: LegacyWindows.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/LegacyWindows.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LegacyWindows.cpp 21 Oct 2005 19:03:37 -0000 1.1 --- LegacyWindows.cpp 30 Oct 2005 01:20:17 -0000 1.2 *************** *** 65,68 **** --- 65,69 ---- } + BOOL LegacyWindows::GetFileAttributesEx(LPCTSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation) { *************** *** 192,193 **** --- 193,221 ---- return ::VirtualQueryEx(hProcess, lpAddress, lpBuffer, dwLength); } + + + BOOL LegacyWindows::CreateHardLink(LPCSTR lpNewFile, LPCSTR lpOldFile) + { + HMODULE hlib = GetModuleHandle("KERNEL32"); + FARPROC fp = GetProcAddress(hlib, "CreateHardLinkA"); + #ifdef KEOW_FORCE_WIN95_VERSIONS + fp=0; + #endif + + if(fp) + { + //can use the real function + + BOOL (CALLBACK *RealCreateHardLinkA) + (LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES); + *(FARPROC *)&RealCreateHardLinkA = fp; + return RealCreateHardLinkA(lpNewFile, lpOldFile, NULL); + } + else + { + //can't do anything like this on win9x + + SetLastError(ERROR_INVALID_FUNCTION); + return FALSE; + } + } Index: LegacyWindows.h =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/LegacyWindows.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LegacyWindows.h 21 Oct 2005 19:03:37 -0000 1.1 --- LegacyWindows.h 30 Oct 2005 01:20:17 -0000 1.2 *************** *** 38,45 **** --- 38,49 ---- public: static BOOL IsProcessorFeaturePresent(DWORD dwFeature); + static BOOL GetFileAttributesEx(LPCTSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation); + static LPVOID VirtualAllocEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect); static BOOL VirtualFreeEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType); static DWORD VirtualQueryEx(HANDLE hProcess, LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength); + + static BOOL CreateHardLink(LPCSTR lpNewFile, LPCSTR lpOldFile); }; Index: sys_process.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/sys_process.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sys_process.cpp 23 Oct 2005 20:44:59 -0000 1.4 --- sys_process.cpp 30 Oct 2005 01:20:17 -0000 1.5 *************** *** 221,224 **** --- 221,234 ---- ktrace("execve(%s,...,...)\n", filename.c_str()); + //we can load this, right? + Path img; + img.SetUnixPath(filename); + if(!P->CanLoadImage(img, false)) + { + ctx.Eax = -Win32ErrToUnixError(GetLastError()); + return; //can't exec it + } + + //close files and dealloc mem P->FreeResourcesBeforeExec(); *************** *** 476,477 **** --- 486,502 ---- ktrace("wait4(%d) returned %d [%s]\n", wait_pid, result, one_stopped?"stopped":"exited" ); } + + + /* + * pid_t waitpid(pid_t pid, int *status, int options) + */ + void SysCalls::sys_waitpid(CONTEXT &ctx) + { + //reuse wait4(pid_t pid, int *status, int options, rusage *ru) + CONTEXT save = ctx; + + ctx.Esi = 0; //rusage* + sys_wait4(ctx); + + ctx.Esi = save.Esi; + } Index: sys_io.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/sys_io.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** sys_io.cpp 15 Oct 2005 21:34:41 -0000 1.6 --- sys_io.cpp 30 Oct 2005 01:20:17 -0000 1.7 *************** *** 26,29 **** --- 26,30 ---- #include "IOHPipe.h" + #include "FilesystemKeow.h" *************** *** 926,941 **** void SysCalls::sys_link(CONTEXT &ctx) { - Unhandled(ctx); - #if 0 Path OldP(false), NewP(false); ! OldP.SetUnixPath((const char*)ctx.Ebx); ! NewP.SetUnixPath((const char*)ctx.Ecx); ! if(CreateHardLink(NewP.Win32Path(), OldP.Win32Path(), NULL)) ctx.Eax = 0; else ctx.Eax = -Win32ErrToUnixError(GetLastError()); - #endif } --- 927,939 ---- void SysCalls::sys_link(CONTEXT &ctx) { Path OldP(false), NewP(false); ! OldP.SetUnixPath( MemoryHelper::ReadString(P->m_Win32PInfo.hProcess, (ADDR)ctx.Ebx) ); ! NewP.SetUnixPath( MemoryHelper::ReadString(P->m_Win32PInfo.hProcess, (ADDR)ctx.Ecx) ); ! if(LegacyWindows::CreateHardLink(NewP.GetWin32Path(), OldP.GetWin32Path())) ctx.Eax = 0; else ctx.Eax = -Win32ErrToUnixError(GetLastError()); } *************** *** 951,954 **** --- 949,965 ---- ktrace("unlink(%s)\n", p.GetWin32Path().c_str() ); + DWORD attr = GetFileAttributes(p.GetWin32Path()); + if(attr==INVALID_FILE_ATTRIBUTES) + { + ctx.Eax = -ENOENT; + return; + } + if(attr & FILE_ATTRIBUTE_DIRECTORY) + { + ctx.Eax = -EISDIR; + return; + } + + if(DeleteFile(p.GetWin32Path())) { *************** *** 979,982 **** --- 990,1007 ---- + /* + * int symlink(const char *oldpath, const char *newpath) + */ + void SysCalls::sys_symlink(CONTEXT &ctx) + { + string OldP = MemoryHelper::ReadString(P->m_Win32PInfo.hProcess, (ADDR)ctx.Ebx); + string NewP = MemoryHelper::ReadString(P->m_Win32PInfo.hProcess, (ADDR)ctx.Ecx); + + if(FilesystemKeow::CreateSymbolicLink(OldP, NewP)) + ctx.Eax = 0; + else + ctx.Eax = -Win32ErrToUnixError(GetLastError()); + } + /*****************************************************************************/ *************** *** 1273,1274 **** --- 1298,1331 ---- } + + /* + * int utime(const char *filename, struct utimbuf *buf) + */ + void SysCalls::sys_utime(CONTEXT &ctx) + { + Path path; + path.SetUnixPath( MemoryHelper::ReadString(P->m_Win32PInfo.hProcess, (ADDR)ctx.Ebx) ); + + linux::utimbuf times; + P->ReadMemory(×, (ADDR)ctx.Ecx, sizeof(times)); + + HANDLE hTmp = CreateFile(path.GetWin32Path(), FILE_WRITE_ATTRIBUTES, 0, 0, OPEN_EXISTING, 0, 0); + if(hTmp==INVALID_HANDLE_VALUE) + { + ctx.Eax = -Win32ErrToUnixError(GetLastError()); + return; + } + + + FILETIME access, modify; + TIME_T_TO_FILETIME(times.actime, access); + TIME_T_TO_FILETIME(times.modtime, modify); + + if(SetFileTime(hTmp, NULL, &access, &modify)) + ctx.Eax = 0; + else + ctx.Eax = -Win32ErrToUnixError(GetLastError()); + + CloseHandle(hTmp); + } + |
From: Paul <pa...@us...> - 2005-10-30 01:20:25
|
Update of /cvsroot/keow/keow/keow-kernel/KeowKernel/keow-gate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5873/keow-kernel/KeowKernel/keow-gate Added Files: Makefile keow-gate.c keow-gate.dso keow-gate.dso.txt Log Message: --- NEW FILE: Makefile --- keow-gate.dso: keow-gate.c cc -o keow-gate.dso -shared -fpic -fPIC -nostdlib -ffreestanding keow-gate.c --- NEW FILE: keow-gate.dso --- (This appears to be a binary file; contents omitted.) --- NEW FILE: keow-gate.c --- /* keow-gate.dso */ void __kernel_vsyscall() { asm("int $0x04"); } void __kernel_sigreturn() { asm("mov $0x77,%eax\n\t" "int $0x04"); } void __kernel_rt_sigreturn() { asm("mov $0xAD,%eax\n\t" "int $0x04"); } --- NEW FILE: keow-gate.dso.txt --- keow-gate.dso This is a work-alike of the linux 2.6 kernels linux-gate.so.1. It is not yet used. TODO: make call native SysCallsDll routine. |
From: Paul <pa...@us...> - 2005-10-30 01:20:25
|
Update of /cvsroot/keow/keow/keow-user/KeowUserSysCallsDll In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5873/keow-user/KeowUserSysCallsDll Modified Files: includes.h main.cpp Log Message: Index: main.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-user/KeowUserSysCallsDll/main.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** main.cpp 21 Oct 2005 19:03:37 -0000 1.4 --- main.cpp 30 Oct 2005 01:20:17 -0000 1.5 *************** *** 56,60 **** ! static char g_TraceBuffer[1024]; void ktrace(const char * format, ...) --- 56,60 ---- ! static char g_TraceBuffer[32768]; void ktrace(const char * format, ...) *************** *** 102,105 **** --- 102,106 ---- #endif + BOOL WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID p) { *************** *** 118,128 **** OutputDebugString("SysCallDll transfering to kernel\n"); __asm { ! lea eax, AddrInfo //set single-step mode to tell kernel we are ready pushfd ! pop ebx ! or ebx, 0x100 //trap bit ! push ebx popfd //now we are single-stepping --- 119,129 ---- OutputDebugString("SysCallDll transfering to kernel\n"); __asm { ! lea ebx, AddrInfo //set single-step mode to tell kernel we are ready pushfd ! pop eax ! or eax, 0x100 //trap bit ! push eax popfd //now we are single-stepping Index: includes.h =================================================================== RCS file: /cvsroot/keow/keow/keow-user/KeowUserSysCallsDll/includes.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** includes.h 22 Sep 2005 09:18:22 -0000 1.2 --- includes.h 30 Oct 2005 01:20:17 -0000 1.3 *************** *** 28,31 **** --- 28,34 ---- #include "../../keow-kernel/KeowKernel/linux_includes.h" #include "../../keow-kernel/KeowKernel/SysCallDll.h" + #include "../../keow-kernel/KeowKernel/string.h" + #include "../../keow-kernel/KeowKernel/list.h" + #include "../../keow-kernel/KeowKernel/utils.h" void ktrace(const char * format, ...); |
From: Paul <pa...@us...> - 2005-10-30 01:20:25
|
Update of /cvsroot/keow/keow In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5873 Modified Files: KernelEmulationOnWindows.opt Log Message: Index: KernelEmulationOnWindows.opt =================================================================== RCS file: /cvsroot/keow/keow/KernelEmulationOnWindows.opt,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 Binary files /tmp/cvsipxfSB and /tmp/cvsGoUvyr differ |
From: Paul <pa...@us...> - 2005-10-25 07:56:31
|
Update of /cvsroot/keow/keow/keow-kernel/KeowKernel/keow-gate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11237/keow-gate Log Message: Directory /cvsroot/keow/keow/keow-kernel/KeowKernel/keow-gate added to the repository |
From: Paul <pa...@us...> - 2005-10-23 20:45:07
|
Update of /cvsroot/keow/keow/keow-kernel/KeowKernel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14896/keow-kernel/KeowKernel Modified Files: KernelStartup.cpp Process.cpp Process.h Utils.cpp Utils.h sys_process.cpp Log Message: shell scripts can be run as executables now (eg ldd) Index: Utils.h =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/Utils.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Utils.h 22 Sep 2005 09:14:50 -0000 1.2 --- Utils.h 23 Oct 2005 20:44:59 -0000 1.3 *************** *** 36,39 **** --- 36,41 ---- void ktrace(const char *format, ...); void halt(); + void ParseCommandLine(LPSTR lpCmdLine, list<string> &lst); + const int SIZE4k = 4*1024; Index: Process.h =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/Process.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Process.h 15 Oct 2005 21:34:41 -0000 1.5 --- Process.h 23 Oct 2005 20:44:59 -0000 1.6 *************** *** 120,125 **** Path m_UnixPwd; - string m_CommandLine; - struct MemoryAlloc { --- 120,123 ---- Index: sys_process.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/sys_process.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sys_process.cpp 13 Oct 2005 06:52:12 -0000 1.3 --- sys_process.cpp 23 Oct 2005 20:44:59 -0000 1.4 *************** *** 215,221 **** string filename = MemoryHelper::ReadString(P->m_Win32PInfo.hProcess, (ADDR)ctx.Ebx); //need a kernel copy of argv and envp (we're about to remove the processes own memory) ! DWORD dwCnt, dwMemSize; ! ADDR argv = MemoryHelper::CopyStringListBetweenProcesses(P->m_Win32PInfo.hProcess, (ADDR)ctx.Ecx, GetCurrentProcess(), NULL, &dwCnt, &dwMemSize); ! ADDR envp = MemoryHelper::CopyStringListBetweenProcesses(P->m_Win32PInfo.hProcess, (ADDR)ctx.Edx, GetCurrentProcess(), NULL, &dwCnt, &dwMemSize); ktrace("execve(%s,...,...)\n", filename.c_str()); --- 215,221 ---- string filename = MemoryHelper::ReadString(P->m_Win32PInfo.hProcess, (ADDR)ctx.Ebx); //need a kernel copy of argv and envp (we're about to remove the processes own memory) ! DWORD dwArgCnt, dwEnvCnt, dwMemSize; ! ADDR argv = MemoryHelper::CopyStringListBetweenProcesses(P->m_Win32PInfo.hProcess, (ADDR)ctx.Ecx, GetCurrentProcess(), NULL, &dwArgCnt, &dwMemSize); ! ADDR envp = MemoryHelper::CopyStringListBetweenProcesses(P->m_Win32PInfo.hProcess, (ADDR)ctx.Edx, GetCurrentProcess(), NULL, &dwEnvCnt, &dwMemSize); ktrace("execve(%s,...,...)\n", filename.c_str()); *************** *** 227,230 **** --- 227,232 ---- P->m_Arguments = argv; P->m_Environment = envp; + P->m_ArgCnt = dwArgCnt; + P->m_EnvCnt = dwEnvCnt; //reset the keow stack (AFTER resource free - it may have injected code and new stack) *************** *** 235,239 **** //load new image P->m_ProcessFileImage.SetUnixPath(filename); ! P->LoadImage(P->m_ProcessFileImage, false); //this runs it too //participate in ptrace() --- 237,242 ---- //load new image P->m_ProcessFileImage.SetUnixPath(filename); ! P->LoadImage(P->m_ProcessFileImage, false); ! P->StartNewImageRunning(); //set up context at least //participate in ptrace() Index: Process.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/Process.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Process.cpp 21 Oct 2005 19:03:37 -0000 1.7 --- Process.cpp 23 Oct 2005 20:44:59 -0000 1.8 *************** *** 511,514 **** --- 511,517 ---- m_bInWin32Setup = false; //done now + + //make the stub execute the image + StartNewImageRunning(); } *************** *** 681,686 **** m_UnixPwd = other.m_UnixPwd; - m_CommandLine = other.m_CommandLine; - m_ElfLoadData = other.m_ElfLoadData; --- 684,687 ---- *************** *** 754,758 **** DWORD rc; ! HANDLE hImg = CreateFile(m_ProcessFileImage.GetWin32Path().c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); if(hImg==INVALID_HANDLE_VALUE) { --- 755,759 ---- DWORD rc; ! HANDLE hImg = CreateFile(img.GetWin32Path().c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); if(hImg==INVALID_HANDLE_VALUE) { *************** *** 763,767 **** //Read the first chunk of the file ! int buflen=1024; //plenty enough to understand the file DWORD dwRead; BYTE * buf = new BYTE[buflen]; --- 764,768 ---- //Read the first chunk of the file ! int buflen=1024; //plenty enough to understand the file - enough for elf header and also the 128 chars allowed for a #! shell script DWORD dwRead; BYTE * buf = new BYTE[buflen]; *************** *** 784,816 **** { //yes - it is a shell script with a header ! // eg: #!/bin/sh ! //Use that program as the process and give it the args we specified ! char * space = strchr((char*)buf, ' '); char * nl = strchr((char*)buf, 0x0a); if(nl==NULL) ! { ! buf[buflen-1] = NULL; ! space = NULL; ! } ! else ! { ! *nl = NULL; //line ends here ! char * args; ! if(space==NULL || space>nl) ! args = NULL; ! else ! args = space+1; ! //skip #! and any whitespace ! char * interp = (char*)buf + 2; ! while(*interp == ' ') ! interp++; ! rc = LoadImage(Path(interp), LoadAsLibrary); ! if(args) ! m_CommandLine = args; } } else --- 785,827 ---- { //yes - it is a shell script with a header ! // eg: #! /bin/sh -x ! //Use that program as the process and apppend our original args ! char * nl = strchr((char*)buf, 0x0a); if(nl==NULL) ! nl = (char*)&buf[buflen-1]; //use end of buffer ! *nl = NULL; //line ends here ! //skip #! and any whitespace ! char * interp = (char*)buf + 2; ! while(*interp == ' ') ! interp++; ! //process the command and arguments ! list<string> arglist; ! ParseCommandLine(interp, arglist); ! rc = LoadImage(Path(arglist[0]), false); //scripts are never libraries ! //At this point the arguments are still in the kernel ! //Prepend the interpreter arguments to the list ! ! //TODO: this is a hack - think about it and make it better ! //need list of pointers ! const char **pTmpAddr = new const char*[m_ArgCnt+arglist.size()+1]; ! //copy new pointers ! list<string>::iterator it; ! int i; ! for(i=0,it=arglist.begin(); it!=arglist.end(); ++i,++it) ! { ! pTmpAddr[i] = (*it).c_str(); } + //original pointers plus the null + memcpy(&pTmpAddr[i], m_Arguments, sizeof(ADDR)*(m_ArgCnt+1)); + //new copy + ADDR pOldArgs = m_Arguments; + m_Arguments = MemoryHelper::CopyStringListBetweenProcesses(GetCurrentProcess(), (ADDR)pTmpAddr, GetCurrentProcess(), NULL, &m_ArgCnt, NULL); + //free old kernel copy + //leak! VirtualFree(pOldArgs, dwArgsSize, MEM_DECOMMIT); } else *************** *** 826,833 **** CloseHandle(hImg); - - //make the stub execute the image - StartNewImageRunning(); - return rc; } --- 837,840 ---- Index: Utils.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/Utils.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Utils.cpp 10 Oct 2005 05:51:55 -0000 1.3 --- Utils.cpp 23 Oct 2005 20:44:59 -0000 1.4 *************** *** 77,78 **** --- 77,122 ---- } } + + + void ParseCommandLine(LPSTR lpCmdLine, list<string> &args) + { + //some yucky code to process a command line + + char * pLineEnd = lpCmdLine + strlen(lpCmdLine); + char * pArg = lpCmdLine; + while(pArg<pLineEnd) + { + bool inQuote; + string a; + char *p; + + //start of the name + while(isspace(*pArg)) + ++pArg; + + //find end of argument, possibly double quoted + p = pArg; + inQuote = false; + while((inQuote || !isspace(*p)) && p<pLineEnd) + { + //something is quoted? + if(*p=='"') + { + inQuote = !inQuote; + } + else + { + a += *p; + } + + ++p; + } + + //store + args.push_back(a); + + //next arg + pArg = p+1; + } + + } Index: KernelStartup.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/KernelStartup.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** KernelStartup.cpp 15 Oct 2005 21:34:41 -0000 1.4 --- KernelStartup.cpp 23 Oct 2005 20:44:59 -0000 1.5 *************** *** 56,96 **** list<string> args; ! ! char * pLineEnd = lpCmdLine + strlen(lpCmdLine); ! char * pArg = lpCmdLine; ! while(pArg<pLineEnd) ! { ! bool inQuote; ! string a; ! char *p; ! ! //start of the name ! while(isspace(*pArg)) ! ++pArg; ! ! //find end of argument, possibly double quoted ! p = pArg; ! inQuote = false; ! while((inQuote || !isspace(*p)) && p<pLineEnd) ! { ! //something is quoted? ! if(*p=='"') ! { ! inQuote = !inQuote; ! } ! else ! { ! a += *p; ! } ! ! ++p; ! } ! ! //store ! args.push_back(a); ! ! //next arg ! pArg = p+1; ! } //process the found args --- 56,60 ---- list<string> args; ! ParseCommandLine(lpCmdLine, args); //process the found args |
From: Paul <pa...@us...> - 2005-10-23 20:45:07
|
Update of /cvsroot/keow/keow In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14896 Modified Files: KernelEmulationOnWindows.opt Log Message: shell scripts can be run as executables now (eg ldd) Index: KernelEmulationOnWindows.opt =================================================================== RCS file: /cvsroot/keow/keow/KernelEmulationOnWindows.opt,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 Binary files /tmp/cvs9JsIZA and /tmp/cvst5UJzs differ |
From: Paul <pa...@us...> - 2005-10-21 19:44:27
|
Update of /cvsroot/keow/keow/research In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9072/research Added Files: linux-gate.dso Log Message: copy of linux-gate.so.1 extracted from debian sid with 2.6 kernel. --- NEW FILE: linux-gate.dso --- (This appears to be a binary file; contents omitted.) |
Update of /cvsroot/keow/keow/keow-kernel/KeowKernel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31454/keow-kernel/KeowKernel Modified Files: MemoryHelper.cpp Process.cpp SysCallDll.h SysCallDll_Kernel.cpp Added Files: LegacyWindows.cpp LegacyWindows.h Log Message: loads on win95 - but needs handler to intercept int80 syscalls Index: SysCallDll_Kernel.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/SysCallDll_Kernel.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SysCallDll_Kernel.cpp 15 Oct 2005 21:34:41 -0000 1.3 --- SysCallDll_Kernel.cpp 21 Oct 2005 19:03:37 -0000 1.4 *************** *** 53,56 **** --- 53,57 ---- } + /* left here as an example of how to call a function with a large structure/buffer to deal with DWORD _stdcall SysCallDll::VirtualQuery(LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength) { *************** *** 71,75 **** memcpy(lpBuffer, &stack.MemBuf, sizeof(stack.MemBuf)); return ret; ! } --- 72,76 ---- memcpy(lpBuffer, &stack.MemBuf, sizeof(stack.MemBuf)); return ret; ! }*/ *************** *** 194,195 **** --- 195,197 ---- return P->InjectFunctionCall(P->SysCallAddr.PeekAvailablePipe, &stack, sizeof(stack)); } + Index: Process.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/Process.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Process.cpp 15 Oct 2005 21:34:41 -0000 1.6 --- Process.cpp 21 Oct 2005 19:03:37 -0000 1.7 *************** *** 260,268 **** CoInitialize(NULL);//Ex(NULL, COINIT_MULTITHREADED); - //We run the debug loop at higher priority to hopefully receive and handle - //child system calls faster. The child is doing all the normal processing - //so this should not end up elevating it's priority and system impact - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); - //Start the stub STARTUPINFO si; --- 260,263 ---- *************** *** 279,282 **** --- 274,282 ---- SetEvent(P->m_hProcessStartEvent); + //We run the debug loop at higher priority to hopefully receive and handle + //child system calls faster. The child is doing all the normal processing + //so this should not end up elevating it's priority and system impact + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); + // *************** *** 362,365 **** --- 362,366 ---- m_dwExitCode = evt.u.ExitProcess.dwExitCode; m_bStillRunning = false; //parent will clean up the process table entry + ktrace("process exit debug event\n"); return; //no longer debugging *************** *** 433,437 **** //The info is passed as a pointer in Eax and causing an initial breakpoint ! m_bInWin32Setup = false; CONTEXT ctx; --- 434,438 ---- //The info is passed as a pointer in Eax and causing an initial breakpoint ! m_bInWin32Setup = true; //not done just yet CONTEXT ctx; *************** *** 476,479 **** --- 477,481 ---- ForkCopyOtherProcess(*pParent); + m_bInWin32Setup = false; //done now SetEvent(m_hForkDoneEvent); return; *************** *** 489,493 **** DWORD size=1024*1024L; //1MB will do? ADDR stack_bottom = (ADDR)0x70000000 - size; //ok location? ! m_KeowUserStackBase = MemoryHelper::AllocateMemAndProtect(stack_bottom, size, PAGE_EXECUTE_READWRITE); m_KeowUserStackTop = m_KeowUserStackBase + size; //linux process start with a little bit of stack in use but overwritable? --- 491,495 ---- DWORD size=1024*1024L; //1MB will do? ADDR stack_bottom = (ADDR)0x70000000 - size; //ok location? ! m_KeowUserStackBase = MemoryHelper::AllocateMemAndProtect(stack_bottom, size, PAGE_EXECUTE_READWRITE);//we sometimes inject executable code into the stack m_KeowUserStackTop = m_KeowUserStackBase + size; //linux process start with a little bit of stack in use but overwritable? *************** *** 497,500 **** --- 499,503 ---- //not fork or exec, must be 'init', the very first process + ktrace("init/exec: load image: %s\n", m_ProcessFileImage.GetWin32Path().c_str()); LoadImage(m_ProcessFileImage, false); *************** *** 506,509 **** --- 509,514 ---- m_OpenFiles[1]->SetInheritable(true); m_OpenFiles[2]->SetInheritable(true); + + m_bInWin32Setup = false; //done now } *************** *** 534,538 **** case EXCEPTION_SINGLE_STEP: DumpContext(ctx); ! SetSingleStep(true, &ctx); //keep it up (DEbug only?) break; --- 539,592 ---- case EXCEPTION_SINGLE_STEP: DumpContext(ctx); ! SetSingleStep(true, &ctx); //keep it up (Debug only?) ! break; ! ! case EXCEPTION_FLT_DENORMAL_OPERAND: ! case EXCEPTION_FLT_DIVIDE_BY_ZERO: ! case EXCEPTION_FLT_INEXACT_RESULT: ! case EXCEPTION_FLT_INVALID_OPERATION: ! case EXCEPTION_FLT_OVERFLOW: ! case EXCEPTION_FLT_STACK_CHECK: ! case EXCEPTION_FLT_UNDERFLOW: ! case EXCEPTION_INT_DIVIDE_BY_ZERO: ! ktrace("math exception\n"); ! SendSignal(SIGFPE); ! break; ! ! case EXCEPTION_INT_OVERFLOW: ! { ! //is this an INT 80 linux SYSCALL? ! //--Actually is it the replacement instruction that we placed there? ! ! WORD instruction; ! ReadMemory(&instruction, (ADDR)(ctx.Eip-2), sizeof(instruction)); ! if(instruction == 0x04CD) //Int 4 - overflow exception - see InterceptInt80Calls() ! { ! //this exception is raised with EIP already pointing after the instruction ! //no need to increment EIP ! ! //handle int 80h ! SysCalls::HandleInt80SysCall(ctx); ! } ! else ! { ! ReadMemory(&instruction, (ADDR)(ctx.Eip-1), sizeof(instruction)); ! if(instruction == 0x04CD) //Int 4 - overflow exception - see InterceptInt80Calls() ! { ! //this exception is raised with EIP already pointing after the instruction ! ctx.Eip += 1; ! ! //handle int 80h ! SysCalls::HandleInt80SysCall(ctx); ! } ! else ! { ! //genuine exception ! ktrace("math exception\n"); ! ktrace("(instruction = 0x%04lX)\n", instruction); ! SendSignal(SIGFPE); ! } ! } ! } break; *************** *** 540,548 **** { //is this an INT 80 linux SYSCALL? WORD instruction; ReadMemory(&instruction, (ADDR)evt.u.Exception.ExceptionRecord.ExceptionAddress, sizeof(instruction)); ! if(instruction == 0x80CD) { //skip over the INT instruction --- 594,604 ---- { //is this an INT 80 linux SYSCALL? + //or a replacement instruction that we placed there? WORD instruction; ReadMemory(&instruction, (ADDR)evt.u.Exception.ExceptionRecord.ExceptionAddress, sizeof(instruction)); ! if(instruction == 0x80CD //INT 80h ! || instruction == 0x04CD) //Int 4 - overflow exception - see InterceptInt80Calls() { //skip over the INT instruction *************** *** 556,559 **** --- 612,616 ---- { ktrace("Access violation @ 0x%08lx\n", evt.u.Exception.ExceptionRecord.ExceptionAddress); + ktrace("instruction = 0x%04lX\n", instruction); DumpContext(ctx); *************** *** 565,581 **** break; - case EXCEPTION_FLT_DENORMAL_OPERAND: - case EXCEPTION_FLT_DIVIDE_BY_ZERO: - case EXCEPTION_FLT_INEXACT_RESULT: - case EXCEPTION_FLT_INVALID_OPERATION: - case EXCEPTION_FLT_OVERFLOW: - case EXCEPTION_FLT_STACK_CHECK: - case EXCEPTION_FLT_UNDERFLOW: - case EXCEPTION_INT_DIVIDE_BY_ZERO: - case EXCEPTION_INT_OVERFLOW: - ktrace("math exception\n"); - SendSignal(SIGFPE); - break; - case EXCEPTION_PRIV_INSTRUCTION: case EXCEPTION_ILLEGAL_INSTRUCTION: --- 622,625 ---- *************** *** 713,717 **** if(hImg==INVALID_HANDLE_VALUE) { ! return GetLastError(); } --- 757,763 ---- if(hImg==INVALID_HANDLE_VALUE) { ! DWORD dwErr = GetLastError(); ! ktrace("image not found - err %d\n",dwErr); ! return dwErr; } *************** *** 771,774 **** --- 817,821 ---- { //unhandled file format + ktrace("bad/unhandled image format\n"); rc = ERROR_BAD_FORMAT; } *************** *** 1127,1132 **** m_Environment = pEnv; m_Arguments = pArgs; ! ktrace("args @ 0x%08lx\n", m_Arguments); ! ktrace("env @ 0x%08lx\n", m_Environment); //stack data needed --- 1174,1179 ---- m_Environment = pEnv; m_Arguments = pArgs; ! ktrace("%d args @ 0x%08lx\n", m_ArgCnt, m_Arguments); ! ktrace("%d env @ 0x%08lx\n", m_EnvCnt, m_Environment); //stack data needed *************** *** 1142,1145 **** --- 1189,1193 ---- //stack grows DOWN ctx.Esp -= stack_needed; + ktrace("writing initial stack frame @ 0x%08lx, len %d\n", ctx.Esp, stack_needed); //copy data to the stack *************** *** 1206,1209 **** --- 1254,1258 ---- SetThreadContext(m_Win32PInfo.hThread, &ctx); + ktrace("Transfer to ELF code done\n"); return 0; } *************** *** 1574,1583 **** //(actually it ought to be from the SysCallDll::RemoteAddrInfo) //This means we place args on the stack so that param1 pops first ! //Stack®ister cleanup is irrelavent because HandleException() restores the correct state - //shouldn't need this, but... CONTEXT OldCtx; ! OldCtx.ContextFlags = CONTEXT_FULL | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS; ! GetThreadContext(m_Win32PInfo.hThread, &OldCtx); //Injection uses the original Win32 context (& stack etc) from when --- 1623,1639 ---- //(actually it ought to be from the SysCallDll::RemoteAddrInfo) //This means we place args on the stack so that param1 pops first ! //Stack®ister cleanup is unnessesary because our caller will restore the correct state ! ! //we need current state whilst in setup ! // this is because we are using context in ConvertProcessToKeow() ! // and StartNewImageRunning() and both those cause VirtualAlloc calls ! // that on win95 cause an injection to occur. CONTEXT OldCtx; ! if(m_bInWin32Setup) ! { ! OldCtx.ContextFlags = CONTEXT_FULL; ! GetThreadContext(m_Win32PInfo.hThread, &OldCtx); ! } //Injection uses the original Win32 context (& stack etc) from when *************** *** 1587,1590 **** --- 1643,1648 ---- CONTEXT InjectCtx = m_BaseWin32Ctx; + //trying to get win95 memory written to correctly + //InjectCtx.Esp = OldCtx.Esp; //use stack WE allocated InjectCtx.Eip = (DWORD)func; //call this in the stub *************** *** 1592,1596 **** InjectCtx.Esp -= nStackDataSize; //the params ! //SetSingleStep(true, &InjectCtx); //FOR DEBUG SetThreadContext(m_Win32PInfo.hThread, &InjectCtx); --- 1650,1654 ---- InjectCtx.Esp -= nStackDataSize; //the params ! // SetSingleStep(true, &InjectCtx); //FOR DEBUG SetThreadContext(m_Win32PInfo.hThread, &InjectCtx); *************** *** 1598,1601 **** --- 1656,1660 ---- ADDR addr = (ADDR)InjectCtx.Esp; + ktrace("inject data @ 0x%08lx\n", addr); //return address - we don't actually need it (exit trapped below) *************** *** 1611,1632 **** for(int i=0; i<CountInjectInfo; ++i) { ! DWORD addr = (DWORD)ParamAddr + pInjectInfo[i].StackRelativeOffsetToBuffer; int offset = pInjectInfo[i].StackParamToActAsPointer; ! ((DWORD*)pStackData)[offset] = addr; } } WriteMemory(addr, nStackDataSize, pStackData); addr += nStackDataSize; ! //resume the process to let it run the function ! //expect the stub to do a Break at the end //we'll capture the break and then return DEBUG_EVENT evt; for(;;) { - //SetSingleStep(true); //debug FlushInstructionCache(m_Win32PInfo.hProcess, 0, 0); //need this for our process modifications? --- 1670,1692 ---- for(int i=0; i<CountInjectInfo; ++i) { ! DWORD a = (DWORD)ParamAddr + pInjectInfo[i].StackRelativeOffsetToBuffer; int offset = pInjectInfo[i].StackParamToActAsPointer; ! ((DWORD*)pStackData)[offset] = a; } } WriteMemory(addr, nStackDataSize, pStackData); addr += nStackDataSize; ! //trying to get win95 memory written to correctly ! //DumpMemory((ADDR)InjectCtx.Esp, nStackDataSize+4); ! //DumpContext(InjectCtx); //resume the process to let it run the function ! //expect the stub to do a Break (int 3) at the end //we'll capture the break and then return DEBUG_EVENT evt; for(;;) { FlushInstructionCache(m_Win32PInfo.hProcess, 0, 0); //need this for our process modifications? *************** *** 1659,1663 **** GetThreadContext(m_Win32PInfo.hThread, &ctx); DumpContext(ctx); ! HandleException(evt); #endif } --- 1719,1723 ---- GetThreadContext(m_Win32PInfo.hThread, &ctx); DumpContext(ctx); ! SendSignal(SIGSEGV); //terminate #endif } *************** *** 1666,1669 **** --- 1726,1730 ---- if(evt.dwDebugEventCode==EXIT_PROCESS_DEBUG_EVENT) { + ktrace("process exit whilst in injected code\n"); m_dwExitCode = evt.u.ExitProcess.dwExitCode; m_bStillRunning = false; *************** *** 1701,1707 **** ktrace("Injection exit @ 0x%08lx\n", InjectCtx.Eip); ! ! //No need to set keow context back. We'll be resetting the context when we return back to HandleException() ! SetThreadContext(m_Win32PInfo.hThread, &OldCtx); //but we seem to need it when Win95 needs code injection before process fully running (VirtualAlloc etc) return dwRet; --- 1762,1769 ---- ktrace("Injection exit @ 0x%08lx\n", InjectCtx.Eip); ! if(m_bInWin32Setup) ! { ! SetThreadContext(m_Win32PInfo.hThread, &OldCtx); ! } return dwRet; *************** *** 1896,1897 **** --- 1958,1960 ---- } } + --- NEW FILE: LegacyWindows.cpp --- /* * Copyright 2005 Paul Walker * * GNU General Public License * * This file is part of: Kernel Emulation on Windows (keow) * * Keow is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Keow is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Keow; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ // LegacyWindows.cpp: implementation of the LegacyWindows class. // ////////////////////////////////////////////////////////////////////// #include "includes.h" #include "LegacyWindows.h" //#define KEOW_FORCE_WIN95_VERSIONS #undef KEOW_FORCE_WIN95_VERSIONS ////////////////////////////////////////////////////////////////////// BOOL LegacyWindows::IsProcessorFeaturePresent(DWORD dwFeature) { HMODULE hlib = GetModuleHandle("KERNEL32"); FARPROC fp = GetProcAddress(hlib, "IsProcessorFeaturePresent"); #ifdef KEOW_FORCE_WIN95_VERSIONS fp=0; #endif if(fp) { //can use the real function BOOL (CALLBACK *RealIsProcessorFeaturePresent) (DWORD); *(FARPROC *)&RealIsProcessorFeaturePresent = fp; return RealIsProcessorFeaturePresent(dwFeature); } else { //emulate it switch(dwFeature) { case PF_FLOATING_POINT_EMULATED: return FALSE; default: return FALSE; } } } BOOL LegacyWindows::GetFileAttributesEx(LPCTSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation) { HMODULE hlib = GetModuleHandle("KERNEL32"); FARPROC fp = GetProcAddress(hlib, "GetFileAttributesExA"); #ifdef KEOW_FORCE_WIN95_VERSIONS fp=0; #endif if(fp) { //can use the real function BOOL (CALLBACK *RealGetFileAttributesEx) (LPCTSTR, GET_FILEEX_INFO_LEVELS, LPVOID); *(FARPROC *)&RealGetFileAttributesEx = fp; if(!RealGetFileAttributesEx(lpFileName, fInfoLevelId, lpFileInformation)) return FALSE; } else { //emulate it if(fInfoLevelId != GetFileExInfoStandard) return FALSE; //can't do it DWORD FileAddr = GetFileAttributes(lpFileName); if(FileAddr == INVALID_FILE_ATTRIBUTES) return FALSE; HANDLE hfind; WIN32_FIND_DATA wfd; string find = lpFileName; if(FileAddr & FILE_ATTRIBUTE_DIRECTORY) find += "\\*.*"; hfind = FindFirstFile(find, &wfd); if(hfind == INVALID_HANDLE_VALUE) return FALSE; FindClose(hfind); WIN32_FILE_ATTRIBUTE_DATA * pFA = (WIN32_FILE_ATTRIBUTE_DATA *)lpFileInformation; pFA->dwFileAttributes = wfd.dwFileAttributes; pFA->ftCreationTime = wfd.ftCreationTime; pFA->ftLastAccessTime = wfd.ftLastAccessTime; pFA->ftLastWriteTime = wfd.ftLastWriteTime; pFA->nFileSizeHigh = wfd.nFileSizeHigh; pFA->nFileSizeLow = wfd.nFileSizeLow; } return TRUE; } LPVOID LegacyWindows::VirtualAllocEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect) { if(hProcess == GetCurrentProcess()) return VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect); #ifdef _DEBUG if(hProcess != P->m_Win32PInfo.hProcess) DebugBreak(); #endif HMODULE hlib = GetModuleHandle("KERNEL32"); FARPROC fp = GetProcAddress(hlib, "VirtualAllocEx"); #ifdef KEOW_FORCE_WIN95_VERSIONS fp=0; #endif if(fp) { //can use the real function LPVOID (CALLBACK *RealVirtualAllocEx) (HANDLE, LPVOID, SIZE_T, DWORD, DWORD); *(FARPROC *)&RealVirtualAllocEx = fp; return RealVirtualAllocEx(hProcess, lpAddress, dwSize, flAllocationType, flProtect); } else { //get stub to do it return (LPVOID)SysCallDll::VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect); } } BOOL LegacyWindows::VirtualFreeEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType) { if(hProcess == GetCurrentProcess()) return VirtualFree(lpAddress, dwSize, dwFreeType); #ifdef _DEBUG if(hProcess != P->m_Win32PInfo.hProcess) DebugBreak(); #endif HMODULE hlib = GetModuleHandle("KERNEL32"); FARPROC fp = GetProcAddress(hlib, "VirtualFreeEx"); #ifdef KEOW_FORCE_WIN95_VERSIONS fp=0; #endif if(fp) { //can use the real function BOOL (CALLBACK *RealVirtualFreeEx) (HANDLE, LPVOID, SIZE_T, DWORD); *(FARPROC *)&RealVirtualFreeEx = fp; return RealVirtualFreeEx(hProcess, lpAddress, dwSize, dwFreeType); } else { //get stub to do it return SysCallDll::VirtualFree(lpAddress, dwSize, dwFreeType); } } DWORD LegacyWindows::VirtualQueryEx(HANDLE hProcess, LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength) { //Windows 95 does have VirtualQueryEx //we just have this routine here for consisency //(all routines using VirtualXXX functions will be using this class) return ::VirtualQueryEx(hProcess, lpAddress, lpBuffer, dwLength); } Index: MemoryHelper.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/MemoryHelper.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MemoryHelper.cpp 15 Oct 2005 21:34:41 -0000 1.3 --- MemoryHelper.cpp 21 Oct 2005 19:03:37 -0000 1.4 *************** *** 69,76 **** { LegacyWindows::VirtualQueryEx(hProcess, tmp64k, &mbi, sizeof(mbi)); if(mbi.State == MEM_FREE) { //allocate with full perms, individual pages can lock it down as required ! p = (ADDR)LegacyWindows::VirtualAllocEx(hProcess, tmp64k, SIZE64k, MEM_RESERVE, PAGE_EXECUTE_READWRITE); if(p!=tmp64k) { --- 69,82 ---- { LegacyWindows::VirtualQueryEx(hProcess, tmp64k, &mbi, sizeof(mbi)); + + DWORD len64k = end_addr - tmp64k; + if(len64k > (mbi.RegionSize - (DWORD)(tmp64k - (LPBYTE)mbi.BaseAddress))) + len64k = (mbi.RegionSize - (DWORD)(tmp64k - (LPBYTE)mbi.BaseAddress)); + len64k = (len64k+0xFFFFL) & ~0xFFFFL; //rounded up to 64k boundary + if(mbi.State == MEM_FREE) { //allocate with full perms, individual pages can lock it down as required ! p = (ADDR)LegacyWindows::VirtualAllocEx(hProcess, tmp64k, len64k, MEM_RESERVE, PAGE_EXECUTE_READWRITE); if(p!=tmp64k) { *************** *** 78,82 **** } } ! tmp64k += SIZE64k; } --- 84,89 ---- } } ! ! tmp64k += len64k; } *************** *** 87,102 **** { LegacyWindows::VirtualQueryEx(hProcess, (void*)tmp4k, &mbi, sizeof(mbi)); if(mbi.State == MEM_RESERVE) { //seems this cannot be changed within the 64k successfully? // p = LegacyWindows::VirtualAlloc((void*)tmp4k, SIZE4k, MEM_COMMIT, prot); ! p = (ADDR)LegacyWindows::VirtualAllocEx(hProcess, (void*)tmp4k, SIZE4k, MEM_COMMIT, PAGE_EXECUTE_READWRITE); if(p!=tmp4k) { return (ADDR)-1; } } ! // LegacyWindows::VirtualProtect((void*)tmp64k, SIZE4k, prot, &oldprot); //in case re-using old area ! tmp4k += SIZE4k; } --- 94,116 ---- { LegacyWindows::VirtualQueryEx(hProcess, (void*)tmp4k, &mbi, sizeof(mbi)); + + DWORD len4k = end_addr - tmp4k; + if(len4k > (mbi.RegionSize - (DWORD)(tmp4k - (LPBYTE)mbi.BaseAddress))) + len4k = (mbi.RegionSize - (DWORD)(tmp4k - (LPBYTE)mbi.BaseAddress)); + len4k = (len4k+0xFFFL) & ~0xFFFL; //rounded up to 4k boundary + if(mbi.State == MEM_RESERVE) { //seems this cannot be changed within the 64k successfully? // p = LegacyWindows::VirtualAlloc((void*)tmp4k, SIZE4k, MEM_COMMIT, prot); ! p = (ADDR)LegacyWindows::VirtualAllocEx(hProcess, (void*)tmp4k, len4k, MEM_COMMIT, PAGE_EXECUTE_READWRITE); if(p!=tmp4k) { return (ADDR)-1; } + // LegacyWindows::VirtualProtect((void*)tmp64k, SIZE4k, prot, &oldprot); //in case re-using old area } ! ! tmp4k += len4k; } *************** *** 146,151 **** /* It's not documented (anywhere I could find) but Read/Write ProcessMemory() calls appear to fail if either the local or remote addresses cross a 4k boundary. Therefore this routine has to transfer memory in chunks to ensure ! that neither end does. Example: | is a 4k boundary, . is not accessed, * is copied --- 160,168 ---- /* It's not documented (anywhere I could find) but Read/Write ProcessMemory() calls appear to fail if either the local or remote addresses cross a 4k boundary. + Possibly it is that you cannot cross an allocation boundary and that many things + use VirtualAlloc to commit in 4k blocks and not larger. + Therefore this routine has to transfer memory in chunks to ensure ! that neither end (src,dest) crosses 4k. Example: | is a 4k boundary, . is not accessed, * is copied *************** *** 193,197 **** else bRet = WriteProcessMemory(hProcess, (LPVOID)pRemote, (LPVOID)pLocal, dwRemoteToCopy, &dwXfer); ! if(bRet==FALSE) { DWORD err = GetLastError(); --- 210,214 ---- else bRet = WriteProcessMemory(hProcess, (LPVOID)pRemote, (LPVOID)pLocal, dwRemoteToCopy, &dwXfer); ! if(bRet==0) { DWORD err = GetLastError(); *************** *** 215,219 **** else bRet = WriteProcessMemory(hProcess, (LPVOID)pRemote, (LPVOID)pLocal, dwRemoteToCopy, &dwXfer); ! if(bRet==FALSE) { DWORD err = GetLastError(); --- 232,236 ---- else bRet = WriteProcessMemory(hProcess, (LPVOID)pRemote, (LPVOID)pLocal, dwRemoteToCopy, &dwXfer); ! if(bRet==0) { DWORD err = GetLastError(); --- NEW FILE: LegacyWindows.h --- /* * Copyright 2005 Paul Walker * * GNU General Public License * * This file is part of: Kernel Emulation on Windows (keow) * * Keow is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Keow is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Keow; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ // LegacyWindows.h: interface for the LegacyWindows class. // This is windows functions that need emulating in Win95 etc // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_LEGACYWINDOWS_H__E7DD2E50_8394_481B_95DE_6B192387DA06__INCLUDED_) #define AFX_LEGACYWINDOWS_H__E7DD2E50_8394_481B_95DE_6B192387DA06__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 class LegacyWindows { public: static BOOL IsProcessorFeaturePresent(DWORD dwFeature); static BOOL GetFileAttributesEx(LPCTSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation); static LPVOID VirtualAllocEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect); static BOOL VirtualFreeEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType); static DWORD VirtualQueryEx(HANDLE hProcess, LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength); }; #endif // !defined(AFX_LEGACYWINDOWS_H__E7DD2E50_8394_481B_95DE_6B192387DA06__INCLUDED_) Index: SysCallDll.h =================================================================== RCS file: /cvsroot/keow/keow/keow-kernel/KeowKernel/SysCallDll.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SysCallDll.h 15 Oct 2005 21:34:41 -0000 1.3 --- SysCallDll.h 21 Oct 2005 19:03:37 -0000 1.4 *************** *** 57,61 **** SC VirtualAlloc(LPVOID lpAddress, DWORD dwSize, DWORD flAllocationType, DWORD flProtect); SC VirtualFree(LPVOID lpAddress, DWORD dwSize, DWORD dwFreeType); - SC VirtualQuery(LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength); SC GetLastError(); SC CloseHandle(HANDLE h); --- 57,60 ---- *************** *** 78,82 **** LPVOID VirtualAlloc; LPVOID VirtualFree; - LPVOID VirtualQuery; LPVOID GetLastError; LPVOID CloseHandle; --- 77,80 ---- |
From: Paul <pa...@us...> - 2005-10-21 19:03:45
|
Update of /cvsroot/keow/keow In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31454 Modified Files: KernelEmulationOnWindows.opt Log Message: loads on win95 - but needs handler to intercept int80 syscalls Index: KernelEmulationOnWindows.opt =================================================================== RCS file: /cvsroot/keow/keow/KernelEmulationOnWindows.opt,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 Binary files /tmp/cvsQMHkfm and /tmp/cvs2WyIca differ |
From: Paul <pa...@us...> - 2005-10-21 19:03:45
|
Update of /cvsroot/keow/keow/keow-user/KeowUserSysCallsDll In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31454/keow-user/KeowUserSysCallsDll Modified Files: SysCallDll_User.cpp main.cpp Log Message: loads on win95 - but needs handler to intercept int80 syscalls Index: main.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-user/KeowUserSysCallsDll/main.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** main.cpp 15 Oct 2005 21:34:42 -0000 1.3 --- main.cpp 21 Oct 2005 19:03:37 -0000 1.4 *************** *** 38,42 **** SET_ADDR(VirtualAlloc); SET_ADDR(VirtualFree); - SET_ADDR(VirtualQuery); SET_ADDR(GetLastError); SET_ADDR(CloseHandle); --- 38,41 ---- *************** *** 70,73 **** --- 69,105 ---- + #if 1 + void DumpMemory(BYTE * addr, DWORD len) + { + const int BYTES_PER_LINE = 8; + char hexbuf[5 * BYTES_PER_LINE + 1]; // "0x00 "... + null + char charbuf[BYTES_PER_LINE + 1]; // "xxxxxxxx" + null + int x; + BYTE b; + + memset(charbuf, 0, sizeof(charbuf)); + + ktrace("memory dump @ 0x%08lx, len %d\n", addr,len); + x=0; + for(DWORD i=0; i<len; ++i) + { + b = addr[x]; + wsprintf(&hexbuf[x*5], "0x%02x ", b); + charbuf[x] = (isalnum(b)||ispunct(b)) ? b : '.'; + + ++x; + if(x>=BYTES_PER_LINE) + { + ktrace(" 0x%08lx: %s %s\n", addr, hexbuf, charbuf); + addr+=BYTES_PER_LINE; + x=0; + memset(charbuf, 0, sizeof(charbuf)); + } + } + if(x>0) + ktrace(" 0x%08lx: %s %s\n", addr, hexbuf, charbuf); + } + #endif + BOOL WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID p) { Index: SysCallDll_User.cpp =================================================================== RCS file: /cvsroot/keow/keow/keow-user/KeowUserSysCallsDll/SysCallDll_User.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SysCallDll_User.cpp 15 Oct 2005 21:34:41 -0000 1.3 --- SysCallDll_User.cpp 21 Oct 2005 19:03:37 -0000 1.4 *************** *** 28,35 **** #include "includes.h" - SysCallDll::RemoteAddrInfo AddrInfo; DWORD g_LastError = 0; //How to return from these functions so that the kernel/debugger see's it --- 28,36 ---- #include "includes.h" SysCallDll::RemoteAddrInfo AddrInfo; DWORD g_LastError = 0; + extern void DumpMemory(BYTE * addr, DWORD len); + //How to return from these functions so that the kernel/debugger see's it *************** *** 44,47 **** --- 45,95 ---- DWORD _stdcall SysCallDll::VirtualAlloc(LPVOID lpAddress, DWORD dwSize, DWORD flAllocationType, DWORD flProtect) { + #if 0 + //we are expecting lpAddress = 0x6ff00000, dwSize=1M + //search to see where in memory we can find it + ktrace("lpaddr @ 0x%08lx\n", &lpAddress); + DWORD stack; + __asm mov stack,esp + DumpMemory((LPBYTE)stack-4, 64); + + ktrace("searching for 0x6ff00000\n"); + BYTE * addr; + BYTE * prev_addr = 0; + for(addr=0; addr<(BYTE*)0x80000000L; ) + { + if(((DWORD)addr&0xFFF00000) != ((DWORD)prev_addr&0xFFF00000)) + { + ktrace("looking ... %08lx\n", addr); + } + prev_addr = addr; + + //is this block of memory allocated? + MEMORY_BASIC_INFORMATION m; + if(::VirtualQuery(addr, &m, sizeof(m)) > 0 + && m.State==MEM_COMMIT) + { + addr = (BYTE*)m.BaseAddress; + { + //search this block of memory for the value + for(DWORD i=0; i<m.RegionSize-8; ++i) + { + DWORD * pTest = (DWORD*)(addr+i); + if(*pTest==0x6ff00000 + )//&& *(pTest+1)==1M) + { + ktrace("found 0x6ff00000 @ 0x%08lx\n", addr+i); + DumpMemory(addr+i, m.RegionSize-i<64?m.RegionSize-i:64); + } + } + } + addr += m.RegionSize; + } + else + { + addr+=4096; + } + } + ktrace("search done\n"); + #endif ktrace("VirtualAlloc(0x%08lx, %d, %d, %d)\n", lpAddress, dwSize, flAllocationType, flProtect); RET( (DWORD)::VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect) ); *************** *** 54,64 **** } - DWORD _stdcall SysCallDll::VirtualQuery(LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength) - { - ktrace("virtualquery(0x%08lx,0x%08lx,%d)\n", lpAddress, lpBuffer, dwLength); - RET( ::VirtualQuery(lpAddress, lpBuffer, dwLength) ); - } - - DWORD _stdcall SysCallDll::GetLastError() { --- 102,105 ---- |
From: Paul <pa...@us...> - 2005-10-15 21:34:55
|
Update of /cvsroot/keow/keow In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20002 Modified Files: KernelEmulationOnWindows.opt make-release.sh Log Message: debugging to get running in win95 Index: KernelEmulationOnWindows.opt =================================================================== RCS file: /cvsroot/keow/keow/KernelEmulationOnWindows.opt,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 Binary files /tmp/cvsoGMsoe and /tmp/cvs91U98a differ Index: make-release.sh =================================================================== RCS file: /cvsroot/keow/keow/make-release.sh,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** make-release.sh 22 Mar 2005 09:17:12 -0000 1.3 --- make-release.sh 15 Oct 2005 21:34:41 -0000 1.4 *************** *** 10,14 **** rm -f keow.zip [ ! -d keow ] && mkdir keow ! cp Release/*.exe Release/*.dll INSTALL-keow.txt keow zip -r9 keow.zip keow --- 10,14 ---- rm -f keow.zip [ ! -d keow ] && mkdir keow ! cp Release/*.exe Release/*.dll Build/INSTALL-keow.txt keow zip -r9 keow.zip keow |