473,396 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

CTString in detour function

iam_clint
1,208 Expert 1GB
Ok the issue is I am reverse engineering a game (I use IDAPRO) and detouring a function. This function happens to be AddChatMessage(uchar,long,CTString,CTString)
I have the detour working its running to my function But i can't seem to figure out how to get CTString into a readable text
Expand|Select|Wrap|Line Numbers
  1. FARPROC WINAPI myAddChatMessage(char *char1,long long1,char *String1, char *String2)
  2. {
  3.     char szTemp[1024];
  4.     std::string str1 = String1;
  5.     std::string str2 = String2;
  6.     sprintf(szTemp, "string: %s string2: %s",str1.c_str(),str2.c_str());
  7.     MessageBox(NULL,szTemp,"Add Chat Message Function",MB_OK);
  8.     return false;
  9. }
  10.  
The Reverse Engineered Function
Expand|Select|Wrap|Line Numbers
  1. AddChatMessage(uchar,long,CTString &,CTString &)
  2.  
I have tried several different approaches this just happened to be the last one I tried. So if someone could please shed some light on this all help would be appreciated.
Dec 17 '07 #1
2 2266
RedSon
5,000 Expert 4TB
Ok the issue is I am reverse engineering a game (I use IDAPRO) and detouring a function. This function happens to be AddChatMessage(uchar,long,CTString,CTString)
I have the detour working its running to my function But i can't seem to figure out how to get CTString into a readable text
Expand|Select|Wrap|Line Numbers
  1. FARPROC WINAPI myAddChatMessage(char *char1,long long1,char *String1, char *String2)
  2. {
  3.     char szTemp[1024];
  4.     std::string str1 = String1;
  5.     std::string str2 = String2;
  6.     sprintf(szTemp, "string: %s string2: %s",str1.c_str(),str2.c_str());
  7.     MessageBox(NULL,szTemp,"Add Chat Message Function",MB_OK);
  8.     return false;
  9. }
  10.  
The Reverse Engineered Function
Expand|Select|Wrap|Line Numbers
  1. AddChatMessage(uchar,long,CTString &,CTString &)
  2.  
I have tried several different approaches this just happened to be the last one I tried. So if someone could please shed some light on this all help would be appreciated.
It could be that your string needs to be a wide char. You will need to make szTemp, str1, str2 all into wide chars (wchar_t or TCHAR) then use a wide printf method, if memory servers I think you want wsprintf but you'll need to double check.
Dec 18 '07 #2
weaknessforcats
9,208 Expert Mod 8TB
You need to use the TCHAR mappings. You cannot use char, wchat_t, sprintf, etc in Windows code. Try:

Expand|Select|Wrap|Line Numbers
  1. FARPROC WINAPI myAddChatMessage(PCHAR char1,long long1,PCHAR String1, PCHAR String2)
  2. {
  3.     TCHAR szTemp[1024];
  4. //could be either string or wstring based on the character set
  5. //STL is incompatible with TCHAR. You will need your own #define
  6. //to toggle between string and wstring based on Unicode defined or not.
  7. //
  8.     //std::string str1 = String1;
  9.     //std::string str2 = String2;
  10.     _stprintf(szTemp, TEXT("string: %s string2: %s"),String1,String2);
  11.     MessageBox(NULL,szTemp,TEXT("Add Chat Message Function"),MB_OK);
  12.     return false;
  13. }
  14.  

MessageBox is also a TCHAR mapped function toggling between MessageBoxA and MessageBoxW.

Read http://msdn2.microsoft.com/en-us/library/ms860358.aspx.
Dec 18 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
6
by: pablo | last post by:
Dear Newsgroupers, The 'main' page contains a call to a function in an included file. This function puts a html-form on the screen. Before the form gets posted (to the 'main' page) some prior...
9
by: Lenard Lindstrom | last post by:
I was wondering if anyone has suggested having Python determine a method's kind from its first parameter. 'self' is a de facto reserved word; 'cls' is a good indicator of a class method ( __new__...
10
by: Brad Tilley | last post by:
Is there an easier way to do this: def print_whats_returned(function): print function print type(function)
9
by: Derek Hart | last post by:
I wish to execute code from a string. The string will have a function name, which will return a string: Dim a as string a = "MyFunctionName(param1, param2)" I have seen a ton of people...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
2
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
32
by: Greg | last post by:
I know I can use the Microsoft.VisualBasic.Left function to get the left portion of a string, but I would prefer to avoid using any Microsoft.VisualBasic namespace items. What is the equivilant in...
1
by: dlreich | last post by:
While viewing a form, I use Find (Ctrl-F) to find a new record. In On Current for the form, I use GoToControl to adjust the display of one of the fields in the new record. Is there any way I can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.