Commit in reactos on MAIN
include/structs.h+81.89 -> 1.90
lib/kernel32/misc/ldr.c+87-11.19 -> 1.20
                 /stubs.c+1-151.74 -> 1.75
+96-16
3 modified files
implemented LoadModule()

reactos/include
structs.h 1.89 -> 1.90
diff -u -r1.89 -r1.90
--- structs.h	10 Apr 2004 23:19:42 -0000	1.89
+++ structs.h	3 May 2004 14:34:44 -0000	1.90
@@ -2991,6 +2991,14 @@
 } LANA_ENUM;
 
 
+typedef struct tagLOADPARMS32 {
+  LPSTR lpEnvAddress;
+  LPSTR lpCmdLine;
+  LPSTR lpCmdShow;
+  DWORD dwReserved;
+} LOADPARMS32;
+
+
 typedef struct tagLOCALESIGNATURE {
   DWORD  lsUsb[4];
   DWORD  lsCsbDefault[2];

reactos/lib/kernel32/misc
ldr.c 1.19 -> 1.20
diff -u -r1.19 -r1.20
--- ldr.c	23 Jan 2004 21:16:03 -0000	1.19
+++ ldr.c	3 May 2004 14:34:44 -0000	1.20
@@ -1,4 +1,4 @@
-/* $Id: ldr.c,v 1.19 2004/01/23 21:16:03 ekohl Exp $
+/* $Id: ldr.c,v 1.20 2004/05/03 14:34:44 weiden Exp $
  *
  * COPYRIGHT: See COPYING in the top level directory
  * PROJECT  : ReactOS user mode libraries
@@ -409,4 +409,90 @@
 	return ((HMODULE)BaseAddress);
 }
 
+
+/*
+ * @implemented
+ */
+DWORD
+STDCALL
+LoadModule (
+    LPCSTR  lpModuleName,
+    LPVOID  lpParameterBlock
+    )
+{
+  STARTUPINFOA StartupInfo;
+  PROCESS_INFORMATION ProcessInformation;
+  LOADPARMS32 *LoadParams;
+  char FileName[MAX_PATH];
+  char *CommandLine, *t;
+  BYTE Length;
+  
+  LoadParams = (LOADPARMS32*)lpParameterBlock;
+  if(!lpModuleName || !LoadParams || (((WORD*)LoadParams->lpCmdShow)[0] != 2))
+  {
+    /* windows doesn't check parameters, we do */
+    SetLastError(ERROR_INVALID_PARAMETER);
+    return 0;
+  }
+  
+  if(!SearchPathA(NULL, lpModuleName, ".exe", MAX_PATH, FileName, NULL) &&
+     !SearchPathA(NULL, lpModuleName, NULL, MAX_PATH, FileName, NULL))
+  {
+    return ERROR_FILE_NOT_FOUND;
+  }
+  
+  Length = (BYTE)LoadParams->lpCmdLine[0];
+  if(!(CommandLine = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+                               strlen(lpModuleName) + Length + 2)))
+  {
+    SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+    return 0;
+  }
+  
+  /* Create command line string */
+  strcpy(CommandLine, lpModuleName);
+  t = CommandLine + strlen(CommandLine);
+  *(t++) = ' ';
+  memcpy(t, LoadParams->lpCmdLine + 1, Length);
+  
+  /* Build StartupInfo */
+  RtlZeroMemory(&StartupInfo, sizeof(STARTUPINFOA));
+  StartupInfo.cb = sizeof(STARTUPINFOA);
+  StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
+  StartupInfo.wShowWindow = ((WORD*)LoadParams->lpCmdShow)[1];
+  
+  if(!CreateProcessA(FileName, CommandLine, NULL, NULL, FALSE, 0, LoadParams->lpEnvAddress,
+                     NULL, &StartupInfo, &ProcessInformation))
+  {
+    DWORD Error;
+    
+    HeapFree(GetProcessHeap(), 0, CommandLine);
+    /* return the right value */
+    Error = GetLastError();
+    switch(Error)
+    {
+      case ERROR_BAD_EXE_FORMAT:
+      {
+        return ERROR_BAD_FORMAT;
+      }
+      case ERROR_FILE_NOT_FOUND:
+      case ERROR_PATH_NOT_FOUND:
+      {
+        return Error;
+      }
+    }
+    return 0;
+  }
+  
+  HeapFree(GetProcessHeap(), 0, CommandLine);
+  
+  /* Wait up to 15 seconds for the process to become idle */
+  WaitForInputIdle(ProcessInformation.hProcess, 15000);
+  
+  CloseHandle(ProcessInformation.hThread);
+  CloseHandle(ProcessInformation.hProcess);
+  
+  return 33;
+}
+
 /* EOF */

reactos/lib/kernel32/misc
stubs.c 1.74 -> 1.75
diff -u -r1.74 -r1.75
--- stubs.c	2 May 2004 14:47:05 -0000	1.74
+++ stubs.c	3 May 2004 14:34:44 -0000	1.75
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.74 2004/05/02 14:47:05 weiden Exp $
+/* $Id: stubs.c,v 1.75 2004/05/03 14:34:44 weiden Exp $
  *
  * KERNEL32.DLL stubs (unimplemented functions)
  * Remove from this file, if you implement them.
@@ -324,20 +324,6 @@
 
 #endif
 
-/*
- * @unimplemented
- */
-DWORD
-STDCALL
-LoadModule (
-    LPCSTR  lpModuleName,
-    LPVOID  lpParameterBlock
-    )
-{
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return 0;
-}
-
 
 /*
  * @unimplemented
CVSspam 0.2.8