Exemplo n.º 1
0
/// <summary>
/// Adjust image memory protection
/// </summary>
/// <param name="pImage">image data</param>
/// <returns>true on success</returns>
bool MMap::ProtectImageMemory( ImageContext* pImage )
{
    // Set section memory protection
    for (auto& section : pImage->PEImage.sections())
    {
        auto prot = GetSectionProt( section.Characteristics );
        if (pImage->imgMem.Protect( prot, section.VirtualAddress, section.Misc.VirtualSize ) != STATUS_SUCCESS)
            return false;
    }

    return true;
}
Exemplo n.º 2
0
	bool MMap::ProtectImageMemory(ImageContext* pImage) {
		// Set section memory protection
		for(auto& section : pImage->peImage.Sections()) {
			auto prot = GetSectionProt(section.Characteristics);
			if(prot != PAGE_NOACCESS) {
				if(pImage->imgMem.Protect(prot, section.VirtualAddress, section.Misc.VirtualSize) != STATUS_SUCCESS) {
					BLACBONE_TRACE(
						L"ManualMap: Failed to set section memory protection at offset 0x%x. Status = 0x%x",
						section.VirtualAddress, LastNtStatus()
						);
					return false;
				}
			}
			// Decommit pages with NO_ACCESS protection
			else {
				_process.Memory().Free(pImage->imgMem.Ptr() + section.VirtualAddress, section.Misc.VirtualSize, MEM_DECOMMIT);
			}
		}
		return true;
	}