Freebasic Driver Programming

Windows specific questions.
Post Reply
Username
Posts: 30
Joined: Jun 22, 2020 5:56

Freebasic Driver Programming

Post by Username »

Can i make windows drivers with freebasic?
adeyblue
Posts: 299
Joined: Nov 07, 2019 20:08

Re: Freebasic Driver Programming

Post by adeyblue »

Not practically. None of the kernel mode headers have been translated (though the libs are provided), and you can't use anything that requires the fb runtime. That includes basic things like simply declaring (much less actually using) string variables. Even then, with -nodeflibs, you'd need a different piece of startup code since the provided one is for user mode.

So technically possible, but plenty of large hoops to jump through to get there.
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: Freebasic Driver Programming

Post by exagonx »

Username wrote:Can i make windows drivers with freebasic?
Device drivers are typically written in C, using the Driver Development Kit (DDK).
There are functional and object-oriented ways to program drivers, depending on the language chosen to write in.
It is generally not possible to program a driver in Visual Basic or other high-level languages like FreeBASIC .
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: Freebasic Driver Programming

Post by caseih »

FB is not Visual Basic. FB is closer to C, and can access anything that C can. If one translated the DDK header files to FB, there's absolutely no reason why you couldn't use FB to do that. However you'd probably want to use just the subset of FB features that translate 1:1 to C. No dynamic strings, no arrays, etc. Nothing from the FB runtime library.
exagonx
Posts: 314
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: Freebasic Driver Programming

Post by exagonx »

caseih wrote:FB is not Visual Basic. FB is closer to C, and can access anything that C can. If one translated the DDK header files to FB, there's absolutely no reason why you couldn't use FB to do that. However you'd probably want to use just the subset of FB features that translate 1:1 to C. No dynamic strings, no arrays, etc. Nothing from the FB runtime library.
You are right caseih, I also created a library that allowed me to control a card on the parallel port, but I had to write most of the code in assembler language, it's okay to say that I used freeBASIC but I hardly wrote anything in freeBASIC , although lately FreeBASIC tends to look like GCC.

However, with windows it's another thing, to be able to do many things I had to include libraries written in C because writing a header in FreeBASIC that did the same things was too expensive and complicated (at least for me)
marcov
Posts: 3454
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: Freebasic Driver Programming

Post by marcov »

exagonx wrote:
Username wrote:Can i make windows drivers with freebasic?
Device drivers are typically written in C, using the Driver Development Kit (DDK).
There are functional and object-oriented ways to program drivers, depending on the language chosen to write in.
It is generally not possible to program a driver in Visual Basic or other high-level languages like FreeBASIC .
Note also that afaik you need to develop for the (native)NT target, iow, no win32 (user32,kernel32) or libraries that depend on that (like msvcrt). The C backend thus also would have to work with a non gcc compiler (or the GAS port needs an additional target)

Maybe if you can go through the DDK's native NT C compiler you can workaround platform support, but you might also need to reduce the RTS for that. Some calls from those libs might also be available in NTDLL though.

Most of this knowledge is very old (2007 based on older (2003) SDKs), I also mostly only read about it in threads on a forum, never tried myself. Maybe MS has made it easier meanwhile.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Freebasic Driver Programming

Post by D.J.Peters »

FreeBASIC created DLL's run only in user space (totaly different virtual address space)
so the answer is simple "NO"
you can't write driver for current Windows OS with FreeBASIC.

here are a MIDI driver I wrote long time ago in FreeBASIC: viewtopic.php?f=6&t=16853&p=147979


Joshy
Post Reply