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