示例#1
0
int PrintAdapters()
{
	ListDevices();
#if 0
	nbPacketCapture PacketCapture;
	int IfNumber;

	nbNetVmPortLocalAdapter *DeviceList= PacketCapture.GetListLocalAdapters();
	if (DeviceList == NULL)
	{
		printf("Error getting the devices installed in the system: %s\n", PacketCapture.GetLastError() );
		return nbFAILURE;
	}

	printf("\nAdapters installed in the system:");
	printf("\n=================================\n\n");

	IfNumber= 1;

	while (DeviceList)
	{
		printf("Interface %d: %s (%s)\n", IfNumber, DeviceList->Name, DeviceList->Description);

		DeviceList= DeviceList->GetNext();
		IfNumber++;
	}
#endif
	return nbSUCCESS;

}
示例#2
0
void SelectDirDlg::SetDataDir(QString dir)
{
	ui.edtPath->setText(dir);

	if ( dir.isEmpty() )
		return;

	ListDevices();
}
示例#3
0
void SelectDirDlg::Browse()
{
	QString dir = QFileDialog::getExistingDirectory(this, Utils::stoq("选择案例所在目录"));

	if ( dir.isEmpty() )
		return;

	dir.replace("/", "\\");
	ui.edtPath->setText(dir);

	ListDevices();
}
示例#4
0
int main(int argc, char* argv[]) {
  int device_num = 0; // Default to device ID 0
  if (argc >= 2) {
    char *end;
    long value = strtol(argv[1], &end, 10); 
    if (!(end == argv[1] || *end != '\0' || errno == ERANGE)) {
      ListAllDynamixels(device_num);
    } else {
      printf("Arg 1 (%s) was not recognized as an integer device number.\n", argv[1]);
    }
  } else {
    printf("Enter USB2AX ttyACM* number as argument 1!\n");
    printf("Here are some possible device ID's from /dev/*.\n");
    ListDevices();
  }
  return 0;
}
示例#5
0
void Sys_PlatformInit( void )
{
	// Init libxenon
	xenos_init(VIDEO_MODE_AUTO);

	console_init();

	xenon_make_it_faster(XENON_SPEED_FULL);
	
	
	http_output_start();
		
#if 0
	threading_init();
	network_init_sys();
#endif	
	
	usb_init();
	usb_do_poll();

	xenon_ata_init();
	xenon_atapi_init();

	// fatInitDefault();
	// XTAFMount();	
	
	// fatInit(16, 1);
	
	fatMount ("uda", &usb2mass_ops_0, 0, 256, 64);
	
	ListDevices();
	
	Sys_SetEnv("HOME", "uda:/");
	
	console_close();
}
示例#6
0
int _cdecl main(int argc, char *argv[])
{
    SC_HANDLE               hSCManager = NULL;
    SC_HANDLE               hService = NULL;
    SERVICE_STATUS_PROCESS  serviceInfo;
    DWORD                   bytesNeeded;
    HANDLE                  hDevice = NULL;
    BOOL                    bResult;
    DWORD                   result;
    ULONG                   threadId;
    HANDLE                  thread = NULL;
    LOG_CONTEXT             context;
    INT                     inputChar;


    //
    // Initialize handle in case of error
    //

    context.ShutDown = NULL;
    context.VerbosityFlags = 0;

    //
    // Start the kernel mode driver through the service manager
    //
    
    hSCManager = OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS) ;
    if (NULL == hSCManager) {
        result = GetLastError();
        printf("ERROR opening Service Manager...\n");
        DisplayError( result );
        goto Main_Continue;
    }


    hService = OpenService( hSCManager,
                            FILESPY_SERVICE_NAME,
                            FILESPY_SERVICE_ACCESS);

    if (NULL == hService) {
        result = GetLastError();
        printf("ERROR opening FileSpy Service...\n");
        DisplayError( result );
        goto Main_Continue;
    }

    if (!QueryServiceStatusEx( hService,
                               SC_STATUS_PROCESS_INFO,
                               (UCHAR *)&serviceInfo,
                               sizeof(serviceInfo),
                               &bytesNeeded))
    {
        result = GetLastError();
        printf("ERROR querrying status of FileSpy Service...\n");
        DisplayError( result );
        goto Main_Continue;
    }

    if(serviceInfo.dwCurrentState != SERVICE_RUNNING) {
        //
        // Service hasn't been started yet, so try to start service
        //
        if (!StartService(hService, 0, NULL)) {
            result = GetLastError();
            printf("ERROR starting FileSpy service...\n");
            DisplayError( result );
            goto Main_Continue;
        }
    }
   

