Page 1 of 1

Pointer problems that make my brain bleed

Posted: Sat Nov 30, 2002 12:00 am
by VoidLogic
walk through this with me and tell me whats wrong :(

Background:
-Mode: Real (on a x86)
-OS running: MS-DOS
-Lang. being used: C\C++

Here we go:

1. Program A calls Program B [ System("ProgB.exe"); ]
2. Program B places the pointer to a function in a file
3. Program A gets the pointer, does the aprprite type casting
3. Program A "runs" the pointer
4. The funtion runs "hello world"
5. The computer crashes! instr. flow did not resume after the function call,
   the computer hangs, the Ctr-Alt-Del Intrp. dosn't even work, tear

Help Please fellow programers, my sanity is slipping... and so is my time to complete my shell\OS......ahhhhhhhhh

-VoidLogic

RE:Pointer problems that make my brain bleed

Posted: Sat Nov 30, 2002 12:00 am
by VoidLogic
never mind my gammatical/spelling errors. i'm losing my mind

RE:Pointer problems that make my brain bleed

Posted: Sat Nov 30, 2002 12:00 am
by asm_fool
sir,
  "flow did not resume after the function call"
That could be because of ret or retn (return in c/c++) is missing some where. Check the flow of the function. Up to the prob.exe which is running in program A and calls "hello ...".so ret/retn to the caller should be missing.

RE:Pointer problems that make my brain bleed

Posted: Sat Nov 30, 2002 12:00 am
by VoidLogic
thanks,
the pointer to a funtion called is void,
void (*HelloPtr)(void);

hmm...

-VoidLogic

RE:Pointer problems that make my brain bleed

Posted: Sat Nov 30, 2002 12:00 am
by jamethiel
My best guess is that you're calling a near function through a far pointer, and it's doing a near return and not popping the CS register from the stack.

RE:Pointer problems that make my brain bleed

Posted: Sat Nov 30, 2002 12:00 am
by VoidLogic
so by changing the delcaration to void far(*HelloPtr)(void); will all be well? hmm
if i can get these external function calls to work then i can have my kernel running.. oh yey

thanks for your time,
-VoidLogic

RE:Pointer problems that make my brain bleed

Posted: Sat Nov 30, 2002 12:00 am
by jamethiel
Actually, the problem is more on the function side than the pointer side. You need to declare the -function- as far as well as the pointer.

RE:Pointer problems that make my brain bleed

Posted: Sun Dec 01, 2002 12:00 am
by VoidLogic
Thanx