From 3665f8cac451007009dd9dd9843a5e39b9313ef1 Mon Sep 17 00:00:00 2001 From: Robert Kopferl Date: Thu, 18 Apr 2002 23:49:42 +0000 Subject: [PATCH] documentatnio and slight mods svn path=/trunk/; revision=2857 --- os2/doc/index.html | 67 ++++++++++++++++++++++ os2/lib/doscalls/misc/doscalls.c | 98 +++++++++++++++++++++++++++++++- os2/lib/doscalls/misc/os2def.h | 4 +- 3 files changed, 166 insertions(+), 3 deletions(-) create mode 100644 os2/doc/index.html diff --git a/os2/doc/index.html b/os2/doc/index.html new file mode 100644 index 00000000000..8f28539bcb0 --- /dev/null +++ b/os2/doc/index.html @@ -0,0 +1,67 @@ + + +OS/2 subsystem for ReactOS + + + + +

OS/2 subsystem for ReactOS (ROS/2)

+

Introduction

+

The OS/2 subsystem is being developed to enable NT-like systems (like WinNT + and ReactOS) to run 32-Bit OS/2 applications natively. With this it shall provide + binary compatiblility on x86-Based systems. It is intended to port the ROS/2 + also to other platforms supported by ReactOS / NT. It is planned to provide + source code compatibility on these platforms. Yeeahh, OS/2 for PowerPC is in + sight.

+

Components

+

ROS/2 consists of the following components:

+ +

Current state

+

Up to now just a fragment of DOSCALLS.DLL exists. The biggest problem are the + os2 API headers which are (C) by IBM. So help is still welcome.

+

16-Bit issues

+

It is not intended to support 16-bit OS/2 applications. This would make the + system inconsistent and produce much more work that use. But there is still + one issue: Current textmode applications are either 16-bit or use thunking to + call the 16-bit APIs. These 32-Bit thunking applications have to be supported. + We are still thinking how to accomplish that.

+

32-Bit issues

+

It is planned to replace the current MOU- KBD- MSG- and VIO- subsystems with + the Unicode + Console API. This is also the foundation for other platforms we want to + provide source code compatibility with. So nearly every 32-Bit processor can + be supported. It sould even be possible to implement a 64-bit OS/2 API.

+

Architecture

+

To understand the architecture of ReactOS or WinNT read a book from the "Inside + Windows NT"-series. The architecture of ROS/2 is like every normal subsystem. + When OS2SS.EXE starts, it creates an object directory named os2 and therein + it creates a port object with the name Os2API. A port is something like a socket. + Two programs can comunicate with each other via a port. The port Os2API provides + the LPC API of the OS2SS.EXE - the actual subsystem.
+ Every OS/2 program that is loaded, is linked with DOSCALLS.DLL and NTDLL.DLL + - the interface to the NT-kernel. Since DOSCALLS is implemented using NTDLL.DLL, + every OS/2 app has it in its adress space. Many functions in DOSCALLS.DLL are + implemented by just wrapping NTDLL.DLL functions. Some functions however need + assistance by the subsystem. For this reason the app makes an LPC to OS2SS.EXE. + LPC means local procedure call and it is a very fast version of RPC. Together + with the first application also OS2.EXE starts up. OS2.EXE runs in the win32 + subsystem with the security of the current user. OS2.EXE is used to gather keyboard + and mouse input and to show console windows and PM-windows of all OS/2 programms + of the current user. In order to accomplish this OS2.EXE creates a port object + in the os2 object directory named Os2Interact. OS/2 applications have a connection + to OS2.EXE, too. OS2SS.EXE and OS2.EXE also talk to each other. An OS/2 application + then makes LPCs either to OS2.EXE directly or if required via OS2SS.EXE.

+

Details

+

 

+

LPC Documentation

