Exemplo n.º 1
0
void KernelPatcher_start(void)
{
	register_kernel_patch(patch_cpuid_set_info_all, KERNEL_ANY, CPUID_MODEL_UNKNOWN); 
	
	register_kernel_patch(patch_commpage_stuff_routine, KERNEL_ANY, CPUID_MODEL_ANY);
	
	register_kernel_patch(patch_lapic_init, KERNEL_ANY, CPUID_MODEL_ANY);
	
	// NOTE: following is currently 32bit only
	register_kernel_patch(patch_lapic_configure, KERNEL_32, CPUID_MODEL_ANY);
	
	register_kernel_symbol(KERNEL_ANY, "_panic");
	register_kernel_symbol(KERNEL_ANY, "_cpuid_set_info");
	register_kernel_symbol(KERNEL_ANY, "_pmCPUExitHaltToOff");
	register_kernel_symbol(KERNEL_ANY, "_lapic_init");
	register_kernel_symbol(KERNEL_ANY, "_commpage_stuff_routine");
	
	// lapic_configure symbols
	register_kernel_symbol(KERNEL_ANY, "_lapic_configure");
	register_kernel_symbol(KERNEL_ANY, "_lapic_start");
	register_kernel_symbol(KERNEL_ANY, "_lapic_interrupt_base");
	
	// lapic_interrup symbols
	//register_kernel_patch(patch_lapic_interrupt, KERNEL_ANY, CPUID_MODEL_ANY);
	//register_kernel_symbol(KERNEL_ANY, "_lapic_interrupt");
	
	// TODO: register needed symbols
	
	register_hook_callback("ExecKernel", &patch_kernel); 
	
	replace_system_function("_getKernelCachePath", &kernel_patcher_ignore_cache);
}
Exemplo n.º 2
0
uint32_t Keylayout_real_start(void)
{
	char  layoutPath[512];
	const char	*val;
	int			len;
	
	if (getValueForKey("KeyLayout", &val, &len, DEFAULT_BOOT_CONFIG))
	{
		snprintf(layoutPath, sizeof(layoutPath),"/Extra/Keymaps/%s", val);
		// Add the extension if needed
		if (len <= 4 || strncmp(val+len-4,".lyt", sizeof(".lyt")) != 0)
			strlcat(layoutPath, ".lyt", sizeof(layoutPath));
		
		if (!load_keyboard_layout_file(layoutPath))
		{
			DBG("Can't load %s keyboard layout file. Keylayout will not be used !\n",
				layoutPath);
			return 0;
		} 
		
		
		if (replace_system_function("_getc", &getchar_replacement) != EFI_SUCCESS ) 
		{
			printf("no function getc() to replace. Keylayout will not be used ! \n");
			return 0;
		}
		
		return 1;
		
	}
	return 0;
}
Exemplo n.º 3
0
void Keymapper_start(void)
{
    if (Keylayout_real_start()) 
    {
        return;
    } 
    
#ifdef TRUNK	
    if (!replace_system_function("_getchar", &Keymapper_getc)) 
    {
        printf("no function getchar() to replace. Keymapper will not be used ! \n");
        
    }		
#else
    if (replace_system_function("_getc", &Keymapper_getc) != EFI_SUCCESS) 
    {
        printf("no function getc() to replace. Keymapper will not be used ! \n");
    }
#endif
    	
}
Exemplo n.º 4
0
void ACPICodec_start(void)
{   
    replace_system_function("_setup_acpi",&setupAcpi);        
}
Exemplo n.º 5
0
void NBI_PreBoot_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
{	
	
	bool dummyVal = 0;
	config_file_t systemVersion;
	
	char valid = false;
	const char *val;
	int len;
	const char* gPrevMacOSBuildVersion;
	
	
	if (!loadConfigFile("System/Library/CoreServices/SystemVersion.plist", &systemVersion))
	{
		valid = true;
	}
	else if (!loadConfigFile("System/Library/CoreServices/ServerVersion.plist", &systemVersion))
	{
		valid = true;
	}
	
	if (valid)
	{
		if  (getValueForKey("ProductBuildVersion", &val, &len, &systemVersion))
		{
			
			if (!loadConfigFile("Extra/SystemVersion.LastPatched.plist", &systemVersion))
			{
				if(getValueForKey("ProductBuildVersion", &gPrevMacOSBuildVersion, &len, &systemVersion))
				{
					if(strlen(val) != strlen(gPrevMacOSBuildVersion) ||
					   strcmp(val, gPrevMacOSBuildVersion) != 0
					   )
					{
						runNetbookInstaller = 1;
					}
					else 
					{
						// Only allow restore from hibernation if the system hasn't changed, probably a bad idea though
						//char* val="/private/var/vm/sleepimage";
						
						// Do this first to be sure that root volume is mounted
						//ret = GetFileInfo(0, val, &flags, &sleeptime);
						
						//printf("System version has not changed\n");
						//runNetbookInstaller = 0;
						
					}
					
				}
			}
		}
	}
	
	
	
	
	
	if (!runNetbookInstaller && getBoolForKey("recovery", &dummyVal, DEFAULT_BOOT_CONFIG) && dummyVal)
	{
		if(dummyVal) runNetbookInstaller = 2;
	}
	
	if(runNetbookInstaller)
	{
		
		replace_system_function("_LoadDrivers", &NBI_LoadDrivers);
		
		if(runNetbookInstaller == 1 )
		{
			if (execute_hook("isRamDiskRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS)
			{
				replace_function_any("_md0Ramdisk", &NBI_md0Ramdisk);
			} 
			else
			{
				register_hook_callback("md0Ramdisk", NBI_md0Ramdisk_hook);
			}
			
		}
		
		// Force arch=i386 + -v
		safe_set_env(envarchCpuType, CPU_TYPE_I386);
		safe_set_env(envgVerboseMode, true);
	}
}