Example #1
0
static int
server_acquire_creds(char *service_name, gss_cred_id_t *server_creds)
{
    gss_buffer_desc name_buf;
    gss_name_t server_name;
    OM_uint32 maj_stat, min_stat;

    name_buf.value = service_name;
    name_buf.length = strlen(name_buf.value) + 1;
    maj_stat = gss_import_name(&min_stat, &name_buf,
                               (gss_OID) gss_nt_service_name, &server_name);
    if (maj_stat != GSS_S_COMPLETE) {
        display_status("importing name", maj_stat, min_stat);
        return -1;
    }

    maj_stat = gss_acquire_cred(&min_stat, server_name, 0,
                                GSS_C_NO_OID_SET, GSS_C_ACCEPT,
                                server_creds, NULL, NULL);
    if (maj_stat != GSS_S_COMPLETE) {
        display_status("acquiring credentials", maj_stat, min_stat);
        return -1;
    }

    (void) gss_release_name(&min_stat, &server_name);

    return 0;
}
Example #2
0
File: common.c Project: PADL/krb5
void
check_gsserr(const char *msg, OM_uint32 major, OM_uint32 minor)
{
    if (GSS_ERROR(major)) {
        display_status(msg, major, GSS_C_GSS_CODE);
        display_status(msg, minor, GSS_C_MECH_CODE);
        exit(1);
    }
}
Example #3
0
void on_new_logentry_activate(GtkMenuItem *menuitem, gpointer user_data)
{
	if (log_on == 1)
	{
	  display_status("log frame is visible, just enter dates and then click 'save entry'");
	}
	else
	{
	  display_status("New logentry: enter dates and then click 'OK & save'");
	  gtk_widget_show(wqsoeditor);	
	}
}
Example #4
0
void on_qso_cancel_clicked (GtkButton *button, gpointer user_data)
{
	gtk_widget_hide(wqsoeditor);
	actlog = 0;
	log_set(0);
	display_status("nothing changed in log.");
}
Example #5
0
int wait_for_event( VSS_INFO *vss_info )
{
  EVENT  event ;
  size_t load_time ;
  int    ret = 0 ;
  int    which ;

  display_status( STATUS_WAITING ) ;

  memset( &event, 0, sizeof(EVENT) ) ;
  event.ev_mflags     = MU_KEYBD | MU_TIMER | MU_BUTTON ;
  if ( vss_info->wait_mini_sec < 0 ) event.ev_mflags &= ~MU_TIMER ;
  event.ev_mbclicks   = 258 ;
  event.ev_bmask      = 3 ;
  event.ev_mtlocount  = 0 ;
  event.ev_mthicount  = 0 ;
  load_time           = PerfInfo.total_load_time ;
  if ( 100L*vss_info->wait_mini_sec > load_time )
    event.ev_mtlocount = (int) ( 1000L*vss_info->wait_mini_sec - 10L*load_time ) ;

  which = EvntMulti( &event ) ;
  if ( which & MU_KEYBD )
    if ( event.ev_mkreturn == TESC ) ret = -1 ;

  return( ret ) ;
}
Example #6
0
int load_nextimg( char *name, MFDB *mfdb, INFO_IMAGE *inf, VSS_INFO *vss_info, GEM_WINDOW *wprog )
{
  int ret ;

  display_status( STATUS_LOADING ) ;
  ret = img_format( name, inf ) ;
  if ( ret != 0 )
  {
    if ( inf->palette ) free( inf->palette ) ;
  }
  else
  {
    memset( mfdb, 0, sizeof(MFDB) ) ;
    mfdb->fd_nplanes = nb_plane ;
    if ( nb_plane == 16 ) Force16BitsLoad = 1 ;
    else                  Force16BitsLoad = 0 ;
    mouse_busy() ;
    ret = load_picture( name, mfdb, inf, wprog ) ;
    mouse_restore() ;
    mfdb->fd_w = inf->largeur ; /* Evite la bande sur la droite */
    if ( ( vss_info->display_type & DISPLAYTYPE_ZOOM ) &&
        ( ( mfdb->fd_w < 1+Xmax ) || ( mfdb->fd_h < 1+Ymax ) )
      )
     strech_img( mfdb ) ;
   else
    if ( ( vss_info->display_type & DISPLAYTYPE_REDUC ) &&
         ( ( mfdb->fd_w > 1+Xmax ) || ( mfdb->fd_h > 1+Ymax ) )
      )
     strech_img( mfdb ) ;
  }

  log_event( CMD_DISPLAY, name ) ;

  return( ret ) ;
}
Example #7
0
static void heat_iteration(struct brew_task *bt)
{
    int ii = 0;
    display_status();

    // kick off reading the temp
    vTaskEnterCritical();
    DS1820Init();
    DS1820Skip();
    DS1820Convert();
    vTaskExitCritical();

    // 1 second delay, run heat according to the duty cycle
    for (ii = 0; ii < 100; ii++)
    {
	if (ds1820_get_temperature() < heat_target &&
	    ii <= heat_duty_cycle &&
	    level_hit_heat() == 1) // check the element is covered
	{
	    outputOn(SSR);
	}
	else
	{
	    heat_target_reached = test_had_reached_target();
	    allOff();
	}
	vTaskDelay(10); // wait for the conversion to happen
    }

    vTaskEnterCritical();
    DS1820ReadTemp();
    vTaskExitCritical();
    heat_keep_temperature();
}
//## operation display_status()
void display_status() {
    NOTIFY_FUNCTION(Default, display_status, display_status(), 0, Default_display_status_SERIALIZE);
    //#[ operation display_status()
    bool on = Light.IS_IN(ON);
    
    std::cout << "Lightbulb: (" << (on ? "*" : "O") << ")\n";
    //#]
}
Example #9
0
void param_read()
{
/* aus config-Datei gespeicherte params einlesen ------------------- */
	FILE *conf;
	conf = fopen("hf/hfterm.rc", "r");
	if(conf == NULL) {
	  display_status("Configuration File hf/hfterm.rc can not be opened.");
	  return;
	}  
	else	
	
	display_status ("Configuration File hf/hfterm.rc opened.");
	if(fread(&params, sizeof(params), 1, conf) != 1) {
		display_status("Error while reading configuration file.");
		fclose(conf);	
		return;
	}
	fclose(conf);	
} 
/**
 * The function corresponding to 
 * void ExposureControl.setExposureCompensation()
 *  method of AMMS Java API, see JSR-234 Spec
 *
 * Sets the exposure compensation.
 *
 * @param hNative  native handle.
 *     Java layer guarantees the following:
 *        - it is a valid media player handle,
 *        - it refers to a video capture player,
 *        - the player has acquired exclusive
 *          access to the camera device
 * @param ec  new exposure compensation value
 *
 * @retval JAVACALL_OK if operation is successful
 * @retval JAVACALL_FAIL if the given value is not supported
 *
 * @see
 *     javacall_amms_exposure_control_get_supported_exposure_compensations_count
 * @see javacall_amms_exposure_control_get_supported_exposure_compensation
 */
