/*++ Copyright (c) Microsoft Corporation. All rights reserved. THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. Module Name: OZ-UTokyo2004.h UTokyo2004 version Abstract: Original Author: Dave Probert Environment: User mode Win32 DLL Revision History: Version for UTokyo July 2004 --*/ #ifdef OZDLL # define OZDLL_IMPORT #else # define OZDLL_IMPORT DECLSPEC_IMPORT #endif // !OZDLL OZDLL_IMPORT HANDLE WINAPI OzCreateProcess ( IN char* exename, OUT PVOID* pstartaddress); OZDLL_IMPORT BOOL WINAPI OzSetChildProcessName ( IN HANDLE ProcessHandle, IN PCHAR ImageName ); OZDLL_IMPORT HANDLE WINAPI OzCreateThread ( IN HANDLE process, IN PVOID startaddress, IN PVOID arg ); OZDLL_IMPORT BOOL WINAPI OzResumeThread ( IN HANDLE thread ); OZDLL_IMPORT BOOL WINAPI OzSuspendThread ( IN HANDLE thread ); OZDLL_IMPORT BOOL WINAPI OzTerminateProcess( IN HANDLE ProcessHandle, IN ULONG status ); OZDLL_IMPORT BOOL WINAPI OzTerminateThread( IN HANDLE ThreadHandle, IN ULONG status ); OZDLL_IMPORT VOID WINAPI SetVerboseFlag( IN BOOL value ); OZDLL_IMPORT VOID WINAPI SetServerFlag( IN BOOL value ); OZDLL_IMPORT VOID WINAPI WriteOutput( char* msg ); OZDLL_IMPORT HANDLE WINAPI OzOpenFile( PCHAR path, UINT mode ); OZDLL_IMPORT ULONG WINAPI OzReadFile( HANDLE fd, PCHAR buffer, ULONG maxlength ); OZDLL_IMPORT ULONG WINAPI OzWriteFile( HANDLE fd, PCHAR buffer, ULONG maxlength ); OZDLL_IMPORT VOID WINAPI OzCloseFile( HANDLE fd ); OZDLL_IMPORT BOOL WINAPI OzCloseRemoteNTHandle( HANDLE process, HANDLE NThandle ); OZDLL_IMPORT HANDLE WINAPI OzDuplicateHandleToChild ( HANDLE childprocess, HANDLE NTHandle ); OZDLL_IMPORT HANDLE WINAPI OzDuplicateHandleFromChild ( HANDLE childprocess, HANDLE NTHandle ); OZDLL_IMPORT HANDLE WINAPI OzCreateAnonymousSection ( ULONG size ); OZDLL_IMPORT HANDLE WINAPI OzCreateFileSection ( HANDLE filehandle ); OZDLL_IMPORT PVOID WINAPI OzMapSection( HANDLE section, HANDLE process, PVOID baseaddress, SIZE_T size ); OZDLL_IMPORT BOOL WINAPI OzUnmapSection( HANDLE process, PVOID baseaddress ); OZDLL_IMPORT VOID WINAPI OzCloseSection( HANDLE filehandle ); OZDLL_IMPORT BOOL WINAPI OzReadChildMemory ( IN HANDLE childprocess, IN PVOID childaddress, IN SIZE_T buffersize, OUT PVOID buffer ); OZDLL_IMPORT BOOL WINAPI OzWriteChildMemory ( IN HANDLE childprocess, IN PVOID childaddress, IN SIZE_T buffersize, OUT PVOID buffer ); // // OzOpen modes // #define OZOPEN_READ 0x001 #define OZOPEN_WRITE 0x002 #define OZOPEN_MAYCREATE 0x010 #define OZOPEN_TRUNCATE 0x020 // // // #define OZ_LPC_REQUEST 1 #define OZ_LPC_REPLY 2 #define OZ_LPC_DATAGRAM 3 #define OZ_LPC_LOST_REPLY 4 #define OZ_LPC_PORT_CLOSED 5 #define OZ_LPC_CLIENT_DIED 6 #define OZ_LPC_EXCEPTION 7 #define OZ_LPC_DEBUG_EVENT 8 #define OZ_LPC_ERROR_EVENT 9 #define OZ_LPC_CONNECTION_REQUEST 10 typedef struct _OZ_PORT_MESSAGE { unsigned short DataLength; unsigned short TotalLength; unsigned short Type; unsigned short DataInfoOffset; ULONG_PTR ClientProcessId; ULONG_PTR ClientThreadId; ULONG MessageId; ULONG CallbackId; // UCHAR Data[]; } OZ_PORT_MESSAGE, *POZ_PORT_MESSAGE; OZDLL_IMPORT HANDLE OzCreatePort ( PCHAR portname, ULONG maxmessagesize ); OZDLL_IMPORT HANDLE OzConnectPort ( PCHAR portname ); OZDLL_IMPORT HANDLE OzAcceptConnection ( POZ_PORT_MESSAGE connectionmessage, BOOLEAN acceptconnection, PVOID portcontext ); OZDLL_IMPORT LONG OzRequestWaitReplyMessage ( HANDLE porthandle, POZ_PORT_MESSAGE request, POZ_PORT_MESSAGE reply ); OZDLL_IMPORT LONG OzReplyWaitReceive ( HANDLE porthandle, POZ_PORT_MESSAGE reply, // optional POZ_PORT_MESSAGE receive, // optional PVOID* portcontext // optional ); typedef struct { ULONG pid; HANDLE handle; } Hashentry; // // For hashing child process id -> child process handle // void OzRegisterPIDHandle( ULONG childprocessid, HANDLE childprocess ); HANDLE OzGetPIDHandle( ULONG childprocessid ); // // Define system calls in this table // enum mysyscode; typedef struct _OZSYSCALL { enum mysyscode ozsyscode; ULONG_PTR ozarg[4]; ULONG_PTR result; } OZSYSCALL, *POZSYSCALL; typedef ULONG_PTR (*POZSYSCALLHANDLER)(HANDLE clientprocess, POZSYSCALL psyscall); OZDLL_IMPORT ULONG_PTR WINAPI OzSyscall ( enum mysyscode ozsyscode, ULONG_PTR arg0, ULONG_PTR arg1, ULONG_PTR arg2, ULONG_PTR arg3 ); OZDLL_IMPORT BOOL OzDispatchSyscalls ( IN POZSYSCALLHANDLER sysenter[], IN ULONG nsysentries ); // // // System call stuff // #define OZ_PORTNAME "\\OZ" ///////////////////////////////////////// ///////////////////////////////////////// // ADD SYSCALLS BELOW ///////////////////////////////////////// ///////////////////////////////////////// // define system calls in this table enum mysyscode { myos_printmsg = 0 // ,myos_syscall1 = 1 // ,myos_syscall2 = 2 // ,myos_syscall3 = 3 // ,myos_syscall4 = 4 }; //#define MYSYS_LIMIT 5 #define MYSYS_LIMIT 1