SM - Sorry, I forgot silence dbg messages!
[reactos.git] / reactos / ntoskrnl / ldr / userldr.c
1 /* $Id:$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/ldr/userldr.c
6 * PURPOSE: Loaders for PE executables
7 *
8 * PROGRAMMERS: Jean Michault
9 * Rex Jolliff (rex@lvcablemodem.com)
10 */
11
12 /* INCLUDES *****************************************************************/
13
14 #include <ntoskrnl.h>
15 #define NDEBUG
16 #include <internal/debug.h>
17
18
19 /* FUNCTIONS *****************************************************************/
20
21 NTSTATUS LdrpMapImage(HANDLE ProcessHandle,
22 HANDLE SectionHandle,
23 PVOID* ReturnedImageBase)
24 /*
25 * FUNCTION: LdrpMapImage maps a user-mode image into an address space
26 * PARAMETERS:
27 * ProcessHandle
28 * Points to the process to map the image into
29 *
30 * SectionHandle
31 * Points to the section to map
32 *
33 * RETURNS: Status
34 */
35 {
36 ULONG ViewSize;
37 PVOID ImageBase;
38 NTSTATUS Status;
39
40 ViewSize = 0;
41 ImageBase = 0;
42
43 Status = ZwMapViewOfSection(SectionHandle,
44 ProcessHandle,
45 (PVOID*)&ImageBase,
46 0,
47 ViewSize,
48 NULL,
49 &ViewSize,
50 0,
51 MEM_COMMIT,
52 PAGE_READWRITE);
53 if (!NT_SUCCESS(Status))
54 {
55 CPRINT("Image map view of section failed (Status %x)", Status);
56 return(Status);
57 }
58
59 *ReturnedImageBase = ImageBase;
60
61 return(STATUS_SUCCESS);
62 }