473,396 Members | 1,923 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Reading WndProc Messages

First some background:

I have been asked to develop a program that access our data warehouse. It
requires a login and password to use so we created a custom control that is
placed on the form, the user types in their username/password, we validate
then return either true or false. The program hosting the control has no
access to the keydown and keyup events from the control. This user control
is used throughout the plant and by many developers. Now we need to use it
for the access the warehouse. We must log everyone that attempted to log
into the system and everyone who logs into the system. I cannot capture
this by the control we use, so I created a class that extends the control
and listens for messages. It inherits from the
System.Windows.Forms.NativeWindow object.

I have overridden the WndProc process and raise an event passing out the
System.Windows.Forms.Message. I need to interrupt the message that is thrown
and then log the username that was entered. I can get an ASCII value using
the WParam but it only gives me upper case and freaks out when the shift key
is pressed (usernames can be something like J0hnD03). Does anyone know how
to read this message and see what key was pressed?

Thanks.

John

One the form side, I have the following routine:

Private Const WM_KEYDOWN As System.Int32 = &H100

Private Const WM_KEYUP As System.Int32 = &H101

Private Const WM_SYSKEYDOWN As Integer = &H104

Private Const WM_SYSKEYUP As Integer = &H105

Dim WithEvents abc As Hooked
'Code I need help with
Private Sub abc_CallBackProc(ByVal m As System.Windows.Forms.Message)
Handles abc.CallBackProc

Select Case m.Msg

Case WM_KEYDOWN

TextBox2.Text &= ChrW(m.WParam)

End Select

End Sub
Dec 13 '07 #1
6 2353
"John Wright" <ri***********@hotmail.comwrote in
news:eg**************@TK2MSFTNGP04.phx.gbl:
This user control
is used throughout the plant and by many developers. Now we need to
use it for the access the warehouse. We must log everyone that
attempted to log into the system and everyone who logs into the
system. I cannot capture this by the control we use, so I created a
class that extends the control and listens for messages.
Why aren't you capturing this stuff on the back end?

--
sp**********@rogers.com (Do not e-mail)
Dec 13 '07 #2
John Wright wrote:
First some background:
.... we created a custom control that is
placed on the form, the user types in their username/password, we validate
then return either true or false. The program hosting the control has no
access to the keydown and keyup events from the control.
Hmmm.... This sounds very fishy to me. If you "created" the custom
control, then why not just "modify" the custom control to provide what
you're looking for?

If you're trying to create some kind of password capture app then I
don't think you'll find too many people here wanting to help you!

Maybe I've read this wrong, and I apologise if this is the case, but
that's how it reads to me.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Dec 13 '07 #3
I think Windows logs all this for you now...
"John Wright" <ri***********@hotmail.comwrote in message
news:eg**************@TK2MSFTNGP04.phx.gbl...
First some background:

I have been asked to develop a program that access our data warehouse. It
requires a login and password to use so we created a custom control that
is placed on the form, the user types in their username/password, we
validate then return either true or false. The program hosting the
control has no access to the keydown and keyup events from the control.
This user control is used throughout the plant and by many developers.
Now we need to use it for the access the warehouse. We must log everyone
that attempted to log into the system and everyone who logs into the
system. I cannot capture this by the control we use, so I created a class
that extends the control and listens for messages. It inherits from the
System.Windows.Forms.NativeWindow object.

I have overridden the WndProc process and raise an event passing out the
System.Windows.Forms.Message. I need to interrupt the message that is
thrown and then log the username that was entered. I can get an ASCII
value using the WParam but it only gives me upper case and freaks out when
the shift key is pressed (usernames can be something like J0hnD03). Does
anyone know how to read this message and see what key was pressed?

Thanks.

John

One the form side, I have the following routine:

Private Const WM_KEYDOWN As System.Int32 = &H100

Private Const WM_KEYUP As System.Int32 = &H101

Private Const WM_SYSKEYDOWN As Integer = &H104

Private Const WM_SYSKEYUP As Integer = &H105

Dim WithEvents abc As Hooked
'Code I need help with
Private Sub abc_CallBackProc(ByVal m As System.Windows.Forms.Message)
Handles abc.CallBackProc

Select Case m.Msg

Case WM_KEYDOWN

TextBox2.Text &= ChrW(m.WParam)

End Select

End Sub


