Exemplo n.º 1
0
int main(int argc, char **argv){
 // Interpret the command-lin arguments and decide if they make sense
	int status = parseArgs(argc, argv, &prefs);

    printf(COPYRIGHT);
	setLogLevel(LOG_INFO);
	
	if (status == FAIL){
	 // The command-line was duff...
		if (prefs.errorMsg != NULL){
		 // ...and we have a specific error to show the user
			printf("Error: %s\n", prefs.errorMsg);
		} else {
		 // ...and we have no specific error message, so show a vague one
			printf("BitMeter did not understand. ");
		}
		printf("Use the '-h' option to display help.\n");

	} else if (prefs.help){
	 // Dump the help info and stop
		doHelp();

	} else if (prefs.version){
	 // Show the version and stop
		doVersion();

	} else {
	 // We will need to go to the database if we end up here
		openDb();
        dbVersionCheck();

		switch(prefs.mode){
			case PREF_MODE_DUMP:
				doDump();
				break;
			case PREF_MODE_SUMMARY:
				doSummary();
				break;
			case PREF_MODE_MONITOR:
				doMonitor();
				break;
			case PREF_MODE_QUERY:
				doQuery();
				break;
			default:
				assert(FALSE); // Any other mode value should cause parseArgs to fail
				break;
		}

		closeDb();
	}

	return 0;
}
Exemplo n.º 2
0
int module_start(SceSize argc, const void *args)
{
	int i, j;
	int ret;
	size_t num;
	SceKernelModuleInfo modinfo;
	SceUID modlist[MOD_LIST_SIZE];

	log_reset();

	LOG("kplugin by xerpi\n");

	memset(modlist, 0, sizeof(modlist));

	num = MOD_LIST_SIZE;
	ret = ksceKernelGetModuleList(KERNEL_PID, 0x80000001, 1, modlist, &num);
	if (ret < 0)
		LOG("Error getting the module list\n");

	LOG("Found %d modules.\n", num);

	for (i = 0; i < num; i++) {
		memset(&modinfo, 0, sizeof(modinfo));

		ret = ksceKernelGetModuleInfo(KERNEL_PID, modlist[i], &modinfo);
		if (ret < 0) {
			LOG("Error getting the module info for module: %d\n", i);
			continue;
		}

		LOG("Module %d name: %s\n", i, modinfo.module_name);

		for (j = 0; j < 4; j++) {
			char path[128];
			SceKernelSegmentInfo *seginfo = &modinfo.segments[j];

			if (seginfo->size != sizeof(*seginfo))
				continue;

			if (seginfo->vaddr == NULL)
				continue;

			snprintf(path, sizeof(path), DUMP_PATH "%s_0x%08X_seg%d.bin",
				modinfo.module_name, (uintptr_t)seginfo->vaddr, j);

			dump_region(path, seginfo->vaddr, seginfo->memsz);
		}
		doDump(&modinfo);
	}

	return SCE_KERNEL_START_SUCCESS;
}
Exemplo n.º 3
0
int main( int argc, char *argv[] )
{
	int   ch;
	char *file;

	/* Scan options */
	while ((ch = getopt( argc, argv, "ahvV" )) != -1)
	{
		switch ((char) ch)
		{
		case 'a':
			option_all = TRUE;
			break;

		case 'h':
			usage();
			exit( EXIT_SUCCESS );
			break;

		case 'v':
			option_verbose = TRUE;
			break;

		case 'V':
			version();
			exit( EXIT_SUCCESS );
			break;

		default:
			usage();
			exit( EXIT_FAILURE );
			break;
		}
	}

	if (optind >= argc)
	{
		usage();
		exit( EXIT_FAILURE );
	}

	file = argv[optind];

	if (! EcInit())
		error( "can't initialize elastiC environment" );

	doDump( file );

	EcCleanup();
	exit( EXIT_SUCCESS );
}