Tech Support > Microsoft Windows > Development Resources > NetBIOS structure runtime check fails on WOW32 on 64 bit Windows
NetBIOS structure runtime check fails on WOW32 on 64 bit Windows
Posted by Sten Westerback \(MVP SDK 2005-6 :\) on September 26th, 2007


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[i]=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


Posted by Sam Hobbs on October 5th, 2007


This is a debugging (obviously) feature that is new for VC 2005. It is
certainly possible that the program will work in a release build in spite of
the problem. The stack corruption could exist in programs compiled with
previous versions of VC and not be detected. The problem is that the stack
corruption could cause a problem at anytime and that could be confusing and
fatal. You need to determine the cause of the problem.

The most comon cause probably is (mis)use of #pragma pack. Are you using
that in your code?

I created a thread in the MSDN VC General forum because it seems we need
help diagnosing the problem; see:

Debugging: Run-Time Check Failure #2 - Stack around the variable
'LoggerThread' was corrupted.
http://forums.microsoft.com/MSDN/Sho...62481&SiteID=1

There are some suggestions there for debugging this specific error. If any
of them do help, then please let us know.

Also try:
http://search.msdn.microsoft.com/sea...=00&lang=en-us


"Sten Westerback (MVP SDK 2005-6 "
<REMOVE_UPPERCASEext-sten.westerback@nokia.com> wrote in message
news:1190794550.182756@xnews001...



Similar Posts