Esempio n. 1
0
/***********************************************************************
*@函数名称: sdfuse_uboot
*@功能描述: sdfuse烧写u-boot映像文件
*@参数: 	无
*@返回:		无
*@备注:	   本u-boot未使用,real210.h中有CONFIG_FASTBOOT_SDFUSE这个定义
 **********************************************************************/
void sdfuse_uboot()
{
    char *buf;
    ulong checksum = 0;
    int i = 0;
    if(!ExecuteCmd("fatload mmc 1:1 30f00000 /sdfuse/u-boot.bin"))
    {
        buf = 0x30f00000 + 16;/*把u-boot首地址偏移16字节的内存地址赋值给buf,此时u-boot的首地址是30f00000*/
        for(i = 16; i < 8192; i++) /*循环进行u-boot的前8K代码校验和计算,i赋值为16是因为u-boot的前16字节可不必要校验和校验*/
        {
            checksum += *buf;
            buf++;
        }
        *((volatile u32 *)(0x30f00000 + 0x8)) = checksum;/*把计算出的校验和写入3ff00008地址处等待写入EMMC*/
        printf("\nBL1 checksum is:%08x\n\n", checksum);

        /*printf("erase start block 1 (count 1073 blocks)...");
        ExecuteCmd("mmc erase 1 431");*/

        printf("writing BL1 start block 1 (count 16 blocks)...");
        ExecuteCmd("mmc write 30f00000 1 10");/*烧写BL1到eMMC的第一个block,长度为16 block(注意此时是10,但是为16进制)*/

        printf("\n");
        printf("writing u-boot.bin start block 49 (count 1024 blocks)...");
        ExecuteCmd("mmc write 30f00000 31 400");/*烧写u-boot到eMMC的第49个block,长度为1024 block(注意此时是400,但是为16进制)*/
    }
}
Esempio n. 2
0
//EQLIB_API VOID DoMappable(PSPAWNINFO pChar, PCHAR szLine)
int CMD_Keypress(int argc, char *argv[])
{
	if (argc<2)
	{
		WriteChatf("Syntax: %s <eqcommand|keycombo> [hold|chat]",argv[0]);
		return 0;
	}
	bool bHold=false;
	bool bChat=false;
	if (argc==3)
	{
		if (!stricmp(argv[2],"hold"))
		{
			bHold=true;
		}
		else if (!stricmp(argv[2],"chat"))
		{
			bChat=true;
		}
	}
	if (!PressMQ2KeyBind(argv[1],bHold))
	{
		int N=FindMappableCommand(argv[1]);
		if (N>=0)
		{
			ExecuteCmd(N,1,0);
			if (!bHold)
				ExecuteCmd(N,0,0);
			return 0;
		}
		KeyCombo Temp;
		if (ParseKeyCombo(argv[1],Temp))
		{
			if (bChat)
			{
				pWndMgr->HandleKeyboardMsg(Temp.Data[3],1);
				pWndMgr->HandleKeyboardMsg(Temp.Data[3],0);
			}
			else
			{
				MQ2HandleKeyDown(Temp);
				if (!bHold)
					MQ2HandleKeyUp(Temp);
			}
			return 0;
		}

		WriteChatf("Invalid mappable command or key combo '%s'",argv[1]);
		return -1;
	}
	return 0;
}
Esempio n. 3
0
bool DbgGdb::DoInitializeGdb(const std::vector<BreakpointInfo> &bpList, const wxArrayString &cmds)
{
	//place breakpoint at first line
#ifdef __WXMSW__
	ExecuteCmd(wxT("set  new-console on"));
#endif
	ExecuteCmd(wxT("set unwindonsignal on"));

	if (m_info.enablePendingBreakpoints) {
		ExecuteCmd(wxT("set breakpoint pending on"));
	}

	if (m_info.catchThrow) {
		ExecuteCmd(wxT("catch throw"));
	}

#ifdef __WXMSW__
	if (m_info.debugAsserts) {
		ExecuteCmd(wxT("break assert"));
	}
#endif

	ExecuteCmd(wxT("set width 0"));
	ExecuteCmd(wxT("set height 0"));
	ExecuteCmd(wxT("set print pretty on"));  // pretty printing

	// Number of elements to show for arrays (including strings)
	wxString sizeCommand;
	sizeCommand << wxT("set print elements ") << m_info.maxDisplayStringSize;
	ExecuteCmd( sizeCommand );

	// set the project startup commands
	for (size_t i=0; i<cmds.GetCount(); i++) {
		ExecuteCmd(cmds.Item(i));
	}

	// keep the list of breakpoints
	m_bpList = bpList;
	
	if(GetIsRemoteDebugging() == false) 
		// When remote debugging, apply the breakpoints after we connect the 
		// gdbserver
		SetBreakpoints();

	if (m_info.breakAtWinMain) {
		//try also to set breakpoint at WinMain
		WriteCommand(wxT("-break-insert main"), NULL);
	}
	return true;
}
Esempio n. 4
0
/***********************************************************************
*@函数名称: emmc_format
*@功能描述: 格式化emmc
*@参数: 	无
*@返回:		无
*@备注:	   本u-boot未使用该函数
 **********************************************************************/
