• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ MmUnmapIoSpace函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中MmUnmapIoSpace函数的典型用法代码示例。如果您正苦于以下问题:C++ MmUnmapIoSpace函数的具体用法?C++ MmUnmapIoSpace怎么用?C++ MmUnmapIoSpace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MmUnmapIoSpace函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: peChecksumExecSections

uint32 peChecksumExecSections(uint8 *peBaseAddr, 
                              void *realBase, 
                              PEPROCESS proc, 
                              PKAPC_STATE apc, 
                              PHYSICAL_ADDRESS *physArr)
{
    uint16 numExecSections = peGetNumExecSections(peBaseAddr);
    uint32 checksum = 0, k, i, j, 
                        numRelocs = peGetNumberOfRelocs(peBaseAddr, realBase, proc, apc), 
                        relocDelta = peCalculateRelocDiff(peBaseAddr, realBase);
    uint8 *dataPtr = NULL;
    PHYSICAL_ADDRESS phys = {0};
    SectionData *execSections = (SectionData *) MmAllocateNonCachedMemory(
                                                numExecSections * sizeof(SectionData));
    peGetExecSections(peBaseAddr, execSections);
    
    //DbgPrint("Found %d relocations, delta of: %x\r\n", numRelocs, relocDelta);
    
    for (i = 0; i < numExecSections; i++)
    {   
        uint32 numpages = execSections[i].Size / 0x1000, size = execSections[i].Size;
        if (numpages * 0x1000 < execSections[i].Size)
            numpages++;
        for (k = 0; k < numpages; k++)
        {
            KeStackAttachProcess(proc, apc); 
            dataPtr = (uint8 *) MmMapIoSpace(MmGetPhysicalAddress((void *)(((uint32) realBase) +
                        execSections[i].VirtualAddress + (0x1000 * k))),
                        0x1000, 0);
            phys = MmGetPhysicalAddress((void *) dataPtr);

            for (j = 0; j < min(size, 0x1000); j++)
            {
                checksum += dataPtr[j];
            }
            MmUnmapIoSpace((void *) dataPtr, 0x1000);
            size -= 0x1000;
            KeUnstackDetachProcess(apc);
        }
    }
    
    // Subtract the relocations from the checksum
    // TODO Fix incase of lower load address
    checksum += numRelocs * (relocDelta & 0x000000FF);
    checksum += numRelocs * ((relocDelta & 0x0000FF00) >> 8);
    checksum += numRelocs * ((relocDelta & 0x00FF0000) >> 16);
    checksum += numRelocs * ((relocDelta & 0xFF000000) >> 24);
    
    
    MmFreeNonCachedMemory((void *) execSections, numExecSections * sizeof(SectionData));
    return checksum;
}
开发者ID:ainfosec,项目名称:MoRE,代码行数:52,代码来源:pe.c


示例2: FreeDMABuffers

CRomiDisk::~CRomiDisk(
    )
{
    FreeDMABuffers();

    if ( m_vpSYSCONRegs)
    {
        MmUnmapIoSpace((PVOID)m_vpSYSCONRegs, sizeof(S3C6410_SYSCON_REG));
        m_vpSYSCONRegs= NULL;
    }

    if ( m_vpIOPORTRegs)
    {
        MmUnmapIoSpace((PVOID)m_vpIOPORTRegs, sizeof(S3C6410_GPIO_REG));
        m_vpIOPORTRegs= NULL;
    }

    if ( m_pDMAVirtualAddress )
    {
        PHYSICAL_ADDRESS PhysicalAddress;

        PhysicalAddress.LowPart = m_DMAPhyaddress.LowPart;
        HalFreeCommonBuffer(0, 0, PhysicalAddress, (PVOID)m_pDMAVirtualAddress, FALSE);
        m_pDMAVirtualAddress = NULL;
    }

    InterlockedDecrement(&m_lDeviceCount);

    DEBUGMSG(ZONE_INIT|ZONE_PCI, (_T(
        "Atapi!CRomiDisk::~CRomiDisk> device count(%d)\r\n"
        ), m_lDeviceCount));
}
开发者ID:HITEG,项目名称:TenByTen6410_SLC,代码行数:32,代码来源:atapiRomi.cpp


示例3: CameraDeinit

