示例#1
0
/* Initialization function for the driver. Only called once. */
void E2Init (PRPINITOUT Req)
{
 int		UnitCount;
 char FAR	*pCmdLine;

 /* Initialize some of the important global variables. */
 DevHelp= ((PRPINITIN) Req)->DevHlpEP;		/* Get pointer to DevHelp */
 pDataSeg= (PVOID) &pDataSeg;			/* Get pointer to data seg */
 OFFSETOF(pDataSeg)= 0;
 VirtToPhys (pDataSeg,&ppDataSeg);		/* Get the physical address */
						/* of the data segment */
 for (MountCount= 0; MountCount<MAX_LINUX_PARTITIONS; MountCount++)
  MountTable[MountCount]= MountCount;
 						/* MountCount= max num of */
						/* partitions to mount. */

 pCmdLine= ((PRPINITIN) Req)->InitArgs;		/* Get command line args */
 OFFSETOF(pCmdLine)=(USHORT) ((PDDD_PARM_LIST) pCmdLine)->cmd_line_args;

 ProcessCmdline (pCmdLine);
 InitPrint ("Linux partition filter. (C) Deon van der Westhuysen. v1.2\n\r"
            "Development version (Alpha).\n\r");

 InitScanDrivers();				/* Scan for partitions... */
 InitGetUnitFS();				/* Determine FS for each unit */
 InitSortUnits();				/* Sort the units */

 if (MountCount>NumVirtUnits)			
  MountCount =NumVirtUnits;			/* Get correct number of */
						/* units to be mounted. */

 /* Check that each entry points to a valid unit. If not valid, point to */
 /* first unit. (Which can only be allocated once, thus one drive letter.) */
 for (UnitCount=0;UnitCount<MountCount;UnitCount++)
  if (MountTable[UnitCount]>=NumVirtUnits)
   MountTable[UnitCount]= 0;

 if (!NumVirtUnits)
 {
  InitPrint ("No Linux partitions were found: filter not installed.");
  Req->Unit= 0;
  Req->CodeEnd= 0;				/* No code to keep */
  Req->DataEnd= 0;				/* No data to keep */
  Req->rph.Status= STDON+STERR+ERROR_I24_QUIET_INIT_FAIL;
						/* Indicate failure */
  return;
 }

 ADDHandle= RegisterADD (E2FilterIORBWrapper,FILTER_ADD_NAME);
						/* Register filter */
 if (!ADDHandle)				/* Check registration */
 {
  InitPrint ("Could't register filter. Installation aborted.");
  while (NumBaseUnits) InitRemoveBaseUnit();	/* Free all base units */
  Req->Unit= 0;
  Req->CodeEnd= 0;				/* No code to keep */
  Req->DataEnd= 0;				/* No data to keep */
  Req->rph.Status= STDON+STERR+ERROR_I24_QUIET_INIT_FAIL;
						/* Indicate failure */
  return;
 }

 for (UnitCount= 0; UnitCount<NumBaseUnits; UnitCount++)
  InitFilterBaseUnit (UnitCount);		/* Filter all base units... */

 InitPrintVerbose ("Filter installed.");
 Req->Unit= 0;

 Req->CodeEnd= ((USHORT)E2Init);		/* Pointer to end of code */
 Req->DataEnd= ((USHORT)&StartInitData);	/* Pointer to end of data */
 Req->rph.Status= STDON;			/* Everything is OK */
}
示例#2
0
int WINAPI WinMain(HINSTANCE inst, HINSTANCE, LPTSTR cmdline, int cmdshow)
{
	MSG msg;
	BOOL ret;
	HWND sheet, active;
	HACCEL accelerators;

#ifdef MSVC_MEMLEAK_CHECK
	_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);	//check for memory leaks
