Exemplo n.º 1
0
//--------------------------------- Callback Functions --------------------------------------------
void GraphicalUI::cb_load_scene(Fl_Menu_* o, void* v) 
{
	GraphicalUI* pUI=whoami(o);
	
	static char* lastFile = 0;
	char* newfile = fl_file_chooser("Open Scene?", "*.ray", NULL );

	if (newfile != NULL) {
		char buf[256];

		if (pUI->raytracer->loadScene(newfile)) {
			sprintf(buf, "Ray <%s>", newfile);
			stopTracing();	// terminate the previous rendering
		} else{
			sprintf(buf, "Ray <Not Loaded>");
		}

		pUI->m_mainWindow->label(buf);
		pUI->m_debuggingWindow->m_debuggingView->setDirty();

		if( lastFile != 0 && strcmp(newfile, lastFile) != 0 )
			pUI->m_debuggingWindow->m_debuggingView->resetCamera();

		pUI->m_debuggingWindow->redraw();
	}
}
Exemplo n.º 2
0
/*
 * io_control_set_process_info
 *
 *  Arguments:
 *      irp
 *      io_stack_irp
 *      input_buffer
 *          setProcessInfo
 *      output_buffer
 */
NTSTATUS io_control_set_process_info(
        PIRP irp,
        PIO_STACK_LOCATION  io_stack_irp,
        unsigned char * input_buffer,
        unsigned char * output_buffer )
{
    NTSTATUS        function_result = STATUS_SUCCESS;
    setProcessInfo *   processInfo = (setProcessInfo *)input_buffer;

    UNREFERENCED_PARAMETER(irp);
    UNREFERENCED_PARAMETER(output_buffer);

    try {
        ProbeForRead(
                input_buffer,
                io_stack_irp->Parameters.DeviceIoControl.InputBufferLength,
                sizeof( char ) );
    } except (EXCEPTION_EXECUTE_HANDLER) {
        KdPrint(( "Oregano: io_control_set_process_info: Failed to read buffer\r\n" ));
        function_result = STATUS_DATA_ERROR;
        goto IO_CONTROL_SET_PROCESS_ID_INVALID_ARG;
    }

    if (0 != targetProcessId) {
        if (0 == processInfo->processId) {
            /* Clearing the target process */
            KdPrint( ("Oregano: io_control_set_process_info: Clearing process info\r\n") );
            stopTracing();
            goto IO_CONTROL_SET_PROCESS_ID_DONE;
        }
        else if (targetProcessId != (HANDLE)processInfo->processId) {
            /* Currently I can log only one process at a time */
            KdPrint( ("Oregano: io_control_set_process_info: You must stop tracing befor setting a new target process!\r\n") );
            function_result = STATUS_INVALID_PARAMETER_1;
            goto IO_CONTROL_SET_PROCESS_ID_INVALID_ARG;
        }
    }

    targetProcessId = (HANDLE)processInfo->processId;
    targetThreadId  = (HANDLE)processInfo->threadId;
    
    targetEProcess = NULL;
    target_process = NULL;
    function_result = PsLookupProcessByProcessId( targetProcessId, (PEPROCESS *)(&targetEProcess) );
    if (NT_SUCCESS(function_result) && (NULL != targetEProcess))
    {
        target_process = *(void **)(targetEProcess + offsets->eprocess.DirectoryTableBase);
    }
    else
    {
        KdPrint(("Oregano: io_control_set_process_info: Failed to query target process %p\r\n", targetProcessId));
    }

IO_CONTROL_SET_PROCESS_ID_INVALID_ARG:
IO_CONTROL_SET_PROCESS_ID_DONE:
    return function_result;
}
Exemplo n.º 3
0
NTSTATUS onClose(PDEVICE_OBJECT device_object, PIRP irp)
{
    /* Would hold the return code of the function */
    NTSTATUS    return_ntstatus = STATUS_SUCCESS;
    
    UNREFERENCED_PARAMETER(device_object);
    UNREFERENCED_PARAMETER(irp);

    PAGED_CODE();

    KdPrint(( "Oregano: on_close: Start\r\n" ));

    /* Stop any active trace */
    stopTracing();

    /* Unhook poor trap interrupt, if needed to... */
    if( 0 != orgTrapInterrupt ) {
        
        /* Would hold the current IDT address */
        idt_t               idt = {0};
        /* Would hold int1 info, original and new one */
        interrupt_info_t    int1_info = {0};
        /* Used only for setting the int address in the int1 info structure */
        MACHINE_LONG        trap_interrupt_address = 0;

        KdPrint(( "Oregano: on_close: Unhooking trap interrupt\r\n" ));
        
        /* First get the idt address */
        #ifndef AMD64
        load_idt( &idt );
        #else
        loadIdt64( &idt );
        #endif

        /* Get the current int1 function */
        get_interrupt_info( &idt, 1, &int1_info );

        /* Set back the old int1 */
#ifdef i386
        trap_interrupt_address = (MACHINE_LONG)orgTrapInterrupt;
        int1_info.low_offset    = (unsigned short)trap_interrupt_address;
        trap_interrupt_address >>= 16;
        int1_info.high_offset   = (unsigned short)trap_interrupt_address;
#elif AMD64
        trap_interrupt_address = (MACHINE_LONG)orgTrapInterrupt;
        int1_info.low_offset    = (unsigned short)trap_interrupt_address;
        trap_interrupt_address >>= 16;
        int1_info.middle_offset = (unsigned short)trap_interrupt_address;
        trap_interrupt_address >>= 16;
        int1_info.high_offset   = (unsigned long)trap_interrupt_address;
#endif
        hookAllCPUs( 1, &int1_info );
        orgTrapInterrupt = NULL;
        KdPrint(( "Oregano: on_close: Unhook done.\r\n" ));
    }
Exemplo n.º 4
0
void GraphicalUI::cb_exit2(Fl_Widget* o, void* v) 
{
	GraphicalUI* pUI=(GraphicalUI *)(o->user_data());
	
	// terminate the rendering
	stopTracing();

	pUI->m_traceGlWindow->hide();
	pUI->m_mainWindow->hide();
	pUI->m_debuggingWindow->hide();
}
Exemplo n.º 5
0
void GraphicalUI::cb_exit(Fl_Menu_* o, void* v)
{
	GraphicalUI* pUI=whoami(o);

	// terminate the rendering
	stopTracing();

	pUI->m_traceGlWindow->hide();
	pUI->m_mainWindow->hide();
	pUI->m_debuggingWindow->hide();
}
Exemplo n.º 6
0
void Tracer::trace()
{
	if( !scene_ || is_tracing_ )
	{
		return;
	}

	startTracing();

	const int width		= film_->getWidth();
	const int height	= film_->getHeight();
	const double aspect = static_cast< double >( width ) /
						  static_cast< double >( height );

	Logging::log( LogLevel::Info,
				"[Tracer] Tracing image with " + std::to_string( width ) + 
				" x " + std::to_string( height ) + " pixels (w x h) and " +
				std::to_string( rays_per_pixel_ ) + " samples per pixel." );

	std::thread t( [=]{
#pragma omp parallel for schedule( dynamic, 1 )	
	for( int samp = 0; samp < rays_per_pixel_; ++samp )
	{
		for( int y = 0; y < height && is_tracing_; ++y )
		{
			for( int x = 0; x < width && is_tracing_; ++x )
			{
				const double x_d = static_cast< double >( x );
				const double y_d = static_cast< double >( y );
				const double width_d = static_cast< double >( width );
				const double height_d = static_cast< double >( height );

				const double dx = aspect * ( x_d / width_d - .5 );
				const double dy = ( y_d / height_d - .5 );

				Color sample = traceLocation( dx, dy );
				film_->addSample( x, y, sample );
				curr_num_samples_.fetch_add( 1 );
			}			
		}
	}

	stopTracing();
	
	auto perf_string = std::to_string( getSpeedAsMsamplesPerSec() );
	// @TODO cutting away unwanted digits entails wrong rounding
	perf_string = perf_string.substr( 0, perf_string.length() - 4 );

	Logging::log( LogLevel::Info,
				  "[Tracer] Generated samples at a rate of " + perf_string +
					  " Msamples/sec." );
	} );
	t.detach();
}
Exemplo n.º 7
0
void GraphicalUI::cb_sizeSlides(Fl_Widget* o, void* v)
{
	GraphicalUI* pUI=(GraphicalUI*)(o->user_data());

	// terminate the rendering so we don't get crashes
	stopTracing();

	pUI->m_nSize=int( ((Fl_Slider *)o)->value() ) ;
	int	height = (int)(pUI->m_nSize / pUI->raytracer->aspectRatio() + 0.5);
	pUI->m_traceGlWindow->resizeWindow( pUI->m_nSize, height );
	// Need to call traceSetup before trying to render
	pUI->raytracer->setReady(false);
}
Exemplo n.º 8
0
/*
 * io_control_stop_trace
 *
 * Arguments:
 *      irp
 *      io_stack_irp
 *      input_buffer
 *      output_buffer
 */
NTSTATUS io_control_stop_trace(
        PIRP irp,
        PIO_STACK_LOCATION  io_stack_irp,
        unsigned char * input_buffer,
        unsigned char * output_buffer )
{
    /* Default return code is success */
    NTSTATUS    return_ntstatus = STATUS_SUCCESS;

    UNREFERENCED_PARAMETER(irp);
    UNREFERENCED_PARAMETER(io_stack_irp);
    UNREFERENCED_PARAMETER(input_buffer);
    UNREFERENCED_PARAMETER(output_buffer);

    stopTracing();

    return return_ntstatus;
}
Exemplo n.º 9
0
//--------------------------------- Callback Functions --------------------------------------------
void GraphicalUI::cb_load_scene(Fl_Menu_* o, void* v) 
{
	GraphicalUI* pUI=whoami(o);
	
	static char* lastFile = 0;
	const char* newfile = pUI->fileDialog(Fl_Native_File_Chooser::BROWSE_FILE,
											"Scene Description File (*.ray)\t*.ray",
											"Open Scene");
	if(!newfile)
		return;

	char buf[300];

	if (pUI->raytracer->loadScene(newfile)) {
		sprintf(buf, "Ray <%s>", newfile);
		stopTracing();	// terminate the previous rendering
	} else{
		sprintf(buf, "Ray <Not Loaded>");
	}

    char buftitle[300];
    int ic;
    for (ic = 299;ic >= 0; ic--) {
        buftitle[ic] = buf[ic];
        if (buf[ic] == '/') break;
    }

    ic++;

    for (int uc = ic;ic <  300; ic++) {
        buftitle[ic-uc] = buf[ic];
    }
    sprintf(buf, "Ray <%s", buftitle);
    
	pUI->m_mainWindow->label(buf);
	pUI->m_debuggingWindow->m_debuggingView->setDirty();

	if( lastFile != 0 && strcmp(newfile, lastFile) != 0 )
		pUI->m_debuggingWindow->m_debuggingView->resetCamera();

	pUI->m_debuggingWindow->redraw();
}
Exemplo n.º 10
0
//////////////////////////////////////////////////////////////////////////////
//WINMAIN
//////////////////////////////////////////////////////////////////////////////
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
#ifdef DEBUGGING
   startTracing(TRACEFILENAME);
#endif

   TRACE ("Start of Session___");
   
   //assign instance to global variable
   hInstMain=hInstance;

   //create window class
   WNDCLASSEX wcx;

   //set the size of the structure
   wcx.cbSize=sizeof(WNDCLASSEX);

   //class style
   wcx.style=CS_OWNDC | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;

   //window procedure
   wcx.lpfnWndProc=TheWindowProc;

   //class extra
   wcx.cbClsExtra=0;

   //window extra
   wcx.cbWndExtra=0;

   //application handle
   wcx.hInstance=hInstMain;

   //icon
   wcx.hIcon=LoadIcon(NULL,IDI_APPLICATION);

   //cursor
   wcx.hCursor=LoadCursor(NULL,IDC_ARROW);

   //background color
   wcx.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);

   //menu
   wcx.lpszMenuName=NULL;

   //class name
   wcx.lpszClassName=WINDOWCLASS;

   //small icon
   wcx.hIconSm=NULL;

   //register the window class, return 0 if not successful
   if(!RegisterClassEx(&wcx)) return(0);

   //create main window
   hWndMain=CreateWindowEx(0,
                           WINDOWCLASS,
                           WINDOWTITLE, 
                           WS_BORDER | WS_SYSMENU | WS_VISIBLE,
                           0,
                           0,
                           windowHorizontalSize,
                           windowVerticalSize,
                           NULL,
                           NULL,
                           hInstMain,
                           NULL);

   //error check
   if(!hWndMain)
   {
      return(0);
   }

   //if program initialization failed, then return with 0
   if(!Prog_Init()) 
   {
      return(0);
   }

   //message structure
   MSG msg;
   TRACE("start message pump..");

   //message pump
   for(;;)   
   {
      //look for a message
      if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
      {
         //there is a message

         //check that we arent quitting
         if(msg.message==WM_QUIT) 
         {
            break;
         }
         
         //translate message
         TranslateMessage(&msg);

         //dispatch message
         DispatchMessage(&msg);
      }

      //run main game loop
      Prog_Loop();
   }
   
   //clean up program data
   Prog_Done();

#ifdef DEBUGGING
   stopTracing();
#endif

   //return the wparam from the WM_QUIT message
   return(msg.wParam);
}