void emmc_format(void)
{
    unsigned char select;
    printf("\n\nEnter 'y' to ensure erase emmc\n\n\n");
    select = getc();
    if((select == 'y') || (select == 'Y'))	{
        ExecuteCmd("ext2format mmc 0:1");
        ExecuteCmd("ext2format mmc 0:2");
        ExecuteCmd("ext2format mmc 0:3");
        printf("\n\nformat complete !!!\n\n");
    }
    else {
        printf("\nformat abort !!!\n\n");
    }
}
Esempio n. 5
0
// Undocumented function
BOOL WINAPI OnSetConsoleKeyShortcuts(BOOL bSet, BYTE bReserveKeys, LPVOID p1, DWORD n1)
{
	//typedef BOOL (WINAPI* OnSetConsoleKeyShortcuts_t)(BOOL,BYTE,LPVOID,DWORD);
	ORIGINALFASTEX(SetConsoleKeyShortcuts,NULL);
	BOOL lbRc = FALSE;

	if (F(SetConsoleKeyShortcuts))
		lbRc = F(SetConsoleKeyShortcuts)(bSet, bReserveKeys, p1, n1);

	if (ghConEmuWnd && IsWindow(ghConEmuWnd))
	{
		DWORD nLastErr = GetLastError();
		DWORD nSize = sizeof(CESERVER_REQ_HDR)+sizeof(BYTE)*2;
		CESERVER_REQ *pIn = ExecuteNewCmd(CECMD_KEYSHORTCUTS, nSize);
		if (pIn)
		{
			pIn->Data[0] = bSet;
			pIn->Data[1] = bReserveKeys;

			wchar_t szGuiPipeName[128];
			msprintf(szGuiPipeName, countof(szGuiPipeName), CEGUIPIPENAME, L".", LODWORD(ghConWnd));

			CESERVER_REQ* pOut = ExecuteCmd(szGuiPipeName, pIn, 1000, NULL);

			if (pOut)
				ExecuteFreeResult(pOut);
			ExecuteFreeResult(pIn);
		}
		SetLastError(nLastErr);
	}

	return lbRc;
}
Esempio n. 6
0
void CorrectGuiChildRect(DWORD anStyle, DWORD anStyleEx, RECT& rcGui)
{
	RECT rcShift = {};

	if ((anStyle != gGuiClientStyles.nStyle) || (anStyleEx != gGuiClientStyles.nStyleEx))
	{
		DWORD nSize = sizeof(CESERVER_REQ_HDR)+sizeof(GuiStylesAndShifts);
		CESERVER_REQ *pIn = ExecuteNewCmd(CECMD_GUICLIENTSHIFT, nSize);
		if (pIn)
		{
			pIn->GuiAppShifts.nStyle = anStyle;
			pIn->GuiAppShifts.nStyleEx = anStyleEx;
			wchar_t szOurExe[MAX_PATH*2] = L"";
			GetModuleFileName(NULL, szOurExe, countof(szOurExe));
			lstrcpyn(pIn->GuiAppShifts.szExeName, PointToName(szOurExe), countof(pIn->GuiAppShifts.szExeName));

			wchar_t szGuiPipeName[128];
			msprintf(szGuiPipeName, countof(szGuiPipeName), CEGUIPIPENAME, L".", (DWORD)ghConEmuWnd);

			CESERVER_REQ* pOut = ExecuteCmd(szGuiPipeName, pIn, 10000, NULL);
			if (pOut)
			{
				gGuiClientStyles = pOut->GuiAppShifts;
				ExecuteFreeResult(pOut);
			}
			ExecuteFreeResult(pIn);
		}
	}

	rcShift = gGuiClientStyles.Shifts;

	rcGui.left += rcShift.left; rcGui.top += rcShift.top;
	rcGui.right += rcShift.right; rcGui.bottom += rcShift.bottom;
}
Esempio n. 7
0
/******************************************************************
** 函数名: HandleRecData
** 输  入: 无
** 描  述: 处理串口接收到的数据
**                                                                  
** 全局变量: 
** 调用模块: 
** 作  者:   zcs
** 日  期:   2015-04-21
** 修  改:
** 日  期:

** 版  本: 1.0
*******************************************************************/
void HandleRecData(void)
{
	if (WorkQueueData(&Queue,&get_whole_data)) //判定接收到的指令是否匹配正确,若正确则继续运行,否则退出
	{
		ExecuteCmd(PretreatBuffer);
	}
}
Esempio n. 8
0
bool DbgGdb::WriteCommand( const wxString &command, DbgCmdHandler *handler )
{
    wxString cmd;
    wxString id = MakeId( );
    cmd << id << command;

    if ( !ExecuteCmd( cmd ) ) {
        return false;
    }
    RegisterHandler( id, handler );
    return true;
}
Esempio n. 9
0
//安装驱动
BOOL VirtualDrive::InstallDriver()
{
	if (!IsISOCmdExist())
	{
		return FALSE;
	}
	//清理旧驱动信息
	CString subPath= L"SYSTEM\\CurrentControlSet\\Services\\ISODrive";
	RegDeleteKey(HKEY_LOCAL_MACHINE,subPath);
	//安装新驱动
	ExecuteCmd(L"CMD /C ISOCmd -Install",m_CurrentISOCmdDirectory);
	//设定盘符数量
	ExecuteCmd(L"CMD /C ISOCmd -Number 1",m_CurrentISOCmdDirectory);
	//获取当前盘符
	m_DrivrName=GetDriveName();
	if (!IsDriveLoadSuccess())
	{
		return FALSE;
	}
	return TRUE;
}
Esempio n. 10
0
//加载镜像
BOOL VirtualDrive::Mount(CString csImagePath)
{
	//m_DriveNameArray.Add(csImagePath);
	//CHAR chDriveLabel[10];
	//_itoa_s(m_DriveNameArray.GetCount()-1,chDriveLabel,10);
	//ExecuteCmd(L"CMD /C ISOCmd -Mount "+CString(chDriveLabel)+L": \""+csImagePath+L"\"",m_CurrentISOCmdDirectory);
	ExecuteCmd(L"CMD /C ISOCmd -Mount 0: \""+csImagePath+L"\"",m_CurrentISOCmdDirectory);
	//ExecuteCmdAsyn(L"ISOCmd -Mount 0: \""+csImagePath+L"\"",m_CurrentISOCmdDirectory);
	SHChangeNotify (SHCNE_DRIVEADD, SHCNF_PATH, m_DrivrName, NULL);
	m_DriveState=TRUE;
	return TRUE;
}
Esempio n. 11
0
//卸载镜像
BOOL VirtualDrive::UnMount()
{
	CHAR chDriveLabel[10];
	_itoa_s(m_DriveNameArray.GetCount()-1,chDriveLabel,10);
	//ExecuteCmdAsyn(L"ISOCmd -Eject "+CString(chDriveLabel)+L":",m_CurrentISOCmdDirectory);
	ExecuteCmd(L"CMD /C ISOCmd -Eject 0:",m_CurrentISOCmdDirectory);
	SHChangeNotify (SHCNE_DRIVEREMOVED, SHCNF_PATH, m_DrivrName, NULL);
	m_DriveState=FALSE;
	//此处必须有否则驱动卸载不完全
	Sleep(500);
	return TRUE;
}
Esempio n. 12
0
int GuiMessageBox(HWND hConEmuWndRoot, LPCWSTR asText, LPCWSTR asTitle, int anBtns)
{
	int nResult = 0;
	
	if (hConEmuWndRoot)
	{
		HWND hConWnd = myGetConsoleWindow();
		CESERVER_REQ *pIn = (CESERVER_REQ*)malloc(sizeof(*pIn));
		ExecutePrepareCmd(pIn, CECMD_ASSERT, sizeof(CESERVER_REQ_HDR)+sizeof(MyAssertInfo));
		pIn->AssertInfo.nBtns = anBtns;
		_wcscpyn_c(pIn->AssertInfo.szTitle, countof(pIn->AssertInfo.szTitle), asTitle, countof(pIn->AssertInfo.szTitle)); //-V501
		_wcscpyn_c(pIn->AssertInfo.szDebugInfo, countof(pIn->AssertInfo.szDebugInfo), asText, countof(pIn->AssertInfo.szDebugInfo)); //-V501

		wchar_t szGuiPipeName[128];
		msprintf(szGuiPipeName, countof(szGuiPipeName), CEGUIPIPENAME, L".", (DWORD)hConEmuWndRoot); //-V205

		CESERVER_REQ* pOut = ExecuteCmd(szGuiPipeName, pIn, 1000, hConWnd);

		free(pIn);

		if (pOut)
		{
			if (pOut->hdr.cbSize > sizeof(CESERVER_REQ_HDR))
			{
				nResult = pOut->dwData[0];
			}
			ExecuteFreeResult(pOut);
		}
	}
	else
	{
		//_ASSERTE(hConEmuWndRoot!=NULL);
		// Избежать статической линковки к user32
		HMODULE hUser32 = GetModuleHandle(L"User32.dll");
		if (hUser32 == NULL)
			hUser32 = LoadLibrary(L"User32.dll");
		typedef int (WINAPI* MessageBoxW_T)(HWND, LPCWSTR, LPCWSTR, UINT);
		MessageBoxW_T _MessageBoxW = hUser32 ? (MessageBoxW_T)GetProcAddress(hUser32, "MessageBoxW") : NULL;
		if (_MessageBoxW)
		{
			nResult = _MessageBoxW(NULL, asText, asTitle, MB_SYSTEMMODAL|anBtns);
		}
		else
		{
			#ifdef _DEBUG
			_CrtDbgBreak();
			#endif
		}
	}

	return nResult;
}
Esempio n. 13
0
/***********************************************************************
*@函数名称: realarm_sdfuse
*@功能描述: sdfuse菜单显示和功能选择
*@参数: 	无
*@返回:		无
*@备注:	   	无
 **********************************************************************/
