mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
implemented LoadModule()
svn path=/trunk/; revision=9292
This commit is contained in:
parent
03cfc7943a
commit
eae24c4093
3 changed files with 96 additions and 16 deletions
|
@ -2991,6 +2991,14 @@ typedef struct _LANA_ENUM {
|
|||
} LANA_ENUM;
|
||||
|
||||
|
||||
typedef struct tagLOADPARMS32 {
|
||||
LPSTR lpEnvAddress;
|
||||
LPSTR lpCmdLine;
|
||||
LPSTR lpCmdShow;
|
||||
DWORD dwReserved;
|
||||
} LOADPARMS32;
|
||||
|
||||
|
||||
typedef struct tagLOCALESIGNATURE {
|
||||
DWORD lsUsb[4];
|
||||
DWORD lsCsbDefault[2];
|
||||
|
|
|
@ -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 @@ GetModuleHandleW (LPCWSTR lpModuleName)
|
|||
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 */
|
||||
|
|
|
@ -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 @@ IsDBCSLeadByteEx (
|
|||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
DWORD
|
||||
STDCALL
|
||||
LoadModule (
|
||||
LPCSTR lpModuleName,
|
||||
LPVOID lpParameterBlock
|
||||
)
|
||||
{
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
|
|
Loading…
Reference in a new issue