flat assembler
Message board for the users of flat assembler.

Index > Windows > Drivers for 98/2000

Goto page Previous  1, 2, 3, 4  Next
Author
Thread Post new topic Reply to topic
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
Here maybe this is clean example? Run "scm.exe beeper.sys"

Code:
macro syslibrary [name,string]
 { forward
    local _label
    if ~ name#.needed
    dd RVA name,0,0,RVA _label,RVA name
    end if
   common
    dd 0,0,0,0,0
   forward
    if ~ name#.needed
    _label db string,0
    end if }    


Description:
Download
Filename: beeper.zip
Filesize: 5.55 KB
Downloaded: 292 Time(s)


_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 16 Oct 2003, 04:12
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Kevin_Zheng



Joined: 04 Jul 2003
Posts: 125
Location: China
Kevin_Zheng
Dear All:
Why the returned value of DriverEntry is C000182H? Since standard WDM driver programmer guide, the return value should be 0. So I used 0 as return vaule. And then found the driver can't load more one. The error code is 1072. From MSDN, the error code is ERROR_SERVICE_MARKED_FOR_DELETE.

And others, I used MASM for building the same as driver and returned value is zero, the driver can load more one and worked OK.
Who known the reason about the result? I guest that it maybe FASM doesn't support fully sys file format.
Post 28 Oct 2003, 11:31
View user's profile Send private message MSN Messenger Reply with quote
Kevin_Zheng



Joined: 04 Jul 2003
Posts: 125
Location: China
Kevin_Zheng
Hi,Privalov:
I have known the answer about the fasm doesn't support finally WDM sys
format. Because the FASM set the DllCharacteristics of OptionHeader is 0000H, But the WDM file should be 2000H . I modifed the value and recaluate the checksum. The driver runed OK.
Please see the web site for the description :
Code:
DllCharacteristics 
DLL characteristics of the image. The following values are defined. Value Meaning 
0x0001 Reserved 
0x0002 Reserved 
0x0004 Reserved 
0x0008 Reserved 
0x2000 A WDM driver.     

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/image_optional_header_str.asp
Post 28 Oct 2003, 15:39
View user's profile Send private message MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7750
Location: Kraków, Poland
Tomasz Grysztar
OK, fixed it (check the latest prerelease on this board). I was misguided by the fact, that none of WDM drivers I've found on my system actually have this flag set... Confused
Post 28 Oct 2003, 16:06
View user's profile Send private message Visit poster's website Reply with quote
ProgramMan



Joined: 25 Jan 2004
Posts: 5
ProgramMan
Greetings to all.
I write through PROMT. Sad
How to establish the control over file system, using the driver (*.sys)
It is possible with examples. Arrow
Post 28 Jan 2004, 07:41
View user's profile Send private message ICQ Number Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2936
Location: vpcmipstrm
bitRAKE
Post 03 Feb 2004, 05:46
View user's profile Send private message Visit poster's website Reply with quote
ProgramMan



Joined: 25 Jan 2004
Posts: 5
ProgramMan
Also what?
How to establish the control over file system, using the driver (*.sys)
It is possible with examples.
Post 08 Feb 2004, 11:34
View user's profile Send private message ICQ Number Reply with quote
Ralph



Joined: 04 Oct 2003
Posts: 86
Ralph
Hey,

I've been desperatly trying to get anything to assemble here, without any luck. All the examples provided here either error out with "unexpected end of file" or some macro error. Additionally %include% doesn't seem to work for me. I have to use absolute path names. I managed to patch together a version that assembled, but the .sys failed to load. I tried using fasm 1.52 for windows console as well as GUI, both produce the same errors.
I hate to ask something like this, but could anyone please provide me with a concise version that actually assembles or maybe tell me how to make these assemble?

This is the code I was trying to work with, it assembles but it wont load:

Code:
format PE DLL native 4.0 at 10000h
entry Start

include 'C:\tools\fasmw\INCLUDE\win32a.inc'     ;%include& doesn't work

section '.text' code readable executable notpageable
proc Start,pDriverObject,pusRegistryPath
        enter
        cli
        ; speaker ON
        in      al,61h
        or      al,11b
        out     61h,al
        sti
        mov     ecx,18000000h
@@:     loop    @B
        cli
        ; speaker OFF
        in      al,61h
        and     al,11111100b
        out     61h,al
        sti
.hal:   stdcall [imp_HalMakeBeep],1568
        mov     ecx,18000000h
@@:     loop    @B
        stdcall [imp_HalMakeBeep],0
.quit:  mov     eax,0C0000182h
        return
endp   ;i need this or else i get an unexpected end of file error

section '.rdata' readable notpageable

;data 12    ;this errors out with "symbol already defined", and I have no idea what 'data' does

  ImportLookup:
        dd rva szRead_port_uc
        dd rva szWrite_port_uc
        dd rva szHalmakebeep
        dd 0

;end data

section 'INIT' import readable notpageable   

        dd rva FirstThunk
        dd 0
        dd 0
        dd rva szHal_dll
        dd rva FirstThunk
        times 5 dd 0

FirstThunk:
        imp_READ_PORT_UCHAR         dd rva szRead_port_uc
        imp_WRITE_PORT_UCHAR        dd rva szWrite_port_uc
        imp_HalMakeBeep             dd rva szHalmakebeep
                                    dd 0

szHalmakebeep     dw 0
                  db 'HalMakeBeep',0
szRead_port_uc    dw 0
                  db 'READ_PORT_UCHAR',0
szWrite_port_uc   dw 0
                  db 'WRITE_PORT_UCHAR',0

szHal_dll db 'HAL.dll',0

