Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Network Access...

Status
Not open for further replies.

adholioshake

Programmer
Feb 9, 2003
136
Does anyone know how to access remote sources low-level style in assembly. I think there may be some interrupts for this if you have the right drivers installed, but I don't know what they are.
Using the 'IN' and 'OUT' operatives would be a start, but I don't know what the port number(s) are for an ethernet card.
Any information/resources would be appreciated !

Thanks, Add.
 
i once spoke to a wise man called ralf brown. he told me everything i need to know about netBIOS (netBIOS comes with the network card and automatically installs on power up):

INT 5C - NetBIOS INTERFACE
ES:BX -> network control block (NCB) (see #03249)
Return: AL = status (see #03248)
Program: NetBIOS was developed by Sytek, Inc. in 1984 as a high-level
programming interface to the IBM PC Network; the first implementation
was a ROM BIOS extension on Sytek's PCnet LAN adapter card, but many
current networks support NetBIOS as the session layer.
Notes: The Sytek PCnet card uses DMA 3.
On some machines this vector is not initialized (e.g. Epson machines).
Hence this interrupt should only be called or hooked if the vector
does not point to 0000h:0000h.
SeeAlso: INT 2A/AH=01h,INT 2A/AH=04h,INT 5B"Extended NetBIOS"

(Table 03248)
Values for NetBIOS status:
00h successful
01h bad buffer size
03h invalid NETBIOS command
05h timeout
06h receive buffer too small
07h No-ACK command failed
08h bad session number
09h LAN card out of memory
0Ah session closed
0Bh command has been cancelled
0Dh name already exists
0Eh local name table full
0Fh name still in use, can't delete
11h local session table full
12h remote PC not listening
13h bad NCB_NUM field
14h no answer to CALL or no such remote
15h name not in local name table
16h duplicate name
17h bad delete
18h abnormal end
19h name error, multiple identical names in use
1Ah bad packet
21h network card busy
22h too many commands queued
23h bad LAN card number
24h command finished while cancelling
26h command can't be cancelled
30h name defined by another process (OS/2)
34h NetBIOS environment not defined, must issue reset (OS/2)
35h required operating system resources exhausted (OS/2)
36h maximum applications exceeded (OS/2)
37h no SAPs available for NetBIOS (OS/2)
38h requested resources not available (OS/2)
40h Lana System Error
41h Lana Remote Hot Carrier
42h Lana Local Hot Carrier
43h Lana No Carrier Detected
44h unusual network condition
45h-4Dh hardware error
4Eh token ring is broken
4Fh token ring error
50h adapter malfunction
F7h error in explicit INITIALIZE
F8h error in implicit OPEN
F9h TOKREUI internal error
FAh hardware adapter testing
FBh NetBIOS emulator not found
FCh OPEN or OPEN_SAP failure
FDh unexpected adapter closure
FFh NetBIOS busy (command pending)

Format of NetBIOS Network Control Block:
Offset Size Description (Table 03249)
00h BYTE command code (see #03250)
01h BYTE return code (see #03248)
02h BYTE local session number (LSN)
03h BYTE "ncb_num" datagram table entry from ADD NAME
04h DWORD -> I/O buffer
08h WORD length of data in buffer
0Ah 16 BYTEs remote system to call
1Ah 16 BYTEs network name of local machine
2Ah BYTE receive timeout in 1/2 seconds
2Bh BYTE send timeout in 1/2 seconds
2Ch DWORD -> FAR post handler /* int (far *ncb_post)(); */
30h BYTE network adapter number on which to execute command
00h-03h IBM NetBIOS specs
F0h-FFh Eicon NABios interface (see also INT 7B"Eicon")
31h BYTE command completion code (see #03248)
32h 14 BYTEs reserved for network card

(Table 03250)
Values for NetBIOS command code field in NCB:
10h start session with NCB_NAME name (call)
11h listen for call
12h end session with NCB_NAME name (hangup)
14h send data via NCB_LSN
15h receive data from a session
16h receive data from any session
17h send multiple data buffers
20h send unACKed message (datagram)
21h receive datagram
22h send broadcast datagram
23h receive broadcast datagram
30h add name to name table
31h delete name from name table
32h reset adapter card and tables
33h get adapter status (see #03251)
34h status of all sessions for name (see #03253)
35h cancel
36h add group name to name table
48h send data and receive data (LAN Manager NETBEUI.DOS)
70h unlink from IBM remote program (no F0h function)
71h send data without ACK
72h send multiple buffers without ACK
72h UngermannBass Register (conflicts with above function)
73h UngermannBass SendNmc
74h UngermannBass Callniu
75h UngermannBass Calladdr
76h UngermannBass Listenaddr
77h UngermannBass SendPkt
78h find name
78h UngermannBass RcvPkt (conflicts with above function)
79h token-ring protocol trace
79h UngermannBass SendAttn (conflicts with above function)
7Ah UngermannBass RcvAttn
7Bh UngermannBass Listenniu
7Ch UngermannBass RcvRaw
7Dh UngermannBass SendNmc2
7Fh Beame&Whiteside BWNB installation check (returns with return code and
completion code both set to 03h, while invalid functions return only
return code field set to 03h)
Note: OR any of the above except 70h with 80h for non-waiting call

Format of NetBIOS structure "astatus":
Offset Size Description (Table 03251)
00h 6 BYTEs as_id
06h BYTE as_jumpers
07h BYTE as_post
08h BYTE as_major
09h BYTE as_minor
0Ah WORD as_interval
0Ch WORD as_crcerr
0Eh WORD as_algerr
10h WORD as_colerr
12h WORD as_abterr
14h DWORD as_tcount
18h DWORD as_rcount
1Ch WORD as_retran
1Eh WORD as_xresrc
20h 8 BYTEs as_res0
28h WORD as_ncbfree
2Ah WORD as_ncbmax
2Ch WORD as_ncbx
2Eh 4 BYTEs as_res1
32h WORD as_sespend
34h WORD as_msp
36h WORD as_sesmax
38h WORD as_bufsize
3Ah WORD as_names
3Ch 16 name structures as_name (see #03252)
Note: it has been reported that the first field should be 16 bytes instead
of six (shifthing all remaining fields by ten bytes)

Format of NetBIOS structure "name":
Offset Size Description (Table 03252)
00h 16 BYTEs "nm_name" symbolic name
10h BYTE "nm_num" number associated with name
11h BYTE nm_status

Format of NetBIOS structure "sstatus":
Offset Size Description (Table 03253)
00h BYTE number of sessions being reported
01h BYTE number of sessions with this name
02h BYTE number of outstanding receive datagrams
03h BYTE number of outstanding ReceiveAnys
04h var session structures (see #03254)

Format of NetBIOS structure "session":
Offset Size Description (Table 03254)
00h BYTE local session number
01h BYTE state
01h listen pending
02h call pending
03h session established
04h hangup pending
05h hangup done
06h session aborted
02h 16 BYTEs local name
12h 16 BYTEs remote name
22h BYTE number of outstanding receives
23h BYTE number of outstanding sends/chainsends
"There are 10 types of people in this world, those who know binary and those who don't!"
 
Thanx for the interrupt listing, straiph. I've been to look at 'bril RBIL' myself, and he is a wise man...
Anyway, I have written a code for simple netbios capabilities which will echo a nice message to the screen.
The code looks something like this:

; ( start of code )
jmp start

count db ?

NCB db ? ; Command
db ? ; Ret code (eg. zero=OK)
db 01 ; LSN (Local session number)
db ? ; Entry Number

dw ? ; Buffer address
dw ? ; Buffer address
dw ? ; Buffer length
... etc continuing NCB.

err0 db 'Successful',10,13,'$'
err1 db 'ERROR in netbios !',10,13,'$'
errmsg db 'Bad buffer size $' db 'Unknown error occured $' db 'Invalid NetBIOS command $' db 'Unknown error occured $' ...etc through errors

start:
push cs
pop ds
push cs
pop es

mov NCB,30h ; command add
lea bx,NCB
int 5ch
call print_error
mov NCB,10h ; command call
lea bx,NCB
int 5ch
call print_error

mov ax,4c00h
int 21h
ret

print_error:
cmp ax,0000h
jne failure
success:
lea dx,err0
call msg
jmp print_error_ret
failure:
mov bx,0000h
lea dx,errmsg
mov cx,0038h
errloop:
inc bx
cmp bx,ax
je errfound
add dx,0030h
cmp ax,50h
jg errnotfound
jmp errloop
ret
errnotfound:
lea bx,err1
call msg
jmp print_error_ret
errfound:
call msg
jmp print_error_ret

msg:
mov ah,09h
int 21h
ret
print_error_ret:
ret
( end of program )

The program seems to work in windows OK, and if you jiggle some parameters some errors will occur(!) BUT if you run this in plain DOS it reports successful whatever.
Is this because Windows adds netbios interrupts through a system driver ? I thought netbios interrupts would work in DOS as they are loaded at start time. Is that right ?
Thanks, Add.

 
hmm, ive got a demo program somewhere that demonstraites 05Ch usage. its not very big and its DOS based. you connect 2 PCs via network cards. when you run the program it asks for a name then a connection name. after this your messages are sent to the other PC like a chat room.

ill try to find it and ill post the asm


"There are 10 types of people in this world, those who know binary and those who don't!"
 
ok its like this -

i messed up! i dont know :(

im doing a project on this in 6 months but i dont think you want to wait that long - i could really do with some1 bringing me upto running speed :)




"There are 10 types of people in this world, those who know binary and those who don't!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top