Capturing Text / Telnet Client

Just starting out? Need help? Post your questions and find answers here.
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Capturing Text / Telnet Client

Post by Xombie »

I've got a telnet program (SmarTerm) that my company uses. I was wondering about monitoring and periodically capturing text from the program without user interaction and without interrupting their work in the program. Basically I want to make an assistant program that can give them additional information based on what screen their in at the time.

A did a window/child window output of the main program and got this:

Code: Select all

19334394   59648      MDIClient   1163   673
7210672   65280   Session.stw   SmarTermClassSCO0   1171   700
6358916   59648      AfxFrameOrView42   1159   669
3409596   0   SocketTelnet   SocketTelnet   0   0
6031170   59419      AfxControlBar42   1159   0
4392938   59422      AfxControlBar42   1159   0
3868628   59420      AfxControlBar42   0   669
7669534   59421      AfxControlBar42   0   669
3409578   59392      AfxControlBar42   1159   0
3081504   59393      Afx:400000:8:10011:10:0   1189   17
1180898   59419   Standard   AfxControlBar42   1189   39
3605804   59392   Standard   Afx:400000:8:10011:10:0   708   39
1311788   59422      AfxControlBar42   1189   0
1180704   59420   Control Bar   AfxControlBar42   0   719
18154958   256   Control Bar   AfxWnd42   0   0
7603702   59648      Afx:400000:0:10011:6:0   0   0
2426528   60160      AfxWnd42   0   0
1312418   59920      ScrollBar   16   1
6424052   59904      ScrollBar   1   16
13698444   60161      AfxWnd42   0   0
6162020   59920      ScrollBar   16   1
6423960   59904      ScrollBar   1   16
6686124   60162      AfxWnd42   0   0
11863556   59920      ScrollBar   16   1
7341450   59904      ScrollBar   1   16
1312414   60163      AfxWnd42   0   0
5441140   59920      ScrollBar   16   1
2950706   59904      ScrollBar   1   16
3409332   60164      AfxWnd42   0   0
10618450   59920      ScrollBar   16   1
9438618   59904      ScrollBar   1   16
10683910   60165      AfxWnd42   0   0
6489578   59920      ScrollBar   16   1
23135634   59904      ScrollBar   1   16
1246246   59421      AfxControlBar42   0   719
The two items of interest seem to be the Session.stw/SmarTermClassSCO0 and SocketTelnet/SocketTelnet windows. GetWindowText_() on either of these doesn't, of course, return the actual display text.

In fact, I'm thinking the displayed text may simply be painted text rather than pure text and that would pretty much mean I'm out of luck.

The user does have the ability (within the program) to select the current screen and copy it to the clipboard. I cannot/will not do a SendKeys() to replicate this as it would interrupt what the user is doing.

If I could get a hook into the telnet stream I could parse it for what I need but I'm not sure where to start there.

Any thoughts on this?
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Re: Capturing Text / Telnet Client

Post by dagcrack »

Scan the program's memory for static locations, specifically anything pointing toward the data buffer. If they don't update this tool regularly, you won't have anything to worry about. And since you do have "physical" access to the program, this is indeed a suitable solution.

You could start by learning about ReadProcessMemory(); at MSDN.

Cheers.
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Re: Capturing Text / Telnet Client

Post by Xombie »

That's a good idea, dagcrack. I'll dig around at MSDN.

Thanks!
jamba
Enthusiast
Enthusiast
Posts: 144
Joined: Fri Jan 15, 2010 2:03 pm
Location: Triad, NC
Contact:

Re: Capturing Text / Telnet Client

Post by jamba »

how hard would it be to replace the telnet client with a pb program that communicates over the network, sending and receiving and printing this information?

well...that may be a lot more work than just getting the information from that existing program.

By the way, I was just digging around on here and found some code you wrote a year or so ago to send and receive telnet commands...very awesome! just what I am currently needing to do.
-Jon

Fedora user
But I work with Win7
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Re: Capturing Text / Telnet Client

Post by Xombie »

@jamba - unfortunately that's just not possible and I wouldn't want to be responsible for something going wrong with the program. Glad the old code works for you. I still work with a modified version of it and it's made things a lot easier for some scripting tasks.

I don't look forward to messing around and trying to grab memory information :)
Post Reply