示例#1
0
void
ntdll_redir_init(void)
{
    uint i;
    ntdll_table =
        strhash_hash_create(GLOBAL_DCONTEXT,
                            hashtable_num_bits(REDIRECT_NTDLL_NUM*2),
                            80 /* load factor: not perf-critical, plus static */,
                            HASHTABLE_SHARED | HASHTABLE_PERSISTENT,
                            NULL _IF_DEBUG("ntdll redirection table"));
    TABLE_RWLOCK(ntdll_table, write, lock);
    for (i = 0; i < REDIRECT_NTDLL_NUM; i++) {
        strhash_hash_add(GLOBAL_DCONTEXT, ntdll_table, redirect_ntdll[i].name,
                         (void *) redirect_ntdll[i].func);
    }
    TABLE_RWLOCK(ntdll_table, write, unlock);

    if (get_os_version() >= WINDOWS_VERSION_7) {
        ntdll_win7_table =
            strhash_hash_create(GLOBAL_DCONTEXT, REDIRECT_NTDLL_WIN7_NUM*2,
                                80 /* load factor: not perf-critical, plus static */,
                                HASHTABLE_SHARED | HASHTABLE_PERSISTENT,
                                NULL _IF_DEBUG("ntdll win7 redirection table"));
        TABLE_RWLOCK(ntdll_win7_table, write, lock);
        for (i = 0; i < REDIRECT_NTDLL_WIN7_NUM; i++) {
            strhash_hash_add(GLOBAL_DCONTEXT, ntdll_win7_table,
                             redirect_ntdll_win7[i].name,
                             (void *) redirect_ntdll_win7[i].func);
        }
        TABLE_RWLOCK(ntdll_win7_table, write, unlock);
    }
}
示例#2
0
/*! 
  Opens the diagnostic log, writes a header, and activates all 
  debugging modes.  All subsequent output to stderr will be redirected to
  the diagnostic log.

  \author  jfpatry
*/
void setup_diagnostic_log()
{
    FILE *newfp;
    time_t t;
    char os_buff[BUFF_LEN];
    char time_buff[BUFF_LEN];

    /* Activate a bunch of debugging modes */
    debug_mode_set_active( DEBUG_QUADTREE, True );
    debug_mode_set_active( DEBUG_CONTROL, True );
    debug_mode_set_active( DEBUG_SOUND, True );
    debug_mode_set_active( DEBUG_TEXTURE, True );
    debug_mode_set_active( DEBUG_VIEW, True );
    debug_mode_set_active( DEBUG_GL_EXT, True );
    debug_mode_set_active( DEBUG_FONT, True );
    debug_mode_set_active( DEBUG_UI, True );
    debug_mode_set_active( DEBUG_GAME_LOGIC, True );
    debug_mode_set_active( DEBUG_SAVE, True );
    debug_mode_set_active( DEBUG_JOYSTICK, True );
    debug_mode_set_active( DEBUG_GL_INFO, True );

    /* Redirect stderr to file; taken from SDL_main.c, which is in the 
       public domain */
    newfp = freopen(BUGREPORT_FILE, "w", stderr);
    if ( newfp == NULL ) {	/* This happens on NT */
#if !defined(stderr)
	stderr = fopen(BUGREPORT_FILE, "w");
#else
	newfp = fopen(BUGREPORT_FILE, "w");
	if ( newfp ) {
	    *stderr = *newfp;
	}
#endif
    }

    /* Write bug report header */
    fprintf( stderr, "Tux Racer Diagnostic Log\n\n" );

    /* Generate time string */
    t = time( NULL );
    sprintf( time_buff, "%s", asctime( gmtime( &t ) ) );
    time_buff[ strlen(time_buff)-1 ] = (char)0; /* remove trailing newline */

    fprintf( stderr, "Generated:       %s GMT\n", time_buff );
    fprintf( stderr, "TR Version:      %s\n", VERSION );
    fprintf( stderr, "OS:              " );

    if ( get_os_version( os_buff, sizeof( os_buff ) ) == 0 ) {
	fprintf( stderr, "%s\n", os_buff );
    } else {
	fprintf( stderr, "Could not determine!\n" );
    }

    fprintf( stderr, "\n" );
}
示例#3
0
SelfDescribingJson Utils::get_desktop_context() {
  if (!m_desktop_context) {
    json data;
    data[SNOWPLOW_DESKTOP_OS_TYPE] = get_os_type();
    data[SNOWPLOW_DESKTOP_OS_VERSION] = get_os_version();
    data[SNOWPLOW_DESKTOP_OS_SERVICE_PACK] = get_os_service_pack();
    data[SNOWPLOW_DESKTOP_OS_IS_64_BIT] = get_os_is_64bit();
    data[SNOWPLOW_DESKTOP_DEVICE_MANU] = get_device_manufacturer();
    data[SNOWPLOW_DESKTOP_DEVICE_MODEL] = get_device_model();
    data[SNOWPLOW_DESKTOP_DEVICE_PROC_COUNT] = get_device_processor_count();
    m_desktop_context = new SelfDescribingJson(SNOWPLOW_SCHEMA_DESKTOP_CONTEXT, data);
  }

  SelfDescribingJson copy = *m_desktop_context;
  return copy;
}
示例#4
0
void AppDelegate::initDeviceInfo()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
	// ªÒ»°ª˙∆˜–≈œ¢
	char buff[64] = "";
	get_cpu_vendor_brand(buff,buff);
	get_cpu_vendor(buff);
	gGameManager->GetMachineInfo()._cpu_vendor = buff;
	get_cpu_brand(buff);
	gGameManager->GetMachineInfo()._cpu_name = buff;
	gGameManager->GetMachineInfo()._os = get_os_version();
