Esempio n. 1
0
// This function receives possible keyboard shortcuts from standard OllyDbg
// windows. If it recognizes shortcut, it must process it and return 1,
// otherwise it returns 0.
extc int _export cdecl ODBG_Pluginshortcut(
	int origin,int ctrl,int alt,int shift,int key,void *item) {

		if (ctrl==0 && alt!=0 && key=='1') //Alt+1 to connect
		{
			connect();
			return 1;
		}

		//key==186==VK_OEM_1 is when the semicolon/colon is pressed down on US keyboards
		if (key==VK_OEM_1 && ctrl==0 && alt!=0 && item!=NULL) //item is required for setting a name/comment
		{
			t_dump *pd;
			pd=(t_dump *)item;

			if(shift!=0)
				insert_name(pd); //Alt+; to insert name
			else //shift==0
				insert_comment(pd); //Alt+: to insert comment

			return 1;
		}

		return 0; // Shortcut not recognized
	};
Esempio n. 2
0
// This optional function receives commands from plugin menu in window of type
// origin. Argument action is menu identifier from ODBG_Pluginmenu(). If user
// activates automatically created entry in main menu, action is 0.
extc void _export cdecl ODBG_Pluginaction(int origin,int action,void *item) {
	t_dump *pd;
	if (origin==PM_MAIN) {
		switch (action) {
		case 1:
			connect();
			break;
		case 9: //About
			MessageBox(hwmain,
				""PLUGIN_NAME" plugin v"VERSION"\n"
				"Compiled on " __DATE__ "\n"
				"Copyright (C) 2005 Andrew Hintz\n"
				"http://guh.nu",
				""PLUGIN_NAME"",MB_OK|MB_ICONINFORMATION);
			break;
		default: break;
		}; }
	else if (origin==PM_DISASM) {
		pd=(t_dump *)item;
		switch (action)
		{
		case 2:
			insert_comment(pd);
			break;
		case 3:
			insert_name(pd);
			break;
		default:
			break;
		}//switch
	};//else if
};
int main(int argc, char **argv)
{
    list_node *hashtable[HASHTABLE_SIZE];
    init_hashtable(hashtable);

    // Determining the file size
    struct stat st;
    if(stat("names.txt", &st) == -1)
        return EXIT_FAILURE;

    // Reading all contents to memory
    char contents[st.st_size + 1];
    FILE *h = fopen("names.txt", "r");
    size_t n = fread(contents, sizeof(char), st.st_size, h);
    fclose(h);

    // Extracting names and inserting in hashtable
    int j;
    char aux[NAME_LENGTH+1];
    for(int i = 0; i < n; i++) {
        bzero(aux, NAME_LENGTH);

        j = 0;
        while(contents[i] != ',' && i < n) {
            if(contents[i] != '"')
                aux[j++] = contents[i];
            i++;
        }
        aux[j] = '\0';

        insert_name(hashtable, aux, strlen(aux));
    }

    // Reading names
    long total = 0;
    int pos = 1;
    list_node *aux_node;
    for(int i = 0; i < HASHTABLE_SIZE; i++) {
        if(hashtable[i] != NULL) {
            aux_node = hashtable[i];
            while(aux_node != NULL) {
                total += name_score(
                        aux_node->name, 
                        strlen(aux_node->name), 
                        pos++);
                aux_node = aux_node->next;
            }
        }
    }

    printf("%ld\n", total);

    return EXIT_SUCCESS;
}
Esempio n. 4
0
void render_options(char option_text[][SZ_OPTION], struct player_info *player, int *option_count)
{
	struct opt_info *options[SZ_LOC_OPTS];
	int i;

	debug("Rendering options");

	if (player->location->header.is_auto)
	{
		*option_count = 0;
		return;
	}

	get_options(options, player, option_count);

	debug("Got options");

	for (i = 0; i < *option_count; i++)
	{
		strcpy(option_text[i], options[i]->header.text);
		insert_name(option_text[i], player->name);
	}
}
Esempio n. 5
0
void render_description(char *buffer, struct player_info *player)
{
	strcpy(buffer, player->location->header.desc);
	insert_name(buffer, player->name);
}