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??
Printable View
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??
Try this article.
Cheers
I already answered you in your previous thread. What was wrong there for you? :confused:
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;
}
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.Wrong! You may not redefine this value. Otherwise the rest of your code does not make any sense!Quote:
Code:LPCTSTR RT_String=NULL;
6.Wrong! you must use double backslashes!Quote:
Code:HMODULE some_library = LoadLibrary("C:/Hi/Debug/Hi.exe");
7.Wrong. GetLastError makes any sense only if API call failed. So:Quote:
Code:r=EnumResourceNames(some_library, RT_STRING, MyStringCB, aux_param);
S=GetLastError();
8.Code:if(!EnumResourceNames(some_library, RT_STRING, MyStringCB, aux_param))
S=GetLastError();
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!Quote:
Code:q= MyStringCB(some_library,RT_String,buffer,aux_param);
.......
Well, did you read the article i referred to? :confused:
Did you try to download the Microfoft code to get/read/update string resources? :confused:
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;
}
The line:
is just a declaration of a pointer. You need to create a memory area to hold actual string.Code:LPCTSTR RT_String;
You should write:
Don't forget to call the delete operator when you no longer need the string.Code:LPCTSTR RT_String = new TCHAR[desired size];