javacall_result javacall_amms_exposure_control_set_exposure_compensation(
    javacall_handle hNative, long ec)
{
    audio_handle* ah = (audio_handle*)(((javacall_impl_player*)hNative)->mediaHandle);
    camera_state* cs = (camera_state*)( ah->pExtraCC );

    if( 0 != ec ) return JAVACALL_FAIL;
    display_status( cs );
    return JAVACALL_OK;
}
Example #11
0
void on_qso_clear_clicked (GtkButton *button, gpointer user_data)
{
	log_search();
	if (actlog > 0)
	{
	  log_delete_entry(actlog);
	  log_shift_entries(actlog);
	  actlog = 0;
	  log_set(0);
	  display_status("log entry cleared.");
	  log_store();
	}
	else 
	{
	  log_set(0);
          display_status("nothing changed in log.");	
	}
	gtk_widget_hide(wqsoeditor);
}
Example #12
0
/*
 * Yes, yes, this isn't the best place for doing this test.
 * DO NOT REMOVE THIS UNTIL A BETTER TEST HAS BEEN WRITTEN, THOUGH.
 *                                      -TYT
 */
static int
test_import_export_context(gss_ctx_id_t *context)
{
    OM_uint32 min_stat, maj_stat;
    gss_buffer_desc context_token, copied_token;
    struct timeval tm1, tm2;

    /*
     * Attempt to save and then restore the context.
     */
    gettimeofday(&tm1, (struct timezone *) 0);
    maj_stat = gss_export_sec_context(&min_stat, context, &context_token);
    if (maj_stat != GSS_S_COMPLETE) {
        display_status("exporting context", maj_stat, min_stat);
        return 1;
    }
    gettimeofday(&tm2, (struct timezone *) 0);
    if (verbose && logfile)
        fprintf(logfile, "Exported context: %d bytes, %7.4f seconds\n",
                (int) context_token.length, timeval_subtract(&tm2, &tm1));
    copied_token.length = context_token.length;
    copied_token.value = malloc(context_token.length);
    if (copied_token.value == 0) {
        if (logfile)
            fprintf(logfile,
                    "Couldn't allocate memory to copy context token.\n");
        return 1;
    }
    memcpy(copied_token.value, context_token.value, copied_token.length);
    maj_stat = gss_import_sec_context(&min_stat, &copied_token, context);
    if (maj_stat != GSS_S_COMPLETE) {
        display_status("importing context", maj_stat, min_stat);
        return 1;
    }
    free(copied_token.value);
    gettimeofday(&tm1, (struct timezone *) 0);
    if (verbose && logfile)
        fprintf(logfile, "Importing context: %7.4f seconds\n",
                timeval_subtract(&tm1, &tm2));
    (void) gss_release_buffer(&min_stat, &context_token);
    return 0;
}
Example #13
0
void param_store()
{
/* - Konfiguration speichern ----------------------------------------*/
	FILE *conf = fopen("hf/hfterm.rc", "w");
	if(conf == NULL) {
	  display_status
	      ("Configuration File hf/hfterm.rc can not be opened.");
	  return;
	} else	
	    display_status("Configuration File hf/hfterm.rc opened.");
	if(fwrite(&params, sizeof(params), 1, conf) != 1)
	{
	  display_status
	      ("Error while writing configuration file hf/hfterm.rc.");
	  return;
	}
	else	
	display_status("Configuration stored in hf/hfterm.rc.");
	fclose(conf);	
}
Example #14
0
void on_archivate_activate(GtkMenuItem *menuitem, gpointer user_data)
{
	{
	  log_archivate();
	  log_delete_all();
	  log_list();
	  log_set(0);	  
	  log_store();
	}
	display_status("(log has been archivated on your demand.)");
}	
Example #15
0
// at the moment unused	
void on_delete1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
	{
	  log_delete_all();
	  lb.logsize = 0;
	  log_list();
	  log_set(0);	  
	  log_store();
	}
	display_status("Why did you clear your log? Work them again!");
}	
/**
 * The function corresponding to 
 * int ExposureControl.setExposureTime()
 *  method of AMMS Java API, see JSR-234 Spec
 *
 * Sets the shutter speed.
 *
 * @param hNative  native handle.
 *     Java layer guarantees the following:
 *        - it is a valid media player handle,
 *        - it refers to a video capture player,
 *        - the player has acquired exclusive
 *          access to the camera device
 * @param eTime  pointer to the new exposure time value. The value is in
 *     microseconds, 0 indicates automatic exposure time.
 *
 * @retval JAVACALL_OK if operation is successful
 * @retval JAVACALL_FAIL if the given time is outside of the supported range
 * @retval JAVACALL_INVALID_ARGUMENT indicates one of the following errors:
 *        - \a eTime is \a NULL
 *
 * @see javacall_amms_exposure_control_get_min_exposure_time
 * @see javacall_amms_exposure_control_get_max_exposure_time
 */
