Copy makefile
[reactos.git] / os2 / server / os2ss.cpp
index 2ab2050..8ece4bb 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: os2ss.cpp,v 1.1 2002/03/23 19:23:28 robertk Exp $
+/* $Id: os2ss.cpp,v 1.2 2003/01/07 16:23:12 robd Exp $
  *
  * reactos/subsys/csrss/api/process.c
  *
 
 #include <ddk/ntddk.h>
 #include <ntdll/rtl.h>
+#include <ntos/synch.h>
+
+extern "C" {
+BOOL CsrServerInitialization(ULONG ArgumentCount, PWSTR *ArgumentArray);
+VOID DisplayString(LPCWSTR lpwString);
+//BOOL STDCALL CsrServerInitialization (ULONG ArgumentCount, PWSTR *ArgumentArray);
+//VOID STDCALL DisplayString(LPCWSTR lpwString);
+//VOID STDCALL PrintString (char* fmt, ...);
+//NTSTATUS STDCALL NtDisplayString(IN PUNICODE_STRING DisplayString);
+
+void
+DisplayString(LPCWSTR lpwString)
+{
+  UNICODE_STRING us;
+
+  RtlInitUnicodeString(&us, lpwString);
+  NtDisplayString(&us);
+}
+
+/*
+void
+PrintString(char* fmt,...)
+{
+  char buffer[512];
+  va_list ap;
+  UNICODE_STRING UnicodeString;
+  ANSI_STRING AnsiString;
+
+  va_start(ap, fmt);
+  vsprintf(buffer, fmt, ap);
+  va_end(ap);
+
+  RtlInitAnsiString(&AnsiString, buffer);
+  RtlAnsiStringToUnicodeString(&UnicodeString,
+                              &AnsiString,
+                              TRUE);
+  NtDisplayString(&UnicodeString);
+  RtlFreeUnicodeString(&UnicodeString);
+}
+ */
 
+}
 
 /* server variables */
 
@@ -46,70 +87,71 @@ void NtProcessStartup (PPEB Peb)
 
    while (ArgBuffer[i])
      {
-       if (ArgBuffer[i] == L' ')
-         {
-            argc++;
-            ArgBuffer[i] = L'\0';
-            argv[argc-1] = &(ArgBuffer[afterlastspace]);
-            i++;
-            while (ArgBuffer[i] == L' ')
-               i++;
-            afterlastspace = i;
-         }
-       else
-         {
-            i++;
-         }
+        if (ArgBuffer[i] == L' ')
+          {
+             argc++;
+             ArgBuffer[i] = L'\0';
+             argv[argc-1] = &(ArgBuffer[afterlastspace]);
+             i++;
+             while (ArgBuffer[i] == L' ')
+                i++;
+             afterlastspace = i;
+          }
+        else
+          {
+             i++;
+          }
      }
 
    if (ArgBuffer[afterlastspace] != L'\0')
      {
-       argc++;
-       ArgBuffer[i] = L'\0';
-       argv[argc-1] = &(ArgBuffer[afterlastspace]);
+        argc++;
+        ArgBuffer[i] = L'\0';
+        argv[argc-1] = &(ArgBuffer[afterlastspace]);
      }
    
    RtlInitUnicodeString(&UnicodeString,
-                       L"\\CsrssInitDone");
+                        L"\\CsrssInitDone");
    InitializeObjectAttributes(&ObjectAttributes,
-                             &UnicodeString,
-                             EVENT_ALL_ACCESS,
-                             0,
-                             NULL);
+                              &UnicodeString,
+                              EVENT_ALL_ACCESS,
+                              0,
+                              NULL);
    Status = NtOpenEvent(&CsrssInitEvent,
-                       EVENT_ALL_ACCESS,
-                       &ObjectAttributes);
+                        EVENT_ALL_ACCESS,
+                        &ObjectAttributes);
    if (!NT_SUCCESS(Status))
      {
-       DbgPrint("CSR: Failed to open csrss notification event\n");
+        DbgPrint("CSR: Failed to open csrss notification event\n");
      }
    if (CsrServerInitialization (argc, argv) == TRUE)
      {
 
-       NtSetEvent(CsrssInitEvent,
-                  NULL);
-       
-       RtlFreeHeap (Peb->ProcessHeap,
-                    0, argv);
-       RtlFreeHeap (Peb->ProcessHeap,
-                    0,
-                    ArgBuffer);
-
-       /* terminate the current thread only */
-       NtTerminateThread( NtCurrentThread(), 0 );
+        NtSetEvent(CsrssInitEvent,
+                   NULL);
+        
+        RtlFreeHeap (Peb->ProcessHeap,
+                     0, argv);
+        RtlFreeHeap (Peb->ProcessHeap,
+                     0,
+                     ArgBuffer);
+
+        /* terminate the current thread only */
+        NtTerminateThread( NtCurrentThread(), 0 );
      }
    else
      {
-       DisplayString( L"CSR: Subsystem initialization failed.\n" );
-
-       RtlFreeHeap (Peb->ProcessHeap,
-                    0, argv);
-       RtlFreeHeap (Peb->ProcessHeap,
-                    0,
-                    ArgBuffer);
-
-       /*
-        * Tell SM we failed.
-        */
-       NtTerminateProcess( NtCurrentProcess(), 0 );
-}
\ No newline at end of file
+        DisplayString( L"CSR: Subsystem initialization failed.\n" );
+
+        RtlFreeHeap (Peb->ProcessHeap,
+                     0, argv);
+        RtlFreeHeap (Peb->ProcessHeap,
+                     0,
+                     ArgBuffer);
+
+        /*
+         * Tell SM we failed.
+         */
+        NtTerminateProcess( NtCurrentProcess(), 0 );
+   }
+}