免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3285 | 回复: 2
打印 上一主题 下一主题

[C++] C + +如何转UTF8?? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-09-02 00:53 |只看该作者 |倒序浏览
此程序是朋友给的可我输入中文显示出来会变成乱码应该是没有转码导致有高手能指点一下帮忙修改此程序吗
转换为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;
                          }
   }

论坛徽章:
0
2 [报告]
发表于 2010-09-02 09:07 |只看该作者
楼主这是windows下的程序,发到CU来...
话说你是用终端输出的么?windows 的终端都是ASCII或者Unicode-16的,不支持UTF-8

论坛徽章:
0
3 [报告]
发表于 2010-09-02 10:03 |只看该作者
iconv转
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP