Links

Providers

How ImHex accesses data
Providers in ImHex are how any data is being accessed. They expose a common interface to read or write any data to ImHex and handle everything else that's necessary for it to work in the background. Every file you open, every process you attach to, creates a new instance of a provider which handles data accesses to this source.

Usage

The most simple way to use Providers is by loading any file. Either through File -> Open File..., the Open File shortcut on the Welcome Screen or by dragging a file onto ImHex. This will open a FileProvider to access its data.
Besides the FileProvider, there's also more complex ones accessed through File -> Open Other... or Other Providers on the Welcome Screen.
Other providers
Clicking on any of these buttons creates a new instance of this provider and opens a configuration popup to specify additional parameters. Some providers simply open a file picker here, others display custom windows. Clicking Open opens the provider with these settings.
Process Memory Provider configuration popup

Implementation

In C++, Providers are implemented as a polymorphic Provider base class which, amongst others, has the following functions:
1
// Called when a new provider is created. Opens a connection
2
// to its data source
3
bool open();
4
​
5
// Called when the provider is closed. Handles cleanup
6
void close();
7
​
8
​
9
// Called whenever ImHex wants to read any data from this provider
10
void readRaw(u64 offset, void *buffer, size_t size);
11
// Called whenever Imhex wants to write any data to this provider
12
void writeRaw(u64 offset, const void *buffer, size_t size);
13
​
14
// Called when ImHex wants to know the size of this data
15
size_t getActualSize();
The standard File Provider for example uses standard C File IO functions to access a file. It calls fopen() in the open() function, fclose() in the close() function and fread()/fwrite in the readRaw()/writeRaw() function. This is the simplest example for a Provider and it's far from what a Provider can do. readRaw and writeRaw can make calls to other applications, a web service, the Kernel or any other data source one might want to analyze.
This system allows ImHex to act as a universal data access frontend. If a new source is needed, simply implement a new Provider for it.
Last modified 6d ago