Example #1
0
File: main.c Project: w4kfu/Stunts
void print_info_type_02(FILE *fout, struct file *sFile)
{
	unsigned int uncomp_size = 0;
	unsigned int real_size = 0;
	unsigned int treelevels = 0;
	struct file sFileuncomp;

	fprintf(fout, "--- (TYPE 02) Variable Length Compression ---\n\n");
	uncomp_size = *(sFile->bMap + 1) | (*(sFile->bMap + 2) << 0x8) | (*(sFile->bMap + 3) << 0x10);
	treelevels = *(sFile->bMap + 4);
	fprintf(fout, "* Uncompressed Size : 0x%08X (%d)\n", uncomp_size, uncomp_size);
	fprintf(fout, "* Huffman Binary Tree Depths : %X (%d)\n", treelevels, treelevels);
	exec_decompressor(sFile);
	if (open_and_map("/tmp/out", &sFileuncomp) == 0)
	{
		clean_file(&sFileuncomp);
		fprintf(stderr, "[-] open_and_map failed : %s\n", "/tmp/out");
	}
	real_size = *(unsigned int*)(sFileuncomp.bMap);
	if (real_size == uncomp_size)
	{
		fprintf(fout, "\n[+] Decompression OK!\n\n");
		parse_type2(fout, &sFileuncomp);
	}
	else
		fprintf(fout, "\n[-] Real size not found in new header !\n\n");
	fprintf(fout, "\n\nhexdump :\n\n");
	hex_dump(fout, sFileuncomp.bMap, 0x40);
	clean_file(&sFileuncomp);
}
Example #2
0
File: arg.c Project: w4kfu/Stunts
void clean(struct s_conf *conf)
{
	clean_file(&conf->fhdr);
	clean_file(&conf->fcmn);
	clean_file(&conf->fdif);
	clean_file(&conf->fcod);
}
Example #3
0
File: main.c Project: w4kfu/Stunts
int main(int argc, char **argv)
{
	DIR *rep;
        struct dirent *ent;
    	struct file sFile;
	char filename[4096];
	FILE *fout;

	if (argc != 2)
	{
		fprintf(stderr, "Usage : %s <4DSD_directory>\n", argv[0]);
		exit(EXIT_FAILURE);
	}
	rep = opendir(argv[1]);
	if (rep == NULL)
	{
		perror("opendir()");
		exit(EXIT_FAILURE);
	}
	fout = fopen("stats.md", "w");
	if (!fout)
	{
		perror("fopen()");
		exit(EXIT_FAILURE);
	}
        while ((ent = readdir(rep)) != NULL)
        {
		if (ent->d_type == 8)
		{
			if (strlen(argv[1]) + strlen(ent->d_name) + 1 + 1 < 4096)
			{
				strcpy(filename, argv[1]);
				if (filename[strlen(filename) - 1] != '/')
					strcat(filename, "/");
				strcat(filename, ent->d_name);
    				if (open_and_map(filename, &sFile) == 0)
    				{
        				clean_file(&sFile);
        				fprintf(stderr, "[-] open_and_map failed : %s\n", filename);
    				}
				else
				{
					print_info_file(fout, &sFile);
					clean_file(&sFile);
				}
			}
		}
        }
        closedir(rep);
	fclose(fout);
    	return 0;
}
int main (int argc, char** argv) {

	pthread_t thread;
	int listener, nuevaConexion;

	/* Creación de archivo log */
	Logger = log_create(LOG_PATH, "MSP", false, LOG_LEVEL_TRACE);
	clean_file(LOG_PATH);

	cargarConfiguracion(argv[1]);
	inicializarMSP();

	log_trace(Logger, "Inicio de MSP.\n	Tamaño de Memoria Principal: %u.\n	Tamaño de SWAP: %u.", MaxMem, MaxSwap);

	listener = server_socket(Puerto);
	pthread_create(&thread, NULL, atenderConsola, NULL);

	while (true) {

		nuevaConexion = accept_connection(listener);

		pthread_mutex_lock(&LogMutex);
		log_trace(Logger, "Nueva conexión.");
		pthread_mutex_unlock(&LogMutex);

		pthread_create(&thread, NULL, atenderProceso, &nuevaConexion);
	}

	return EXIT_SUCCESS;

}
Example #5
0
int main(int argc, char **argv)
{
	int opt = 0, i = 0, pstat, nremoved;
	struct sigaction sig;
	pid_t pid;
	char buf[BUFFSIZE];

	if (argc == 1) {
		fprintf(stderr, "Usage: cclean [OPTION] [FILE] ...\n");
		exit(1);
	}

	/* Init signal handlers */
	init_sigaction(&sig);

	/* Handle options */
	while ((opt = getopt(argc, argv, "hv")) != -1) {
		switch (opt) {
			case 'h':
				show_help();
				exit(0);
			case 'v':
				printf("cclean %s, compiled on %s %s.\n", VERSION, __TIME__, __DATE__);
				exit(0);
			default:
				fprintf(stderr, "Use -h for more information.\n");
				exit(1);
		}
	}

	/* Create child processes for input file */
	for (i = 1; i < argc; i++) {
		if ((pid = fork()) < 0)
			perror(argv[0]);

		/* Child process */
		if (pid == 0) {
			if ((nremoved = clean_file(argv[i], buf, BUFFSIZE)) < 0)
				perror(argv[i]);
			else
				printf("%s: Cleaned; %d characters removed\n",
					argv[i], nremoved);
			exit(i);
		}
	}

	/* Wait for child processes */
	while ((pid = wait(&pstat)) >= 0);

	puts("byebye.");
	return 0;
}
Example #6
0
void OpenSndFile(HWND hWin)
{
    OPENFILENAME ofn;
    char szFileName[MAX_PATH] = "";

    ZeroMemory(&ofn, sizeof(ofn));
    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = hWin;
    ofn.lpstrFilter = "Snd Files (*.snd)\0*.snd\0";
    ofn.lpstrFile = szFileName;
    ofn.nMaxFile = MAX_PATH;
    ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST;
    ofn.lpstrDefExt = "snd";
    ListView_DeleteAllItems(hListView);
    clean_file(&sFile);
    if (GetOpenFileName(&ofn))
    {
        if (open_and_map(ofn.lpstrFile, &sFile) == FALSE)
            return;
        SetFileInformation(hWin, &ofn);
    }
}