void CameraDeinit()
{
    RETAILMSG(CAM_INOUT,(TEXT("++++++++++++++++++CameraDeInit\n")));

    if(s6410IOP != NULL)
    {
        MmUnmapIoSpace((PVOID)s6410IOP, sizeof(S3C6410_GPIO_REG));
        s6410IOP = NULL;
    }
    if(s6410CAM != NULL)
    {
        MmUnmapIoSpace((PVOID)s6410CAM, sizeof(S3C6410_CAMIF_REG));
        s6410CAM = NULL;
    }
    if(s6410PWR != NULL)
    {
        MmUnmapIoSpace((PVOID)s6410PWR, sizeof(S3C6410_SYSCON_REG));
        s6410PWR = NULL;
    }

    ModuleDeinit();
    DeinitializeBuffer();

    
//    CloseHandle(hCaptureThread);
//    CloseHandle(hPreviewThread);
    bCaptureThreadExit = TRUE;
    SetEvent(hCaptureEvent);
    bPreviewThreadExit = TRUE;
    SetEvent(hPreviewEvent);
    CloseHandle(hCaptureEvent);
    CloseHandle(hPreviewEvent);
    RETAILMSG(CAM_INOUT,(TEXT("------------------CameraDeInit\n")));
}
开发者ID:HITEG,项目名称:TenByTen6410_SLC,代码行数:34,代码来源:s3c6410_camera.cpp


示例4: BspBattDeallocResource

/*************************************************************************************
// 		Function: BspBattDeallocResource
// 	     Purpose:dellloc resource for battery driver
//       Returns: N/A
//***********************************************************************************/
void 
BspBattDeallocResource( void)
{
	DPNOK(0);
    DeinitPinMuxMutex(g_hADCMutex);
    g_hADCMutex = NULL;

    g_bLedThreadExit = TRUE;
    if(g_hevLEDStatus)
        CloseHandle(g_hevLEDStatus);
        g_hevLEDStatus = NULL;	
    if(g_hNotifyLedThread)
        CloseHandle(g_hNotifyLedThread);
        g_hNotifyLedThread = NULL;	
    if (g_hevBatteryStatus)
	CloseHandle(g_hevBatteryStatus);
    g_hevBatteryStatus = NULL;

#if 1
	DPSTR("MmUnmapIoSpace");
	MmUnmapIoSpace(g_pBspArgs, sizeof(BSP_ARGS));
	MmUnmapIoSpace(v_p2450IOP, sizeof(S3C2450_IOPORT_REG));
	MmUnmapIoSpace(v_pADCregs, sizeof(S3C2450_ADC_REG));
	MmUnmapIoSpace(v_pUSBCtrlAddr, sizeof(S3C2450_USBD_REG));	
#endif
 	

	
	
//    BspPowerStatesManagerDeInit();
//    CspRegUnMap();
}//endof BspBatDeallocResource
开发者ID:blackfa1con,项目名称:openembed,代码行数:37,代码来源:bspbattpdd.c


示例5: SMARTREFLEX_DeinitPolicy