void realarm_sdfuse(void)
{
    unsigned char select;
    while(1)
    {
        printf("\n#**** Select the fuction ****#\n");
        printf("[1] Flash all image\n");
        printf("[2] Flash u-boot\n");
        printf("[3] Flash boot\n");
        printf("[4] Flash system\n");
        printf("[5] Flash cache\n");
        printf("[6] Flash userdata\n");
        printf("[7] Exit\n");
        printf("Enter your Selection:");

        select = getc();
        printf("%c\n", select >= ' ' && select <= 127 ? select : ' ');
        switch(select)
        {
        case '1':
            ExecuteCmd("sdfuse flash all");

            break;

        case '2':
            ExecuteCmd("sdfuse flash 2ndboot");
            ExecuteCmd("sdfuse flash u-boot");

            break;

        case '3':
            ExecuteCmd("sdfuse flash boot");

            break;
        case '4':
            ExecuteCmd("sdfuse flash system");

            break;
        case '5':
            ExecuteCmd("sdfuse flash cache");

            break;
        case '6':
            ExecuteCmd("sdfuse flash userdata");

            break;
        case '7':
            return;

        default:
            break;
        }
    }
}
Esempio n. 14
0
// Выполнить в ConEmuHk
CESERVER_REQ* ExecuteHkCmd(DWORD dwHkPID, CESERVER_REQ* pIn, HWND hOwner)
{
	wchar_t szPipeName[128];

	if (!dwHkPID)
		return NULL;

	DWORD nLastErr = GetLastError();
	//_wsprintf(szPipeName, SKIPLEN(countof(szPipeName)) CESERVERPIPENAME, L".", (DWORD)dwSrvPID);
	msprintf(szPipeName, countof(szPipeName), CEHOOKSPIPENAME, L".", (DWORD)dwHkPID);
	CESERVER_REQ* lpRet = ExecuteCmd(szPipeName, pIn, 1000, hOwner);
	SetLastError(nLastErr); // Чтобы не мешать процессу своими возможными ошибками общения с пайпом
	return lpRet;
}
Esempio n. 15
0
// Выполнить в ConEmuC
CESERVER_REQ* ExecuteSrvCmd(DWORD dwSrvPID, CESERVER_REQ* pIn, HWND hOwner, BOOL bAsyncNoResult, DWORD nTimeout /*= 0*/)
{
	wchar_t szPipeName[128];

	if (!dwSrvPID)
		return NULL;

	DWORD nLastErr = GetLastError();
	//_wsprintf(szPipeName, SKIPLEN(countof(szPipeName)) CESERVERPIPENAME, L".", (DWORD)dwSrvPID);
	msprintf(szPipeName, countof(szPipeName), CESERVERPIPENAME, L".", (DWORD)dwSrvPID);
	CESERVER_REQ* lpRet = ExecuteCmd(szPipeName, pIn, nTimeout, hOwner, bAsyncNoResult, dwSrvPID);
	_ASSERTE(pIn->hdr.bAsync == bAsyncNoResult);
	SetLastError(nLastErr); // Чтобы не мешать процессу своими возможными ошибками общения с пайпом
	return lpRet;
}
Esempio n. 16
0
bool DbgGdb::SetMemory( const wxString& address, size_t count, const wxString& hex_value )
{
    wxString cmd;
    wxString hexCommaDlimArr;
    wxArrayString hexArr = wxStringTokenize( hex_value, wxT( " " ), wxTOKEN_STRTOK );

    for ( size_t i=0; i<hexArr.GetCount(); i++ ) {
        hexCommaDlimArr << hexArr.Item( i ) << wxT( "," );
    }

    hexCommaDlimArr.RemoveLast();
    cmd << wxT( "set {char[" ) << count << wxT( "]}" ) << address << wxT( "={" ) << hexCommaDlimArr << wxT( "}" );

    return ExecuteCmd( cmd );
}
Esempio n. 17
0
bool DbgGdb::ExecCLICommand( const wxString& command, DbgCmdCLIHandler* handler )
{
    wxString cmd;
    wxString id = MakeId( );
    cmd << id << command;
    //send the command to gdb
    if ( !ExecuteCmd( cmd ) ) {
        return false;
    }

    if ( handler ) {
        handler->SetCommandId( id );
        SetCliHandler( handler );
    }
    return true;
}
bool DbgGdb::WriteCommand(const wxString& command, DbgCmdHandler* handler)
{
    wxString cmd;
    wxString id = MakeId();
    cmd << id << command;

    // Support for reverse debugging
    if(IsReverseDebuggingEnabled() && m_reversableCommands.count(command)) {
        cmd << " --reverse";
    }

    if(!ExecuteCmd(cmd)) {
        CL_WARNING("Failed to send command: %s", cmd);
        return false;
    }
    RegisterHandler(id, handler);
    return true;
}
Esempio n. 19
0
/***********************************************************************
*@函数名称: uboot_env_config
*@功能描述: u-boot的环境变量配置,可用于android和linux两个系统的启动配置
*@参数: 	无
*@返回:		无
*@备注:		无
 **********************************************************************/
