コード例 #1
0
ファイル: Function.cpp プロジェクト: b2kguga/CodesAndNotes
int KFuncTable::InterceptWin32(void)
{
    int no = 0;

//	DebugBreak();

    for (int i=0; i<m_funcno; i++)
        if ( (m_func[i].f_kind==FUNC_WIN32API) & !m_func[i].f_hooked )
        // if there is an unhooked win32 function
		{
			int module = m_func[i].f_module;

			// if caller and callee are the same module, patch function target
			if ( strcmp(CallerName(module), CalleeName(module))==0 )
			{
				if ( directpatcher.Patch(ModHandle(module), GetFuncName(i), 
										 i, ProxyProlog,
										 (unsigned long *) &  m_func[i].f_oldaddress) )
					no ++;
			}
			else
			{
				const char *caller  = CallerName(module);
				const char *address = (const char *) ModHandle(module);

				// if caller module is loaded into current process, hack in it.
				if (address)
					no += InterceptWin32(caller, address);
			}
		}

    return no;
}
コード例 #2
0
ファイル: priinv.c プロジェクト: 0871087123/rtems
void AccessRemoteHw(void)
{
  rtems_status_code     Sts;

#if defined(TEST_PRINT_STATISTICS)
  rtems_task_priority   EnterPrio;   /* Statistics log */
  rtems_task_priority   AccessPrio;  /*      :         */
  rtems_task_priority   LeavePrio;   /*      :         */
  uint32_t              EnterCnt;    /*      :         */
  uint32_t              AccessCnt;   /*      :         */
  uint32_t              LeaveCnt;    /*      :         */
#endif

#if defined(TEST_PRINT_STATISTICS)
  /* Store information about the current situation */
  EnterPrio = _Thread_Executing->current_priority;
  EnterCnt  = _Thread_Executing->resource_count;
#endif

  printf("AccessRemoteHw called by %s\n", CallerName());

  /* Obtain exclusive access to remote HW, Start HW, Wait for completion,
   * Release access
   */

  Sts = rtems_semaphore_obtain(RemoteHwAccess_R, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
  directive_failed( Sts, "rtems_semaphore_obtain(RemoteHwAccess_R...)" );

  /* Carry out the remote access via the Local HW interface */
  printf("AccessRemoteHw access local %s\n", CallerName());
  AccessLocalHw();

#if defined(TEST_PRINT_STATISTICS)
  /* Store information about the current situation */
  AccessPrio = _Thread_Executing->current_priority;
  AccessCnt  = _Thread_Executing->resource_count;
#endif

  Sts = rtems_semaphore_release(RemoteHwAccess_R);
  directive_failed( Sts, "rtems_semaphore_release(RemoreHwAccess_R" );

#if defined(TEST_PRINT_STATISTICS)
  /* Store information about the current situation */
  LeavePrio = _Thread_Executing->current_priority;
  LeaveCnt  = _Thread_Executing->resource_count;

  printf(
    "\nAccessRemoteHw from %s statistics:\n"
    " - Prio: %d -> %d -> %d\n - Cnt: %d -> %d -> %d\n",
    CallerName(),
    EnterPrio, AccessPrio, LeavePrio,
    EnterCnt, AccessCnt, LeaveCnt);
#endif

  printf("AccessRemoteHw returns to %s\n", CallerName());
  return;
}
コード例 #3
0
ファイル: priinv.c プロジェクト: 0871087123/rtems
void AccessLocalHw(void)
{
  rtems_status_code     Sts;

#if defined(TEST_PRINT_STATISTICS)
  rtems_task_priority   AccessPrio;  /*      :         */
  uint32_t              AccessCnt;   /*      :         */
  rtems_task_priority   EnterPrio;   /* Statistics log */
  uint32_t              EnterCnt;    /*      :         */
  rtems_task_priority   LeavePrio;   /*      :         */
  uint32_t              LeaveCnt;    /*      :         */
#endif

#if defined(TEST_PRINT_STATISTICS)
  /* Store information about the current situation */
  EnterPrio = _Thread_Executing->current_priority;
  EnterCnt  = _Thread_Executing->resource_count;
#endif

  printf("  AccessLocalHw called by %s\n", CallerName());

  /* Obtain exclusive access to local HW, Start HW, Wait for completion,
   * Release access
   */

  Sts = rtems_semaphore_obtain(LocalHwAccess_R, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
  directive_failed( Sts, "rtems_semaphore_obtain(LocalHwAccess_R...)" );

  StartHw = TRUE;

  Sts = rtems_semaphore_obtain(LocalHwSync_S, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
  directive_failed( Sts, "rtems_semaphore_obtain(LocalHwAccess_R...)" );

#if defined(TEST_PRINT_STATISTICS)
  /* Store information about the current situation */
  AccessPrio = _Thread_Executing->current_priority;
  AccessCnt  = _Thread_Executing->resource_count;
#endif

  Sts = rtems_semaphore_release(LocalHwAccess_R);
  directive_failed( Sts, "rtems_semaphore_release(LocalHwAccess_R)" );

#if defined(TEST_PRINT_STATISTICS)
  /* Store information about the current situation */
  LeavePrio = _Thread_Executing->current_priority;
  LeaveCnt  = _Thread_Executing->resource_count;

  printf(
    "  AccessLocalHw from %s statistics:\n"
    " - Prio: %d -> %d -> %d\n - Cnt: %d -> %d -> %d\n",
    CallerName(),
    EnterPrio, AccessPrio, LeavePrio,
    EnterCnt, AccessCnt, LeaveCnt
  );
#endif

  printf("  AccessLocalHw returns to %s\n", CallerName());
  #if defined(TEST_EXIT_AFTER_ITERATIONS)
    if ( ++Iterations == 10 ) {
      puts( "*** END OF TEST 35 ***" );
      exit(0);
    }
  #endif
  return;
}
コード例 #4
0
ファイル: InternalDS.cpp プロジェクト: skhiro/firebird
void InternalStatement::doPrepare(thread_db* tdbb, const string& sql)
{
	m_inMetadata->reset();
	m_outMetadata->reset();

	JAttachment* att = m_intConnection.getJrdAtt();
	JTransaction* tran = getIntTransaction()->getJrdTran();

	FbLocalStatus status;

	if (m_request)
	{
		doClose(tdbb, true);
		fb_assert(!m_allocated);
	}

	{
		EngineCallbackGuard guard(tdbb, *this, FB_FUNCTION);

		CallerName save_caller_name(tran->getHandle()->tra_caller_name);

		if (m_callerPrivileges)
		{
			jrd_req* request = tdbb->getRequest();
			JrdStatement* statement = request ? request->getStatement() : NULL;
			CallerName callerName;
			const Routine* routine;

			if (statement && statement->parentStatement)
				statement = statement->parentStatement;

			if (statement && statement->triggerName.hasData())
				tran->getHandle()->tra_caller_name = CallerName(obj_trigger, statement->triggerName);
			else if (statement && (routine = statement->getRoutine()) &&
				routine->getName().identifier.hasData())
			{
				if (routine->getName().package.isEmpty())
				{
					tran->getHandle()->tra_caller_name = CallerName(routine->getObjectType(),
						routine->getName().identifier);
				}
				else
				{
					tran->getHandle()->tra_caller_name = CallerName(obj_package_header,
						routine->getName().package);
				}
			}
			else
				tran->getHandle()->tra_caller_name = CallerName();
		}

		m_request.assignRefNoIncr(att->prepare(&status, tran, sql.length(), sql.c_str(),
			m_connection.getSqlDialect(), 0));
		m_allocated = (m_request != NULL);

		tran->getHandle()->tra_caller_name = save_caller_name;
	}

	if (status->getState() & IStatus::STATE_ERRORS)
		raise(&status, tdbb, "JAttachment::prepare", &sql);

	const DsqlCompiledStatement* statement = m_request->getHandle()->getStatement();

	if (statement->getSendMsg())
	{
		try
		{
			PreparedStatement::parseDsqlMessage(statement->getSendMsg(), m_inDescs,
				m_inMetadata, m_in_buffer);
			m_inputs = m_inMetadata->getCount();
		}
		catch (const Exception&)
		{
			raise(tdbb->tdbb_status_vector, tdbb, "parse input message", &sql);
		}
	}
	else
		m_inputs = 0;

	if (statement->getReceiveMsg())
	{
		try
		{
			PreparedStatement::parseDsqlMessage(statement->getReceiveMsg(), m_outDescs,
				m_outMetadata, m_out_buffer);
			m_outputs = m_outMetadata->getCount();
		}
		catch (const Exception&)
		{
			raise(tdbb->tdbb_status_vector, tdbb, "parse output message", &sql);
		}
	}
	else
		m_outputs = 0;

	m_stmt_selectable = false;

	switch (statement->getType())
	{
	case DsqlCompiledStatement::TYPE_SELECT:
	case DsqlCompiledStatement::TYPE_SELECT_UPD:
	case DsqlCompiledStatement::TYPE_SELECT_BLOCK:
		m_stmt_selectable = true;
		break;

	case DsqlCompiledStatement::TYPE_START_TRANS:
	case DsqlCompiledStatement::TYPE_COMMIT:
	case DsqlCompiledStatement::TYPE_ROLLBACK:
	case DsqlCompiledStatement::TYPE_COMMIT_RETAIN:
	case DsqlCompiledStatement::TYPE_ROLLBACK_RETAIN:
	case DsqlCompiledStatement::TYPE_CREATE_DB:
		Arg::Gds(isc_eds_expl_tran_ctrl).copyTo(&status);
		raise(&status, tdbb, "JAttachment::prepare", &sql);
		break;

	case DsqlCompiledStatement::TYPE_INSERT:
	case DsqlCompiledStatement::TYPE_DELETE:
	case DsqlCompiledStatement::TYPE_UPDATE:
	case DsqlCompiledStatement::TYPE_UPDATE_CURSOR:
	case DsqlCompiledStatement::TYPE_DELETE_CURSOR:
	case DsqlCompiledStatement::TYPE_DDL:
	case DsqlCompiledStatement::TYPE_EXEC_PROCEDURE:
	case DsqlCompiledStatement::TYPE_SET_GENERATOR:
	case DsqlCompiledStatement::TYPE_SAVEPOINT:
	case DsqlCompiledStatement::TYPE_EXEC_BLOCK:
		break;
	}
}