32 bi NetBIOS() caused RTC checks to complain under 64 bit Win2003

  • Thread starter Thread starter Sten Westerback \(MVP SDK 2005-6 :\)
  • Start date Start date
S

Sten Westerback \(MVP SDK 2005-6 :\)

Guest
Hi

The below routine works just fine on 32 bit Windows 2000, XP and Server
2003.

But under WOW32 on a 2003 64 bit system the debug code (compiled with
runtime checks) fails claiming that
"Run-Time Check Failure #2 - Stack around the variable 'ncbO' was
corrupted."
Release version without the check seems to work ok but i want to debug. I'm
using MSVC 2003 7.1.6030 and don't currently have time to convert the code
to 64 bit.

Here is the routine which purpose is to simulate use of "NBTSTAT -a
computername" to check if a workstation is online. Netbios is after all
considerably more reliable than ping.

BOOL CheckOnline(char *p_szComputername)
{
NCB ncbO;
int i;
UCHAR uc;
char sz[50];
struct
{
ADAPTER_STATUS as;
NAME_BUFFER nb[20];
} X;

if (p_szComputername==NULL) return FALSE;
if ((i=strlen(p_szComputername))<2) return FALSE;
if (i>16) return FALSE;
memset(&ncbO, 0, sizeof(NCB));
ncbO.ncb_buffer = &X; memset(&X, 0, sizeof(X));
ncbO.ncb_length=sizeof(X);
ncbO.ncb_lana_num = iBestLANadapter();
ncbO.ncb_command = NCBRESET; Netbios(&ncbO);
ncbO.ncb_command = NCBASTAT;
memcpy(ncbO.ncb_name, "IMIPserver ", 16);
memcpy(sz, p_szComputername, i); sz=0; strupr(sz);
memset(ncbO.ncb_callname, ' ', 16); memcpy(ncbO.ncb_callname, sz, i);
uc=Netbios(&ncbO);
if (uc==NRC_CMDTMO) { Sleep(1000); ncbO.ncb_length=sizeof(X);
uc=Netbios(&ncbO); }
if (uc!=NRC_GOODRET && uc!=NRC_INCOMP) return FALSE;
if (uc==NRC_INCOMP) { return FALSE; /* Need to issue second command ? */ }
return TRUE;
}

Can it be possible that the WOW32 has a bug making it update the structures
with data in 64 bit format? But even so i would think that huge buffer
should be big enough and i have also tried to add extra buffers around it.
Maybe it's just the runtime check routine that gets confused somehow. Help!

Also, can someone tell how one is supposed to handle NRC_INCOMP ? And is the
NCBRESET step always required?

- Sten
 
Back
Top