UINT8* UserPS_InitUniFontData(void) { PPSTORE_SECTION_HANDLE pSection; UINT32 uiReadSize; UINT8 *pMemPool; get_blk((void *)&pMemPool, POOL_ID_CAPTURE); rel_blk(POOL_ID_CAPTURE, pMemPool); // Read Unicode font data from PStore to this memory pool pMemPool = (pMemPool + POOL_SIZE_CAPTURE - POOL_SIZE_UNIFONT); //PStore_EnablePS(); if((pSection = PStore_OpenSection(PS_UNIFONT_DATA, PS_RDONLY)) != E_PS_SECHDLER) { // Get Unicode font data size first (leading 4 bytes) if(PStore_ReadSection(pMemPool, 0, 4, pSection) != E_PS_OK) { debug_err(("UserPS: PStore read Unicode font data size fail\r\n")); return NULL; } uiReadSize = MAKE_LONG(MAKE_WORD(pMemPool[0], pMemPool[1]), MAKE_WORD(pMemPool[2], pMemPool[3])); debug_err(("UserPS: Gotta read Unicode font data size = %ld\r\n", uiReadSize)); if(uiReadSize > POOL_SIZE_UNIFONT) { debug_err(("UserPS: Font data size too large!\r\n")); return NULL; } // Get Unicode font data if(PStore_ReadSection(pMemPool, 4, uiReadSize, pSection) != E_PS_OK) { debug_err(("UserPS: PStore read Unicode font data fail\r\n")); return NULL; } PStore_CloseSection(pSection); //PStore_DisablePS(); #if 0 //Just verify the data integrity FilesysReadWriteByName2(FST_CMD_WRITE_BY_NAME, "A:\\VFONT.BIN", (UINT8 *)(pMemPool), &uiReadSize, 0, FST_TIME_INFINITE); #endif } else { debug_err(("UserPS: PStore open section fail\r\n")); //PStore_DisablePS(); return NULL; } return pMemPool; }
INT32 MenuCommonItem_Menu_OnKeyRight(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray) { TM_MENU* pMenu = TM_GetMenu(); TM_PAGE* pPage; TM_ITEM* pItem; if (pMenu->Status == TMS_ON_ITEM) { pPage = &pMenu->pPages[pMenu->SelPage]; pPage->SelItem = UxMenu_GetData(&MenuCommonItem_MenuCtrl, MNU_CURITM); // update selected item of tab menu pItem = &pPage->pItems[pPage->SelItem]; if (pItem->Count != 0 && pItem->SysFlag != 0) // standard process { if (TM_MENU_CALLBACK(pMenu, TMM_ENTER_OPTION, MAKE_LONG(pItem->ItemId, 0)) == TMF_PASS_MESSAGE) { return NVTEVT_CONSUME; } } UxStatic_SetData(&MenuCommonItem_TitleTextCtrl, STATIC_VALUE, pItem->TextId); UxCtrl_SetShow(&MenuCommonItem_TipsIconLDRCtrl, FALSE); UxCtrl_SetShow(&MenuCommonItem_TipsIconLUDRCtrl, FALSE); UxCtrl_SetShow(&MenuCommonItem_TipsIconLUDOKCtrl, TRUE); UxCtrl_SetShow(&MenuCommonItem_PageNumCtrl, FALSE); Ux_Redraw(); if (pItem->Count != 0 && pItem->SysFlag != 0) // standard process { pMenu->Status = TMS_ON_OPTION; Ux_OpenWindow(&MenuCommonOptionCtrl, 0); } else if (pItem->pOptions != 0) // custom process { pMenu->Status = TMS_ON_CUSTOM; TM_ITEM_CALLBACK(pItem, 0, 0); // execute custom menu flow } } return NVTEVT_CONSUME; }
/// Function name : appendDocument // Description : Appends a Document to the documents control // // HWND hTabCtrl : [in] Tab control // DOCUMENT* pDocument : [in] Document to insert // VOID appendDocument(HWND hTabCtrl, DOCUMENT* pDocument) { DOCUMENTS_DATA* pWindowData; // Documents control TCITEM oTabItem; // New Tab data SIZE siTabCtrl; // Size of the tab control // Prepare pWindowData = getDocumentsControlData(hTabCtrl); // [CHECK] Ensure document count == tab count ASSERT(getDocumentCount() == TabCtrl_GetItemCount(hTabCtrl)); // Define tab oTabItem.mask = TCIF_TEXT WITH TCIF_IMAGE; oTabItem.pszText = (TCHAR*)getDocumentFileName(pDocument); oTabItem.iImage = pDocument->eType; /// Add DOCUMENT to document list appendObjectToList(pWindowData->pDocumentList, (LPARAM)pDocument); /// Append new tab, but don't initially select TabCtrl_InsertItem(hTabCtrl, getDocumentCount() - 1, (LPARAM)&oTabItem); // [CHECK] Is this the first document? if (getDocumentCount() == 1) /// [SUCCESS] Set as ActiveDocument setActiveDocument(pWindowData, pDocument); else { // [FAILURE] Resize the active document in case a new row of tabs has been opened utilGetWindowSize(hTabCtrl, &siTabCtrl); PostMessage(hTabCtrl, WM_SIZE, NULL, MAKE_LONG(siTabCtrl.cx, siTabCtrl.cy)); // BUG_FIX: Using updateDocumentSize(pWindowData, pDocument) didn't work, TabCtrl must need to update something internal first... } }
INT32 MenuCommonOption_Menu_OnKeyEnter(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray) { TM_MENU* pMenu = TM_GetMenu(); TM_PAGE* pPage; TM_ITEM* pItem; UINT32 uiSelOption; pPage = &pMenu->pPages[pMenu->SelPage]; pItem = &pPage->pItems[pPage->SelItem]; uiSelOption = UxMenu_GetData(&MenuCommonOption_MenuCtrl, MNU_CURITM); // selected option // set system flag by selected Option SysSetFlag(pItem->SysFlag, uiSelOption); // Close current UI Window now Ux_CloseWindow(&MenuCommonOptionCtrl, 2,pItem->ItemId,uiSelOption); // notify upper layer the Option had been confirmed TM_MENU_CALLBACK(pMenu, TMM_CONFIRM_OPTION, MAKE_LONG(pItem->ItemId, uiSelOption)); return NVTEVT_CONSUME; }
/** * @brief 连接到服务器 * @return 成功0, 否则失败 */ static int EtherConnect(void) { static int ServerSel = 0;//主站主从切换标记(默认连接首主站地址) static int CountFail = 0; struct sockaddr_in addr; unsigned long ip; unsigned short port; //int ctlflag; CLOSE_SOCKET(SockEther); int proto = 0;//默认为TCP方式 if(proto) //UDP { SockEther = socket(AF_INET, SOCK_DGRAM, 0); SockEther = socket(AF_INET, SOCK_DGRAM, 0); } else //TCP { SockEther = socket(AF_INET, SOCK_STREAM, 0); SockEther = socket(AF_INET, SOCK_STREAM, 0); } if(SockEther < 0) { PrintLog(LOGTYPE_ALARM, "create socket errror.\n"); return 1; } memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; if(0 == ServerSel) { port = ParaTermG.svraddr.net.port; addr.sin_port = htons(port); ip = addr.sin_addr.s_addr = MAKE_LONG(ParaTermG.svraddr.net.ip); } else { port = ParaTermG.svraddr_1.net.port; addr.sin_port = htons(port); ip = addr.sin_addr.s_addr =MAKE_LONG( ParaTermG.svraddr_1.net.ip); } PrintLog(0,"connect to %d.%d.%d.%d, %d...\n", ip&0xff, (ip>>8)&0xff, (ip>>16)&0xff, (ip>>24)&0xff, port); PrintLog(LOGTYPE_SHORT, "connect to %d.%d.%d.%d, %d...\n", ip&0xff, (ip>>8)&0xff, (ip>>16)&0xff, (ip>>24)&0xff, port); if(connect(SockEther, (struct sockaddr *)&addr, sizeof(addr)) == 0) { PrintLog(0, "connect succeed.\r\n"); //CountFail = 0; return 0; } DebugPrint(0, "connect failed.\n"); PrintLog(0, "connect failed.\n"); CLOSE_SOCKET(SockEther); /*by ydl add 2011-05-04*/ CountFail++; if(CountFail == 2) { system("wifi down"); } return 1; }
BOOL UI_ShowLogoFile(UINT32 logoId,UINT32 *uiJpgAddr,UINT32 *uiJpgSize) { UINT32 uiFileSize; UINT8 *BgBuf; ER erReturn; PSTORE_SECTION_HANDLE* pSecHdl; // to save the handle of PStore section char *psecnameId; if (logoId == UI_LOGO_POWERON) { psecnameId = PS_POWERON_LOGO; } else //if (logoId == UI_LOGO_POWEROFF) { psecnameId = PS_POWEROFF_LOGO; } //get_blk((void *)&BgBuf, POOL_ID_SICD); //rel_blk(POOL_ID_SICD, BgBuf); BgBuf = (UINT8 *)OS_GetMempoolAddr(POOL_ID_APP); //PStore_EnablePS(); //pSecHdl = PStore_OpenSection(PS_BG_LOGO, PS_RDONLY); pSecHdl = PStore_OpenSection(psecnameId, PS_RDONLY); if (pSecHdl == E_PS_SECHDLER) { debug_err(("Section PS_BG_LOGO open fail\r\n")); PStore_CloseSection(pSecHdl); //PStore_DisablePS(); return FALSE; } erReturn = PStore_ReadSection(BgBuf, 0, 4, pSecHdl); if (erReturn != E_PS_OK) { debug_err(("PStore read error\r\n")); } uiFileSize = MAKE_LONG(MAKE_WORD(BgBuf[0],BgBuf[1]),MAKE_WORD(BgBuf[2],BgBuf[3])); USE_MSG(("UserPS_ShowLogoFile: logo uiFileSize %d\r\n",uiFileSize)); //check file size logo size: 1k---20k if ((uiFileSize < 1024) || (uiFileSize > LOGO_MAX_FILESIZE)) { USE_MSG(("Show logo error\n\r")); PStore_CloseSection(pSecHdl); //PStore_DisablePS(); return FALSE; } erReturn = PStore_ReadSection(BgBuf, 0, (uiFileSize+4), pSecHdl); if (erReturn != E_PS_OK) { debug_err(("PStore read error\r\n")); PStore_CloseSection(pSecHdl); return FALSE; } PStore_CloseSection(pSecHdl); *uiJpgAddr = (UINT32)(BgBuf+4); *uiJpgSize = (UINT32)uiFileSize; return TRUE; }
BOOL UI_LoadCfgFile(void) { ER erReturn; UINT32 i; char *SysParam_Sector; UINT32 uiFileSize; UINT8 *BgBuf; PSTORE_SECTION_HANDLE* pSecHdl; strcpy(gUIConfigInfo.strMakerString, (CHAR *)GetMakerString()); strcpy(gUIConfigInfo.strModelString,(CHAR *)GetModelString()); strcpy(gUIConfigInfo.strSoftwareVer,(CHAR *)GetVersionString()); gUIConfigInfo.uiSizeDefaultIndex = DEFAULT_PHOTO_SIZE; gUIConfigInfo.uiMovieSizeDefaultIndex = DEFAULT_MOVIE_SIZE; gUIConfigInfo.uiLanguageDefaultIndex = DEFAULT_LANGUAGE; gUIConfigInfo.uiFreqDefaultIndex = DEFAULT_FREQUENCY; gUIConfigInfo.uiTVModeDefaultIndex = DEFAULT_TV_MODE; gUIConfigInfo.uiDateImprintDefaultIndex = DEFAULT_MOVIE_DATEIMPRINT; gUIConfigInfo.uiBeepDefaultIndex = DEFAULT_BEEP; gUIConfigInfo.uiVideoAudioDefaultIndex = DEFAULT_MOVIE_AUDIO; BgBuf = (UINT8 *)OS_GetMempoolAddr(POOL_ID_APP); //PStore_EnablePS(); pSecHdl = PStore_OpenSection(PS_BG_CFG, PS_RDONLY); if (pSecHdl == E_PS_SECHDLER) { debug_err(("UserPS_ReadCfgFile: Section open fail\r\n")); goto err_ret; } erReturn = PStore_ReadSection(BgBuf, 0, 4, pSecHdl); if (erReturn != E_PS_OK) { debug_err(("UserPS_ReadCfgFile: PStore read error\r\n")); goto err_ret; } uiFileSize = MAKE_LONG(MAKE_WORD(BgBuf[0],BgBuf[1]),MAKE_WORD(BgBuf[2],BgBuf[3])); USE_MSG(("UserPS_ReadCfgFile: cfg filesize=%d\r\n", uiFileSize)); if (uiFileSize > CFG_MAX_FILESIZE) { debug_err(("UserPS_ReadCfgFile: file size error\n\r")); goto err_ret; } erReturn = PStore_ReadSection(BgBuf, 0, (uiFileSize+4), pSecHdl); if (erReturn != E_PS_OK) { debug_err(("UserPS_ReadCfgFile: PStore read error\r\n")); goto err_ret; } PStore_CloseSection(pSecHdl); //PStore_DisablePS(); SysParam_Sector = (char *)(BgBuf + ((uiFileSize+4+4-1)/4)*4); memset((UINT8 *)SysParam_Sector,0,SYSPARAM_SYSFLAG_LEN); if (!get_key_value((char *)&BgBuf[4],(char*)SysParam_Sector)) { debug_err(("UserPS_ReadCfgFile: Read cfg file error\r\n")); return FALSE;//goto err_ret; } i = 0; while(TRUE) { if (SysParam_Sector[0] == '\0') { debug_err(("sysflag is null\r\n")); break; } if (i*KEY_VALUE_LEN >= SYSPARAM_SYSFLAG_LEN) { break; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "beep")) { if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "yes")) { USE_MSG(("beep yes\r\n")); UI_SetBeepDefaultIndex(BEEP_ON); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "no")) { USE_MSG(("beep no\r\n")); UI_SetBeepDefaultIndex(BEEP_OFF); } } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "videoaudio")) { if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "yes")) { USE_MSG(("videoaudio yes\r\n")); UI_SetVideoAudioDefaultIndex(MOVIE_AUDIO_ON); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "no")) { USE_MSG(("videoaudio no\r\n")); UI_SetVideoAudioDefaultIndex(MOVIE_AUDIO_OFF); } } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "hz")) { if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "50hz")) { USE_MSG(("50hz\r\n")); UI_SetFreqDefaultIndex(FREQUENCY_50HZ); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "60hz")) { USE_MSG(("60hz\r\n")); UI_SetFreqDefaultIndex(FREQUENCY_60HZ); } } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "tvmode")) { if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "pal")) { USE_MSG(("tvmode pal\r\n")); UI_SetTVModeDefaultIndex(TV_MODE_PAL); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "ntsc")) { USE_MSG(("tvmode ntsc\r\n")); UI_SetTVModeDefaultIndex(TV_MODE_NTSC); } } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "date")) { if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "yes")) { USE_MSG(("date_time on\r\n")); UI_SetDateImprintDefaultIndex(DATE_TIME_ON); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "no")) { USE_MSG(("date_time off\r\n")); UI_SetDateImprintDefaultIndex(DATE_TIME_OFF); } } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "moviesize")) { if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "1080p")) { USE_MSG(("moviesize-1080p\r\n")); gTM_OPTIONS_MOVIE_SIZE[MOVIE_SIZE_1080P].TextId = IDS_MOVIE_SIZE_1080FHD; gTM_OPTIONS_MOVIE_SIZE[MOVIE_SIZE_1080P].IconId = IDI_MOVIE_SIZE_1080FHD; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "720p")) { USE_MSG(("moviesize-720p\r\n")); gTM_OPTIONS_MOVIE_SIZE[MOVIE_SIZE_720P].TextId = IDS_MOVIE_SIZE_720P; gTM_OPTIONS_MOVIE_SIZE[MOVIE_SIZE_720P].IconId = IDI_MOVIE_SIZE_720P; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "wvga")) { USE_MSG(("moviesize-wvga\r\n")); gTM_OPTIONS_MOVIE_SIZE[MOVIE_SIZE_WVGA].TextId = IDS_MOVIE_SIZE_WVGA; gTM_OPTIONS_MOVIE_SIZE[MOVIE_SIZE_WVGA].IconId = IDI_MOVIE_SIZE_WVGA; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "vga")) { USE_MSG(("moviesize-vga\r\n")); gTM_OPTIONS_MOVIE_SIZE[MOVIE_SIZE_VGA].TextId = IDS_MOVIE_SIZE_VGA; gTM_OPTIONS_MOVIE_SIZE[MOVIE_SIZE_VGA].IconId = IDI_MOVIE_SIZE_VGA; } } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "photosize")) { if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "12m")) { USE_MSG(("photosize-12m\r\n")); gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_12M].TextId = IDS_PHOTO_SIZE_12M; gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_12M].IconId = IDI_PHOTO_SIZE_12M; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "10m")) { USE_MSG(("photosize-10m\r\n")); gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_10M].TextId = IDS_PHOTO_SIZE_10M; gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_10M].IconId = IDI_PHOTO_SIZE_10M; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "8m")) { USE_MSG(("photosize-8m\r\n")); gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_8M].TextId = IDS_PHOTO_SIZE_8M; gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_8M].IconId = IDI_PHOTO_SIZE_8M; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "5m")) { USE_MSG(("photosize-5m\r\n")); gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_5M].TextId = IDS_PHOTO_SIZE_5M; gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_5M].IconId = IDI_PHOTO_SIZE_5M; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "3m")) { USE_MSG(("photosize-3m\r\n")); gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_3M].TextId = IDS_PHOTO_SIZE_3M; gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_3M].IconId = IDI_PHOTO_SIZE_3M; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "2m169")) { USE_MSG(("photosize-2m9\r\n")); gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_2MHD].TextId = IDS_PHOTO_SIZE_2MHD; gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_2MHD].IconId = IDI_PHOTO_SIZE_2MHD; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "vga")) { USE_MSG(("photosize-vgam\r\n")); gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_VGA].TextId = IDS_PHOTO_SIZE_VGA; gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_VGA].IconId = IDI_PHOTO_SIZE_VGA; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "1m")) { USE_MSG(("photosize-1m\r\n")); gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_1M].TextId = IDS_PHOTO_SIZE_1M; gTM_OPTIONS_PHOTO_SIZE[PHOTO_SIZE_1M].IconId = IDI_PHOTO_SIZE_1M; } } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "defaultmoviesize")) { if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "1080p")) { USE_MSG(("defaultmoviesize-1080p\r\n")); UI_SetMovieSizeDefaultIndex(MOVIE_SIZE_1080P); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "720p")) { USE_MSG(("defaultmoviesize-720p\r\n")); UI_SetMovieSizeDefaultIndex(MOVIE_SIZE_720P); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "wvga")) { USE_MSG(("defaultmoviesize-wvga\r\n")); UI_SetMovieSizeDefaultIndex(MOVIE_SIZE_WVGA); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "vga")) { USE_MSG(("defaultmoviesize-vga\r\n")); UI_SetMovieSizeDefaultIndex(MOVIE_SIZE_VGA); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "qvga")) { USE_MSG(("defaultmoviesize-qvga\r\n")); UI_SetMovieSizeDefaultIndex(MOVIE_SIZE_QVGA); } } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "defaultphotosize")) { #if (UPDATE_CFG == UPDATE_CFG_YES) if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "vga")) { USE_MSG(("defaultphotosize-vga\r\n")); UI_SetSizeDefaultIndex(PHOTO_SIZE_VGA); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "2m169")) { USE_MSG(("defaultphotosize-2m169\r\n")); UI_SetSizeDefaultIndex(PHOTO_SIZE_2MHD); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "2m")) { USE_MSG(("defaultphotosize-2m\r\n")); UI_SetSizeDefaultIndex(PHOTO_SIZE_2M); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "3m")) { USE_MSG(("defaultphotosize-3m\r\n")); UI_SetSizeDefaultIndex(PHOTO_SIZE_3M); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "5m")) { USE_MSG(("defaultphotosize-5m\r\n")); UI_SetSizeDefaultIndex(PHOTO_SIZE_5M); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "8m")) { USE_MSG(("defaultphotosize-8m\r\n")); UI_SetSizeDefaultIndex(PHOTO_SIZE_8M); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "9m")) { USE_MSG(("defaultphotosize-9m\r\n")); //UI_SetSizeDefaultIndex(PHOTO_SIZE_10M); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "10m")) { USE_MSG(("defaultphotosize-10m\r\n")); UI_SetSizeDefaultIndex(PHOTO_SIZE_10M); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "12m")) { USE_MSG(("defaultphotosize-12m\r\n")); UI_SetSizeDefaultIndex(PHOTO_SIZE_12M); } #endif } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "language")) { if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "en")) { USE_MSG(("language-en\r\n")); gTM_OPTIONS_LANGUAGE[LANG_EN].TextId = IDS_LANG_EN; gTM_OPTIONS_LANGUAGE[LANG_EN].IconId = IDI_LANG_EN; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "de")) { USE_MSG(("language-de\r\n")); gTM_OPTIONS_LANGUAGE[LANG_DE].TextId = IDS_LANG_DE; gTM_OPTIONS_LANGUAGE[LANG_DE].IconId = IDI_LANG_DE; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "es")) { USE_MSG(("language-es\r\n")); gTM_OPTIONS_LANGUAGE[LANG_ES].TextId = IDS_LANG_ES; gTM_OPTIONS_LANGUAGE[LANG_ES].IconId = IDI_LANG_ES; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "it")) { USE_MSG(("language-it\r\n")); gTM_OPTIONS_LANGUAGE[LANG_IT].TextId = IDS_LANG_IT; gTM_OPTIONS_LANGUAGE[LANG_IT].IconId = IDI_LANG_IT; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "ru")) { USE_MSG(("language-ru\r\n")); gTM_OPTIONS_LANGUAGE[LANG_RU].TextId = IDS_LANG_RU; gTM_OPTIONS_LANGUAGE[LANG_RU].IconId = IDI_LANG_RU; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "fr")) { USE_MSG(("language-fr\r\n")); gTM_OPTIONS_LANGUAGE[LANG_FR].TextId = IDS_LANG_FR; gTM_OPTIONS_LANGUAGE[LANG_FR].IconId = IDI_LANG_FR; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "sc")) { USE_MSG(("language-sc\r\n")); gTM_OPTIONS_LANGUAGE[LANG_SC].TextId = IDS_LANG_SC; gTM_OPTIONS_LANGUAGE[LANG_SC].IconId = IDI_LANG_SC; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "tc")) { USE_MSG(("language-tc\r\n")); gTM_OPTIONS_LANGUAGE[LANG_TC].TextId = IDS_LANG_TC; gTM_OPTIONS_LANGUAGE[LANG_TC].IconId = IDI_LANG_TC; } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "jp")) { USE_MSG(("language-jp\r\n")); gTM_OPTIONS_LANGUAGE[LANG_JP].TextId = IDS_LANG_JP; gTM_OPTIONS_LANGUAGE[LANG_JP].IconId = IDI_LANG_JP; } } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "defaultlanguage")) { if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "en")) { USE_MSG(("defaultlanguage-en\r\n")); UI_SetLanguageDefaultIndex(LANG_EN); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "fr")) { USE_MSG(("defaultlanguage-fr\r\n")); UI_SetLanguageDefaultIndex(LANG_FR); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "de")) { USE_MSG(("defaultlanguage-de\r\n")); UI_SetLanguageDefaultIndex(LANG_DE); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "es")) { USE_MSG(("defaultlanguage-es\r\n"));\ UI_SetLanguageDefaultIndex(LANG_ES); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "ru")) { USE_MSG(("defaultlanguage-ru\r\n")); UI_SetLanguageDefaultIndex(LANG_RU); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "it")) { USE_MSG(("defaultlanguage-it\r\n")); UI_SetLanguageDefaultIndex(LANG_IT); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "sc")) { USE_MSG(("defaultlanguage-sc\r\n")); UI_SetLanguageDefaultIndex(LANG_SC); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "tc")) { USE_MSG(("defaultlanguage-tc\r\n")); UI_SetLanguageDefaultIndex(LANG_TC); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN, "jp")) { USE_MSG(("defaultlanguage-jp\r\n")); UI_SetLanguageDefaultIndex(LANG_JP); } } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "maker")) { USE_MSG(("maker:%s\r\n",SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN)); strcpy(gUIConfigInfo.strMakerString,SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "model")) { USE_MSG(("model:%s\r\n",SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN)); strcpy(gUIConfigInfo.strModelString,SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "version")) { USE_MSG(("verion:%s\r\n",SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN)); strcpy(gUIConfigInfo.strSoftwareVer,SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN); } if (!strcmp(SysParam_Sector+i*KEY_VALUE_LEN, "ImageDescription")) { USE_MSG(("sImageDescription:%s\r\n",SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN)); strcpy(gUIConfigInfo.strImageDescription,SysParam_Sector+i*KEY_VALUE_LEN+KEY_LEN); } i++; } return TRUE; err_ret: PStore_CloseSection(pSecHdl); //PStore_DisablePS(); return FALSE; }
void parseElf32(FILE* fp, long fileSize) { const int sizeOfElfHeader = 0x34; struct ELF_Header_32 elfHeader32 = {{ 0 }}; unsigned char* buffer = (unsigned char*)malloc(sizeOfElfHeader); fread(buffer, sizeof(unsigned char), sizeOfElfHeader, fp); char mag_str[4] = { buffer[0], buffer[1], buffer[2], buffer[3] }; // 32-bit ELF Header memcpy(elfHeader32.ei_mag, mag_str, 4); elfHeader32.ei_class = buffer[0x04]; elfHeader32.ei_data = buffer[0x05]; elfHeader32.ei_version = buffer[0x06]; elfHeader32.ei_osabi = buffer[0x07]; elfHeader32.ei_abiversion = buffer[0x08]; elfHeader32.e_type = MAKE_SHORT(buffer[0x11], buffer[0x10]); elfHeader32.e_machine = MAKE_SHORT(buffer[0x13], buffer[0x12]); elfHeader32.e_version = MAKE_LONG(buffer[0x17], buffer[0x16], buffer[0x15], buffer[0x14]); elfHeader32.e_entry = MAKE_LONG(buffer[0x1B], buffer[0x1A], buffer[0x19], buffer[0x18]); elfHeader32.e_phoff = MAKE_LONG(buffer[0x1F], buffer[0x1E], buffer[0x1D], buffer[0x1C]); elfHeader32.e_shoff = MAKE_LONG(buffer[0x23], buffer[0x22], buffer[0x21], buffer[0x20]); elfHeader32.e_flags = MAKE_LONG(buffer[0x27], buffer[0x26], buffer[0x25], buffer[0x24]); elfHeader32.e_ehsize = MAKE_SHORT(buffer[0x29], buffer[0x28]); elfHeader32.e_phentsize = MAKE_SHORT(buffer[0x2B], buffer[0x2A]); elfHeader32.e_phnum = MAKE_SHORT(buffer[0x2D], buffer[0x2C]); elfHeader32.e_shentsize = MAKE_SHORT(buffer[0x2F], buffer[0x2E]); elfHeader32.e_shnum = MAKE_SHORT(buffer[0x31], buffer[0x30]); elfHeader32.e_shstrndx = MAKE_SHORT(buffer[0x33], buffer[0x32]); free(buffer); // 32-bit Program Headers // if not there already, seek to program header offset found in elfHeader if (sizeOfElfHeader != elfHeader32.e_phoff) { if (fseek(fp, elfHeader32.e_phoff, SEEK_SET) != 0) { printf("[ELF] Error seeking to elfHeader32.e_phoff (parse).\n"); // TODO: Clean exit in cases like this. exit(-1); } } if (elfHeader32.e_phentsize != (unsigned short)sizeof(struct Program_Header_32)) { printf("[ELF Fatal Error] elfHeader32.e_phentsize == "); printf("sizeof(Program_Header_32)\n[Is file corrupt?]\n"); // TODO: Clean exit in cases like this. exit(-1); } int i = 0; int sizeOfProgramHeaders = elfHeader32.e_phnum * elfHeader32.e_phentsize; buffer = (unsigned char*)malloc(sizeOfProgramHeaders); fread(buffer, sizeof(unsigned char), sizeOfProgramHeaders, fp); struct Program_Header_32* programHeaders = (struct Program_Header_32*)malloc(sizeOfProgramHeaders); for (i = 0; i < elfHeader32.e_phnum; i++) { int cur_phoff = (i * elfHeader32.e_phentsize); struct Program_Header_32 cur_programHeader = { 0 }; cur_programHeader.p_type = MAKE_LONG(buffer[cur_phoff+0x03], buffer[cur_phoff+0x02], buffer[cur_phoff+0x01], buffer[cur_phoff+0x00]); cur_programHeader.p_offset = MAKE_LONG(buffer[cur_phoff+0x07], buffer[cur_phoff+0x06], buffer[cur_phoff+0x05], buffer[cur_phoff+0x04]); cur_programHeader.p_vaddr = MAKE_LONG(buffer[cur_phoff+0x0B], buffer[cur_phoff+0x0A], buffer[cur_phoff+0x09], buffer[cur_phoff+0x08]); cur_programHeader.p_paddr = MAKE_LONG(buffer[cur_phoff+0x0F], buffer[cur_phoff+0x0E], buffer[cur_phoff+0x0D], buffer[cur_phoff+0x0C]); cur_programHeader.p_filesz = MAKE_LONG(buffer[cur_phoff+0x13], buffer[cur_phoff+0x12], buffer[cur_phoff+0x11], buffer[cur_phoff+0x10]); cur_programHeader.p_memsz = MAKE_LONG(buffer[cur_phoff+0x17], buffer[cur_phoff+0x16], buffer[cur_phoff+0x15], buffer[cur_phoff+0x14]); cur_programHeader.p_flags = MAKE_LONG(buffer[cur_phoff+0x1B], buffer[cur_phoff+0x1A], buffer[cur_phoff+0x19], buffer[cur_phoff+0x18]); cur_programHeader.p_align = MAKE_LONG(buffer[cur_phoff+0x1F], buffer[cur_phoff+0x1E], buffer[cur_phoff+0x1D], buffer[cur_phoff+0x1C]); memcpy(&programHeaders[i], &cur_programHeader, elfHeader32.e_phentsize); } free(buffer); // 32-bit Section Headers if (fseek(fp, elfHeader32.e_shoff, SEEK_SET) != 0) { printf("[ELF] Error seeking to elfHeader32.e_shoff (parse).\n"); // TODO: Clean exit in cases like this. free(programHeaders); exit(-1); } if (elfHeader32.e_shentsize != (unsigned short)sizeof(struct Section_Header_32)) { printf("[ELF Fatal Error] elfHeader32.e_shentsize == "); printf("sizeof(Section_Header_32)\n[Is file corrupt?]\n"); // TODO: Clean exit in cases like this. free(programHeaders); exit(-1); } int sizeOfSectionHeaders = elfHeader32.e_shnum * elfHeader32.e_shentsize; buffer = (unsigned char*)malloc(sizeOfSectionHeaders); fread(buffer, sizeof(unsigned char), sizeOfSectionHeaders, fp); struct Section_Header_32* sectionHeaders = (struct Section_Header_32*)malloc(sizeOfSectionHeaders); for (i = 0; i < elfHeader32.e_shnum; i++) { int cur_shoff = (i * elfHeader32.e_shentsize); struct Section_Header_32 cur_sectionHeader = { 0 }; cur_sectionHeader.sh_name = MAKE_LONG(buffer[cur_shoff+0x03], buffer[cur_shoff+0x02], buffer[cur_shoff+0x01], buffer[cur_shoff+0x00]); cur_sectionHeader.sh_type = MAKE_LONG(buffer[cur_shoff+0x07], buffer[cur_shoff+0x06], buffer[cur_shoff+0x05], buffer[cur_shoff+0x04]); cur_sectionHeader.sh_flags = MAKE_LONG(buffer[cur_shoff+0x0B], buffer[cur_shoff+0x0A], buffer[cur_shoff+0x09], buffer[cur_shoff+0x08]); cur_sectionHeader.sh_address = MAKE_LONG(buffer[cur_shoff+0x0F], buffer[cur_shoff+0x0E], buffer[cur_shoff+0x0D], buffer[cur_shoff+0x0C]); cur_sectionHeader.sh_offset = MAKE_LONG(buffer[cur_shoff+0x13], buffer[cur_shoff+0x12], buffer[cur_shoff+0x11], buffer[cur_shoff+0x10]); cur_sectionHeader.sh_size = MAKE_LONG(buffer[cur_shoff+0x17], buffer[cur_shoff+0x16], buffer[cur_shoff+0x15], buffer[cur_shoff+0x14]); cur_sectionHeader.sh_link = MAKE_LONG(buffer[cur_shoff+0x1B], buffer[cur_shoff+0x1A], buffer[cur_shoff+0x19], buffer[cur_shoff+0x18]); cur_sectionHeader.sh_info = MAKE_LONG(buffer[cur_shoff+0x1F], buffer[cur_shoff+0x1E], buffer[cur_shoff+0x1D], buffer[cur_shoff+0x1C]); cur_sectionHeader.sh_addralign = MAKE_LONG(buffer[cur_shoff+0x23], buffer[cur_shoff+0x22], buffer[cur_shoff+0x21], buffer[cur_shoff+0x20]); cur_sectionHeader.sh_entsize = MAKE_LONG(buffer[cur_shoff+0x27], buffer[cur_shoff+0x26], buffer[cur_shoff+0x25], buffer[cur_shoff+0x24]); memcpy(§ionHeaders[i], &cur_sectionHeader, elfHeader32.e_shentsize); } free(buffer); // Now, store the shstrtab int shstrtab_addr = sectionHeaders[elfHeader32.e_shstrndx].sh_offset; if (!shstrtab_addr || fseek(fp, shstrtab_addr, SEEK_SET) != 0) { printf("[ELF] Error seeking to shstrtab_addr (parse).\n"); // TODO: Clean exit in cases like this. free(programHeaders); free(sectionHeaders); exit(-1); } int shstrtab_size = sectionHeaders[elfHeader32.e_shstrndx].sh_size; char* shstrtab = (char*)malloc( sizeof(char)*shstrtab_size); fread(shstrtab, sizeof(char), shstrtab_size, fp); // Printing! unsigned char* codeSection = malloc(sectionHeaders[1].sh_size); fseek(fp, sectionHeaders[1].sh_offset, SEEK_SET); // TODO: Error checking fread(codeSection, sizeof(unsigned char), sectionHeaders[1].sh_size, fp); disassemble_x86(&shstrtab[sectionHeaders[1].sh_name], sectionHeaders[1].sh_address, codeSection, sectionHeaders[1].sh_size); free(codeSection); /* arbitrary separator here */ codeSection = malloc(sectionHeaders[2].sh_size); fseek(fp, sectionHeaders[2].sh_offset, SEEK_SET); // TODO: Error checking fread(codeSection, sizeof(unsigned char), sectionHeaders[2].sh_size, fp); disassemble_x86(&shstrtab[sectionHeaders[2].sh_name], sectionHeaders[2].sh_address, codeSection, sectionHeaders[2].sh_size); free(codeSection); /* arbitrary separator here */ printSectionHeader32(sectionHeaders[3], shstrtab); codeSection = malloc(sectionHeaders[3].sh_size); fseek(fp, sectionHeaders[3].sh_offset, SEEK_SET); // TODO: Error checking fread(codeSection, sizeof(unsigned char), sectionHeaders[3].sh_size, fp); disassemble_x86(&shstrtab[sectionHeaders[3].sh_name], sectionHeaders[3].sh_address, codeSection, sectionHeaders[3].sh_size); free(codeSection); // cleanup free(programHeaders); free(sectionHeaders); free(shstrtab); }
int GprsConnect(int sel) { unsigned long ip; unsigned short port; int rt; varip_t vip; GprsSetApn(ParaTerm.svrip.apn); hsocket = NetCreateSocket(PF_AT,ParaTerm.uplink.proto); if(hsocket == -ERRFAILED) return -1; if(0 == sel) { if(*(unsigned int*)ParaTerm.svrip.ipmain == 0) return -ERRFAILED; memcpy(vip.uc,ParaTerm.svrip.ipmain,4); port = ParaTerm.svrip.portmain; } else if(1 == sel) { if(*(unsigned int*)ParaTerm.svrip.ipbakup == 0) return -ERRFAILED; ip = MAKE_LONG(ParaTerm.svrip.ipbakup); port = ParaTerm.svrip.portbakup; if(0 == ip || 0 == port) { memcpy(vip.uc,ParaTerm.svrip.ipmain,4); port = ParaTerm.svrip.portmain; } else { memcpy(vip.uc,ParaTerm.svrip.ipbakup,4); port = ParaTerm.svrip.portbakup; } }else if(2 == sel) { varip_t ip; PrintLog(LOGTYPE_DEBUG,"IP:DNS\r\n"); if(strlen((const char*)ParaUni.web_addr)>0) { GprsDns((const char*)ParaUni.web_addr,&ip); if(ip.ul != 0) { vip = ip; if(ParaTerm.svrip.portmain != 0) port = ParaTerm.svrip.portmain; else port = ParaTerm.svrip.portbakup; } else return -ERRFAILED; } else return -ERRFAILED; } else return -ERRFAILED; rt = NetConnectHost(hsocket,vip,port); if(rt == SUCCEED) { GprsDevLineState = GSTAT_LINE_ON;//TCP连接成功 } return rt; }