//-----------------------------------------------------------------------------
//
//  Function:  SMARTREFLEX_DeinitPolicy
//
//  Policy uninitialization
//
BOOL
SMARTREFLEX_DeinitPolicy(
    HANDLE hPolicyAdapter
    )
{
    BOOL rc = FALSE;

    RETAILMSG(ZONE_FUNCTION, (
      L"+SMARTREFLEX_DeinitPolicy(0x%08x)\r\n",
      hPolicyAdapter
      ));

    // validate parameters
    if (hPolicyAdapter != (HANDLE)&s_SmartReflexLoadPolicyInfo)
        {
        RETAILMSG (ZONE_ERROR, (L"ERROR: SMARTREFLEX_DeinitPolicy:"
            L"Incorrect context parameter\r\n"
            ));
        goto cleanUp;
        }

    //unmap vdd1 voltage register to virtual memory
    MmUnmapIoSpace(s_VddOptimizationInfo[0].pPrcmRegistryAddress,sizeof(UINT32));

    //unmap vdd2 voltage register to virtual memory
    MmUnmapIoSpace(s_VddOptimizationInfo[1].pPrcmRegistryAddress,sizeof(UINT32));

    //unregisted DVFS change callback function
    PmxUnregisterConstraintCallback(s_SmartReflexLoadPolicyInfo.hDvfsConstraint,
                                    DvfsConstraintCallback
                                    );

    //release DVFS constraint handler
    PmxReleaseConstraint(s_SmartReflexLoadPolicyInfo.hDvfsConstraint);

    //stop thread gracefuly
    if (s_SmartReflexLoadPolicyInfo.hSmartReflexSensingThread != NULL)
        {
        s_SmartReflexLoadPolicyInfo.bExitThread = TRUE;
        SetEvent(s_SmartReflexLoadPolicyInfo.hSmartReflexSensingEvent);
        WaitForSingleObject(s_SmartReflexLoadPolicyInfo.hSmartReflexSensingThread, INFINITE);
        CloseHandle(s_SmartReflexLoadPolicyInfo.hSmartReflexSensingThread);
        }

    //close sync event hanle
    CloseHandle(s_SmartReflexLoadPolicyInfo.hSmartReflexSensingEvent);

    // clear main policy structure
    memset(&s_SmartReflexLoadPolicyInfo, 0, sizeof(SmartReflexPolicyInfo_t));

    rc = TRUE;

cleanUp:
    RETAILMSG(ZONE_FUNCTION, (L"-SMARTREFLEX_DeinitPolicy()\r\n"));
    return rc;
}
开发者ID:zizilala,项目名称:projects_wince_AA,代码行数:62,代码来源:smartreflexpolicy.cpp


示例6: PLxEvtDeviceReleaseHardware

NTSTATUS
PLxEvtDeviceReleaseHardware(
    IN  WDFDEVICE Device,
    IN  WDFCMRESLIST ResourcesTranslated
    )
/*++

Routine Description:

    Unmap the resources that were mapped in PLxEvtDevicePrepareHardware.
    This will only be called when the device stopped for resource rebalance,
    surprise-removed or query-removed.

Arguments:

    Device - A handle to the WDFDEVICE

    ResourcesTranslated - The translated PnP resources associated with the
        device.  This is what is important to a PCI device.

Return Value:

    NT status code - failure will result in the device stack being torn down

--*/
{
	KdPrint(("Entry PLxEvtDeviceReleaseHardware Routine"));
    PDEVICE_EXTENSION   devExt;
    NTSTATUS status = STATUS_SUCCESS;

    UNREFERENCED_PARAMETER(ResourcesTranslated);

    PAGED_CODE();

    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP,
                "--> PLxEvtDeviceReleaseHardware");

    devExt = PLxGetDeviceContext(Device);

    if (devExt->RegsBase) {

        MmUnmapIoSpace(devExt->RegsBase, devExt->RegsLength);
        devExt->RegsBase = NULL;
    }

    if(devExt->SRAMBase){
        MmUnmapIoSpace(devExt->SRAMBase, devExt->SRAMLength);
        devExt->SRAMBase = NULL;
    }

    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP,
                "<-- PLxEvtDeviceReleaseHardware");

	KdPrint(("Leave PLxEvtDeviceReleaseHardware Routine"));
    return status;
}
开发者ID:SagittariusWarrior,项目名称:WinDriver,代码行数:56,代码来源:Pci9656.c


示例7: ScrLoadFontTable

VOID
ScrLoadFontTable(UINT32 CodePage)
{
    PHYSICAL_ADDRESS BaseAddress;
    PUCHAR Bitplane;
    PUCHAR FontBitfield = NULL;
    NTSTATUS Status = STATUS_SUCCESS;

    FontBitfield = (PUCHAR) ExAllocatePoolWithTag(NonPagedPool, 2048, TAG_BLUE);
    if(FontBitfield)
    {
        /* open bit plane for font table access */
        OpenBitPlane();

        /* get pointer to video memory */
        BaseAddress.QuadPart = BITPLANE_BASE;
        Bitplane = (PUCHAR)MmMapIoSpace (BaseAddress, 0xFFFF, MmNonCached);

        Status = ExtractFont(CodePage, FontBitfield);
        if (NT_SUCCESS(Status))
            LoadFont(Bitplane, FontBitfield);

        MmUnmapIoSpace(Bitplane, 0xFFFF);
        ExFreePool(FontBitfield);

        /* close bit plane */
        CloseBitPlane();
    }
}
开发者ID:RareHare,项目名称:reactos,代码行数:29,代码来源:font.c


