flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Solar OS API system

Author
Thread Post new topic Reply to topic
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 11 Dec 2006, 19:00
Hello,

I have a question about Solar OS API system. If the author or someone who is familiar with the OS can help me, I would appreciate it.

As far as I see, the API system of Solar OS works by directly calling a routine in the kernel without passing by interrupt or call gates:

"os_functions_table" (located at 4000h in memory) contains a list of dword addresses of the different API.
Code:
os_functions_table:
        dd      API_CPU_CPUID
        dd      API_Draw_Pixel
        dd      API_Debug_Out_String
        dd      API_Desktop_Get_Addr
...
    


"sol_fasm_inc.asm" contains the absolute addresses of these functions:
Code:
API_CPU_CPUID                   =       4000h
API_Draw_Pixel                  =       4004h
API_Debug_Out_String            =       4008h
API_Desktop_Get_Addr            =       400Ch
...
    


And an example of using this is located in "fasm_sample.asm":
Code:
macro stdcall proc,[arg]
{
        reverse push arg
        common call proc
}
...
        mov     eax,[API_Window_Create]
        stdcall eax ,0,32,32,300,200,0,WND_TYPE_TOP
    


So here's my question: does this kind of system (directly calling a function from kernel space) work in ring3 user mode?

Correct me if I'm wrong, but Windows has a similar API system.

Thanks in advance.
Post 11 Dec 2006, 19:00
View user's profile Send private message Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 557
smiddy 12 Dec 2006, 02:30
I haven't programmed for it in quite a while and never used the API when I did. However, the website is here. Also, I think there is a FASM version that someone has ported. Also, it is expected that there will be a Christmas release coming.
Post 12 Dec 2006, 02:30
View user's profile Send private message Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu 12 Dec 2006, 04:11
ManOfSteel wrote:

Hello,

I have a question about Solar OS API system. If the author or someone who is familiar with the OS can help me, I would appreciate it.


Yes... I am here Wink

ManOfSteel wrote:

As far as I see, the API system of Solar OS works by directly calling a routine in the kernel without passing by interrupt or call gates:


Indeed when applications need an API they do a direct call using the STDCALL calling convention. There is no need for a callgate or an INT because there is no Ring3 to Ring0 transition.

ManOfSteel wrote:

"os_functions_table" (located at 4000h in memory) contains a list of dword addresses of the different API.
Code:
os_functions_table:
        dd      API_CPU_CPUID
        dd      API_Draw_Pixel
        dd      API_Debug_Out_String
        dd      API_Desktop_Get_Addr
...
    




Yes it does ... however this is not exactly related to the subject...

This table exist for helping pure binary external applications (loaded from disk or other device) to find at least a few common API entry points at runtime.

It was designed for very low level and "bare metal" binary applications.

Lately there is a PE loader available in Solar OS. This PE loader can map an executable, relocate and resolve imports of APIs. Hence you can use standard FASM/MASM/TASM/Goasm/etc or even Visual Studio C to generate SolarOS applications.

The table you mention will remain available (in a reduced form) for bare metal binary applications.

ManOfSteel wrote:

"sol_fasm_inc.asm" contains the absolute addresses of these functions:
Code:
API_CPU_CPUID                   =       4000h
API_Draw_Pixel                  =       4004h
API_Debug_Out_String            =       4008h
API_Desktop_Get_Addr            =       400Ch
...
    


And an example of using this is located in "fasm_sample.asm":
Code:
macro stdcall proc,[arg]
{
        reverse push arg
        common call proc
}
...
        mov     eax,[API_Window_Create]
        stdcall eax ,0,32,32,300,200,0,WND_TYPE_TOP
    


So here's my question: does this kind of system (directly calling a function from kernel space) work in ring3 user mode?



Your question is not very clear...

IF you expect to be able to call a RING0 kernel function directly from RING3 then the answer is: NO you can not do that!

You need a valid method of transition from Ring3 to Ring0 (callgate, INT, etc)

Please observe that Solar OS is running all trusted aplications in Ring-0 and because of this there is no need to do a costly ring transition.

However Windows and Linux and many other OS's (including Menuet) do use ring separation and protection and because of this they HAVE TO make ring transitions.

ManOfSteel wrote:

Correct me if I'm wrong, but Windows has a similar API system.

Thanks in advance.


You are wrong. It is a common missconception and myth.