section '.reloc' data fixups readable discardable    
    


Last edited by Ralph on 16 Apr 2004, 05:29; edited 1 time in total
Post 16 Apr 2004, 05:03
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
get old includes

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 16 Apr 2004, 05:23
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Ralph



Joined: 04 Oct 2003
Posts: 86
Ralph
Thanks. What version and where can I get them? Why wouldn't the new includes work? Is there a way to make them work? Any idea why %include% doesn't work?
Post 16 Apr 2004, 05:33
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7750
Location: Kraków, Poland
Tomasz Grysztar
The "data already defined" problem that occured on "data 12" directive is the bug - please download the updated 1.52 release (with 16 April date) which have it fixed. It's very strange noone noticed it earlier, as this bug seems to occur in all the releases since 1.50.

As for the %include%, it is also relict of old releases, later it was replaced with %fasminc% to avoid conflict of system variables. After setting up your FASMINC environment variable correctly (check the section 1.1.1 of FASM.PDF) just replace %include% with %fasminc% and it should work. The "endp" addition at the end of each procedure is also necessary due to some changes in the latest version of includes (look here for more info).

Also, the INCLUDE variable is since 1.52 release recognized by fasm in the same way, as by the most of command line compilers - as a list of semicolon-separated paths where to search for includes that have no absolute path specified and cannot be found in current directory. So use of the %include% would no longer make any sense.

As a summary, this is how your source should look like:
Code:
format PE DLL native 4.0 at 10000h
entry Start

include '%fasminc%\win32a.inc'

section '.text' code readable executable notpageable

proc Start,pDriverObject,pusRegistryPath
        cli
        ; speaker ON
        in      al,61h
        or      al,11b
        out     61h,al
        sti
        mov     ecx,18000000h
@@:     loop    @B
        cli
        ; speaker OFF
        in      al,61h
        and     al,11111100b
        out     61h,al
        sti
.hal:   stdcall [imp_HalMakeBeep],1568
        mov     ecx,18000000h
@@:     loop    @B
        stdcall [imp_HalMakeBeep],0
.quit:  mov     eax,0C0000182h
        return
endp

section '.rdata' readable notpageable

data 12

  ImportLookup:
        dd rva szRead_port_uc
        dd rva szWrite_port_uc
        dd rva szHalmakebeep
        dd 0

end data

section 'INIT' import readable notpageable

        dd rva FirstThunk
        dd 0
        dd 0
        dd rva szHal_dll
        dd rva FirstThunk
        times 5 dd 0

FirstThunk:
        imp_READ_PORT_UCHAR         dd rva szRead_port_uc
        imp_WRITE_PORT_UCHAR        dd rva szWrite_port_uc
        imp_HalMakeBeep             dd rva szHalmakebeep
                                    dd 0

szHalmakebeep     dw 0
                  db 'HalMakeBeep',0
szRead_port_uc    dw 0
                  db 'READ_PORT_UCHAR',0
szWrite_port_uc   dw 0
                  db 'WRITE_PORT_UCHAR',0

szHal_dll db 'HAL.dll',0

section '.reloc' data fixups readable discardable    

(compile it with the updated fasm 1.52)
Post 16 Apr 2004, 11:56
View user's profile Send private message Visit poster's website Reply with quote
Ralph



Joined: 04 Oct 2003
Posts: 86
Ralph
Great, thanks a lot. I got it working. One more quick thing I noticed though: While working on this, I called it test.sys, which would not load. To make it load, all I had to do is rename test.sys to any other file name (beep.sys, blah.sys, f00.sys, etc) and it worked. Since there is no reference to the filename inside the .sys file, I'm assuming it's because a service called test already exists, is reserved or something along those lines?
Post 16 Apr 2004, 18:02
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
What "data 12" means? I can't find the documentation of that
Post 22 May 2006, 14:45
View user's profile Send private message Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 382
Location: Finland
okasvi
who knows, datadirectory nr. 12? no i think it's assembler-stage directive to tell assembler that IMAGE_IMPORT_DESCRIPTOR is there, or? anyway, library/import macros work inside separate import section now with drivers...
Post 22 May 2006, 23:42
View user's profile Send private message MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7750
Location: Kraków, Poland
Tomasz Grysztar
Yes, it's data directory no. 12.
manual, section 2.4.2 wrote:
"data" directive begins the definition of special PE data, it should be followed by one of the data identifiers ("export", "import", "resource" or "fixups") or by the number of data entry in PE header.

And thus "data 0" is the same as "data export", "data 2" is the same as "data resource" etc. There are 16 data directories in standard PE, and since only few of them have symbolical names in fasm, you have to use the raw numbers for the other ones.
Post 23 May 2006, 00:11
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Thanks!!Very Happy
Post 23 May 2006, 01:49
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
tomasz: update the example, there are old macros used

and due to thread name: is this right place? Aren't VxD drivers for 98/2000 and WDM for latter ones?
Post 03 Aug 2006, 12:06
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7750
Location: Kraków, Poland
Tomasz Grysztar
VxD are for 95/98/Me line, while KMD and WDM are for NT/2000/XP line.
Post 03 Aug 2006, 15:59
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
@Tomasz: Are the 16 not standardized or are there other reasons you left then unnamed? For completness it would be nice to have them.
Post 03 Aug 2006, 16:29
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7750
Location: Kraków, Poland
Tomasz Grysztar
I just don't want more reserved words. The ones like "import" or "fixups" were left just for compatibility, even though we could change to define them as equates instead.
Post 03 Aug 2006, 17:08
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:  
Goto page Previous  1, 2, 3, 4  Next

< 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. Also on YouTube, Twitter.

Website powered by rwasa.