示例8: SynthCleanup

VOID
SynthCleanup(
    IN   PGLOBAL_SYNTH_INFO pGDI
)

/*++

Routine Description:

    Clean up all resources allocated by our initialization

Arguments:

    pGDI - Pointer to global data

Return Value:

    NONE

--*/

{
    //
    //  Owning driver will remove all devices and free global data
    //

    if (pGDI->Hw.SynthBase && pGDI->MemType == 0) {
        ASSERT(pGDI->Key == SYNTH_KEY);
        MmUnmapIoSpace(pGDI->Hw.SynthBase, NUMBER_OF_SYNTH_PORTS);
    }
    pGDI->Hw.SynthBase = NULL;
}
开发者ID:BillTheBest,项目名称:WinNT4,代码行数:32,代码来源:synth.c


示例9: HelpMapMMIOSpace

// HelpMapMMIOSpace: Map MMIO space
bool HelpMapMMIOSpace(
    uint64  address,         // IN
    size_t  size,            // IN
    uint64* mappedAddress,   // OUT
    uint64* mappedSize)      // OUT
{
    bool result = false;
    void* pLinearAddress = NULL;
    PHYSICAL_ADDRESS physicalAddress;

    ResetPoolMemory(&physicalAddress, sizeof(PHYSICAL_ADDRESS));
    physicalAddress.QuadPart = address;

    pLinearAddress = static_cast<PUCHAR>(MmMapIoSpace(physicalAddress, size, MmNonCached));

    if (NULL != pLinearAddress)
    {
        if (MmIsAddressValid(pLinearAddress))
        {
            *mappedAddress = reinterpret_cast<uint64>(pLinearAddress);
            *mappedSize = size;
            result = true;
        }
        else
        {
            MmUnmapIoSpace(pLinearAddress, size);
        }
    }

    return result;
}
开发者ID:PlusChie,项目名称:CodeXL,代码行数:32,代码来源:AMDTHelpers.cpp


示例10: sizeof

// The function that initilize the register for HSMMC Control.
BOOL CSDHControllerCh1::InitHSMMC() {
    volatile S3C6410_HSMMC_REG *pHSMMC = NULL;
    PHYSICAL_ADDRESS    ioPhysicalBase = {0,0};

    ioPhysicalBase.LowPart = S3C6410_BASE_REG_PA_HSMMC1;
    pHSMMC = (volatile S3C6410_HSMMC_REG *)MmMapIoSpace(ioPhysicalBase, sizeof(S3C6410_HSMMC_REG), FALSE);
    if (pHSMMC == NULL) {
        RETAILMSG(TRUE, (TEXT("[HSMMC1] HSMMC Special Register is *NOT* mapped.\n")));
        return FALSE;
    }

#ifdef _SRCCLK_48MHZ_
    RETAILMSG(TRUE, (TEXT("[HSMMC1] Setting registers for the USB48MHz (EXTCLK) : HSMMCCon.\n")));
    // Set the clock source to USB_PHY for CLKMMC1
    pHSMMC->CONTROL2 = (pHSMMC->CONTROL2 & ~(0xffffffff)) |
        (0x3<<9) |  // Debounce Filter Count 0x3=64 iSDCLK
        (0x1<<8) |  // SDCLK Hold Enable
        (0x3<<4);   // Base Clock Source = External Clock
#else
    RETAILMSG(TRUE, (TEXT("[HSMMC1] Setting registers for the EPLL : HSMMCCon.\n")));
    // Set the clock source to EPLL out for CLKMMC1
    pHSMMC->CONTROL2 = (pHSMMC->CONTROL2 & ~(0xffffffff)) |
        (0x3<<9) |  // Debounce Filter Count 0x3=64 iSDCLK
        (0x1<<8) |  // SDCLK Hold Enable
        (0x2<<4);   // Base Clock Source = EPLL out
#endif

    MmUnmapIoSpace((PVOID)pHSMMC, sizeof(S3C6410_HSMMC_REG));
    return TRUE;
}
开发者ID:HITEG,项目名称:TenByTen6410_SLC,代码行数:31,代码来源:s3c6410_hsmmc.cpp


示例11: XenGfxFreeResources

