-
September 7th, 2009, 01:30 AM
#1
Display Strings
I have an EXE file and i want to list all the strings from the String Table of the EXE
The exe is the compiled CPP file like the one present in the Debug folder
How do i display all the strings that are present??
-
September 7th, 2009, 01:55 AM
#2
-
September 7th, 2009, 02:33 AM
#3
Re: Display Strings
Originally Posted by nixter
I have an EXE file and i want to list all the strings from the String Table of the EXE?
I already answered you in your previous thread. What was wrong there for you?
Victor Nijegorodov
-
September 7th, 2009, 07:26 AM
#4
Re: Display Strings
I have used this code till now. Is this proper?
#include "stdafx.h"
#include "windows.h"
#include "tchar.h"
#include "stdio.h"
#include "string.h"
BOOL CALLBACK MyStringCB(HMODULE some_library,LPCTSTR RT_String,LPTSTR buffer,LONG_PTR aux_param);
char buffer[200];
int _tmain(int argc, _TCHAR* argv[])
{DWORD S;
LPCTSTR RT_String=NULL;
LONG_PTR aux_param=NULL;
BOOL q,r;
HMODULE some_library = LoadLibrary("C:/Hi/Debug/Hi.exe");
q= MyStringCB(some_library,RT_String,buffer,aux_param);
r=EnumResourceNames(some_library, RT_STRING, MyStringCB, aux_param);
S=GetLastError();
return 0;
}
BOOL CALLBACK MyStringCB(HMODULE some_library,LPCTSTR RT_String,LPTSTR buffer,LONG_PTR aux_param)
{ DWORD startId = ((DWORD)buffer - 1) * 16;
DWORD i, endId = startId + 16;
for (i = startId ; i < endId; ++i)
{ LoadString(some_library, i,buffer,sizeof(buffer));
}
return TRUE;
}
-
September 7th, 2009, 07:45 AM
#5
Re: Display Strings
Originally Posted by nixter
I have used this code till now. Is this proper?
No. Some serious problem are there.
1. Always use Code tags while posting code snippets. Otherwise your code is almost unreadable.
2. Don't be so lazy to *no* insert spaces after commas - the same reason as above.
3. Why are you using obsolete char type instead of TCHAR?
4. What does this magic number '200' mean? Why not '20' or 2000'?
5.
Code:
LPCTSTR RT_String=NULL;
Wrong! You may not redefine this value. Otherwise the rest of your code does not make any sense!
6.
Code:
HMODULE some_library = LoadLibrary("C:/Hi/Debug/Hi.exe");
Wrong! you must use double backslashes!
7.
Code:
r=EnumResourceNames(some_library, RT_STRING, MyStringCB, aux_param);
S=GetLastError();
Wrong. GetLastError makes any sense only if API call failed. So:
Code:
if(!EnumResourceNames(some_library, RT_STRING, MyStringCB, aux_param))
S=GetLastError();
8.
Code:
q= MyStringCB(some_library,RT_String,buffer,aux_param);
Wrong! MyStringCB is a callback function and is called by the system from within the EnumResourceNames (or some other) API. You must not call it yourself!
.......
Well, did you read the article i referred to?
Did you try to download the Microfoft code to get/read/update string resources?
Victor Nijegorodov
-
September 7th, 2009, 08:12 AM
#6
Re: Display Strings
We made the changes suggested by you. While debugging the error is that RT_String needs to be initialized.
Yes i downloaded the STablUpd and am very new to C++ ,just started 2 months back.
#include "stdafx.h"
#include "windows.h"
#include "tchar.h"
#include "stdio.h"
#include "string.h"
BOOL CALLBACK MyStringCB(HMODULE some_library,LPCTSTR RT_String,LPTSTR buffer,LONG_PTR aux_param);
char buffer[200];
int _tmain(int argc, _TCHAR* argv[])
{DWORD S;
LPCTSTR RT_String;
LONG_PTR aux_param=NULL;
BOOL q,r;
HMODULE some_library = LoadLibrary("C:\\Hi\\Debug\\Hi.exe");
//q= MyStringCB(some_library,RT_String,buffer,aux_param);
r=EnumResourceNames(some_library, RT_STRING, MyStringCB, aux_param); //ERROR HERE.
//MyStringCb is not being called
if(!EnumResourceNames(some_library, RT_STRING, MyStringCB, aux_param))
S=GetLastError();
return 0;
}
BOOL CALLBACK MyStringCB(HMODULE some_library,LPCTSTR RT_String,LPTSTR buffer,LONG_PTR aux_param)
{ DWORD startId = ((DWORD)buffer - 1) * 16;
DWORD i, endId = startId + 16;
for (i = startId ; i < endId; ++i)
{ LoadString(some_library,i,buffer,sizeof(buffer));
}
return TRUE;
}
-
September 8th, 2009, 06:49 PM
#7
Re: Display Strings
The line:
is just a declaration of a pointer. You need to create a memory area to hold actual string.
You should write:
Code:
LPCTSTR RT_String = new TCHAR[desired size];
Don't forget to call the delete operator when you no longer need the string.
-
September 9th, 2009, 03:23 AM
#8
Re: Display Strings
Originally Posted by nixter
We made the changes suggested by you. }
No, you dibn't!
Once more:
Originally Posted by VictorN
No. Some serious problem are there.
1. Always use Code tags while posting code snippets. Otherwise your code is almost unreadable.
2. Don't be so lazy to *no* insert spaces after commas - the same reason as above.
3. Why are you using obsolete char type instead of TCHAR?
4. What does this magic number '200' mean? Why not '20' or 2000'?
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|