• C

TSR Guru needed

I have writen a TSR for DOS that displays the current files is use. This is done by traversing the DOS Systems File Table the pointer to which can be retrieved by an INT 21,34 call.
When the Hot Key is detected I need to build my own Stack for the TSR's local variables and functions. Otherwise it will use the foreground program's Stack and the results would be very unpredictable. I achive this with the following code.
1. _asm
2. {
3.    mov ss_register, ss
4.    mov sp_register, sp
5.    mov ax, offset my_stack[499]
6.    mov sp, ax
7.    mov ax, ds
8.    mov ss, ax
9. {
in line 3 & 4 i save the SS and SP in to my own variables. and in line 5 & 6 I move the SP to the top of my newly built Stack (my_stack). My doubt hear is that my_stack is a global variable. Hence I am actually creating this Stack in the Data Segment.
* Firstly is their any problems in doing this??

As to the size of the Stack I allocated 500 bytes taking into account the following local variables and one function which I am using in the code that uses this Stack.
    struct table_tag {
                        struct table_tag * table_previous;
                        struct table_tag * table_next;
                        long int _far * table_sft;
                        int table_sft_entries;
                     };
    typedef struct table_tag * TABLE_POINTER;
    TABLE_POINTER current_table, previous_table,          first_table;
    char * save_screen;
    char page_entry[21];
    long int _far * current_sft;
    char _far * table_sft_file;
    char _far * video_position;
    int no_of_elements, no_of_pages, page_tag_element,         general_counter,general2_counter;
    int table_sft_counter, key_press, key_scan,         element_counter;
/* and the function */
PaintPicture()
{
    int general_counter, general2_counter;
    char _far * video_position;
* Is 500 bytes adequet for these variables and one function??

I am using MS C ver 7. When I call the TSR through the Hotkey, the routine pops us and works fine. But when I exit the routine I get a runtime error "Stack Overflow" and the foreground program terminates to the DOS prompt. I cannot run any more programs thereafter. The COMMAND interpertor gives "Program too big" even for the simple MEM program. When I compile without Code Optimization and without Stack Probes, the program simply hangs along with the OS.

What is wrong in what I am doing? and how could I solve this problem?
Any help would be much apreciated.
ravipalAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
laeuchliConnect With a Mentor Commented:
the site :http://www.fys.ruu.nl/~faber/Amain.html has lots of stuff on tsrs. Take a look.

0
 
scrapdogCommented:
Did you restore the SS and SP to it's original values (in ss_register and sp_register) when the program finishes?
0
 
ravipalAuthor Commented:
Hi scrapdog,

Yes I did restore the SS and SP, with the following code.

    _asm
    {
        mov ss, ss_register
        mov sp, sp_register
    }

0
Managing Security & Risk at the Speed of Business

Gartner Research VP, Neil McDonald & AlgoSec CTO, Prof. Avishai Wool, discuss the business-driven approach to automated security policy management, its benefits and how to align security policy management with business processes to address today's security challenges.

 
ravipalAuthor Commented:
One more thing I fogot to mension. In side my routine I am building a Link List to link all the individual DOS System File Tables into one. For this I use the runtime function "maclloc".

Could their be any problem in using this function in side my TSR routine ??
0
 
ravipalAuthor Commented:
Hi Scrapdog,

I am still waiting for your response...


0
 
scrapdogCommented:
Beats me...you probably know more than I do about TSRs!!

I was just checking if you restored SS and SP, because I know if you didn't that would cause problems.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.