Re: Reading a Wnd structure...
- From: "Doron Holan [MS]" <doronh@xxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 24 May 2006 22:19:58 -0700
This is a discussion forum, not a repository for mission-critical code.not everyone who reads this newsgroup understand this distinction. I can't
tell you how many times i have encountered developers who need to do "X"
real fast, find a post like this, treat it as gospel that they should use it
in production code and then break on the next SP/WU update.
d
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"James Brown [MVP]" <not@home> wrote in message
news:k82dnXfTatycAOnZRVnyvQ@xxxxxxxxxxxx
"Scherbina Vladimir" <vladimir.scherbina@xxxxxxxxxxxx> wrote in message
news:eSRhObwfGHA.4304@xxxxxxxxxxxxxxxxxxxxxxx
[...]
You are still top-posting.....
But your method is even worse! where is the code to limit you to a
specific version of Windows? how do you know, for certain, that you are
running with the same version of user32.dll that you disassembled
yourself? You may have to use checksums to verify this. If you get any
of those checks wrong you are finished. You are talking about an
enormous amount of additional code to support a method that adds no
value whatsover - and just because you think it is 'clever'. It's not.
So my original code, which is still 5 lines long, is completley
stand-alone, requires no extra support, and works on all current
versions of Windows. Anyone can now download this code from the
newsgroup and it will work instantly for them. I was clear up front that
it should not be used for production code and the original poster has
confirmed his intended use. All you have succeeded in doing is confusing
the issue and making it more complicated than it needs to be.
You can't seriously believe that a hard-coded assembly version is
preferable?
James
--
Microsoft MVP - Windows SDK
www.catch22.net
Free Win32 Source and Tutorials
James, your code will fail if MS change passing parameter using ECX, or
if the first call in GetWindowRect will point to another function. So I
can't be sure it will be working in next SP.
Thus, the only possible way to be sure is to calculate offsets for
different versions of OS. Yes, your code calculates "on fly" the address,
but its *unsafe*.
Thanks, I'm well aware of the issues surrounding this technique, which
became evident as I was personally researching this topic and subsequently
developing the solution. Of course this technique would fail if the
GetWindowRect function changed enough (it is obvious just by looking at
it?) but I stand by this technique for the following reasons:
1. It demonstrates the concept that the ValidateHwnd function - a
little-known and undocumented internal routine - can be invoked by a
user-program.
2. It puts across this idea very clearly and simply.
3. It works on all current versions of Windows.
4. It can be copied into someone's program, as-is, and it will work. Do
*not* underestimate how important this is for learning purposes.
5. It is proof-of-concept only, I was very clear that it should not be
used in production code and it should be obvious to anyone reading this
thread that they should do further work if they want to make it
'bullet-proof'.
6. All the original-poster needs to do is add a GetVersion check - that's
it.
This is a discussion forum, not a repository for mission-critical code.
The original poster wanted access to this function and I provided the best
possible solution for him. I appreciate your stand-point but your
suggestion of hard-coding offsets is flawed. I don't believe you have
thought of the sheer amount of code you must write in support of it - you
seem to be trying to make a point to be clever and aren't taking into
account the practicalities of the situation - this is a forum for
*learning*. Your solution wouldn't have worked for anyone else but those
that happened to have the same user32 as you - what use is that?
Each time a new version of user32 is released you must disassemble it,
find the new offset, and then modify and re-release your program to
support any new version. This is a huge amount of work. Been there, done
that, it's not worth the effort. With my method, all that is needed is to
test against the latest Windows and then alter the GetVersion check. Far
less work, and it is *safe*. Post up your version and we'll see how well
it fairs :-)
I would suggest that hard-coded file-offsets not a very good idea for the
reasons I outlined above. The only true method is to download
debug-symbols for user32.dll (in realtime) from Microsoft's symbol-server
and then performing a lookup for ValidateHwnd. Do you really think all
this support-code is necessary to answer the simple question : "how do you
call ValidateHwnd" ???
James
--
Microsoft MVP - Windows SDK
www.catch22.net
Free Win32 Source and Tutorials
.
- References:
- Reading a Wnd structure...
- From: Jack
- Re: Reading a Wnd structure...
- From: James Brown [MVP]
- Re: Reading a Wnd structure...
- From: James Brown [MVP]
- Re: Reading a Wnd structure...
- From: Scherbina Vladimir
- Re: Reading a Wnd structure...
- From: James Brown [MVP]
- Re: Reading a Wnd structure...
- From: Scherbina Vladimir
- Re: Reading a Wnd structure...
- From: James Brown [MVP]
- Re: Reading a Wnd structure...
- From: Scherbina Vladimir
- Re: Reading a Wnd structure...
- From: James Brown [MVP]
- Re: Reading a Wnd structure...
- From: Scherbina Vladimir
- Re: Reading a Wnd structure...
- From: James Brown [MVP]
- Reading a Wnd structure...
- Prev by Date: Re: CreateFile issue with accessing kernel via app and service simultaneously
- Next by Date: Re: Re:without message queue
- Previous by thread: Re: Reading a Wnd structure...
- Next by thread: Re: Reading a Wnd structure...
- Index(es):
Relevant Pages
|