For speed optimizations Windows decided to move many API's into the user space and hence it can indeed make STDCALL "like" calls into DLLs mapped into an application's process memory space.

However when the time comes to do a call into the kernel memory space THEN Windows willl either use an INT (older versions) or use SYSENTER (new versions) to make the ring transition.

As a design choice for Windows: they do try to avoid this transition as much as possible but they do make it when required. Hence the greater speed of Windows ...but lower safety since ring3 API implementations are somehow easyer to abuse.

Linux design choice was to make this transition more offten (at each API by a using an INT) and hence the lower speed of Linux but greater safety.

Solar_OS design is based on a different choice... namely: "TRUST".

I have moved all API and trusted applications into Ring-0... consciently sacrificeing "security" and "fear" and gaining speed and simplicity.

It vaguely resembles Windows choice but only at a very superficial naive look.

As you can now hopefully better understand neither Windows nor Linux will do this for reasons that are easy to understand in an capitalistic world.

However as I have stated before the offending or non trusted applications will be moved into Ring-3 in Solar_OS also.

And by the way ... I hope to have FASM ported and functional into Solar_OS next "christmas" release ...

_________________
"Any intelligent fool can make things bigger,
more complex, and more violent.
It takes a touch of genius -- and a lot of courage --
to move in the opposite direction."
Post 12 Dec 2006, 04:11
View user's profile Send private message Visit poster's website Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 13 Dec 2006, 08:27
Hello,

thank you for your replies.

@ bogdanontanu
Everything is clearer now. And thank you for the clarification about Windows.
I must tell you! SolarOS is impressive. It's indeed really fast and has a magnificent GUI. Keep it up!

@ smiddy
do you know who ported it to fasm or where could I find it?
Post 13 Dec 2006, 08:27
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 26 Dec 2006, 05:42
The official homepage says SolarOS has been updated for Christmas (and gives credit to "Pellailo" for the alleged FASM port). No mention in the web board about FASM being included, only talk about SOL_ASM.

Haven't tried it, too preoccupied with other junk, but I'm sure it works well. Laughing
Post 26 Dec 2006, 05:42
View user's profile Send private message Visit poster's website Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu 26 Dec 2006, 06:40
Well, the FASM port was started but then put on hold until SOL_ASM port was finished . I was not able to port both of them during christmas...

Since that is done, a FASM port to Solar_OS will follow briefly;)
Post 26 Dec 2006, 06:40
View user's profile Send private message Visit poster's website Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias 26 Dec 2006, 10:45
rugxulo wrote:
too preoccupied with other junk,
I know you did not intend to imply that SOL is junk. Very Happy

bogdanontanu wrote:
until SOL_ASM port was finished
, and similarly, I know Bogdan did not intend to convey the notion that his SOL_ASM is finished with this release. Wink
Last I knew, Pelaillo had ceased working on FASM integrated with SOL.
Current release of SOL honestly explains that previously acknowledged missteps have not yet been repaired. I think one demands too much of Bogdan to ask for fixing errors, adding functionality, and integrating FASM, with CLOSED source. I look for NEXT christmas, to offer an unsolicited opinion on the meaning of "briefly":
Bogdan wrote:

a FASM port to Solar_OS will follow briefly
Smile
Post 26 Dec 2006, 10:45
View user's profile Send private message Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo 26 Dec 2006, 14:07
Quote:

Last I knew, Pelaillo had ceased working on FASM integrated with SOL.

I'll give a look at the new SOL release. Following Bogdan comments, there is all functionality already in place for a FASM development environment running on SOL so I am going to finish it.
I just need one condition to be met in order to continue:
bogdan on SOLAR forum wrote:

I have been thinking about it.... and again I have decided to return Solar OS to open source... hopefully forever this time
Post 26 Dec 2006, 14:07
View user's profile Send private message Yahoo Messenger Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias 26 Dec 2006, 15:43
pelaillo wrote:
I just need one condition to be met in order to continue:
Bogdan has addressed your concern here:

http://www.oby.ro/forum/viewtopic.php?p=387#387
Smile
Post 26 Dec 2006, 15:43
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 26 Feb 2007, 20:28
Quote:

Release from 2007_02_15 - open source

* Solar_OS sources (4.368.626 bytes) download
* Solar_OS binary only (183.189 bytes) download


http://www.oby.ro/os/index.html
Post 26 Feb 2007, 20:28
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.