所以我试图为游戏改名。表示gamertag的偏移量为0x838BA824;我试图制作一个循环,它改变了名字的颜色,就像彩虹一样。因此,当我启用" rainbow" -gamertag时,我会这样做:
LastName = (char*)0x838BA824;//char *LastName;
Rainbow = !Rainbow;//a boolean used to toggle
然后在钩子/循环中我这样做:
if(Rainbow)//the toggle boolean
{
printf("LastName: %s\n", LastName);
peep++;//int peep;
if(peep >= 8)
peep = 0;
switch(peep)
{
case 0:
printf("0\n");
Buffer += "^0";//std::string buffer || ^0-9 are the colorcodes for that game, so here it adds the color
Buffer += LastName;//then it adds the name
printf("Buffer: %s\n", Buffer.c_str());
strcpy((char*)0x838BA824, Buffer.c_str());//then it sets the string with the color
Buffer = "";//it clears the Buffer
printf("Buffer: %s\n", Buffer.c_str());
break;
case 1:
printf("1\n");
Buffer += "^1";
Buffer += LastName;
printf("Buffer: %s\n", Buffer.c_str());
strcpy((char*)0x838BA824, Buffer.c_str());
Buffer = "";
printf("Buffer: %s\n", Buffer.c_str());
break;
case 2:
printf("2\n");
Buffer += "^2";
Buffer += LastName;
printf("Buffer: %s\n", Buffer.c_str());
strcpy((char*)0x838BA824, Buffer.c_str());
Buffer = "";
printf("Buffer: %s\n", Buffer.c_str());
break;
case 3:
printf("3\n");
Buffer += "^3";
Buffer += LastName;
printf("Buffer: %s\n", Buffer.c_str());
strcpy((char*)0x838BA824, Buffer.c_str());
Buffer = "";
printf("Buffer: %s\n", Buffer.c_str());
break;
case 4:
printf("4\n");
Buffer += "^4";
Buffer += LastName;
printf("Buffer: %s\n", Buffer.c_str());
strcpy((char*)0x838BA824, Buffer.c_str());
Buffer = "";
printf("Buffer: %s\n", Buffer.c_str());
break;
case 5:
printf("5\n");
Buffer += "^5";
Buffer += LastName;
printf("Buffer: %s\n", Buffer.c_str());
strcpy((char*)0x838BA824, Buffer.c_str());
Buffer = "";
printf("Buffer: %s\n", Buffer.c_str());
break;
case 6:
printf("6\n");
Buffer += "^6";
Buffer += LastName;
printf("Buffer: %s\n", Buffer.c_str());
strcpy((char*)0x838BA824, Buffer.c_str());
Buffer = "";
printf("Buffer: %s\n", Buffer.c_str());
break;
case 7:
printf("7\n");
Buffer += "^7";
Buffer += LastName;
printf("Buffer: %s\n", Buffer.c_str());
strcpy((char*)0x838BA824, Buffer.c_str());
Buffer = "";
printf("Buffer: %s\n", Buffer.c_str());
break;
}
}
编辑:我也可以在钩子中调用它(结果相同 - .-)
void changeName()
{
printf("LastName: %s\n", LastName);
peep++;
if(peep >= 8)
peep = 0;
printf("%i\n", peep);
Buffer += va("^%i", peep);
Buffer += LastName;
printf("Buffer: %s\n", Buffer.c_str());
strcpy((char*)0x838BA824, Buffer.c_str());
Buffer = "";
printf("Buffer: %s\n", Buffer.c_str());
}
直到现在一切似乎对我都没问题,所以我对它进行了测试,并在控制台中将其作为输出:
LastName: Test
1
Buffer: ^1Test
Buffer:
LastName: ^1Test
2
Buffer: ^2^1Test
Buffer:
LastName: ^2^1Test
3
Buffer: ^3^2^1Test
Buffer:
LastName: ^3^2^1Test
4
Buffer: ^4^3^2^1Test
Buffer:
LastName: ^4^3^2^1Test
5
Buffer: ^5^4^3^2^1Test
Buffer:
LastName: ^5^4^3^2^1Test
6
Buffer: ^6^5^4^3^2^1Test
Buffer:
LastName: ^6^5^4^3^2^1Test
7
Buffer: ^7^6^5^4^3^2^1Test
Buffer:
LastName: ^7^6^5^4^3^2^1Test
0
Buffer: ^0^7^6^5^4^3^2^1Test
Buffer:
LastName: ^0^7^6^5^4^3^2^1Test
1
Buffer: ^1^0^7^6^5^4^3^2^1Test
Buffer:
LastName: ^1^0^7^6^5^4^3^2^1Test
2
Buffer: ^2^1^0^7^6^5^4^3^2^1Test
Buffer:
LastName: ^2^1^0^7^6^5^4^3^2^1Test
3
Buffer: ^3^2^1^0^7^6^5^4^3^2^1Test
Buffer:
LastName: ^3^2^1^0^7^6^5^4^3^2^1Test
4
Buffer: ^4^3^2^1^0^7^6^5^4^3^2^1Test
Buffer:
LastName: ^4^3^2^1^0^7^6^5^4^3^2^1Test
5
Buffer: ^5^4^3^2^1^0^7^6^5^4^3^2^1Test
Buffer:
LastName: ^5^4^3^2^1^0^7^6^5^4^3^2^1Test
6
Buffer: ^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
Buffer:
LastName: ^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
7
Buffer: ^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
Buffer:
LastName: ^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
0
Buffer: ^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
Buffer:
LastName: ^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
1
Buffer: ^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
Buffer:
LastName: ^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
2
Buffer: ^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
Buffer:
LastName: ^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
3
Buffer: ^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
Buffer:
LastName: ^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
4
Buffer: ^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
Buffer:
LastName: ^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
5
Buffer: ^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
Buffer:
LastName: ^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
6
Buffer: ^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
Buffer:
LastName: ^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
7
Buffer: ^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1Test
Buffer:
Last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^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5
5
Buffer: ^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5
Buffer:
LastName: ^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5
6
Buffer: ^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5
Buffer:
LastName: ^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5
7
Buffer: ^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5^4^3^2^1^0^7^6^5
Buffer:
任何人都知道为什么它不能正确清除缓冲区(或者为什么它也将lastname设置到缓冲区)或者为什么会这样? 通常输出应该如下所示,如果正确的话:
LastName: Test
1
Buffer: ^1Test
Buffer:
LastName: Test
2
Buffer: ^2Test
Buffer:
LastName: Test
3
Buffer: ^3Test
Buffer:
LastName: Test
4
Buffer: ^4Test
Buffer:
LastName: Test
5
Buffer: ^5Test
Buffer:
LastName: Test
6
Buffer: ^6Test
Buffer:
LastName: Test
7
Buffer: ^7Test
Buffer:
LastName: Test
答案 0 :(得分:2)
正如我在评论中提到的,看起来你在进入函数之前初始化char* LastName = (char*)0x838BA824;
。
然后你改变0x838BA824
strcpy((char*)0x838BA824, Buffer.c_str());
下一次,当您初始化char* LastName = (char*)0x838BA824;
时,您会收到您第一次进行的更改。
每次重复此操作,您都会获取之前运行的更改。
修复方法是首先剥离控制字符。
if(Rainbow)
{
printf("LastName: %s\n", LastName);
// clear off the previous control characters if they are there
if (LastName[0] == '^' && std::isdigit(LastName[1]))
LastName = LastName.substr(2)
if(++peep >= 8)
peep = 0;
printf("%d\n", peep);
Buffer = "^";
Buffer += std::to_string(peep);
Buffer += LastName;
printf("Buffer: %s\n", Buffer.c_str());
strcpy((char*)0x838BA824, Buffer.c_str());
}
答案 1 :(得分:2)
LastName是一个指向0x838BA824的指针,这是你用strcpy写的地址。
每当您更新gamertag时,您都会从LastName重新读取该名称,这样您就可以在最后一次迭代中找回您所添加的内容。
我可以通过两种方式来纠正这个问题:
1)首次启用时将std :: string初始化为LastName,然后不再重新读取LastName
char *LastNamePtr = (char*)0x838BA824;
std::string LastNameString(LastNamePtr);
Rainbow = true;
// ...
if (Rainbow) {
peep = (peep + 1) & 7;
std::string Buffer = "^" + std::to_string(peep) + LastNameString;
strcpy(LastNamePtr, Buffer.c_str());
}
或2)检测' ^'重新读取字符串时的字符,如果是,请更改数字而不是添加' ^'和号码
char *LastNamePtr = (char*)0x838BA824;
Rainbow = true;
// ...
if (Rainbow) {
peep = (peep + 1) & 7;
if (LastNamePtr[0] == '^') { // check first character of string
LastNamePtr[1] = peep + '0'; // update second character of string
} else {
std::string Buffer = "^" + std::to_string(peep) + std::string(LastNamePtr);
strcpy(LastNamePtr, Buffer.c_str());
}
}
在任何一种情况下都注意peep = (peep + 1) & 7
是一种更简洁的写作方式
peep++;
if (peep >= 8)
peep = 0;
我已使用std::to_string
和peep + '0'
从int获取数字而不使用切换。