#endif

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
	// »°µ√CPU≥߅ã®Vendor£©º∞CPU…ñͣ®brand£©
	char cpu_vendor[128] = "";
	char cpu_name[128] = "";
	get_cpu_info(cpu_vendor,cpu_name);
	gGameManager->GetMachineInfo()._cpu_vendor = (cpu_vendor[0] == '\0' ? "Unknown" : cpu_vendor);
	gGameManager->GetMachineInfo()._cpu_name = (cpu_name[0] == '\0' ? "Unknown" : cpu_name);
	CCLOG("---------cpu_vendor=%s cpu_name=%s--------------",cpu_vendor,cpu_name);
	string vendor,num,os,abi;
	get_machine_info(vendor,num,os,abi);
	gGameManager->GetMachineInfo()._vendor = vendor;
	gGameManager->GetMachineInfo()._num = num;
	gGameManager->GetMachineInfo()._os = os;
	gGameManager->GetMachineInfo()._cpu_abi = abi;
#endif

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
//        UIDevice *device = [[UIDevice alloc] int];
//        NSString *name = device.name;		//获取设备所有者的名称
//        NSString *model = [NSString stringWithFormat:@"%@,%@", device.model, device.localizedModel ];;    //获取设备的类�?+ //获取本地化版�?
//        NSString* os = [NSString stringWithFormat:@"%@,%@", device.systemName, device.systemVersion ];    //获取当前运行的系�?+ //获取当前系统的版�?
    
        gGameManager->GetMachineInfo()._vendor = "apple";
        gGameManager->GetMachineInfo()._num = "iphone";
        gGameManager->GetMachineInfo()._os = "ios";
    
        char cpu_vendor[128] = "";
        char cpu_name[128] = "";
        get_cpu_info(cpu_vendor,cpu_name);
        gGameManager->GetMachineInfo()._cpu_vendor = (cpu_vendor[0] == '\0' ? "Unknown" : cpu_vendor);
        gGameManager->GetMachineInfo()._cpu_name = (cpu_name[0] == '\0' ? "Unknown" : cpu_name);
