www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/21/04:36:21

From: Regis BOSSUT <bossut AT isen DOT fr>
Newsgroups: comp.os.msdos.djgpp
Subject: A simple program that works except under GDB...
Date: Thu, 20 Mar 1997 18:35:13 +0100
Organization: IEMN - Dépt ISEN - Acoustique
Lines: 94
Message-ID: <33317551.4DE2@isen.fr>
NNTP-Posting-Host: hpac1.isen.fr
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi all!

I wrote a small program to find out my LAN card MAC address, based on
the example provided by Microsoft, using Netbios, adapted with help of
intwin.hlp (interrupt 0x5c).

It works fine when run as is, but gives incorrect results when run
under GDB. Seems that memory is used differently, but I don't see why.

Can some guru explain it ?

Thanks in advance.

/Régis

_____ Start of adapt.c _____
#include <stdio.h>
#include <stdlib.h>
#include <dpmi.h>
#include <go32.h>

#define BYTE unsigned char
#define WORD unsigned short
#define DWORD unsigned int

typedef struct {
BYTE  ncb_command;
#define NCBASTAT 0x33
BYTE  ncb_retcode, ncb_lsn, ncb_num;
char *ncb_buffer; WORD  ncb_length;
BYTE  ncb_callname[16], ncb_name[16];
BYTE  ncb_rto, ncb_sto;
int   (*ncb_post)();
BYTE  ncb_lana_num, ncb_cmd_cplt;
char *ncb_vname;
BYTE  ncb_vnamelen;
BYTE  ncb_reserve[9];
} NCB;

struct ADAPTER_STATUS {
BYTE as_id[6], as_jumpers, as_post, as_major, as_minor;
WORD  as_interval, as_crcerr, as_algerr, as_colerr, as_abterr;
DWORD as_tcount, as_rcount;
WORD  as_retran, as_xresrc;
BYTE  as_res0[8];
WORD  as_ncbfree, as_ncbmax, as_ncbx;
BYTE  as_res1[4];
WORD  as_sespend, as_msp, as_sesmax, as_bufsize, as_names;
char  buf[512];
} adapt;

BYTE Netbios(Ncb) NCB *Ncb; {
  __dpmi_regs regs;
  char *buf = Ncb->ncb_buffer;
  int len = Ncb->ncb_length;
  if (buf) {
    dosmemput(buf,len,__tb+sizeof(NCB));
    Ncb->ncb_buffer = (char*)(__tb+sizeof(NCB));
  }
  dosmemput(Ncb,sizeof(NCB),__tb);
  memset(&regs,0,sizeof(regs));
  regs.d.ebx = 0;
  regs.x.ds = regs.x.es = __tb/16;
  __dpmi_int(0x5c,&regs);
  dosmemget(__tb,sizeof(NCB),Ncb);
  if (buf) {
    dosmemget(__tb+sizeof(NCB),len,buf);
    Ncb->ncb_buffer = buf;
  }
  return regs.x.ax;
}

void main(void) {
 NCB Ncb;
 BYTE uRetCode;
 int i;

 for (i=0;i<8;i++) {
     memset(&Ncb,0,sizeof(Ncb));
     memset(&adapt,0,sizeof(adapt));
     Ncb.ncb_command = NCBASTAT;
     Ncb.ncb_lana_num = i;
     memcpy(Ncb.ncb_callname,"*               ",16);
     Ncb.ncb_buffer = (char *) &adapt;
     Ncb.ncb_length = sizeof(adapt);

     uRetCode = Netbios(&Ncb);
     printf("The NCBASTAT rc = 0x%x, adapt =
%02x:%02x:%02x:%02x:%02x:%02x\n",
       uRetCode,
       adapt.as_id[0],adapt.as_id[1],adapt.as_id[2],
       adapt.as_id[3],adapt.as_id[4],adapt.as_id[5]);
 }
}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019