#endif

    // These two methods are not the same
    GetModuleFileName(NULL, global::exedir, MAX_PATH); // works
    PathRemoveFileSpec(global::exedir);
	//GetCurrentDirectory(_MAX_PATH, global::exedir); // doesn't work

	//basic initializations
	aokts = inst;
	propdata.p = scen.players;	//start pointing to first member
	ret = setts.load();

	if (*setts.logname) {
	    char logpath[_MAX_PATH];

	    //GetCurrentDirectory(_MAX_PATH, logpath);
        strcpy(logpath, global::exedir);
	    strcat(logpath, "\\");
	    strcat(logpath, setts.logname);
		freopen(logpath, "w", stdout);
	    printf_log("Opened log file %s.\n", logpath);
	}
	printf_log("TS Path: %s\n", global::exedir);

    // Hint about whether to open as AOC or SGWB
	if (setts.recent_first) {
	     scen.game = (Game)setts.recent_first->game;
	     printf_log("Last game was %s.\n", gameName(scen.game));
	}

	//process any compress/decompress requests
	if ((*cmdline == '/' || *cmdline == '-') && ProcessCmdline(cmdline))
			return 0;

	//read genie data
	try
	{
		switch (scen.game) {
		case AOK:
		case AOC:
		case AOHD:
		case AOF:
		    esdata.load(datapath_aok);
		    break;
		case SWGB:
		case SWGBCC:
		    esdata.load(datapath_swgb);
		    break;
		default:
		    esdata.load(datapath_aok);
		}
	}
	catch (std::exception& ex)
	{
		printf_log("Could not load data: %s\n", ex.what());
		MessageBox(NULL,
			"Could not read Genie Data from data.xml. Terminating...",
			"Error", MB_ICONERROR);
		return 0;
	}

	//create the property sheet & init misc data
	InitCommonControls();
	sheet = MakeSheet(inst);
	propdata.tformat = RegisterClipboardFormat("AOKTS Trigger");
	propdata.ecformat = RegisterClipboardFormat("AOKTS EC");
	propdata.mcformat = RegisterClipboardFormat("AOKTS Mapcopy");
	accelerators = LoadAccelerators(inst, (LPCTSTR)IDA_MAIN);	//checked for err later

	//give the sheet its own DialogProc
	pproc = (DLGPROC)SetWindowLong(sheet, DWL_DLGPROC, (LONG)&MainDlgProc);

	//check for errors down here, after we create the sheet
	if (!accelerators)
	{
		MessageBox(sheet,
			"Keyboard Accelerators failed to load. Keyboard shortcuts will not be available.",
			"Warning", MB_ICONWARNING);
	}
	if (!propdata.tformat | !propdata.ecformat)
	{
		MessageBox(sheet,
			"Could not register clipboard format. Clipboard operations will not function.",
			"Warning", MB_ICONWARNING);
	}
	//if (!ret)
	//	MessageBox(sheet, warnNoAOEII, "Warning", MB_ICONWARNING);

	//open mapview window
	propdata.mapview = MakeMapView(sheet, cmdshow || SW_MAXIMIZE);

	//check for, then open the scenario specified in command string
	if (*cmdline != '\0')
	{
		if (*cmdline == '"')
		{
			cmdline++;	//increment past first doublequote
			*strrchr(cmdline, '"') = '\0';	//find last " and replace it
		}

		strcpy(setts.ScenPath, cmdline);
		printf_log("cmdline scenpath: %s\n", setts.ScenPath);
		FileOpen(sheet, false, -1);
	}

	//the message loop
	while (ret = GetMessage(&msg, NULL, 0, 0))
	{
		if (ret < 0)	//did GetMessage() fail?
		{
			MessageBox(sheet,
				"Unable to retrieve messages from queue. Click OK to terminate.",
				"AOKTS Fatal Error", MB_ICONERROR);
			break;
		}

		// Give first dibs to keyboard accelerators and the propsheet.
		if (TranslateAccelerator(sheet, accelerators, &msg) ||
			PropSheet_IsDialogMessage(sheet, &msg))
			continue;

		// Usually active is the sheet. If it's not, it's a modeless dialog and
		// it should get a crack, too.
		if ((active = GetActiveWindow()) != sheet &&
			IsDialogMessage(active, &msg))
			continue;

		// If we get here, it's just a normal message, so Translate and
		// Dispatch.
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	//cleanup
	if (setts.DelTempOnExit)
		DeleteFile(setts.TempPath);

	fclose(stdout);

	return msg.wParam;
}