1 | /* $Id: winmod.cpp,v 1.6 1999-08-18 17:18:01 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Win32 PE Image class
|
---|
5 | *
|
---|
6 | * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
10 | *
|
---|
11 | */
|
---|
12 | #define INCL_BASE
|
---|
13 | #define INCL_WIN
|
---|
14 | #define INCL_WINERRORS
|
---|
15 | #define INCL_DOSFILEMGR
|
---|
16 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
---|
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 | #define INCL_WINRES
|
---|
25 | #include "winres.h"
|
---|
26 | #include "winimage.h"
|
---|
27 | #include "windll.h"
|
---|
28 |
|
---|
29 | //******************************************************************************
|
---|
30 | //******************************************************************************
|
---|
31 | int Win32Image::getWin32ResourceId(int id)
|
---|
32 | {
|
---|
33 | int nrres, i;
|
---|
34 |
|
---|
35 | if(Win32Table == NULL)
|
---|
36 | return(-1);
|
---|
37 |
|
---|
38 | nrres = *Win32Table;
|
---|
39 | for(i=1;i<=nrres;i++) {
|
---|
40 | if(id == (Win32Table[i] >> 16)) {
|
---|
41 | dprintf(("OS/2 id -> Win32 id = %d -> %d\n", id, Win32Table[i] & 0xFFFF));
|
---|
42 | return(Win32Table[i] & 0xFFFF);
|
---|
43 | }
|
---|
44 | }
|
---|
45 | dprintf(("Original resource not found!!\n"));
|
---|
46 | return(-1);
|
---|
47 | }
|
---|
48 | //******************************************************************************
|
---|
49 | //******************************************************************************
|
---|
50 | int Win32Image::convertNameId(char *lpszName)
|
---|
51 | {
|
---|
52 | NameId *curnid;
|
---|
53 | int nrcvtnames, i;
|
---|
54 | char *upname;
|
---|
55 |
|
---|
56 | if(NameTable == NULL)
|
---|
57 | return(0);
|
---|
58 |
|
---|
59 | nrcvtnames = *(USHORT *)NameTable;
|
---|
60 | curnid = (NameId *)((int)NameTable + sizeof(USHORT));;
|
---|
61 | for(i=0;i<nrcvtnames;i++) {
|
---|
62 | if(strcmp(lpszName, curnid->name) == 0) {
|
---|
63 | return(curnid->id);
|
---|
64 | }
|
---|
65 | curnid = (NameId *)((char *)curnid + sizeof(NameId) + strlen(curnid->name));
|
---|
66 | }
|
---|
67 |
|
---|
68 | //try upper case search
|
---|
69 | //SvL: Copy it, since string might be located in readonly object
|
---|
70 |
|
---|
71 | upname = (char *)malloc(strlen(lpszName)+1); //CB: Trap with MFC Toolbar/UpDown samples
|
---|
72 | strcpy(upname, lpszName);
|
---|
73 | strupr(upname);
|
---|
74 | dprintf(("Convert %s to id\n", upname));
|
---|
75 | curnid = (NameId *)((int)NameTable + sizeof(USHORT));;
|
---|
76 | for(i=0;i<nrcvtnames;i++) {
|
---|
77 | if(strcmp(upname, curnid->name) == 0) {
|
---|
78 | free(upname);
|
---|
79 | return(curnid->id);
|
---|
80 | }
|
---|
81 | curnid = (NameId *)((char *)curnid + sizeof(NameId) + strlen(curnid->name));
|
---|
82 | }
|
---|
83 | dprintf(("Converted name NOT found!\n"));
|
---|
84 | free(upname);
|
---|
85 |
|
---|
86 | return(0);
|
---|
87 | }
|
---|
88 | //******************************************************************************
|
---|
89 | //******************************************************************************
|
---|