c++ reading not alphabet string failed menu

User Tag List

Results 1 to 5 of 5
  1. #1
    iceblockman's Avatar Member
    Reputation
    2
    Join Date
    Jun 2012
    Posts
    36
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    c++ reading not alphabet string failed

    Hi guys, my code can read alphabet based player name correctly, but failed for not alphabet .

    for example , this player name: Ashbringér , the letter é cannot be displayed correctly. my code is here

    Code:
    #include <iostream>
    #include <windows.h>
    #include <Tlhelp32.h>
    #pragma comment(lib, "User32.lib")
    #pragma comment(lib, "Advapi32.lib")
    
    DWORD GetPID(char* procName);
    DWORD GetBaseAddress(int pid);
    
    int main ()
    {
    	DWORD id = GetPID("Wow.exe");
    	DWORD base = GetBaseAddress(id);
    	
    	HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);
    	
    	char name[50] = {0};
    	ReadProcessMemory(hProcess, reinterpret_cast<const void*>(base + 0xF24D40), &name, 50, nullptr);
    	printf(name);
    	
    	CloseHandle( hProcess );
        return 0;
    }
    
    DWORD GetPID(char* procName)
    {
    	HANDLE hProcessSnap;
    	PROCESSENTRY32 pe32;
    	  
    	// Take a snapshot of all processes in the system.
    	hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    	if( hProcessSnap == INVALID_HANDLE_VALUE )	
    		return 0;
    	
    	// Set the size of the structure before using it.
    	pe32.dwSize = sizeof(PROCESSENTRY32);
    
    	// Retrieve information about the first process,
    	if(!Process32First(hProcessSnap, &pe32))
    		return 0;
    	
    	do
    	{
    		if(strcmp(pe32.szExeFile, procName) == 0)
    		{
    			DWORD pid = pe32.th32ProcessID;
    			CloseHandle(hProcessSnap);
    			return pid;
    		}
    	} while(Process32Next(hProcessSnap, &pe32));
    
    	CloseHandle(hProcessSnap);
    	return 0;
    }
    
    DWORD GetBaseAddress(int pid)
    {
    	HANDLE phandle = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pid);//get permission to read
    	MODULEENTRY32 module; 
    	module.dwSize = sizeof(MODULEENTRY32);
    	Module32First(phandle, &module);
    	CloseHandle(phandle);
    	return reinterpret_cast<unsigned int>(module.modBaseAddr);
    }

    c++ reading not alphabet string failed
  2. #2
    Merphz's Avatar Private
    Reputation
    9
    Join Date
    Nov 2014
    Posts
    11
    Thanks G/R
    2/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use unicode or extended ASCII.

  3. #3
    TOM_RUS's Avatar Legendary
    Reputation
    914
    Join Date
    May 2008
    Posts
    699
    Thanks G/R
    0/52
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Wow stores strings in UTF-8 encoding. Console doesn't like it too much I guess.

  4. #4
    iceblockman's Avatar Member
    Reputation
    2
    Join Date
    Jun 2012
    Posts
    36
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i read the name bytes out, then use c# utf8 encoding to get the string, the output is correct, So i can confirm it's encoded in utf8.

    but i cannot find Encoding.UTF8.GetString function in native c++, any help?

    Code:
    // Ashbringér  UTF8 encoding byte array
    		byte[] array =
    		{
    			65,
    			115,
    			104,
    			98,
    			114,
    			105,
    			110,
    			103,
    			195,
    			169,
    			114
    	    };
    		
    		string value = Encoding.UTF8.GetString(array);
    		Console.WriteLine(value);  // print Ashbringér correctly

  5. #5
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1511
    Join Date
    May 2008
    Posts
    2,432
    Thanks G/R
    81/333
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by iceblockman View Post
    i read the name bytes out, then use c# utf8 encoding to get the string, the output is correct, So i can confirm it's encoded in utf8.

    but i cannot find Encoding.UTF8.GetString function in native c++, any help?
    MultiByteToWideChar(CP_UTF8, ...)

Similar Threads

  1. [C#] Reading a std::string from memory
    By prixone in forum Programming
    Replies: 3
    Last Post: 03-12-2016, 08:37 PM
  2. Reading a build string in OS X
    By thefrese in forum WoW Memory Editing
    Replies: 1
    Last Post: 07-22-2014, 02:47 PM
  3. Reading and writing strings
    By miceiken in forum WoW Memory Editing
    Replies: 9
    Last Post: 03-10-2010, 03:49 PM
  4. Not related to model editing but I need a file, please read
    By kody in forum WoW ME Questions and Requests
    Replies: 0
    Last Post: 07-26-2007, 01:40 PM
  5. Account Suspended (Please Read) Not a flame or crap just need info
    By Remko01 in forum World of Warcraft Bots and Programs
    Replies: 22
    Last Post: 11-23-2006, 05:02 AM
All times are GMT -5. The time now is 04:15 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search