The MASM Forum Archive 2004 to 2012

Specialised Projects => Compiler Based Assembler => Pelle's C compiler and tools => Topic started by: shlomok on April 03, 2012, 08:43:52 PM

Title: Using Pelle's c for generating kernel mode device drivers (e.g. .sys)
Post by: shlomok on April 03, 2012, 08:43:52 PM
Hi,
I just moved from using RadASM and MASM32 to Pelle's c IDE. The single reason for doing so is the integrated debugger that is shipped with Pelle's c and is a pleasure to work with.

Now, I am using the Kernel Mode Driver Development Kit for MASM32 programmers (http://www.freewebs.com/four-f/) and with RadASM its very easy to set the target as a .sys file (and not an exe).

How do I do that in Pelle's c IDE?

Please see the attached screen-shots.

Thanks,

SK.

Title: Re: Using Pelle's c for generating kernel mode device drivers (e.g. .sys)
Post by: qWord on April 03, 2012, 09:21:16 PM
subsystem = native  :U
Title: Re: Using Pelle's c for generating kernel mode device drivers (e.g. .sys)
Post by: shlomok on April 03, 2012, 09:44:59 PM
Quote from: qWord on April 03, 2012, 09:21:16 PM
subsystem = native  :U

Thanks but it is still generating an EXE and not  SYS, see:

> poasm.exe -AIA32 -Zi -Gd  -Fo"C:\Users\bim\Documents\Pelles C Projects\test345\output\test.obj" "C:\Users\bim\Documents\Pelles C Projects\test345\test.asm"
Building test345.tag.
> polink.exe -debug -debugtype:coff -subsystem:native -machine:x86 kernel32.lib advapi32.lib delayimp.lib -out:"C:\Users\bim\Documents\Pelles C Projects\test345\test345.exe" "C:\Users\bim\Documents\Pelles C Projects\test345\output\test.obj"

Title: Re: Using Pelle's c for generating kernel mode device drivers (e.g. .sys)
Post by: qWord on April 03, 2012, 10:01:10 PM
it is the same option as for link.exe:  /DRIVER
You have take a look in the documentation before asking? :wink

qWord
Title: Re: Using Pelle's c for generating kernel mode device drivers (e.g. .sys)
Post by: clive on April 04, 2012, 02:30:10 AM
Quote from: shlomok on April 03, 2012, 09:44:59 PM
Thanks but it is still generating an EXE and not  SYS, see:

> poasm.exe -AIA32 -Zi -Gd  -Fo"C:\Users\bim\Documents\Pelles C Projects\test345\output\test.obj" "C:\Users\bim\Documents\Pelles C Projects\test345\test.asm"
Building test345.tag.
> polink.exe -debug -debugtype:coff -subsystem:native -machine:x86 kernel32.lib advapi32.lib delayimp.lib -out:"C:\Users\bim\Documents\Pelles C Projects\test345\test345.exe" "C:\Users\bim\Documents\Pelles C Projects\test345\output\test.obj"

The -out option is wrong, and you're not going to be able to use kernel32, advapi32 or delayimp because they won't be available to you in kernel mode.
Title: Re: Using Pelle's c for generating kernel mode device drivers (e.g. .sys)
Post by: shlomok on April 04, 2012, 04:46:54 AM
Quote from: clive on April 04, 2012, 02:30:10 AM
The -out option is wrong, and you're not going to be able to use kernel32, advapi32 or delayimp because they won't be available to you in kernel mode.

I used the IDE to create a new "win 32 console application" so you are right, the out option is wrong and was generated automatically by the IDE.
This is what i am trying to change since there is no template for creating drivers under this IDE.
Title: Re: Using Pelle's c for generating kernel mode device drivers (e.g. .sys)
Post by: clive on April 04, 2012, 06:14:28 AM
I always used MSVC, MASM and NMAKE, and then debugged with SoftICE loaded real early in the boot process. Some how I don't think the IDE debugger is going to be much use to you.
Title: Re: Using Pelle's c for generating kernel mode device drivers (e.g. .sys)
Post by: shlomok on April 04, 2012, 06:59:34 AM
Quote from: clive on April 04, 2012, 06:14:28 AM
I always used MSVC, MASM and NMAKE, and then debugged with SoftICE loaded real early in the boot process. Some how I don't think the IDE debugger is going to be much use to you.

Hi,
When writing Assembly code under MSVC, the syntax highlighting and code completion is very limited even with the latest plugin.

I am using Dbgview.exe which intercepts messages generated by a device driver, at this stage SoftIce is not that useful to me though it is an indispensible tool.

You are right that the IDE debugger is useless for debugging drivers, but the driver will be shipped with a GUI to send messages to the driver for configuration purposes and the GUI can be debugged with Pelles IDE.

So what is the bottom line, is there a way that I can create my own template under Pelles so that the -out\ option is set to SYS and not EXE?


Thanks,