#endif
}
示例#5
0
        void crash_handler::create_log_file_for_hockey_app(EXCEPTION_POINTERS* /* pExcPtrs */)
        {   
            const int max_stack_trace_depth = 48;
            void *stack[max_stack_trace_depth];
            USHORT count = CaptureStackBackTrace(0, max_stack_trace_depth, stack, NULL);

            std::stringstream stack_trace_stream;
            for (USHORT c = 0; c < count; c++)
            {
                stack_trace_stream << stack[c] << ";";
            }

            std::string stack_trace = stack_trace_stream.str();
            std::wstring log_name = get_report_log_path();

            time_t now = time(0);
            std::stringstream log_stream;
            // TODO (*) : use real info about app
            log_stream << "Package: " << product_bundle << std::endl;
            log_stream << "Version: " << VERSION_INFO_STR << std::endl;
            log_stream << "OS: " << get_os_version() << std::endl;
            log_stream << "Manufacturer: MS" << std::endl;
            log_stream << "Model: " << tools::version_info().get_version() << std::endl;

            char str[26];
            ctime_s(str, sizeof str, &now);
            log_stream << "Date: " << str << std::endl;
            log_stream << stack_trace << std::endl;

            auto log_text = log_stream.str();
            DWORD dwWritten;
            HANDLE handleFile (CreateFile(log_name.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, 
                0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0));

            // https://msdn.microsoft.com/ru-ru/library/windows/desktop/5fc6ft2t(v=vs.80).aspx
            if(handleFile == INVALID_HANDLE_VALUE)
            {
                return;
            }

            CHandle hFile(handleFile);
            WriteFile(hFile, log_text.c_str(), log_text.size(), &dwWritten, 0);
        }