+ + diff --git a/os2/lib/doscalls/misc/doscalls.c b/os2/lib/doscalls/misc/doscalls.c index 5e691a97085..5ccea055af2 100644 --- a/os2/lib/doscalls/misc/doscalls.c +++ b/os2/lib/doscalls/misc/doscalls.c @@ -1,4 +1,4 @@ -/* $Id: doscalls.c,v 1.3 2002/03/24 18:55:38 ea Exp $ +/* $Id: doscalls.c,v 1.4 2002/04/18 23:49:42 robertk Exp $ */ /* * @@ -58,6 +58,85 @@ IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength );*/ + + + + OBJECT_ATTRIBUTES ObjectAttributes; + IO_STATUS_BLOCK IoStatusBlock; + UNICODE_STRING NtPathU; + HANDLE FileHandle; + NTSTATUS Status; + ULONG Flags = 0; + + switch (dwCreationDisposition) + { + case CREATE_NEW: + dwCreationDisposition = FILE_CREATE; + break; + + case CREATE_ALWAYS: + dwCreationDisposition = FILE_OVERWRITE_IF; + break; + + case OPEN_EXISTING: + dwCreationDisposition = FILE_OPEN; + break; + + case OPEN_ALWAYS: + dwCreationDisposition = OPEN_ALWAYS; + break; + + case TRUNCATE_EXISTING: + dwCreationDisposition = FILE_OVERWRITE; + } + + DPRINT("CreateFileW(lpFileName %S)\n",lpFileName); + + if (dwDesiredAccess & GENERIC_READ) + dwDesiredAccess |= FILE_GENERIC_READ; + + if (dwDesiredAccess & GENERIC_WRITE) + dwDesiredAccess |= FILE_GENERIC_WRITE; + + if (!(dwFlagsAndAttributes & FILE_FLAG_OVERLAPPED)) + { + Flags |= FILE_SYNCHRONOUS_IO_ALERT; + } + + if (!RtlDosPathNameToNtPathName_U ((LPWSTR)lpFileName, + &NtPathU, + NULL, + NULL)) + return INVALID_HANDLE_VALUE; + + DPRINT("NtPathU \'%S\'\n", NtPathU.Buffer); + + ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); + ObjectAttributes.RootDirectory = NULL; + ObjectAttributes.ObjectName = &NtPathU; + ObjectAttributes.Attributes = OBJ_CASE_INSENSITIVE; + ObjectAttributes.SecurityDescriptor = NULL; + ObjectAttributes.SecurityQualityOfService = NULL; + + Status = NtCreateFile (&FileHandle, + dwDesiredAccess, + &ObjectAttributes, + &IoStatusBlock, + NULL, + dwFlagsAndAttributes, + dwShareMode, + dwCreationDisposition, + Flags, + NULL, + 0); + if (!NT_SUCCESS(Status)) + { + SetLastErrorByStatus (Status); + return INVALID_HANDLE_VALUE; + } + + return FileHandle; + return 0; } @@ -175,6 +254,23 @@ APIRET STDCALL Dos32Beep(ULONG freq, ULONG dur) if( freq<0x25 || freq>0x7FFF ) return 395; // ERROR_INVALID_FREQUENCY + HANDLE hBeep; + IO_STATUS_BLOCK ComplStatus; + //UNICODE_STRING + OBJECT_ATTRIBUTES oa = {sizeof oa, 0, {8,8,"\\\\.\\Beep"l}, OBJ_CASE_INSENSITIVE}; + NTSTATUS stat; + stat = NtOpenFile( &hBeep, + FILE_READ_DATA | FILE_WRITE_DATA, + &oa, + &ComplStatus, + 0, // no sharing + FILE_OPEN ); + + if (!NT_SUCCESS(stat)) + { + } + + if( ComplStatus-> /* HANDLE hBeep; BEEP_SET_PARAMETERS BeepSetParameters; DWORD dwReturned; diff --git a/os2/lib/doscalls/misc/os2def.h b/os2/lib/doscalls/misc/os2def.h index e555dc3e5c7..527075f3a17 100644 --- a/os2/lib/doscalls/misc/os2def.h +++ b/os2/lib/doscalls/misc/os2def.h @@ -1,11 +1,11 @@ -/* $Id: os2def.h,v 1.2 2002/03/24 18:55:39 ea Exp $ */ +/* $Id: os2def.h,v 1.3 2002/04/18 23:49:42 robertk Exp $ */ /* This file conains common OS/2 types that are needed to build this dll */ /* this file should have temporal character until a better idea is born */ #ifndef __OS2DEF__ #define __OS2DEF__ -typedef unsigned long APIRET; +typedef unsigned long __stdcall APIRET; #define APIENTRY typedef char *PSZ; typedef char *NPSZ;