VirtualBox

source: vbox/trunk/include/iprt/krnlmod.h@ 78377

Last change on this file since 78377 was 76585, checked in by vboxsync, 6 years ago

*: scm --fix-header-guard-endif

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.4 KB
Line 
1/** @file
2 * IPRT - Kernel module.
3 */
4
5/*
6 * Copyright (C) 2017-2019 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef IPRT_INCLUDED_krnlmod_h
27#define IPRT_INCLUDED_krnlmod_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/cdefs.h>
33#include <iprt/types.h>
34
35
36RT_C_DECLS_BEGIN
37
38/** @defgroup grp_rt_kmod RTKrnlMod - Kernel module/driver userspace side API.
39 * @ingroup grp_rt
40 * @{
41 */
42
43/**
44 * Checks whether the given kernel module was loaded.
45 *
46 * @returns IPRT status code.
47 * @param pszName The driver name to check.
48 * @param pfLoaded Where to store the flag whether the module is loaded on success.
49 */
50RTDECL(int) RTKrnlModQueryLoaded(const char *pszName, bool *pfLoaded);
51
52/**
53 * Returns the kernel module information handle for the given loaded kernel module.
54 *
55 * @returns IPRT status code.
56 * @retval VERR_NOT_FOUND if the kernel driver is not loaded.
57 * @param pszName The driver name.
58 * @param phKrnlModInfo Where to store the handle to the kernel module information record.
59 */
60RTDECL(int) RTKrnlModLoadedQueryInfo(const char *pszName, PRTKRNLMODINFO phKrnlModInfo);
61
62/**
63 * Returns the number of kernel modules loaded on the host system.
64 *
65 * @returns Number of kernel modules loaded.
66 */
67RTDECL(uint32_t) RTKrnlModLoadedGetCount(void);
68
69/**
70 * Returns all loaded kernel modules on the host.
71 *
72 * @returns IPRT status code.
73 * @retval VERR_BUFFER_OVERFLOW if there are not enough entries in the passed handle array.
74 * The required number of entries will be returned in pcEntries.
75 * @param pahKrnlModInfo Where to store the handles to the kernel module information records
76 * on success.
77 * @param cEntriesMax Maximum number of entries fitting in the given array.
78 * @param pcEntries Where to store the number of entries used/required.
79 */
80RTDECL(int) RTKrnlModLoadedQueryInfoAll(PRTKRNLMODINFO pahKrnlModInfo, uint32_t cEntriesMax,
81 uint32_t *pcEntries);
82
83/**
84 * Retains the given kernel module information record handle.
85 *
86 * @returns New reference count.
87 * @param hKrnlModInfo The kernel module information record handle.
88 */
89RTDECL(uint32_t) RTKrnlModInfoRetain(RTKRNLMODINFO hKrnlModInfo);
90
91/**
92 * Releases the given kernel module information record handle.
93 *
94 * @returns New reference count, on 0 the handle is destroyed.
95 * @param hKrnlModInfo The kernel module information record handle.
96 */
97RTDECL(uint32_t) RTKrnlModInfoRelease(RTKRNLMODINFO hKrnlModInfo);
98
99/**
100 * Returns the number of references held onto the kernel module by other
101 * drivers or userspace clients.
102 *
103 * @returns Number of references held on the kernel module.
104 * @param hKrnlModInfo The kernel module information record handle.
105 */
106RTDECL(uint32_t) RTKrnlModInfoGetRefCnt(RTKRNLMODINFO hKrnlModInfo);
107
108/**
109 * Returns the name of the kernel module.
110 *
111 * @returns Pointer to the kernel module name.
112 * @param hKrnlModInfo The kernel module information record handle.
113 */
114RTDECL(const char *) RTKrnlModInfoGetName(RTKRNLMODINFO hKrnlModInfo);
115
116/**
117 * Returns the filepath of the kernel module.
118 *
119 * @returns Pointer to the kernel module path.
120 * @param hKrnlModInfo The kernel module information record handle.
121 */
122RTDECL(const char *) RTKrnlModInfoGetFilePath(RTKRNLMODINFO hKrnlModInfo);
123
124/**
125 * Returns the size of the kernel module.
126 *
127 * @returns Size of the kernel module in bytes.
128 * @param hKrnlModInfo The kernel module information record handle.
129 */
130RTDECL(size_t) RTKrnlModInfoGetSize(RTKRNLMODINFO hKrnlModInfo);
131
132/**
133 * Returns the load address of the kernel module.
134 *
135 * @returns Load address of the kernel module.
136 * @param hKrnlModInfo The kernel module information record handle.
137 */
138RTDECL(RTR0UINTPTR) RTKrnlModInfoGetLoadAddr(RTKRNLMODINFO hKrnlModInfo);
139
140/**
141 * Query the kernel information record for a referencing kernel module of the
142 * given record.
143 *
144 * @returns IPRT status code.
145 * @param hKrnlModInfo The kernel module information record handle.
146 * @param idx Referencing kernel module index (< reference count
147 * as retrieved by RTKrnlModInfoGetRefCnt() ).
148 * @param phKrnlModInfoRef Where to store the handle to the referencing kernel module
149 * information record.
150 */
151RTDECL(int) RTKrnlModInfoQueryRefModInfo(RTKRNLMODINFO hKrnlModInfo, uint32_t idx,
152 PRTKRNLMODINFO phKrnlModInfoRef);
153
154/** @} */
155
156RT_C_DECLS_END
157
158#endif /* !IPRT_INCLUDED_krnlmod_h */
159
Note: See TracBrowser for help on using the repository browser.

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