Main_Continue:
    printf("Hit [Enter] to begin command mode...\n");

    //
    //  Open the device that is used to talk to FileSpy.
    //
    printf("FileSpy:  Opening device...\n");
    
    hDevice = CreateFile( FILESPY_W32_DEVICE_NAME,
                          GENERIC_READ | GENERIC_WRITE,
                          0,
                          NULL,
                          OPEN_EXISTING,
                          FILE_ATTRIBUTE_NORMAL,
                          NULL);
    if (hDevice == INVALID_HANDLE_VALUE) {
        result = GetLastError();
        printf("ERROR opening device...\n");
        DisplayError( result );
        goto Main_Exit;
    }
    
    //
    //  Initialize the fields of the LOG_CONTEXT.
    //
    context.Device = hDevice;
    context.ShutDown = CreateSemaphore(
        NULL, 
        0, 
        1, 
        L"FileSpy shutdown");

    if (context.ShutDown == NULL) {
        //
        //  Insufficient memory for this semaphore, so shutdown.
        //

        printf( "ERROR insufficient memory\n" );
        goto Main_Exit;
    }
    
    context.CleaningUp = FALSE;
    context.LogToScreen = context.NextLogToScreen = TRUE;
    context.LogToFile = FALSE;
    context.OutputFile = NULL;

    //
    // Check the valid parameters for startup
    //
    if (argc > 1) {
        if (InterpretCommand(argc - 1, &(argv[1]), &context) == USAGE_ERROR) {
            goto Main_Exit;
        }
    }

    //
    // Propagate the /s switch to the variable that the logging
    // thread checks.
    //
    context.LogToScreen = context.NextLogToScreen;

    //
    // Check to see what devices we are attached to from
    // previous runs of this program.
    //
    bResult = ListDevices(&context);
    if (!bResult) {
        result = GetLastError();
        printf("ERROR listing devices...\n");
        DisplayError( result );
    }

    //
    // Create the thread to read the log records that are gathered
    // by filespy.sys.
    //
    printf("FileSpy:  Creating logging thread...\n");
    thread = CreateThread(
        NULL,
        0,
        RetrieveLogRecords,
        (LPVOID)&context,
        0,
        &threadId);
    if (!thread) {
        result = GetLastError();
        printf("ERROR creating logging thread...\n");
        DisplayError( result );
        goto Main_Exit;
    }

    while (inputChar = getchar()) {
        CHAR    commandLine[81];
        INT     parmCount, count, ch;
        CHAR  **parms;
        BOOLEAN newParm;
        DWORD   returnValue = SUCCESS;

        if (inputChar == '\n') {
            //
            // Start command interpreter.  First we must turn off logging
            // to screen if we are.  Also, remember the state of logging
            // to the screen, so that we can reinstate that when command
            // interpreter is finished.
            //
            context.NextLogToScreen = context.LogToScreen;
            context.LogToScreen = FALSE;

            while (returnValue != EXIT_INTERPRETER) {
                //
                // Print prompt
                //
                printf(">");

                //
                // Read in next line, keeping track of the number of parameters 
                // as you go
                //
                parmCount = 1;
                for (count = 0; 
                     (count < 80) && ((ch = getchar())!= '\n'); 
                     count++) {
                    commandLine[count] = (CHAR)ch;
                    if (ch == ' ') {
                        parmCount ++;
                    }
                }
                commandLine[count] = '\0';
    
                parms = (CHAR **)malloc(parmCount * sizeof(CHAR *));
    
                parmCount = 0;
                newParm = TRUE;
                for (count = 0; commandLine[count] != '\0'; count++) {
                    if (newParm) {
                        parms[parmCount] = &(commandLine[count]);
                        parmCount ++;
                    }
                    if (commandLine[count] == ' ' ) {
                        newParm = TRUE;
                    } else {
                        newParm = FALSE;
                    }
                }
    
                //
                // We've got our parameter count and parameter list, so
                // send it off to be interpreted.
                //
                returnValue = InterpretCommand(parmCount, parms, &context);
                free(parms);
                if (returnValue == EXIT_PROGRAM) {
                    // Time to stop the program
                    goto Main_Cleanup;
                }
            }

            // Set LogToScreen appropriately based on any commands seen
            context.LogToScreen = context.NextLogToScreen;

            if (context.LogToScreen) {
                printf("Should be logging to screen...\n");
            }
        }
    }

