示例#1
0
文件: sstrip.c 项目: deater/tb1
/* main() loops over the cmdline arguments, leaving all the real work
 * to the other functions.
 */
int main(int argc, char *argv[]) {

    int			fd;
    Elf_Ehdr		ehdr;
    Elf_Phdr	       *phdrs;
    unsigned long	newsize;
    char	      **arg;
    int			failures = 0;

    if (argc < 2 || argv[1][0] == '-') {
	printf("Usage: sstrip FILE...\n"
	       "sstrip discards all nonessential bytes from an executable.\n\n"
	       "Version 2.0 Copyright (C) 2000,2001 Brian Raiter.\n"
	       "This program is free software, licensed under the GNU\n"
	       "General Public License. There is absolutely no warranty.\n");
	return EXIT_SUCCESS;
    }

    progname = argv[0];

    for (arg = argv + 1 ; *arg != NULL ; ++arg) {

	filename = *arg;

	fd = open(*arg, O_RDWR);
	if (fd < 0) {
	    ferr("can't open");
	    ++failures;
	    continue;
	}

	if (!(readelfheader(fd, &ehdr)			&&
	      readphdrtable(fd, &ehdr, &phdrs)		&&
	      getmemorysize(&ehdr, phdrs, &newsize)	&&
	      truncatezeros(fd, &newsize)		&&
	      modifyheaders(&ehdr, phdrs, newsize)	&&
	      commitchanges(fd, &ehdr, phdrs, newsize)))
	    ++failures;

	close(fd);
    }

    return failures ? EXIT_FAILURE : EXIT_SUCCESS;
}
示例#2
0
types::Function::ReturnValue sci_getmemory(types::typed_list &in, int _iRetCount, types::typed_list &out)
{
    if (in.size() > 0)
    {
        Scierror(77, _("%s: Wrong number of input argument(s): %d expected."), "funcprot", 0);
        return types::Function::Error;
    }

    if (_iRetCount > 2)
    {
        Scierror(77, _("%s: Wrong number of output argument(s): %d expected."), "funcprot", 2);
        return types::Function::Error;
    }

    out.push_back(new types::Double((double)getfreememory()));

    if(_iRetCount == 2)
    {
        out.push_back(new types::Double((double)getmemorysize()));
    }

    return types::Function::OK;
}