1 | /* $Id: resource.cpp,v 1.14 2000-01-05 19:39:56 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 | //******************************************************************************
|
---|
24 | HRSRC 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 | //******************************************************************************
|
---|
37 | HRSRC 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 | * Name : HRSRC WIN32API FindResourceExA
|
---|
52 | * Purpose : The FindResourceExA function determines the location of the
|
---|
53 | * resource with the specified type, name, and language in the
|
---|
54 | * specified module.
|
---|
55 | * Parameters: HMODULE hModule resource-module handle
|
---|
56 | * LPCSTR lpType pointer to resource type
|
---|
57 | * LPCSTR lpName pointer to resource name
|
---|
58 | * WORD wLanguage resource language
|
---|
59 | * Variables :
|
---|
60 | * Result : If the function succeeds, the return value is a handle to the
|
---|
61 | * specified resource's info block. To obtain a handle to the
|
---|
62 | * resource, pass this handle to the LoadResource function.
|
---|
63 | * If the function fails, the return value is NULL
|
---|
64 | * Remark :
|
---|
65 | * Status : UNTESTED STUB
|
---|
66 | *
|
---|
67 | * Author : SvL
|
---|
68 | *****************************************************************************/
|
---|
69 |
|
---|
70 | HRSRC WIN32API FindResourceExA( HMODULE hModule, LPCSTR lpType,
|
---|
71 | LPCSTR lpName, WORD wLanguage)
|
---|
72 | {
|
---|
73 | Win32ImageBase *module;
|
---|
74 |
|
---|
75 | module = Win32ImageBase::findModule(hModule);
|
---|
76 | if(module == NULL) {
|
---|
77 | dprintf(("FindResourceExA Module %X not found (%x %d)", hModule, lpName, lpType));
|
---|
78 | return(NULL);
|
---|
79 | }
|
---|
80 |
|
---|
81 | return module->findResourceA((LPSTR)lpName, (LPSTR)lpType, wLanguage);
|
---|
82 | }
|
---|
83 |
|
---|
84 | /*****************************************************************************
|
---|
85 | * Name : HRSRC WIN32API FindResourceExA
|
---|
86 | * Purpose : The FindResourceExA function determines the location of the
|
---|
87 | * resource with the specified type, name, and language in the
|
---|
88 | * specified module.
|
---|
89 | * Parameters: HMODULE hModule resource-module handle
|
---|
90 | * LPCSTR lpType pointer to resource type
|
---|
91 | * LPCSTR lpName pointer to resource name
|
---|
92 | * WORD wLanguage resource language
|
---|
93 | * Variables :
|
---|
94 | * Result : If the function succeeds, the return value is a handle to the
|
---|
95 | * specified resource's info block. To obtain a handle to the
|
---|
96 | * resource, pass this handle to the LoadResource function.
|
---|
97 | * If the function fails, the return value is NULL
|
---|
98 | * Remark :
|
---|
99 | * Status : UNTESTED STUB
|
---|
100 | *
|
---|
101 | * Author : SvL
|
---|
102 | *****************************************************************************/
|
---|
103 |
|
---|
104 | HRSRC WIN32API FindResourceExW(HMODULE hModule,
|
---|
105 | LPCWSTR lpType,
|
---|
106 | LPCWSTR lpName,
|
---|
107 | WORD wLanguage)
|
---|
108 | {
|
---|
109 | Win32ImageBase *module;
|
---|
110 |
|
---|
111 | module = Win32ImageBase::findModule(hModule);
|
---|
112 | if(module == NULL) {
|
---|
113 | dprintf(("FindResourceExW Module %X not found (%x %d)", hModule, lpName, lpType));
|
---|
114 | return(NULL);
|
---|
115 | }
|
---|
116 |
|
---|
117 | return module->findResourceW((LPWSTR)lpName, (LPWSTR)lpType, wLanguage);
|
---|
118 | }
|
---|
119 | //******************************************************************************
|
---|
120 | //hRes returned by LoadResource
|
---|
121 | //******************************************************************************
|
---|
122 | PVOID WIN32API LockResource(HGLOBAL hRes)
|
---|
123 | {
|
---|
124 | return (PVOID)hRes;
|
---|
125 | }
|
---|
126 | //******************************************************************************
|
---|
127 | //hRes == returned by FindResource(Ex)
|
---|
128 | //******************************************************************************
|
---|
129 | HGLOBAL WIN32API LoadResource(HINSTANCE hModule, HRSRC hRes)
|
---|
130 | {
|
---|
131 | Win32Resource *res = (Win32Resource *)hRes;
|
---|
132 |
|
---|
133 | dprintf(("LoadResource %x %X\n", hModule, hRes));
|
---|
134 |
|
---|
135 | /* @@@PH */
|
---|
136 | if (HIWORD(res) == NULL) {
|
---|
137 | dprintf(("LoadResource %x: invalid hRes %x", hModule, hRes));
|
---|
138 | return 0;
|
---|
139 | }
|
---|
140 | else return (HGLOBAL)res->lockResource();
|
---|
141 | }
|
---|
142 | //******************************************************************************
|
---|
143 | //hRes == returned by FindResource(Ex)
|
---|
144 | //******************************************************************************
|
---|
145 | DWORD WIN32API SizeofResource(HINSTANCE hModule, HRSRC hRes)
|
---|
146 | {
|
---|
147 | Win32Resource *res = (Win32Resource *)hRes;
|
---|
148 |
|
---|
149 | dprintf(("OS2SizeofResource\n"));
|
---|
150 | if(res == NULL)
|
---|
151 | return(0);
|
---|
152 |
|
---|
153 | return res->getSize();
|
---|
154 | }
|
---|
155 | //******************************************************************************
|
---|
156 |
|
---|
157 |
|
---|
158 |
|
---|
159 | /**
|
---|
160 | * The EnumResourceNames function searches a module for each
|
---|
161 | * resource of the specified type and passes the name of each
|
---|
162 | * resource it locates to an application-defined callback function
|
---|
163 | *
|
---|
164 | * @returns If the function succeeds, the return value is nonzero.
|
---|
165 | * If the function fails, the return value is zero
|
---|
166 | * @param hModule resource-module handling
|
---|
167 | * @param lpszType pointer to resource type
|
---|
168 | * @param lpEnumFunc pointer to callback function
|
---|
169 | * @param lParam application-defined parameter
|
---|
170 | * @status stub
|
---|
171 | * @author knut st. osmundsen
|
---|
172 | * @remark The EnumResourceNames function continues to enumerate resource
|
---|
173 | * names until the callback function returns FALSE or all resource
|
---|
174 | * names have been enumerated
|
---|
175 | */
|
---|
176 | BOOL WIN32API EnumResourceNamesA(HINSTANCE hModule,
|
---|
177 | LPCTSTR lpszType,
|
---|
178 | ENUMRESNAMEPROCA lpEnumFunc,
|
---|
179 | LONG lParam)
|
---|
180 | {
|
---|
181 | Win32ImageBase *pModule;
|
---|
182 |
|
---|
183 | dprintf(("KERNEL32:EnumResourceNamesA(%08x,%08x,%08x,%08x)",
|
---|
184 | hModule, lpszType, lpEnumFunc, lParam
|
---|
185 | ));
|
---|
186 |
|
---|
187 | pModule = Win32ImageBase::findModule(hModule);
|
---|
188 | if (pModule == NULL)
|
---|
189 | {
|
---|
190 | SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
|
---|
191 | return FALSE;
|
---|
192 | }
|
---|
193 |
|
---|
194 | return pModule->enumResourceNamesA(hModule, lpszType, lpEnumFunc, lParam);
|
---|
195 | }
|
---|
196 |
|
---|
197 |
|
---|
198 | /**
|
---|
199 | * The EnumResourceNames function searches a module for each
|
---|
200 | * resource of the specified type and passes the name of each
|
---|
201 | * resource it locates to an application-defined callback function
|
---|
202 | *
|
---|
203 | * @returns If the function succeeds, the return value is nonzero.
|
---|
204 | * If the function fails, the return value is zero
|
---|
205 | * @param hModule resource-module handling
|
---|
206 | * @param lpszType pointer to resource type
|
---|
207 | * @param lpEnumFunc pointer to callback function
|
---|
208 | * @param lParam application-defined parameter
|
---|
209 | * @status stub
|
---|
210 | * @author knut st. osmundsen
|
---|
211 | * @remark The EnumResourceNames function continues to enumerate resource
|
---|
212 | * names until the callback function returns FALSE or all resource
|
---|
213 | * names have been enumerated
|
---|
214 | */
|
---|
215 | BOOL WIN32API EnumResourceNamesW(HMODULE hModule,
|
---|
216 | LPCWSTR lpszType,
|
---|
217 | ENUMRESNAMEPROCW lpEnumFunc,
|
---|
218 | LONG lParam)
|
---|
219 | {
|
---|
220 | Win32ImageBase *pModule;
|
---|
221 |
|
---|
222 | dprintf(("KERNEL32:EnumResourceNamesW(%08x,%08x,%08x,%08x)\n",
|
---|
223 | hModule, lpszType, lpEnumFunc, lParam));
|
---|
224 |
|
---|
225 | pModule = Win32ImageBase::findModule(hModule);
|
---|
226 | if (pModule == NULL)
|
---|
227 | {
|
---|
228 | SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
|
---|
229 | return FALSE;
|
---|
230 | }
|
---|
231 |
|
---|
232 | return pModule->enumResourceNamesW(hModule, lpszType, lpEnumFunc, lParam);
|
---|
233 | }
|
---|
234 |
|
---|
235 | /*****************************************************************************
|
---|
236 | * Name : BOOL WIN32API EnumResourceLanguagesA
|
---|
237 | * Purpose : The EnumResourceLanguagesA function searches a module for each
|
---|
238 | * resource of the specified type and name and passes the language
|
---|
239 | * of each resource it locates to a defined callback function
|
---|
240 | * Parameters: HMODULE hModule resource-module handle
|
---|
241 | * LPCTSTR lpType pointer to resource type
|
---|
242 | * LPCTSTR lpName, pointer to resource name
|
---|
243 | * ENUMRESLANGPROC lpEnumFunc pointer to callback function
|
---|
244 | * LONG lParam application-defined parameter
|
---|
245 | * Variables :
|
---|
246 | * Result : If the function succeeds, the return value is nonzero.
|
---|
247 | * If the function fails, the return value is zero.
|
---|
248 | * Remark : The EnumResourceLanguages function continues to enumerate
|
---|
249 | * resource languages until the callback function returns FALSE
|
---|
250 | * or all resource languages have been enumerated.
|
---|
251 | * Status : UNTESTED STUB
|
---|
252 | *
|
---|
253 | * Author : Markus Montkowski [Tha, 1998/05/21 17:46]
|
---|
254 | *****************************************************************************/
|
---|
255 |
|
---|
256 | BOOL WIN32API EnumResourceLanguagesA(HMODULE hModule, LPCSTR lpType,
|
---|
257 | LPCSTR lpName,
|
---|
258 | ENUMRESLANGPROCA lpEnumFunc,
|
---|
259 | LONG lParam)
|
---|
260 | {
|
---|
261 |
|
---|
262 | dprintf(("KERNEL32:EnumResourceLanguagesA(%08x,%08x,%08x,%08x,%08x)\n not implemented",
|
---|
263 | hModule, lpType, lpName, lpEnumFunc, lParam
|
---|
264 | ));
|
---|
265 |
|
---|
266 | return (FALSE);
|
---|
267 | }
|
---|
268 |
|
---|
269 | /*****************************************************************************
|
---|
270 | * Name : BOOL WIN32API EnumResourceLanguagesW
|
---|
271 | * Purpose : The EnumResourceLanguagesW function searches a module for each
|
---|
272 | * resource of the specified type and name and passes the language
|
---|
273 | * of each resource it locates to a defined callback function
|
---|
274 | * Parameters: HMODULE hModule resource-module handle
|
---|
275 | * LPCTSTR lpType pointer to resource type
|
---|
276 | * LPCTSTR lpName, pointer to resource name
|
---|
277 | * ENUMRESLANGPROC 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 : The EnumResourceLanguages function continues to enumerate
|
---|
283 | * resource languages until the callback function returns FALSE
|
---|
284 | * or all resource languages have been enumerated.
|
---|
285 | * Status : UNTESTED STUB
|
---|
286 | *
|
---|
287 | * Author : Markus Montkowski [Tha, 1998/05/21 17:46]
|
---|
288 | *****************************************************************************/
|
---|
289 |
|
---|
290 | BOOL WIN32API EnumResourceLanguagesW(HMODULE hModule, LPCWSTR lpType,
|
---|
291 | LPCWSTR lpName,
|
---|
292 | ENUMRESLANGPROCW lpEnumFunc,
|
---|
293 | LONG lParam)
|
---|
294 | {
|
---|
295 |
|
---|
296 | dprintf(("KERNEL32:EnumResourceLanguagesW(%08x,%08x,%08x,%08x,%08x)\n not implemented",
|
---|
297 | hModule, lpType, lpName, lpEnumFunc, lParam
|
---|
298 | ));
|
---|
299 |
|
---|
300 | return (FALSE);
|
---|
301 | }
|
---|
302 |
|
---|
303 |
|
---|
304 |
|
---|
305 | /*****************************************************************************
|
---|
306 | * Name : BOOL WIN32API EnumResourceTypesA
|
---|
307 | * Purpose : The EnumResourceTypesA function searches a module for resources
|
---|
308 | * and passes each resource type it finds to an application-defined
|
---|
309 | * callback function
|
---|
310 | * Parameters: HMODULE hModule, resource-module handle
|
---|
311 | * ENUMRESTYPEPROC lpEnumFunc pointer to callback function
|
---|
312 | * LONG lParam application-defined parameter
|
---|
313 | * Variables :
|
---|
314 | * Result : If the function succeeds, the return value is nonzero.
|
---|
315 | * If the function fails, the return value is zero
|
---|
316 | * Remark :
|
---|
317 | * Status : UNTESTED STUB
|
---|
318 | *
|
---|
319 | * Author : Markus Montkowski [Tha, 1998/05/21 17:46]
|
---|
320 | *****************************************************************************/
|
---|
321 |
|
---|
322 | BOOL WIN32API EnumResourceTypesA(HMODULE hModule,
|
---|
323 | ENUMRESTYPEPROCA lpEnumFunc, LONG lParam)
|
---|
324 | {
|
---|
325 | Win32ImageBase *pModule;
|
---|
326 |
|
---|
327 | dprintf(("KERNEL32:EnumResourceTypesA(%08x,%08x,%08x)\n",
|
---|
328 | hModule, lpEnumFunc, lParam));
|
---|
329 |
|
---|
330 | pModule = Win32ImageBase::findModule(hModule);
|
---|
331 | if (pModule == NULL)
|
---|
332 | {
|
---|
333 | SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
|
---|
334 | return FALSE;
|
---|
335 | }
|
---|
336 |
|
---|
337 | return pModule->enumResourceTypesA(hModule, lpEnumFunc, lParam);
|
---|
338 | }
|
---|
339 |
|
---|
340 | /*****************************************************************************
|
---|
341 | * Name : BOOL WIN32API EnumResourceTypesW
|
---|
342 | * Purpose : The EnumResourceTypesW function searches a module for resources
|
---|
343 | * and passes each resource type it finds to an application-defined
|
---|
344 | * callback function
|
---|
345 | * Parameters: HMODULE hModule, resource-module handle
|
---|
346 | * ENUMRESTYPEPROC lpEnumFunc pointer to callback function
|
---|
347 | * LONG lParam application-defined parameter
|
---|
348 | * Variables :
|
---|
349 | * Result : If the function succeeds, the return value is nonzero.
|
---|
350 | * If the function fails, the return value is zero
|
---|
351 | * Remark :
|
---|
352 | * Status : UNTESTED STUB
|
---|
353 | *
|
---|
354 | * Author : Markus Montkowski [Tha, 1998/05/21 17:46]
|
---|
355 | *****************************************************************************/
|
---|
356 |
|
---|
357 | BOOL WIN32API EnumResourceTypesW(HMODULE hModule,
|
---|
358 | ENUMRESTYPEPROCW lpEnumFunc, LONG lParam)
|
---|
359 | {
|
---|
360 | Win32ImageBase *pModule;
|
---|
361 |
|
---|
362 | dprintf(("KERNEL32:EnumResourceTypesW(%08x,%08x,%08x)\n",
|
---|
363 | hModule, lpEnumFunc, lParam));
|
---|
364 |
|
---|
365 | pModule = Win32ImageBase::findModule(hModule);
|
---|
366 | if (pModule == NULL)
|
---|
367 | {
|
---|
368 | SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
|
---|
369 | return FALSE;
|
---|
370 | }
|
---|
371 |
|
---|
372 | return pModule->enumResourceTypesW(hModule, lpEnumFunc, lParam);
|
---|
373 | }
|
---|