Beispiel #1
0
void main(int argc,char **argv)
{
	DWORD iLength;
	void * pvStartingAddress;
	DWORD PID;
	static char * szPid;
	static char * szAddress;
	static char * szLength;
	static char * szFile;

	static BEGIN_ARGS	
		ARG("f:",szFile,"char *","Output file name.")
		ARG("p:",szPid,"char *","PID of the destination process(hex)")
		ARG("a:",szAddress,"char *","Starting address(hex).")
		ARG("l:",szLength,"char *","Length of memory to dump(hex).")
	END_ARGS

	process_args_1(argc,argv);
	if(!szFile || !szPid || !szAddress || !szLength){
		print_usage(__CmdLineArgValues);
		return;
	};
	sscanf(szPid,"%x",&PID);
	sscanf(szLength,"%x",&iLength);
	sscanf(szAddress,"%x",&pvStartingAddress);
	dump_memory(PID,pvStartingAddress,iLength,szFile);
}
Beispiel #2
0
int main(int c, char **v)
{
	char	buf[1024];
	CArgs	args;
	char	*dirName = ".";
	char	*catagory=0;
	char	path[F8_MAX_PATH];

	BEGIN_ARGS
		ARG("-d:", dirName, "char *", "specify operation directory.")
		ARG("-c:", catagory, "char *", "specify library catagory[dir name]")
	END_ARGS

	if(process_args_1(c, v)){
		print_usage_1();
		return -1;
	}
	
	if(!SetCurrentDirectory(dirName)){
		utils_error("Cannot change directory to ``%s''.\n", dirName);
		return -1;
	}
	GetCurrentDirectory(sizeof(buf), buf);
	parse_arg_ex(buf, &args, ":/\\");

	if(!catagory){
		catagory = args.argv[args.argc-1];
	}

	GetCurrentDirectory(sizeof(path), path);
	printf(
		"Making library database in ``%s'', catagory ``%s''\n",
		path,
		catagory
		);

	fdb = fopen("f8.dir", "w");
	if(!fdb){
		return -1;
	}
	fprintf(fdb, "[library]\n");
	fprintf(fdb, "catagory=%s\n", catagory);

	enumerate_files(
		".",
		"*.blk",
		_e_file,
		0,
		0);
	fprintf(fdb, "count=%d\n", count);
	fclose(fdb);

	printf("%d entries added.\n", count);
	
	return 0;
}
Beispiel #3
0
static int on_test(char * arg, void * k)
{
	int i;
	int count=10;
	char * cmd = "uload";
	BEGIN_ARGS
		ARG("-c:", count, "int", "count")
		ARG("-a:", cmd, "char *", "command to stress")
	END_ARGS
	CArgs args;
	parse_arg_ex(arg, &args, FS);
	if(process_args_1(args.argc, args.argv) < 0){
		print_usage_1();
		return F8_SYNTAX;
	}
	for(i=0; i<count; i++){
		kproxy_shell(cmd);
	}
	return 0;
}
Beispiel #4
0
int main(int c, char **v)
{
	char	buf[128];
	__bool	bClipBoard=__false;
	f8_uuid	uuid;

	BEGIN_ARGS
		ARG("-c", bClipBoard, "tbool", "copy result to clipboard")
	END_ARGS

	if(process_args_1(c, v)){
		print_usage_1();
		return -1;
	}

	create_f8_uuid(&uuid);
	f8_uuid_to_string(&uuid, buf, sizeof(buf));
	printf("%s\n", buf);

#ifdef _WIN32
	//if(bClipBoard)
	{
		if( !OpenClipboard(NULL) ){
			return -1;
		}
		EmptyClipboard();
		HANDLE h = GlobalAlloc(GMEM_MOVEABLE, strlen(buf) + 1);
		char * p = (char *)GlobalLock(h);
		if(p){
			GlobalUnlock(h);
			strcpy(p, buf);
			SetClipboardData(CF_TEXT, h);
		}
		CloseClipboard();
	}
#endif

	return 0;
}
/*
	in WIN32, the executive can run in two mode, i.e., the SoftPLC
	mode or the simulator mode. in SoftPLC mode, the executive will
	try to probe additional IO drivers and perform IOs during execution,
	while in simulator mode, no IO is performed.
*/
KSERVER_API int kserver_main2(int c, char **v)
{
	int flags;
	char * mode = 0;
	int port = 0;
	__bool dbgMode;
	int leakDetect = 0;
	
	BEGIN_ARGS
		ARG("mode=", mode, "char *", "mode specifiers")
		ARG("port=", port, "int", "agent port")
		ARG("leak=", leakDetect, "int", "detect memory leakage")
		ARG("--debug", dbgMode, "tbool", "debug mode")
	END_ARGS

	if(process_args_1(c, v)<0){
		print_usage_1();
		return F8_SYNTAX;
	}
	
	if(leakDetect){
		_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
		_CrtSetBreakAlloc(leakDetect);
	}
	
	if(mode){
		CArgs a;
		parse_arg_ex(mode, &a, "+/|-= ,;:");
		int i;
		flags = 0;
		for(i=0; i<a.argc; i++){
			if(!strcmp(a.argv[i], "sched")){
				flags |= KERN_F_ENABLE_SCHEDULER;
			}else if(!strcmp(a.argv[i], "standby")){
				flags |= KERN_F_ENABLE_STANDBY;
			}else if(!strcmp(a.argv[i], "io")){
				flags |= KERN_F_ENABLE_IO;
			}else if(!strcmp(a.argv[i], "sio")){
				flags |= KERN_F_SERIALIZED_IO;
			}else if(!strcmp(a.argv[i], "agent")){
				flags |= KERN_F_ENABLE_AGENT;
			}else if(!strcmp(a.argv[i], "single")){
				flags = KERN_F_ENABLE_SCHEDULER | KERN_F_ENABLE_IO | KERN_F_ENABLE_AGENT;
				break;
			}else if(!strcmp(a.argv[i], "all")){
				flags = KERN_F_ENABLE_SCHEDULER | KERN_F_ENABLE_IO | KERN_F_ENABLE_AGENT
					| KERN_F_ENABLE_STANDBY;
				break;
			}else if(!strcmp(a.argv[i], "headless")){
				flags = KERN_F_ENABLE_SCHEDULER | KERN_F_ENABLE_AGENT | KERN_F_ENABLE_STANDBY;
				break;
			}
		}
	}else{
		flags = KERN_F_ENABLE_SCHEDULER | KERN_F_ENABLE_IO | KERN_F_ENABLE_AGENT
			| KERN_F_ENABLE_STANDBY;
	}

	ex_init();
	g_kernel = ke_get_default_kernel();
	ex_start(flags, port);
	sections = ke_get_blk(g_kernel, NULL);

	return F8_SUCCESS;
}
Beispiel #6
0
int on_export(char * v, void *k)
{
	CArgsEx a;
	char * path = 0;
	char * ofname = 0;
	__bool includeConfig = 0;
	__bool includeSource = 0;

	BEGIN_ARGS
		ARG("-of:", ofname, "char *", "output file name")
		ARG("-p:", path, "char *", "root block path")
		ARG("-config", includeConfig, "tbool", "include configuration")
		ARG("-source", includeSource, "tbool", "include source")
	END_ARGS
		
	a.parse(v, FS);

	if(process_args_1(a.argc, a.argv) < 0){
		print_usage_1();
		return F8_SYNTAX;
	}

	if(!includeSource && !includeConfig){
		return F8_SUCCESS;
	}

	IBlk * b;
	if(path){
		b = IBlk_blk_by_path(sections, path);
	}else{
		b = sections;
	}
	if(!b){
		utils_error("%s - path not found.\n", path);
		return F8_PATH_NOT_FOUND;
	}
	FILE * of;
	if(ofname){
		of = fopen(ofname, "wt");
		if(!of){
			utils_error("%s - cannot open.\n", ofname);
			return F8_FILE_NOT_FOUND;
		}
	}else{
		of = stdout;
	}

	if(includeSource){
		dumpSource(of, b);
	}

	if(includeConfig){
		dumpDevices(of);
	}

	if(of != stdout){
		fclose(of);
	}
	
	return F8_SUCCESS;
}