Solved

Plink beeps

Posted on 2010-09-23
12
806 Views
Last Modified: 2012-06-22
Hi Folks, this is driving me bananas..

I'm trying to find the bit of code within the PLINK source code that makes the terminal beep. Its turning out to be surprisingly hard to find. The whole thing is multithreaded so you can't just step thru until you hear the beep. With the full PUTTY compile, there's UI options to turn beep on and off, and the code relating to the settings is visible in the plink and putty projects, but I can't for the life of me find where the line of code is that actually does the beep.

I'm compiling for windows 2003 under C++ VS 2005

I'm guessing its probably an escape sequence sent to stdout to do a beep, as I can't see any win api beep calls in there ? But finding it is clearly way beyond my capability !

Source code is here http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Any ideas what I should be searching for ? or can you find it for me ????

thanks
0
Comment
Question by:plq
  • 7
  • 5
12 Comments
 
LVL 30

Expert Comment

by:Zoppo
Comment Utility
Hi plg,

I'm not really sure (since I didn't compile the code and test it) but I guess the code is in 'Terminal.c' in function 'static void term_out(Terminal *term)' near line 2754 starting with this line:

> case '\007':          /* BEL: Bell */

The '\007' indicates the ASCII code BEL (bell).

Hope that helps,

ZOPPO
0
 
LVL 8

Author Comment

by:plq
Comment Utility
Hmmm. Interesting.

terminal.c isn't in the plink.vcproj project, which compiles and runs fine, and does do beeps.

however it is in the putty.vcproj project, which compiles and runs fine, but doesn't do beeps even when I tell it to in the UI  !!!!

Well you've given me a clue anyway..
0
 
LVL 8

Author Comment

by:plq
Comment Utility
it seems to beep in a separate thread dedicated to terminal output, on line 280 of winhandl.c (WriteFile), the buffer contains the plink command prompt, and I guess an escape sequence which forms the beep is within that buffer...

Here's the mem dump of the buffer..

0x009BCFA4  61 6e 61 63 6f 6e 64 61 2d 6b 73 2e 63 66 67 20 20 73 64 0d 0a 1b 5d 30 3b 72 6f 6f 74 40 44 45 56 30 33 46 44 56 2d 46 45 44 4f 52 41 3a 7e 07 5b  anaconda-ks.cfg  sd...]0;root@DEV03FDV-FEDORA:~.[

0x009BCFD5  72 6f 6f 74 40 44 45 56 30 33 46 44 56 2d 46 45 44 4f 52 41 20 7e 5d 23 20 cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd  root@DEV03FDV-FEDORA ~]# ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ

0x009BD006  cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd  ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
0
 
LVL 30

Expert Comment

by:Zoppo
Comment Utility
Hm - maybe it gets called via 'from_backend' (i.e. in 'Windows.c') which calls 'term_data' which calls 'term_out'.

But up to now I have no idea where the data comes from which is passed to 'from_backend' ...
0
 
LVL 30

Accepted Solution

by:
Zoppo earned 500 total points
Comment Utility
Yes, this could be right - I guess the '07' in the first line is the 'BEL' char ...
0
 
LVL 8

Author Comment

by:plq
Comment Utility
I'm there in debug mode, and its called direct from kernel32.dll, with no upstream callers shown. So its some kind of callback infrastructure where the kernel has received a function pointer to handle_output_threadfunc. The functions you list might allow me to catch where the beep gets put in though. Catching it in handle_output_threadfunc is a bit late I suppose. Let me do some messing around with the debugger...
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 8

Author Comment

by:plq
Comment Utility
>>Yes, this could be right - I guess the '07' in the first line is the 'BEL' char ...
OK I can edit that out with the immediate window... will report back in a while
0
 
LVL 8

Author Comment

by:plq
Comment Utility
Yay I made it a 32 instead of an 07, and it doesn't beep now ! thats pretty cool. An awful hack though. I'll report back later if I can find where that 07 originates from
0
 
LVL 8

Author Closing Comment

by:plq
Comment Utility
A simple loop through the ctx->buffer to replace 7 with 32 did the job nicely.
0
 
LVL 30

Expert Comment

by:Zoppo
Comment Utility
Fine, that's great ...

Have a nice day,

best regards,

ZOPPO
0
 
LVL 8

Author Comment

by:plq
Comment Utility
OMG I forgot to say... THANK YOU !.. cheers
0
 
LVL 30

Expert Comment

by:Zoppo
Comment Utility
:o)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now