VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/ldr/ldrNative.cpp@ 5999

最後變更 在這個檔案從5999是 5999,由 vboxsync 提交於 17 年 前

The Giant CDDL Dual-License Header Change.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 4.0 KB
 
1/* $Id: ldrNative.cpp 5999 2007-12-07 15:05:06Z vboxsync $ */
2/** @file
3 * innotek Portable Runtime - Binary Image Loader, Native interface.
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.alldomusa.eu.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*******************************************************************************
29* Header Files *
30*******************************************************************************/
31#define LOG_GROUP RTLOGGROUP_LDR
32#include <iprt/ldr.h>
33#include <iprt/alloc.h>
34#include <iprt/assert.h>
35#include <iprt/log.h>
36#include <iprt/string.h>
37#include <iprt/err.h>
38#include "internal/ldr.h"
39
40
41/** @copydoc RTLDROPS::pfnEnumSymbols */
42static DECLCALLBACK(int) rtldrNativeEnumSymbols(PRTLDRMODINTERNAL pMod, unsigned fFlags, const void *pvBits, RTUINTPTR BaseAddress,
43 PFNRTLDRENUMSYMS pfnCallback, void *pvUser)
44{
45 return VERR_NOT_SUPPORTED;
46}
47
48
49/** @copydoc RTLDROPS::pfnDone */
50static DECLCALLBACK(int) rtldrNativeDone(PRTLDRMODINTERNAL pMod)
51{
52 return VINF_SUCCESS;
53}
54
55
56/**
57 * Operations for a native module.
58 */
59static const RTLDROPS s_rtldrNativeOps =
60{
61 "native",
62 rtldrNativeClose,
63 rtldrNativeGetSymbol,
64 rtldrNativeDone,
65 rtldrNativeEnumSymbols,
66 /* ext: */
67 NULL,
68 NULL,
69 NULL,
70 NULL,
71 42
72};
73
74
75
76/**
77 * Loads a dynamic load library (/shared object) image file using native
78 * OS facilities.
79 *
80 * The filename will be appended the default DLL/SO extension of
81 * the platform if it have been omitted. This means that it's not
82 * possible to load DLLs/SOs with no extension using this interface,
83 * but that's not a bad tradeoff.
84 *
85 * If no path is specified in the filename, the OS will usually search it's library
86 * path to find the image file.
87 *
88 * @returns iprt status code.
89 * @param pszFilename Image filename.
90 * @param phLdrMod Where to store the handle to the loaded module.
91 */
92RTDECL(int) RTLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod)
93{
94 LogFlow(("RTLdrLoad: pszFilename=%p:{%s} phLdrMod=%p\n", pszFilename, pszFilename, phLdrMod));
95
96 /*
97 * validate input.
98 */
99 AssertMsgReturn(VALID_PTR(pszFilename), ("pszFilename=%p\n", pszFilename), VERR_INVALID_PARAMETER);
100 AssertMsgReturn(VALID_PTR(phLdrMod), ("phLdrMod=%p\n", phLdrMod), VERR_INVALID_PARAMETER);
101
102 /*
103 * Allocate and initialize module structure.
104 */
105 int rc = VERR_NO_MEMORY;
106 PRTLDRMODNATIVE pMod = (PRTLDRMODNATIVE)RTMemAlloc(sizeof(*pMod));
107 if (pMod)
108 {
109 pMod->Core.u32Magic = RTLDRMOD_MAGIC;
110 pMod->Core.eState = LDR_STATE_LOADED;
111 pMod->Core.pOps = &s_rtldrNativeOps;
112 pMod->hNative = ~(uintptr_t)0;
113
114 /*
115 * Attempt to open the module.
116 */
117 rc = rtldrNativeLoad(pszFilename, &pMod->hNative);
118 if (RT_SUCCESS(rc))
119 {
120 *phLdrMod = &pMod->Core;
121 LogFlow(("RTLdrLoad: returns %Rrc *phLdrMod=%RTldrm\n", rc, *phLdrMod));
122 return rc;
123 }
124 RTMemFree(pMod);
125 }
126 *phLdrMod = NIL_RTLDRMOD;
127 LogFlow(("RTLdrLoad: returns %Rrc\n", rc));
128 return rc;
129}
130
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette