- DBGKD_WAIT_STATE_CHANGE64 is used in KD protocol 5, not number 6 that we use. Proto...
[reactos.git] / reactos / lib / smlib / execpgm.c
index fd29e70..169f5e7 100644 (file)
@@ -1,87 +1,84 @@
-/* $Id: execpgm.c 13731 2005-02-23 23:37:06Z ea $\r
- *\r
- * COPYRIGHT:       See COPYING in the top level directory\r
- * PROJECT:         ReactOS system libraries\r
- * FILE:            lib/smlib/execpgm.c\r
- * PURPOSE:         Call SM API SM_API_EXECPGM\r
- */\r
-#define NTOS_MODE_USER\r
-#include <ntos.h>\r
-#include <sm/helper.h>\r
-#include <string.h>\r
-\r
-#define NDEBUG\r
-#include <debug.h>\r
-\r
-/**********************************************************************\r
- * NAME                                                        EXPORTED\r
- *     SmExecuteProgram/2\r
- *\r
- * DESCRIPTION\r
- *     This function is used to make the SM start an environment\r
- *     subsystem server process.\r
- *\r
- * ARGUMENTS\r
- *     hSmApiPort: port handle returned by SmConnectApiPort;\r
- *     Pgm       : name of the subsystem (to be used by the SM to\r
- *                 lookup the image name from the registry).\r
- *                 Valid names are: DEBUG, WINDOWS, POSIX, OS2,\r
- *                 and VMS.\r
- *     \r
- * RETURN VALUE\r
- *     Success status as handed by the SM reply; otherwise a failure\r
- *     status code.\r
- */\r
-NTSTATUS STDCALL\r
-SmExecuteProgram (IN HANDLE          hSmApiPort,\r
-                 IN PUNICODE_STRING Pgm)\r
-{\r
-  NTSTATUS         Status;\r
-  SM_PORT_MESSAGE  SmReqMsg;\r
-\r
-\r
-  DPRINT("SMLIB: %s(%08lx,'%S') called\n",\r
-       __FUNCTION__, hSmApiPort, Pgm->Buffer);\r
-\r
-  /* Check Pgm's length */\r
-  if (Pgm->Length > (sizeof (Pgm->Buffer[0]) * SM_EXEXPGM_MAX_LENGTH))\r
-  {\r
-    return STATUS_INVALID_PARAMETER;\r
-  }\r
-  /* Marshal Pgm in the LPC message */\r
-  RtlZeroMemory (& SmReqMsg, sizeof SmReqMsg);\r
-  SmReqMsg.Request.ExecPgm.NameLength = Pgm->Length;\r
-  RtlCopyMemory (SmReqMsg.Request.ExecPgm.Name,\r
-                Pgm->Buffer,\r
-                Pgm->Length);\r
-               \r
-  /* SM API to invoke */\r
-  SmReqMsg.SmHeader.ApiIndex = SM_API_EXECUTE_PROGRAMME;\r
-\r
-  /* LPC message */\r
-  SmReqMsg.Header.MessageType = LPC_NEW_MESSAGE;\r
-  SmReqMsg.Header.DataSize    = SM_PORT_DATA_SIZE(SmReqMsg.Request);\r
-  SmReqMsg.Header.MessageSize = SM_PORT_MESSAGE_SIZE;\r
-\r
-  DPRINT("SMLIB: %s:\n"\r
-         "  MessageType = %d\n"\r
-         "  DataSize    = %d\n"\r
-         "  MessageSize = %d\n"\r
-         "  sizeof(LPC_MESSAGE)==%d\n",\r
-         __FUNCTION__,\r
-         SmReqMsg.Header.MessageType,\r
-         SmReqMsg.Header.DataSize,\r
-         SmReqMsg.Header.MessageSize,\r
-         sizeof(LPC_MESSAGE));\r
-\r
-  /* Call SM and wait for a reply */\r
-  Status = NtRequestWaitReplyPort (hSmApiPort, (PLPC_MESSAGE) & SmReqMsg, (PLPC_MESSAGE) & SmReqMsg);\r
-  if (NT_SUCCESS(Status))\r
-  {\r
-    return SmReqMsg.SmHeader.Status;\r
-  }\r
-  DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);\r
-  return Status;\r
-}\r
-\r
-/* EOF */\r
+/* $Id$
+ *
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS system libraries
+ * FILE:            lib/smlib/execpgm.c
+ * PURPOSE:         Call SM API SM_API_EXECPGM
+ */
+#include "precomp.h"
+
+#define NDEBUG
+#include <debug.h>
+
+/**********************************************************************
+ * NAME                                                        EXPORTED
+ *     SmExecuteProgram/2
+ *
+ * DESCRIPTION
+ *     This function is used to make the SM start an environment
+ *     subsystem server process.
+ *
+ * ARGUMENTS
+ *     hSmApiPort: port handle returned by SmConnectApiPort;
+ *     Pgm       : name of the subsystem (to be used by the SM to
+ *                 lookup the image name from the registry).
+ *                 Valid names are: DEBUG, WINDOWS, POSIX, OS2,
+ *                 and VMS.
+ *
+ * RETURN VALUE
+ *     Success status as handed by the SM reply; otherwise a failure
+ *     status code.
+ */
+NTSTATUS WINAPI
+SmExecuteProgram (IN HANDLE          hSmApiPort,
+                 IN PUNICODE_STRING Pgm)
+{
+  NTSTATUS         Status;
+  SM_PORT_MESSAGE  SmReqMsg;
+
+
+  DPRINT("SMLIB: %s(%08lx,'%S') called\n",
+       __FUNCTION__, hSmApiPort, Pgm->Buffer);
+
+  /* Check Pgm's length */
+  if (Pgm->Length > (sizeof (Pgm->Buffer[0]) * SM_EXEXPGM_MAX_LENGTH))
+  {
+    return STATUS_INVALID_PARAMETER;
+  }
+  /* Marshal Pgm in the LPC message */
+  RtlZeroMemory (& SmReqMsg, sizeof SmReqMsg);
+  SmReqMsg.Request.ExecPgm.NameLength = Pgm->Length;
+  RtlCopyMemory (SmReqMsg.Request.ExecPgm.Name,
+                Pgm->Buffer,
+                Pgm->Length);
+
+  /* SM API to invoke */
+  SmReqMsg.SmHeader.ApiIndex = SM_API_EXECUTE_PROGRAMME;
+
+  /* LPC message */
+  SmReqMsg.Header.u2.s2.Type = LPC_NEW_MESSAGE;
+  SmReqMsg.Header.u1.s1.DataLength    = SM_PORT_DATA_SIZE(SmReqMsg.Request);
+  SmReqMsg.Header.u1.s1.TotalLength = SM_PORT_MESSAGE_SIZE;
+
+  DPRINT("SMLIB: %s:\n"
+         "  u2.s2.Type = %d\n"
+         "  u1.s1.DataLength    = %d\n"
+         "  u1.s1.TotalLength = %d\n"
+         "  sizeof(PORT_MESSAGE)==%d\n",
+         __FUNCTION__,
+         SmReqMsg.Header.u2.s2.Type,
+         SmReqMsg.Header.u1.s1.DataLength,
+         SmReqMsg.Header.u1.s1.TotalLength,
+         sizeof(PORT_MESSAGE));
+
+  /* Call SM and wait for a reply */
+  Status = NtRequestWaitReplyPort (hSmApiPort, (PPORT_MESSAGE) & SmReqMsg, (PPORT_MESSAGE) & SmReqMsg);
+  if (NT_SUCCESS(Status))
+  {
+    return SmReqMsg.SmHeader.Status;
+  }
+  DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
+  return Status;
+}
+
+/* EOF */