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

📄 pm.c

📁 BIOS emulator and interface to Realmode X86 Emulator Library Can emulate a PCI Graphic Controller V
💻 C
📖 第 1 页 / 共 3 页
字号:
{	return "c:\\";}/****************************************************************************REMARKS:Return the path to the Nucleus driver files.****************************************************************************/const char * PMAPI PM_getNucleusPath(void){	static char path[256];	char 		*env;	if ((env = getenv("NUCLEUS_PATH")) != NULL)		return env;	GetSystemDirectory(path,sizeof(path));	strcat(path,"\\nucleus");	return path;}/****************************************************************************REMARKS:Return the path to the Nucleus configuration files.****************************************************************************/const char * PMAPI PM_getNucleusConfigPath(void){	static char path[256];	strcpy(path,PM_getNucleusPath());	PM_backslash(path);	strcat(path,"config");	return path;}/****************************************************************************REMARKS:Return a unique identifier for the machine if possible.****************************************************************************/const char * PMAPI PM_getUniqueID(void){	return PM_getMachineName();}/****************************************************************************REMARKS:Query a string from the registry (extended version).****************************************************************************/static ibool REG_queryStringEx(	HKEY hKey,	const char *szValue,	char *value,	ulong size){	DWORD	type;	if (RegQueryValueEx(hKey,(PCHAR)szValue,(PDWORD)NULL,(PDWORD)&type,(LPBYTE)value,(PDWORD)&size) == ERROR_SUCCESS)		return true;	return false;}/****************************************************************************REMARKS:Query a string from the registry.****************************************************************************/static ibool REG_queryString(	const char *szKey,	const char *szValue,	char *value,	DWORD size){	HKEY 	hKey;	ibool	status = false;	memset(value,0,sizeof(value));	if (RegOpenKey(HKEY_LOCAL_MACHINE,szKey,&hKey) == ERROR_SUCCESS) {    	status = REG_queryStringEx(hKey,szValue,value,size);		RegCloseKey(hKey);		}	return status;}/****************************************************************************REMARKS:Get the name of the machine on the network.****************************************************************************/const char * PMAPI PM_getMachineName(void){	static char name[256];	if (REG_queryString(szMachineNameKey,szMachineName,name,sizeof(name)))		return name;	if (REG_queryString(szMachineNameKeyNT,szMachineName,name,sizeof(name)))		return name;	return "Unknown";}/****************************************************************************REMARKS:Return a pointer to the real mode BIOS data area.****************************************************************************/void * PMAPI PM_getBIOSPointer(void){	return (void*)0x400;}/****************************************************************************REMARKS:Return a pointer to 0xA0000 physical VGA graphics framebuffer.****************************************************************************/void * PMAPI PM_getA0000Pointer(void){	/* Always use the 0xA0000 linear address so that we will use	 * whatever page table mappings are set up for us (ie: for virtual	 * bank switching.     */	return (void*)0xA0000;}/****************************************************************************REMARKS:Map a physical address to a linear address in the callers process.****************************************************************************/void * PMAPI PM_mapPhysicalAddr(	ulong base,	ulong limit,	ibool isCached){	DWORD	inBuf[3];	/* Buffer to send data to VxD		*/	DWORD	outBuf[1];	/* Buffer to receive data from VxD	*/	DWORD	count;		/* Count of bytes returned from VxD	*/	if (!inited)		PM_init();	inBuf[0] = base;	inBuf[1] = limit;	inBuf[2] = isCached;	if (DeviceIoControl(_PM_hDevice, PMHELP_MAPPHYS32, inBuf, sizeof(inBuf),			outBuf, sizeof(outBuf), &count, NULL))		return (void*)outBuf[0];	return NULL;}/****************************************************************************REMARKS:Free a physical address mapping allocated by PM_mapPhysicalAddr.****************************************************************************/void PMAPI PM_freePhysicalAddr(	void *ptr,	ulong limit){	/* We never free the mappings under Win32 (the VxD tracks them and	 * reissues the same mappings until the system is rebooted).	 */	(void)ptr;	(void)limit;}/****************************************************************************REMARKS:Find the physical address of a linear memory address in current process.****************************************************************************/ulong PMAPI PM_getPhysicalAddr(	void *p){	DWORD	inBuf[1];	/* Buffer to send data to VxD		*/	DWORD	outBuf[1];	/* Buffer to receive data from VxD	*/	DWORD	count;		/* Count of bytes returned from VxD	*/	if (!inited)		PM_init();	inBuf[0] = (ulong)p;	if (DeviceIoControl(_PM_hDevice, PMHELP_GETPHYSICALADDR32, inBuf, sizeof(inBuf),			outBuf, sizeof(outBuf), &count, NULL))		return outBuf[0];	return 0xFFFFFFFFUL;}/****************************************************************************REMARKS:Sleep for the specified number of milliseconds.****************************************************************************/void PMAPI PM_sleep(	ulong milliseconds){	Sleep(milliseconds);}/****************************************************************************REMARKS:Return the base I/O port for the specified COM port.****************************************************************************/int PMAPI PM_getCOMPort(int port){	// TODO: Re-code this to determine real values using the Plug and Play	//		 manager for the OS.	switch (port) {		case 0:	return 0x3F8;		case 1:	return 0x2F8;		}	return 0;}/****************************************************************************REMARKS:Return the base I/O port for the specified LPT port.****************************************************************************/int PMAPI PM_getLPTPort(int port){	// TODO: Re-code this to determine real values using the Plug and Play	//		 manager for the OS.	switch (port) {		case 0:	return 0x3BC;		case 1: return 0x378;		case 2:	return 0x278;		}	return 0;}/****************************************************************************REMARKS:Allocate a block of shared memory. For Win9x we allocate shared memoryas locked, global memory that is accessible from any memory context(including interrupt time context), which allows us to load our importantdata structure and code such that we can access it directly from a ring0 interrupt context.****************************************************************************/void * PMAPI PM_mallocShared(	long size){	DWORD	inBuf[1];	/* Buffer to send data to VxD		*/	DWORD	outBuf[1];	/* Buffer to receive data from VxD	*/	DWORD	count;		/* Count of bytes returned from VxD	*/	inBuf[0] = size;	if (DeviceIoControl(_PM_hDevice, PMHELP_MALLOCSHARED32, inBuf, sizeof(inBuf),			outBuf, sizeof(outBuf), &count, NULL))		return (void*)outBuf[0];	return NULL;}/****************************************************************************REMARKS:Map the (unnamed) shared memory block into the process address space.****************************************************************************/int PMAPI PM_mapShared(	void *ptr){	DWORD	inBuf[1];	/* Buffer to send data to VxD		*/	DWORD	outBuf[1];	/* Buffer to receive data from VxD	*/	DWORD	count;		/* Count of bytes returned from VxD	*/	inBuf[0] = (ulong)ptr;	if (DeviceIoControl(_PM_hDevice, PMHELP_MAPSHARED32, inBuf, sizeof(inBuf),			outBuf, sizeof(outBuf), &count, NULL))		return outBuf[0];	return -1;}/****************************************************************************REMARKS:Free a block of shared memory.****************************************************************************/void PMAPI PM_freeShared(	void *ptr){	DWORD	inBuf[1];	/* Buffer to send data to VxD		*/	inBuf[0] = (ulong)ptr;	DeviceIoControl(_PM_hDevice, PMHELP_FREESHARED32, inBuf, sizeof(inBuf), NULL, 0, NULL, NULL);}/****************************************************************************REMARKS:Map a linear memory address to the calling process address space. Theaddress will have been allocated in another process using thePM_mapPhysicalAddr function.****************************************************************************/void * PMAPI PM_mapToProcess(	void *base,	ulong limit){	(void)base;	(void)limit;	return base;}/****************************************************************************REMARKS:Map a real mode pointer to a protected mode pointer.****************************************************************************/void * PMAPI PM_mapRealPointer(	uint r_seg,	uint r_off){	return (void*)(MK_PHYS(r_seg,r_off));}/****************************************************************************REMARKS:Allocate a block of real mode memory****************************************************************************/void * PMAPI PM_allocRealSeg(	uint size,	uint *r_seg,	uint *r_off){	/* We do not support dynamically allocating real mode memory buffers	 * from Win32 programs (we need a 16-bit DLL for this, and Windows	 * 9x becomes very unstable if you free the memory blocks out of order).	 */	(void)size;	(void)r_seg;	(void)r_off;	return NULL;}/****************************************************************************REMARKS:Free a block of real mode memory.****************************************************************************/void PMAPI PM_freeRealSeg(	void *mem){	/* Not supported in Windows */	(void)mem;}/****************************************************************************REMARKS:Issue a real mode interrupt (parameters in DPMI compatible structure)****************************************************************************/void PMAPI DPMI_int86(	int intno,	DPMI_regs *regs)

⌨️ 快捷键说明

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