VOID
XenGfxFreeResources(XENGFX_DEVICE_EXTENSION *pXenGfxExtension)
{
    PAGED_CODE();
    // T & S Level 3
    XenGfxDisableVCrtcs(pXenGfxExtension);

    if (pXenGfxExtension->pSources != NULL) {
        ExFreePoolWithTag(pXenGfxExtension->pSources, XENGFX_TAG);
        pXenGfxExtension->pSources = NULL;
    }

    XenGfxFreeVCrtcBanks(pXenGfxExtension);

    if (pXenGfxExtension->pXgfxRegs != NULL) {
        MmUnmapIoSpace(pXenGfxExtension->pXgfxRegs,
                       pXenGfxExtension->XgfxRegistersDescriptor.u.Memory.Length);
        pXenGfxExtension->pXgfxRegs = NULL;
        pXenGfxExtension->pGartRegs = NULL;
        pXenGfxExtension->pVCrtcsRegs = NULL;
        pXenGfxExtension->pGlobalRegs = NULL;        
        pXenGfxExtension->pGartBaseReg = NULL;
    }

    RtlZeroMemory(&pXenGfxExtension->GraphicsApertureDescriptor,
                  sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
    RtlZeroMemory(&pXenGfxExtension->XgfxRegistersDescriptor,
                  sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));

    pXenGfxExtension->pPhysicalDeviceObject = NULL;
    pXenGfxExtension->hDxgkHandle = NULL;
}
开发者ID:OpenXT,项目名称:xc-windows,代码行数:32,代码来源:misc.c


示例12: MmUnmapIoSpace

 ~CPdd6410Serial3()
 {
     if(m_pSysconRegs)
     {
         m_pSysconRegs->PCLK_GATE  &= ~PCLK_UART3;        // UART3
         m_pSysconRegs->SCLK_GATE  &= ~SCLK_UART;        // UART0~3
     }
     if (m_pIOPregs!=NULL)
     {
         MmUnmapIoSpace((PVOID)m_pIOPregs, sizeof(S3C6410_GPIO_REG));
     }
     if (m_pSysconRegs!=NULL)
     {
         MmUnmapIoSpace((PVOID)m_pSysconRegs, sizeof(S3C6410_SYSCON_REG));
     }
 }
开发者ID:hibive,项目名称:sjmt6410pm090728,代码行数:16,代码来源:ser_smdk6410.cpp


示例13: NdisMUnmapIoSpace

/*
 * @implemented
 */
VOID
EXPORT
NdisMUnmapIoSpace(
    IN  NDIS_HANDLE MiniportAdapterHandle,
    IN  PVOID       VirtualAddress,
    IN  UINT        Length)
/*
 * FUNCTION: Un-maps space previously mapped with NdisMMapIoSpace
 * ARGUMENTS:
 *     MiniportAdapterHandle: handle originally passed into MiniportInitialize
 *     VirtualAddress: Address to un-map
 *     Length: length of the mapped memory space
 * NOTES:
 *     - Must be called at IRQL = PASSIVE_LEVEL
 *     - Must only be called from MiniportInitialize and MiniportHalt
 *     - See also: NdisMMapIoSpace
 * BUGS:
 *     - Depends on MmUnmapIoSpace to Do The Right Thing in all cases
 */
{
  PAGED_CODE();

  ASSERT(MiniportAdapterHandle);

  MmUnmapIoSpace(VirtualAddress, Length);
}
开发者ID:GYGit,项目名称:reactos,代码行数:29,代码来源:io.c


示例14: InitModem

CPdd6410Uart::~CPdd6410Uart()
{
    InitModem(FALSE);
    if (m_hISTEvent)
    {
        m_bTerminated=TRUE;
        ThreadStart();
        SetEvent(m_hISTEvent);
        ThreadTerminated(1000);
        InterruptDisable( m_dwSysIntr );         
        CloseHandle(m_hISTEvent);
    };
    if (m_pReg6410Uart)
    {
        delete m_pReg6410Uart;
    }
    if (m_XmitFlushDone)
    {
        CloseHandle(m_XmitFlushDone);
    }
    if (m_pRegVirtualAddr != NULL)
    {
        MmUnmapIoSpace((PVOID)m_pRegVirtualAddr,sizeof(S3C6410_UART_REG));
    }        
}
开发者ID:HITEG,项目名称:TenByTen6410_SLC,代码行数:25,代码来源:pdds3c6410_ser.cpp


