Call gates!

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
Blue Sky

Call gates!

Post by Blue Sky »

Its been a few years now since I have been doing any serious assembly language programing and I was wondering if anybody could help me. Is it possible when using a call gate for either the LDT or GDT to use a register as the descriptor index.
Thamks for your time :)

Note I have looked through intel documention(briefly) and it seems to give no clues....
Tim

Re:Call gates!

Post by Tim »

By the sounds of it, you want to be able to call a call gate but branch to different descriptors based on the value of a register. An individual call gates can only occupy one descriptor, and it can only point to one segment:offset location.

Assuming descriptor 28h is a call gate, an instruction such as:

CALL 28:1234

will always branch to the same location, regardless of the offset. However, the call gate handler could disassemble the FAR CALL instruction which invoked it and read the offset as a function index.
Blue Sky

Re:Call gates!

Post by Blue Sky »

The idea behind what I'am trying to do is when a program starts it obtains the call gates descriptors based on the functions that the program will use (the ones for the O/S will probaly be static but user modules will problay be different evertime the O/S is run) I want to avoid the table fixes at the start.

I think the "example" code could explain things...


.data
@function1 dw ?
@function1name db "justsomefunctionname"
.code
@start mov si,ptr function1name
callgate 1:[ffffffff] ;obtain function location O/S call

mov [function1],eax

.....

when the user needs to make a call.

mov eax,[function1]
callgate ax:[ffffffff]

I hope this explains it much better. Thanks for any input ;D
Tim

Re:Call gates!

Post by Tim »

For a start, that's not going to assemble (apart from the fact that you need to use the CALL instruction, not 'callgate'); you can't do a far JMP to a selector specified by a register. The [xxx] notation is suspect, too; it looks like an indirect call (the normal syntax would be 1:FFFFFFFF). Also, 1 isn't a valid selector (but that's just a detail).

Anyway, there's nothing to stop you writing code in the handler for the call gate which looks at, say, the EAX register and branches appropriately. But the CPU isn't going to do it for you automatically.
Post Reply