Ejemplo n.º 1
0
Archivo: main.c Proyecto: Aleyr/nesemu2
static void console_addline(char *str)
{
	HWND hCtrl;
	int index;

	hCtrl = GetDlgItem(hConsole,IDC_CONSOLEEDIT);
	index = GetWindowTextLength(hCtrl);
	Edit_SetSel(hCtrl,index,index);
	Edit_ReplaceSel(hCtrl,str);
}
Ejemplo n.º 2
0
// delete a line
void editDeleteLine(HWND i_hwnd, size_t i_n)
{
    int len = Edit_LineLength(i_hwnd, i_n);
    if (len < 0)
        return;
    len += 2;
    int index = Edit_LineIndex(i_hwnd, i_n);
    Edit_SetSel(i_hwnd, index, index + len);
    Edit_ReplaceSel(i_hwnd, _T(""));
}
Ejemplo n.º 3
0
/* This function writes the appropriate signature for the specified
 * topic.
 */
void FASTCALL SetEditSignature( HWND hwndEdit, PTL ptl )
{
   LPSTR lpszSignature;
   char * pszSig;

   pszSig = NULL;
   if( NULL == ptl )
      pszSig = szGlobalSig;
   else
      {
      TOPICINFO topicinfo;

      Amdb_GetTopicInfo( ptl, &topicinfo );
      if( topicinfo.szSigFile[ 0 ] )
         pszSig = topicinfo.szSigFile;
      }
   if( NULL != pszSig )
      if( NULL != ( lpszSignature = GetEditSignature( pszSig ) ) )
         {
         DWORD dwSig1Sel;

         /* Save the caret position and append the signature to the end of the
          * current text. Then put the caret back where it was.
          */
         dwSig1Sel = Edit_GetSel( hwndEdit );
         if( fEditAtTop )
         {
         Edit_SetSel( hwndEdit, 0, 0 );
         Edit_ReplaceSel( hwndEdit, lpszSignature );
         Edit_SetSel( hwndEdit, 0, 0 );
         Edit_ScrollCaret( hwndEdit );
         }
         else
         {
         Edit_SetSel( hwndEdit, USHRT_MAX, USHRT_MAX );
         Edit_ReplaceSel( hwndEdit, lpszSignature );
         Edit_SetSel( hwndEdit, LOWORD(dwSig1Sel), HIWORD(dwSig1Sel) );
         }

         FreeMemory( &lpszSignature );
         }
}
Ejemplo n.º 4
0
void edit_info_append (const char *msg)
{
    HWND hwndEditInfo;
    int len;

    hwndEditInfo = GetDlgItem (hwndDlg, IDC_EDT_INFO); 

    len = GetWindowTextLength (hwndEditInfo);
    SetFocus (hwndEditInfo);
    Edit_SetSel (hwndEditInfo, len, len);
    Edit_ReplaceSel (hwndEditInfo, msg);
}
Ejemplo n.º 5
0
Archivo: qa.c Proyecto: mingpen/OpenNT
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
void AppPrint(LPTSTR sz,...)
{
    HWND hwndE = GetWindow(hwndApp, GW_CHILD);
    TCHAR ach[128];
    va_list marker;

    va_start( marker, sz );

    if (hwndE == NULL) 
    {
    	RECT rc;
        GetClientRect(hwndApp, &rc);
        hwndE = CreateWindow (TEXT("Edit"), TEXT(""),
            WS_VISIBLE | WS_CHILD | ES_MULTILINE | ES_READONLY | WS_VSCROLL | ES_AUTOVSCROLL,
            0, 0, rc.right, rc.bottom,
            hwndApp, (HMENU)-1, hInstApp, NULL);

        SetWindowFont(hwndE, GetStockObject(ANSI_FIXED_FONT), TRUE);
    }

    if (sz == NULL)
    {
    	Edit_SetSel(hwndE, 0, (UINT)-1);
    	Edit_ReplaceSel(hwndE, TEXT(""));
    }
    else
    {
    	wvsprintf (ach,(LPCTSTR)sz,marker);   /* Format the string */
    	lstrcat(ach, TEXT("\r\n"));

    	Edit_SetSel(hwndE, (UINT)-1, (UINT)-1);
    	Edit_ReplaceSel(hwndE, ach);
    }

    va_end(marker);
}
Ejemplo n.º 6
0
void Calculus::OutputResult_D(int iSelectIndex,ErrNo err)
{
	PCTSTR	pErrInfo;
	HWND hEdit = GetDlgItem(hDlg,EditOutputID);
	TCHAR szBuffer[MAXSIZE];

	Edit_SetSel(hEdit,0,0);
	switch(iSelectIndex)
	{
	case FORWARD_DIFFERENCE_INDEX:
		Edit_ReplaceSel(hEdit,TEXT("选择的算法: 基于Taylor公式的数值微分公式-向前差商 \r\n"));
		break;

	case BACKFORWARD_DIFFERENCE_INDEX:
		Edit_ReplaceSel(hEdit,TEXT("选择的算法: 基于Taylor公式的数值微分公式-向后差商 \r\n"));
		break;

	case CENTRAL_DIFFERENCE_DIFFERENCE_INDEX:
		Edit_ReplaceSel(hEdit,TEXT("选择的算法: 基于Taylor公式的数值微分公式-中心差商 \r\n"));
		break;

	case SO_CENTRAL_DIFFERENCE_DIFFERENCE_INDEX:
		Edit_ReplaceSel(hEdit,TEXT("选择的算法: 基于Taylor公式的数值微分公式-二阶中心差商 \r\n"));
		break;
	}

	_stprintf_s(szBuffer,MAXSIZE,TEXT("函数表达式为:y=%s\r\n"),exp_store);
	Edit_ReplaceSel(hEdit,szBuffer);
	if(err)
	{
		pErrInfo = FormatError(err);
		_sntprintf_s(szBuffer,_countof(szBuffer),MAXSIZE,TEXT("错误ID:%d\r\n错误信息:%s\r\n"),err,pErrInfo);
		Edit_ReplaceSel(hEdit,szBuffer);
	}
	else
	{
		
		if(iSelectIndex == SO_CENTRAL_DIFFERENCE_DIFFERENCE_INDEX)
			_stprintf_s(szBuffer,MAXSIZE,TEXT("所求点:%f  间隔:%f  函数在该点的二阶导数为:%f\r\n"),value,interval,result);
		else
			_stprintf_s(szBuffer,MAXSIZE,TEXT("所求点:%f  间隔:%f  函数在该点的一阶导数为:%f\r\n"),value,interval,result);
		Edit_ReplaceSel(hEdit,szBuffer);
	}
	Edit_ReplaceSel(hEdit,TEXT("++++++++++++++++++++++++++++++++++++++\r\n"));
}
Ejemplo n.º 7
0
void Calculus::OutputResult_I(int iSelectIndex,ErrNo err)
{
	PCTSTR		pErrInfo;
	HWND		hwndEdit = GetDlgItem(hDlg,EditOutputID);
	TCHAR		szBuffer[MAXSIZE];

	Edit_SetSel(hwndEdit,0,0);
	switch(iSelectIndex)
	{
	case ROMBERG_INDEX:
		Edit_ReplaceSel(hwndEdit,TEXT("选择的算法: Romberg算法 \r\n"));
		break;
	case GAUSS_LEGENDRE_INDEX:
		Edit_ReplaceSel(hwndEdit,TEXT("选择的算法: Gauss-Legendre求积公式(5点式) \r\n"));
		break;
	case GAUSS_CHEBYSHEV_INDEX:
		Edit_ReplaceSel(hwndEdit,TEXT("选择的算法: Gauss-Chebyshev求积公式(5点式) \r\n"));
		break;
	}


	swprintf(szBuffer,MAXSIZE,TEXT("所求函数为:%s\r\n"),exp_store);
	Edit_ReplaceSel(hwndEdit,szBuffer);
	
	if(err)
	{
		pErrInfo = FormatError(err);
		_sntprintf_s(szBuffer,_countof(szBuffer),MAXSIZE,TEXT("错误ID:%d\r\n错误信息:%s\r\n"),err,pErrInfo);
		Edit_ReplaceSel(hwndEdit,szBuffer);
	}
	else
	{
		if(iSelectIndex == ROMBERG_INDEX)
		{
			if(precision_a == precision)
				swprintf(szBuffer,MAXSIZE,TEXT("积分值:%f  精度:%f  区间:[%f,%f] \r\n"),result,precision,left_interval,right_interval);
			else
				swprintf(szBuffer,MAXSIZE,TEXT("积分值:%f  精度:%f  已达到精度:%f  区间:[%f,%f] \r\n"),result,precision,precision_a,left_interval,right_interval);
		}
		else
		{
			swprintf(szBuffer,MAXSIZE,TEXT("积分值:%f  区间:[%f,%f] \r\n"),result,left_interval,right_interval);
		}
		Edit_ReplaceSel(hwndEdit,szBuffer);
	}
	Edit_ReplaceSel(hwndEdit,TEXT("++++++++++++++++++++++++++++++++++++++\r\n"));

}
Ejemplo n.º 8
0
	void CEditUI::SetReplaceSel(LPCTSTR lpszReplace)
	{
		if( m_pWindow != NULL ) Edit_ReplaceSel(*m_pWindow, lpszReplace);
	}
