- status_t vmi_init (vmi_instance_t *vmi, vmi_mode_t mode, const void *domain, uint64_t init_flags, vmi_init_data_t *init_data, vmi_init_error_t *error) NOEXCEPT
Initializes access to a specific VM or file given a name or an ID. All calls to vmi_init must eventually call vmi_destroy. This is a costly funtion in terms of the time needed to execute. You should call this function only once per VM or file, and then use the resulting instance when calling any of the other library functions. When this function returns VMI_SUCCESS, you will have access to the physical memory of the target VM, as well as vCPU register functions. If you need access to virtual-to-physical translation or OS specific information, you will further need to call the appropriate init functions. Alternatively, you can use vmi_init_complete to initialize access to all LibVMI functions. Parameters- [out] vmi Struct that holds instance information
- [in] mode Specifying the hypervisor mode to init You can call vmi_get_access_mode prior to calling vmi_init to automatically determine this.
- [in] domain Unique name or id specifying the VM or file to view Need to specify whether this is a domainname or domainid by setting either VMI_INIT_DOMAINNAME or VMI_INIT_DOMAINID on init_flags.
- [in] init_flags Init flags to specify the domain input (name or id) and to initialize further LibVMI features, such as events. See VMI_INIT_* declarations above.
- [in] init_data In case initialization requires additional information for a given hypervisor, it can be provided via this input.
- [out] error Optional. If not NULL and the function returns VMI_FAILURE, this will specify the stage at which initialization failed.
Returns- VMI_SUCCESS or VMI_FAILURE
|
- status_t vmi_init_complete (vmi_instance_t *vmi, const void *domain, uint64_t init_flags, vmi_init_data_t *init_data, vmi_config_t config_mode, void *config, vmi_init_error_t *error) NOEXCEPT
Initializes access to a specific VM or file given a name or an ID. All calls to vmi_init_complete must eventually call vmi_destroy. This is a costly funtion in terms of the time needed to execute. You should call this function only once per VM or file, and then use the resulting instance when calling any of the other library functions. When this function returns VMI_SUCCESS, you will have access to the physical memory of the target VM, accessing vCPU registers, virtual-to-physcal translation as well as OS specific functions. Parameters- [out] vmi Struct that holds instance information
- [in] domain Unique name or id specifying the VM or file to view Need to specify whether this is a domainname or domainid by setting either VMI_INIT_DOMAINNAME or VMI_INIT_DOMAINID on init_flags.
- [in] init_flags Additional flags to initialize See VMI_INIT_* declarations above.
- [in] init_data In case initialization requires additional information for a given hypervisor, it can be provided via this input.
- [in] config_mode The type of OS configuration that is provided.
- [in] config Configuration is passed directly to LibVMI (ie. in a string or in a GHashTable) or NULL of global config file is used.
- [out] error Optional. If not NULL and the function returns VMI_FAILURE, this will specify the stage at which initialization failed.
Returns- VMI_SUCCESS or VMI_FAILURE
|
- page_mode_t vmi_init_paging (vmi_instance_t vmi, uint64_t flags) NOEXCEPT
Initialize or reinitialize the paging specific functionality of LibVMI required for virtual-to-physical translation. Note: this function is designed only for live VMs (ie. VMI_XEN or VMI_KVM). and will not work in VMI_FILE mode as that requires OS-specific heuristics. Parameters- [in] vmi LibVMI instance
- [in] paging_flags Additional flags to configure paging using VMI_PM_INITFLAG_* values.
Returns- The page mode that was initialized, or VMI_PM_UNKNOWN.
|
|
|
|
|
|
|
|
|
|
- status_t vmi_pid_to_dtb (vmi_instance_t vmi, vmi_pid_t pid, addr_t *dtb) NOEXCEPT
Given a pid, this function returns the virtual address of the directory table base for this process' address space. This value is effectively what would be in the CR3 register while this process is running. Note: this function uses OS internal linked-lists to find a match but these lists are not guaranteed to be complete and accurate. Use of this function is discouraged when using events. Note: Use of this function is discouraged with events. Parameters- [in] vmi LibVMI instance
- [in] pid Desired process id to lookup
- [out] dtb The directory table base virtual address for a pid
Returns- VMI_SUCCESS or VMI_FAILURE
|
- status_t vmi_dtb_to_pid (vmi_instance_t vmi, addr_t dtb, vmi_pid_t *pid) NOEXCEPT
Given a dtb, this function returns the PID corresponding to the virtual address of the directory table base. This function does NOT implement caching as to avoid false mappings. Note: this function uses OS internal linked-lists to find a match but these lists are not guaranteed to be complete and accurate. Use of this function is discouraged when using events. Note: On Linux certain PIDs don't have their own dtb (task->mm) and rather re-use other process' dtb (task->active_mm). In such case the PID returned by this function will be that of the "owning" process. Note: Use of this function is discouraged with events. Parameters- [in] vmi LibVMI instance
- [in] dtb Desired dtb to lookup
- [out] pid The PID corresponding to the dtb
Returns- VMI_SUCCESS or VMI_FAILURE
|
|
|
- status_t vmi_nested_pagetable_lookup (vmi_instance_t vmi, addr_t npt, page_mode_t npm, addr_t pt, page_mode_t pm, addr_t vaddr, addr_t *paddr, addr_t *naddr) NOEXCEPT
Translates a virtual address to a physical address, supporting nested pagetables (ie. EPT). Can be called with npm set to VMI_PM_NONE, in which case this function is equivalent to vmi_pagetable_lookup. To perform only nested pagetable lookup of an l2 guest paddr use pt and pm with the nested pagetable address and mode. Parameters- [in] vmi LibVMI instance
- [in] npt address of the nested pagetable
- [in] npm page mode to use for lookup in nested pagetable
- [in] pt address of the relevant pagetable
- [in] pm page mode to use for lookup.
- [in] vaddr virtual address to translate via dtb
- [out] paddr Guest physical address (l2) value is set to ~0ull if npm is set and translation was in the v2p cache
- [out] naddr Guest nested physical address (l1) if npm is set
Returns- VMI_SUCCESS or VMI_FAILURE
|
|
|
|
|
|
|
|
|
|
- unicode_string_t* vmi_read_unicode_str_pm (vmi_instance_t vmi, const access_context_t *ctx, page_mode_t mode) NOEXCEPT
Reads a Unicode string from the given address using the specified page mode. This is needed for introspecting Windows-on-Windows (WoW) processes that are 32-bit code running on 64-bit OS. If the guest is running Windows, a UNICODE_STRING struct is read. Linux is not yet supported. The returned value must be freed by the caller. Parameters- [in] vmi LibVMI instance
- [in] ctx Access context
- [in] mode Memory page mode
Returns- String read from memory or NULL on error; this function will set the encoding field.
|
|
|
- status_t vmi_mmap_guest (vmi_instance_t vmi, const access_context_t *ctx, size_t num_pages, void **access_ptrs) NOEXCEPT
Maps num_pages of the guest's virtual memory into host, starting at the provided vaddr. Each page will have it's own pointer in access_ptrs output array. Be aware that not all virtual pages may be allocated and in such case, the corresponding array item will be set to NULL. Remember to call munmap() on each array item afterwards. Parameters- [in] vmi LibVMI instance
- [in] ctx Access context
- [in] num_pages Number of guest pages to be mapped (starting from ctx.addr)
- [out] access_ptrs Output array of size [num_pages] containing pointers to the respective guest's pages
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- status_t vmi_write_8 (vmi_instance_t vmi, const access_context_t *ctx, uint8_t *value) NOEXCEPT
Writes 8 bits to memory Parameters- [in] vmi LibVMI instance
- [in] ctx Access context
- [in] value The value written to memory
Returns- VMI_SUCCESS or VMI_FAILURE
|
- status_t vmi_write_16 (vmi_instance_t vmi, const access_context_t *ctx, uint16_t *value) NOEXCEPT
Writes 16 bits to memory Parameters- [in] vmi LibVMI instance
- [in] ctx Access context
- [in] value The value written to memory
Returns- VMI_SUCCESS or VMI_FAILURE
|
- status_t vmi_write_32 (vmi_instance_t vmi, const access_context_t *ctx, uint32_t *value) NOEXCEPT
Writes 32 bits to memory Parameters- [in] vmi LibVMI instance
- [in] ctx Access context
- [in] value The value written to memory
Returns- VMI_SUCCESS or VMI_FAILURE
|
- status_t vmi_write_64 (vmi_instance_t vmi, const access_context_t *ctx, uint64_t *value) NOEXCEPT
Writes 64 bits to memory Parameters- [in] vmi LibVMI instance
- [in] ctx Access context
- [in] value The value written to memory
Returns- VMI_SUCCESS or VMI_FAILURE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- status_t vmi_get_access_mode (vmi_instance_t vmi, const void *domain, uint64_t init_flags, vmi_init_data_t *init_data, vmi_mode_t *mode) NOEXCEPT
Gets the current access mode for LibVMI, which tells what resource is being using to access the memory (e.g., VMI_XEN, VMI_KVM, or VMI_FILE). If LibVMI is already initialized it will return the active mode. If the LibVMI instance passed is NULL, it will automatically determine the mode. Parameters- [in] vmi LibVMI instance or NULL
- [in] domain Unique name or id specifying the VM or file to view Need to specify whether this is a domainname or domainid by setting either VMI_INIT_DOMAINNAME or VMI_INIT_DOMAINID on init_flags.
- [in] init_flags Init flags to specify the domain input (name or id) and to initialize further LibVMI features, such as events.
- [in] init_data In case initialization requires additional information for a given hypervisor, it can be provided via this input.
- [out] mode The access mode that was identified.
Returns- VMI_SUCCESS if LibVMI was able to access a hypervisor and found the given domain; VMI_FAILURE otherwise.
|
- page_mode_t vmi_get_page_mode (vmi_instance_t vmi, unsigned long vcpu) NOEXCEPT
Gets the current page mode for LibVMI, which tells what type of address translation is in use (e.g., VMI_PM_LEGACY, VMI_PM_PAE, or VMI_PM_IA32E). On live VMs every call to this function will re-check the current state of the specified vCPU. For file-mode it will just return the page-mode that was determined using OS-specific heuristics. ParametersReturns
|
- uint8_t vmi_get_address_width (vmi_instance_t vmi) NOEXCEPT
Gets the current address width for the given vmi_instance_t Note: relative to the OS mode, not that of a process. Also, if paging mode is altered after vmi_init, the information as recorded in vmi_instance_t will be stale and require re-initialization. ParametersReturns
|
|
|
|
|
|
- win_ver_t vmi_get_winver_manual (vmi_instance_t vmi, addr_t kdvb_pa) NOEXCEPT
Get the version of Windows based on the provided KDVB address. This is the simple Windows version - no service pack or patch level is provided. This function is intended to be used during partial init as an aid to elevate to full init. Parameters- [in] vmi LibVMI instance
- [in] kdvb_pa The physical address of the KDVB
Returns
|
|
- status_t vmi_get_kernel_struct_offset (vmi_instance_t vmi, const char *struct_name, const char *member, addr_t *addr) NOEXCEPT
parameterlist simplesect #text
|
|
- uint64_t vmi_get_memsize (vmi_instance_t vmi) NOEXCEPT
Gets the memory size of the guest or file that LibVMI is currently accessing. This is the amount of RAM allocated to the guest, but does not necessarily indicate the highest addressable physical address; get_max_physical_address() should be used. NOTE: if memory ballooning alters the allocation of memory to a VM after vmi_init, this information will have become stale and a re-initialization will be required. ParametersReturns
|
- addr_t vmi_get_max_physical_address (vmi_instance_t vmi) NOEXCEPT
Gets highest addressable physical memory address of the guest or file that LibVMI is currently accessing plus one. That is, any address less then the returned value "may be" a valid physical memory address, but the layout of the guest RAM is hypervisor specific, so there can and will be holes that are not memory pages and can't be read by libvmi. NOTE: if memory ballooning alters the allocation of memory to a VM after vmi_init, this information will have become stale and a re-initialization will be required. ParametersReturns
|
|
|
|
|
- status_t vmi_get_vcpureg (vmi_instance_t vmi, uint64_t *value, reg_t reg, unsigned long vcpu) NOEXCEPT
Gets the current value of a VCPU register. This currently only supports control registers. When LibVMI is accessing a raw memory file, this function will fail. NOTE: for some hypervisor drivers, it is important to understand the validity of the values that registers hold. For example, CR3 for Xen paravirtual VMs may hold a physical address higher than the maximum psuedophysical address of the given VM (this is an expected and correct idiosyncrasy of that platform). Similar scenarios exist for IDTR, etc. Parameters- [in] vmi LibVMI instance
- [out] value Returned value from the register, only valid on VMI_SUCCESS
- [in] reg The register to access
- [in] vcpu The index of the VCPU to access, use 0 for single VCPU systems
Returns- VMI_SUCCESS or VMI_FAILURE
|
|
|
- status_t vmi_set_vcpuregs (vmi_instance_t vmi, registers_t *regs, unsigned long vcpu) NOEXCEPT
Sets the vCPU registers to the ones passed in the struct. It is important to have a valid value in all registers when calling this function, so the user likely wants to call vmi_get_vcpuregs before calling this function. When LibVMI is accessing a raw memory file or KVM, this function will fail. Parameters- [in] vmi LibVMI instance
- [] LibVMI instance
- [in] vcpu The index of the VCPU to access, use 0 for single VCPU systems
Returns- VMI_SUCCESS or VMI_FAILURE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- const char* vmi_get_os_profile_path (vmi_instance_t vmi) NOEXCEPT
Get full path of associated OS profile. This can be either the Rekall profile, Volatility ISF or System.map file. ParametersReturns- Full path of the OS profile
|