hi Does anybody know how to get the Network Adapret Adress (the one returned by running winipcfg) ? Thx
Posted on 2001-02-13 13:53:00 by BogdanOntanu
Hi im not shure if you mean this ,but i hope this helps ;) shows you the mac adress. cu ;+--------------------------------------------------------------------------+; ;| NetBios Example (c)1998 Prove It 2000 |; ;| =============== ===================== |; ;| |; ;+--------------------------------------------------------------------------+; .386p ; 386 Proccessor or above locals jumps .model flat, STDCALL L equ extrn Netbios:PROC, ExitProcess:PROC extrn MessageBoxA:PROC ;============================================================================; .data pncb db 33h ; Command db 0 ; Ret Code db 69h ; lsn db 0 ; num dd offset buff1 ; -> Buffer dw 256 ; length db '*', 15 dup(0) ; callname db 16 dup(0) ; name db 0 ; rto db 0 ; sto db 0 ; lana_num db 0 ; cmd_cplt db 10 dup(0) ; reserve dd 0 ; handle db 256 dup(0) buff1 db 256 dup(0) msga db 'SyStEm InFo (c)1998 Jimmy Moore', 0 msg0 db 'The Hardware Address of this PC is: ' msg1 db 'xx-' msg2 db 'xx-' msg3 db 'xx-' msg4 db 'xx-' msg5 db 'xx-' msg6 db 'xx', 0 hextab db '0123456789ABCDEF' .code start: push L offset pncb call Netbios mov al, byte ptr mov edi, offset msg1 call putal mov al, byte ptr mov edi, offset msg2 call putal mov al, byte ptr mov edi, offset msg3 call putal mov al, byte ptr mov edi, offset msg4 call putal mov al, byte ptr mov edi, offset msg5 call putal mov al, byte ptr mov edi, offset msg6 call putal push L 0 push L offset msga push L offset msg0 push L 0 call MessageBoxA push L 0 call ExitProcess ;============================================================================; putal proc mov ebx, eax shr ebx, 4 and ebx, 0fh mov bl, byte ptr mov byte ptr , bl mov ebx, eax and ebx, 0fh mov bl, byte ptr mov byte ptr , bl ret putal endp ;============================================================================; ends end start
Posted on 2001-02-13 17:55:00 by WH¥
Hi again the above example works well (after some changes/conversion) but ONLY if you have "Enable Netbios over TCP/IP" in Network... (this is a major security threat)... If you DO NOT...then it just returns 00-00-00-00-00-00 :( However Winipcfg gets it even if the above setting is OFF.. I still wonder HOW? Is there any othere API to do the same thing? Thx
Posted on 2001-02-14 10:54:00 by BogdanOntanu
Not sure if this info is helpful to you, but here goes, for what it's worth... On my NT box here at work, I have used RegEdit to create a string called "NetworkAddress" in:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\ATNICm41\Parameters\
The string contains the 12 hex digits "DEADBEEFD00D". Magically, IPConfig reports my MAC as "DEADBEEFD00D", and anyone using ping and arp through my network sees that as my MAC also. Of course this is NT, the registry setting may be different for 95/98/ME, and will differ depending on your NIC (as you can see, mine is Allied Telesyn)... I believe NT retrieves all the driver info from the registry early in the boot process. I think the driver retrieves the MAC during load. If Windows found the registry setting, it ignores the driver's findings. Once up and running, HAL (the Hardware Abstraction Layer) generally doesn't let software touch the hardware. The process is probably very similar under 95/98, without HAL's help. As far as actually interrogating the hardware for the MAC, I doubt you'd have much luck under NT, 95/98 is a different story... I have no Win2000/ME experience to speak of, so I'm clueless there.
Posted on 2001-02-14 14:34:00 by Q