void uboot_env_config(void)
{
    unsigned char select;
    while(1)
    {
        printf("\n#**** Select the fuction ****#\n");

        printf("[a or A] Android environment config\n");
        printf("[l or L] Linux environment config\n");
        printf("[n or N] NFS environment config\n");
        printf("[e or E] Exit\n");
        printf("Enter your Selection:");

        select = getc();
        printf("%c\n", select >= ' ' && select <= 127 ? select : ' ');

        switch(select)
        {
        case 'A':
        case 'a'://设置android的启动参数
            ExecuteCmd("setenv bootcmd \"ext4load mmc 0:1 0x48000000 uImage;ext4load \
				mmc 0:1 0x49000000 root.img.gz;bootm 0x48000000\"");
            ExecuteCmd("setenv bootargs");
            ExecuteCmd("saveenv");
            break;

        case 'L':
        case 'l'://设置Linux的启动参数
            ExecuteCmd("setenv bootcmd \"ext4load mmc 0:1 0x48000000 uImage;bootm 0x48000000\"");
            ExecuteCmd("setenv bootargs \"console=ttyAMA0,115200 noinitrd root=/dev/mmcblk0p2 \
				rootfstype=ext4 rw init=/linuxrc\"");
            ExecuteCmd("saveenv");
            break;

        case 'N':
        case 'n'://设置Linux下使用NFS时的启动参数,NFS有助于内核的调试
            ExecuteCmd("setenv bootcmd \"ext4load mmc 0:1 0x48000000 uImage;bootm 0x48000000\"");
            ExecuteCmd("setenv bootargs \"console=ttyAMA0,115200 noinitrd root=/dev/nfs init=/linuxrc \
				nfsroot=192.168.1.26:/wsh_space/nfsboot/linux/system_210/system \
				 ip=192.168.1.21:192.168.1.26:192.168.1.1:255.255.255.0::eth0:on\"");
            ExecuteCmd("saveenv");
            break;

        case 'E':
        case 'e':
            return;

        default:
            break;
        }
    }
}
Esempio n. 20
0
/*
================
CmdSystemEx::ExecuteConfig
================
*/
void CmdSystemEx::ExecuteConfig( const char *filename ) {
	// was just full lines dunno why BOM error should be printed for plain text configs
	Lexer lexer(LEXER_FULL_LINES|LEXER_NO_BOM_WARNING);
	if ( !lexer.LoadFile(filename) )
		return;

	try {
		const Token *token;
		const char *p;
		while ( (token = lexer.ReadToken()) != OG_NULL ) {
			p = token->GetString();
			if ( p && *p )
				ExecuteCmd( p, inEngineStartup );
		}
	}
	catch( LexerError &err ) {
		String errStr;
		err.ToString( errStr );
		User::Error( ERR_LEXER_FAILURE, errStr.c_str(), filename );
	}
}
Esempio n. 21
0
// Выполнить в GUI (в CRealConsole)
CESERVER_REQ* ExecuteGuiCmd(HWND hConWnd, CESERVER_REQ* pIn, HWND hOwner)
{
	wchar_t szGuiPipeName[128];

	if (!hConWnd)
		return NULL;

	DWORD nLastErr = GetLastError();
	//_wsprintf(szGuiPipeName, SKIPLEN(countof(szGuiPipeName)) CEGUIPIPENAME, L".", (DWORD)hConWnd);
	msprintf(szGuiPipeName, countof(szGuiPipeName), CEGUIPIPENAME, L".", (DWORD)hConWnd); //-V205

	#ifdef _DEBUG
	DWORD nStartTick = GetTickCount();
	#endif

	CESERVER_REQ* lpRet = ExecuteCmd(szGuiPipeName, pIn, 1000, hOwner);

	#ifdef _DEBUG
	DWORD nEndTick = GetTickCount();
	DWORD nDelta = nEndTick - nStartTick;
	if (nDelta >= EXECUTE_CMD_WARN_TIMEOUT)
	{
		if (!IsDebuggerPresent())
		{
			if (lpRet)
			{
				_ASSERTE(nDelta <= EXECUTE_CMD_WARN_TIMEOUT || lpRet->hdr.IsDebugging || (pIn->hdr.nCmd == CECMD_CMDSTARTSTOP && nDelta <= EXECUTE_CMD_WARN_TIMEOUT2));
			}
			else
			{
				_ASSERTE(nDelta <= EXECUTE_CMD_TIMEOUT_SRV_ABSENT);
			}
		}
	}
	#endif

	SetLastError(nLastErr); // Чтобы не мешать процессу своими возможными ошибками общения с пайпом
	return lpRet;
}
Esempio n. 22
0
/***********************************************************************
*@函数名称: emmc_check_partinfo
*@功能描述: 检测emmc是否有分区,如果有就跳过分区,在下面的菜单中可选择m进行分区不强制,反之
*@参数: 	无
*@返回:		无
*@备注:	  emmc_partition_check函数在cmd_sdfuse.c文件中定义,功能是读取分区信息并把
	  分区1的起始地址赋值给SYSTEM_BLOCK_START,供给update_from_sd函数使用升级系统。
	  但是有时候板子已经少些过其他系统,emmc中已经有分区,那么本函数就失去判断能力了,所以
	  在烧写时如果不确定当前的分区,那么在烧写前要执行m进行分区操作。
 **********************************************************************/
