hardware inline asm

This is a discussion on hardware inline asm within the C Programming forums, part of the General Programming Boards category; reading hardware wifi Code: /* hardware wifi card address 00-01-02-03-04-05 */ int wifiadaptercardpeek( int wifidatapeek ) { asm( " mov ...

  1. #1
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638

    hardware inline asm

    reading hardware wifi

    Code:
     
    /*    hardware wifi card address 00-01-02-03-04-05    */	
    
        int wifiadaptercardpeek( int wifidatapeek ) {
        asm( " mov (0x000102030405)  ,  wifidatapeek ; " ); // end asm  source dest
        return wifidatapeek;
        }; // end wifiadapterpeek
    Assembler messages:
    too many memory references for `mov'
    this is the least amount of error messages. have tried
    mov (0102030405h) , %eax ;
    mov 0x000102030405 , wifidatapeek ;
    mov 000102030405 , wifidatapeek ;
    mov 0102030405h , wifidatapeek ;
    mov [0102030405] , wifidatapeek ;
    mov $0x000102030405 , wifidatapeek ;
    mov (0x000102030405) , wifidatapeek
    mov [0x0102030405] , wifidatapeek ;

    " missing or invalid displacement expression `(0x000102030405)' taken as 0 "
    with something like that for errors

    want to read the wifi card at the hex address of 00-01-02-03-04-05. actual address removed just for question to keep simple addr of 12345 for question. function wifiadaptercardpeek() read raw and return what variable wifidatapeek obtains. unknown registers of wifiadapter. if any. administrator tools say device is working properly and driver is installed.
    Ethernet adapter Wireless Network Connection:

    Media State . . . . . . . . . . . : Media disconnected
    have not tried
    Code:
       "movl %%ebx, %0;"
                 : "=r" ( wifidatapeek  )        /* output */
    can not get any info from the wifi adapter company.

    i looked in to read() and readex() and tried to figure a way to do this in c but the best solution was to do a function inline asm to read the wifi raw. after a little bit of tinkering i got the wifi to do a limited connection. with file share off and tcp/ip also off i get a limited connection. it will read the ssid but that is about it. but the xp will not display the wifi network ssid in the dialog box. i got it from nonoperational to operational. i still want to try to get a prog to read the adapter raw. i turned on all the services but it will not do any more. the popup box in the bar say that it is connected. the task manager says operational but does not stay like that. 0 send 0 received but does read the ssid. how with out showing a received packet ? or showing the "available networks" in the dialog box net manager ?

    problem is that i can not get the inline asm to compile. have tried the variable wifidatapeek as both an int and char. both ways at&t and intel asm.

    second problem reading an address of a hardware location. known address 0x000102030405. if it were a variable i could get the address like (var) or get the contents of var by just using var. or in c &var as example. instead of using a variable i tried to mov the contents of the address to the accumulator then from the accumulator to the print que. as the above function wifiadaptercardpeek() was modified to try different way to accomplish the same task.

    also have looked in to using pop store and other asm nemonic with same no compile result. note it has it own folder. still wifried any suggestions <that are not co$$$$tly> ? meow tia.

    note two also downloaded ebook linux writing drivers .pdf have to read adapter before i can write a driver.


    note three trying to read hardware addr through usb think that i might be missing port and hub of the usb inorder to get it to work ? but that i have addr of hardware and should not be usb relevant just access it as if it were on motherboard since usb is just transport uart for addr and data lines <par to ser> and then back.

    note four incentive .... internet from 7bps to 36.6 bps dial up too 400mbps wifi

    note five tasm does not have a store accumulator but it does have a store string why ?

    dev-cpp or borland
    Last edited by kryptkat; 11-04-2010 at 11:28 AM.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,592
    Do you know that a MAC address is nothing to do with memory addresses?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    MAC address - Wikipedia, the free encyclopedia
    How to find your MAC address
    Windows NT

    The 12-digit Physical Address is the same as MAC address
    yes. yes i do know that the mac address is a unique identifier that is assigned to companies then the companies assign the mac address to their card that is not necessarily the same thing as the physical address. according to a link on the wiki mac address page under xp it says that the mac is the same as the physical address. you may also want to ask the writer of the dos prog that exact same question. you will note that it also says physical address. instead of mac address.


    Host Name . . . . . . . . . . . . : <name removed>
    Primary Dns Suffix . . . . . . . :
    Node Type . . . . . . . . . . . . : Unknown
    IP Routing Enabled. . . . . . . . : No
    WINS Proxy Enabled. . . . . . . . : No

    Ethernet adapter Wireless Network Connection:

    Connection-specific DNS Suffix . :
    Description . . . . . . . . . . . : <name removed>
    ==> Physical Address. . . . . . . . . : 00-01-02-03-04-05 <addr changed to example addr>
    Dhcp Enabled. . . . . . . . . . . : Yes
    Autoconfiguration Enabled . . . . : Yes
    IP Address. . . . . . . . . . . . : 0.0.0.0
    Subnet Mask . . . . . . . . . . . : 0.0.0.0
    Default Gateway . . . . . . . . . :
    DHCP Server . . . . . . . . . . . : 0.0.0.0
    NetBIOS over Tcpip. . . . . . . . : Disabled

    C:\>
    still getting the same error even when i shortened the address to a 32 bit address since the xp is a 32bit buss. addressing the card with the full address on the address line the card may be only able to receive the 32bits and everything to the left would not be used. " too many memory references for `mov' " using 2345 hex. also 9029 dec. "00000010000000110000010000000101" the actual physical 32bit buss lines to access the card. or in this case the adapter. the code would be almost the same instead of writing to or reading from a memory location or variable the card address would receive the data or send it. if it were an external memory card location the data would activate the jk flip flops storing the data. but with the wifi the data would be transmitted or received by another external source. in the 802.11 packet format.

    do i need to add the -g to devcpp ? have not tried extended asm with ':' ....

    have read other reffs on inline asm with the standard format of
    asm("assembly code");
    it is not a register so the % was not used

    also getting
    " no instruction mnemonic suffix given and no register operands; can't size instruction " when $ is used. but that is not telling the compiler to do what i want it to do.

    Memory address - Wikipedia, the free encyclopedia

    if the memory card has a processor<mmu> the address of the stored memory can be different than that of the actual physical address of the memory card. this i do understand. but the problem of getting the prog to compile and access the adapter is still the same. meow.

    Physical address - Wikipedia, the free encyclopedia

  4. #4
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    611
    The physical address of my house is 76, it doesn't mean if I try and read a string from that address on my computer I'll find out who keeps sending me junk mail. Same name, different things, woof

  5. #5
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    kryptcat ... you are NOT going to find your network card's mac address by poking around in memory... The MAC number (it's not really an address at all) is stored as 6 characters inside the network adaptor's chipset. It is retrieved on demand by driver calls.

    If you are on a windows system, investigate the SendARP() windows api call. It will get the MAC number from any computer that is connected to your network.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,592
    Your network card has TWO addresses.

    There is the memory address (probably allocated using PCI) which allows your CPU (aka your programs) to send and receive data from the network card.

    The network card then uses it's own MAC address when talking to the next network node (probably your very own router/gateway). All the machines plugged into any given router all have UNIQUE MAC addresses.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Salem View Post
    Your network card has TWO addresses.

    There is the memory address (probably allocated using PCI) which allows your CPU (aka your programs) to send and receive data from the network card.

    The network card then uses it's own MAC address when talking to the next network node (probably your very own router/gateway). All the machines plugged into any given router all have UNIQUE MAC addresses.
    Actually....

    The MAC number is embedded into the chip and is *supposed* to be unique to the world, like a phone number.

    What you work with on LAN and Internet are not MAC addresses, those are IP (Internet Positioning) addresses which are a software contraption that can be dynamically assigned by the router/isp/etc. They have to be unique within a given network node, but non-connected nodes can duplicate IP addresses all they like.

    The IP address might change... The MAC number is fixed.

    Neither of these has anything to do with the memory address of the card/chip/driver.
    Last edited by CommonTater; 11-07-2010 at 01:13 AM.

  8. #8
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    Regardless of whether it's at that physical memory address or not(it's not), you can't access that physical address like that. Windows runs programs in virtual memory with paging that can map any physical address to any virtual address. That's how segfaults work. When you access a virtual address that hasn't been mapped, the OS gets really mad and kills your process. I'm guessing the code you posted segfaults, no?

  9. #9
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Looking at the code again... I see that kryptcat has mistaken the MAC number for a memory address... sorry, not the same thing.

  10. #10
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    Something like think will require the use of OS specific interfaces. For Windows, Three ways to get your MAC address. - CodeGuru. For other, idk.

  11. #11
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by User Name: View Post
    Something like think will require the use of OS specific interfaces. For Windows, Three ways to get your MAC address. - CodeGuru. For other, idk.
    Also as I mentioned earlier... use SendARP() ... this will load the 6 byte MAC number for your machine or any other you have an IP address for.

  12. #12
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    i have not mistaken the mac for the physical address. as i tried to explain i was hoping that the 32bit end part of the mac would be the physical address for the wireless adapter a remote chance. i know that the mac is an id that can be looked up to identify the manufacture of the card like a licence plate on a car.

    the physical address is the actual addressing lines on the card. trying to find that and all i have to work with is the address that the dos prog gave. altenitivally the only other way is to take the adapter apart and look at the circuitry assuming that the chips are labeled. but as you said it is probably accessed by a virtual id. with out the info from the company there is not that much that can be done. i did get it working partly. the installer quit when it did not detect the service packs. the job of the driver is to take the function calls and access the wireless adapter by the id be it physical address or software id then send the data back and forth. but i did not find any address in the driver yet that is useable. all i did find in the .info file was three items under deviceid that looks like usb\vid_xxxx&pid_xxxx there are three driver files one is a .dll file. another one is .sys and the other is a .dat .meow

    the adapter looks to be inclosed in a two part plastic with no screws and a usb connector. i am not sure it can be taken apart with out breaking it.

    suggestions .... reasonable suggestions ? the government seems to be highly reluctant to give me a nuclear weapon to blow the adapter up with.

  13. #13
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,592
    A design aim of PCI was to remove some of the grubby problems which beset people who still remember the ISA days, where address and IRQ conflicts were the norm.

    To that extent, there is some low level negotiation (transparent to s/w) where all the devices on the PCI bus sort themselves out. So that when you come along and enumerate the bus to see what devices are on it, you get a nice clean answer.

    > all i did find in the .info file was three items under deviceid that looks like usb\vid_xxxx&pid_xxxx
    Type them in here
    PCI Vendor and Device Lists

    So if you rearrange your PCI bus and switch the machine back on, your network card might decide that it should be at a different PHYSICAL address. But that's not a problem, since when the bus is enumerated, one of the things you find out is how to talk to it in future.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  14. #14
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by kryptkat View Post
    the adapter looks to be inclosed in a two part plastic with no screws and a usb connector. i am not sure it can be taken apart with out breaking it.

    suggestions .... reasonable suggestions ? the government seems to be highly reluctant to give me a nuclear weapon to blow the adapter up with.
    Oh wait... that's a USB device?

    It has literally NO address in the system. It will have a USB ID that is dynamically assigned when you connect it to the system. Not only is this dynamically assigned, it might not be the same every time...

    What happens is when you connect the device the usb hub chip asks for the next available USB ID and assigns it to the device, then it downloads an ID code (which may or may not be the MAC number) and publishes it to all registered USB drivers on the system. The driver that recognizes the ID code then makes note of the USB ID and begins polling the device.

    It never actually occupies an address on the system buss.
    Only the USB hub chip has a machine address...

    Your only hope of communicating with that device is through the drivers provided by the manufacturer and I pretty much doubt they're going to give you the source code.

    USB Protocol Specification

  15. #15
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    looked in to sendarp()
    No ARP Entries Found
    while on line. does same thing as dos command. with getinterfaceinfo() i get adapter index number also with another prog i am getting device index number that is different than getinterfaceinfo() results ?

    looked in the device manager at most of the entries like usb and network to get any info from there.
    It will have a USB ID that is dynamically assigned when you connect it to the system. Not only is this dynamically assigned, it might not be the same every time...
    progmatically how ? do you use the usb id ?
    Code:
      
    /*    hardware wifi card address 00-01-02-03-04-05    */	
    
        int wifiadaptercardpeek( int wifidatapeek ) {
        asm( " mov  "00-01-02-03-04-05 " ,  wifidatapeek ; " ); // end asm  source dest
        return wifidatapeek;
        }; // end wifiadapterpeek
    while reading through both the usb 2.0 and usb 3.0 protocall specifications under packet identifier field <chap 8> they have the lsb on the left instead of the right side. as 8bits for the whole id. both pdf file did not have any example code to access devices connected. it did have the commands and response code. no example of getting the usb id.

    Your only hope of communicating with that device is through the drivers provided by the manufacturer and I pretty much doubt they're going to give you the source code.
    the driver was not installed by the installer .... it has some type of check for service pack 3 on it and quit. it did not install anything. by playing with manually extracting the files i installed the driver files where they should be but think that there are some registery settings that should have been set up by the installer that did not happen so not knowing exactly what the installer sets the registry settings too .... i wifried. add insult to injury the wifiapi also had check for service pack 3 so it too had to be manually extracted. you can not even unpack it to look at the source code unless you have sp3.

    the program that did not compile is to access the wifi adapter directly and not make any calls to the driver <mostly because it is not functioning because the installer quit when no sp3 was detected>.

    the other programs that i have also access the driver or require the driver to work. and use pcap and wsock2. <also not giving a direct communication to the adapter>

    all i got it to do is to read the ssids of the local networks. that is it. if i could get this prog to compile and work using the command codes in the pdf and adapter id i thought that would get it working.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  2. Certain functions
    By Lurker in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2003, 12:26 AM
  3. Inline asm
    By wavering in forum C Programming
    Replies: 2
    Last Post: 01-29-2002, 01:42 AM
  4. Inline asm - I love it!
    By wavering in forum C Programming
    Replies: 2
    Last Post: 01-08-2002, 01:19 PM
  5. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 05:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21