| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		Liger Cheater
  Reputation: 0
  Joined: 26 Jan 2019 Posts: 36 Location: don't have
  | 
		
			
				 Posted: Thu Jul 22, 2021 9:08 pm    Post subject: Read String Memory UTF-16 C++ | 
				       | 
			 
			
				
  | 
			 
			
				I try to read this string, but it only reads the first letter 
 
 
using language C++
 
 
https://im.ge/i/7xr8P
 _________________
 (^_^)  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		DanyDollaro Master Cheater
  Reputation: 3
  Joined: 01 Aug 2019 Posts: 334
 
  | 
		
			
				 Posted: Fri Jul 23, 2021 2:21 am    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				That's a UTF-16 string, you need to use the wide version of the output function you are using, assuming you are using cout, what you are doing could be:
 
 	  | Code: | 	 		  | std::cout << string; | 	  
 
To show that string you have to do:
 
 	  | Code: | 	 		  | std::wcout << string; | 	  
 
 
In case that is not the solution, it could also be that you are reading with ReadProcessMemory the wrong amount of bytes, as size you cannot put things like "sizeof(wchar_t)", but the actual length of the string in bytes, which is "6 * sizeof ( wchar_t)" also counting the escape sequence '\ 0'.
 
 
(it would help in case you also post the code you wrote)
 | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		Liger Cheater
  Reputation: 0
  Joined: 26 Jan 2019 Posts: 36 Location: don't have
  | 
		
			
				 Posted: Sat Jul 24, 2021 9:43 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				 	  | DanyDollaro wrote: | 	 		  That's a UTF-16 string, you need to use the wide version of the output function you are using, assuming you are using cout, what you are doing could be:
 
 	  | Code: | 	 		  | std::cout << string; | 	  
 
To show that string you have to do:
 
 	  | Code: | 	 		  | std::wcout << string; | 	  
 
 
In case that is not the solution, it could also be that you are reading with ReadProcessMemory the wrong amount of bytes, as size you cannot put things like "sizeof(wchar_t)", but the actual length of the string in bytes, which is "6 * sizeof ( wchar_t)" also counting the escape sequence '\ 0'.
 
 
(it would help in case you also post the code you wrote) | 	  
 
 
 
 
I already use . ReadProcessMemory  function .  
 
and i'm not strong enough in C++ language 
 
So can you give me an example.
 
Thank you for helping me.
 _________________
 (^_^)  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		DanyDollaro Master Cheater
  Reputation: 3
  Joined: 01 Aug 2019 Posts: 334
 
  | 
		
			
				 Posted: Sun Jul 25, 2021 3:38 am    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				I used a 32-bit process as a target.
 
 
 	  | Code: | 	 		  #include <iostream>
 
#include <Windows.h>
 
 
int main()
 
{
 
   DWORD pid = 1337; // Pid stand for Process ID
 
 
   HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, pid);
 
 
   wchar_t wstring[256] = { 0 };
 
   ReadProcessMemory(hProcess, (LPVOID)0x008D31C0, wstring, sizeof(wstring), NULL);
 
 
   std::wcout << wstring << std::endl;
 
 
   CloseHandle(hProcess);
 
   getchar();
 
   return 0;
 
} | 	  
 
 
And I am attaching the contents of the address 0x008D31C0 (the memory address on which the string is located).
	
  
	 
	
	
		
	 
	
		|  Description: | 
		
			
		 | 
	 
	
		|  Filesize: | 
		 3.88 KB | 
	 
	
		|  Viewed: | 
		 4931 Time(s) | 
	 
	
		
  
 
  | 
	 
	 
	 
 | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		Liger Cheater
  Reputation: 0
  Joined: 26 Jan 2019 Posts: 36 Location: don't have
  | 
		 | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		 |