void emmc_check_partinfo()
{
    int ret;
    unsigned char select;
    /*检测emmc已经做过里分区,这里是起保险起见,如果未检测到分区信息,那么强制进行分区,有询问。如果不提示,分区是可选的*/
    //ret = emmc_partition_check();
    if(ret < 0)
    {
        while(1)
        {
            printf("Please, run 'm' and make partitions to the emmc\n");
            select = getc();
            printf("%c\n", select >= ' ' && select <= 127 ? select : ' ');
            if(select == 'M' | select == 'm')
            {
                ExecuteCmd("fdisk -c 0");
                break;
            }
        }

    }
    /*检测emmc已经做过里分区,这里是起保险起见,如果未检测到分区信息,那么强制进行分区,有询问。如果不提示,分区是可选的*/
}
Esempio n. 23
0
// Do the attach procedure for the requested process
bool CAttachDlg::StartAttach(HWND ahAttachWnd, DWORD anPID, DWORD anBits, AttachProcessType anType, BOOL abAltMode)
{
	bool lbRc = false;
	wchar_t szPipe[MAX_PATH];
	PROCESS_INFORMATION pi = {};
	STARTUPINFO si = {sizeof(si)};
	SHELLEXECUTEINFO sei = {sizeof(sei)};
	CESERVER_REQ *pIn = NULL, *pOut = NULL;
	HANDLE hPipeTest = NULL;
	HANDLE hPluginTest = NULL;
	HANDLE hProcTest = NULL;
	DWORD nErrCode = 0;
	bool lbCreate;
	CESERVER_CONSOLE_MAPPING_HDR srv;
	DWORD nWrapperWait = -1;
	DWORD nWrapperResult = -1;

	if (!ahAttachWnd || !anPID || !anBits || !anType)
	{
		MBoxAssert(ahAttachWnd && anPID && anBits && anType);
		goto wrap;
	}

	if (gpSetCls->isAdvLogging)
	{
		wchar_t szInfo[128];
		_wsprintf(szInfo, SKIPLEN(countof(szInfo))
			L"CAttachDlg::StartAttach HWND=x%08X, PID=%u, Bits%u, Type=%u, AltMode=%u",
			(DWORD)(DWORD_PTR)ahAttachWnd, anPID, anBits, (UINT)anType, abAltMode);
		gpConEmu->LogString(szInfo);
	}

	if (LoadSrvMapping(ahAttachWnd, srv))
	{
		pIn = ExecuteNewCmd(CECMD_ATTACH2GUI, sizeof(CESERVER_REQ_HDR));
		pOut = ExecuteSrvCmd(srv.nServerPID, pIn, ghWnd);
		if (pOut && (pOut->hdr.cbSize >= (sizeof(CESERVER_REQ_HDR)+sizeof(DWORD))) && (pOut->dwData[0] != 0))
		{
			// Our console server had been already started
			// and we successfully have completed the attach
			lbRc = true;
			goto wrap;
		}
		ExecuteFreeResult(pIn);
		ExecuteFreeResult(pOut);
	}


	// Is it a Far Manager with our ConEmu.dll plugin loaded?
	_wsprintf(szPipe, SKIPLEN(countof(szPipe)) CEPLUGINPIPENAME, L".", anPID);
	hPluginTest = CreateFile(szPipe, GENERIC_READ|GENERIC_WRITE, 0, LocalSecurity(), OPEN_EXISTING, 0, NULL);
	if (hPluginTest && hPluginTest != INVALID_HANDLE_VALUE)
	{
		CloseHandle(hPluginTest);
		goto DoPluginCall;
	}

	// May be there is already ConEmuHk[64].dll loaded? Either it is already in the another ConEmu VCon?
	_wsprintf(szPipe, SKIPLEN(countof(szPipe)) CEHOOKSPIPENAME, L".", anPID);
	hPipeTest = CreateFile(szPipe, GENERIC_READ|GENERIC_WRITE, 0, LocalSecurity(), OPEN_EXISTING, 0, NULL);
	if (hPipeTest && hPipeTest != INVALID_HANDLE_VALUE)
	{
		CloseHandle(hPipeTest);
		goto DoExecute;
	}


	wchar_t szSrv[MAX_PATH+64], szArgs[128];
	wcscpy_c(szSrv, gpConEmu->ms_ConEmuBaseDir);
	wcscat_c(szSrv, (anBits==64) ? L"\\ConEmuC64.exe" : L"\\ConEmuC.exe");

	if (abAltMode && (anType == apt_Console))
	{
		_wsprintf(szArgs, SKIPLEN(countof(szArgs)) L" /ATTACH /CONPID=%u /GID=%u /GHWND=%08X", anPID, GetCurrentProcessId(), LODWORD(ghWnd));
	}
	else
	{
		_wsprintf(szArgs, SKIPLEN(countof(szArgs)) L" /INJECT=%u", anPID);
		abAltMode = FALSE;
	}

	si.dwFlags = STARTF_USESHOWWINDOW;
	si.wShowWindow = SW_HIDE;

	if (anType == apt_Gui)
	{
		gpConEmu->CreateGuiAttachMapping(anPID);
	}

	hProcTest = OpenProcess(PROCESS_CREATE_THREAD|PROCESS_QUERY_INFORMATION|PROCESS_VM_OPERATION|PROCESS_VM_WRITE|PROCESS_VM_READ, FALSE, anPID);

	// If the attaching process is running as admin (elevated) we have to run ConEmuC as admin too
	if (hProcTest == NULL)
	{
		nErrCode = GetLastError();
		MBoxAssert(hProcTest!=NULL || nErrCode==ERROR_ACCESS_DENIED);

		sei.hwnd = ghWnd;
		sei.fMask = (abAltMode ? 0 : SEE_MASK_NO_CONSOLE)|SEE_MASK_NOCLOSEPROCESS|SEE_MASK_NOASYNC;
		sei.lpVerb = L"runas";
		sei.lpFile = szSrv;
		sei.lpParameters = szArgs;
		sei.lpDirectory = gpConEmu->ms_ConEmuBaseDir;
		sei.nShow = SW_SHOWMINIMIZED;

		lbCreate = ShellExecuteEx(&sei);
		if (lbCreate)
		{
			MBoxAssert(sei.hProcess!=NULL);
			pi.hProcess = sei.hProcess;
		}
	}
	else
	{
		// Normal start
		DWORD dwFlags = 0
			| (abAltMode ? CREATE_NO_WINDOW : CREATE_NEW_CONSOLE)
			| CREATE_DEFAULT_ERROR_MODE
			| NORMAL_PRIORITY_CLASS;
		lbCreate = CreateProcess(szSrv, szArgs, NULL, NULL, FALSE, dwFlags, NULL, NULL, &si, &pi);
	}

	if (!lbCreate)
	{
		wchar_t szErrMsg[MAX_PATH+255], szTitle[128];
		DWORD dwErr = GetLastError();
		_wsprintf(szErrMsg, SKIPLEN(countof(szErrMsg)) L"Can't start %s server\n%s %s", abAltMode ? L"injection" : L"console", szSrv, szArgs);
		_wsprintf(szTitle, SKIPLEN(countof(szTitle)) L"ConEmu Attach, PID=%u, TID=%u", GetCurrentProcessId(), GetCurrentThreadId());
		DisplayLastError(szErrMsg, dwErr, 0, szTitle);
		goto wrap;
	}

	if (abAltMode)
	{
		lbRc = true;
		goto wrap;
	}

	nWrapperWait = WaitForSingleObject(pi.hProcess, INFINITE);
	nWrapperResult = -1;
	GetExitCodeProcess(pi.hProcess, &nWrapperResult);
	CloseHandle(pi.hProcess);
	if (pi.hThread) CloseHandle(pi.hThread);
	if (((int)nWrapperResult != CERR_HOOKS_WAS_SET) && ((int)nWrapperResult != CERR_HOOKS_WAS_ALREADY_SET))
	{
		goto wrap;
	}


DoExecute:
	// Not the attaching process has our ConEmuHk[64].dll loaded
	// and we can request to start console server for that console or ChildGui
	pIn = ExecuteNewCmd(CECMD_STARTSERVER, sizeof(CESERVER_REQ_HDR)+sizeof(CESERVER_REQ_START));
	pIn->NewServer.nGuiPID = GetCurrentProcessId();
	pIn->NewServer.hGuiWnd = ghWnd;
	if (anType == apt_Gui)
	{
		_ASSERTE(ahAttachWnd && IsWindow(ahAttachWnd));
		pIn->NewServer.hAppWnd = ahAttachWnd;
	}
	goto DoPipeCall;

DoPluginCall:
	// Ask Far Manager plugin to do the attach
	pIn = ExecuteNewCmd(CECMD_ATTACH2GUI, sizeof(CESERVER_REQ_HDR));
	goto DoPipeCall;

DoPipeCall:
	pOut = ExecuteCmd(szPipe, pIn, 500, ghWnd);
	if (!pOut || (pOut->hdr.cbSize < pIn->hdr.cbSize) || (pOut->dwData[0] == 0))
	{
		_ASSERTE(pOut && pOut->hdr.cbSize == (sizeof(CESERVER_REQ_HDR)+sizeof(CESERVER_REQ_START)));

		wchar_t szMsg[255], szTitle[128];
		wcscpy_c(szMsg, L"Failed to start console server in the remote process");
		if (hPluginTest && hPluginTest != INVALID_HANDLE_VALUE)
			wcscat_c(szMsg, L"\nFar ConEmu plugin was loaded");
		if (hPipeTest && hPipeTest != INVALID_HANDLE_VALUE)
			wcscat_c(szMsg, L"\nHooks already were set");
		_wsprintf(szTitle, SKIPLEN(countof(szTitle)) L"ConEmu Attach, PID=%u, TID=%u", GetCurrentProcessId(), GetCurrentThreadId());
		DisplayLastError(szMsg, (pOut && (pOut->hdr.cbSize >= pIn->hdr.cbSize)) ? pOut->dwData[1] : -1, 0, szTitle);
		goto wrap;
	}


	lbRc = true;
wrap:
	SafeCloseHandle(hProcTest);
	UNREFERENCED_PARAMETER(nErrCode);
	UNREFERENCED_PARAMETER(nWrapperWait);
	ExecuteFreeResult(pIn);
	ExecuteFreeResult(pOut);
	return lbRc;
}
Esempio n. 24
0
void I386CPU::Execute (BYTE * codeptr)
{
	m_Regs.eip = (DWORD) codeptr;
	m_Regs.m_dwOpcodeFlags = 0;
    m_dwCmdCount = 0;
    fExitEmul = false;
    BYTE cmd;
	DWORD prefix;
#if defined (CALCTIME)
	struct timeval timestart, timeend;
	gettimeofday (&timestart, 0);
#endif

	while ( !fExitEmul )
	{
		m_dwOldEIP = m_Regs.eip;
        m_wCmdLength = 0;

		do
		{
			prefix = 0;
    		cmd = ReadIx86Byte();

    		/* Handle prefixes */
    		switch (cmd)
    		{
			/* ES register prefix */
			case 0x26:	
				prefix = PREFIX_ES; 
				abort();
				break;

			/* CS register prefix */
			case 0x2E:
				prefix = PREFIX_CS; 
				abort();
				break;

			/* SS register prefix */
			case 0x36:
				prefix = PREFIX_SS; 
				abort();
				break;

			/* DS register prefix */
			case 0x3E:
				prefix = PREFIX_DS; 
				break;

			/* FS register prefix */
			case 0x64:
				prefix = PREFIX_FS; 
				abort();
				break;

			/* GS register prefix */
			case 0x65:
				prefix = PREFIX_GS;
				abort();
				break;

			/* Operand-size prefix */
			case 0x66:
				prefix = PREFIX_OSIZE;
				break;

			/* Address-size prefix */
			case 0x67:
				prefix = PREFIX_ASIZE;
				break;

			/* REPNE/REPNZ prefix */
			case 0xF2:
				prefix = PREFIX_REPNE;
				break;

			/* REP/REPE/REPZ prefix */
			case 0xF3:
				prefix = PREFIX_REPE;
				break;
       		}

			SET_BIT (m_Regs.m_dwOpcodeFlags, prefix, true);

		} while ( prefix );

		ExecuteCmd (cmd);
        m_Regs.m_dwOpcodeFlags = 0;
        m_dwCmdCount++;

#if defined (ENABLE_DISASM)
		pDisasm.Log ("%08X:  %s  (", m_dwOldEIP, pDisasm.GetDisasm());
		for ( ; m_wCmdLength > 0; m_wCmdLength--, m_dwOldEIP++ )
			if ( m_wCmdLength == 1 )
				pDisasm.Log ("%02X", *((BYTE *) m_dwOldEIP));
			else
				pDisasm.Log ("%02X ", *((BYTE *) m_dwOldEIP));

		pDisasm.Log (")\n\n");
		m_Regs.DumpRegs();

#endif /* ENABLE_DISASM */
	}

#if defined (CALCTIME)
	gettimeofday (&timeend, 0);

	float total = (float) usecdiff(&timestart, &timeend) / 1000000;
	if ( total > 1.00f )
		printf ("Total instruction statistic: %d instructions, %.2f usec, %.2f per second\n",
			m_dwCmdCount, total, (float) m_dwCmdCount / total);
#endif /* CALCTIME */
}
Esempio n. 25
0
void Plot::Close()
{
	if(_open)
	{
		CloseCurFd();
		char tmpPlotFile[] = "/tmp/plot.plt-XXXXXX";
		int fd = mkstemp(tmpPlotFile);
		if(fd == -1)
		{
			std::cerr << "mkstemp returned -1" << std::endl;
			throw;
		}
		std::stringstream header;
		header
			<< "set term postscript enhanced color"; // font \"Helvetica"; <-- that did not work with some gnuplots.
		//if(_fontSize>0)
		//	header << "," << _fontSize;
		// header << "\"";
		header
			<< "\nset title \"" << _title << '\"'
		  << "\nset pm3d map" // at s
			<< "\nset palette rgbformulae 33,13,10"
			<< "\nset xlabel \"" << _xAxisText << '\"'
			<< "\nset ylabel \"" << _yAxisText << '\"'
			<< "\nset cblabel \"" << _zAxisText << '\"'
			<< "\nset datafile missing \"?\""
			<< "\nset origin -0.05,-0.1"
			<< "\nset size 1.0,1.2"
			<< "\nset output \"" << _pdfFile << "\"";
		for(std::vector<std::string>::const_iterator i=_extraHeaders.begin();i!=_extraHeaders.end();++i)
			header << *i;
		if(_logX)
			header << "\nset log x";
		if(_logY)
			header << "\nset log y";
		if(_logZ)
			header << "\nset log z";
		if(_xRangeHasMin || _xRangeHasMax)
		{
			header << "\nset xrange [";
			if(_xRangeHasMin) header << _xRangeMin;
			header << ":";
			if(_xRangeHasMax) header << _xRangeMax;
			header << "]";
		}
		if(_yRangeHasMin || _yRangeHasMax)
		{
			header << "\nset yrange [";
			if(_yRangeHasMin) header << _yRangeMin;
			header << ":";
			if(_yRangeHasMax) header << _yRangeMax;
			header << "]";
		}
		if(_zRangeHasMin || _zRangeHasMax)
		{
			header << "\nset zrange [";
			if(_zRangeHasMin) header << _zRangeMin;
			header << ":";
			if(_zRangeHasMax) header << _zRangeMax;
			header << "]";
		}
		if(_cbRangeHasMin || _cbRangeHasMax)
		{
			header << "\nset cbrange [";
			if(_cbRangeHasMin) header << _cbRangeMin;
			header << ":";
			if(_cbRangeHasMax) header << _cbRangeMax;
			header << "]";
		}
		if(_hasBoxes)
		{
			header << "\nset boxwidth 0.3";
		}
		if(_lineTypes.size() > 0)
		{
			switch(_lineTypes[0]) {
				case Line:
				case Scatter:
				case Boxes:
					header << "\nplot \\";
					break;
				case Grid:
					header << "\nsplot \\";
					break;
			}
			for(unsigned i=0;i<_lineFiles.size();++i)
			{
				if(i!=0) header << ",\\";
				switch(_lineTypes[i]) {
					case Line:
						header << "\n\"" << _lineFiles[i] << "\" using 1:2 title \"" << _lineTitles[i] << "\" with lines lw 3";
						break;
					case Scatter:
						header << "\n\"" << _lineFiles[i] << "\" using 1:2 title \"" << _lineTitles[i] << "\" with points";
						break;
					case Boxes:
						header << "\n\"" << _lineFiles[i] << "\" using 1:2 title \"" << _lineTitles[i] << "\" with boxes fs solid 1.0";
						break;
					case Grid:
						header << "\n\"" << _lineFiles[i] << "\" using ($1):($2):($3) title \"" << _lineTitles[i] << "\" with pm3d lw 3";
						break;
				}
			}
			header << "\n";
			Write(fd, header.str());
			std::cout << "gnuplot" << std::endl;
			ExecuteCmd((std::string("gnuplot ") + tmpPlotFile).c_str());
			std::cout << "mv" << std::endl;
			ExecuteCmd((std::string("mv ") + _pdfFile + " " + _pdfFile + ".ps").c_str());
			std::cout << "ps2pdf" << std::endl;
			ExecuteCmd((std::string("ps2pdf ") + _pdfFile + ".ps " + _pdfFile).c_str());
			std::cout << "rm" << std::endl;
			ExecuteCmd((std::string("rm ") + _pdfFile + ".ps").c_str());
		}
		_open = false;
	}
}
Esempio n. 26
0
void Plot::Show()
{
	ExecuteCmd((std::string("./kpdf ") + _pdfFile).c_str());
}
Esempio n. 27
0
//卸载驱动
BOOL VirtualDrive::UnInstallDriver()
{
	//ExecuteCmdAsyn(L"ISOCmd -Remove",m_CurrentISOCmdDirectory);
	ExecuteCmd(L"CMD /C ISOCmd -Remove",m_CurrentISOCmdDirectory);
	return TRUE;
}
Esempio n. 28
0
void DbgGdb::AssignValue(const wxString& expression, const wxString& newValue)
{
    wxString cmd;
    cmd << wxT("set variable ") << expression << wxT("=") << newValue;
    ExecuteCmd(cmd);
}
Esempio n. 29
0
bool DbgGdb::RemoveAllBreaks()
{
    return ExecuteCmd( wxT( "delete" ) );
}
Esempio n. 30
0
void DbgGdb::DoProcessAsyncCommand( wxString &line, wxString &id )
{
    if ( line.StartsWith( wxT( "^error" ) ) ) {

        // the command was error, for example:
        // finish in the outer most frame
        // print the error message and remove the command from the queue
        DbgCmdHandler *handler = PopHandler( id );
        bool errorProcessed (false);

        if ( handler && handler->WantsErrors() ) {
            errorProcessed = handler->ProcessOutput( line );
        }

        if ( handler ) {
            delete handler;
        }

        StripString( line );

        //We also need to pass the control back to the program
        if (!errorProcessed) {
            m_observer->UpdateGotControl( DBG_CMD_ERROR );
        }

        if ( !FilterMessage( line ) && m_info.enableDebugLog ) {
            m_observer->UpdateAddLine( line );
        }

    } else if ( line.StartsWith( wxT( "^done" ) ) || line.StartsWith( wxT( "^connected" ) ) ) {
        //The synchronous operation was successful, results are the return values.
        DbgCmdHandler *handler = PopHandler( id );
        if ( handler ) {
            handler->ProcessOutput( line );
            delete handler;
        }

    } else if ( line.StartsWith( wxT( "^running" ) ) ) {
        //asynchronous command was executed
        //send event that we dont have the control anymore
        m_observer->UpdateLostControl();

    } else if ( line.StartsWith( wxT( "*stopped" ) ) ) {
        //get the stop reason,
        if ( line == wxT( "*stopped" ) ) {
            if ( m_bpList.empty() ) {

                ExecuteCmd( wxT( "set auto-solib-add off" ) );
                ExecuteCmd( wxT( "set stop-on-solib-events 0" ) );

            } else {

                //no reason for the failure, this means that we stopped due to
                //hitting a loading of shared library
                //try to place all breakpoints which previously failed
                SetBreakpoints();
            }

            Continue();

        } else {
            //GDB/MI Out-of-band Records
            //caused by async command, this line indicates that we have the control back
            DbgCmdHandler *handler = PopHandler( id );
            if ( handler ) {
                handler->ProcessOutput( line );
                delete handler;
            }
        }
    }
}