⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 virtualalloccopy.c

📁 X-scale 27x 平台
💻 C
字号:
//
// Copyright (c) Chrontel Inc.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Chrontel end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

Module Name:  
   VirtualAllocCopy.c
   
Abstract:  
   Mapping physical memory & register to virtual memory under Windows CE

Revision:
   11/11/02  Created by Roger Yu.     

Notes: 
--*/
#include <windows.h>
#include <ceddk.h>
#include <devload.h>
#include <winreg.h>


#include "chrontel.h"


#define PHY_PAGE_SIZE 0x1000
#define ALIGNMENT_MASK (PHY_PAGE_SIZE-1)

PVOID VirtualAllocCopy(unsigned size,PVOID *vpBase,PVOID pPhysicalAddress)
{
	PVOID ptr;
    unsigned offset;

	offset = (unsigned)pPhysicalAddress & ALIGNMENT_MASK;

	size +=offset ? PHY_PAGE_SIZE : 0;
	*vpBase = NULL;
	ptr = VirtualAlloc(0,size,MEM_RESERVE,PAGE_NOACCESS);
	if (ptr == NULL) {
		ERRORMSG(1,(TEXT("VirtualAlloc [0x%x] failed  : size=0x%x, (0x%x)\r\n"),
			      pPhysicalAddress,size,GetLastError()));
		return(0);
	}
    
	if (!wrapVirtualCopy((PVOID)ptr,(PVOID)((unsigned)pPhysicalAddress - offset),size,PAGE_READWRITE|PAGE_NOCACHE)) {
		ERRORMSG(1,(TEXT("VirtualCopy [0x%x] failed to addr=0x%x, offset=0x%x(0x%x)\r\n"),(unsigned)pPhysicalAddress, ptr, offset,GetLastError()));
		return(0);
	}  
	*vpBase = ptr;
	return((PVOID)((PBYTE)ptr+offset));
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -