Documentation
¶
Overview ¶
Package memprocfs provides Go bindings for the MemProcFS vmmdll native library, enabling live memory analysis and forensics on Windows targets (physical or VM) without requiring CGo.
The primary entry point is NewVmm, which loads the native library and opens a connection to a memory target. All analysis operations are methods on the returned *Vmm handle.
Index ¶
- Constants
- Variables
- func CloseAll()
- type ConfigOpt
- type EatEntry
- type EatList
- type Handle
- type HandleList
- type HeapAllocEntry
- type HeapAllocList
- type HeapAllocType
- type HeapEntry
- type HeapList
- type HeapSegmentEntry
- type HeapSegmentType
- type HeapType
- type IATThunkInfo
- type IatEntry
- type IatList
- type IatThunk
- type ImageDataDirectory
- type ImageSectionHeader
- type KDeviceEntry
- type KDeviceList
- type KDriverEntry
- type KDriverList
- type KObjectEntry
- type KObjectList
- type MemFlag
- type MemoryModel
- type Module
- type ModuleDebugInfo
- type ModuleFlag
- type ModuleList
- type ModuleType
- type ModuleVersionInfo
- type NetAddr
- type NetEntry
- type NetList
- type Option
- func WithDevice(device string) Option
- func WithDeviceFPGA() Option
- func WithDisableInfoDB() Option
- func WithDisablePython() Option
- func WithDisableSymbolServer() Option
- func WithDisableSymbols() Option
- func WithForensic(lvl int) Option
- func WithMemMap(filename string) Option
- func WithNorefresh() Option
- func WithPageFile(pageID int, pageFile string) Option
- func WithPrintf() Option
- func WithRemote(dsn string) Option
- func WithVM() Option
- func WithVMBasic() Option
- func WithVMNested() Option
- func WithVerbose() Option
- func WithWaitInitialize() Option
- type PfnEntry
- type PfnFlag
- type PfnList
- type PfnType
- type PfnTypeExtended
- type PhysMemEntry
- type PhysMemList
- type PoolEntry
- type PoolList
- type PoolMapFlag
- type PoolType
- type ProcessInfo
- type ProcessInfoStringOptions
- type ProcessIntegrityLevel
- type PteEntry
- type PteList
- type PteType
- type RegistryHive
- type RegistryKey
- type RegistryValue
- type ScatterHandle
- func (h *ScatterHandle) Clear(pid uint32, flags MemFlag) error
- func (h *ScatterHandle) Close()
- func (h *ScatterHandle) Execute() error
- func (h *ScatterHandle) ExecuteRead() error
- func (h *ScatterHandle) Prepare(va uint64, cb uint32) error
- func (h *ScatterHandle) PrepareWrite(va uint64, data []byte) error
- func (h *ScatterHandle) Read(va uint64, cb uint32) ([]byte, error)
- func (h *ScatterHandle) ReadInto(va uint64, dst []byte) (int, error)
- type SearchOptions
- type SearchPattern
- type SearchRegion
- type ServiceEntry
- type ServiceList
- type ServiceStatus
- type SystemType
- type Thread
- type ThreadCallstack
- type ThreadCallstackEntry
- type ThreadList
- type UnloadedModule
- type UnloadedModuleList
- type UserEntry
- type UserList
- type VMList
- type Vad
- type VadExEntry
- type VadExList
- type VadList
- type VfsEntry
- type VmEntry
- type VmType
- type Vmm
- func (vmm *Vmm) Close() error
- func (vmm *Vmm) ConfigGet(option ConfigOpt) (uint64, error)
- func (vmm *Vmm) ConfigSet(option ConfigOpt, value uint64) error
- func (vmm *Vmm) GetEatList(pid uint32, moduleName string) (*EatList, error)
- func (vmm *Vmm) GetHandleList(pid uint32) (*HandleList, error)
- func (vmm *Vmm) GetHeapAllocList(pid uint32, heapNumOrAddress uint64) (*HeapAllocList, error)
- func (vmm *Vmm) GetHeapList(pid uint32) (*HeapList, error)
- func (vmm *Vmm) GetIATThunkInfo(pid uint32, moduleName string, importModuleName string, importFuncName string) (*IATThunkInfo, error)
- func (vmm *Vmm) GetIatList(pid uint32, moduleName string) (*IatList, error)
- func (vmm *Vmm) GetKDeviceList() (*KDeviceList, error)
- func (vmm *Vmm) GetKDriverList() (*KDriverList, error)
- func (vmm *Vmm) GetKObjectList() (*KObjectList, error)
- func (vmm *Vmm) GetModuleBase(pid uint32, moduleName string) (uint64, error)
- func (vmm *Vmm) GetModuleByName(pid uint32, moduleName string, flags ModuleFlag) (*Module, error)
- func (vmm *Vmm) GetModuleList(pid uint32, flags ModuleFlag) (*ModuleList, error)
- func (vmm *Vmm) GetNetList() (*NetList, error)
- func (vmm *Vmm) GetPfnList(pfns []uint32, flags PfnFlag) (*PfnList, error)
- func (vmm *Vmm) GetPhysMem() (*PhysMemList, error)
- func (vmm *Vmm) GetPidByName(processName string) (uint32, error)
- func (vmm *Vmm) GetPidList() ([]uint32, error)
- func (vmm *Vmm) GetPoolList(flag PoolMapFlag) (*PoolList, error)
- func (vmm *Vmm) GetProcAddress(pid uint32, moduleName string, funcName string) (uint64, error)
- func (vmm *Vmm) GetProcessDirectories(pid uint32, moduleName string) ([16]ImageDataDirectory, error)
- func (vmm *Vmm) GetProcessInfo(pid uint32) (*ProcessInfo, error)
- func (vmm *Vmm) GetProcessInfoAll() ([]ProcessInfo, error)
- func (vmm *Vmm) GetProcessInfoString(pid uint32, opt ProcessInfoStringOptions) (string, error)
- func (vmm *Vmm) GetProcessSections(pid uint32, moduleName string) ([]ImageSectionHeader, error)
- func (vmm *Vmm) GetPteList(pid uint32, identifyModules bool) (*PteList, error)
- func (vmm *Vmm) GetRegistryHives() ([]RegistryHive, error)
- func (vmm *Vmm) GetRegistrySubKeys(keyPath string) ([]RegistryKey, error)
- func (vmm *Vmm) GetRegistryValues(keyPath string) ([]RegistryValue, error)
- func (vmm *Vmm) GetServiceList() (*ServiceList, error)
- func (vmm *Vmm) GetThreadCallstack(pid, tid uint32) (*ThreadCallstack, error)
- func (vmm *Vmm) GetThreadList(pid uint32) (*ThreadList, error)
- func (vmm *Vmm) GetUnloadedModuleList(pid uint32) (*UnloadedModuleList, error)
- func (vmm *Vmm) GetUserList() (*UserList, error)
- func (vmm *Vmm) GetVMList() (*VMList, error)
- func (vmm *Vmm) GetVadExList(pid uint32, oPage uint32, cPage uint32) (*VadExList, error)
- func (vmm *Vmm) GetVadList(pid uint32, identifyModules bool) (*VadList, error)
- func (vmm *Vmm) HiveReadEx(vaCMHive uint64, ra uint32, cb uint32, flags MemFlag) ([]byte, uint32, error)
- func (vmm *Vmm) HiveWrite(vaCMHive uint64, ra uint32, data []byte) error
- func (vmm *Vmm) InitializePlugins() error
- func (vmm *Vmm) MemPrefetchPages(pid uint32, addresses []uint64) error
- func (vmm *Vmm) MemRead(pid uint32, addr uint64, size uint32) ([]byte, error)
- func (vmm *Vmm) MemReadEx(pid uint32, addr uint64, size uint32, flags MemFlag) ([]byte, uint32, error)
- func (vmm *Vmm) MemReadPage(pid uint32, addr uint64) ([]byte, error)
- func (vmm *Vmm) MemSearch(ctx context.Context, pid uint32, patterns []SearchPattern, opts *SearchOptions) ([]uint64, error)
- func (vmm *Vmm) MemSearchFunc(ctx context.Context, pid uint32, patterns []SearchPattern, opts *SearchOptions, ...) error
- func (vmm *Vmm) MemVirt2Phys(pid uint32, va uint64) (uint64, error)
- func (vmm *Vmm) MemWrite(pid uint32, addr uint64, data []byte) error
- func (vmm *Vmm) PdbLoad(pid uint32, vaModuleBase uint64) (string, error)
- func (vmm *Vmm) PdbSymbolAddress(module string, symbolName string) (uint64, error)
- func (vmm *Vmm) PdbSymbolName(module string, addressOrOffset uint64) (string, uint32, error)
- func (vmm *Vmm) PdbTypeChildOffset(module string, typeName string, childName string) (uint32, error)
- func (vmm *Vmm) PdbTypeSize(module string, typeName string) (uint32, error)
- func (vmm *Vmm) RegQueryValueEx(keyValuePath string) (uint32, []byte, error)
- func (vmm *Vmm) ScatterInitialize(pid uint32, flags MemFlag) (*ScatterHandle, error)
- func (vmm *Vmm) VfsList(path string) ([]VfsEntry, error)
- func (vmm *Vmm) VfsRead(path string, cb uint32, offset uint64) ([]byte, error)
- func (vmm *Vmm) VfsWrite(path string, data []byte, offset uint64) error
- func (vmm *Vmm) VmGetVmmHandle(vm *VmEntry) (*Vmm, error)
- func (vmm *Vmm) VmMemRead(vm *VmEntry, qwGPA uint64, cb uint32) ([]byte, error)
- func (vmm *Vmm) VmMemTranslateGPA(vm *VmEntry, qwGPA uint64) (pa uint64, va uint64, err error)
- func (vmm *Vmm) VmMemWrite(vm *VmEntry, qwGPA uint64, data []byte) error
- func (vmm *Vmm) VmScatterInitialize(vm *VmEntry) (*ScatterHandle, error)
- func (vmm *Vmm) YaraSearch(ctx context.Context, pid uint32, rules []string, opts *SearchOptions) ([]uint64, error)
- func (vmm *Vmm) YaraSearchFunc(ctx context.Context, pid uint32, rules []string, opts *SearchOptions, ...) ([]uint64, error)
- type WinProcessInfo
- type YaraMatch
- type YaraMeta
- type YaraString
Constants ¶
const ( // PidPhysical targets physical memory instead of a process. PidPhysical = 0xFFFFFFFF // PidProcessWithKernelMemory is a flag to OR with a PID to also access // kernel memory from that process's address space. PidProcessWithKernelMemory = 0x80000000 )
Special PID values.
const ( MapPTEVersion = 2 MapVADVersion = 6 MapVADExVersion = 4 MapModuleVersion = 6 MapUnloadedModuleVersion = 2 MapEATVersion = 3 MapIATVersion = 2 MapHeapVersion = 4 MapHeapAllocVersion = 1 MapThreadVersion = 4 MapThreadCallstackVersion = 1 MapHandleVersion = 3 MapPoolVersion = 2 MapKObjectVersion = 1 MapKDriverVersion = 1 MapKDeviceVersion = 1 MapNetVersion = 3 MapPhysMemVersion = 2 MapUserVersion = 2 MapVMVersion = 2 MapServiceVersion = 3 )
Map*Version constants define the vmmdll structure versions this library was built against. Get* methods return an ErrUnsupported*Version error if the loaded native library returns a different version, indicating a vmmdll API mismatch.
Variables ¶
var ( // ErrClosed is returned when a method is called on a closed handle. ErrClosed = errors.New("handle is closed") // ErrReadFailed is returned when the native library fails to read memory. ErrReadFailed = errors.New("memory read failed") // ErrWriteFailed is returned when the native library fails to write memory. ErrWriteFailed = errors.New("memory write failed") // ErrScatterFailed is returned when a scatter prepare, execute or clear fails. ErrScatterFailed = errors.New("scatter operation failed") // ErrSearchFailed is returned when the native library fails a memory or // YARA search, e.g. because of invalid rules or a missing vmmyara library. ErrSearchFailed = errors.New("search failed") )
Sentinel errors for memory and scatter operations. Errors returned by those operations wrap one of these, so callers can match them with errors.Is.
The native library only reports success or failure, so ErrReadFailed does not say why a read failed (e.g. unreadable page vs. invalid address).
var ( ErrUnsupportedPTEVersion = errors.New("unsupported PTE version") ErrUnsupportedVADVersion = errors.New("unsupported VAD version") ErrUnsupportedVADExVersion = errors.New("unsupported VADEx version") ErrUnsupportedModuleVersion = errors.New("unsupported Module version") ErrUnsupportedUnloadedModuleVersion = errors.New("unsupported UnloadedModule version") ErrUnsupportedEATVersion = errors.New("unsupported EAT version") ErrUnsupportedIATVersion = errors.New("unsupported IAT version") ErrUnsupportedHeapVersion = errors.New("unsupported Heap version") ErrUnsupportedHeapAllocVersion = errors.New("unsupported HeapAlloc version") ErrUnsupportedThreadVersion = errors.New("unsupported Thread version") ErrUnsupportedThreadCallstackVersion = errors.New("unsupported ThreadCallstack version") ErrUnsupportedHandleVersion = errors.New("unsupported Handle version") ErrUnsupportedPoolVersion = errors.New("unsupported Pool version") ErrUnsupportedKObjectVersion = errors.New("unsupported KObject version") ErrUnsupportedKDriverVersion = errors.New("unsupported KDriver version") ErrUnsupportedKDeviceVersion = errors.New("unsupported KDevice version") ErrUnsupportedNetVersion = errors.New("unsupported Net version") ErrUnsupportedPhysMemVersion = errors.New("unsupported PhysMem version") ErrUnsupportedUserVersion = errors.New("unsupported User version") ErrUnsupportedVMVersion = errors.New("unsupported VM version") ErrUnsupportedServiceVersion = errors.New("unsupported Service version") )
ErrUnsupported*Version errors are returned when the native vmmdll library returns a map structure version that does not match the expected Map*Version constant.
Functions ¶
Types ¶
type ConfigOpt ¶
type ConfigOpt uint64
ConfigOpt defines the type for VMM configuration options used with ConfigGet/ConfigSet.
const ( // Core Options OptCorePrintfEnable ConfigOpt = 0x4000000100000000 // RW OptCoreVerbose ConfigOpt = 0x4000000200000000 // RW OptCoreVerboseExtra ConfigOpt = 0x4000000300000000 // RW OptCoreVerboseExtraTlp ConfigOpt = 0x4000000400000000 // RW OptCoreMaxNativeAddress ConfigOpt = 0x4000000800000000 // R OptCoreLeechcoreHandle ConfigOpt = 0x4000001000000000 // R OptCoreVmmId ConfigOpt = 0x4000002000000000 // R OptCoreSystem ConfigOpt = 0x2000000100000000 // R OptCoreMemoryModel ConfigOpt = 0x2000000200000000 // R // Config Options OptConfigIsRefreshEnabled ConfigOpt = 0x2000000300000000 // R OptConfigTickPeriod ConfigOpt = 0x2000000400000000 // RW OptConfigReadCacheTicks ConfigOpt = 0x2000000500000000 // RW OptConfigTlpCacheTicks ConfigOpt = 0x2000000600000000 // RW OptConfigProcCacheTicksPartial ConfigOpt = 0x2000000700000000 // RW OptConfigProcCacheTicksTotal ConfigOpt = 0x2000000800000000 // RW OptConfigVmmVersionMajor ConfigOpt = 0x2000000900000000 // R OptConfigVmmVersionMinor ConfigOpt = 0x2000000A00000000 // R OptConfigVmmVersionRevision ConfigOpt = 0x2000000B00000000 // R OptConfigStatisticsFunctionCall ConfigOpt = 0x2000000C00000000 // RW OptConfigIsPagingEnabled ConfigOpt = 0x2000000D00000000 // RW OptConfigDebug ConfigOpt = 0x2000000E00000000 // W OptConfigYaraRules ConfigOpt = 0x2000000F00000000 // R // Windows Specific Options OptWinVersionMajor ConfigOpt = 0x2000010100000000 // R OptWinVersionMinor ConfigOpt = 0x2000010200000000 // R OptWinVersionBuild ConfigOpt = 0x2000010300000000 // R OptWinSystemUniqueId ConfigOpt = 0x2000010400000000 // R // Forensic Mode Options OptForensicMode ConfigOpt = 0x2000020100000000 // RW // Refresh Options OptRefreshAll ConfigOpt = 0x2001ffff00000000 // W OptRefreshFreqMem ConfigOpt = 0x2001100000000000 // W OptRefreshFreqMemPartial ConfigOpt = 0x2001000200000000 // W OptRefreshFreqTlb ConfigOpt = 0x2001080000000000 // W OptRefreshFreqTlbPartial ConfigOpt = 0x2001000400000000 // W OptRefreshFreqFast ConfigOpt = 0x2001040000000000 // W OptRefreshFreqMedium ConfigOpt = 0x2001000100000000 // W OptRefreshFreqSlow ConfigOpt = 0x2001001000000000 // W // Process Specific Options (PID in lower DWORD) OptProcessDtb ConfigOpt = 0x2002000100000000 // W OptProcessDtbFastLowIntegrity ConfigOpt = 0x2002000200000000 // W )
type EatEntry ¶
type EatEntry struct {
FunctionAddress uint64
Ordinal uint32
FunctionName string
ForwardedFunctionName string
OFunctionsArray uint32
ONamesArray uint32
}
EatEntry represents a single entry in the Export Address Table.
type EatList ¶
type EatList struct {
Version uint32
OrdinalBase uint32
NumberOfNames uint32
NumberOfFunctions uint32
NumberOfForwardedFunctions uint32
ModuleBaseAddress uint64
AddressOfFunctions uint64
AddressOfNames uint64
MultiText string
Count uint32
Entries []EatEntry
}
EatList holds the Export Address Table of a module.
type Handle ¶
type Handle struct {
Object uint64
Handle uint32
GrantedAccess uint32
TypeIndex uint32
HandleCount uint64
PointerCount uint64
ObjectCreateInfo uint64
SecurityDescriptor uint64
Text string
PID uint32
PoolTag uint32
Type string
}
Handle represents a single handle in a process.
type HandleList ¶
HandleList contains a list of handles for a process.
type HeapAllocEntry ¶
type HeapAllocEntry struct {
Address uint64
Size uint32
Type HeapAllocType
}
HeapAllocEntry represents a single heap allocation entry.
type HeapAllocList ¶
type HeapAllocList struct {
Version uint32
Count uint32
Entries []HeapAllocEntry
}
HeapAllocList contains a list of heap allocation entries for a process and heap.
type HeapAllocType ¶
type HeapAllocType uint32
HeapAllocType corresponds to the VMMDLL_HEAPALLOC_TP enum.
const ( HeapAllocTypeNA HeapAllocType = 0 HeapAllocTypeNtHeap HeapAllocType = 1 HeapAllocTypeNtLfh HeapAllocType = 2 HeapAllocTypeNtLarge HeapAllocType = 3 HeapAllocTypeNtNa HeapAllocType = 4 HeapAllocTypeSegVs HeapAllocType = 5 HeapAllocTypeSegLfh HeapAllocType = 6 HeapAllocTypeSegLarge HeapAllocType = 7 HeapAllocTypeSegNa HeapAllocType = 8 )
type HeapList ¶
type HeapList struct {
Version uint32
Count uint32
Segments []HeapSegmentEntry
Entries []HeapEntry
}
HeapList contains a list of heap entries and segments for a process.
type HeapSegmentEntry ¶
type HeapSegmentEntry struct {
Address uint64
Size uint32
SegmentType HeapSegmentType
HeapIndex uint16
}
HeapSegmentEntry represents a single heap segment.
type HeapSegmentType ¶
type HeapSegmentType uint16
HeapSegmentType corresponds to the VMMDLL_HEAP_SEGMENT_TP enum.
const ( HeapSegmentNA HeapSegmentType = 0 HeapSegmentNtSegment HeapSegmentType = 1 HeapSegmentNtLfh HeapSegmentType = 2 HeapSegmentNtLarge HeapSegmentType = 3 HeapSegmentNtNa HeapSegmentType = 4 HeapSegmentSegHeap HeapSegmentType = 5 HeapSegmentSegSegment HeapSegmentType = 6 HeapSegmentSegLarge HeapSegmentType = 7 HeapSegmentSegNa HeapSegmentType = 8 )
type IATThunkInfo ¶
type IATThunkInfo struct {
Is32Bit bool // true if thunk entry is 4 bytes wide (32-bit process)
VaThunk uint64 // virtual address of the IAT slot itself
VaFunction uint64 // current value of the IAT slot = actual function address
VaNameModule uint64 // VA of the null-terminated module name string
VaNameFunc uint64 // VA of the null-terminated function name string
}
IATThunkInfo holds information about a single Import Address Table thunk. Useful for detecting IAT hooks and for locating where a specific import lives in memory.
type IatEntry ¶
type IatEntry struct {
FunctionAddress uint64
FunctionName string
ModuleName string
Thunk IatThunk
}
IatEntry represents a single entry in the Import Address Table.
type IatList ¶
type IatList struct {
Version uint32
ModuleBaseAddress uint64
Count uint32
MultiText string
Entries []IatEntry
}
IatList represents the Import Address Table for a module.
type IatThunk ¶
type IatThunk struct {
Is32Bit bool
Hint uint16
RvaFirstThunk uint32
RvaOriginalFirstThunk uint32
RvaNameModule uint32
RvaNameFunction uint32
}
IatThunk represents the Thunk data for an IAT entry.
type ImageDataDirectory ¶
ImageDataDirectory mirrors the Windows IMAGE_DATA_DIRECTORY structure.
type ImageSectionHeader ¶
type ImageSectionHeader struct {
Name [8]byte
VirtualSize uint32 // Also PhysicalAddress
VirtualAddress uint32
SizeOfRawData uint32
PointerToRawData uint32
PointerToRelocations uint32
PointerToLinenumbers uint32
NumberOfRelocations uint16
NumberOfLinenumbers uint16
Characteristics uint32
}
ImageSectionHeader mirrors the Windows IMAGE_SECTION_HEADER structure.
type KDeviceEntry ¶
type KDeviceEntry struct {
Va uint64
Depth uint32
DeviceType uint32
DeviceTypeName string
VaDriverObject uint64
VaAttachedDevice uint64
VaFileSystemDevice uint64
VolumeInfo string
}
KDeviceEntry represents a single kernel device object entry.
type KDeviceList ¶
type KDeviceList struct {
Version uint32
Count uint32
Entries []KDeviceEntry
}
KDeviceList contains a list of kernel device objects.
type KDriverEntry ¶
type KDriverEntry struct {
Va uint64
VaDriverStart uint64
CbDriverSize uint64
VaDeviceObject uint64
Name string
Path string
ServiceKeyName string
MajorFunction [28]uint64
}
KDriverEntry represents a single kernel driver entry.
type KDriverList ¶
type KDriverList struct {
Version uint32
Count uint32
Entries []KDriverEntry
}
KDriverList contains a list of kernel drivers.
type KObjectEntry ¶
KObjectEntry represents a single kernel object entry.
type KObjectList ¶
type KObjectList struct {
Version uint32
Count uint32
Entries []KObjectEntry
}
KObjectList contains a list of kernel objects.
type MemFlag ¶
type MemFlag uint32
MemFlag is a bitmask of memory read/write flags (VMMDLL_FLAG_*).
const ( // MemFlagNone is the default — no special flags. MemFlagNone MemFlag = 0 // MemFlagNoCache forces reading from the acquisition device, bypassing cache. MemFlagNoCache MemFlag = 0x0001 // MemFlagZeroPadOnFail zero-pads failed physical memory reads and reports // success if the read is within range of physical memory. MemFlagZeroPadOnFail MemFlag = 0x0002 // MemFlagForceCacheRead forces use of cache; fails non-cached pages. // Invalid combined with MemFlagNoCache or MemFlagZeroPadOnFail. MemFlagForceCacheRead MemFlag = 0x0008 // MemFlagNoPaging skips retrieval of paged-out memory from pagefile/compressed. MemFlagNoPaging MemFlag = 0x0010 // MemFlagNoPagingIO skips retrieval of paged-out memory if it would incur I/O. MemFlagNoPagingIO MemFlag = 0x0020 // MemFlagNoCachePut prevents writing back to the data cache after a successful read. MemFlagNoCachePut MemFlag = 0x0100 // MemFlagCacheRecentOnly fetches only from the most recent active cache region. MemFlagCacheRecentOnly MemFlag = 0x0200 // MemFlagForceCacheReadDisable disables VMMDLL_FLAG_FORCECACHE_READ. // Recommended for local files to improve forensic artifact ordering. MemFlagForceCacheReadDisable MemFlag = 0x0800 // MemFlagScatterPrepareExNoMemZero skips zero-ing the buffer when // preparing a scatter read. MemFlagScatterPrepareExNoMemZero MemFlag = 0x1000 // MemFlagNoMemCallback suppresses user-set memory callback functions. MemFlagNoMemCallback MemFlag = 0x2000 // MemFlagScatterForcePageRead forces page-sized reads in scatter operations. MemFlagScatterForcePageRead MemFlag = 0x4000 )
type MemoryModel ¶
type MemoryModel uint32
MemoryModel corresponds to the VMMDLL_MEMORYMODEL_TP enum.
const ( MemoryModelNA MemoryModel = 0 MemoryModelX86 MemoryModel = 1 MemoryModelX86PAE MemoryModel = 2 MemoryModelX64 MemoryModel = 3 MemoryModelARM64 MemoryModel = 4 )
type Module ¶
type Module struct {
BaseAddress uint64
EntryPoint uint64
ImageSize uint32
IsWow64 bool
Name string
FullName string
Type ModuleType
FileSize uint32
SectionCount uint32
ExportCount uint32
ImportCount uint32
DebugInfo *ModuleDebugInfo
VersionInfo *ModuleVersionInfo
}
Module contains information about a single loaded module.
type ModuleDebugInfo ¶ added in v0.1.2
ModuleDebugInfo contains PDB debug information for a module. Populated only when ModuleFlagDebugInfo is passed.
type ModuleFlag ¶ added in v0.1.2
type ModuleFlag uint32
ModuleFlag controls module enumeration behavior.
const ( // ModuleFlagNone retrieves basic module information. ModuleFlagNone ModuleFlag = 0 // ModuleFlagDebugInfo includes debug info (Age, GUID, PDB filename). ModuleFlagDebugInfo ModuleFlag = 1 // ModuleFlagVersionInfo includes version info (company, description, version, etc.). ModuleFlagVersionInfo ModuleFlag = 2 )
type ModuleList ¶
ModuleList contains a list of loaded modules for a process.
type ModuleType ¶
type ModuleType uint32
ModuleType corresponds to the VMMDLL_MODULE_TP enum.
const ( ModuleTypeNormal ModuleType = 0 ModuleTypeData ModuleType = 1 ModuleTypeNotLinked ModuleType = 2 ModuleTypeInjected ModuleType = 3 )
type ModuleVersionInfo ¶ added in v0.1.2
type ModuleVersionInfo struct {
CompanyName string
FileDescription string
FileVersion string
InternalName string
LegalCopyright string
OriginalFilename string
ProductName string
ProductVersion string
}
ModuleVersionInfo contains version resource information for a module. Populated only when ModuleFlagVersionInfo is passed.
type NetEntry ¶
type NetEntry struct {
PID uint32
State uint32
AddressFamily uint16
Src NetAddr
Dst NetAddr
Object uint64
Timestamp uint64
PoolTag uint32
Text string
}
NetEntry represents a single network connection entry.
type Option ¶
type Option func() []string
Option is a functional option for NewVmm. Use the With* constructors to build the option list.
func WithDevice ¶
WithDevice sets the target device or memory source. Accepts a file path (e.g. "./dump.raw"), a device name, or a special string like "fpga".
func WithDeviceFPGA ¶
func WithDeviceFPGA() Option
WithDeviceFPGA connects to an FPGA hardware device (default if no option is given).
func WithDisableInfoDB ¶
func WithDisableInfoDB() Option
WithDisableInfoDB disables the internal info/symbol database.
func WithDisablePython ¶
func WithDisablePython() Option
WithDisablePython disables the Python plugin subsystem.
func WithDisableSymbolServer ¶
func WithDisableSymbolServer() Option
WithDisableSymbolServer disables network access to the Microsoft symbol server. Use when offline or to speed up initialization.
func WithDisableSymbols ¶
func WithDisableSymbols() Option
WithDisableSymbols skips PDB symbol loading entirely (faster startup, no symbol resolution).
func WithForensic ¶
WithForensic enables forensic mode at the given level (0–4). Higher levels perform more analysis (e.g. timeline, yara scanning) at the cost of time.
func WithMemMap ¶
WithMemMap provides a physical memory map file that describes memory regions.
func WithNorefresh ¶
func WithNorefresh() Option
WithNorefresh disables the background memory refresh that re-reads live targets periodically.
func WithPageFile ¶
WithPageFile attaches a Windows page file to supplement the memory image. pageID is 0–9 corresponding to pagefile0–pagefile9.
func WithPrintf ¶
func WithPrintf() Option
WithPrintf enables stdout output from the native vmmdll library.
func WithRemote ¶
WithRemote connects to a remote LeechAgent instead of a local device. dsn format: "remoteaddr:port" or a LeechCore DSN string.
func WithVM ¶
func WithVM() Option
WithVM enables detection and parsing of virtual machines in the memory image.
func WithVMBasic ¶
func WithVMBasic() Option
WithVMBasic enables basic VM detection (less thorough than WithVM, faster).
func WithVMNested ¶
func WithVMNested() Option
WithVMNested enables nested VM detection (VMs inside VMs).
func WithVerbose ¶
func WithVerbose() Option
WithVerbose enables verbose diagnostic output from the native library.
func WithWaitInitialize ¶
func WithWaitInitialize() Option
WithWaitInitialize blocks NewVmm until full initialization is complete. Without this, some data (e.g. processes) may not be ready immediately after NewVmm returns.
type PfnEntry ¶
type PfnEntry struct {
Pfn uint32
TypeExtended PfnTypeExtended
Pid uint32 // valid for active non-prototype pages
Va uint64 // virtual address (non-zero when known)
VaPte uint64
OriginalPte uint64
Type PfnType // page location type (PageLocation bitfield)
ReferenceCount uint16
}
PfnEntry holds information about a single Page Frame Number.
type PfnFlag ¶ added in v0.1.2
type PfnFlag uint32
PfnFlag controls the level of detail returned by GetPfnList.
type PfnTypeExtended ¶
type PfnTypeExtended uint32
PfnTypeExtended corresponds to the VMMDLL_MAP_PFN_TYPEEXTENDED enum.
const ( PfnExtUnknown PfnTypeExtended = 0 PfnExtUnused PfnTypeExtended = 1 PfnExtProcessPrivate PfnTypeExtended = 2 PfnExtPageTable PfnTypeExtended = 3 PfnExtLargePage PfnTypeExtended = 4 PfnExtDriverLocked PfnTypeExtended = 5 PfnExtFile PfnTypeExtended = 7 )
type PhysMemEntry ¶
PhysMemEntry represents a physical memory range.
type PhysMemList ¶
type PhysMemList struct {
Version uint32
Count uint32
Entries []PhysMemEntry
}
PhysMemList contains a list of physical memory ranges.
type PoolMapFlag ¶
type PoolMapFlag uint32
PoolMapFlag controls which pool allocations are returned.
const ( PoolMapFlagAll PoolMapFlag = 0 PoolMapFlagBig PoolMapFlag = 1 )
type ProcessInfo ¶
type ProcessInfo struct {
Magic uint64
Version uint16
Size uint16
MemoryModel MemoryModel
SystemType SystemType
IsUserOnly uint32 // BOOL
PID uint32
ParentPID uint32
State uint32
NameRaw [16]byte
NameLongRaw [64]byte
DTB uint64
UserDTB uint64
Win WinProcessInfo
// contains filtered or unexported fields
}
ProcessInfo mirrors the C struct VMMDLL_PROCESS_INFORMATION
func (*ProcessInfo) Name ¶
func (pi *ProcessInfo) Name() string
Name returns the process name as a Go string.
func (*ProcessInfo) NameLong ¶
func (pi *ProcessInfo) NameLong() string
NameLong returns the long process name as a Go string.
type ProcessInfoStringOptions ¶
type ProcessInfoStringOptions uint32
const ( ProcessInformationOptStringPathKernel ProcessInfoStringOptions = 1 ProcessInformationOptStringPathUserImage ProcessInfoStringOptions = 2 ProcessInformationOptStringCmdline ProcessInfoStringOptions = 3 )
type ProcessIntegrityLevel ¶
type ProcessIntegrityLevel uint32
type PteEntry ¶
type PteEntry struct {
BaseAddress uint64
PageCount uint64
PageFlags uint64
IsWow64 bool
Name string
SoftwareCount uint32
}
PteEntry represents a single Page Table Entry.
type RegistryHive ¶
RegistryHive represents a single registry hive.
type RegistryKey ¶
type RegistryKey struct {
Name string
LastWriteTime uint64 // FILETIME: 100-nanosecond intervals since Jan 1, 1601
}
RegistryKey represents a single registry sub-key entry.
type RegistryValue ¶
RegistryValue represents a single registry value entry.
type ScatterHandle ¶
type ScatterHandle struct {
// contains filtered or unexported fields
}
ScatterHandle is a handle for batched scatter read/write operations. Create via Vmm.ScatterInitialize; close with Close when done. A ScatterHandle is not safe for concurrent use.
func (*ScatterHandle) Clear ¶
func (h *ScatterHandle) Clear(pid uint32, flags MemFlag) error
Clear resets the handle for reuse in a subsequent scatter operation. Optionally change the target PID; pass 0 to keep the current PID.
func (*ScatterHandle) Close ¶
func (h *ScatterHandle) Close()
Close releases all resources associated with the scatter handle. It is safe to call Close more than once; later calls do nothing. Other methods return ErrClosed after Close.
func (*ScatterHandle) Execute ¶
func (h *ScatterHandle) Execute() error
Execute writes all ranges registered with PrepareWrite, then reads all ranges registered with Prepare.
func (*ScatterHandle) ExecuteRead ¶
func (h *ScatterHandle) ExecuteRead() error
ExecuteRead reads all ranges registered with Prepare.
func (*ScatterHandle) Prepare ¶
func (h *ScatterHandle) Prepare(va uint64, cb uint32) error
Prepare registers a virtual address range for reading. After Execute or ExecuteRead, retrieve the data with Read or ReadInto.
func (*ScatterHandle) PrepareWrite ¶
func (h *ScatterHandle) PrepareWrite(va uint64, data []byte) error
PrepareWrite registers a virtual address range for writing. Data is copied immediately, so the slice may be modified after this call. Writing takes place before reading during Execute. Note: requires a live/writable target.
func (*ScatterHandle) Read ¶
func (h *ScatterHandle) Read(va uint64, cb uint32) ([]byte, error)
Read retrieves data for a range previously registered with Prepare. Must be called after Execute or ExecuteRead. It allocates a new slice on every call; use ReadInto to reuse a buffer.
func (*ScatterHandle) ReadInto ¶ added in v0.3.0
func (h *ScatterHandle) ReadInto(va uint64, dst []byte) (int, error)
ReadInto copies data for a range previously registered with Prepare into dst and returns the number of bytes read. len(dst) is the range size. Must be called after Execute or ExecuteRead. An empty dst reads nothing.
type SearchOptions ¶ added in v0.4.0
type SearchOptions struct {
// MinAddress and MaxAddress limit the searched range. They are rounded to
// page boundaries. MaxAddress 0 means the end of the address space (or the
// end of physical memory when pid is PidPhysical).
MinAddress uint64
MaxAddress uint64
// MaxResults stops the search after this many hits. 0 means no limit other
// than the native one: about one million for MemSearch and 65536 for YARA.
// For YaraSearchFunc it counts matched string offsets, not callback calls.
MaxResults uint32
// Flags are memory read flags, such as MemFlagNoCache.
Flags MemFlag
// ForcePTE and ForceVAD select how a process address space is walked.
// By default MemProcFS picks one. They have no effect for PidPhysical.
ForcePTE bool
ForceVAD bool
// Filter is called for each memory region before it is read.
// Return false to skip the region. It is not called for PidPhysical.
Filter func(SearchRegion) bool
}
SearchOptions configures MemSearch and YaraSearch. A nil *SearchOptions searches the whole address space with default settings.
type SearchPattern ¶ added in v0.4.0
type SearchPattern struct {
// Bytes is the data to look for: 1 to 32 bytes, not all zero.
Bytes []byte
// Mask is optional. If set it must be as long as Bytes. Bits set to 1 are
// wildcards: they are ignored when comparing the matching byte.
// For example Mask byte 0xFF matches any byte, 0x0F matches any low nibble.
Mask []byte
// Align is the step in bytes between tested offsets. 0 or 1 tests every byte.
// A power of two up to 4096 means "only addresses that are multiples of Align".
Align uint32
}
SearchPattern is one byte pattern for MemSearch and MemSearchFunc.
type SearchRegion ¶ added in v0.4.0
SearchRegion is a memory region offered to SearchOptions.Filter. Exactly one of Pte and Vad is set, depending on how the process address space is walked (see SearchOptions.ForcePTE and ForceVAD). Text fields (PteEntry.Name, Vad.Text) may be empty during YARA searches.
type ServiceEntry ¶
type ServiceEntry struct {
Object uint64
Ordinal uint32
StartType uint32
Status ServiceStatus
ServiceName string
DisplayName string
Path string
UserType string
UserAccount string
ImagePath string
PID uint32
}
ServiceEntry represents a single service entry.
type ServiceList ¶
type ServiceList struct {
Version uint32
Count uint32
MultiText string
Entries []ServiceEntry
}
ServiceList contains a list of services.
type ServiceStatus ¶
type ServiceStatus struct {
ServiceType uint32
CurrentState uint32
ControlsAccepted uint32
Win32ExitCode uint32
ServiceSpecificExitCode uint32
CheckPoint uint32
WaitHint uint32
}
ServiceStatus mirrors the Windows SERVICE_STATUS structure.
type SystemType ¶
type SystemType uint32
SystemType corresponds to the VMMDLL_SYSTEM_TP enum.
const ( SystemUnknownPhysical SystemType = 0 SystemUnknown64 SystemType = 1 SystemWindows64 SystemType = 2 SystemUnknown32 SystemType = 3 SystemWindows32 SystemType = 4 )
type Thread ¶
type Thread struct {
TID uint32
PID uint32
ExitStatus uint32
State byte
Running byte
Priority byte
BasePriority byte
ETHREAD uint64
Teb uint64
CreateTime uint64
ExitTime uint64
StartAddress uint64
StackBaseUser uint64
StackLimitUser uint64
StackBaseKernel uint64
StackLimitKernel uint64
TrapFrame uint64
RIP uint64
RSP uint64
Affinity uint64
UserTime uint32
KernelTime uint32
SuspendCount byte
WaitReason byte
ImpersonationToken uint64
Win32StartAddress uint64
}
Thread represents a single thread in a process.
type ThreadCallstack ¶
type ThreadCallstack struct {
Version uint32
PID uint32
TID uint32
Text string
MultiText string
Count uint32
Entries []ThreadCallstackEntry
}
ThreadCallstack contains the callstack for a thread.
type ThreadCallstackEntry ¶
type ThreadCallstackEntry struct {
Index uint32
RegPresent bool
RetAddr uint64
RSP uint64
BaseSP uint64
Displacement uint32
ModuleName string
FunctionName string
}
ThreadCallstackEntry represents a single entry in the thread callstack.
type ThreadList ¶
ThreadList contains a list of threads for a process.
type UnloadedModule ¶
type UnloadedModule struct {
BaseAddress uint64
ImageSize uint32
IsWow64 bool
Name string
UnloadTime uint64
Checksum uint32
Timestamp uint32
}
UnloadedModule represents a single unloaded module.
type UnloadedModuleList ¶
type UnloadedModuleList struct {
Version uint32
Count uint32
MultiText string
Modules []UnloadedModule
}
UnloadedModuleList contains a list of unloaded modules for a process.
type Vad ¶
type Vad struct {
Start uint64
End uint64
VadAddress uint64
VadType uint32
Protection uint32
IsImage bool
IsFile bool
IsPageFile bool
IsPrivateMemory bool
IsTeb bool
IsStack bool
HeapNum uint32
IsHeap bool
CommitCharge uint32
IsCommitted bool
PrototypePteSize uint32
PrototypePte uint64
Subsection uint64
Text string
FileObject uint64
VadExPages uint32
VadExPagesBase uint32
}
Vad represents a single Virtual Address Descriptor.
type VadExEntry ¶
type VadExEntry struct {
Type PteType
PageMapLevel uint8
PteFlags uint8
Va uint64
Pa uint64
Pte uint64
ProtoType PteType
ProtoPa uint64
ProtoPte uint64
VadBase uint64
}
VadExEntry is a single extended VAD page entry returned by GetVadExList.
type VadExList ¶
type VadExList struct {
Count uint32
Entries []VadExEntry
}
VadExList holds extended VAD page entries.
type VfsEntry ¶
type VfsEntry struct {
Name string
Size uint64 // file size in bytes; ^uint64(0) means directory
IsDirectory bool
CreationTime uint64 // FILETIME
LastAccessTime uint64 // FILETIME
LastWriteTime uint64 // FILETIME
}
VfsEntry represents a single file or directory in the MemProcFS virtual filesystem.
type VmEntry ¶
type VmEntry struct {
Handle uintptr
Name string
GpaMax uint64
Type VmType
IsActive bool
IsReadOnly bool
IsPhysicalOnly bool
PartitionID uint32
VersionBuild uint32
SystemType SystemType
ParentVmmMountID uint32
VmMemPID uint32
}
VmEntry represents a single virtual machine discovered by MemProcFS.
type Vmm ¶
type Vmm struct {
// contains filtered or unexported fields
}
Vmm is a handle to an active MemProcFS session. Create one with NewVmm; release resources with Close when done. All analysis methods (memory reads, process info, registry, etc.) are methods on *Vmm.
func NewVmm ¶
NewVmm loads the vmmdll native library from libPath and initializes a new MemProcFS session with the given options.
libPath is the path to the platform-specific vmmdll shared library (e.g. "./libs/vmm.dylib" on macOS, "vmm.dll" on Windows).
Use option functions (WithDevice, WithRemote, etc.) to configure the target. If no options are provided, the default target is an FPGA device.
The caller must call Close on the returned handle to release resources.
func (*Vmm) Close ¶
Close shuts down this Vmm session and frees all associated resources. After Close, the Vmm handle must not be used. VMMDLL_Close has no return value, so the error is always nil; it is kept so Vmm satisfies io.Closer.
func (*Vmm) GetEatList ¶
GetEatList retrieves the Export Address Table (EAT) for a given module in a process. GetEatList returns the Export Address Table for moduleName in process pid.
func (*Vmm) GetHandleList ¶
func (vmm *Vmm) GetHandleList(pid uint32) (*HandleList, error)
GetHandleList returns all open kernel handles for process pid.
func (*Vmm) GetHeapAllocList ¶
func (vmm *Vmm) GetHeapAllocList(pid uint32, heapNumOrAddress uint64) (*HeapAllocList, error)
GetHeapAllocList retrieves the heap allocation entries for a given process and heap. GetHeapAllocList returns individual allocations within a heap for process pid. heapNumOrAddress is either a heap index (0, 1, …) or the base address of the heap.
func (*Vmm) GetHeapList ¶
GetHeapList retrieves the heap entries for a given process. GetHeapList returns all heaps for process pid.
func (*Vmm) GetIATThunkInfo ¶
func (vmm *Vmm) GetIATThunkInfo(pid uint32, moduleName string, importModuleName string, importFuncName string) (*IATThunkInfo, error)
GetIATThunkInfo retrieves IAT thunk details for a specific imported function.
- pid — target process PID
- moduleName — the module that owns the IAT (e.g. "notepad.exe")
- importModuleName — the DLL being imported from (e.g. "ntdll.dll")
- importFuncName — the function name (e.g. "NtCreateFile")
func (*Vmm) GetIatList ¶
GetIatList retrieves the Import Address Table (IAT) for a given module in a process. GetIatList returns the Import Address Table for moduleName in process pid.
func (*Vmm) GetKDeviceList ¶
func (vmm *Vmm) GetKDeviceList() (*KDeviceList, error)
GetKDeviceList retrieves the list of Windows kernel device objects. Each entry includes the device's virtual address, type, associated driver object, and optional volume info.
func (*Vmm) GetKDriverList ¶
func (vmm *Vmm) GetKDriverList() (*KDriverList, error)
GetKDriverList retrieves the list of loaded Windows kernel drivers. Each entry includes the driver's virtual address, image path, service key name, and MajorFunction dispatch table.
func (*Vmm) GetKObjectList ¶
func (vmm *Vmm) GetKObjectList() (*KObjectList, error)
GetKObjectList retrieves the Windows kernel object manager directory tree. Each entry includes the object's virtual address, parent, children, name, and type.
func (*Vmm) GetModuleBase ¶
GetModuleBase returns the base virtual address of a loaded module in process pid.
func (*Vmm) GetModuleByName ¶
GetModuleByName retrieves a single module by its name for a given process. GetModuleByName returns detailed information for a specific module in process pid.
func (*Vmm) GetModuleList ¶
func (vmm *Vmm) GetModuleList(pid uint32, flags ModuleFlag) (*ModuleList, error)
GetModuleList returns all loaded modules (DLLs and EXEs) for process pid.
func (*Vmm) GetNetList ¶
GetNetList retrieves the network connections for a given process. GetNetList returns all active and recently closed network connections on the system.
func (*Vmm) GetPfnList ¶
GetPfnList retrieves Page Frame Number information for the supplied PFNs. flags: PfnFlagNormal (0) for basic info, PfnFlagExtended (1) for full extended info.
func (*Vmm) GetPhysMem ¶
func (vmm *Vmm) GetPhysMem() (*PhysMemList, error)
GetPhysMem retrieves the physical memory map of the system. Returns the list of physical memory ranges (base address and size) reported by the hardware/hypervisor.
func (*Vmm) GetPidByName ¶
GetPidByName returns the PID of the first process whose name matches processName. The match is case-insensitive and against the short (≤15 char) process name.
func (*Vmm) GetPidList ¶
GetPidList returns the PIDs of all currently running processes.
func (*Vmm) GetPoolList ¶
func (vmm *Vmm) GetPoolList(flag PoolMapFlag) (*PoolList, error)
GetPoolList retrieves kernel pool allocations. Use PoolMapFlagAll to return all allocations or PoolMapFlagBig to return only big-pool allocations.
func (*Vmm) GetProcAddress ¶
GetProcAddress returns the virtual address of an exported function in a module, equivalent to the Windows GetProcAddress API.
func (*Vmm) GetProcessDirectories ¶
func (vmm *Vmm) GetProcessDirectories(pid uint32, moduleName string) ([16]ImageDataDirectory, error)
GetProcessDirectories retrieves the 16 PE data directories of a module.
func (*Vmm) GetProcessInfo ¶
func (vmm *Vmm) GetProcessInfo(pid uint32) (*ProcessInfo, error)
GetProcessInfo returns detailed information about a single process.
func (*Vmm) GetProcessInfoAll ¶
func (vmm *Vmm) GetProcessInfoAll() ([]ProcessInfo, error)
GetProcessInfoAll returns detailed information for every running process in one call.
func (*Vmm) GetProcessInfoString ¶
func (vmm *Vmm) GetProcessInfoString(pid uint32, opt ProcessInfoStringOptions) (string, error)
GetProcessInfoString returns a specific string field for a process. opt selects which string to return (e.g. ProcessInformationOptStringCmdline for the command line).
func (*Vmm) GetProcessSections ¶
func (vmm *Vmm) GetProcessSections(pid uint32, moduleName string) ([]ImageSectionHeader, error)
GetProcessSections retrieves the sections of a module in a process.
func (*Vmm) GetPteList ¶
GetPteList retrieves the Page Table Entries (PTEs) for a given process. GetPteList returns the Page Table Entries for process pid. If identifyModules is true, vmmdll will attempt to resolve module names for each entry.
func (*Vmm) GetRegistryHives ¶
func (vmm *Vmm) GetRegistryHives() ([]RegistryHive, error)
GetRegistryHives returns all registry hives present in the memory image. Each hive includes its base address, name, short name, and path.
func (*Vmm) GetRegistrySubKeys ¶
func (vmm *Vmm) GetRegistrySubKeys(keyPath string) ([]RegistryKey, error)
GetRegistrySubKeys enumerates all sub-keys of the given registry key path. keyPath examples: "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
func (*Vmm) GetRegistryValues ¶
func (vmm *Vmm) GetRegistryValues(keyPath string) ([]RegistryValue, error)
GetRegistryValues enumerates all values of the given registry key path.
func (*Vmm) GetServiceList ¶
func (vmm *Vmm) GetServiceList() (*ServiceList, error)
GetServiceList retrieves the list of Windows services from the system. Each entry includes the service name, display name, start type, status, image path, and associated PID.
func (*Vmm) GetThreadCallstack ¶
func (vmm *Vmm) GetThreadCallstack(pid, tid uint32) (*ThreadCallstack, error)
GetThreadCallstack retrieves the callstack for a specific thread.
func (*Vmm) GetThreadList ¶
func (vmm *Vmm) GetThreadList(pid uint32) (*ThreadList, error)
GetThreadList returns all threads for process pid.
func (*Vmm) GetUnloadedModuleList ¶
func (vmm *Vmm) GetUnloadedModuleList(pid uint32) (*UnloadedModuleList, error)
GetUnloadedModuleList retrieves the list of unloaded modules for a given process. GetUnloadedModuleList returns modules that were previously loaded and then unloaded in process pid.
func (*Vmm) GetUserList ¶
GetUserList retrieves the list of user accounts found in the memory image. Each entry includes the account name (text), registry hive address, and SID.
func (*Vmm) GetVMList ¶
GetVMList retrieves the list of virtual machines detected by MemProcFS. Returns an empty list (not an error) if no VMs are present (e.g. bare-metal dump).
func (*Vmm) GetVadExList ¶
GetVadExList retrieves extended per-page VAD information for a process. oPage is the 0-based page offset into the process VAD map; cPage is the number of pages to retrieve.
func (*Vmm) GetVadList ¶
GetVadList returns the Virtual Address Descriptor entries for process pid. If identifyModules is true, vmmdll will attempt to resolve module names for each VAD region.
func (*Vmm) HiveReadEx ¶
func (vmm *Vmm) HiveReadEx(vaCMHive uint64, ra uint32, cb uint32, flags MemFlag) ([]byte, uint32, error)
HiveReadEx reads up to cb bytes from a registry hive at registry address ra. ra is the byte offset within the hive data space (regf header is NOT included). flags: use MemFlagNone (0) for default behaviour; other VMMDLL_FLAG_* values are accepted. Returns the data read and the actual byte count; a short read is not an error.
func (*Vmm) HiveWrite ¶
HiveWrite writes data to a registry hive at registry address ra. Note: requires a live/writable target — will fail on a read-only dump.
func (*Vmm) InitializePlugins ¶
InitializePlugins loads all available vmmdll plugins. Called automatically by NewVmm; exposed for manual re-initialization.
func (*Vmm) MemPrefetchPages ¶
MemPrefetchPages preloads the given virtual addresses into the memory cache. Useful to batch-warm the cache before making multiple smaller reads.
func (*Vmm) MemRead ¶
MemRead reads size bytes from virtual address addr in process pid. Use pid = PidPhysical for physical memory, or OR a PID with PidProcessWithKernelMemory to also read that process's kernel memory. Returns an error if any byte in the range is unreadable; use MemReadEx for partial reads. A zero size returns an empty slice.
func (*Vmm) MemReadEx ¶
func (vmm *Vmm) MemReadEx(pid uint32, addr uint64, size uint32, flags MemFlag) ([]byte, uint32, error)
MemReadEx reads memory with optional flags and reports the actual bytes read. NB: may return success even if fewer than size bytes were read — check bytesRead. A zero size returns an empty slice.
func (*Vmm) MemReadPage ¶
MemReadPage reads exactly one 4096-byte memory page.
func (*Vmm) MemSearch ¶ added in v0.4.0
func (vmm *Vmm) MemSearch(ctx context.Context, pid uint32, patterns []SearchPattern, opts *SearchOptions) ([]uint64, error)
MemSearch searches the memory of process pid (or physical memory when pid is PidPhysical) for any of the given patterns and returns the addresses of all hits. Addresses are roughly ascending; with several patterns the order within one 1 MiB chunk follows the pattern order.
A search may take a long time. Cancel ctx to stop it; the error is then ctx.Err() and the partial result is lost. Use MemSearchFunc to get hits as they are found.
func (*Vmm) MemSearchFunc ¶ added in v0.4.0
func (vmm *Vmm) MemSearchFunc(ctx context.Context, pid uint32, patterns []SearchPattern, opts *SearchOptions, fn func(va uint64, pattern int) bool) error
MemSearchFunc is like MemSearch but calls fn for each hit instead of collecting addresses. pattern is the index into patterns that matched. Return false from fn to stop the search; MemSearchFunc then returns nil.
fn runs on the goroutine that called MemSearchFunc, while the native search is in progress: it must not call back into the same search. A panic in fn stops the search and is re-raised after the native call returns.
func (*Vmm) MemVirt2Phys ¶
MemVirt2Phys translates virtual address va in process pid to a physical address.
func (*Vmm) MemWrite ¶
MemWrite writes data to virtual address addr in process pid. Note: requires a live/writable target — will fail on a read-only memory dump.
func (*Vmm) PdbLoad ¶
PdbLoad loads the PDB symbol file for the given module and returns the module name used internally (e.g. "nt", "kernel32"). The module name can then be passed to PdbSymbolAddress, PdbTypeSize, etc.
func (*Vmm) PdbSymbolAddress ¶
PdbSymbolAddress returns the virtual address of a symbol in the given module.
func (*Vmm) PdbSymbolName ¶
PdbSymbolName resolves a symbol name from a virtual address or offset within the given module. Also returns the displacement from the symbol start.
func (*Vmm) PdbTypeChildOffset ¶
func (vmm *Vmm) PdbTypeChildOffset(module string, typeName string, childName string) (uint32, error)
PdbTypeChildOffset returns the byte offset of a child field within a struct type.
func (*Vmm) PdbTypeSize ¶
PdbTypeSize returns the byte size of a named type in the given module.
func (*Vmm) RegQueryValueEx ¶
RegQueryValueEx queries a specific registry value by full path. keyValuePath example: "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName"
func (*Vmm) ScatterInitialize ¶
func (vmm *Vmm) ScatterInitialize(pid uint32, flags MemFlag) (*ScatterHandle, error)
ScatterInitialize creates a new scatter handle for the given PID and flags. Use pid = PidPhysical to target physical memory. The caller must call Close() to release resources.
func (*Vmm) VfsList ¶
VfsList lists entries in the given MemProcFS virtual path. Path examples: "/", "/sys", "/pid/4/modules"
func (*Vmm) VfsRead ¶
VfsRead reads up to cb bytes from a MemProcFS virtual file at the given offset. Returns the data actually read; a short read is not an error.
func (*Vmm) VfsWrite ¶
VfsWrite writes data to a MemProcFS virtual file at the given offset. Note: requires a live/writable target — will fail on a read-only dump.
func (*Vmm) VmGetVmmHandle ¶
VmGetVmmHandle returns a full VMM_HANDLE for the given virtual machine, allowing all standard Vmm methods to be used directly against the VM guest. The returned *Vmm must be closed by calling Close() when no longer needed. Physical-memory-only VMs are not supported.
func (*Vmm) VmMemTranslateGPA ¶
VmMemTranslateGPA translates a VM guest physical address (GPA) to a host physical address (PA) and/or a virtual address (VA) in the host 'vmmem' process. Pass nil for outputs you do not need.
func (*Vmm) VmMemWrite ¶
VmMemWrite writes data to guest physical address qwGPA inside the VM.
func (*Vmm) VmScatterInitialize ¶
func (vmm *Vmm) VmScatterInitialize(vm *VmEntry) (*ScatterHandle, error)
VmScatterInitialize returns a ScatterHandle for efficient scatter-read/write of guest physical address (GPA) memory inside a virtual machine. The handle must be closed with Close() when no longer needed.
func (*Vmm) YaraSearch ¶ added in v0.4.0
func (vmm *Vmm) YaraSearch(ctx context.Context, pid uint32, rules []string, opts *SearchOptions) ([]uint64, error)
YaraSearch scans the memory of process pid (or physical memory when pid is PidPhysical) with YARA rules and returns the addresses of all matched strings.
Each element of rules is either YARA rule source text or a path to a rules file. Alternatively rules may hold a single path to a compiled rules file. The search needs the vmmyara library next to the vmmdll library; if it is missing or the rules do not compile, ErrSearchFailed is returned.
Cancel ctx to stop the search; the error is then ctx.Err().
func (*Vmm) YaraSearchFunc ¶ added in v0.4.0
func (vmm *Vmm) YaraSearchFunc(ctx context.Context, pid uint32, rules []string, opts *SearchOptions, fn func(*YaraMatch) bool) ([]uint64, error)
YaraSearchFunc is like YaraSearch but also calls fn for each rule match with details about the rule. Return false from fn to stop the search; YaraSearchFunc then returns nil. The returned addresses are those found before the search ended; they are nil if fn stopped it.
fn runs on the goroutine that called YaraSearchFunc, while the native search is in progress. A panic in fn stops the search and is re-raised after the native call returns.
type WinProcessInfo ¶
type WinProcessInfo struct {
EPROCESS uint64
PEB uint64
Reserved1 uint64
IsWow64 uint32 // BOOL
PEB32 uint32
SessionID uint32
LUID uint64
SIDRaw [260]byte
IntegrityLevel ProcessIntegrityLevel
// contains filtered or unexported fields
}
WinProcessInfo mirrors the nested 'win' struct from VMMDLL_PROCESS_INFORMATION
type YaraMatch ¶ added in v0.4.0
type YaraMatch struct {
Rule string
Tags []string
Meta []YaraMeta
Strings []YaraString
}
YaraMatch describes a YARA rule that matched during YaraSearchFunc. MemProcFS scans memory in chunks of up to 1 MiB, so one rule may be reported once per chunk it matches in.
type YaraString ¶ added in v0.4.0
type YaraString struct {
// Pattern is the string's data as defined in the rule (e.g. the text of a
// text string), not its $identifier. It ends at the first zero byte.
Pattern string
Addresses []uint64
}
YaraString is one string of a matched YARA rule with the addresses where it matched. The native library reports at most 24 addresses per string per chunk.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
cmd/layoutgen
command
Command layoutgen writes layout_test.go: a table of sizes and field offsets that the Go mirrors of vmmdll.h structs must match.
|
Command layoutgen writes layout_test.go: a table of sizes and field offsets that the Go mirrors of vmmdll.h structs must match. |