-/* $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 */