Emanuele Aliberti <ea@reactos.com>
authorEmanuele Aliberti <ea@iol.it>
Thu, 23 Sep 2004 21:01:23 +0000 (21:01 +0000)
committerEmanuele Aliberti <ea@iol.it>
Thu, 23 Sep 2004 21:01:23 +0000 (21:01 +0000)
- Some stubs for ts moved in process/session.c.
- Implemented ProcessIdToSessionId.

svn path=/trunk/; revision=11017

reactos/lib/kernel32/kernel32.def
reactos/lib/kernel32/kernel32.rc
reactos/lib/kernel32/misc/stubs.c
reactos/lib/kernel32/process/session.c

index 2bac4b6..eed5072 100644 (file)
@@ -168,8 +168,8 @@ DisconnectNamedPipe@4
 DnsHostnameToComputerNameA@12
 DnsHostnameToComputerNameW@12
 DosDateTimeToFileTime@12
-;DosPathToSessionPathA
-;DosPathToSessionPathW
+DosPathToSessionPathA@12
+DosPathToSessionPathW@12
 DuplicateConsoleHandle@16
 DuplicateHandle@28
 EndUpdateResourceA@8
index b48d4ca..62d85e4 100644 (file)
@@ -29,6 +29,7 @@ BEGIN
             VALUE "OriginalFilename",  "kernel32.dll\0"
             VALUE "ProductName",       RES_STR_PRODUCT_NAME
             VALUE "ProductVersion",    RES_STR_PRODUCT_VERSION
+            VALUE "Build Date",                RES_STR_BUILD_DATE
         END
     END
     BLOCK "VarFileInfo"
index d3646da..cdd9dea 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.91 2004/09/23 19:03:26 weiden Exp $
+/* $Id: stubs.c,v 1.92 2004/09/23 21:01:23 ea Exp $
  *
  * KERNEL32.DLL stubs (STUB functions)
  * Remove from this file, if you implement them.
@@ -1197,17 +1197,6 @@ WriteFileGather(
     return 0;
 }
 
-/*
- * @unimplemented
- */
-DWORD
-STDCALL
-WTSGetActiveConsoleSessionId(VOID)
-{
-    STUB;
-    return 0;
-}
-
 /*
  * @unimplemented
  */
index d79e9e8..385195a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: session.c,v 1.5 2003/07/10 18:50:51 chorns Exp $
+/* $Id: session.c,v 1.6 2004/09/23 21:01:23 ea Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
  */
 #include <k32.h>
 
+DWORD ActiveConsoleSessionId = 0;
+
+
+/*
+ * @unimplemented
+ */
+DWORD STDCALL
+DosPathToSessionPathW (DWORD SessionID, LPWSTR InPath, LPWSTR * OutPath)
+{
+       return 0;
+}
+
 /*
+ * From: ActiveVB.DE
+ *
+ * Declare Function DosPathToSessionPath _
+ * Lib "kernel32.dll" _
+ * Alias "DosPathToSessionPathA" ( _
+ *     ByVal SessionId As Long, _
+ *     ByVal pInPath As String, _
+ *     ByVal ppOutPath As String ) _
+ * As Long
+ * 
  * @unimplemented
  */
-BOOL STDCALL ProcessIdToSessionId (
-  DWORD dwProcessId,
-  DWORD* pSessionId
-  )
+DWORD STDCALL
+DosPathToSessionPathA (DWORD SessionId, LPSTR InPath, LPSTR * OutPath)
+{
+       //DosPathToSessionPathW (SessionId,InPathW,OutPathW);
+       return 0;
+}
+
+/*
+ * @implemented
+ */
+BOOL STDCALL ProcessIdToSessionId (IN  DWORD dwProcessId,
+                                  OUT DWORD* pSessionId)
 {
-       if (NULL != pSessionId)
+       NTSTATUS           Status = STATUS_SUCCESS;
+       HANDLE             ProcessHandle = INVALID_HANDLE_VALUE;
+       OBJECT_ATTRIBUTES  Oa = { sizeof (OBJECT_ATTRIBUTES), 0, };
+       DWORD              SessionId = 0;
+
+       if (IsBadWritePtr(pSessionId, sizeof (DWORD)))
+       {
+               SetLastError (ERROR_INVALID_DATA); //FIXME
+               goto ProcessIdToSessionId_FAIL_EXIT;
+       }
+       Status = NtOpenProcess (
+                       & ProcessHandle,
+                       PROCESS_QUERY_INFORMATION,
+                       & Oa,
+                       NULL);
+       if (!NT_SUCCESS(Status))
+       {
+               goto ProcessIdToSessionId_FAIL;
+       }
+       Status = NtQueryInformationProcess (
+                       ProcessHandle,
+                       ProcessSessionInformation,
+                       & SessionId,
+                       sizeof SessionId,
+                       NULL);
+       if (!NT_SUCCESS(Status))
        {
-               /* TODO: implement TS */
-               *pSessionId = 0; /* no TS */
-               return TRUE;
+               NtClose (ProcessHandle);
+               goto ProcessIdToSessionId_FAIL;
        }
+       NtClose (ProcessHandle);
+       *pSessionId = SessionId;
+       return TRUE;
+
+ProcessIdToSessionId_FAIL:
+       SetLastErrorByStatus(Status);
+ProcessIdToSessionId_FAIL_EXIT:
        return FALSE;
 }
 
+/*
+ * @implemented
+ */
+DWORD STDCALL
+WTSGetActiveConsoleSessionId (VOID)
+{
+       return ActiveConsoleSessionId;
+}
 
 /* EOF */