Main_Cleanup:
    //
    // Clean up the threads, then fall through to Main_Exit
    //

    printf("FileSpy:  Cleaning up...\n");
    // 
    // Set the Cleaning up flag to TRUE to notify other threads
    // that we are cleaning up
    //
    context.CleaningUp = TRUE;

    // 
    // Wait for everyone to shut down
    //
    WaitForSingleObject(context.ShutDown, INFINITE);
    if (context.LogToFile) {
        fclose(context.OutputFile);
    }

Main_Exit:
    // 
    // Clean up the data that is always around and exit
    //
    if(context.ShutDown) {
        CloseHandle(context.ShutDown);
    }
    if (thread) {
        CloseHandle(thread);
    }

    if(hSCManager) {
        CloseServiceHandle(hSCManager);
    }
    if(hService) {
        CloseServiceHandle(hService);
    }
    if (hDevice) {
        CloseHandle(hDevice);
    }
    
    printf("FileSpy:  All done\n");
    return 0;  

}
示例#7
0
DWORD
InterpretCommand(
    int argc,
    char *argv[],
    PLOG_CONTEXT Context
)
{
    int         parmIndex;
    CHAR       *parm;      
    BOOL        bResult;
    DWORD       result;
    DWORD       returnValue = SUCCESS;
    CHAR        buffer[BUFFER_SIZE];
    DWORD       bufferLength;
    DWORD       bytesReturned;

    //
    // Interpret the command line parameters
    //
    for (parmIndex = 0; parmIndex < argc; parmIndex++) {
        parm = argv[parmIndex];
        if (parm[0] == '/') {
            //
            // Have the beginning of a switch
            //
            switch (parm[1]) {
            case 'a':
            case 'A':
                //
                // Attach to the specified drive letter
                //
                parmIndex++;
                if (parmIndex >= argc) {
                    //
                    // Not enough parameters
                    //
                    goto InterpretCommand_Usage;
                }
                parm = argv[parmIndex];
                printf("\tAttaching to %s\n", parm);
                bufferLength = MultiByteToWideChar(
                    CP_ACP,
                    MB_ERR_INVALID_CHARS,
                    parm,
                    -1,
                    (LPWSTR)buffer,
                    BUFFER_SIZE/sizeof(WCHAR));
                
                bResult = DeviceIoControl(
                    Context->Device,
                    FILESPY_StartLoggingDevice,
                    buffer,
                    bufferLength * sizeof(WCHAR),
                    NULL,
                    0,
                    &bytesReturned,
                    NULL);
                if (!bResult) {
                    result = GetLastError();
                    printf("ERROR attaching to device...\n");
                    DisplayError( result );
                }
                
                break;

            case 'd':
            case 'D':
                //
                // Detach to the specified drive letter
                //
                parmIndex++;
                if (parmIndex >= argc) {
                    //
                    // Not enough parameters
                    //
                    goto InterpretCommand_Usage;
                }
                parm = argv[parmIndex];
                printf("\tDetaching from %s\n", parm);
                bufferLength = MultiByteToWideChar(
                    CP_ACP,
                    MB_ERR_INVALID_CHARS,
                    parm,
                    -1,
                    (LPWSTR)buffer,
                    BUFFER_SIZE/sizeof(WCHAR));
                
                bResult = DeviceIoControl(
                    Context->Device,
                    FILESPY_StopLoggingDevice,
                    buffer,
                    bufferLength * sizeof(WCHAR),
                    NULL,
                    0,
                    &bytesReturned,
                    NULL);
                
                if (!bResult) {
                    result = GetLastError();
                    printf("ERROR detaching to device...\n");
                    DisplayError( result );
                }
                break;
            
            case 'h':
            case 'H':
                ListHashStats(Context);
                break;

            case 'l':
            case 'L':
                //
                // List all devices that are currently being monitored
                //
                bResult = ListDevices(Context);
                if (!bResult) {
                    result = GetLastError();
                    printf("ERROR listing devices...\n");
                    DisplayError( result );
                }
                
                break;

            case 's':
            case 'S':
                //
                // Output logging results to screen, save new value to
                // instate when command interpreter is exited.
                //
                if (Context->NextLogToScreen) {
                    printf("\tTurning off logging to screen\n");
                } else {
                    printf("\tTurning on logging to screen\n");
                }
                Context->NextLogToScreen = !Context->NextLogToScreen;
                break;

            case 'f':
            case 'F':
                //
                // Output logging results to file
                //
                if (Context->LogToFile) {
                    printf("\tStop logging to file \n");
                    Context->LogToFile = FALSE;
                    _ASSERT(Context->OutputFile);
                    fclose(Context->OutputFile);
                    Context->OutputFile = NULL;
                } else {
                    parmIndex++;
                    if (parmIndex >= argc) {
                        // Not enough parameters
                        goto InterpretCommand_Usage;
                    }
                    parm = argv[parmIndex];
                    Context->OutputFile = fopen(parm, "w");

                    if (Context->OutputFile == NULL) {
                        result = GetLastError();
                        printf("\nERROR opening \"%s\"...\n",parm);
                        DisplayError( result );

                        returnValue = USAGE_ERROR;
                        goto InterpretCommand_Exit;
                    }
                    
                    Context->LogToFile = TRUE;
                    printf("\tLog to file %s\n", parm);
                }
                break;

            case 'v':
            case 'V':
                //
                // Toggle the specified verbosity flag.
                //
                parmIndex++;
                if (parmIndex >= argc) {
                    //
                    // Not enough parameters
                    //
                    goto InterpretCommand_Usage;
                }
                parm = argv[parmIndex];
                switch(parm[0]) {
                case 'p':
                case 'P':
                    ToggleFlag( Context->VerbosityFlags, FS_VF_DUMP_PARAMETERS );
                    break;

                default:                    
                    //
                    // Invalid switch, goto usage
                    //
                    goto InterpretCommand_Usage;
                }
                break;

            default:
                //
                // Invalid switch, goto usage
                //
                goto InterpretCommand_Usage;
            }
        } else {
            //
            // Look for "go" or "g" to see if we should exit interpreter
            //
            if (!_strnicmp(
                    parm, 
                    INTERPRETER_EXIT_COMMAND1, 
                    sizeof(INTERPRETER_EXIT_COMMAND1))) {
                returnValue = EXIT_INTERPRETER;
                goto InterpretCommand_Exit;
            }
            if (!_strnicmp(
                    parm, 
                    INTERPRETER_EXIT_COMMAND2, 
                    sizeof(INTERPRETER_EXIT_COMMAND2))) {
                returnValue = EXIT_INTERPRETER;
                goto InterpretCommand_Exit;
            }
            //
            // Look for "exit" to see if we should exit program
            //
            if (!_strnicmp(
                    parm, 
                    PROGRAM_EXIT_COMMAND, 
                    sizeof(PROGRAM_EXIT_COMMAND))) {
                returnValue = EXIT_PROGRAM;
                goto InterpretCommand_Exit;
            }
            //
            // Invalid parameter
            //
            goto InterpretCommand_Usage;
        }
    }

InterpretCommand_Exit:
    return returnValue;

InterpretCommand_Usage:
    printf("Valid switches: [/a <drive>] [/d <drive>] [/h] [/l] [/s] [/f [<file name>] [/v <flag>]]\n"
           "\t[/a <drive>] attaches monitor to <drive>\n"
           "\t[/d <drive>] detaches monitor from <drive>\n"
           "\t[/h] print filename hash statistics\n"
           "\t[/l] lists all the drives the monitor is currently attached to\n"
           "\t[/s] turns on and off showing logging output on the screen\n"
           "\t[/f [<file name>]] turns on and off logging to the specified file\n"
           "\t[/v <flag>] toggles a verbosity flag.  Valid verbosity flags are:\n"
           "\t\tp (dump irp parameters)\n"
           "If you are in command mode,\n"
           "\t[go|g] will exit command mode\n"
           "\t[exit] will terminate this program\n"
           );
    returnValue = USAGE_ERROR;
    goto InterpretCommand_Exit;
}
示例#8
0
PortAudioSound::PortAudioSound()
{
	error(Pa_Initialize());
	
	iSampleRate = 192000;
	sampleRate = (double) iSampleRate;
	framesPerBuffer = 2048;
	FFTSize = 512;
	FFTsPerBuffer = framesPerBuffer/FFTSize;
	recordflag = false;
	Processing = FALSE;
	overlap = FALSE;
	
	if (!logFile.Open(L"C:/Bat Recordings/TestFileLog.txt", CFile::modeCreate | CFile::modeWrite | CFile::typeText)){
		OutputDebugString(L"Unable to open Log File\n");
	}

	numBuffers = 16;
	ReadIndex = 0;
	WriteIndex = 0;
	currentColumn = 0;
	currentRow = 0;
	maxi = 6.0;
	mini = -6.0;
	
	FFTin = (double *) fftw_malloc(sizeof(double) * (FFTSize+2));
	FFTout = (double *) fftw_malloc(sizeof(double) * FFTSize);
	hamming = (double *) fftw_malloc(sizeof(double) * FFTSize);
	CreateHammingProfile(hamming);
	FFTplan = fftw_plan_r2r_1d(FFTSize, FFTin, FFTout, FFTW_DHT, FFTW_ESTIMATE);
	ppPowSpect = (double **) fftw_malloc(sizeof(double *) * numBuffers);
	ppShade = (BYTE **) fftw_malloc(sizeof(BYTE *) *numBuffers);
	for (int i = 0; i < numBuffers; i++){
		ppPowSpect[i] = (double *) fftw_malloc(sizeof(double) * (FFTSize+1));
		ppShade[i] = (BYTE *) fftw_malloc(sizeof(BYTE) * (FFTSize + 1));
	}
	//FFTplan = fftw_plan_dft_r2c_1d(512, FFTin, FFTout,  FFTW_ESTIMATE);
	//Pspect = (double *) fftw_malloc(sizeof(double) * 512);

	ListDevices();

	PaStreamParameters inputParameters;

	inputParameters.device = 1;
	inputParameters.channelCount = 1;
	inputParameters.sampleFormat = paInt16;
	
	inputParameters.suggestedLatency = Pa_GetDeviceInfo(inputParameters.device)->defaultHighInputLatency;
	inputParameters.hostApiSpecificStreamInfo = NULL;
	int err = Pa_IsFormatSupported(&inputParameters, NULL, sampleRate);
	if (err==0){
		logFile.WriteString(L"Input format is supported\n");
	}
	else{
		logFile.WriteString(L"Input format NOT supported\n");
	}


	
	//error(Pa_OpenStream(
	//	&pStream,
	//	&inputParameters, /* input channel*/
	//	NULL, /* output channel*/
	//	Pa_GetDeviceInfo(inputParameters.device)->defaultSampleRate,
	//	2048,
	//	paClipOff,
	//	&PortAudioSound::myPaCallback,
	//	this
	//	));
		

		error(Pa_OpenStream(
		&pStream,
		&inputParameters, /* input channel*/
		NULL, /* output channel*/
		sampleRate,
		framesPerBuffer,
		paClipOff,
		&PortAudioSound::myPaCallback,
		this
		));

	logFile.WriteString(L"Stream opened\n");
	const PaDeviceInfo* info= Pa_GetDeviceInfo(1);
	CString lf;
	lf.Format(L"Max Input Channels=%d\n", info->maxInputChannels);
	logFile.WriteString(lf);
	lf.Format(L"Default sample rate=%f\n", info->defaultSampleRate);
	logFile.WriteString(lf);
	lf.Format(L"Default input device name=%s\n", CString((info->name)));
	logFile.WriteString(lf);
	lf.Format(L"Default HostApi=%s\n\n",CString((Pa_GetHostApiInfo(info->hostApi)->name)));
	logFile.WriteString(lf);
	


}
示例#9
0
//============================================================================
LRESULT CALLBACK WndProc (
    _In_ HWND   hwnd,
    _In_ UINT   uMsg,
    _In_ WPARAM wParam,
    _In_ LPARAM lParam
) {

    PAINTSTRUCT paint_struct;
    HDC hDC;

    switch (uMsg) {
        case WM_PAINT: {
            hDC = BeginPaint(hwnd, &paint_struct);
            EndPaint(hwnd, &paint_struct);
        } return 0;

        case WM_DESTROY: {
            PostQuitMessage(0);
        } return 0;

        case WM_CHAR: {
            if (wParam == VK_ESCAPE) {
                PostQuitMessage(0);
                return 0;
            }
            else if (wParam == 'l') {
                ListDevices();
            }
        } break;
        
        case WM_INPUT: {
            static const UINT s_ds4Vendor  = 0x54C;
            static const UINT s_ds4Product = 0x5C4;
            UINT              bufferSize   = 0;
            
            GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &bufferSize, sizeof(RAWINPUTHEADER));
            LPBYTE lpb = new BYTE[bufferSize];
            memset(lpb, 0, bufferSize);
            if (lpb == NULL) 
                break;

            GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &bufferSize, sizeof(RAWINPUTHEADER));
            RAWINPUT* raw = (RAWINPUT*)lpb;
            if (raw->header.dwType != RIM_TYPEHID)
                break;
                
            RID_DEVICE_INFO sRidDeviceInfo;
            UINT            sRidDeviceInfoSize = sizeof(sRidDeviceInfo);
            memset(&sRidDeviceInfo, 0, sizeof(sRidDeviceInfo));
            if (GetRawInputDeviceInfo(raw->header.hDevice, RIDI_DEVICEINFO, &sRidDeviceInfo, &sRidDeviceInfoSize) <= 0 ) {
                OutputDebugString(L"failed to get raw input's device info...\n");
                break;
            }
            // Ignore anything that's not a DualShock 4 controller
            if (sRidDeviceInfo.hid.dwVendorId != s_ds4Vendor || sRidDeviceInfo.hid.dwProductId != s_ds4Product)
                break;
                
            ReadDs4RawInput(raw->data.hid.dwCount, raw->data.hid.dwSizeHid, raw->data.hid.bRawData);

            delete[] lpb; 
        } return 0;
    }

    return DefWindowProc(hwnd, uMsg, wParam, lParam);

}
示例#10
0
std::list<std::string> UIScheduler::GetDevices() {
    std::list<std::string> devices;
    ListDevices(&devices);
    return devices;
}