Pointer problems that make my brain bleed

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
VoidLogic

Pointer problems that make my brain bleed

Post 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
VoidLogic

RE:Pointer problems that make my brain bleed

Post by VoidLogic »

never mind my gammatical/spelling errors. i'm losing my mind
asm_fool

RE:Pointer problems that make my brain bleed

Post 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.
VoidLogic

RE:Pointer problems that make my brain bleed

Post by VoidLogic »

thanks,
the pointer to a funtion called is void,
void (*HelloPtr)(void);

hmm...

-VoidLogic
jamethiel

RE:Pointer problems that make my brain bleed

Post 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.
VoidLogic

RE:Pointer problems that make my brain bleed

Post 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
jamethiel

RE:Pointer problems that make my brain bleed

Post 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.
VoidLogic

RE:Pointer problems that make my brain bleed

Post by VoidLogic »

Thanx
Post Reply