javacall_result javacall_amms_exposure_control_set_exposure_time(
    javacall_handle hNative, /*IN/OUT*/long *eTime)
{
    audio_handle* ah = (audio_handle*)(((javacall_impl_player*)hNative)->mediaHandle);
    camera_state* cs = (camera_state*)( ah->pExtraCC );

    if( NULL == eTime ) return JAVACALL_INVALID_ARGUMENT;
    if( 0 != *eTime ) return JAVACALL_FAIL;
    display_status( cs );
    return JAVACALL_OK;
}
Example #17
0
void on_logentry_clear_clicked (GtkButton *button, gpointer user_data)
{
	log_search();
	gtk_widget_hide(Wsearchlogentr);
	if (actlog == 0) 
	//only clear window
	{
	  log_set(0);
	  display_status("entry was not yet stored, only mask cleared.");
	  return;
	}
	else
	{
	  log_delete_entry(actlog);
	  log_shift_entries(actlog);
	  actlog = 0;
	  log_set(0);
	  display_status("log entry cleared.");
	  log_store();
	}
}
Example #18
0
int 
status_switch(struct CONN * prev, enum STATUS status) 
{
#define CURR (prev->next)
	display_status( stdout, CURR, status );
	if ( status == CLOSED || 
	     status == RESET  || 
	     status == EXPIRED )
		rmconn( prev );
	else
		CURR->status = status;
}
Example #19
0
static int
clone_child(void *arg)
{

    usleep(10000);      /* Just avoid confused intermingling of output */
    logmsg("\t\t", "clone child started\n");
    display_status("\t\t");

    /* Change the root directory. This affects the parent process,
       since it shares the root directory attribute. */

    if (chdir("chroot") == -1)
        errExit("chdir");
    if (chroot(".") == -1)
        errExit("chroot");

    logmsg("\t\t", "finished chroot()\n");
    display_status("\t\t");

    logmsg("\t\t", "exiting\n");
    return 0;
}
/**
 * The function corresponding to 
 * void ExposureControl.setLightMetering()
 *  method of AMMS Java API, see JSR-234 Spec
 *
 * Sets the metering mode for the automatic exposure of the camera.
 *
 * @param hNative  native handle.
 *     Java layer guarantees the following:
 *        - it is a valid media player handle,
 *        - it refers to a video capture player,
 *        - the player has acquired exclusive
 *          access to the camera device
 * @param lm  the new metering mode (null-terminated string)
 *
 * @retval JAVACALL_OK if operation is successful
 * @retval JAVACALL_INVALID_ARGUMENT indicates one of the following errors:
 *        - \a lm is \a NULL or refers to an unsupported value
 *
 * @see javacall_amms_exposure_control_get_supported_light_meterings_count
 * @see javacall_amms_exposure_control_get_supported_light_metering
 */
