Esempio n. 1
0
static long matchLibraries(void)
{
	// printf("in MatchLibraries()\n");

    TagPtr     prop, prop2;
    ModulePtr  module, module2;
    long       done;

    do
	{
        done = 1;
        module = gModuleHead;
        
        while (module != 0)
        {
            if (module->willLoad == 1)
            {
                prop = XMLGetProperty(module->dict, kPropOSBundleLibraries);

                if (prop != 0)
                {
                    prop = prop->tag;

                    while (prop != 0)
                    {
                        module2 = gModuleHead;

                        while (module2 != 0)
                        {
                            prop2 = XMLGetProperty(module2->dict, kPropCFBundleIdentifier);

                            if ((prop2 != 0) && (!strcmp(prop->string, prop2->string)))
                            {
                                if (module2->willLoad == 0)
								{
                                    module2->willLoad = 1;
								}
                                break;
                            }
                            module2 = module2->nextModule;
                        }
                        prop = prop->tagNext;
                    }
                }
                module->willLoad = 2;
                done = 0;
            }
            module = module->nextModule;
        }
    }
    while (!done);

    return 0;
}
Esempio n. 2
0
static long
ParseXML( char * buffer, ModulePtr * module, TagPtr * personalities )
{
	long       length, pos;
	TagPtr     moduleDict, required;
	ModulePtr  tmpModule;
  
    pos = 0;
  
    while (1)
    {
        length = XMLParseNextTag(buffer + pos, &moduleDict);
        if (length == -1) break;
    
        pos += length;
    
        if (moduleDict == 0) continue;
        if (moduleDict->type == kTagTypeDict) break;
    
        XMLFreeTag(moduleDict);
    }
  
    if (length == -1) return -1;

    required = XMLGetProperty(moduleDict, kPropOSBundleRequired);
    if ( (required == 0) ||
         (required->type != kTagTypeString) ||
         !strcmp(required->string, "Safe Boot"))
    {
        XMLFreeTag(moduleDict);
        return -2;
    }

    tmpModule = (ModulePtr)malloc(sizeof(Module));
    if (tmpModule == 0)
    {
        XMLFreeTag(moduleDict);
        return -1;
    }
    tmpModule->dict = moduleDict;
  
    // For now, load any module that has OSBundleRequired != "Safe Boot".

    tmpModule->willLoad = 1;

    *module = tmpModule;
  
    // Get the personalities.

    *personalities = XMLGetProperty(moduleDict, kPropIOKitPersonalities);
  
    return 0;
}
Esempio n. 3
0
// Faster method and no need to (re-)compile the map, everything is done with xml (i have a keymap maker made in cocoa and with a gui that i have don't released yet)
void Keymapper_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
{
	int *ret = (int *)arg1;
	int c = *(int *)ret;
	char *kMatchkey = NULL;
    
	// Check for xml map in the config file
	if (match_map == NULL)				
		match_map = XMLGetProperty(DEFAULT_BOOT_CONFIG_DICT, (const char*)"KeyboardMap");
	
	if (match_map)
	{
		kMatchkey = newStringWithFormat("%d",c); 
        if (!kMatchkey) {
            return;
        }        
		TagPtr match_key;
		if ((match_key = XMLGetProperty(match_map, (const char*)kMatchkey)))
		{
			kMatchkey = XMLCastString(match_key);
			c  = strtoul((const char *)kMatchkey, NULL,10);		
			if (c) goto out;
		}
	}
	
	// Check for built-in map
	if (map_kb_type == NULL)
	{		
		TagPtr match_type;
		if ((match_type = XMLGetProperty(DEFAULT_BOOT_CONFIG_DICT, (const char*)"KeyboardType")))
			map_kb_type = XMLCastString(match_type);
		else 
			map_kb_type =  "NONE"; // Default to QWERTY
	}
	
	if (map_kb_type && (strncmp(map_kb_type, "AZERTY",sizeof("AZERTY")) == 0))		
        c = AZERTY_switch(c);
	
out:
	
	*ret = c;
	if (kMatchkey) free(kMatchkey);
}
Esempio n. 4
0
bool getValueForConfigTableKey(config_file_t *config, const char *key, const char **val, int *size)
{
	if (config->dictionary != 0 ) {
		// Look up key in XML dictionary
		TagPtr value;
		value = XMLGetProperty(config->dictionary, key);
		if (value != 0) {
			if (value->type != kTagTypeString) {
				error("Non-string tag '%s' found in config file\n", key);
				return false;
			}
			*val = value->string;
			*size = strlen(value->string);
			return true;
		}
	} else {

		// Legacy plist-style table

	}

	return false;
}
Esempio n. 5
0
static long
LoadMatchedModules( void )
{
    TagPtr        prop;
    ModulePtr     module;
    char          *fileName, segName[32];
    DriverInfoPtr driver;
    long          length, driverAddr, driverLength;
    void          *driverModuleAddr = 0;

  
    module = gModuleHead;

    while (module != 0)
    {
        if (module->willLoad)
        {
            prop = XMLGetProperty(module->dict, kPropCFBundleExecutable);

            if (prop != 0)
            {
                fileName = prop->string;
                sprintf(gFileSpec, "%s%s", module->driverPath, fileName);
                length = LoadThinFatFile(gFileSpec, &driverModuleAddr);
                //length = LoadFile(gFileSpec);
                //driverModuleAddr = (void *)kLoadAddr;
                //printf("%s length = %d addr = 0x%x\n", gFileSpec, length, driverModuleAddr); getc();
            }
            else
                length = 0;

            if (length != -1)
            {
		//driverModuleAddr = (void *)kLoadAddr;
                //if (length != 0)
                //{
		//    ThinFatFile(&driverModuleAddr, &length);
		//}

                // Make make in the image area.
                driverLength = sizeof(DriverInfo) + module->plistLength + length;
                driverAddr = AllocateKernelMemory(driverLength);

                // Set up the DriverInfo.
                driver = (DriverInfoPtr)driverAddr;
                driver->plistAddr = (char *)(driverAddr + sizeof(DriverInfo));
                driver->plistLength = module->plistLength;
                if (length != 0)
                {
                    driver->moduleAddr = (void *)(driverAddr + sizeof(DriverInfo) +
					                     module->plistLength);
                    driver->moduleLength = length;
                }
                else
                {
                    driver->moduleAddr   = 0;
                    driver->moduleLength = 0;
                }

                // Save the plist and module.
                strcpy(driver->plistAddr, module->plistAddr);
                if (length != 0)
                {
                    memcpy(driver->moduleAddr, driverModuleAddr, length);
                }

                // Add an entry to the memory map.
                sprintf(segName, "Driver-%lx", (unsigned long)driver);
                AllocateMemoryRange(segName, driverAddr, driverLength,
                                    kBootDriverTypeKEXT);
            }
        }
        module = module->nextModule;
    }

    return 0;
}
Esempio n. 6
0
BOOL getValueForConfigTableKey(const char *table, const char *key, const char **val, int *size)
{
	int keyLength;
	const char *tableKey;

        if (gConfigDict != 0 ) {
            /* Look up key in XML dictionary */
            TagPtr value;
            value = XMLGetProperty(gConfigDict, key);
            if (value != 0) {
                if (value->type != kTagTypeString) {
                    error("Non-string tag '%s' found in config file\n",
                          key);
                    return NO;
                }
                *val = value->string;
                *size = strlen(value->string);
                return YES;
            }
        } else {
            /* Legacy plist-style table */
            do
                {
                    eatThru('\"',&table);
                    tableKey = table;
                    keyLength = strlen(key);
                    if (keyLength &&
                        (stringLength(table,1) == keyLength) &&
                        (keyncmp(key, table, keyLength) == 0))
                        {
                            int c;
			
                            /* found the key; now look for either
                             * '=' or ';'
                             */
                            while (c = *table) {
                                ++table;
                                if (c == '\\') {
                                    ++table;
                                    continue;
                                } else if (c == '=' || c == ';') {
                                    break;
                                }
                            }
                            if (c == ';') {
                                table = tableKey;
                            } else {
                                eatThru('\"',&table);
                            }
                            *val = table;
                            *size = stringLength(table,0);
                            return YES;
                        }

                    eatThru(';',&table);

                } while (*table);
        }

	return NO;
}