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