If your string is constant, then you could scan physical memory (!search) (for user mode, you would just scan your virtual address
space) for the string, and then break on that address, but I don’t imagine that is what you mean. Otherwise, if I understand you
correctly, you pretty much would have to single step in some way, shape or form. While only certain opcodes could reference memory
in a way that you might be interested in, you would have to evaluate the opcode to determine that, which would either also require
effectively single stepping or something really complicated like simulation or binary translation. No matter how you do this, it is
going to be unbearably slow, and I think you would be be off exploring this outside of WinDbg via the use of a customized simulator
that recorded program activity during a run. This would at least remove the over the wire time, but I would think long and hard
before I did either of these about why it is that you can’t narrow this problem down.
If you decide to proceed in WinDbg, here’s my best guess as to how to do this. You might be able to do this with a conditional
breakpoint in theory, but I’m not sure that you could handle all the permutations on registers within a conditional breakpoint.
That is, since you don’t know what you’re looking for in the way of code that will be doing the referencing, you would have to do
something like if ((eax==) || (ebx=) …), and I haven’t any idea if that works or not. Don’t do this.
I wouldn’t do what you’re considering at all, but if I had to do this in WinDbg, I would try writing an extension that would
disassemble the current instruction and check to see if it referenced memory that matched. This would be a lot of work, and would
also be unbearable to use in practice, because you are still in effect single stepping, plus you have to do all the host side WinDbg
processing, pull the referenced memory, do the comparison, and finally resume execution. Don’t do this either.
Why do you need to do this? Not knowing the address of a pattern you seek is not unusual, nor is not knowing the address of an
instruction that references a certain address, but not knowing either is unusual, and it’s a bit of a problem, at least as I see it.
There has to be some way you can narrow this problem down by specifying some detail. Ideally, there has to be some way to avoid
this problem altogether.
Good luck,
mm
xxxxx@hotmail.com wrote:
Hello,
I’m seeking a way to trace a program in windbg until a special string is
referenced for example
imagine I’m seeking for “helloworld” whois located at un unknow location
in the program memory.
I want windbg to stop when he is actually matching this string into a
register or memory
for example
[eax] == “helloworld”
mov edx,[eax]
windbg would stop because edx contain a address to a string equal to
“helloworld”.
what is the best way to accomplish such task?
thanks.