C + +如何转UTF8??
时间:2010-09-02
来源:互联网
此程序是朋友给的可我输入中文显示出来会变成乱码应该是没有转码导致有高手能指点一下帮忙修改此程序吗
转换为UTF8 写入内存
#include <windows.h>
#include <psapi.h>
#include <iostream>
#include <Tlhelp32.h>
#include <fstream>
using namespace std;
// Debug Priviledges.
void EnableDebugPriv( )
{HANDLE hToken;
LUID sedebugnameValue;
TOKEN_PRIVILEGES tkp;
OpenProcessToken( GetCurrentProcess( ), TOKEN_ADJUST_PRIVILEGES |TOKEN_QUERY, &hToken );
LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &sedebugnameValue );
tkp.PrivilegeCount = 1;tkp.Privileges[0].Luid = sedebugnameValue;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges( hToken, false, &tkp, sizeof( tkp ), NULL, NULL );
CloseHandle( hToken );
}
int main()
{
SetConsoleTitle("test."
;
cout <<" ||||||||||||||||||||||||||||||||||||||||||||||||||||\n";
cout <<" ~GayPimp's ";
cout <<"N";
cout <<"a";
cout <<"m";
cout <<"e";
cout <<"s";
cout <<"p";
cout <<"o";
cout <<"o";
cout <<"f";
cout <<"e";
cout <<"r";
cout <<" for 1.22.0.6328~\n";
cout <<" ||||||||||||||||||||||||||||||||||||||||||||||||||||\n" << endl;
cout <<" Do NOT use this program before playing a Battle.net Ladder game." << endl << endl;
cout <<" Yellow: |CFFFFFF00 ";
cout <<"NinjaTurtleGreen: |CFF008000" << endl;
cout <<" Pale Blue: |CFF008080 ";
cout <<"Wine Red: |CFF800000" << endl;
cout <<" Purple: |CFF800080 ";
cout <<"Mustard: |CFF808000" << endl;
cout <<" Pale Grey: |CFFC0C0C0 ";
cout <<"Grey: |CFF808080" << endl;
cout <<" Blue: |CFF0000FF ";
cout <<"Green: |CFF00FF00" << endl;
cout <<" Cyan: |CFF00FFFF ";
cout <<"Red: |CFFFF0000" << endl;
cout <<" Pink: |CFFFF0000 ";
cout <<"White: |CFFFFFFFF" << endl;
cout <<" Teal: |CFF000080 ";
cout <<"Black: |CFF000000 " << endl <<endl;
cout <<"Detecting Battle.net lobby... " << endl <<endl;
EnableDebugPriv();
TCHAR War3Name[32] = TEXT("Warcraft III"
;
HWND hWar3 = FindWindow(War3Name, NULL);
if(!hWar3)
{
cout << "Detect less than your side of the implementation of Program, please re-open your Program" << endl;
system( "pause" );
return 1;
}
DWORD pid;
GetWindowThreadProcessId( hWar3, &pid );
HANDLE hOpen = OpenProcess( PROCESS_ALL_ACCESS, false, pid );
if( !hOpen )
{
cout << "Can't open Warcraft III process." << endl;system( "pause" );
return 1;
}
// Finding the name's address.
DWORD Address = 764;
DWORD Buffer = 0;
DWORD WINAPI GetLastError(void);
SIZE_T BytesRead = 0;
for (;
{
ReadProcessMemory(hOpen, (LPCVOID)Address, &Buffer, 4, &BytesRead);
if(Buffer == 1463898675)
{
// ROC (3RAW).
Address -= 32;
break;
}
else if
(Buffer == 1462982736)
{
// TFT (PX3W).
Address-= 32;
break;
}
else
{
Address += 65536;
}
}
// Couting out name.
while(1)
{
char Name[16];
Name[15] = 0;
DWORD Address2 = 111665304;
for( unsigned int i = 0; i < 15; i++ )
{
ReadProcessMemory( hOpen, (LPVOID)( Address2 + i), &Buffer, 1, &BytesRead );
Name = Buffer;
}
//CloseHandle( hOpen );
cout << "Your current name is: ";
cout << Name << endl << endl;
cout << "
lease type in a new name and press enter." << endl << endl;
// Changing the name.
SIZE_T BytesWritten = 0;
char NewName[16];
memset(NewName, 0, 16 );
cin.getline (NewName,16);
for( unsigned int j = 0; j < 15; j++ )
{
WriteProcessMemory( hOpen, (LPVOID)(Address + j), (LPCVOID)(NewName+ j), 1, &BytesWritten );
}
cout << "\n";
cout << "Your new name is: ";
cout << NewName << endl << endl;
}
}
转换为UTF8 写入内存
#include <windows.h>
#include <psapi.h>
#include <iostream>
#include <Tlhelp32.h>
#include <fstream>
using namespace std;
// Debug Priviledges.
void EnableDebugPriv( )
{HANDLE hToken;
LUID sedebugnameValue;
TOKEN_PRIVILEGES tkp;
OpenProcessToken( GetCurrentProcess( ), TOKEN_ADJUST_PRIVILEGES |TOKEN_QUERY, &hToken );
LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &sedebugnameValue );
tkp.PrivilegeCount = 1;tkp.Privileges[0].Luid = sedebugnameValue;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges( hToken, false, &tkp, sizeof( tkp ), NULL, NULL );
CloseHandle( hToken );
}
int main()
{
SetConsoleTitle("test."

cout <<" ||||||||||||||||||||||||||||||||||||||||||||||||||||\n";
cout <<" ~GayPimp's ";
cout <<"N";
cout <<"a";
cout <<"m";
cout <<"e";
cout <<"s";
cout <<"p";
cout <<"o";
cout <<"o";
cout <<"f";
cout <<"e";
cout <<"r";
cout <<" for 1.22.0.6328~\n";
cout <<" ||||||||||||||||||||||||||||||||||||||||||||||||||||\n" << endl;
cout <<" Do NOT use this program before playing a Battle.net Ladder game." << endl << endl;
cout <<" Yellow: |CFFFFFF00 ";
cout <<"NinjaTurtleGreen: |CFF008000" << endl;
cout <<" Pale Blue: |CFF008080 ";
cout <<"Wine Red: |CFF800000" << endl;
cout <<" Purple: |CFF800080 ";
cout <<"Mustard: |CFF808000" << endl;
cout <<" Pale Grey: |CFFC0C0C0 ";
cout <<"Grey: |CFF808080" << endl;
cout <<" Blue: |CFF0000FF ";
cout <<"Green: |CFF00FF00" << endl;
cout <<" Cyan: |CFF00FFFF ";
cout <<"Red: |CFFFF0000" << endl;
cout <<" Pink: |CFFFF0000 ";
cout <<"White: |CFFFFFFFF" << endl;
cout <<" Teal: |CFF000080 ";
cout <<"Black: |CFF000000 " << endl <<endl;
cout <<"Detecting Battle.net lobby... " << endl <<endl;
EnableDebugPriv();
TCHAR War3Name[32] = TEXT("Warcraft III"

HWND hWar3 = FindWindow(War3Name, NULL);
if(!hWar3)
{
cout << "Detect less than your side of the implementation of Program, please re-open your Program" << endl;
system( "pause" );
return 1;
}
DWORD pid;
GetWindowThreadProcessId( hWar3, &pid );
HANDLE hOpen = OpenProcess( PROCESS_ALL_ACCESS, false, pid );
if( !hOpen )
{
cout << "Can't open Warcraft III process." << endl;system( "pause" );
return 1;
}
// Finding the name's address.
DWORD Address = 764;
DWORD Buffer = 0;
DWORD WINAPI GetLastError(void);
SIZE_T BytesRead = 0;
for (;

{
ReadProcessMemory(hOpen, (LPCVOID)Address, &Buffer, 4, &BytesRead);
if(Buffer == 1463898675)
{
// ROC (3RAW).
Address -= 32;
break;
}
else if
(Buffer == 1462982736)
{
// TFT (PX3W).
Address-= 32;
break;
}
else
{
Address += 65536;
}
}
// Couting out name.
while(1)
{
char Name[16];
Name[15] = 0;
DWORD Address2 = 111665304;
for( unsigned int i = 0; i < 15; i++ )
{
ReadProcessMemory( hOpen, (LPVOID)( Address2 + i), &Buffer, 1, &BytesRead );
Name = Buffer;
}
//CloseHandle( hOpen );
cout << "Your current name is: ";
cout << Name << endl << endl;
cout << "

// Changing the name.
SIZE_T BytesWritten = 0;
char NewName[16];
memset(NewName, 0, 16 );
cin.getline (NewName,16);
for( unsigned int j = 0; j < 15; j++ )
{
WriteProcessMemory( hOpen, (LPVOID)(Address + j), (LPCVOID)(NewName+ j), 1, &BytesWritten );
}
cout << "\n";
cout << "Your new name is: ";
cout << NewName << endl << endl;
}
}
作者: nokina789 发布时间: 2010-09-02
楼主这是windows下的程序,发到CU来...
话说你是用终端输出的么?windows 的终端都是ASCII或者Unicode-16的,不支持UTF-8
话说你是用终端输出的么?windows 的终端都是ASCII或者Unicode-16的,不支持UTF-8
作者: davelv 发布时间: 2010-09-02
iconv转
作者: zhangsuozhu 发布时间: 2010-09-02
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28