示例15: TpmEvtDeviceReleaseHardware

NTSTATUS
TpmEvtDeviceReleaseHardware(
							IN  WDFDEVICE Device,
							IN  WDFCMRESLIST ResourcesTranslated
    )
{
    PTPM_CONTEXT                TpmContext;

	PAGED_CODE();

    TpmContext = GetTpmContext(Device);

    KdPrintEx((DPFLTR_PNPMEM_ID, DPFLTR_INFO_LEVEL,
        "TpmEvtDeviceReleaseHardware\n"));

#if _NT_TARGET_VERSION >= 0x601
    if(TpmContext->hEntropySource)
        EntropyUnregisterSource(TpmContext->hEntropySource);
    TpmContext->hEntropySource = NULL;
#endif

    if(TpmContext->MemAddr)
        MmUnmapIoSpace(TpmContext->MemAddr,TpmContext->MemLen);
    TpmContext->MemAddr = NULL;
    TpmContext->MemLen  = 0;

    KdPrintEx((DPFLTR_PNPMEM_ID, DPFLTR_INFO_LEVEL,
        "TpmEvtDeviceReleaseHardware exited with Status code 0x%x\n",STATUS_SUCCESS));

    return STATUS_SUCCESS;
}
开发者ID:aldertotori,项目名称:windows-tpm-1.2-wdf-driver,代码行数:31,代码来源:tpm.c


示例16: BalloonEvtDeviceReleaseHardware

NTSTATUS
BalloonEvtDeviceReleaseHardware (
    IN WDFDEVICE      Device,
    IN WDFCMRESLIST   ResourcesTranslated
    )
{
    PDEVICE_CONTEXT     devCtx = NULL;

    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "--> %s\n", __FUNCTION__);

    UNREFERENCED_PARAMETER(ResourcesTranslated);

    PAGED_CODE();

    devCtx = GetDeviceContext(Device);

    if(devCtx->PortBase && devCtx->PortMapped)
    {
        MmUnmapIoSpace( devCtx->PortBase,  devCtx->PortCount );
    }

    devCtx->PortBase = NULL;

    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "<-- %s\n", __FUNCTION__);
    return STATUS_SUCCESS;
}
开发者ID:allen-junkang-fu,项目名称:kvm-guest-drivers-windows,代码行数:26,代码来源:Device.c


示例17: MmUnmapIoSpace

RegCtrlG2D::~RegCtrlG2D()
{
    if (m_pG2DReg != NULL)
    {
        MmUnmapIoSpace((PVOID)m_pG2DReg, sizeof(G2D_REG));
        m_pG2DReg = NULL;
    }
}
开发者ID:hibive,项目名称:sjmt6410pm090728,代码行数:8,代码来源:regctrl_g2d.cpp


示例18: HalpUnmapVirtualAddress

