| 1 | /* $Id: nameid.cpp,v 1.5 1999-06-19 10:54:42 sandervl Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | *
|
|---|
| 5 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 6 | *
|
|---|
| 7 | */
|
|---|
| 8 | /*
|
|---|
| 9 | * Resource id to name id conversion procedures
|
|---|
| 10 | *
|
|---|
| 11 | * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
|
|---|
| 12 | *
|
|---|
| 13 | */
|
|---|
| 14 | #define INCL_BASE
|
|---|
| 15 | #define INCL_WIN
|
|---|
| 16 | #define INCL_WINERRORS
|
|---|
| 17 | #define INCL_DOSFILEMGR
|
|---|
| 18 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
|---|
| 19 | #include <stdio.h>
|
|---|
| 20 | #include <stdlib.h>
|
|---|
| 21 | #include <string.h>
|
|---|
| 22 | #include <win32type.h>
|
|---|
| 23 | #include <misc.h>
|
|---|
| 24 | #include "nameid.h"
|
|---|
| 25 | #include "win32util.h"
|
|---|
| 26 | #include <winimage.h>
|
|---|
| 27 | #include <winexe.h>
|
|---|
| 28 | #include "os2util.h"
|
|---|
| 29 |
|
|---|
| 30 | void UpCase(char *mixedcase);
|
|---|
| 31 |
|
|---|
| 32 | /******************************************************************************/
|
|---|
| 33 | /******************************************************************************/
|
|---|
| 34 | int SYSTEM EXPORT ConvertNameId(ULONG hmod, char *name)
|
|---|
| 35 | {
|
|---|
| 36 | HMODULE hmodule;
|
|---|
| 37 | Win32Dll *module;
|
|---|
| 38 |
|
|---|
| 39 | dprintf(("Convert %s in mod %X to id\n", name, hmod ));
|
|---|
| 40 |
|
|---|
| 41 | hmodule = GetOS2ModuleHandle(hmod);
|
|---|
| 42 | if( hmodule == 0
|
|---|
| 43 | || hmodule == -1
|
|---|
| 44 | || hmodule == OS2iGetModuleHandleA( NULL ) )
|
|---|
| 45 | {
|
|---|
| 46 | return WinExe->convertNameId(name);
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | module = Win32Dll::findModule(hmodule);
|
|---|
| 50 | if(module == 0)
|
|---|
| 51 | {
|
|---|
| 52 | dprintf(("ConvertNameId: module %X not found\n", hmod));
|
|---|
| 53 | return(0);
|
|---|
| 54 | }
|
|---|
| 55 | return module->convertNameId(name);
|
|---|
| 56 | }
|
|---|
| 57 | //******************************************************************************
|
|---|
| 58 | //******************************************************************************
|
|---|
| 59 | void SYSTEM EXPORT UpCase(char *mixedcase)
|
|---|
| 60 | {
|
|---|
| 61 | int i;
|
|---|
| 62 |
|
|---|
| 63 | for(i=0;i<strlen(mixedcase);i++) {
|
|---|
| 64 | if(mixedcase[i] >= 'a' && mixedcase[i] <= 'z') {
|
|---|
| 65 | mixedcase[i] += 'A' - 'a';
|
|---|
| 66 | }
|
|---|
| 67 | }
|
|---|
| 68 | }
|
|---|
| 69 | /******************************************************************************/
|
|---|
| 70 | /******************************************************************************/
|
|---|
| 71 | ULONG GetOS2ModuleHandle(ULONG hmod)
|
|---|
| 72 | {
|
|---|
| 73 | APIRET rc;
|
|---|
| 74 | char modname[128];
|
|---|
| 75 | HMODULE hmodule;
|
|---|
| 76 |
|
|---|
| 77 | if(hmod == 0 || hmod == -1) {
|
|---|
| 78 | return(0);
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | if(Win32QueryModuleName(hmod, modname, sizeof(modname)) == 0) {
|
|---|
| 82 | dprintf(("Can't determine handle of dll %X\n", hmod));
|
|---|
| 83 | return(0);
|
|---|
| 84 | }
|
|---|
| 85 | rc = DosQueryModuleHandle(modname, &hmodule);
|
|---|
| 86 | if(rc) {
|
|---|
| 87 | dprintf(("Can't determine handle of dll %s\n", modname));
|
|---|
| 88 | return(0);
|
|---|
| 89 | }
|
|---|
| 90 | return(hmodule);
|
|---|
| 91 | }
|
|---|
| 92 | /******************************************************************************/
|
|---|
| 93 | /******************************************************************************/
|
|---|