예제 #1
0
void cTrackManiaHack::NoRestrictions(void)
{
	static CCodeChange NoRes;
	static CCodeChange NoPw;
	BYTE FIX[] = {0xE9, 0x8C, 0x01, 0x00, 0x00, 0x90};
	BYTE FIX2[] = {0xE9, 0x10, 0x02, 0x00, 0x00, 0x90};
	NoRes.Initialize(this, GetAddress("NoRestrictions"), FIX, 6);
	NoPw.Initialize(this, GetAddress("NoTrackPassword"), FIX2, 6);

	if (!NoRes.IsEnabled())
	{
		int iOffset = 0x18C; BYTE *pOffset = (BYTE*)&iOffset;
		ReadAddress(GetAddress("NoRestrictions")+2, &iOffset, 4); iOffset++;
		for (int i = 0; i < 4; i++) FIX[i+1] = pOffset[i]; NoRes.SetNewCode(FIX);

		int iOffset2 = 0x210; BYTE *pOffset2 = (BYTE*)&iOffset2;
		ReadAddress(GetAddress("NoTrackPassword")+2, &iOffset2, 4); iOffset2++;
		for (int i = 0; i < 4; i++) FIX2[i+1] = pOffset2[i]; NoPw.SetNewCode(FIX2);

		NoRes.Enable();
		NoPw.Enable();
		SoundUpdate(SOUND_ON);
	}
	else
	{
		NoRes.Disable();
		NoPw.Disable();
		SoundUpdate(SOUND_OFF);
	}
}
예제 #2
0
void cTrackManiaHack::SaveCurPos(int iIndex)
{
	DWORD dwPos = GetPositionAddress();

	DIRECTION CurDirection;
	ReadAddress(dwPos, &CurDirection, sizeof(DIRECTION));
	m_SavedDirections[iIndex] = CurDirection;

	dwPos += 0x34;

	POSITION CurPos;
	ReadAddress(dwPos, &CurPos, sizeof(CurPos));
	m_SavedPos[iIndex] = CurPos;
}
예제 #3
0
void cTrackManiaHack::CheckpointHack(void)
{
	static CCodeChange CPFix1;
	static CNop CPFix2;

	BYTE FIX1[] = {0xE9, 0x3A, 0x01, 0x00, 0x00, 0x90};

	CPFix1.Initialize(this, GetAddress("CheckpointFix1"), FIX1, 6);
	CPFix2.Initialize(this, GetAddress("CheckpointFix2"), 11);

	if (!CPFix1.IsEnabled())
	{
		/*
		Anschalten
		*/
		int iOffset = 0x13A; BYTE *pOffset = (BYTE*)&iOffset;
		ReadAddress(GetAddress("CheckpointFix1")+2, &iOffset, 4); iOffset++;
		for (int i = 0; i < 4; i++) FIX1[i+1] = pOffset[i]; CPFix1.SetNewCode(FIX1);
		CPFix1.Enable();
		CPFix2.Enable();
		SoundUpdate(SOUND_ON);
	}
	else
	{
		/*
		Ausschalten - Daten wiederherstellen
		*/
		CPFix1.Disable();
		CPFix2.Disable();
		SoundUpdate(SOUND_OFF);
	}
}
예제 #4
0
void EvalDereference( std::stack<TokenEval> &varStack, std::vector<TokenEval> &callStack )
{
    Variable dst;
    dst = varStack.top().v;
    varStack.pop();
    dst = ReadAddress((LPCVOID)dst.AsValue());
    varStack.push(TokenEval(dst, NULL));
}
예제 #5
0
void CTM2Hack::SaveCurPosToSeries(void)
{
	DWORD dwPos = GetPositionAddress();

	POSITION CurPos;
	ReadAddress(dwPos, &CurPos, sizeof(CurPos));
	m_vecAutoPositions.push_back(CurPos);
}
예제 #6
0
void CTM2Hack::SaveCurPos(int iIndex)
{
	DWORD dwPos = GetPositionAddress();

	POSITION CurPos;
	ReadAddress(dwPos, &CurPos, sizeof(CurPos));
	m_SavedPos[iIndex] = CurPos;
}
예제 #7
0
void cTrackManiaHack::CheckVersion(void)
{
	if (!this->m_hGameHandle)
	{
		MessageBox(NULL, "Start Trackmania first to do a version check", "ERROR - Invalid Game Handle", MB_ICONERROR);
		return;
	}
	char gameversion[8];
	DWORD gameVersionAddress = 0;
	ReadAddress(GetAddress("Version"), &gameVersionAddress, sizeof(DWORD));
	ReadAddress(gameVersionAddress, gameversion, sizeof(gameversion));

	char versionInfo[255];
	sprintf_s(versionInfo, sizeof(versionInfo), "Supported Version: %s\nGame Version: %s\n-----------\nIf the version differs you may have luck. The Trainer does pattern scanning so it should find the new (or older) addresses as well", GAMEVERSION, gameversion);

	MessageBox(NULL, versionInfo, "Version Check", NULL);
}
예제 #8
0
int cTrackManiaHack::GetBoostDuration(void)
{
	DWORD dwOffsetsSpeed[] = {0x4, 0x64, 0x18, m_dwModeOffset, 0xF8};
	int iBoostDuration = 250;
	DWORD dwBoostOptionAddress = ReadPointer(GetAddress("GroundNumBase"), dwOffsetsSpeed, sizeof(dwOffsetsSpeed));
	if (dwBoostOptionAddress) ReadAddress(dwBoostOptionAddress, &iBoostDuration, sizeof(iBoostDuration));
	return iBoostDuration;
}
예제 #9
0
float cTrackManiaHack::GetBoostMulti(void)
{
	DWORD dwOffsetsSpeed[] = {0x4, 0x64, 0x18, m_dwModeOffset, 0xF0};
	float fBoostMulti = 5;
	DWORD dwBoostOptionAddress = ReadPointer(GetAddress("GroundNumBase"), dwOffsetsSpeed, sizeof(dwOffsetsSpeed));
	if (dwBoostOptionAddress) ReadAddress(dwBoostOptionAddress, &fBoostMulti, sizeof(fBoostMulti));
	return fBoostMulti;
}
예제 #10
0
void cTrackManiaHack::SaveCurPosToSeries()
{
	DWORD dwPos = GetPositionAddress();
	dwPos += 0x34;
	POSITION CurPos;
	ReadAddress(dwPos, &CurPos, sizeof(CurPos));
	m_vecAutoPositions.push_back(CurPos);
}
예제 #11
0
void CTM2Hack::DoCarJump(int iHeight)
{
	DWORD dwZPos = GetPositionAddress() + 0x4;

	float fPos = 0;
	ReadAddress(dwZPos, &fPos, sizeof(fPos));
	fPos += iHeight;
	WriteAddress(dwZPos, &fPos, sizeof(fPos));
}
예제 #12
0
void CTM2Hack::CheckVersion(void)
{
	char gameversion[50];
	DWORD gameVersionAddress = GetAddress("Version");
	//ReadAddress(GetAddress("Version"), &gameVersionAddress, sizeof(DWORD));
	ReadAddress(gameVersionAddress, gameversion, sizeof(gameversion));

	char versionInfo[512];
	sprintf_s(versionInfo, sizeof(versionInfo), "Supported Version:\t%s\nGame Version:\t%s\n-----------\nIf the version differs you may have luck. The Trainer does pattern scanning so it should find the new (or older) addresses as well", GAMEVERSION, gameversion);

	MessageBox(NULL, versionInfo, "Version Check", NULL);
}
예제 #13
0
// Read Operation
int CFanmotorDlg::rreg(int reg_addr)
{
success=1;

	CString s;
	int dat=0;
	long r;
	int timeout_counter=0;
	CByteArray baAddr;
	baAddr.SetSize (1);   
	baAddr.SetAt(0,reg_addr); 
	COleVariant ReadAddress(baAddr); // Create ReadAddress argument
	VARIANT dataIn;
	VariantInit(&dataIn);
	int datalen=2;//in bytes

	if(this->virtual_board)
	{
		dat = ReadVirtualBoardReg(reg_addr, fOTP);
	}

	else
	{
		r = Bridge->ReadIICdataReg(L"0000011", 0x49, ReadAddress,datalen, &dataIn); 
		//r = Bridge->ReadIICdataReg(L"0000011", reg_addr, ReadAddress,datalen, &dataIn); 
		//Sleep(500);
		//r = Bridge->ReadIICdataReg(L"0000011", 0x49, ReadAddress,datalen, &dataIn);//no data received.????
		//do{
		//	timeout_counter++;
		//	if (timeout_counter == TIMEOUT){
		//		DisplayInforMessageBox((LPCWSTR)L"Error", (LPCWSTR)L"Device is not available.\nPlease check your hardware connection and power supply!");
		//		success = 0;
		//	}
		//	r = Bridge->ReadIICdataReg(L"0000011", 0x49, ReadAddress,datalen, &dataIn); 
		//}while ((r !=34) && (timeout_counter != TIMEOUT));

			CString strByte;
			for (long i = 0; i < datalen; i++) {
				BYTE ReadByte;
				SafeArrayGetElement(dataIn.parray, &i, &ReadByte);
				strByte.Format(L"%02x",ReadByte);
				s += strByte;
			}
			dat=use_debugdlg_main.string2int(s,2*datalen);
		//	success=1;
		//}
		//else {ErrorMsg(r);};
		VariantClear(&dataIn);
	}
	return dat;
	Sleep(20);
}
예제 #14
0
int CFanmotorDlg::rFWData(int fType, int nByte)
{
	success=1;
	CString s;
	int dat=0;
	int timeout_counter=0;
	long r;
	CByteArray baAddr;
	baAddr.SetSize (1);   
	baAddr.SetAt(0,fType); 
	COleVariant ReadAddress(baAddr); // Create ReadAddress argument
	VARIANT dataIn;
	VariantInit(&dataIn);

	///*Sleep(50);*/
	//long r = Bridge->ReadIICdataReg(L"0000011", 0x49, ReadAddress, 
 //                                  1, &dataIn);  
	do{
		timeout_counter++;
		if (timeout_counter == TIMEOUT){
			DisplayInforMessageBox((LPCWSTR)L"Error", (LPCWSTR)L"Device is not available.\nPlease check your hardware connection and power supply!");
			success = 0;
		}
		r = Bridge->ReadIICdataReg(L"0000011", 0x49, ReadAddress,nByte, &dataIn); 
	}while ((r !=34) && (timeout_counter != TIMEOUT));
	//{
		CString strByte;
		for (long i = 0; i < nByte; i++) {
			BYTE ReadByte;
			SafeArrayGetElement(dataIn.parray, &i, &ReadByte);
			strByte.Format(L"%02x",ReadByte);
			s += strByte;
		}
		dat=use_debugdlg_main.string2int(s,2*nByte);
		success=1;
	//}
	//else {ErrorMsg(r);};
	VariantClear(&dataIn);
	return dat;	
}
예제 #15
0
파일: HP03S.c 프로젝트: diabay/Raspberry-Pi
void main(int argc, char* argv[]) {
	const int SlaveAddr   = 0x77;
	const int cnConstants = 11;
	const int cnMaxLine   = 10;
	int fd;
	char device[20];
	int D1,D2;
	int nParameters[cnConstants];

	if (argc >=2 ) {
		FILE* file;
		const char* szFilename=NULL;
		const int cnMaxLine = 10;
		char szBuffer[cnMaxLine+1];
		
		szFilename = argv[1];	
		if (szFilename) {
			file = fopen(szFilename, "rb");
		}
		if (file) {
			int nParamCnt;
			for (nParamCnt=0; nParamCnt<cnConstants; nParamCnt++) {
				if (!fgets(szBuffer, cnMaxLine, file)) {
					fprintf(stderr,
					"Error reading line %d from file '%s'\n", nParamCnt+1, szFilename);
					exit(1);
				}		
				if (sscanf(szBuffer, "%X", &nParameters[nParamCnt]) !=1 ) {
					fprintf(stderr,
					"Error scanning line %d from file '%s'\n", nParamCnt+1, szFilename);
					exit(1);
				}
			}
			fclose(file);
		}
		else{
			fprintf(stderr, "Can't open file '%s' for reading\n", szFilename);
			exit(1);
		}
		
	}
	else{
		fprintf(stderr, "Constant file parameter missing\n");
		exit(1);	
	}

	sprintf(device, "/dev/i2c-1");
	if ((fd = open(device, O_RDWR)) < 0) {
		fprintf(stderr,"Failed to open i2c bus '%s'\n",device);
        exit(1);
    }
    if (ioctl(fd, I2C_SLAVE, SlaveAddr) < 0) {
		fprintf(stderr,
		"Failed to acquire i2c bus access or talk to slave %X\n", SlaveAddr);
		close(fd);
		exit(1);
	}
	
	D1 = ReadAddress(fd, 0xF0, "Pressure");
	D2 = ReadAddress(fd, 0xE8, "Temperature");
	usleep(50000); //drop first reading
	D1 = ReadAddress(fd, 0xF0, "Pressure");
	D2 = ReadAddress(fd, 0xE8, "Temperature");	
	close(fd);
	if (D1 != 0 && D2 != 0) {
		int C1, C2, C3, C4, C5, C6, C7, A, B, C, D;
		int dUT, OFF, SENS, X, P, T;

		C1 = nParameters[0];
		C2 = nParameters[1];
		C3 = nParameters[2];
		C4 = nParameters[3];
		C5 = nParameters[4];
		C6 = nParameters[5];
		C7 = nParameters[6];
		A  = nParameters[7];
		B  = nParameters[8];
		C  = nParameters[9];
		D  = nParameters[10];

		if (D2 >= C5) {
			dUT = D2 - C5 - ((D2 - C5) / 128) * ((D2 - C5) / 128) * A / (2 << C);
		} else {
			dUT = D2 - C5 - ((D2 - C5) / 128) * ((D2 - C5) / 128) * B / (2 << C);
		}
		OFF = (C2 + (C4 - 1024) * dUT / 16384) * 4;
		SENS = C1 + C3 * dUT / 1024;
		X = SENS * (D1 - 7168) / 16384 - OFF;
		P = X * 10 / 32 + C7;
		T = 250 + dUT * C6 / 65536 - dUT / (2 << D);
		
		printf("Pressure=%.1f hPa\tTemperature=%.1f C\n", P / 10.0f, T / 10.0f);
		exit(0);
	} else {
		fprintf(stderr, 
		"ADC read error (i2c bus ok?, XCLR high?, MCLK=32kHz?\n");
		exit(1);	
	}
}
예제 #16
0
파일: Drive.cpp 프로젝트: frodete/simcoupe
void CDrive::ExecuteNext ()
{
    BYTE bStatus = m_sRegs.bStatus;

    // Nothing to do if there's no disk in the drive
    if (!m_pDisk)
        return;

    // Continue processing the background
    if (m_pDisk->IsBusy(&bStatus))
    {
        // Keep the drive motor on as we're busy
        ModifyStatus(MOTOR_ON, 0);
        return;
    }

    // Some commands require additional handling
    switch (m_sRegs.bCommand & FDC_COMMAND_MASK)
    {
        case READ_1SECTOR:
        case READ_MSECTOR:
        {
            IDFIELD id;

            if (!FindSector(&id))
                ModifyStatus(RECORD_NOT_FOUND, BUSY);
            else
            {
                // Read the data, reporting anything but CRC errors now, as we can't check the CRC until we reach it at the end of the data on the disk
                m_bDataStatus = ReadSector(m_pbBuffer = m_abBuffer, &m_uBuffer);
                ModifyReadStatus();

                // Just for fun ;-)
                if (m_sRegs.bTrack == 4 && m_sRegs.bSector == 1 && m_abBuffer[0x016] == 0xC3 && CrcBlock(m_abBuffer, m_uBuffer) == 0x6c54)
                    m_abBuffer[0x016] -= 0x37;
            }
            break;
        }

        case WRITE_1SECTOR:
        case WRITE_MSECTOR:
        {
            if (m_nState == 0)
            {
                IDFIELD id;

                // Locate the sector, reset busy and signal record not found if we couldn't find it
                if (!FindSector(&id))
                    ModifyStatus(RECORD_NOT_FOUND, BUSY);
                else if (m_pDisk->IsReadOnly())
                    ModifyStatus(WRITE_PROTECT, BUSY);
                else
                {
                    // Prepare data pointer to receive data, and the amount we're expecting
                    m_pbBuffer = m_abBuffer;
                    m_uBuffer = 128U << (id.bSize & 3);

                    // Signal that data is now requested for writing
                    ModifyStatus(DRQ, 0);
                    m_nState++;
                }
            }
            else
            {
                // Write complete, so set its status and clear busy
                ModifyStatus(bStatus, BUSY);
            }

            break;
        }

        case READ_ADDRESS:
        {
            // Read an ID field into our general buffer
            IDFIELD* pId = reinterpret_cast<IDFIELD*>(m_pbBuffer = m_abBuffer);
            BYTE bReadStatus = ReadAddress(pId);

            // If successful set up the number of bytes available to read
            if (!(bReadStatus & TYPE23_ERROR_MASK))
            {
                m_sRegs.bSector = pId->bTrack;

                m_uBuffer = sizeof(IDFIELD);
                ModifyStatus(bStatus|DRQ, 0);   // Don't clear BUSY yet!
            }

            // Set the error status, resetting BUSY so the client sees the error
            else
            {
                ModifyStatus(bStatus, BUSY);
                m_uBuffer = 0;
            }

            break;
        }

        case READ_TRACK:
        {
            // Prepare a semi-convincing raw track
            ReadTrack(m_pbBuffer = m_abBuffer, m_uBuffer = sizeof(m_abBuffer));
            ModifyStatus(DRQ, 0);
            break;
        }

        case WRITE_TRACK:
        {
            ModifyStatus(bStatus, BUSY);
            break;
        }
    }
}