Solved

longjmp in windows

Posted on 1997-10-14
4
222 Views
Last Modified: 2013-12-03
I have a question concerning longjmp in Windows.

I am using some old DOS code in a Windows 3.1 program and longjump doesn't seem to work the same.

I call setjmp from a C function to store the required information and everything works just fine.  When call LONGJMP(not the same in DOS) from an assembly function I get an exeption 13 error in the LONGJMP code.

I can't find any manual that will help me find the differences between the DOS longjmp and the Windows LONGJMP.
I know that they are different functions but what else should I need to do except call LONGJMP in place of longjmp?
Thanks.

AJ.
0
Comment
Question by:youngs101497
  • 2
4 Comments
 
LVL 3

Expert Comment

by:mirek071497
ID: 1407548
In windows you are not  working in real mode so i think that this is your error. You can found some description about programming in protected and virtual mode at : www.intel.com. You can find there full set of instructions for pentium processors and description about them.

If you need more then ask, however i think so you must be familiar with other processor modes.
Good luck.
0
 
LVL 3

Accepted Solution

by:
Melange earned 100 total points
ID: 1407549
You should check out the Catch and Throw functions. These are 16-bit Win SDK functions that setjmp/longjmp map to.

Now things to consider are that you must NOT jump across message boundaries. In other words, in the same context of a windows message you must fully handle the catch/throw.

If you have visual C++, then check out mfc's afx.h header file. 16-bit MFC uses these functions for its simulated C++ exception handling.

0
 

Author Comment

by:youngs101497
ID: 1407550
I looked into using the Catch and Throw functions.  They will not work with the code I am using.  I don't want to have to rewrite large sections of code to do something that is suposed to work as well in Windows as it does in DOS.

All information I can find says that I can use setjmp and longjmp in a Windows program.

Do you know of any changes in the way which setjmp and long jmp are called?

This program has to work using setjmp and longjmp.  I wish I could use something else, it would just not be efficatious.


Thanks for your help.
0
 
LVL 3

Expert Comment

by:Melange
ID: 1407551
The most important thing to remember is NOT to jump across a windows message. You can't have one global setjmp for the program. Only use it within a specific context.

0

Featured Post

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

Join & Write a Comment

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video discusses moving either the default database or any database to a new volume.

746 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

17 Experts available now in Live!

Get 1:1 Help Now