Thread overview
writing windows kernel mode code using D?
Feb 06, 2007
Mike Carifio
Feb 06, 2007
Walter Bright
Feb 06, 2007
Mike Carifio
Feb 06, 2007
Thomas Kuehne
Feb 07, 2007
Walter Bright
Feb 07, 2007
Kyle Furlong
February 06, 2007
Can D be used to write Windows kernel mode code?
Has someone written a tutorial to get started on this?

In particular, I'm looking for a leg up on the port/miniport
remote file system approach on Windows. This is a pretty
difficult place to start learning D, but D also looks to be
uniquely suited to do it.
February 06, 2007
Mike Carifio wrote:
> Can D be used to write Windows kernel mode code?

Sure.

> Has someone written a tutorial to get started on this?

I don't think so. Why not keep a notebook of your explorations on doing this, and later turn it into an article? It could be a valuable contribution.

> In particular, I'm looking for a leg up on the port/miniport
> remote file system approach on Windows. This is a pretty
> difficult place to start learning D, but D also looks to be
> uniquely suited to do it.
February 06, 2007
Walter Bright wrote:
> Mike Carifio wrote:
>> Can D be used to write Windows kernel mode code?
> 
> Sure.
> 

Is that "Sure" as in "Yes, the compiler produces object code that the kernel can link" or "Sure" as in "Sure, why not? Tell us if you run into a wall"?

Would garbage collection work for kernel mode memory management?

>> Has someone written a tutorial to get started on this?
> 
> I don't think so. Why not keep a notebook of your explorations on doing this, and later turn it into an article? It could be a valuable contribution.
> 
>> In particular, I'm looking for a leg up on the port/miniport
>> remote file system approach on Windows. This is a pretty
>> difficult place to start learning D, but D also looks to be
>> uniquely suited to do it.

Sure. As in "Sure, why not? But I'm not very qualified to write something like this."

Thanks.
February 06, 2007
Mike Carifio schrieb am 2007-02-06:
> Walter Bright wrote:
>> Mike Carifio wrote:
>>> Can D be used to write Windows kernel mode code?
>> 
>> Sure.
>> 
>
> Is that "Sure" as in "Yes, the compiler produces object code that the kernel can link" or "Sure" as in "Sure, why not? Tell us if you run into a wall"?

I've implemented a few Linux kernel modules in D.

> Would garbage collection work for kernel mode memory management?

Yes, but the GC works only if it knows where to find potential pointers. Potential problems are the same as those encountered with different GC engines and multiple DLLs.

Thomas

February 07, 2007
Mike Carifio wrote:
> Walter Bright wrote:
>> Mike Carifio wrote:
>>> Can D be used to write Windows kernel mode code?
>>
>> Sure.
>>
> 
> Is that "Sure" as in "Yes, the compiler produces object code that the kernel can link" or "Sure" as in "Sure, why not? Tell us if you run into a wall"?

Anything you can do in C, you can do in D pretty much directly, with the same results.


> Would garbage collection work for kernel mode memory management?

Probably not. But you can use malloc/free. You can use D just as you'd use C.


>>> Has someone written a tutorial to get started on this?
>>
>> I don't think so. Why not keep a notebook of your explorations on doing this, and later turn it into an article? It could be a valuable contribution.
>>
>>> In particular, I'm looking for a leg up on the port/miniport
>>> remote file system approach on Windows. This is a pretty
>>> difficult place to start learning D, but D also looks to be
>>> uniquely suited to do it.
> 
> Sure. As in "Sure, why not? But I'm not very qualified to write something like this."

The best way to get qualified is to just do it.
February 07, 2007
Walter Bright wrote:
> Mike Carifio wrote:
>> Walter Bright wrote:
>>> Mike Carifio wrote:
>>>> Can D be used to write Windows kernel mode code?
>>>
>>> Sure.
>>>
>>
>> Is that "Sure" as in "Yes, the compiler produces object code that the kernel can link" or "Sure" as in "Sure, why not? Tell us if you run into a wall"?
> 
> Anything you can do in C, you can do in D pretty much directly, with the same results.
> 
> 
>> Would garbage collection work for kernel mode memory management?
> 
> Probably not. But you can use malloc/free. You can use D just as you'd use C.
> 
> 
>>>> Has someone written a tutorial to get started on this?
>>>
>>> I don't think so. Why not keep a notebook of your explorations on doing this, and later turn it into an article? It could be a valuable contribution.
>>>
>>>> In particular, I'm looking for a leg up on the port/miniport
>>>> remote file system approach on Windows. This is a pretty
>>>> difficult place to start learning D, but D also looks to be
>>>> uniquely suited to do it.
>>
>> Sure. As in "Sure, why not? But I'm not very qualified to write something like this."
> 
> The best way to get qualified is to just do it.

Having written part of a working kernel in D, I can say that low level programming in D compared to C is an order of magnitude better. Modules, fast and easy compilation, DbC, and all the rest makes this sort of programming less tiresome and more productive. All we needed other than D was an asm boot loader. I might even go so far to say that its a BAD thing, because dangerous code (i.e. kernel level code) shouldn't be easy to write.

That said, we never got to the step of getting the gc up and running (mainly for lack of a memory subsystem :D), so I cant comment on that portion of the question.