source: trunk/src/kernel32/winmod.cpp@ 99

Last change on this file since 99 was 99, checked in by phaller, 26 years ago

Add: added cvs variable $Id$ to source files.

File size: 2.4 KB
Line 
1/* $Id: winmod.cpp,v 1.3 1999-06-10 19:09:05 phaller Exp $ */
2
3/*
4 *
5 * Project Odin Software License can be found in LICENSE.TXT
6 *
7 */
8/*
9 * Win32 PE Image class
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 <os2.h>
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#define INCL_WINRES
27#include "winres.h"
28#include "winimage.h"
29#include "windll.h"
30
31//******************************************************************************
32//******************************************************************************
33int Win32Image::getWin32ResourceId(int id)
34{
35 int nrres, i;
36
37 if(Win32Table == NULL)
38 return(-1);
39
40 nrres = *Win32Table;
41 for(i=1;i<=nrres;i++) {
42 if(id == (Win32Table[i] >> 16)) {
43 dprintf(("OS/2 id -> Win32 id = %d -> %d\n", id, Win32Table[i] & 0xFFFF));
44 return(Win32Table[i] & 0xFFFF);
45 }
46 }
47 dprintf(("Original resource not found!!\n"));
48 return(-1);
49}
50//******************************************************************************
51//******************************************************************************
52int Win32Image::convertNameId(char *lpszName)
53{
54 NameId *curnid;
55 int nrcvtnames, i;
56 char *upname;
57
58 if(NameTable == NULL)
59 return(0);
60
61 nrcvtnames = *(USHORT *)NameTable;
62 curnid = (NameId *)((int)NameTable + sizeof(USHORT));;
63 for(i=0;i<nrcvtnames;i++) {
64 if(strcmp(lpszName, curnid->name) == 0) {
65 return(curnid->id);
66 }
67 curnid = (NameId *)((char *)curnid + sizeof(NameId) + strlen(curnid->name));
68 }
69 //try upper case search
70 //SvL: Copy it, since string might be located in readonly object
71 upname = (char *)malloc(strlen(lpszName)+1);
72 strcpy(upname, lpszName);
73 UpCase(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//******************************************************************************
Note: See TracBrowser for help on using the repository browser.