|
Hi,
We need to extract strings from a .EXE file. What are ways to do that?
|
|
|
|
|
Use LoadLibrary[^] to load the EXE.
Call LoadString[^] and pass the handle returned by LoadLibrary as the first parameter.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Thanks for the reply.
We have tried these functions but loadstring function requires the string ID. How do we find that? Can you provide any links which have the sample code?
|
|
|
|
|
|
|
Thanks,
Stablupd.exe is already available for this but,
We want to make project that will fetch string from EXE.
Can you help us regarding this?
|
|
|
|
|
If you need to get all strings from executable, than You need dothis:
HMODULE some = LoadLibrary("mylib.dll")
and than
EnumResourceNames(some, RT_STRING, MyStringCB, NULL);
Please note that every string resource is actually a block of 16 unicode strings. So You have 2 options there:
a) interpret RT_STRING by yourself
b) compute 16 string ID's (nStringIDfirst = (nBlockID- 1) * 16; ) and call LoadString() 16 times:
BOOL CALLBACK MyStringCB(HMODULE some_library,
LPCTSTR resource_type,
LPTSTR resource_name,
LONG_PTR aux_param)
{
DWORD startId = ((DWORD)resource_name - 1) * 16;
DWORD i, endId = startId + 16;
for (i = startId ; i < endId; ++i)
{
LoadString(some_library, i, ...)
...
}
return TRUE;
}
|
|
|
|
|
Can you please explain the various parameters of MyStringCB in more detail.
Loadlibrary is working properly but, We have problem in the EnumResourceNames.
Thanks.
|
|
|
|
|
choramale_vs wrote: Can you please explain the various parameters of MyStringCB in more detail.
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Parameters of MyStringCB is obvious, refer MSDN: EnumResNameProc Function.
some_library - handle to library we load
resource_type - resource type, will always be RT_STRING in our case
resource_name - resource identifier (either string name or numerical)
aux_param - optional auxiliary parameter specified in call to EnumResourceNames , in my sample it is not used.
The first trick is with resource_name . You can check for strings it always integer (try ASSERT(IS_INTRESOURCE(resource_name)); ).
'INTRESOURCE' is not a real pointer, it's an integer (refer MSDN: IS_INTRESOURCE) and we reinterpret is a WORD (or DWORD, in all cases it have only 16 significant bits).
The second issue - is RT_STRING resource itself not a string, this is a block of 16 strings! This why we generate 16 ID's and load strings with LoadString() API
PS: Your task is to load/list all strings in string resources, not to find all strings in code of application (like Process Explorer of Mark Russinovich or other hackers tool)?
|
|
|
|
|
I have some strings in my program. Does these strings goes into string table of exe?
can i use string name as resource_name?
|
|
|
|
|
Hi,
I got crash once in GetMessage method while calling that method in message loop. I am doing some simple opertion with win32 coding and try to get the message form message queue of windows and it got crash. Can anybody help me to find out the possible reason behind this crash with fixes. The crash has been seen on XP 32 bit machine.
|
|
|
|
|
Kundan Kumar Bharti wrote: Can anybody help me to find out the possible reason behind this crash with fixes.
Without any code neither the exact error message, this will be very difficult. We still can't read mind, you know...
So, please post the code snippet where the crash occurs (make sure you read point 7 here[^] before posting). Post also the exact error message of the crash.
|
|
|
|
|
I have a dialog box popping up, which contains a updown control.
I need to set and get the values of its buddy control through my c++ program.
Basically i am automating it.
Please could some one help me.
|
|
|
|
|
Use FindWindowEx[^] to find the updown control in the dialog.
Type cast the CWnd* of the control to a CSpinButtonCtrl* and call CSpinButtonCtrl::GetBuddy[^] to get a pointer to the buddy window.
You can then use GetWindowText[^] and SetWindowText[^] to get and set the value of the buddy control respectively.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hi Superman,
First thanks a lot for replying.
I have another problem, i know only the dialog name.
I don't have the handle to the updown control.
How should i find it?
Thanks in advance
|
|
|
|
|
That is exactly what FindWindowEx gives you.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Thanks a lot.
Its working fine..
|
|
|
|
|
Hi all,
I m using a ListBox and add Variable for this that is CCheckListBox type.
there is 4 items,and i m also use a Check box that is use to select and deselct all items of ListBox.
i m handle it over ON_LBN_SELCHANGE of ListBox and Click event of Check box.
selection and deselection from Checkbox working fine.
but problem occur when i use it by List box means, iwant when the all items of list box checked than Select all Check box automatically Checked or vice-versa.
but i have one problem when i continous click on listbox its not working fine.
CButton m_sel_all_chk;
CCeckListBox m_col_lb;
void CExcel_Info_Dlg::OnBnClickedCheckSelAll()
{
if(m_sel_all_chk.GetCheck()==1)
{
for(int i=0;i<m_col_lb.GetCount();i++)
{
m_col_lb.SetCheck(i, 1);
}
}
else if(m_sel_all_chk.GetCheck()==0)
{
for(int i=0;i<m_col_lb.GetCount();i++)
{
m_col_lb.SetCheck(i, 0);
}
}
}
void CExcel_Info_Dlg::OnLbnSelchangeListColumns()
{
BOOL flag;
flag=FALSE;
int count=m_col_lb.GetCount();
for(int i=0;i<count;i++)
{
if(m_col_lb.GetCheck(i)==0)
{
flag=TRUE;
break;
}
}
if(flag==FALSE)
{
m_sel_all_chk.SetCheck(1);
}
else
{
m_sel_all_chk.SetCheck(0);
}
}
so please help me for this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
"_$h@nky_" wrote: but i have one problem when i continous click on listbox its not working fine.
...
so please help me for this
Your code snippet worked fine for me.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
i means when i click on List box item multiple times and all items are checked than select all check box automatically checked.
or if not checked all items select all button not checked.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
I understand what you want, and the code snippet you've shown does exactly that.
In addition to what you want the code to do, you might also add what it's actually doing.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi all,
I want to read the content of the file.(say .txt)
I am using Read method...But Its not reading the entire contents present in the file rather it reads around 50% of the file.
-------------------------
Code Snippet:
CStdioFile docfile;
WCHAR* preadbuf;
if(docfile.open(....))
docfile.read(preadbuf,docfile.getlength());
------------
Please tell me how to solve this problem. please let me know if you have any queries..
Thanks,
Rakesh.
|
|
|
|
|
Does CStdioFile have open and read methods?
The length parameter to any read function is the amount of data to be read from the file.
I believe there is some mistake here.
The first parameter to the read function must be a buffer containing some memory and not just a pointer.
Look at the example in the documentation of CFile::Read[^].
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
You never allocate preadbuf, so I'm really amazed that your code doesn't crash here...
|
|
|
|