javacall_result javacall_amms_exposure_control_set_light_metering(
    javacall_handle hNative, const char *lm)
{
    audio_handle* ah = (audio_handle*)(((javacall_impl_player*)hNative)->mediaHandle);
    camera_state* cs = (camera_state*)( ah->pExtraCC );

    if( NULL == lm || strcmp( lm, g_MatrixMeteringString ) )
    {
        return JAVACALL_INVALID_ARGUMENT;
    }
    display_status( cs );
    return JAVACALL_OK;
}
Example #21
0
static void
keypress_wait(CdIo_t *p_cdio)
  {
    action("press any key to continue");
    while (1 != select_wait(b_cd ? 1 : 5)) {
      read_subchannel(p_cdio);
      display_status(true);
    }
    (void) getch();
    clrtobot();
    action(NULL);
    if (!b_all_tracks)
      display_cdinfo(p_cdio, i_tracks_global, i_first_track_global);
    i_last_display_track = CDIO_INVALID_TRACK;
  }
Example #22
0
void loglist_select(GtkCList *clist, gint row, gint column, GdkEventButton *event, gpointer user_data)
{
	actlog = row + 1;
	log_set (actlog);
	gtk_widget_hide(wlistalllog);
	if (log_on == 0)
	{
	  gtk_widget_show(wqsoeditor);
	}
	if (log_on == 0)
	{  
	  gtk_widget_show(wqsoeditor);
	}
	display_status("log entry loaded, You can edit it!");
}
Example #23
0
void on_logentry_edit_clicked(GtkButton *button, gpointer user_data)
{
	log_search();
	gtk_widget_hide(Wsearchlogentr);
	if (actlog == 0) 
	{
	  return;
	}

	if (log_on == 0)
	{  
	  gtk_widget_show(wqsoeditor);
	}
	log_set(actlog);
	display_status("log entry loaded, You can edit it!");
}	
/**
 * The function corresponding to 
 * void ExposureControl.setISO()
 *  method of AMMS Java API, see JSR-234 Spec
 *
 * Sets the sensitivity.
 *
 * @param hNative  native handle.
 *     Java layer guarantees the following:
 *        - it is a valid media player handle,
 *        - it refers to a video capture player,
 *        - the player has acquired exclusive
 *          access to the camera device
 * @param iso  new sensitivity value, 0 for automatic sensitivity.
 *
 * @retval JAVACALL_OK if operation is successful
 * @retval JAVACALL_FAIL if the given value is not supported
 *
 * @see javacall_amms_exposure_control_get_supported_isos_count
 * @see javacall_amms_exposure_control_get_supported_iso
 */
