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