source: trunk/kLdr/kLdrRdrFile.c@ 3188

Last change on this file since 3188 was 2974, checked in by bird, 19 years ago

off_t -> KLDRFOFF.

  • Property svn:keywords set to Id
File size: 34.6 KB
Line 
1/* $Id: kLdrRdrFile.c 2974 2007-02-14 10:12:44Z bird $ */
2/** @file
3 *
4 * kLdr - The Dynamic Loader, file abstraction.
5 *
6 * Copyright (c) 2006 knut st. osmundsen <[email protected]>
7 *
8 *
9 * This file is part of kLdr.
10 *
11 * kLdr is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * kLdr is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with kLdr; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27
28/*******************************************************************************
29* Header Files *
30*******************************************************************************/
31#ifdef __OS2__
32# define INCL_ERRORS
33# define INCL_BASE
34# include <os2.h>
35
36#elif defined(__WIN32__) || defined(__WIN64__) || defined(__WIN__)
37# define WIN32_NO_STATUS
38# include <Windows.h>
39# ifndef __WIN__
40# define __WIN__
41# endif
42# include <ntsecapi.h>
43# include <ntstatus.h>
44
45 /** @todo find a non-conflicting header with NTSTATUS, NTAPI, ++ */
46 typedef LONG NTSTATUS;
47 #define NT_SUCCESS(x) ((x)>=0)
48
49 typedef struct _OBJECT_ATTRIBUTES
50 {
51 ULONG Length;
52 HANDLE RootDirectory;
53 PUNICODE_STRING ObjectName;
54 ULONG Attributes;
55 PVOID SecurityDescriptor;
56 PVOID SecurityQualityOfService;
57 } OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
58
59 typedef enum _SECTION_INHERIT
60 {
61 ViewShare = 1,
62 ViewUnmap = 2
63 } SECTION_INHERIT;
64
65# define NTOSAPI __declspec(dllimport)
66# define NtCurrentProcess() GetCurrentProcess()
67
68# ifndef MEM_DOS_LIM
69# define MEM_DOS_LIM 0x40000000UL
70# endif
71
72 NTOSAPI
73 NTSTATUS
74 NTAPI
75 NtCreateSection(
76 OUT PHANDLE SectionHandle,
77 IN ACCESS_MASK DesiredAccess,
78 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
79 IN PLARGE_INTEGER SectionSize OPTIONAL,
80 IN ULONG Protect,
81 IN ULONG Attributes,
82 IN HANDLE FileHandle OPTIONAL
83 );
84
85 NTOSAPI
86 NTSTATUS
87 NTAPI
88 NtMapViewOfSection(
89 IN HANDLE SectionHandle,
90 IN HANDLE ProcessHandle,
91 IN OUT PVOID *BaseAddress,
92 IN ULONG ZeroBits,
93 IN ULONG CommitSize,
94 IN OUT PLARGE_INTEGER SectionOffset OPTIONAL,
95 IN OUT PSIZE_T ViewSize,
96 IN SECTION_INHERIT InheritDisposition,
97 IN ULONG AllocationType,
98 IN ULONG Protect
99 );
100
101 NTOSAPI
102 NTSTATUS
103 NTAPI
104 NtUnmapViewOfSection(
105 IN HANDLE ProcessHandle,
106 IN PVOID BaseAddress
107 );
108
109 NTOSAPI
110 NTSTATUS
111 NTAPI
112 NtClose(
113 IN HANDLE Handle
114 );
115
116 NTOSAPI
117 NTSTATUS
118 NTAPI
119 ZwProtectVirtualMemory(
120 IN HANDLE ProcessHandle,
121 IN OUT PVOID *BaseAddress,
122 IN OUT PULONG ProtectSize,
123 IN ULONG NewProtect,
124 OUT PULONG OldProtect
125 );
126# define NtProtectVirtualMemory ZwProtectVirtualMemory
127
128 NTOSAPI
129 NTSTATUS
130 NTAPI
131 NtAllocateVirtualMemory(
132 IN HANDLE ProcessHandle,
133 IN OUT PVOID *BaseAddress,
134 IN ULONG ZeroBits,
135 IN OUT PULONG AllocationSize,
136 IN ULONG AllocationType,
137 IN ULONG Protect
138 );
139
140 NTOSAPI
141 NTSTATUS
142 NTAPI
143 NtFreeVirtualMemory(
144 IN HANDLE ProcessHandle,
145 IN OUT PVOID *BaseAddress,
146 IN OUT PULONG FreeSize,
147 IN ULONG FreeType
148 );
149
150#else
151# error "port me"
152#endif