source: trunk/src/kernel32/nameid.cpp@ 557

Last change on this file since 557 was 550, checked in by sandervl, 26 years ago

PE loader changes

File size: 2.8 KB
Line 
1/* $Id: nameid.cpp,v 1.6 1999-08-18 17:18:00 sandervl Exp $ */
2
3/*
4 * Resource id to name id conversion procedures
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#include <winimage.h>
25#include <winexe.h>
26#include "os2util.h"
27
28/******************************************************************************/
29/******************************************************************************/
30int SYSTEM EXPORT ConvertNameId(ULONG hmod, char *name)
31{
32 HMODULE hmodule;
33 Win32Dll *module;
34
35 dprintf(("Convert %s in mod %X to id\n", name, hmod ));
36
37 hmodule = GetOS2ModuleHandle(hmod);
38 if( hmodule == 0
39 || hmodule == -1
40 || hmodule == OS2iGetModuleHandleA( NULL ) )
41 {
42 return WinExe->convertNameId(name);
43 }
44
45 module = Win32Dll::findModule(hmodule);
46 if(module == 0)
47 {
48 dprintf(("ConvertNameId: module %X not found\n", hmod));
49 return(0);
50 }
51 return module->convertNameId(name);
52}
53//******************************************************************************
54//******************************************************************************
55char *StripPath(char *path)
56{
57 /* @@@PH what does this function do ? Strip the path from a FQFN name ? */
58 char *pszFilename;
59
60 pszFilename = strrchr(path, '\\'); /* find rightmost slash */
61 if (pszFilename != NULL)
62 return (pszFilename++); /* return pointer to next character */
63
64 pszFilename = strrchr(path, '/'); /* find rightmost slash */
65 if (pszFilename != NULL)
66 return (pszFilename++); /* return pointer to next character */
67
68 return (path); /* default return value */
69}
70//******************************************************************************
71//******************************************************************************
72ULONG GetOS2ModuleHandle(ULONG hmod)
73{
74 APIRET rc;
75 char modname[128];
76 HMODULE hmodule;
77
78 if(hmod == 0 || hmod == -1) {
79 return(0);
80 }
81
82 if(Win32QueryModuleName(hmod, modname, sizeof(modname)) == 0) {
83 dprintf(("Can't determine handle of dll %X\n", hmod));
84 return(0);
85 }
86 rc = DosQueryModuleHandle(modname, &hmodule);
87 if(rc) {
88 dprintf(("Can't determine handle of dll %s\n", modname));
89 return(0);
90 }
91 return(hmodule);
92}
93/******************************************************************************/
94/******************************************************************************/
Note: See TracBrowser for help on using the repository browser.