source: trunk/src/kernel32/resource.cpp@ 1885

Last change on this file since 1885 was 1885, checked in by sandervl, 26 years ago

Added process api + virtualprotect fix

File size: 11.7 KB
Line 
1/* $Id: resource.cpp,v 1.12 1999-11-30 14:15:54 sandervl Exp $ */
2
3/*
4 * Misc resource procedures
5 *
6 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
7 * Copyright 1998 Patrick Haller
8 *
9 *
10 * Project Odin Software License can be found in LICENSE.TXT
11 *
12 */
13#include <os2win.h>
14#include <unicode.h>
15#include "winres.h"
16#include <winimagebase.h>
17#include <winexebase.h>
18#include <windllbase.h>
19
20//******************************************************************************
21//lpszName = integer id (high word 0), else string (name or "#237")
22//Can lpszType contain a pointer to a default resource type name?
23//******************************************************************************
24HRSRC WIN32API FindResourceA(HINSTANCE hModule, LPCSTR lpszName, LPCSTR lpszType)
25{
26 Win32ImageBase *module;
27
28 module = Win32ImageBase::findModule(hModule);
29 if(module == NULL) {
30 dprintf(("FindResourceA Module %X not found (%x %d)", hModule, lpszName, lpszType));
31 return(NULL);
32 }
33 return module->findResourceA(lpszName, (LPSTR)lpszType);
34}
35//******************************************************************************
36//******************************************************************************
37HRSRC WIN32API FindResourceW(HINSTANCE hModule, LPCWSTR lpszName,
38 LPCWSTR lpszType)
39{
40 Win32ImageBase *module;
41
42 module = Win32ImageBase::findModule(hModule);
43 if(module == NULL) {
44 dprintf(("FindResourceW Module %X not found (%x %d)", hModule, lpszName, lpszType));
45 return(NULL);
46 }
47
48 return module->findResourceW((LPWSTR)lpszName, (LPWSTR)lpszType);
49}
50//******************************************************************************
51//hRes returned by LoadResource
52//******************************************************************************
53PVOID WIN32API LockResource(HGLOBAL hRes)
54{
55 return (PVOID)hRes;
56}
57//******************************************************************************
58//hRes == returned by FindResource(Ex)
59//******************************************************************************
60HGLOBAL WIN32API LoadResource(HINSTANCE hModule, HRSRC hRes)
61{
62 Win32Resource *res = (Win32Resource *)hRes;
63
64 dprintf(("LoadResource %x %X\n", hModule, hRes));
65
66 /* @@@PH */
67 if (HIWORD(res) == NULL) {
68 dprintf(("LoadResource %x: invalid hRes %x", hModule, hRes));
69 return 0;
70 }
71 else return (HGLOBAL)res->lockResource();
72}
73//******************************************************************************
74//hRes == returned by FindResource(Ex)
75//******************************************************************************
76DWORD WIN32API SizeofResource(HINSTANCE hModule, HRSRC hRes)
77{
78 Win32Resource *res = (Win32Resource *)hRes;
79
80 dprintf(("OS2SizeofResource\n"));
81 if(res == NULL)
82 return(0);
83
84 return res->getSize();
85}
86//******************************************************************************
87
88
89
90/**
91 * The EnumResourceNames function searches a module for each
92 * resource of the specified type and passes the name of each
93 * resource it locates to an application-defined callback function
94 *
95 * @returns If the function succeeds, the return value is nonzero.
96 * If the function fails, the return value is zero
97 * @param hModule resource-module handling
98 * @param lpszType pointer to resource type
99 * @param lpEnumFunc pointer to callback function
100 * @param lParam application-defined parameter
101 * @status stub
102 * @author knut st. osmundsen
103 * @remark The EnumResourceNames function continues to enumerate resource
104 * names until the callback function returns FALSE or all resource
105 * names have been enumerated
106 */
107BOOL WIN32API EnumResourceNamesA(HINSTANCE hModule,
108 LPCTSTR lpszType,
109 ENUMRESNAMEPROCA lpEnumFunc,
110 LONG lParam)
111{
112 Win32ImageBase *pModule;
113
114 dprintf(("KERNEL32:EnumResourceNamesA(%08x,%08x,%08x,%08x) not implemented\n",
115 hModule, lpszType, lpEnumFunc, lParam
116 ));
117
118 pModule = Win32ImageBase::findModule(hModule);
119 if (pModule == NULL)
120 {
121 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
122 return FALSE;
123 }
124
125 return pModule->enumResourceNamesA(hModule, lpszType, lpEnumFunc, lParam);
126}
127
128
129/**
130 * The EnumResourceNames function searches a module for each
131 * resource of the specified type and passes the name of each
132 * resource it locates to an application-defined callback function
133 *
134 * @returns If the function succeeds, the return value is nonzero.
135 * If the function fails, the return value is zero
136 * @param hModule resource-module handling
137 * @param lpszType pointer to resource type
138 * @param lpEnumFunc pointer to callback function
139 * @param lParam application-defined parameter
140 * @status stub
141 * @author knut st. osmundsen
142 * @remark The EnumResourceNames function continues to enumerate resource
143 * names until the callback function returns FALSE or all resource
144 * names have been enumerated
145 */
146BOOL WIN32API EnumResourceNamesW(HMODULE hModule,
147 LPCWSTR lpszType,
148 ENUMRESNAMEPROCW lpEnumFunc,
149 LONG lParam)
150{
151 Win32ImageBase *pModule;
152
153 dprintf(("KERNEL32:EnumResourceNamesW(%08x,%08x,%08x,%08x)\n",
154 hModule, lpszType, lpEnumFunc, lParam));
155
156 pModule = Win32ImageBase::findModule(hModule);
157 if (pModule == NULL)
158 {
159 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
160 return FALSE;
161 }
162
163 return pModule->enumResourceNamesW(hModule, lpszType, lpEnumFunc, lParam);
164}
165
166/*****************************************************************************
167 * Name : BOOL WIN32API EnumResourceLanguagesA
168 * Purpose : The EnumResourceLanguagesA function searches a module for each
169 * resource of the specified type and name and passes the language
170 * of each resource it locates to a defined callback function
171 * Parameters: HMODULE hModule resource-module handle
172 * LPCTSTR lpType pointer to resource type
173 * LPCTSTR lpName, pointer to resource name
174 * ENUMRESLANGPROC lpEnumFunc pointer to callback function
175 * LONG lParam application-defined parameter
176 * Variables :
177 * Result : If the function succeeds, the return value is nonzero.
178 * If the function fails, the return value is zero.
179 * Remark : The EnumResourceLanguages function continues to enumerate
180 * resource languages until the callback function returns FALSE
181 * or all resource languages have been enumerated.
182 * Status : UNTESTED STUB
183 *
184 * Author : Markus Montkowski [Tha, 1998/05/21 17:46]
185 *****************************************************************************/
186
187BOOL WIN32API EnumResourceLanguagesA(HMODULE hModule, LPCSTR lpType,
188 LPCSTR lpName,
189 ENUMRESLANGPROCA lpEnumFunc,
190 LONG lParam)
191{
192
193 dprintf(("KERNEL32:EnumResourceLanguagesA(%08x,%08x,%08x,%08x,%08x)\n not implemented",
194 hModule, lpType, lpName, lpEnumFunc, lParam
195 ));
196
197 return (FALSE);
198}
199
200/*****************************************************************************
201 * Name : BOOL WIN32API EnumResourceLanguagesW
202 * Purpose : The EnumResourceLanguagesW function searches a module for each
203 * resource of the specified type and name and passes the language
204 * of each resource it locates to a defined callback function
205 * Parameters: HMODULE hModule resource-module handle
206 * LPCTSTR lpType pointer to resource type
207 * LPCTSTR lpName, pointer to resource name
208 * ENUMRESLANGPROC lpEnumFunc pointer to callback function
209 * LONG lParam application-defined parameter
210 * Variables :
211 * Result : If the function succeeds, the return value is nonzero.
212 * If the function fails, the return value is zero.
213 * Remark : The EnumResourceLanguages function continues to enumerate
214 * resource languages until the callback function returns FALSE
215 * or all resource languages have been enumerated.
216 * Status : UNTESTED STUB
217 *
218 * Author : Markus Montkowski [Tha, 1998/05/21 17:46]
219 *****************************************************************************/
220
221BOOL WIN32API EnumResourceLanguagesW(HMODULE hModule, LPCWSTR lpType,
222 LPCWSTR lpName,
223 ENUMRESLANGPROCW lpEnumFunc,
224 LONG lParam)
225{
226
227 dprintf(("KERNEL32:EnumResourceLanguagesW(%08x,%08x,%08x,%08x,%08x)\n not implemented",
228 hModule, lpType, lpName, lpEnumFunc, lParam
229 ));
230
231 return (FALSE);
232}
233
234
235
236/*****************************************************************************
237 * Name : BOOL WIN32API EnumResourceTypesA
238 * Purpose : The EnumResourceTypesA function searches a module for resources
239 * and passes each resource type it finds to an application-defined
240 * callback function
241 * Parameters: HMODULE hModule, resource-module handle
242 * ENUMRESTYPEPROC lpEnumFunc pointer to callback function
243 * LONG lParam application-defined parameter
244 * Variables :
245 * Result : If the function succeeds, the return value is nonzero.
246 * If the function fails, the return value is zero
247 * Remark :
248 * Status : UNTESTED STUB
249 *
250 * Author : Markus Montkowski [Tha, 1998/05/21 17:46]
251 *****************************************************************************/
252
253BOOL WIN32API EnumResourceTypesA(HMODULE hModule,
254 ENUMRESTYPEPROCA lpEnumFunc, LONG lParam)
255{
256 Win32ImageBase *pModule;
257
258 dprintf(("KERNEL32:EnumResourceTypesA(%08x,%08x,%08x)\n",
259 hModule, lpEnumFunc, lParam));
260
261 pModule = Win32ImageBase::findModule(hModule);
262 if (pModule == NULL)
263 {
264 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
265 return FALSE;
266 }
267
268 return pModule->enumResourceTypesA(hModule, lpEnumFunc, lParam);
269}
270
271/*****************************************************************************
272 * Name : BOOL WIN32API EnumResourceTypesW
273 * Purpose : The EnumResourceTypesW function searches a module for resources
274 * and passes each resource type it finds to an application-defined
275 * callback function
276 * Parameters: HMODULE hModule, resource-module handle
277 * ENUMRESTYPEPROC lpEnumFunc pointer to callback function
278 * LONG lParam application-defined parameter
279 * Variables :
280 * Result : If the function succeeds, the return value is nonzero.
281 * If the function fails, the return value is zero
282 * Remark :
283 * Status : UNTESTED STUB
284 *
285 * Author : Markus Montkowski [Tha, 1998/05/21 17:46]
286 *****************************************************************************/
287
288BOOL WIN32API EnumResourceTypesW(HMODULE hModule,
289 ENUMRESTYPEPROCW lpEnumFunc, LONG lParam)
290{
291 Win32ImageBase *pModule;
292
293 dprintf(("KERNEL32:EnumResourceTypesW(%08x,%08x,%08x)\n",
294 hModule, lpEnumFunc, lParam));
295
296 pModule = Win32ImageBase::findModule(hModule);
297 if (pModule == NULL)
298 {
299 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
300 return FALSE;
301 }
302
303 return pModule->enumResourceTypesW(hModule, lpEnumFunc, lParam);
304}
Note: See TracBrowser for help on using the repository browser.