Dec 13 '07 #4


"John Wright" wrote:
First some background:

I have been asked to develop a program that access our data warehouse. It
requires a login and password to use so we created a custom control that is
placed on the form, the user types in their username/password, we validate
then return either true or false. The program hosting the control has no
access to the keydown and keyup events from the control. This user control
is used throughout the plant and by many developers. Now we need to use it
for the access the warehouse. We must log everyone that attempted to log
into the system and everyone who logs into the system. I cannot capture
this by the control we use, so I created a class that extends the control
and listens for messages. It inherits from the
System.Windows.Forms.NativeWindow object.
Capturing who tries to log in should be on the end where the control
connects. Handle it there and not in your client. After all, where are you
going to log it? Logging to the client does not make sense for tracking
hackers.
Dec 13 '07 #5
I guess I was not clear in what I needed to do. The control I was given was
claimed to be hack proof and to keep the credentials of the user safe and
unexcessible to a developer. I wanted to prove my point it was not secure
at all. I created a class to extend the control and was able to intercept
the WndProc messages and I wanted to send them out to a file on the network
for logging to prove a point. However, I found a better way to do this. I
just turned the KeyPreview on and was able to capture the keys strokes sent
to the control. Voila, I was able to capture who logged on. Now I can see
who has tried to access the dataware house and when. This is an auditing
procedure we must follow in our industry due to the data being stored.
Since I was forced to use this control, I "hacked" it to see who was trying
to access the system. I did not log it where the control connects because
a) I don't have access to the server that validates the users and b)Only our
site needs this data.

So problem solved. KeyPreview saved it for me.
Dec 14 '07 #6
"John Wright" <ri***********@hotmail.comwrote in
news:e5*************@TK2MSFTNGP03.phx.gbl:
Voila, I was
able to capture who logged on. Now I can see who has tried to access
the dataware house and when. This is an auditing procedure we must
follow in our industry due to the data being stored. Since I was
forced to use this control, I "hacked" it to see who was trying to
access the system. I did not log it where the control connects
because a) I don't have access to the server that validates the users
and b)Only our site needs this data.
OK, you proved your point that the control is insecure... but that's
trivial since any keylogger could do what you did.

If you believe your type of auditing is secure, you're kidding yourself.
You should really get access to the login reports and generate your audit
logs from those.

Hacking the control to do what you've done is a poor mans solution ... and
hopefully you'll never need to rely on the data ;-)

--
sp**********@rogers.com (Do not e-mail)
Dec 14 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ed Sutton | last post by:
How can a WndProc be created inside a component? Currently I have a WndProc in my frmMain. It looks for WM_DEVICECHANGE messages for connection and removal events for a USB/Serial device. My...
4
by: UmmagummA | last post by:
Some time ago there was post with list of all windows messages for WndProc procedure, but I was stupid enough to lose them :( So if somebody could send this list (with codes) I will be veery happy....
1
by: Max Khitrov | last post by:
Hi there, I realize this is more of a Windows API question then C#, but thought I'd ask anyway just in case anyone had experience with this specifically in C#. What I'm trying to do is read...
0
by: Manfred Braun | last post by:
Hi All, I have a problem reading queue-messages async. My QueueReader has a Start() and a Stop() method and if my app starts, it calls Start(). The problem is, that there are possibly several...
0
by: Anders K. Olsen | last post by:
Hello group Happy New Year to you all. I'm developing a Windows Service that needs to access the messages stored in a Public Folder in Microsoft Exchange. I have been looking into CDO 1.21,...
4
by: Craig Vermeer | last post by:
Hi All, I have a program that's using the file system as a queuing mechanism, and it's consuming an inordinate amount of CPU time when the file system queue gets all that large (any more than a...
3
by: S Wheeler | last post by:
Hi - I have a vc++ WinForms app. Can I override the WndProc so I can send custom messages to my app. Is there any way to do this? I need to notify the main form of events from a library. How is...
1
by: CodeSeeker | last post by:
I have an application, which uses pop3 to read the messages from the mailbox, and it has been working fine for so many year. We recently have started changing this application to use java mail IMAP 4...
4
by: Piotrekk | last post by:
Hi I have overriden WndProc to detect when the key is pressed. Because it didnt work i inserted debug code to detect what messages pass through the WndProc exactly.My application is minimized in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.