static gboolean
record_os_version (gpointer unused)
{
  gchar *os_name = NULL;
  gchar *os_version = NULL;

  if (!get_os_version (&os_name, &os_version))
    return G_SOURCE_REMOVE;

  GVariant *payload = g_variant_new ("(sss)",
                                     os_name, os_version, "");
  emtr_event_recorder_record_event (emtr_event_recorder_get_default (),
                                    OS_VERSION_EVENT, payload);

  g_free (os_name);
  g_free (os_version);

  return G_SOURCE_REMOVE;
}
示例#7
0
static void
init_log()
{
	std::ostream& stream =
			ppogl::Log::Instance()->getStream();
	
	stream << "PlanetPenguin Racer Diagnostic Log\n" << std::endl;
		
	time_t t = time( NULL );
	stream << "Generated:       " << asctime( gmtime( &t ) ); 
	stream << "PlanetPenguin Racer Version: " << VERSION << std::endl;
	stream << "OS:              ";
	
	char buff[512];
	
    if ( get_os_version( buff, sizeof( buff ) ) == 0 ) {
		stream << buff << "\n" << std::endl;
    } else {
		stream << "Could not determine!\n" << std::endl;
    }  
}
示例#8
0
app_pc
drwinapi_redirect_imports(privmod_t *impmod, const char *name, privmod_t *importer)
{
    if (strcasecmp(impmod->name, "ntdll.dll") == 0) {
        return ntdll_redir_lookup(name);
    } else if (strcasecmp(impmod->name, "kernel32.dll") == 0 ||
               strcasecmp(impmod->name, "kernelbase.dll") == 0) {
        app_pc res = kernel32_redir_lookup(name);
        if (res == NULL) {
            /* win7 has some Reg* routines in kernel32 so we check advapi */
            res = advapi32_redir_lookup(name);
        }
        if (res != NULL && get_os_version() >= WINDOWS_VERSION_7 &&
                importer != NULL && strcasecmp(importer->name, "kernel32.dll") == 0) {
            /* We can't redirect kernel32.dll's calls to kernelbase when we ourselves
             * call the kernel32.dll routine when our redirection fails.
             *
             * XXX: we could add a 2nd return val from the lookup, but there are
             * only a few of these and as time goes forward this set should ideally
             * shrink to zero.  Thus we hardcode here.
             *
             * XXX: might some dlls import from kernelbase instead of kernel32 and
             * bypass our redirection altogether?  Yet another reason to eliminate
             * our redirection routines calling back into the priv libs.
             */
            if (strcmp(name, "GetModuleHandleA") == 0 ||
                    strcmp(name, "GetModuleHandleW") == 0 ||
                    strcmp(name, "GetProcAddress") == 0 ||
                    strcmp(name, "LoadLibraryA") == 0 ||
                    strcmp(name, "LoadLibraryW") == 0)
                return NULL;
        }
        return res;
    } else if (strcasecmp(impmod->name, "rpcrt4.dll") == 0) {
        return rpcrt4_redir_lookup(name);
    } else if (strcasecmp(impmod->name, "advapi32.dll") == 0) {
        return advapi32_redir_lookup(name);
    }
    return NULL;
}
示例#9
0
void diag(FILE *output)
{
	char *yn[] = { "No", "Yes", "Unknown" };

	fprintf(output,"CVSNT Diagnostic output\n");
	fprintf(output,"-----------------------\n");
	fprintf(output,"\n");
	fprintf(output,"Server version: "CVSNT_PRODUCTVERSION_STRING"\n");
	fprintf(output,"OS Version: %s\n",get_os_version());
	fprintf(output,"\n");
	fprintf(output,"CVS Service installed: %s\n",service_installed("Cvsnt")?"Yes":"No");
	fprintf(output,"LockService installed: %s\n",service_installed("CvsLock")?"Yes":"No");
	fprintf(output,"\n");
	fprintf(output,":pserver: installed: %s\n",protocol_installed("pserver")?"Yes":"No");
	fprintf(output,":sserver: installed: %s\n",protocol_installed("sserver")?"Yes":"No");
	fprintf(output,":gserver: installed: %s\n",protocol_installed("gserver")?"Yes":"No");
	fprintf(output,":server: installed: %s\n",protocol_installed("server")?"Yes":"No");
	fprintf(output,":ssh: installed: %s\n",protocol_installed("ssh")?"Yes":"No");
	fprintf(output,":sspi: installed: %s\n",protocol_installed("sspi")?"Yes":"No");
	fprintf(output,":ext: installed: %s\n",protocol_installed("ext")?"Yes":"No");
	fprintf(output,"\n");
	fprintf(output,"Installation Path: %s\n",get_reg_string("InstallPath"));
	fprintf(output,"Repository 0 Path: %s\n",get_reg_string("Repository0"));
	fprintf(output,"Repository 0 Name: %s\n",get_reg_string("Repository0Name"));
	fprintf(output,"Repository 1 Path: %s\n",get_reg_string("Repository1"));
	fprintf(output,"Repository 1 Name: %s\n",get_reg_string("Repository1Name"));
	fprintf(output,"Repository 2 Path: %s\n",get_reg_string("Repository2"));
	fprintf(output,"Repository 2 Name: %s\n",get_reg_string("Repository2Name"));
	fprintf(output,"Repository 3 Path: %s\n",get_reg_string("Repository3"));
	fprintf(output,"Repository 3 Name: %s\n",get_reg_string("Repository3Name"));
	fprintf(output,"CVS Temp directory: %s\n",get_reg_string("TempDir"));
	fprintf(output,"CA Certificate File: %s\n",get_reg_string("CertificateFile"));
	fprintf(output,"Private Key File: %s\n",get_reg_string("PrivateKeyFile"));
	fprintf(output,"Local Users Only: %s\n",get_reg_int("DontUseDomain")?"Yes":"No");
	fprintf(output,"Default LockServer: %s\n",get_reg_string("LockServer"));
	fprintf(output,"Disable Reverse DNS: %s\n",get_reg_int("NoReverseDns")?"Yes":"No");
	fprintf(output,"Server Tracing: %s\n",get_reg_int("AllowTrace")?"Yes":"No");
	fprintf(output,"Case Sensitive: %s\n",get_reg_int("CaseSensitive")?"Yes":"No");
	fprintf(output,"Server listen port: %d\n",get_reg_int("PServerPort"));
	fprintf(output,"Compatibility (Non-cvsnt clients):\n");
	fprintf(output,"\tReport old CVS version: %s\n",get_reg_int("Compat0_OldVersion")?"Yes":"No");
	fprintf(output,"\tHide extended status: %s\n",get_reg_int("Compat0_HideStatus")?"Yes":"No");
	fprintf(output,"\tEmulate co -n bug: %s\n",get_reg_int("Compat0_OldCheckout")?"Yes":"No");
	fprintf(output,"\tIgnore client wrappers: %s\n",get_reg_int("Compat0_IgnoreWrappers")?"Yes":"No");
	fprintf(output,"Compatibility (CVSNT clients):\n");
	fprintf(output,"\tReport old CVS version: %s\n",get_reg_int("Compat1_OldVersion")?"Yes":"No");
	fprintf(output,"\tHide extended status: %s\n",get_reg_int("Compat1_HideStatus")?"Yes":"No");
	fprintf(output,"\tEmulate co -n bug: %s\n",get_reg_int("Compat1_OldCheckout")?"Yes":"No");
	fprintf(output,"\tIgnore client wrappers: %s\n",get_reg_int("Compat1_IgnoreWrappers")?"Yes":"No");
	fprintf(output,"Default domain: %s\n",get_reg_string("DefaultDomain"));
	fprintf(output,"Force run as user: %s\n",get_reg_string("RunAsUser"));
	fprintf(output,"\n");
	fprintf(output,"Temp dir readable by current user: %s\n",yn[is_readable(false,get_reg_string("TempDir"))]);
//	fprintf(output,"Temp dir readable by LocalSystem: %s\n",yn[is_readable(true,get_reg_string("TempDir"))]);
	fprintf(output,"Repository0 readable by current user: %s\n",yn[is_readable(false,get_reg_string("Repository0"))]);
//	fprintf(output,"Repository0 readable by LocalSystem: %s\n",yn[is_readable(true,get_reg_string("Repository0"))]);
	fprintf(output,"Temp dir writable by current user: %s\n",yn[is_writable(false,get_reg_string("TempDir"))]);
//	fprintf(output,"Temp dir writable by LocalSystem: %s\n",yn[is_writable(true,get_reg_string("TempDir"))]);
	fprintf(output,"\n");
	fprintf(output,"AV files detected:\n");
	print_found_files(output,"_AVP32.EXE\0_AVPCC.EXE\0_AVPM.EXE\0AVP32.EXE\0AVPCC.EXE\0AVPM.EXE\0"
							"N32SCANW.EXE\0NAVAPSVC.EXE\0NAVAPW32.EXE\0NAVLU32.EXE\0NAVRUNR.EXE\0NAVW32.EXE"
							"NAVWNT.EXE\0NOD32.EXE\0NPSSVC.EXE\0NRESQ32.EXE\0NSCHED32.EXE\0NSCHEDNT.EXE"
							"NSPLUGIN.EXE\0SCAN.EXE\0AVGSRV.EXE\0AVGSERV.EXE\0AVGCC32.EXE\0AVGCC.EXE\0"
							"AVGAMSVR.EXE\0AVGUPSVC.EXE\0NOD32KRN.EXE\0NOD32KUI.EXE\0");

	fprintf(output,"\n");
	WSADATA wsa = {0};
	if(WSAStartup(MAKEWORD(2,0),&wsa))
		fprintf(output,"Winsock intialisation failed!\n");
	else
	{
		fprintf(output,"Installed Winsock protocols:\n\n");
		DWORD dwSize=0;
		LPWSAPROTOCOL_INFO proto;
		WSAEnumProtocols(NULL,NULL,&dwSize);
		proto=(LPWSAPROTOCOL_INFO)malloc(dwSize);
		WSAEnumProtocols(NULL,proto,&dwSize);
		for(int n=0; n<(int)(dwSize/sizeof(proto[0])); n++)
		{
			if(!strncmp(proto[n].szProtocol,"MSAFD NetBIOS",13))
				continue; // Ignore netbios layers
			fprintf(output,"%d: %s\n",proto[n].dwCatalogEntryId,proto[n].szProtocol);
		}
		free(proto);
	}
}
示例#10
0
void TaskStart (void *data)
{
  extern u32 _end;
  u32 bss_end = (u32)(&_end);
  BOOL ret = FALSE;
  u32 *pstack_pnt = NULL;
  u32 heap_start = 0;
 // u32 montage_auto = 0;
  u32 cpuclk = 0;

  heap_start = ROUNDUP(bss_end,4);

  mtos_irq_init();

//  hal_warriors_attach(&hal_config);
  extern void hal_concerto_attach(void);

  hal_concerto_attach( );

  mtos_register_putchar(uart_write_byte);
  mtos_register_getchar(uart_read_byte_polling);

  //mtos_ticks_init(SYS_CPU_CLOCK);
  hal_module_clk_get(HAL_CPU0, &cpuclk);
  mtos_ticks_init(cpuclk);

  mem_mgr_partition_param_t partition_param = { 0 };//, partition2_param = { 0 };
  uart_init(0);
  uart_init(1);

  //init memory manager, to the memory end
  mem_mgr_init((u8 *)heap_start, SYSTEM_MEMORY_END);

  //create system partition
  partition_param.id   = MEM_SYS_PARTITION;
  partition_param.size = SYS_PARTITION_SIZE;
  partition_param.p_addr = (u8 *)heap_start;
  partition_param.atom_size = SYS_PARTITION_ATOM;
  partition_param.user_id = SYS_MODULE_SYSTEM;
  partition_param.method_id = MEM_METHOD_NORMAL;
  ret = MEM_CREATE_PARTITION(&partition_param);
  MT_ASSERT(FALSE != ret);
#if 0
  OS_PRINTF("\n 1. mem_start[0x%x]\n", heap_start);
  OS_PRINTF("\n 2. system memory size[%d]\n", SYSTEM_MEMORY_END);
  OS_PRINTF("SYS_PARTITION_SIZE is %x\n", SYS_PARTITION_SIZE);
  OS_PRINTF("create SYS_PARTITION111 ok!\n");

  partition2_param.id   = MEM_DMA_PARTITION;
  partition2_param.size = DMA_PARTITION_SIZE;
  partition2_param.p_addr = (u8 *)((heap_start + SYS_PARTITION_SIZE + 0x40000) | 0xa0000000);
  partition2_param.atom_size = DMA_PARTITION_ATOM;
  partition2_param.user_id = SYS_MODULE_SYSTEM;
  partition2_param.method_id = MEM_METHOD_NORMAL;

  OS_PRINTF("\n 1. mem_start[0x%x]\n", partition2_param.p_addr);
  OS_PRINTF("\n 2. system memory size[%d]\n", SYSTEM_MEMORY_END);
  OS_PRINTF("SYS_PARTITION_SIZE is 0x%x\n", DMA_PARTITION_SIZE);


  ret = MEM_CREATE_PARTITION(&partition2_param);
  MT_ASSERT(FALSE != ret);
#endif
  mtos_mem_init(mt_mem_malloc, mt_mem_free);
  #if 0
  OS_PRINTF("Now check os version!\n");
  u32 os_version = get_os_version();

  if (os_version != 0x11112222) {
    OS_PRINTF("Wrong os version, please talk with os person!\n");
  }

  OS_PRINTF("Os version pass!\n");

  if(CPU_IS_AP) {
      OS_PRINTF("AP CPU id get pass \n");
  }else{
      OS_PRINTF("cannot get right cpu id \n");
  }
  #endif
 //create timer task
  pstack_pnt = (u32*)mtos_malloc(SYS_TIMER_TASK_STK_SIZE);
  MT_ASSERT(pstack_pnt != NULL);

  ret = mtos_task_create((u8 *)"Timer",
         Task_SysTimer,
         (void *)0,
         SYS_TIMER_TASK_PRIORITY,
         pstack_pnt,
         SYS_TIMER_TASK_STK_SIZE);

  MT_ASSERT(FALSE != ret);

  // init_dual_printk();

   //init message queue
  //OS_PRINTF("start    mtos_irq_enable!!!!!!!!!!!!!!\n");
  mtos_irq_enable(TRUE);
  ret = mtos_message_init();
  MT_ASSERT(FALSE != ret);


#ifdef CORE_DUMP_DEBUG
   mtos_stat_init();
#endif

   init_section();
  mtos_task_sleep(100);

   ap_init();

  mtos_task_exit();
}