JMI
December 24th, 2001, 15:33
Viper:
This is an extract from an article titled "Rhayader's Softice Tips.." which I attached to one of my previous posts. He said:
----------------------------
Let's take a look at GetWindowTexta first. It's declared as:
int GetWindowText( HWND hWnd, LPTSTR lpString, int nMaxCount );
GetWindowText use stdcall calling convention. That means that argument will be pushed right to left. Since SoftIce pop up before the prologue code is executed, the EBP stack frame isn't set up yet. So we had to use ESP to adressed the argument. Here's how the stack will look like when SoftIce pop up:
...
[ESP+0Ch] - nMaxCount
[ESP+08h] - lpString
[ESP+04h] - hwnd
[ESP+00h] - return EIP
When the function return, GetWindowTexta will put the text it retrieved to the location pointed to by lpString (LPTSTR is a long pointer to a null terminated string). Thus, we had to use SoftIce's indirection operator (it's the * character, same as C language, see Chapter 8. For example, the command:
D *(esp+8)
means, "show in data window, the location pointed to by the content of esp+8". Since, this is a very common operation, SoftIce had a shorthand for it: esp->8. Allright then, now we can set the breakpoint such as this:
BPX getwindowtexta DO "D esp->8;"
And when we hit F12, we return to the caller and the text we entered will sit nicely at the top of the data window, waiting for us to set up a BPR with it

Why don't we do a return to the caller automatically? Well, in my case, the screen flashes, and I hate it. But, if you want to try, you can set the breakpoint as:
BPX getwindowtexta DO "D esp->8;P RET;"
Now, let's take a look at GetDlgItemTexta. It is declared as:
UINT GetDlgItemText( HWND hDlg, int nIDDlgItem, LPTSTR lpString, int nMaxCount );
The only difference is nIDDlgItem, which is the ID of the control to get the text from. The stack will look like this:
...
[ESP+10h] - nMaxCount
[ESP+0Ch] - lpString << here it is
[ESP+08h] - nIDDlgItem
[ESP+04h] - hwnd
[ESP+00h] - return EIP
And the breakpoint to set (I had a feeling that you already find out
BPX getdlgitemtexta DO "D esp->C;"
___________________
His breakpoints do not have the "\"s shown in your first example and maybe that is the problem. try
MARCO ANY = "BPX getwindowtexta DO "D esp->8;P RET;" "
Hope that works.
Js wrote, before he gave up, that your second example has single quotes instead of double quotes around "D esp->8;P RET;"
I've unchecked smilies, I don't know why they are showing up.
Regards.