VOID
NTAPI
HalpUnmapVirtualAddress(IN PVOID VirtualAddress,
                        IN ULONG NumberPages)
{
    /* Use kernel memory manager I/O map facilities */
    MmUnmapIoSpace(VirtualAddress, NumberPages << PAGE_SHIFT);
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:8,代码来源:misc.c


示例19: peGetNumberOfRelocs

uint32 peGetNumberOfRelocs(uint8 *peBaseAddr, void *realBase, PEPROCESS proc, PKAPC_STATE apc)
{
    ImageDosHeader *dosHeader = NULL;
    ImageNtHeaders *ntHeaders = NULL;
    ImageSectionHeader *sectionHeader = NULL;
    ImageBaseRelocation *relocationPtr = NULL, *bkupRPtr = NULL;
    uint32 numRelocs = 0;
    PageTableEntry *pte = NULL;
    PHYSICAL_ADDRESS phys = {0};
    
    uint16 i, j = 0, execSectionCount = 0, numSections = 0;
    
    dosHeader = (ImageDosHeader *) peBaseAddr;
    ntHeaders = (ImageNtHeaders *) ((uint8 *) peBaseAddr + dosHeader->e_lfanew);
    numSections = ntHeaders->FileHeader.NumberOfSections;
    sectionHeader = (ImageSectionHeader *) &ntHeaders[1];
    
    for (i = 0; i < numSections; i++)
    {
        if(strncmp(sectionHeader[i].Name, ".reloc", 8) == 0)
            break;
    }
    if(strncmp(sectionHeader[i].Name, ".reloc", 8) != 0)
            return 0;
    /*DbgPrint("Found %.08s RVA: %x Characteristics: %x", sectionHeader[i].Name, 
                                                        sectionHeader[i].VirtualAddress,
                                                        sectionHeader[i].Characteristics);*/

    //KeStackAttachProcess(proc, apc);
    pte = pagingMapInPte(targetCR3, (uint8 *) (((uint32) realBase) +
                                sectionHeader[i].VirtualAddress));
    if (pte == NULL)
        return 0;
    phys.LowPart = pte->address << 12;
    pagingMapOutEntry(pte);

    relocationPtr = (ImageBaseRelocation *) MmMapIoSpace(phys,
            PAGE_SIZE,
            0);
    bkupRPtr = relocationPtr;        
    /*DbgPrint("%p + %x = %x", realBase, sectionHeader[i].VirtualAddress, (((uint32) realBase) +
                                sectionHeader[i].VirtualAddress));*/
    i = 0;
    do
    {       
        //DbgPrint("RP: %x %x\r\n", relocationPtr->VirtualAddress, relocationPtr->SizeOfBlock); 
        numRelocs += (relocationPtr->SizeOfBlock - sizeof(*relocationPtr)) / sizeof(uint16);
        relocationPtr = (ImageBaseRelocation *) ((uint8 *) relocationPtr + relocationPtr->SizeOfBlock);
        i++;
    } while(relocationPtr->SizeOfBlock != 0);
    MmUnmapIoSpace(bkupRPtr, PAGE_SIZE);
    //KeUnstackDetachProcess(apc);
   //DbgPrint("I %d\r\n", i);
   
    // Size of the table (minus the header) divided by the size of each entry
    // FIXME Figure out why this is the case
    return numRelocs - (i);
}
开发者ID:ainfosec,项目名称:MoRE,代码行数:58,代码来源:pe.c


示例20: PushUnload

VOID
PushUnload( DRIVER_OBJECT* DriverObject )
{
    UNICODE_STRING DeviceLinkU;
    NTSTATUS ntStatus;
    PMAPINFO pMapInfo;
    PSINGLE_LIST_ENTRY pLink;

    DbgPrint("[Push] => (PushUnload)");

    RdUnload(DriverObject);

    //free resources
    pLink=PopEntryList(&lstMapInfo);
    while(pLink)
    {
        pMapInfo=CONTAINING_RECORD(pLink, MAPINFO, link);

        MmUnmapLockedPages(pMapInfo->pvu, pMapInfo->pMdl);
        IoFreeMdl(pMapInfo->pMdl);
        MmUnmapIoSpace(pMapInfo->pvk, pMapInfo->memSize);

        ExFreePool(pMapInfo);

        pLink=PopEntryList(&lstMapInfo);
    }


    //
    //  By default the I/O device is configured incorrectly or the
    // configuration parameters to the driver are incorrect.
    //
    ntStatus = STATUS_DEVICE_CONFIGURATION_ERROR;

    //
    // restore the call back routine, thus givinig chance to the
    // user mode application to unload dynamically the driver
    //
    ntStatus = PsSetCreateProcessNotifyRoutine(ProcessCallback, TRUE);

    IoDeleteDevice(DriverObject->DeviceObject);

    RtlInitUnicodeString(&DeviceLinkU, PUSH_SYMLINK_NAME);

    ntStatus=IoDeleteSymbolicLink(&DeviceLinkU);

    if (NT_SUCCESS(ntStatus))
    {
        IoDeleteDevice(DriverObject->DeviceObject);
    }
    else
    {
        DbgPrint("Error: IoDeleteSymbolicLink failed");
    }

    DbgPrint("[Push] <= (PushUnload)");
}
开发者ID:Volkanite,项目名称:Push,代码行数:57,代码来源:push0.c



注:本文中的MmUnmapIoSpace函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MmioRead32函数代码示例发布时间:2022-05-30
下一篇:
C++ MmIsAddressValid函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap