flat assembler
Message board for the users of flat assembler.

Index > Windows > device driver with fasm

Author
Thread Post new topic Reply to topic
wolf



Joined: 28 Sep 2003
Posts: 11
wolf
hi everybody

I'm trying to compile a device driver scidrive.sys with fasm, using a code skeleton once posted in the masm32 board.

Code:
FORMAT PE native at 10000h
entry DriverEntry

section '.code' code readable writeable executable

proc DriverEntry, DriverObject, RegPath
...
endproc

...
    


Loading this driver I get a Windows Error 0xC0000221 and a Message Box telling me: Can't load driver, the driver is not valid.

Does anybody know, how to write a driver skeleton with fasm?
With masm32 the driver is running ok with the following makeit.bat:
Code:
e:\masm32\bin\ml /c /coff /Ie:\masm32\scidrive scidrive.asm
e:\masm32\bin\LINK e:\masm32\scidrive\scidrive.obj /MERGE:.rdata=.text /MERGE:_PAGE=PAGE /SECTION:INIT,d /OPT:REF /RELEASE /DRIVER /INCREMENTAL:NO /FULLBUILD /FORCE:MULTIPLE /IGNORE:4001,4037,4039,4065,4070,4078,4087,4089 
/FILEALIGN:4096 /PDB:NONE /version:4.00 /osversion:4.00 /entry:DriverEntry@8 /align:0x20 /out:scidrive.sys /base:0x10000 /subsystem:native /LIBPATH:e:\masm32\scidrive 
    



sorry, was a bit sleepy this morning - now I've recognized the existing driver thread. my question is obsolete at the moment.

wolf
Post 28 Sep 2003, 06:31
View user's profile Send private message Reply with quote
Kevin_Zheng



Joined: 04 Jul 2003
Posts: 125
Location: China
Kevin_Zheng
Hi,Wolf:
Please see the link, I think that it will answer your question.
http://board.flatassembler.net/topic.php?t=256&start=30
Post 28 Sep 2003, 15:06
View user's profile Send private message MSN Messenger Reply with quote
wolf



Joined: 28 Sep 2003
Posts: 11
wolf
Thanks a lot Kevin_Zheng - I've rewritten the beep routine a bit:
Timer frequency is in low word and beep duration in milliseconds is in high word of BeepParam
Code:
invoke PsCreateSystemThread,ThreadHandle,THREAD_ALL_ACCESS,0,0,0,BeepThread,02000400h
...
proc BeepThread,BeepParam
     .Interval dq ?
     enter
        invoke KeGetCurrentThread
        invoke KeSetPriorityThread,eax,LOW_REALTIME_PRIORITY + 1

        mov al,0B6h
        out 43h,al
        mov eax,[BeepParam]
        out 42h,al
        mov al,ah
        out 42h,al
        in al,61h
        or al,3
        out 61h,al

        shr eax,16
        btr eax,15
        mov ecx,10000          ; 1 millisecond = 10000*100 nanoseconds 
        xor edx,edx
        mul ecx
        neg eax
        sbb edx,0

        lea ecx,[.Interval]    ; .Interval must be a 64 bit integer value
        mov dword[ecx],eax
        mov dword[ecx+4],edx
        invoke KeDelayExecutionThread,0,0,ecx

        in al,61h
        and al,0FCh
        out 61h,al
        invoke PsTerminateSystemThread,STATUS_SUCCESS
     return
    
The first parameter in the DelayExecution call is either UserMode or KernelMode.
I put in a zero or a one, both worked. But I didn't find any definition for that in ntddk.h
- does anybody know where the definition can be found?
Another matter I'm still trying to figure out:
Is it possible to intercept the timer interrupt with an Interrupt Service Routine in order to get a more precice timing if necessary?
I found out that the thread delay is not really exact. It varies at about 20% of the given value.

wolf
Post 12 Oct 2003, 10:43
View user's profile Send private message 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-2020, Tomasz Grysztar.

Powered by rwasa.