示例#1
0
bool signalOtherInstance()
{
	const char *fname = getPIDFile().c_str();
	pid_t pid = readPID( fname );
	std::cout << "read pid: " << pid << std::endl;
	return ( pid > 0 && kill(pid, SIGUSR1) == 0 );
}
示例#2
0
int _tmain(int argc, _TCHAR* argv[])
{
	TCHAR dllPath[MAX_PATH];

	DWORD length = GetCurrentDirectory(MAX_PATH, dllPath);
	dllPath[length++] = '\\';
	dllPath[length++] = '\0';
	_tcscat_s(dllPath, MAX_PATH - length, _T("Injection.Dummy.dll"));

	printf("PID: ");
	int processID = readPID();

	if (processID == 0)
	{
		return 0;
	}

	HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processID);

	if (!hProcess)
	{
		return 0;
	}

	LPVOID memoryAddress = VirtualAllocEx(hProcess, 0, sizeof(dllPath), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);

	if (!memoryAddress)
	{
		return 0;
	}

	SIZE_T writen = 0;
	if (WriteProcessMemory(hProcess, memoryAddress, dllPath, sizeof(dllPath), &writen) == FALSE)
	{
		return 0;
	}

	HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
	FARPROC loadLibraryW = GetProcAddress(kernel32, "LoadLibraryW");

	DWORD threadID = 0;
	HANDLE hTread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)loadLibraryW, memoryAddress, 0, &threadID);
	if (!hTread)
	{
		// check same architecture type
		DWORD errorCode = GetLastError();
		return 0;
	}

	return 0;
}
示例#3
0
void readEEPROM() {
  readPID(XAXIS, ROLL_PID_GAIN_ADR);
  readPID(YAXIS, PITCH_PID_GAIN_ADR);
  readPID(ZAXIS, YAW_PID_GAIN_ADR);
  readPID(ATTITUDE_XAXIS_PID_IDX, LEVELROLL_PID_GAIN_ADR);
  readPID(ATTITUDE_YAXIS_PID_IDX, LEVELPITCH_PID_GAIN_ADR);
  readPID(HEADING_HOLD_PID_IDX, HEADING_PID_GAIN_ADR);
  readPID(ATTITUDE_GYRO_XAXIS_PID_IDX, LEVEL_GYRO_ROLL_PID_GAIN_ADR);
  readPID(ATTITUDE_GYRO_YAXIS_PID_IDX, LEVEL_GYRO_PITCH_PID_GAIN_ADR);

  rotationSpeedFactor = readFloat(ROTATION_SPEED_FACTOR_ARD);
  
  // Leaving separate PID reads as commented for now
  // Previously had issue where EEPROM was not reading right data
  #if defined AltitudeHoldBaro || defined AltitudeHoldRangeFinder
    readPID(BARO_ALTITUDE_HOLD_PID_IDX, ALTITUDE_PID_GAIN_ADR);
    PID[BARO_ALTITUDE_HOLD_PID_IDX].windupGuard = readFloat(ALTITUDE_WINDUP_ADR);
    #if defined AltitudeHoldBaro
      baroSmoothFactor = readFloat(ALTITUDE_SMOOTH_ADR);
    #endif  
    altitudeHoldBump = readFloat(ALTITUDE_BUMP_ADR);
    altitudeHoldPanicStickMovement = readFloat(ALTITUDE_PANIC_ADR);
    minThrottleAdjust = readFloat(ALTITUDE_MIN_THROTTLE_ADR);
    maxThrottleAdjust = readFloat(ALTITUDE_MAX_THROTTLE_ADR);
    readPID(ZDAMPENING_PID_IDX, ZDAMP_PID_GAIN_ADR);
  #endif

  // Mag calibration
  #ifdef HeadingMagHold
    magBias[XAXIS]  = readFloat(XAXIS_MAG_BIAS_ADR);
    magBias[YAXIS]  = readFloat(YAXIS_MAG_BIAS_ADR);
    magBias[ZAXIS]  = readFloat(ZAXIS_MAG_BIAS_ADR);
  #endif
  
  // Battery Monitor
  #ifdef BattMonitor
    batteryMonitorAlarmVoltage = readFloat(BATT_ALARM_VOLTAGE_ADR);
    batteryMonitorThrottleTarget = readFloat(BATT_THROTTLE_TARGET_ADR);
    batteryMonitorGoingDownTime = readFloat(BATT_DOWN_TIME_ADR);
  #endif
  
  windupGuard = readFloat(WINDUPGUARD_ADR);
  // AKA - added so that each PID has its own windupGuard, will need to be removed once each PID's range is established and put in the EEPROM
	byte i;
  for (i = XAXIS; i < LAST_PID_IDX; i++ ) {
    #if defined AltitudeHoldBaro
      if (i != BARO_ALTITUDE_HOLD_PID_IDX) {
        PID[i].windupGuard = windupGuard;
      }
    #else
      PID[i].windupGuard = windupGuard;
    #endif      
  }
    
  minArmedThrottle = readFloat(MINARMEDTHROTTLE_ADR);
  aref = readFloat(AREF_ADR);
  flightMode = readFloat(FLIGHTMODE_ADR);
  accelOneG = readFloat(ACCEL_1G_ADR);
  headingHoldConfig = readFloat(HEADINGHOLD_ADR);

  #if defined (UseGPSNavigator)
    missionNbPoint = readFloat(GPS_MISSION_NB_POINT_ADR);
    readPID(GPSROLL_PID_IDX, GPSROLL_PID_GAIN_ADR);
    readPID(GPSPITCH_PID_IDX, GPSPITCH_PID_GAIN_ADR);
    readPID(GPSYAW_PID_IDX, GPSYAW_PID_GAIN_ADR);
    
    for (byte location = 0; location < MAX_WAYPOINTS; location++) {
      waypoint[location].longitude = readLong(WAYPOINT_ADR[location].longitude);
      waypoint[location].latitude = readLong(WAYPOINT_ADR[location].latitude);
      waypoint[location].altitude = readLong(WAYPOINT_ADR[location].altitude);
    }    
  #endif

  // Camera Control
  #ifdef CameraControl
    cameraMode = readFloat(CAMERAMODE_ADR);
    mCameraPitch = readFloat(MCAMERAPITCH_ADR);
    mCameraRoll = readFloat(MCAMERAROLL_ADR);    
    mCameraYaw = readFloat(MCAMERAYAW_ADR);
    servoCenterPitch = readFloat(SERVOCENTERPITCH_ADR);
    servoCenterRoll = readFloat(SERVOCENTERROLL_ADR);
    servoCenterYaw = readFloat(SERVOCENTERYAW_ADR);
    servoMinPitch = readFloat(SERVOMINPITCH_ADR);
    servoMinRoll = readFloat(SERVOMINROLL_ADR);
    servoMinYaw = readFloat(SERVOMINYAW_ADR);
    servoMaxPitch = readFloat(SERVOMAXPITCH_ADR);
    servoMaxRoll = readFloat(SERVOMAXROLL_ADR);
    servoMaxYaw = readFloat(SERVOMAXYAW_ADR);
    #ifdef CameraTXControl
      servoTXChannels = readFloat(SERVOTXCHANNELS_ADR);
      servoActualCenter = readFloat(SERVOCENTERPITCH_ADR);
    #endif
  #endif   
}