javacall_result javacall_amms_exposure_control_set_iso(
    javacall_handle hNative, long iso)
{
    audio_handle* ah = (audio_handle*)(((javacall_impl_player*)hNative)->mediaHandle);
    camera_state* cs = (camera_state*)( ah->pExtraCC );
    int i;

    for( i = 0; i < SIZEOF_ARRAY( g_ExposureSupportedISOs ); i++ )
    {
        if( g_ExposureSupportedISOs[ i ] == iso )
        {
            cs->exposureCurrentISO = iso;
            display_status( cs );
            return JAVACALL_OK;
        }
    }
    return JAVACALL_FAIL;
}
Example #25
0
void on_clear_logentry_activate(GtkMenuItem *menuitem, gpointer user_data)
{
	if (actlog == 0) 
	//only clear window
	{
	  log_set(0);
	  return;
	}
	else
	{
	  log_delete_entry(actlog);
	  log_shift_entries(actlog);
	  actlog = 0;
	  log_set(0);
	  display_status("log entry cleared.");
	  log_store();
	}
}
Example #26
0
void strech_img(MFDB *mfdb)
{
  MFDB  out ;
  float x_level , y_level, level ;

  display_status( STATUS_SCALING ) ;
  x_level = (float)(Xmax-2)/(float)mfdb->fd_w ;
  y_level = (float)(Ymax-2)/(float)mfdb->fd_h ;
  if (x_level > y_level) level = y_level ;
  else                   level = x_level ;
  out.fd_addr = NULL ;
  out.fd_w = (int) ( 0.5 + (float)mfdb->fd_w * level ) ;
  out.fd_h = (int) ( 0.5 + (float)mfdb->fd_h * level ) ;
/*  if ( raster_pczoom( mfdb, &out, level, level, NULL ) == 0 )*/
  if ( RasterZoom( mfdb, &out, NULL ) == 0 )
  {
    free( mfdb->fd_addr ) ;
    memcpy( mfdb, &out, sizeof(MFDB) ) ;
  }
}
Example #27
0
void _droidzebra_compute_evals(int side_to_move) {
    int stored_pv[sizeof(full_pv) / sizeof(full_pv[0])];
    int stored_pv_depth = 0;

    set_slack(0);
    set_perturbation(0);
    toggle_human_openings(FALSE);
    set_forced_opening(NULL);
    memcpy(stored_pv, full_pv, sizeof(stored_pv));
    stored_pv_depth = full_pv_depth;

    extended_compute_move(side_to_move, FALSE, TRUE, skill[EMPTY], exact_skill[EMPTY],
                          wld_skill[EMPTY]);

    memcpy(full_pv, stored_pv, sizeof(full_pv));
    full_pv_depth = stored_pv_depth;
    set_slack(floor(s_slack * 128.0));
    set_perturbation(floor(s_perturbation * 128.0));
    toggle_human_openings(s_human_opening);
    set_forced_opening(s_forced_opening_seq);

    display_status(stdout, FALSE);
}
Example #28
0
void savestates_save()
{
	char *filename, buf[1024];
	gzFile f;
	int len, i, filename_f = 0;
   
	savestates_job_success = TRUE;
   
	if (*autoinc_save_slot)
	{
		if (++slot == 10)
		{
			slot = 0;
		}
	}
   
	if (slot <= 9)
	{
		filename = (char*)malloc(strlen(get_savespath())+
		strlen(ROM_SETTINGS.goodname)+4+1);
		strcpy(filename, get_savespath());
		strcat(filename, ROM_SETTINGS.goodname);
		strcat(filename, ".st");
		sprintf(buf, "%d", slot);
		strcat(filename, buf);
	}
	else
	{
		filename = (char*)malloc(strlen(fname)+1);
		strcpy(filename, fname);
		slot -= 10;
		filename_f = 1;
	}

	{
		char str [256];
		if(filename_f)
			sprintf(str, "saving %-200s", filename);
		else
			sprintf(str, "saving slot %d", slot);
		display_status(str);
	}
   	
	f = gzopen(filename, "wb");
	free(filename);
   
	gzwrite(f, ROM_SETTINGS.MD5, 32);
   
	gzwrite(f, &rdram_register, sizeof(RDRAM_register));
	gzwrite(f, &MI_register, sizeof(mips_register));
	gzwrite(f, &pi_register, sizeof(PI_register));
	gzwrite(f, &sp_register, sizeof(SP_register));
	gzwrite(f, &rsp_register, sizeof(RSP_register));
	gzwrite(f, &si_register, sizeof(SI_register));
	gzwrite(f, &vi_register, sizeof(VI_register));
	gzwrite(f, &ri_register, sizeof(RI_register));
	gzwrite(f, &ai_register, sizeof(AI_register));
	gzwrite(f, &dpc_register, sizeof(DPC_register));
	gzwrite(f, &dps_register, sizeof(DPS_register));
	gzwrite(f, rdram, 0x800000);
	gzwrite(f, SP_DMEM, 0x1000);
	gzwrite(f, SP_IMEM, 0x1000);
	gzwrite(f, PIF_RAM, 0x40);

	save_flashram_infos(buf);
	gzwrite(f, buf, 24);
   
	gzwrite(f, tlb_LUT_r, 0x400000);
	gzwrite(f, tlb_LUT_w, 0x400000);
   
	gzwrite(f, &llbit, 4);
	gzwrite(f, reg, 32*8);
	for (i=0; i<32; i++)
		gzwrite(f, reg_cop0+i, 8); // *8 for compatibility with old versions purpose
	gzwrite(f, &lo, 8);
	gzwrite(f, &hi, 8);
	gzwrite(f, reg_cop1_fgr_64, 32*8);
	gzwrite(f, &FCR0, 4);
	gzwrite(f, &FCR31, 4);
	gzwrite(f, tlb_e, 32*sizeof(tlb));
	if (!dynacore && interpcore) 
		gzwrite(f, &interp_addr, 4);
	else 
		gzwrite(f, &PC->addr, 4);
   
	gzwrite(f, &next_interupt, 4);
	gzwrite(f, &next_vi, 4);
	gzwrite(f, &vi_field, 4);
   
	len = save_eventqueue_infos(buf);
	gzwrite(f, buf, len);

	// re-recording
	BOOL movieActive = VCR_isActive();
	gzwrite(f, &movieActive, sizeof(movieActive));
	if(movieActive)
	{
		char* movie_freeze_buf = NULL;
		unsigned long movie_freeze_size = 0;

		VCR_movieFreeze(&movie_freeze_buf, &movie_freeze_size);
		if(movie_freeze_buf)
		{
			gzwrite(f, &movie_freeze_size, sizeof(movie_freeze_size));
			gzwrite(f, movie_freeze_buf, movie_freeze_size);
			free(movie_freeze_buf);
		}
		else
		{
			fprintf(stderr, "Failed to save movie snapshot.\n");
			savestates_job_success = FALSE;
		}
	}
	// /re-recording

	gzclose(f);
}
Example #29
0
void savestates_load()
{
	char *filename, buf[1024];
	gzFile f;
	int len, i;
	int filename_f = 0;

	savestates_job_success = TRUE;
   
	if (slot <= 9)
	{
		filename = (char*)malloc(strlen(get_savespath())+
		strlen(ROM_SETTINGS.goodname)+4+1);
		strcpy(filename, get_savespath());
		strcat(filename, ROM_SETTINGS.goodname);
		strcat(filename, ".st");
		sprintf(buf, "%d", slot);
		strcat(filename, buf);
	}
	else
	{
		filename = (char*)malloc(strlen(fname)+1);
		strcpy(filename, fname);
		slot -= 10;
		filename_f = 1;
	}

	{
		char str [256];
		if(filename_f)
			sprintf(str, "loading %-200s", filename);
		else
			sprintf(str, "loading slot %d", slot);
		display_status(str);
	}

	f = gzopen(filename, "rb");
   
	if (f == NULL)
	{
		printf("Savestate \"%s\" not found.\n", filename);
		free(filename);
		warn_savestate_not_exist();
		savestates_job_success = FALSE;
		return;
	}
	free(filename);
   
	gzread(f, buf, 32);
	if (memcmp(buf, ROM_SETTINGS.MD5, 32))
	{
		warn_savestate_from_another_rom();
		gzclose(f);
		savestates_job_success = FALSE;
		return;
	}
   
	gzread(f, &rdram_register, sizeof(RDRAM_register));
	gzread(f, &MI_register, sizeof(mips_register));
	gzread(f, &pi_register, sizeof(PI_register));
	gzread(f, &sp_register, sizeof(SP_register));
	gzread(f, &rsp_register, sizeof(RSP_register));
	gzread(f, &si_register, sizeof(SI_register));
	gzread(f, &vi_register, sizeof(VI_register));
	gzread(f, &ri_register, sizeof(RI_register));
	gzread(f, &ai_register, sizeof(AI_register));
	gzread(f, &dpc_register, sizeof(DPC_register));
	gzread(f, &dps_register, sizeof(DPS_register));
	gzread(f, rdram, 0x800000);
	gzread(f, SP_DMEM, 0x1000);
	gzread(f, SP_IMEM, 0x1000);
	gzread(f, PIF_RAM, 0x40);

	gzread(f, buf, 24);
	load_flashram_infos(buf);
   
	gzread(f, tlb_LUT_r, 0x400000);
	gzread(f, tlb_LUT_w, 0x400000);
   
	gzread(f, &llbit, 4);
	gzread(f, reg, 32*8);
	for (i=0; i<32; i++) 
	{
		gzread(f, reg_cop0+i, 4);
		gzread(f, buf, 4); // for compatibility with old versions purpose
	}
	gzread(f, &lo, 8);
	gzread(f, &hi, 8);
	gzread(f, reg_cop1_fgr_64, 32*8);
	gzread(f, &FCR0, 4);
	gzread(f, &FCR31, 4);
	gzread(f, tlb_e, 32*sizeof(tlb));
	if (!dynacore && interpcore)
		gzread(f, &interp_addr, 4);
	else
	{
		int i;
		gzread(f, &len, 4);
		for (i=0; i<0x100000; i++) 
			invalid_code[i] = 1;
		jump_to(len);
	}
   
	gzread(f, &next_interupt, 4);
	gzread(f, &next_vi, 4);
	gzread(f, &vi_field, 4);
   
	len = 0;
	while(1)
	{
		gzread(f, buf+len, 4);
		if (*((unsigned long*)&buf[len]) == 0xFFFFFFFF) 
			break;
		gzread(f, buf+len+4, 4);
		len += 8;
	}
	load_eventqueue_infos(buf);
      
	BOOL movieSnapshot;
	gzread(f, &movieSnapshot, sizeof(movieSnapshot));
	if(VCR_isActive() && !movieSnapshot)
	{
		fprintf(stderr, "Can't load a non-movie snapshot while a movie is active.\n");
		savestates_job_success = FALSE;
		goto failedLoad;
	}
   
	if(movieSnapshot) // even if a movie isn't active we still want to parse through this in case other stuff is added later on in the save format
	{
		unsigned long movieInputDataSize = 0;
		gzread(f, &movieInputDataSize, sizeof(movieInputDataSize));
		char* local_movie_data = (char*)malloc(movieInputDataSize * sizeof(char));
		int readBytes = gzread(f, local_movie_data, movieInputDataSize);
		if(readBytes != movieInputDataSize)
		{
			fprintf(stderr, "Corrupt movie snapshot.\n");
			if(local_movie_data)
				free(local_movie_data);
			savestates_job_success = FALSE;
			goto failedLoad;
		}
		int code = VCR_movieUnfreeze(local_movie_data, movieInputDataSize);
		if(local_movie_data) 
			free(local_movie_data);
		if(code != SUCCESS && !VCR_isIdle())
		{
			char errStr [1024];
			strcpy(errStr, "Failed to load movie snapshot\n");
			switch(code)
			{
				case NOT_FROM_THIS_MOVIE: 
					strcat(errStr, ";\nSnapshot not from this movie"); 
					break;
				case NOT_FROM_A_MOVIE:
					strcat(errStr, ";\nNot a movie snapshot"); 
					break;// shouldn't get here...
				case INVALID_FRAME:
					strcat(errStr, ";\nInvalid frame number");
					break;
				case WRONG_FORMAT: 
					strcat(errStr, ";\nWrong format");
					break;
			}
			strcat(errStr, ".");
			fprintf(stderr, "%s\n", errStr);
		#ifdef __WIN32__
			void ShowInfo(char *Str, ...);
			ShowInfo(errStr);
		#endif
			savestates_job_success = FALSE;
			goto failedLoad;
		}
	}
	else // loading a non-movie snapshot from a movie
	{
		if(VCR_isActive())
		{
		#ifdef __WIN32__
			MessageBox(NULL, "The movie has been stopped to load this non-movie snapshot.", "Warning", MB_OK | MB_ICONWARNING);
		#else
			printf("[VCR]: Warning: The movie has been stopped to load this non-movie snapshot.\n");
		#endif
			if(VCR_isPlaying())
				VCR_stopPlayback();
			else
				VCR_stopRecord();
		}
	}
failedLoad:

	gzclose(f);
	if (!dynacore && interpcore)
		last_addr = interp_addr;
	else
		last_addr = PC->addr;
}
Example #30
0
/* Brute force all possible WPS pins for a given access point */
void crack()
{
    unsigned char *bssid = NULL;
    char *pin = NULL;
    int fail_count = 0, loop_count = 0, sleep_count = 0, assoc_fail_count = 0;
    float pin_count = 0;
    time_t start_time = 0;
    enum wps_result result = 0;
    /* MAC CHANGER VARIABLES */
    int mac_changer_counter = 0;
    char mac[MAC_ADDR_LEN] = { 0 };
    unsigned char mac_string [] = "ZZ:ZZ:ZZ:ZZ:ZZ:ZZ";
    unsigned char* new_mac = &mac_string[0];
    char last_digit = '0';

    if(!get_iface())
    {
        return;
    }

    if(get_max_pin_attempts() == -1)
    {
        cprintf(CRITICAL, "[X] ERROR: This device has been blacklisted and is not supported.\n");
        return;
    }

    /* Initialize network interface */
    set_handle(capture_init(get_iface()));

    if(get_handle() != NULL)
    {
        generate_pins();

        /* Restore any previously saved session */
        if(get_static_p1() == NULL)
        {
            restore_session();
        }

        /* Convert BSSID to a string */
        bssid = mac2str(get_bssid(), ':');

        /*
         * We need to get some basic info from the AP, and also want to make sure the target AP
         * actually exists, so wait for a beacon packet
         */
        cprintf(INFO, "[+] Waiting for beacon from %s\n", bssid);
        read_ap_beacon();
        process_auto_options();

        /* I'm fairly certian there's a reason I put this in twice. Can't remember what it was now though... */
        if(get_max_pin_attempts() == -1)
        {
            cprintf(CRITICAL, "[X] ERROR: This device has been blacklisted and is not supported.\n");
            return;
        }

        /* This initial association is just to make sure we can successfully associate */
        while(!reassociate())
        {
            if(assoc_fail_count == MAX_ASSOC_FAILURES)
            {
                assoc_fail_count = 0;
                cprintf(CRITICAL, "[!] WARNING: Failed to associate with %s (ESSID: %s)\n", bssid, get_ssid());
            }
            else
            {
                assoc_fail_count++;
            }
        }
        cprintf(INFO, "[+] Associated with %s (ESSID: %s)\n", bssid, get_ssid());

        /* Used to calculate pin attempt rates */
        start_time = time(NULL);

        /* If the key status hasn't been explicitly set by restore_session(), ensure that it is set to KEY1_WIP */
        if(get_key_status() <= KEY1_WIP)
        {
            set_key_status(KEY1_WIP);
        }
        /*
         * If we're starting a session at KEY_DONE, that means we've already cracked the pin and the AP is being re-attacked.
         * Re-set the status to KEY2_WIP so that we properly enter the main cracking loop.
         */
        else if(get_key_status() == KEY_DONE)
        {
            set_key_status(KEY2_WIP);
        }

        //copy the current mac to the new_mac variable for mac changer
        if (get_mac_changer() == 1) {
            strncpy(new_mac, mac2str(get_mac(), ':'), 16);
        }

        /* Main cracking loop */
        for(loop_count=0, sleep_count=0; get_key_status() != KEY_DONE; loop_count++, sleep_count++)
        {
            //MAC Changer switch/case to define the last mac address digit
            if (get_mac_changer() == 1) {
                switch (mac_changer_counter) {
                case 0:
                    last_digit = '0';
                    break;
                case 1:
                    last_digit = '1';
                    break;
                case 2:
                    last_digit = '2';
                    break;
                case 3:
                    last_digit = '3';
                    break;
                case 4:
                    last_digit = '4';
                    break;
                case 5:
                    last_digit = '5';
                    break;
                case 6:
                    last_digit = '6';
                    break;
                case 7:
                    last_digit = '7';
                    break;
                case 8:
                    last_digit = '8';
                    break;
                case 9:
                    last_digit = '9';
                    break;
                case 10:
                    last_digit = 'A';
                    break;
                case 11:
                    last_digit = 'B';
                    break;
                case 12:
                    last_digit = 'C';
                    break;
                case 13:
                    last_digit = 'D';
                    break;
                case 14:
                    last_digit = 'E';
                    break;
                case 15:
                    last_digit = 'F';
                    mac_changer_counter = -1;
                    break;
                }

                mac_changer_counter++;

                new_mac[16] = last_digit;
                //transform the string to a MAC and define the MAC
                str2mac((unsigned char *) new_mac, (unsigned char *) &mac);
                set_mac((unsigned char *) &mac);

                cprintf(WARNING, "[+] Using MAC %s \n", mac2str(get_mac(), ':'));
            }

            /*
             * Some APs may do brute force detection, or might not be able to handle an onslaught of WPS
             * registrar requests. Using a delay here can help prevent the AP from locking us out.
             */
            pcap_sleep(get_delay());

            /* Users may specify a delay after x number of attempts */
            if((get_recurring_delay() > 0) && (sleep_count == get_recurring_delay_count()))
            {
                cprintf(VERBOSE, "[+] Entering recurring delay of %d seconds\n", get_recurring_delay());
                pcap_sleep(get_recurring_delay());
                sleep_count = 0;
            }

            /*
             * Some APs identify brute force attempts and lock themselves for a short period of time (typically 5 minutes).
             * Verify that the AP is not locked before attempting the next pin.
             */
            while(get_ignore_locks() == 0 && is_wps_locked())
            {
                cprintf(WARNING, "[!] WARNING: Detected AP rate limiting, waiting %d seconds before re-checking\n", get_lock_delay());
                pcap_sleep(get_lock_delay());

            }

            /* Initialize wps structure */
            set_wps(initialize_wps_data());
            if(!get_wps())
            {
                cprintf(CRITICAL, "[-] Failed to initialize critical data structure\n");
                break;
            }

            /* Try the next pin in the list */
            pin = build_next_pin();
            if(!pin)
            {
                cprintf(CRITICAL, "[-] Failed to generate the next payload\n");
                break;
            }
            else
            {
                cprintf(WARNING, "[+] Trying pin %s\n", pin);
            }

            /*
             * Reassociate with the AP before each WPS exchange. This is necessary as some APs will
             * severely limit our pin attempt rate if we do not.
             */
            assoc_fail_count = 0;
            while(!reassociate())
            {
                if(assoc_fail_count == MAX_ASSOC_FAILURES)
                {
                    assoc_fail_count = 0;
                    cprintf(CRITICAL, "[!] WARNING: Failed to associate with %s (ESSID: %s)\n", bssid, get_ssid());
                }
                else
                {
                    assoc_fail_count++;
                }
            }


            /*
             * Enter receive loop. This will block until a receive timeout occurs or a
             * WPS transaction has completed or failed.
             */
            result = do_wps_exchange();

            switch(result)
            {
            /*
             * If the last pin attempt was rejected, increment
             * the pin counter, clear the fail counter and move
             * on to the next pin.
             */
            case KEY_REJECTED:
                fail_count = 0;
                pin_count++;
                advance_pin_count();
                break;
            /* Got it!! */
            case KEY_ACCEPTED:
                break;
            /* Unexpected timeout or EAP failure...try this pin again */
            default:
                cprintf(VERBOSE, "[!] WPS transaction failed (code: 0x%.2X), re-trying last pin\n", result);
                fail_count++;
                break;
            }

            /* If we've had an excessive number of message failures in a row, print a warning */
            if(fail_count == WARN_FAILURE_COUNT)
            {
                cprintf(WARNING, "[!] WARNING: %d failed connections in a row\n", fail_count);
                fail_count = 0;
                pcap_sleep(get_fail_delay());
            }

            /* Display status and save current session state every DISPLAY_PIN_COUNT loops */
            if(loop_count == DISPLAY_PIN_COUNT)
            {
                save_session();
                display_status(pin_count, start_time);
                loop_count = 0;
            }

            /*
             * The WPA key and other settings are stored in the globule->wps structure. If we've
             * recovered the WPS pin and parsed these settings, don't free this structure. It
             * will be freed by wpscrack_free() at the end of main().
             */
            if(get_key_status() != KEY_DONE)
            {
                wps_deinit(get_wps());
                set_wps(NULL);
            }
            /* If we have cracked the pin, save a copy */
            else
            {
                set_pin(pin);
            }
            free(pin);
            pin = NULL;

            /* If we've hit our max number of pin attempts, quit */
            if((get_max_pin_attempts() > 0) &&
                    (pin_count == get_max_pin_attempts()))
            {
                cprintf(VERBOSE, "[+] Quitting after %d crack attempts\n", get_max_pin_attempts());
                break;
            }
        }

        if(bssid) free(bssid);
        if(get_handle())
        {
            pcap_close(get_handle());
            set_handle(NULL);
        }
    }
    else
    {
        cprintf(CRITICAL, "[-] Failed to initialize interface '%s'\n", get_iface());
    }
}