Ejemplo n.º 9
0
/* This function locates the old signature in the specified edit
 * control and replaces it with the new one.
 */
void FASTCALL ReplaceEditSignature( HWND hwndEdit, char * pszOldSig, char * pszNewSig, BOOL fTop )
{
   LPSTR lpszOldSigText;
   LPSTR lpszNewSigText;
   UINT cbEdit;

   /* Get some lengths. Skip the replacement if
    * the signature is smaller than the edit text.
    */
   cbEdit = Edit_GetTextLength( hwndEdit );
   if( NULL != ( lpszOldSigText = GetEditSignature( pszOldSig ) ) )
      {
      if( NULL != ( lpszNewSigText = GetEditSignature( pszNewSig ) ) )
         {
         if( strlen(lpszOldSigText) <= cbEdit )
            {
            LPSTR lpText;
         
            INITIALISE_PTR(lpText);
            if( fNewMemory( &lpText, cbEdit + 1 ) )
               {
               DWORD sel;
               int nOldSig;
               int selEnd;
               int selStart;
         
               /* Get the edit control contents.
                */
               sel = Edit_GetSel( hwndEdit );
               selStart = LOWORD(sel);
               selEnd = HIWORD(sel);
               Edit_GetText( hwndEdit, lpText, cbEdit+1 );
               nOldSig = FStrMatch( lpText, lpszOldSigText, TRUE, FALSE );
#ifdef USEBIGEDIT
               SetWindowRedraw( hwndEdit, FALSE );
#endif USEBIGEDIT
               if( -1 != nOldSig )
                  {
                  Edit_SetSel( hwndEdit, nOldSig, nOldSig + strlen(lpszOldSigText) );
                  Edit_ReplaceSel( hwndEdit, lpszNewSigText );
                  }
               else
                  {
                  /* Not found, so go to end of edit text and append new
                   * signature there.
                   */
                  if( fTop )
                     Edit_SetSel( hwndEdit, 0, 0 );
                  else
                     Edit_SetSel( hwndEdit, 32767, 32767 );
                  Edit_ReplaceSel( hwndEdit, lpszNewSigText );
                  }
               Edit_SetSel( hwndEdit, selStart, selEnd );
#ifdef USEBIGEDIT
               SetWindowRedraw( hwndEdit, TRUE );
#endif USEBIGEDIT
               UpdateWindow( hwndEdit );
               FreeMemory( &lpText );
               }
            }
         FreeMemory( &lpszNewSigText );
         }
      FreeMemory( &lpszOldSigText );
      }
}
Ejemplo n.º 10
0
void DlgOnCommand (HWND hwnd, int id, HWND, UINT) 
{
	OPENFILENAME ofn;

	switch (id) 
	{
		/* * /
	case IDC_BUTTON_COPY:
		CopyControlToClipboard (g_hWndListBox) ;
		break ;
		/* */

    case IDC_BUTTON_BROWSE:
		
		ZERO_STRUCT(ofn, TRUE);
        
		ofn.hwndOwner    = hwnd;
        ofn.lpstrFile    = szVictimModule;
        ofn.nMaxFile     = _MAX_PATH;
        ofn.lpstrTitle   = "Select module (.dll or .exe) to analyze & load";
		ofn.lpstrFilter  = szFilters;
        ofn.Flags        = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_READONLY;
      
		GetOpenFileNameA (&ofn);
        
		if (stricmp (ofn.lpstrFile, szOriginalVictimModule) == 0)
			strcpy (ofn.lpstrFile, szOriginalShortVictim) ;

		SetDlgItemText (hwnd, IDC_EDIT_MODULE_FILENAME, ofn.lpstrFile);

		SetFocus (GetDlgItem (hwnd, IDC_BUTTON_LOAD));
        
		break;

	case IDC_BUTTON_FRESH_SIOD:

		FreshSiodThread () ;

		break;

	case IDC_BUTTON_LOAD:

		Edit_SetSel     (g_hWndEdit, 0, -1) ;
		Edit_ReplaceSel (g_hWndEdit, ""   ) ;

		GetDlgItemText (hwnd, IDC_EDIT_MODULE_FILENAME, szVictimModule, _MAX_PATH);

		g_hLoaderThread = CreateThread
		(
			NULL,							// No Security Attributes, please
			0,								// Default stack size, please
			ThreadLoader, 					// Run this function, please
			0,								// Function dosn't need any input
			0,								// Wake up now 
			&g_dwLoaderThreadId				// Must have an ID on Win95
		);

		if (g_hLoaderThread == NULL)
			LastErrorBox();

		break;
	
	case IDCANCEL:

		if (g_hSiodReplThread)
			CloseHandle (g_hSiodReplThread);

		if (g_hLoaderThread)
			CloseHandle (g_hLoaderThread);

		EndDialog(hwnd, id);

		break;
	}
}
Ejemplo n.º 11
0
inline void newline ()
{
	Edit_ReplaceSel (g_hWndListener, "\r\012") ;
}
Ejemplo n.º 12
0
static void printAddr( HWND hwnd,const TCHAR *beg,int num,
    void *ptr,const TCHAR *posFile,int posLine,const TCHAR *funcName,
    int posColumn )
{
  TCHAR hexNum[20];

  if( ptr )
  {
    Edit_ReplaceSel( hwnd,beg );

    if( num>=0 )
    {
      _stprintf( hexNum,TEXT("%02d"),num );
      Edit_ReplaceSel( hwnd,hexNum );
    }

    Edit_ReplaceSel( hwnd,TEXT(": 0x") );
    _stprintf( hexNum,TEXT("%p"),ptr );
    Edit_ReplaceSel( hwnd,hexNum );
  }
  else
  {
    _stprintf( hexNum,TEXT("%*s"),14,TEXT("") );
    Edit_ReplaceSel( hwnd,hexNum );
    _stprintf( hexNum,TEXT("%*s"),2+(int)sizeof(void*)*2,TEXT("") );
    Edit_ReplaceSel( hwnd,hexNum );
  }

  if( posFile )
  {
    Edit_ReplaceSel( hwnd,TEXT(" (") );
    Edit_ReplaceSel( hwnd,posFile );

    if( posLine>0 )
    {
      Edit_ReplaceSel( hwnd,TEXT(":") );
      _stprintf( hexNum,TEXT("%d"),posLine );
      Edit_ReplaceSel( hwnd,hexNum );

      if( posColumn>0 )
      {
        Edit_ReplaceSel( hwnd,TEXT(":") );
        _stprintf( hexNum,TEXT("%d"),posColumn );
        Edit_ReplaceSel( hwnd,hexNum );
      }
    }

    Edit_ReplaceSel( hwnd,TEXT(")") );
  }

  if( funcName )
  {
    Edit_ReplaceSel( hwnd,TEXT(" [") );
    Edit_ReplaceSel( hwnd,funcName );
    Edit_ReplaceSel( hwnd,TEXT("]") );
  }

  Edit_ReplaceSel( hwnd,TEXT("\r\n") );
}
Ejemplo n.º 13
0
static LONG WINAPI exceptionPrinter( LPEXCEPTION_POINTERS ep )
{
  EnumWindows( enumWindowsForDisable,GetCurrentProcessId() );

#define DWARFSTACK_DIALOG_CLASS TEXT("dwarfstack_exception_dialog")
  WNDCLASS wc;
  wc.style = CS_HREDRAW | CS_VREDRAW;
  wc.lpfnWndProc = exceptionWndProc;
  wc.cbClsExtra = 0;
  wc.cbWndExtra = DLGWINDOWEXTRA;
  wc.hInstance = GetModuleHandle( NULL );
  wc.hIcon = NULL;
  wc.hCursor = LoadCursor( NULL,IDC_ARROW );
  wc.hbrBackground = (HBRUSH)( COLOR_BTNFACE+1 );
  wc.lpszMenuName = NULL;
  wc.lpszClassName = DWARFSTACK_DIALOG_CLASS;
  RegisterClass( &wc );

  int sw = GetSystemMetrics( SM_CXSCREEN );
  int sh = GetSystemMetrics( SM_CYSCREEN );
#define DLG_W 500
#define DLG_H 500

  HWND hwnd = CreateWindow(
      DWARFSTACK_DIALOG_CLASS,TEXT("application crashed"),
      WS_CAPTION,(sw-DLG_W)/2,(sh-DLG_H)/2,DLG_W,DLG_H,
      NULL,NULL,GetModuleHandle(NULL),NULL );

  RECT rect;
  GetClientRect( hwnd,&rect );
  int w = rect.right - rect.left;
  int h = rect.bottom - rect.top;

  HWND textHwnd = CreateWindow( TEXT("edit"),TEXT(""),
      WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER|WS_HSCROLL|WS_VSCROLL|
      ES_MULTILINE|ES_AUTOHSCROLL|ES_AUTOVSCROLL|ES_READONLY,
      0,0,w,h-32,hwnd,NULL,NULL,NULL );
  CreateWindow( TEXT("button"),TEXT("OK"),
      WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_DEFPUSHBUTTON,
      (w-50)/2,h-28,50,24,
      hwnd,(HMENU)IDCANCEL,NULL,NULL );

#ifdef DWST_SHARED
  // needs -lgdi32 -> only in shared library
  HFONT font = GetStockObject( ANSI_FIXED_FONT );
  if( font )
    SendMessage( textHwnd,WM_SETFONT,(WPARAM)font,FALSE );
#endif


  {
    TCHAR exeName[MAX_PATH];
    if( GetModuleFileName(GetModuleHandle(NULL),exeName,MAX_PATH) )
    {
      Edit_ReplaceSel( textHwnd,TEXT("application:\r\n") );
      Edit_ReplaceSel( textHwnd,exeName );
      Edit_ReplaceSel( textHwnd,TEXT("\r\n\r\n") );
    }
  }

  if( myExtraInfo )
  {
    Edit_ReplaceSel( textHwnd,TEXT("extra information:\r\n") );
    Edit_ReplaceSel( textHwnd,myExtraInfo );
    Edit_ReplaceSel( textHwnd,TEXT("\r\n\r\n") );
  }

  DWORD code = ep->ExceptionRecord->ExceptionCode;
  const TCHAR *desc = NULL;
  switch( code )
  {
#define EX_DESC( name ) \
    case EXCEPTION_##name: desc = TEXT(" (") #name ")"; \
                           break

    EX_DESC( ACCESS_VIOLATION );
    EX_DESC( ARRAY_BOUNDS_EXCEEDED );
    EX_DESC( BREAKPOINT );
    EX_DESC( DATATYPE_MISALIGNMENT );
    EX_DESC( FLT_DENORMAL_OPERAND );
    EX_DESC( FLT_DIVIDE_BY_ZERO );
    EX_DESC( FLT_INEXACT_RESULT );
    EX_DESC( FLT_INVALID_OPERATION );
    EX_DESC( FLT_OVERFLOW );
    EX_DESC( FLT_STACK_CHECK );
    EX_DESC( FLT_UNDERFLOW );
    EX_DESC( ILLEGAL_INSTRUCTION );
    EX_DESC( IN_PAGE_ERROR );
    EX_DESC( INT_DIVIDE_BY_ZERO );
    EX_DESC( INT_OVERFLOW );
    EX_DESC( INVALID_DISPOSITION );
    EX_DESC( NONCONTINUABLE_EXCEPTION );
    EX_DESC( PRIV_INSTRUCTION );
    EX_DESC( SINGLE_STEP );
    EX_DESC( STACK_OVERFLOW );
  }
  TCHAR hexNum[20];

  Edit_ReplaceSel( textHwnd,TEXT("code: 0x") );
  _stprintf( hexNum,TEXT("%08lX"),code );
  Edit_ReplaceSel( textHwnd,hexNum );
  if( desc )
    Edit_ReplaceSel( textHwnd,desc );
  Edit_ReplaceSel( textHwnd,TEXT("\r\n") );

  if( code==EXCEPTION_ACCESS_VIOLATION &&
      ep->ExceptionRecord->NumberParameters==2 )
  {
    ULONG_PTR flag = ep->ExceptionRecord->ExceptionInformation[0];
    ULONG_PTR addr = ep->ExceptionRecord->ExceptionInformation[1];
    Edit_ReplaceSel( textHwnd,
        flag==8?TEXT("data execution prevention"):
        (flag?TEXT("write access"):TEXT("read access")) );
    Edit_ReplaceSel( textHwnd,TEXT(" violation at 0x") );
    _stprintf( hexNum,TEXT("%p"),(void*)addr );
    Edit_ReplaceSel( textHwnd,hexNum );
    Edit_ReplaceSel( textHwnd,TEXT("\r\n") );
  }
  Edit_ReplaceSel( textHwnd,TEXT("\r\n") );

  struct dialog_info di = { 0,textHwnd,NULL };
  dwstOfException( ep->ContextRecord,&dlgPrint,&di );

  SendMessage( hwnd,WM_NEXTDLGCTL,(WPARAM)textHwnd,TRUE );
  Edit_SetSel( textHwnd,0,0 );

  ShowWindow( hwnd,SW_SHOW );
  UpdateWindow( hwnd );

  MSG msg;
  while( GetMessage(&msg,NULL,0,0) )
  {
    if( IsDialogMessage(hwnd,&msg) ) continue;

    TranslateMessage( &msg );
    DispatchMessage( &msg );
  }

  return( EXCEPTION_EXECUTE_HANDLER );
}