Solved

Problem with Program - Access Violation (C0000005) in Windows NT4

Posted on 2002-04-08
11
1,800 Views
Last Modified: 2010-05-18

Hi.  I have developed a Purchase Order application that has a server
and a client component.  The communication implemented was with winsockets
and the server is designed to react to messages coming in from the client
and vice-versa.  I am experiencing an application error, seemingly at random.
It may occur twice in one day, or may occur every week or two weeks.  
Whenever the crash happens, it simply says something like "poserver.exe has
generated an application protection fault c0000005".  The program was designed
in VB6 running on SP5.  The server portion sits on a Windows NT4 server running
SP6A & Post 6A patch.  This problem has been plaguing me for quite awhile.  If
anyone has any ideas on how I could solve this problem, it would be
appreciated greatly!  

Thanks much,
Bob

Dr. Watson log follows:


Application exception occurred:
        App:  (pid=168)
        When: 3/28/2002 @ 16:9:59.718
        Exception number: c0000005 (access violation)

*----> System Information <----*
        Computer Name: NT1_BRAMPTON
        User Name: Admin
        Number of Processors: 2
        Processor Type: x86 Family 6 Model 5 Stepping 1
        Windows Version: 4.0
        Current Build: 1381
        Service Pack: 6
        Current Type: Multiprocessor Free
        Registered Organization:
        Registered Owner:

*----> Task List <----*
   0 Idle.exe
   2 System.exe
  26 smss.exe
  34 csrss.exe
  40 winlogon.exe
  46 services.exe
  49 lsass.exe
  73 spoolss.exe
 106 AMGRSRVC.exe
  76 llssrv.exe
 111 MCSHIELD.exe
 121 VSTSKMGR.exe
 132 LOCATOR.exe
 142 RpcSs.exe
 155 tcpsvcs.exe
 158 dns.exe
 160 pstores.exe
 164 MSTask.exe
 187 wins.exe
 171 nddeagnt.exe
  92 Explorer.exe
 148 loadwc.exe
 243 SHSTAT.exe
  63 WScheduler.exe
 248 HPJETDSC.exe
 249 WinVNC.exe
 289 ddhelp.exe
 168 POSERVER.exe
 281 NDaemon.exe
 371 ntvdm.exe
 344 drwtsn32.exe
   0 _Total.exe

(00400000 - 00400000)
(77f60000 - 77fbe000) dll\ntdll.dbg
(66000000 - 66153000) DLL\MSVBVM60.dbg
(77f00000 - 77f5f000) dll\kernel32.dbg
(77e70000 - 77ec5000) dll\user32.dbg
(77ed0000 - 77efc000) dll\gdi32.dbg
(77dc0000 - 77dff000) dll\advapi32.dbg
(77e10000 - 77e67000) dll\rpcrt4.dbg
(77b20000 - 77bd1000) dll\ole32.dbg
(65340000 - 653db000) D:\OA\rwin32\oleaut32.dll
(10000000 - 10000000)
(5f800000 - 5f8e7000) mfc40_opt.DBG
(779d0000 - 779d0000)
(78000000 - 78040000)
(780a0000 - 780b2000)
(22170000 - 2218c000) ocx\mswinsck.dbg
(776d0000 - 776d8000) dll\wsock32.dbg
(776b0000 - 776c4000) dll\ws2_32.dbg
(776a0000 - 776a7000) dll\ws2help.dbg
(77660000 - 7766f000) dll\msafd.dbg
(77690000 - 77699000) dll\wshtcpip.dbg
(71300000 - 71306000) dll\msidle.dbg
(76e70000 - 76e82000) dll\secur128.dbg
(71900000 - 71914000) dll\msapsspc.dbg
(77400000 - 7741e000) dll\sch128c.dbg
(5e380000 - 5e3a5000) dll\msoss.dbg
(5cf00000 - 5cf5e000) dll\crypt32.dbg
(017c0000 - 017d0000)
(1b5c0000 - 1b655000) dll\mswstr10.dbg
(0f9c0000 - 0fa22000) expsrv.DBG
(0f9a0000 - 0f9ab000) vbajet32.dbg
(1b7f0000 - 1b82a000) dll\msjtes40.dbg
(1b730000 - 1b7b7000) dll\dao360.dbg
(1b000000 - 1b16f000) dll\msJET40.dbg
(1b270000 - 1b2bc000) dll\msrd3x40.dbg

State Dump for Thread Id 0x13a

eax=0016da8c ebx=00000014 ecx=00000002 edx=00000014 esi=00170000 edi=0016da98
eip=653690ba esp=0012efe4 ebp=77f1da74 iopl=0         nv up ei pl nz na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000206


function: SysAllocStringLen
        653690a2 7425             jz      SysAllocStringLen+0x89 (653690c9)
        653690a4 8b742414         mov     esi,[esp+0x14]         ss:010cd9eb=????????
        653690a8 8918             mov     [eax],ebx              ds:0016da8c=0049005a
        653690aa 83c004           add     eax,0x4
        653690ad 85f6             test    esi,esi
        653690af 7412             jz      SysAllocStringLen+0x83 (653690c3)
        653690b1 8bcb             mov     ecx,ebx
        653690b3 8bf8             mov     edi,eax
        653690b5 8bd1             mov     edx,ecx
        653690b7 c1e902           shr     ecx,0x2
FAULT ->653690ba f3a5            rep  movsd ds:00170000=???????? es:0016da98=0046004e
        653690bc 8bca             mov     ecx,edx
        653690be 83e103           and     ecx,0x3
        653690c1 f3a4             rep     movsb         ds:00170000=?? es:0016da98=4e
        653690c3 66c704180000     mov     word ptr [eax+ebx],0x0     ds:00000014=????
        653690c9 5f               pop     edi
        653690ca 5e               pop     esi
        653690cb 5d               pop     ebp
        653690cc 5b               pop     ebx
        653690cd c20800           ret     0x8

*----> Stack Back Trace <----*

FramePtr ReturnAd Param#1  Param#2  Param#3  Param#4  Function Name
0012eff0 1b7514cd 0016fff4 0000000a 6602465b 00000000 oleaut32!SysAllocStringLen  (FPO: [EBP 0x001b5c00] [2,0,4])
001b5c00 001b5c0c 001b5d70 1b798e18 00000001 001b5c00 dao360!<nosymbols>

*----> Raw Stack Dump <----*
0012efe4  00 5c 1b 00 f4 ff 16 00 - ec f0 12 00 b4 5c 1b 00  .\...........\..
0012eff4  cd 14 75 1b f4 ff 16 00 - 0a 00 00 00 5b 46 02 66  ..u.........[F.f
0012f004  00 00 00 00 a8 90 14 00 - b0 81 79 1b 00 5c 1b 00  ..........y..\..
0012f014  00 00 00 00 53 b2 41 00 - b4 5c 1b 00 f4 ff 16 00  ....S.A..\......
0012f024  5b 46 02 66 00 00 00 00 - a8 90 14 00 00 00 00 00  [F.f............
0012f034  00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ................
0012f044  00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ................
0012f054  00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ................
0012f064  00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ................
0012f074  00 00 00 00 00 00 00 00 - b4 5c 1b 00 00 00 00 00  .........\......
0012f084  00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ................
0012f094  00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ................
0012f0a4  00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ................
0012f0b4  00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ................
0012f0c4  00 00 00 00 00 00 00 00 - 90 f3 12 00 26 20 40 00  ............& @.
0012f0d4  24 f0 12 00 90 16 40 00 - 00 00 00 00 01 00 00 00  $.....@.........
0012f0e4  16 00 00 00 06 00 00 00 - a4 f3 12 00 87 a9 42 00  ..............B.
0012f0f4  a8 90 14 00 38 f3 12 00 - a8 67 13 00 40 68 13 00  ....8....g..@h..
0012f104  34 f3 12 00 4c f3 12 00 - 50 f3 12 00 78 f3 12 00  4...L...P...x...
0012f114  98 f1 12 00 94 f1 12 00 - 90 f1 12 00 fc f2 12 00  ................

State Dump for Thread Id 0x15d

eax=000000c0 ebx=00000000 ecx=7ffdd000 edx=00000000 esi=00000000 edi=00000084
eip=77f682db esp=017aff44 ebp=017aff98 iopl=0         nv up ei ng nz ac pe cy
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000293


function: NtWaitForSingleObject
        77f682d0 b8c5000000       mov     eax,0xc5
        77f682d5 8d542404         lea     edx,[esp+0x4]          ss:0274e94b=????????
        77f682d9 cd2e             int     2e
        77f682db c20c00           ret     0xc
        77f682de 8bc0             mov     eax,eax

*----> Stack Back Trace <----*

FramePtr ReturnAd Param#1  Param#2  Param#3  Param#4  Function Name
017aff98 77661e92 00000084 ffffffff 00000003 00000004 ntdll!NtWaitForSingleObject
017affec 00000000 77661e66 00000000 00000000 8f8f8f8f msafd!<nosymbols>
00000000 00000000 00000000 00000000 00000000 00000000 !<nosymbols>

*----> Raw Stack Dump <----*
017aff44  ce 89 66 77 84 00 00 00 - 01 00 00 00 70 ff 7a 01  ..fw........p.z.
017aff54  48 b0 66 77 e0 2b 67 01 - 00 00 00 00 fa 8f 69 e9  H.fw.+g.......i.
017aff64  9c d6 c1 01 ff ff ff ff - ff ff ff 7f ff ff ff ff  ................
017aff74  ff ff ff 7f e0 2b 67 01 - 48 b0 66 77 e0 2b 67 01  .....+g.H.fw.+g.
017aff84  00 00 00 00 3c 51 66 77 - 50 2d 67 01 05 00 00 00  ....<QfwP-g.....
017aff94  ec ff 7a 00 ec ff 7a 01 - 92 1e 66 77 84 00 00 00  ..z...z...fw....
017affa4  ff ff ff ff 03 00 00 00 - 04 00 00 00 00 f0 fd 7f  ................
017affb4  68 f5 12 00 00 00 00 00 - f0 4e f0 77 00 00 00 00  h........N.w....
017affc4  00 f0 fd 7f 68 f5 12 00 - 00 00 00 00 68 f5 12 00  ....h.......h...
017affd4  c4 ff 7a 01 8a 54 f4 77 - ff ff ff ff 6c b9 f3 77  ..z..T.w....l..w
017affe4  50 d2 f3 77 00 00 00 00 - 00 00 00 00 00 00 00 00  P..w............
017afff4  66 1e 66 77 00 00 00 00 - 00 00 00 00 8f 8f 8f 8f  f.fw............
017b0004  8f 8f 8f 8f 8f 8f 8f 8f - 8f 8f 8f 8f 8f 8f 8f 8f  ................
017b0014  8f 8f 8f 8f 8f 8f 8f 8f - 8f 8f 8f 8f 8f 8f 8f 8f  ................
017b0024  8f 8f 6b 8f 8f 6b 8f 8f - 6b 8f 8f 8f 6b 8f 8f 8f  ..k..k..k...k...
017b0034  8f 6b 6b 8f 6b 8f 6b 6b - 8f 6b 8f 6b 8f 6b 8f 6b  .kk.k.kk.k.k.k.k
017b0044  8f 6b 8f 6b 8f 8f 6b 8f - 6b 8f 6b 8f 6b 8f b3 8f  .k.k..k.k.k.k...
017b0054  b3 8e ab ab aa a5 ab a4 - ab aa a5 ab aa ab ab aa  ................
017b0064  aa ab aa ab aa ab cf aa - ab ab aa ab aa aa ab aa  ................
017b0074  aa a5 aa aa aa aa a4 aa - aa aa a4 aa aa aa aa a4  ................

State Dump for Thread Id 0x65

eax=653529c0 ebx=0be4ff24 ecx=ffffffff edx=00000000 esi=7ffdf000 edi=00000001
eip=77f682cb esp=0be4ff00 ebp=0be4ff54 iopl=0         nv up ei pl nz ac pe cy
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00000213


function: NtWaitForMultipleObjects
        77f682c0 b8c4000000       mov     eax,0xc4
        77f682c5 8d542404         lea     edx,[esp+0x4]          ss:0cdee907=????????
        77f682c9 cd2e             int     2e
        77f682cb c21400           ret     0x14
        77f682ce 8bc0             mov     eax,eax

*----> Stack Back Trace <----*

FramePtr ReturnAd Param#1  Param#2  Param#3  Param#4  Function Name
0be4ff54 77f1cf41 00000002 0be4ff98 00000000 ffffffff ntdll!NtWaitForMultipleObjects
0be4ff70 65352a46 00000002 0be4ff98 00000000 ffffffff kernel32!WaitForMultipleObjects

State Dump for Thread Id 0x12f

eax=1b0034a3 ebx=00000000 ecx=1b11fc60 edx=00000000 esi=00000128 edi=0b32ff10
eip=77f682db esp=0b32fef4 ebp=0b32ff18 iopl=0         nv up ei pl nz na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00000206


function: NtWaitForSingleObject
        77f682d0 b8c5000000       mov     eax,0xc5
        77f682d5 8d542404         lea     edx,[esp+0x4]          ss:0c2ce8fb=????????
        77f682d9 cd2e             int     2e
        77f682db c20c00           ret     0xc
        77f682de 8bc0             mov     eax,eax

*----> Stack Back Trace <----*

FramePtr ReturnAd Param#1  Param#2  Param#3  Param#4  Function Name
0b32ff18 77f04f49 00000128 00001388 00000000 1b00997a ntdll!NtWaitForSingleObject
00000000 00000000 00000000 00000000 00000000 00000000 kernel32!WaitForSingleObject

State Dump for Thread Id 0x180

eax=1b0034a3 ebx=00000000 ecx=1b11fc60 edx=00000000 esi=00000128 edi=00000000
eip=77f682db esp=0b42fef4 ebp=0b42ff18 iopl=0         nv up ei pl zr na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00000246


function: NtWaitForSingleObject
        77f682d0 b8c5000000       mov     eax,0xc5
        77f682d5 8d542404         lea     edx,[esp+0x4]          ss:0c3ce8fb=????????
        77f682d9 cd2e             int     2e
        77f682db c20c00           ret     0xc
        77f682de 8bc0             mov     eax,eax

*----> Stack Back Trace <----*

FramePtr ReturnAd Param#1  Param#2  Param#3  Param#4  Function Name
0b42ff18 77f04f49 00000128 ffffffff 00000000 1b00997a ntdll!NtWaitForSingleObject
00000000 00000000 00000000 00000000 00000000 00000000 kernel32!WaitForSingleObject

State Dump for Thread Id 0x14a

eax=1b0034a3 ebx=00000000 ecx=1b11fc60 edx=00000000 esi=00000128 edi=00000000
eip=77f682db esp=0b52fef4 ebp=0b52ff18 iopl=0         nv up ei pl zr na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00000246


function: NtWaitForSingleObject
        77f682d0 b8c5000000       mov     eax,0xc5
        77f682d5 8d542404         lea     edx,[esp+0x4]          ss:0c4ce8fb=????????
        77f682d9 cd2e             int     2e
        77f682db c20c00           ret     0xc
        77f682de 8bc0             mov     eax,eax

*----> Stack Back Trace <----*

FramePtr ReturnAd Param#1  Param#2  Param#3  Param#4  Function Name
0b52ff18 77f04f49 00000128 ffffffff 00000000 1b00997a ntdll!NtWaitForSingleObject
00000000 00000000 00000000 00000000 00000000 00000000 kernel32!WaitForSingleObject

*----> Raw Stack Dump <----*
0b52fef4  6b ce f1 77 28 01 00 00 - 00 00 00 00 00 00 00 00  k..w(...........
0b52ff04  ff ff ff ff 40 06 d3 06 - 80 ff 52 0b d4 2c f9 77  ....@.....R..,.w
0b52ff14  e8 d0 f9 77 00 00 00 00 - 49 4f f0 77 28 01 00 00  ...w....IO.w(...
0b52ff24  ff ff ff ff 00 00 00 00 - 7a 99 00 1b 28 01 00 00  ........z...(...
0b52ff34  ff ff ff ff 42 99 00 1b - ff ff ff ff 80 ff 52 0b  ....B.........R.
0b52ff44  02 00 00 00 14 4b 15 07 - 00 00 00 00 d0 fd 11 1b  .....K..........
0b52ff54  00 00 00 00 ff ff ff ff - 4a 01 00 00 28 35 00 1b  ........J...(5..
0b52ff64  80 ff 52 0b 02 00 00 00 - 14 4b 15 07 ec ff 52 0b  ..R......K....R.
0b52ff74  d0 fd 11 1b 00 00 00 00 - 24 01 00 00 01 00 00 00  ........$.......
0b52ff84  00 00 00 00 84 78 a8 80 - ff ff ff ff 46 02 00 00  .....x......F...
0b52ff94  69 62 14 80 08 ee 13 f1 - 30 79 a8 80 a0 77 a8 80  ib......0y...w..
0b52ffa4  0c 78 a8 80 01 00 00 00 - 84 78 a8 80 a0 77 a8 80  .x.......x...w..
0b52ffb4  00 79 a8 80 4d 90 f6 77 - f0 4e f0 77 d0 fd 11 1b  .y..M..w.N.w....
0b52ffc4  02 00 00 00 14 4b 15 07 - d0 fd 11 1b 14 4b 15 07  .....K.......K..
0b52ffd4  c4 ff 52 0b c1 4f 00 1b - ff ff ff ff 6c b9 f3 77  ..R..O......l..w
0b52ffe4  50 d2 f3 77 00 00 00 00 - 00 00 00 00 00 00 00 00  P..w............
0b52fff4  a3 34 00 1b d0 fd 11 1b - 00 00 00 00 b0 00 00 00  .4..............
0b530004  00 01 00 00 ff ee ff ee - 02 10 00 00 00 00 00 00  ................
0b530014  00 fe 00 00 00 00 20 00 - 00 20 00 00 00 02 00 00  ...... .. ......
0b530024  00 20 00 00 e1 03 00 00 - ff ef fd 7f 11 00 48 05  . ............H.

State Dump for Thread Id 0x6c

eax=1b28c73e ebx=00000000 ecx=0012e6f4 edx=00000000 esi=000000e4 edi=061eff08
eip=77f682db esp=061efeec ebp=061eff10 iopl=0         nv up ei pl nz na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00000202


function: NtWaitForSingleObject
        77f682d0 b8c5000000       mov     eax,0xc5
        77f682d5 8d542404         lea     edx,[esp+0x4]          ss:0718e8f3=????????
        77f682d9 cd2e             int     2e
        77f682db c20c00           ret     0xc
        77f682de 8bc0             mov     eax,eax

*----> Stack Back Trace <----*

FramePtr ReturnAd Param#1  Param#2  Param#3  Param#4  Function Name
061eff10 77f04f49 000000e4 00001379 00000000 1b271a5e ntdll!NtWaitForSingleObject
00000000 00000000 00000000 00000000 00000000 00000000 kernel32!WaitForSingleObject

State Dump for Thread Id 0x18a

eax=1b28c73e ebx=00000000 ecx=0012e6f4 edx=00000000 esi=000000e4 edi=00000000
eip=77f682db esp=062efeec ebp=062eff10 iopl=0         nv up ei pl zr na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00000246


function: NtWaitForSingleObject
        77f682d0 b8c5000000       mov     eax,0xc5
        77f682d5 8d542404         lea     edx,[esp+0x4]          ss:0728e8f3=????????
        77f682d9 cd2e             int     2e
        77f682db c20c00           ret     0xc
        77f682de 8bc0             mov     eax,eax

*----> Stack Back Trace <----*

FramePtr ReturnAd Param#1  Param#2  Param#3  Param#4  Function Name
062eff10 77f04f49 000000e4 ffffffff 00000000 1b271a5e ntdll!NtWaitForSingleObject
00000000 00000000 00000000 00000000 00000000 00000000 kernel32!WaitForSingleObject

State Dump for Thread Id 0x163

eax=1b28c73e ebx=00000000 ecx=0012e6f4 edx=00000000 esi=000000e4 edi=00000000
eip=77f682db esp=063efeec ebp=063eff10 iopl=0         nv up ei pl zr na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00000246


function: NtWaitForSingleObject
        77f682d0 b8c5000000       mov     eax,0xc5
        77f682d5 8d542404         lea     edx,[esp+0x4]          ss:0738e8f3=????????
        77f682d9 cd2e             int     2e
        77f682db c20c00           ret     0xc
        77f682de 8bc0             mov     eax,eax

*----> Stack Back Trace <----*

FramePtr ReturnAd Param#1  Param#2  Param#3  Param#4  Function Name
063eff10 77f04f49 000000e4 ffffffff 00000000 1b271a5e ntdll!NtWaitForSingleObject
00000000 00000000 00000000 00000000 00000000 00000000 kernel32!WaitForSingleObject

*----> Raw Stack Dump <----*
063efeec  6b ce f1 77 e4 00 00 00 - 00 00 00 00 00 00 00 00  k..w............
063efefc  ff ff ff ff 40 06 cf 01 - 80 ff 3e 06 00 00 00 00  ....@.....>.....
063eff0c  ff ff ff ff 00 00 00 00 - 49 4f f0 77 e4 00 00 00  ........IO.w....
063eff1c  ff ff ff ff 00 00 00 00 - 5e 1a 27 1b e4 00 00 00  ........^.'.....
063eff2c  ff ff ff ff 3a 1a 27 1b - ff ff ff ff 80 ff 3e 06  ....:.'.......>.
063eff3c  88 41 53 0b ec e5 12 00 - 00 00 00 00 50 61 2b 1b  .AS.........Pa+.
063eff4c  ff ff ff ff 00 00 00 00 - 40 06 cf 01 76 87 81 7b  ........@...v..{
063eff5c  63 01 00 00 c3 c7 28 1b - 80 ff 3e 06 88 41 53 0b  c.....(...>..AS.
063eff6c  ec e5 12 00 ec ff 3e 06 - 50 61 2b 1b 00 00 00 00  ......>.Pa+.....
063eff7c  e8 00 00 00 01 00 00 00 - 00 00 00 00 00 00 00 00  ................
063eff8c  ff ff ff ff 46 02 00 00 - 69 62 14 80 08 ee 14 f1  ....F...ib......
063eff9c  b0 e1 8d 80 20 e0 8d 80 - 8c e0 8d 80 01 00 00 00  .... ...........
063effac  04 e1 8d 80 20 e0 8d 80 - 80 e1 8d 80 4d 90 f6 77  .... .......M..w
063effbc  f0 4e f0 77 50 61 2b 1b - 88 41 53 0b ec e5 12 00  .N.wPa+..AS.....
063effcc  50 61 2b 1b ec e5 12 00 - c4 ff 3e 06 01 00 00 00  Pa+.......>.....
063effdc  ff ff ff ff 6c b9 f3 77 - 50 d2 f3 77 00 00 00 00  ....l..wP..w....
063effec  00 00 00 00 00 00 00 00 - 3e c7 28 1b 50 61 2b 1b  ........>.(.Pa+.
063efffc  00 00 00 00 07 00 00 00 - 01 01 00 00 ee ff ee ff  ................
063f000c  00 00 00 00 00 00 53 0b - 00 e0 0f 00 00 00 3f 06  ......S.......?.
063f001c  00 01 00 00 38 00 3f 06 - 00 00 4f 06 fe 00 00 00  ....8.?...O.....

0
Comment
Question by:sharizod
11 Comments
 
LVL 3

Expert Comment

by:Bahnass
Comment Utility
of course U tested H/W once & Again !!!!

Hard drives, Ram, Processors are common source of problems

I hope U can test it on another m/c
0
 
LVL 1

Author Comment

by:sharizod
Comment Utility
Yes,  I have it on two different servers, and it produces the same errors.
0
 
LVL 18

Accepted Solution

by:
mdougan earned 300 total points
Comment Utility
Is there any way to tell what function you were in when the server crashed?  A protection fault will probably keep you from executing any error handling code, so, what you might try doing is writing out each method name to the Application Event log when you begin to execute any procedure in your server.  Then, when your server crashes, you can find the procedure that is giving you trouble.  Once you have that, post the code for that procedure and we'll see what we can see.....

A protection fault usually occurs when you are trying to access storage outside of the bounds of your program.  This could be a buffer overflow problem, or a problem with some other API call you are making.
0
 
LVL 28

Expert Comment

by:vinnyd79
Comment Utility
Are there any clues in the event logs at the times when the errors occured?
0
 
LVL 6

Expert Comment

by:anthony_glenwright
Comment Utility
C0000005 means "Access violation".  Probably means you are accessing memory that doesn't belong to your application.  Like mdougan says, look for API calls as the cause...

In my experience, the most common causes for these kinds of errors (when they are intermittent) is when your code assumes that a call always works (without checking the return value).

For example, calling accept() and assuming it has worked without checking the return value, then using the *addr buffer later in code (probably a bad example, but hopefully you know what I mean)
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 1

Author Comment

by:sharizod
Comment Utility
Basically, all the server does is facilitate logins, and ensures proper administration of the database (Access 97)(ie: proper backups, proper handling of connections).  Whenever a user logs in, a winsock control is automatically loaded at runtime and that connection is used until either the person logs off or the server is shutdown.  During the logon process, I do call a class that logs into windows NT first, and then validates the password on in the databsae (same as network password).

VinnyD:
There does not seem to be a specific time that the problem occurs.  As I have said before, it appears random.

MDougan, Anthony:
I make quite a number of API calls in my application. There are too many to mention, but most of them are called once when the application starts, and not again.  There is one class however, that is called whenever a user logs into the system.  I'm not sure I should post the code here as it is pretty lengthly.  The thing that is really frustrating is that the problem is intermittent, you can sometimes go weeks before having a crash happen and other times, you can get two crashes in the same day!

Thanks & best Regards
0
 
LVL 1

Author Comment

by:sharizod
Comment Utility
Ah, the post is already long.  Here is the class that I am using to log into the WinNT server from the various clients we have here (Win9x, WinNT4, Win2K).

Regards


Option Explicit

Const SEC_E_OK = &H0
Const SEC_E_INSUFFICIENT_MEMORY = &H80090300
Const SEC_E_INVALID_HANDLE = &H80090301
Const SEC_E_UNSUPPORTED_FUNCTION = &H80090302
Const SEC_E_TARGET_UNKNOWN = &H80090303
Const SEC_E_INTERNAL_ERROR = &H80090304
Const SEC_E_SECPKG_NOT_FOUND = &H80090305
Const SEC_E_NOT_OWNER = &H80090306
Const SEC_E_CANNOT_INSTALL = &H80090307
Const SEC_E_INVALID_TOKEN = &H80090308
Const SEC_E_CANNOT_PACK = &H80090309
Const SEC_E_QOP_NOT_SUPPORTED = &H8009030A
Const SEC_E_NO_IMPERSONATION = &H8009030B
Const SEC_E_LOGON_DENIED = &H8009030C
Const SEC_E_UNKNOWN_CREDENTIALS = &H8009030D
Const SEC_E_NO_CREDENTIALS = &H8009030E
Const SEC_E_MESSAGE_ALTERED = &H8009030F
Const SEC_E_OUT_OF_SEQUENCE = &H80090310
Const SEC_E_NO_AUTHENTICATING_AUTHORITY = &H80090311
Const SEC_I_CONTINUE_NEEDED = &H90312
Const SEC_I_COMPLETE_NEEDED = &H90313
Const SEC_I_COMPLETE_AND_CONTINUE = &H90314
Const SEC_I_LOCAL_LOGON = &H90315
Const SEC_E_BAD_PKGID = &H80090316
Const SEC_E_CONTEXT_EXPIRED = &H80090317
Const SEC_E_INCOMPLETE_MESSAGE = &H80090318
Const SEC_E_INCOMPLETE_CREDENTIALS = &H80090320
Const SEC_E_BUFFER_TOO_SMALL = &H80090321
Const SEC_I_INCOMPLETE_CREDENTIALS = &H90320
Const SEC_I_RENEGOTIATE = &H90321
Const SEC_E_WRONG_PRINCIPAL = &H80090322

Const SECPKG_CRED_OUTBOUND = 2
Const SECPKG_CRED_INBOUND = 1

Const SEC_WINNT_AUTH_IDENTITY_ANSI = 1
Const SEC_WINNT_AUTH_IDENTITY_UNICODE = 2

Const SECURITY_NATIVE_DREP = 16
Const SECURITY_NETWORK_DREP = 0

Const SECBUFFER_TOKEN = 2


'typedef struct _SERVER_INFO {
'    DWORD     sv101_platform_id;
'    LPWSTR    sv101_name;
'    DWORD     sv101_version_major;
'    DWORD     sv101_version_minor;
'    DWORD     sv101_type;
'    LPWSTR    sv101_comment;
'} SERVER_INFO;
 
Private Type SERVER_INFO
    platform_id As String
    name As String
    version_major As String
    version_minor As String
    type As String
    comment As String
End Type
   
   
Private Declare Function NetServerGetInfoNT Lib "netapi32.dll" Alias "NetServerGetInfo" _
    (ByVal ServerName As Long, ByVal level As Long, ByVal bufptr As Long) As Long
Private Declare Function NetServerGetInfo9X Lib "svrapi.dll" Alias "NetServerGetInfo" _
    (ByVal ServerName As String, ByVal level As Integer, ByVal bufptr As Long, ByVal buflen As Integer, ByVal totalavail As Long) As Long

Private Declare Function NetApiBufferFree Lib "netapi32.dll" (ByVal bufptr As Long) As Long

Private Type SecPkgInfo
    fCapabilities As Long   'unsigned long          Capability bitmask
    wVersion As Integer     'unsigned short         Version of driver
    wRPCID As Integer       'unsigned short         ID for RPC Runtime
    cbMaxToken As Long      'unsigned long          Size of authentication token (max)
    name As Long            'SEC_CHAR SEC_FAR *     Text name
    comment As Long         'SEC_CHAR SEC_FAR *     Comment
End Type

Private Type SEC_WINNT_AUTH_IDENTITY
    User As Long            'unsigned char __RPC_FAR *
    UserLength As Long      'unsigned long
    domain As Long          'unsigned char __RPC_FAR *
    DomainLength As Long    'unsigned long
    password As Long        'unsigned char __RPC_FAR *
    PasswordLength As Long  'unsigned long
    Flags As Long           'unsigned long
End Type

Private Type DWORD
    dwLower As Long         'unsigned long
    dwUpper As Long         'unsigned long
End Type

Private Type SecBuffer
    cbBuffer As Long        'unsigned long      Size of the buffer, in bytes
    BufferType As Long      'unsigned long      Type of the buffer (below)
    pvBuffer As Long        'void SEC_FAR *     Pointer to the buffer
End Type

Private Type SecBufferDesc
    ulVersion As Long       'unsigned long      Version number
    cBuffers As Long        'unsigned long      Number of buffers
    pBuffers As Long        'PSecBuffer         Pointer to array of buffers
End Type

Private Declare Function AcquireCredentialsHandleNT Lib "security.dll" _
    Alias "AcquireCredentialsHandleA" ( _
    ByVal pszPrincipal As Long, ByVal pszPackage As String, _
    ByVal fCredentialUse As Long, ByVal pvLogonId As Long, _
    ByVal pAuthData As Long, ByVal pGetKeyFn As Long, _
    ByVal pvGetKeyArgument As Long, ByRef PCredHandle As DWORD, _
    ByRef ptsExpiry As DWORD) As Long
Private Declare Function AcquireCredentialsHandle9X Lib "secur32.dll" _
    Alias "AcquireCredentialsHandleA" ( _
    ByVal pszPrincipal As Long, ByVal pszPackage As String, _
    ByVal fCredentialUse As Long, ByVal pvLogonId As Long, _
    ByVal pAuthData As Long, ByVal pGetKeyFn As Long, _
    ByVal pvGetKeyArgument As Long, ByRef PCredHandle As DWORD, _
    ByRef ptsExpiry As DWORD) As Long

Private Declare Function InitializeSecurityContextNT Lib "security.dll" _
    Alias "InitializeSecurityContextA" ( _
    ByRef phCredential As DWORD, ByVal phContext As Long, _
    ByVal pszTargetName As String, ByVal fContextReq As Long, _
    ByVal Reserved1 As Long, ByVal TargetDataRep As Long, _
    ByVal pInput As Long, ByVal Reserved2 As Long, _
    ByRef phNewContext As DWORD, ByRef pOutput As SecBufferDesc, _
    ByRef pfContextAttr As Long, ByRef ptsExpiry As DWORD) As Long
Private Declare Function InitializeSecurityContext9X Lib "secur32.dll" _
    Alias "InitializeSecurityContextA" ( _
    ByRef phCredential As DWORD, ByVal phContext As Long, _
    ByVal pszTargetName As String, ByVal fContextReq As Long, _
    ByVal Reserved1 As Long, ByVal TargetDataRep As Long, _
    ByVal pInput As Long, ByVal Reserved2 As Long, _
    ByRef phNewContext As DWORD, ByRef pOutput As SecBufferDesc, _
    ByRef pfContextAttr As Long, ByRef ptsExpiry As DWORD) As Long

Private Declare Function AcceptSecurityContextNT Lib "security.dll" _
    Alias "AcceptSecurityContext" ( _
    ByRef phCredential As DWORD, ByVal phContext As Long, _
    ByRef pInput As SecBufferDesc, ByVal fContextReq As Long, _
    ByVal TargetDataRep As Long, ByRef phNewContext As DWORD, _
    ByRef pOutput As SecBufferDesc, ByRef pfContextAttr As Long, _
    ByRef ptsExpiry As DWORD) As Long
Private Declare Function AcceptSecurityContext9X Lib "secur32.dll" _
    Alias "AcceptSecurityContext" ( _
    ByRef phCredential As DWORD, ByVal phContext As Long, _
    ByRef pInput As SecBufferDesc, ByVal fContextReq As Long, _
    ByVal TargetDataRep As Long, ByRef phNewContext As DWORD, _
    ByRef pOutput As SecBufferDesc, ByRef pfContextAttr As Long, _
    ByRef ptsExpiry As DWORD) As Long
   
Private Declare Function CompleteAuthTokenNT Lib "security.dll" _
    Alias "CompleteAuthToken" _
    (ByRef phContext As DWORD, ByRef pToken As SecBufferDesc) As Long
Private Declare Function CompleteAuthToken9X Lib "secur32.dll" _
    Alias "CompleteAuthToken" _
    (ByRef phContext As DWORD, ByRef pToken As SecBufferDesc) As Long
   
Private Declare Function FreeContextBufferNT Lib "security.dll" _
    Alias "FreeContextBuffer" (ByVal pvContextBuffer As Long) As Long
Private Declare Function FreeContextBuffer9X Lib "secur32.dll" _
    Alias "FreeContextBuffer" (ByVal pvContextBuffer As Long) As Long

Private Declare Function FreeCredentialsHandleNT Lib "security.dll" _
    Alias "FreeCredentialsHandle" (ByRef hcred As DWORD) As Long
Private Declare Function FreeCredentialsHandle9X Lib "secur32.dll" _
    Alias "FreeCredentialsHandle" (ByRef hcred As DWORD) As Long

Private Declare Function DeleteSecurityContextNT Lib "security.dll" _
    Alias "DeleteSecurityContext" (ByRef hctxt As DWORD) As Long
Private Declare Function DeleteSecurityContext9X Lib "secur32.dll" _
    Alias "DeleteSecurityContext" (ByRef hctxt As DWORD) As Long

Private Declare Function InitSecurityInterfaceNT Lib "security.dll" _
    Alias "InitSecurityInterfaceA" () As Long
Private Declare Function InitSecurityInterface9X Lib "secur32.dll" _
    Alias "InitSecurityInterfaceA" () As Long

Private Declare Function QuerySecurityPackageInfoNT Lib "security.dll" _
    Alias "QuerySecurityPackageInfoA" _
    (ByVal pszPackageName As String, ByRef ppPackageInfo As Long) As Integer
Private Declare Function QuerySecurityPackageInfo9X Lib "secur32.dll" _
    Alias "QuerySecurityPackageInfoA" _
    (ByVal pszPackageName As String, ByRef ppPackageInfo As Long) As Integer

Private Declare Function ImpersonateSecurityContext Lib "security.dll" _
    (ByRef hctxt As DWORD) As Long

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
    (Destination As Any, ByVal Source As Long, ByVal Length As Long)

Private Const VER_PLATFORM_WIN32_NT = 2

Private Type OSVERSIONINFO
        dwOSVersionInfoSize As Long
        dwMajorVersion As Long
        dwMinorVersion As Long
        dwBuildNumber As Long
        dwPlatformId As Long
        szCSDVersion As String * 128      '  Maintenance string for PSS usage
End Type

Dim osvi As OSVERSIONINFO

Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
    (lpVersionInformation As OSVERSIONINFO) As Long


'    SEC_CHAR SEC_FAR * pszPrincipal,    // Name of principal
'    SEC_CHAR SEC_FAR * pszPackage,      // Name of package
'    unsigned long fCredentialUse,       // Flags indicating use
'    void SEC_FAR * pvLogonId,           // Pointer to logon ID
'    void SEC_FAR * pAuthData,           // Package specific data
'    SEC_GET_KEY_FN pGetKeyFn,           // Pointer to GetKey() func
'    void SEC_FAR * pvGetKeyArgument,    // Value to pass to GetKey()
'    PCredHandle phCredential,           // (out) Cred Handle
'    PTimeStamp ptsExpiry                // (out) Lifetime (optional)

Private Function AcquireCredentialsHandle(ByVal pszPrincipal As Long, _
    ByVal pszPackage As String, ByVal fCredentialUse As Long, ByVal pvLogonId As Long, _
    ByVal pAuthData As Long, ByVal pGetKeyFn As Long, ByVal pvGetKeyArgument As Long, _
    ByRef PCredHandle As DWORD, ByRef ptsExpiry As DWORD) As Long
   
    If IsNT() Then
        AcquireCredentialsHandle = AcquireCredentialsHandleNT(pszPrincipal, _
            pszPackage, fCredentialUse, pvLogonId, pAuthData, pGetKeyFn, _
            pvGetKeyArgument, PCredHandle, ptsExpiry)
    Else
        AcquireCredentialsHandle = AcquireCredentialsHandle9X(pszPrincipal, _
            pszPackage, fCredentialUse, pvLogonId, pAuthData, pGetKeyFn, _
            pvGetKeyArgument, PCredHandle, ptsExpiry)
    End If
End Function
   
'    PCredHandle phCredential,               // Cred to base context
'    PCtxtHandle phContext,                  // Existing context (OPT)
'    SEC_CHAR SEC_FAR * pszTargetName,       // Name of target
'    unsigned long fContextReq,              // Context Requirements
'    unsigned long Reserved1,                // Reserved, MBZ
'    unsigned long TargetDataRep,            // Data rep of target
'    PSecBufferDesc pInput,                  // Input Buffers
'    unsigned long Reserved2,                // Reserved, MBZ
'    PCtxtHandle phNewContext,               // (out) New Context handle
'    PSecBufferDesc pOutput,                 // (inout) Output Buffers
'    unsigned long SEC_FAR * pfContextAttr,  // (out) Context attrs
'    PTimeStamp ptsExpiry                    // (out) Life span (OPT)

Private Function InitializeSecurityContext(ByRef phCredential As DWORD, _
    ByVal phContext As Long, ByVal pszTargetName As String, _
    ByVal fContextReq As Long, ByVal Reserved1 As Long, ByVal TargetDataRep As Long, _
    ByVal pInput As Long, ByVal Reserved2 As Long, ByRef phNewContext As DWORD, _
    ByRef pOutput As SecBufferDesc, ByRef pfContextAttr As Long, _
    ByRef ptsExpiry As DWORD) As Long
   
    If IsNT() Then
        InitializeSecurityContext = InitializeSecurityContextNT(phCredential, _
            phContext, pszTargetName, fContextReq, Reserved1, TargetDataRep, _
            pInput, Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry)
    Else
        InitializeSecurityContext = InitializeSecurityContext9X(phCredential, _
            phContext, pszTargetName, fContextReq, Reserved1, TargetDataRep, _
            pInput, Reserved2, phNewContext, pOutput, pfContextAttr, ptsExpiry)
    End If
End Function
   
'    PCredHandle phCredential,               // Cred to base context
'    PCtxtHandle phContext,                  // Existing context (OPT)
'    PSecBufferDesc pInput,                  // Input buffer
'    unsigned long fContextReq,              // Context Requirements
'    unsigned long TargetDataRep,            // Target Data Rep
'    PCtxtHandle phNewContext,               // (out) New context handle
'    PSecBufferDesc pOutput,                 // (inout) Output buffers
'    unsigned long SEC_FAR * pfContextAttr,  // (out) Context attributes
'    PTimeStamp ptsExpiry                    // (out) Life span (OPT)

Private Function AcceptSecurityContext( _
    ByRef phCredential As DWORD, ByVal phContext As Long, _
    ByRef pInput As SecBufferDesc, ByVal fContextReq As Long, _
    ByVal TargetDataRep As Long, ByRef phNewContext As DWORD, _
    ByRef pOutput As SecBufferDesc, ByRef pfContextAttr As Long, _
    ByRef ptsExpiry As DWORD) As Long
   
    If IsNT() Then
        AcceptSecurityContext = AcceptSecurityContextNT(phCredential, _
            phContext, pInput, fContextReq, TargetDataRep, phNewContext, _
            pOutput, pfContextAttr, ptsExpiry)
    Else
        AcceptSecurityContext = AcceptSecurityContext9X(phCredential, _
            phContext, pInput, fContextReq, TargetDataRep, phNewContext, _
            pOutput, pfContextAttr, ptsExpiry)
    End If
End Function
   
'    PCtxtHandle phContext,              // Context to complete
'    PSecBufferDesc pToken               // Token to complete

Private Function CompleteAuthToken _
    (ByRef phContext As DWORD, ByRef pToken As SecBufferDesc) As Long
   
    If IsNT() Then
        CompleteAuthToken = CompleteAuthTokenNT(phContext, pToken)
    Else
        CompleteAuthToken = CompleteAuthToken9X(phContext, pToken)
    End If
End Function
   
Private Function DeleteSecurityContext(ByRef hctxt As DWORD) As Long
    If IsNT() Then
        DeleteSecurityContext = DeleteSecurityContextNT(hctxt)
    Else
        DeleteSecurityContext = DeleteSecurityContext9X(hctxt)
    End If
End Function

Private Function FreeContextBuffer(ByVal pvContextBuffer As Long) As Long
    If IsNT() Then
        FreeContextBuffer = FreeContextBufferNT(pvContextBuffer)
    Else
        FreeContextBuffer = FreeContextBuffer9X(pvContextBuffer)
    End If
End Function

Private Function FreeCredentialsHandle(ByRef hcred As DWORD) As Long
    If IsNT() Then
        FreeCredentialsHandle = FreeCredentialsHandleNT(hcred)
    Else
        FreeCredentialsHandle = FreeCredentialsHandle9X(hcred)
    End If
End Function

Private Function InitSecurityInterface() As Long
    If IsNT() Then
        InitSecurityInterface = InitSecurityInterfaceNT()
    Else
        InitSecurityInterface = InitSecurityInterface9X()
    End If
End Function

Private Function QuerySecurityPackageInfo( _
    ByVal pszPackageName As String, ByRef ppPackageInfo As Long) As Integer
    If IsNT() Then
        QuerySecurityPackageInfo = _
            QuerySecurityPackageInfoNT(pszPackageName, ppPackageInfo)
    Else
        QuerySecurityPackageInfo = _
            QuerySecurityPackageInfo9X(pszPackageName, ppPackageInfo)
    End If
End Function


Function ByteToStr(b() As Byte, i As Integer) As String
    Dim s As String
   
    Do While b(i) <> 0
        s = s & Chr(b(i))
        i = i + 1
    Loop
    ByteToStr = s
End Function

Function GetServerType(i As Long) As String
    Dim s As String
    Dim nl As String
   
    nl = vbCr & vbLf
   
    If i And &H1 Then s = s & "WORKSTATION" & nl            '#define SV_TYPE_WORKSTATION         0x00000001
    If i And &H2 Then s = s & "SERVER" & nl                 '#define SV_TYPE_SERVER              0x00000002
    If i And &H4 Then s = s & "SQLSERVER" & nl              '#define SV_TYPE_SQLSERVER           0x00000004
    If i And &H8 Then s = s & "DOMAIN_CTRL" & nl            '#define SV_TYPE_DOMAIN_CTRL         0x00000008
    If i And &H10 Then s = s & "DOMAIN_BAKCTRL" & nl        '#define SV_TYPE_DOMAIN_BAKCTRL      0x00000010
    If i And &H20 Then s = s & "TIME_SOURCE" & nl           '#define SV_TYPE_TIME_SOURCE         0x00000020
    If i And &H40 Then s = s & "AFP" & nl                   '#define SV_TYPE_AFP                 0x00000040
    If i And &H80 Then s = s & "NOVELL" & nl                '#define SV_TYPE_NOVELL              0x00000080
    If i And &H100 Then s = s & "DOMAIN_MEMBER" & nl        '#define SV_TYPE_DOMAIN_MEMBER       0x00000100
    If i And &H200 Then s = s & "PRINTQ_SERVER" & nl        '#define SV_TYPE_PRINTQ_SERVER       0x00000200
    If i And &H400 Then s = s & "DIALIN_SERVER" & nl        '#define SV_TYPE_DIALIN_SERVER       0x00000400
    If i And &H800 Then s = s & "UNIX" & nl                 '#define SV_TYPE_SERVER_UNIX         0x00000800
    If i And &H1000 Then s = s & "NT" & nl                  '#define SV_TYPE_NT                  0x00001000
    If i And &H2000 Then s = s & "WFW" & nl                 '#define SV_TYPE_WFW                 0x00002000
    If i And &H4000 Then s = s & "SERVER_MFPN" & nl         '#define SV_TYPE_SERVER_MFPN         0x00004000
    If i And &H8000 Then s = s & "SERVER_NT" & nl           '#define SV_TYPE_SERVER_NT           0x00008000
    If i And &H10000 Then s = s & "POTENTIAL_BROWSER" & nl  '#define SV_TYPE_POTENTIAL_BROWSER   0x00010000
    If i And &H20000 Then s = s & "BACKUP_BROWSER" & nl     '#define SV_TYPE_BACKUP_BROWSER      0x00020000
    If i And &H40000 Then s = s & "MASTER_BROWSER" & nl     '#define SV_TYPE_MASTER_BROWSER      0x00040000
    If i And &H80000 Then s = s & "DOMAIN_MASTER" & nl      '#define SV_TYPE_DOMAIN_MASTER       0x00080000
    If i And &H100000 Then s = s & "SERVER_OSF" & nl        '#define SV_TYPE_SERVER_OSF          0x00100000
    If i And &H200000 Then s = s & "SERVER_VMS" & nl        '#define SV_TYPE_SERVER_VMS          0x00200000
    If i And &H400000 Then s = s & "WINDOWS" & nl           '#define SV_TYPE_WINDOWS             0x00400000  /* Windows95 and above */
    If i And &H800000 Then s = s & "DFS" & nl               '#define SV_TYPE_DFS                 0x00800000  /* Root of a DFS tree */
    If i And &H1000000 Then s = s & "CLUSTER_NT" & nl       '#define SV_TYPE_CLUSTER_NT          0x01000000  /* NT Cluster */
    If i And &H10000000 Then s = s & "DCE" & nl             '#define SV_TYPE_DCE                 0x10000000  /* IBM DSS (Directory and Security Services) or equivalent */
    If i And &H20000000 Then s = s & "ALTERNATE_XPORT" & nl '#define SV_TYPE_ALTERNATE_XPORT     0x20000000  /* return list for alternate transport */
    If i And &H40000000 Then s = s & "LOCAL_LIST_ONLY" & nl '#define SV_TYPE_LOCAL_LIST_ONLY     0x40000000  /* Return local list only */
    If i And &H80000000 Then s = s & "DOMAIN_ENUM" & nl     '#define SV_TYPE_DOMAIN_ENUM         0x80000000

    GetServerType = s
End Function


'5      ERROR_ACCESS_DENIED         ' win95 win98 haven't logon
'53     ERROR_BAD_NETPATH           ' server does not exist
'87     ERROR_INVALID_PARAMETER
'124    ERROR_INVALID_LEVEL
'234    ERROR_MORE_DATA             ' buffer not big enough, correct size returned

'2102   NERR_NetNotStarted
'2113   NERR_BufTooSmall            ' buffer too small for fixed length structure
'2114   NERR_ServerNotStarted
'2351   NERR_InvalidComputer        ' invalid computer name e.g. \\\\abcd

Private Function NetServerGetInfo(ServerName As String, SvrInfo As SERVER_INFO) As Long
    Dim status As Long
    Dim i As Long
    Dim s As String
   
    SvrInfo.platform_id = ""
    SvrInfo.name = ""
    SvrInfo.version_major = ""
    SvrInfo.version_minor = ""
    SvrInfo.type = ""
    SvrInfo.comment = ""
   
    If IsNT() Then
        Dim b As Long
       
        status = NetServerGetInfoNT(StrPtr(ServerName & Chr(0)), 101, VarPtr(b))
        If status = 0 Then
            CopyMemory i, b, 4
            SvrInfo.platform_id = i
            CopyMemory i, b + 8, 4
            SvrInfo.version_major = i
            CopyMemory i, b + 12, 4
            SvrInfo.version_minor = i
            CopyMemory i, b + 16, 4
            SvrInfo.type = GetServerType(i)
            i = NetApiBufferFree(b)

            '??? free buffer here
        End If
    Else
        Dim buf(100) As Byte
        Dim cb As Integer
       
        status = NetServerGetInfo9X("\\" & ServerName, 1, VarPtr(buf(0)), 100, VarPtr(cb))
        If status = 0 Then
            SvrInfo.name = ByteToStr(buf, 0)
            SvrInfo.version_major = buf(16) And &HF
            SvrInfo.version_minor = buf(17)
            CopyMemory i, VarPtr(buf(0)) + 18, 4
            SvrInfo.type = GetServerType(i)
            CopyMemory i, VarPtr(buf(0)) + 22, 4
            If SvrInfo.version_major = 0 Then
            Else
                SvrInfo.comment = ByteToStr(buf, i - VarPtr(buf(0)))
            End If
        End If
    End If
   
    NetServerGetInfo = status
End Function

Private Function IsNT() As Boolean
    IsNT = (osvi.dwPlatformId = VER_PLATFORM_WIN32_NT)
End Function

Private Function GetMsg(i As Long) As String
    Select Case i
        Case SEC_E_OK
                GetMsg = "OK"
        Case SEC_E_INSUFFICIENT_MEMORY
                GetMsg = "E: INSUFFICIENT_MEMORY"
        Case SEC_E_INVALID_HANDLE
                GetMsg = "E: INVALID_HANDLE"
        Case SEC_E_UNSUPPORTED_FUNCTION
                GetMsg = "E: UNSUPPORTED_FUNCTION"
        Case SEC_E_TARGET_UNKNOWN
                GetMsg = "E: TARGET_UNKNOWN"
        Case SEC_E_INTERNAL_ERROR
                GetMsg = "E: INTERNAL_ERROR"
        Case SEC_E_SECPKG_NOT_FOUND
                GetMsg = "E: SECPKG_NOT_FOUND"
        Case SEC_E_NOT_OWNER
                GetMsg = "E: NOT_OWNER"
        Case SEC_E_CANNOT_INSTALL
                GetMsg = "E: CANNOT_INSTALL"
        Case SEC_E_INVALID_TOKEN
                GetMsg = "E: INVALID_TOKEN"
        Case SEC_E_CANNOT_PACK
                GetMsg = "E: CANNOT_PACK"
        Case SEC_E_QOP_NOT_SUPPORTED
                GetMsg = "E: QOP_NOT_SUPPORTED"
        Case SEC_E_NO_IMPERSONATION
                GetMsg = "E: NO_IMPERSONATION"
        Case SEC_E_LOGON_DENIED
                GetMsg = "E: LOGON_DENIED"
        Case SEC_E_UNKNOWN_CREDENTIALS
                GetMsg = "E: UNKNOWN_CREDENTIALS"
        Case SEC_E_NO_CREDENTIALS
                GetMsg = "E: NO_CREDENTIALS"
        Case SEC_E_MESSAGE_ALTERED
                GetMsg = "E: MESSAGE_ALTERED"
        Case SEC_E_OUT_OF_SEQUENCE
                GetMsg = "E: OUT_OF_SEQUENCE"
        Case SEC_E_NO_AUTHENTICATING_AUTHORITY
                GetMsg = "E: NO_AUTHENTICATING_AUTHORITY"
        Case SEC_I_CONTINUE_NEEDED
                GetMsg = "I: CONTINUE_NEEDED"
        Case SEC_I_COMPLETE_NEEDED
                GetMsg = "I: COMPLETE_NEEDED"
        Case SEC_I_COMPLETE_AND_CONTINUE
                GetMsg = "I: COMPLETE_AND_CONTINUE"
        Case SEC_I_LOCAL_LOGON
                GetMsg = "I: LOCAL_LOGON"
        Case SEC_E_BAD_PKGID
                GetMsg = "E: BAD_PKGID"
        Case SEC_E_CONTEXT_EXPIRED
                GetMsg = "E: CONTEXT_EXPIRED"
        Case SEC_E_INCOMPLETE_MESSAGE
                GetMsg = "E: INCOMPLETE_MESSAGE"
        Case SEC_E_INCOMPLETE_CREDENTIALS
                GetMsg = "E: INCOMPLETE_CREDENTIALS"
        Case SEC_E_BUFFER_TOO_SMALL
                GetMsg = "E: BUFFER_TOO_SMALL"
        Case SEC_I_INCOMPLETE_CREDENTIALS
                GetMsg = "I: INCOMPLETE_CREDENTIALS"
        Case SEC_I_RENEGOTIATE
                GetMsg = "I: RENEGOTIATE"
        Case SEC_E_WRONG_PRINCIPAL
                GetMsg = "E: WRONG_PRINCIPAL"
        Case Else
                GetMsg = "Unknown Error"
    End Select
End Function

Private Sub StrToByte(s As String, b() As Byte)
    Dim i As Integer
   
    For i = 0 To Len(s) - 1
        b(i) = Asc(Mid(s, i + 1, 1))
    Next i
    b(i) = 0
End Sub

Public Function SSPILogonUser(User As String, password As String, _
                                domain As String, errmsg) As Boolean
    Dim i As Long
    Dim ppkgInfo As Long
    Dim hcred As DWORD
    Dim AuthIdentity As SEC_WINNT_AUTH_IDENTITY
    Dim UserBuf(20) As Byte
    Dim DomainBuf(20) As Byte
    Dim PasswordBuf(20) As Byte
    Dim hctxt As DWORD
    Dim OutBuffDesc As SecBufferDesc
    Dim OutSecBuff As SecBuffer
    Dim ContextAttributes As Long
    Dim LifeTime As DWORD
    Dim cbMaxMessage As Long
 
    AuthIdentity.domain = VarPtr(DomainBuf(0))
    AuthIdentity.DomainLength = Len(domain)
    AuthIdentity.password = VarPtr(PasswordBuf(0))
    AuthIdentity.PasswordLength = Len(password)
    AuthIdentity.User = VarPtr(UserBuf(0))
    AuthIdentity.UserLength = Len(User)
    AuthIdentity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI
     
    StrToByte domain, DomainBuf
    StrToByte User, UserBuf
    StrToByte password, PasswordBuf
   
    i = InitSecurityInterface
    If i < 0 Then GoTo error
   
    i = QuerySecurityPackageInfo("NTLM", ppkgInfo)
    If i < 0 Then GoTo error
   
    i = FreeContextBuffer(ppkgInfo)
    If i < 0 Then GoTo error
   
    CopyMemory cbMaxMessage, ppkgInfo + 8, 4

    '----------------------------------- negotiate, Client Initialization
   
    ReDim pOut(cbMaxMessage) As Byte
   
    OutSecBuff.cbBuffer = cbMaxMessage
    OutSecBuff.pvBuffer = VarPtr(pOut(0))
    OutSecBuff.BufferType = SECBUFFER_TOKEN
    OutBuffDesc.ulVersion = 0
    OutBuffDesc.cBuffers = 1
    OutBuffDesc.pBuffers = VarPtr(OutSecBuff)

    i = AcquireCredentialsHandle(0, "NTLM", SECPKG_CRED_OUTBOUND, 0, _
            VarPtr(AuthIdentity), 0, 0, hcred, LifeTime)
    If i < 0 Then GoTo error
         
    i = InitializeSecurityContext(hcred, 0, "\\AuthSamp", 0, 0, _
            SECURITY_NATIVE_DREP, 0, 0, hctxt, OutBuffDesc, _
            ContextAttributes, LifeTime)
    If i < 0 Then GoTo error
           
    If i = SEC_I_COMPLETE_NEEDED Or i = SEC_I_COMPLETE_AND_CONTINUE Then
        i = CompleteAuthToken(hctxt, OutBuffDesc)
        MsgBox ("COMPLETE should not be required for NTLM.")
    End If
   
    '----------------------------------- challenge
   
    Dim hCred2 As DWORD
    Dim hctxt2 As DWORD
    Dim InBuffDesc2 As SecBufferDesc
    Dim InSecBuff2 As SecBuffer
    Dim OutBuffDesc2 As SecBufferDesc
    Dim OutSecBuff2 As SecBuffer
    ReDim pout2(cbMaxMessage) As Byte
   
    i = AcquireCredentialsHandle(0, "NTLM", SECPKG_CRED_INBOUND, 0, _
            0, 0, 0, hCred2, LifeTime)  ' Server initialization
    If i < 0 Then GoTo error
         
    InSecBuff2.cbBuffer = OutSecBuff.cbBuffer
    InSecBuff2.pvBuffer = OutSecBuff.pvBuffer
    InSecBuff2.BufferType = SECBUFFER_TOKEN
    InBuffDesc2.ulVersion = 0
    InBuffDesc2.cBuffers = 1
    InBuffDesc2.pBuffers = VarPtr(InSecBuff2)
   
    OutSecBuff2.cbBuffer = cbMaxMessage
    OutSecBuff2.pvBuffer = VarPtr(pout2(0))
    OutSecBuff2.BufferType = SECBUFFER_TOKEN
    OutBuffDesc2.ulVersion = 0
    OutBuffDesc2.cBuffers = 1
    OutBuffDesc2.pBuffers = VarPtr(OutSecBuff2)
   
    'server transmits the output security buffer and length back to the client.
   
    i = AcceptSecurityContext(hCred2, 0, InBuffDesc2, 0, SECURITY_NATIVE_DREP, _
            hctxt2, OutBuffDesc2, ContextAttributes, LifeTime)
    If i < 0 Then GoTo error
   
    '----------------------------------- authenticate

    Dim InSecBuff As SecBuffer
    Dim InBuffDesc As SecBufferDesc
   
    InSecBuff.cbBuffer = OutSecBuff2.cbBuffer
    InSecBuff.pvBuffer = OutSecBuff2.pvBuffer
    InSecBuff.BufferType = SECBUFFER_TOKEN
    InBuffDesc.ulVersion = 0
    InBuffDesc.cBuffers = 1
    InBuffDesc.pBuffers = VarPtr(InSecBuff)
   
    OutSecBuff.cbBuffer = cbMaxMessage
   
    ' the client transmits the output security buffer and buffer length to the server,
    ' as it did after the first call to InitializeSecurityContext.
    ' The client has now finished setting up the security context.
   
    i = InitializeSecurityContext(hcred, VarPtr(hctxt), "\\AuthSamp", 0, 0, _
            SECURITY_NATIVE_DREP, VarPtr(InBuffDesc), 0, hctxt, OutBuffDesc, _
            ContextAttributes, LifeTime)
    If i < 0 Then GoTo error

    '----------------------------------- authenticate
   
    InSecBuff2.cbBuffer = OutSecBuff.cbBuffer
    InSecBuff2.pvBuffer = OutSecBuff.pvBuffer
   
    OutSecBuff2.cbBuffer = cbMaxMessage
   
    ' The server makes the final call to AcceptSecurityContext
   
    i = AcceptSecurityContext(hCred2, VarPtr(hctxt2), InBuffDesc2, 0, _
            SECURITY_NATIVE_DREP, hctxt2, OutBuffDesc2, ContextAttributes, LifeTime)
                                         '^ no output security token, can use null instead of OutSecBuff2
    If i < 0 Then GoTo error
   
    ' the client was successfully authenticated
   
'    i = ImpersonateSecurityContext(hctxt2)
'    If i < 0 Then GoTo error
   
   
   
    i = DeleteSecurityContext(hctxt)
    If i < 0 Then GoTo error
    i = DeleteSecurityContext(hctxt2)
    If i < 0 Then GoTo error
    i = FreeCredentialsHandle(hcred)
    If i < 0 Then GoTo error
    i = FreeCredentialsHandle(hCred2)
    If i < 0 Then GoTo error
   
    SSPILogonUser = True
    Exit Function

error:

    errmsg = GetMsg(i)
    SSPILogonUser = False
   
End Function

Public Function LoginNT(txtName As String, txtPassword As String, _
txtDomain As String, errmsg, isocknum As Integer)
   
    'Dim errmsg As String
    Dim status As Integer
    Dim i As Integer
   
'    DoCmd.Hourglass True
   
    osvi.dwOSVersionInfoSize = 148
    i = GetVersionEx(osvi)
   
    status = SSPILogonUser(txtName, txtPassword, txtDomain, errmsg)
       
    If status Then
        LoginNT = True
    Else
        LoginNT = False
        If errmsg = "E: NO_AUTHENTICATING_AUTHORITY" Then
            SendMsg "NOAUTHENTICATINGAUTHORITY", isocknum
            'MsgBox "No authenticating authority. You need to enable user level access in Win95/Win98. " & _
                "It can be set in control panel/network/access control/" & _
                "user level access control."
            Exit Function
        End If
       
        If errmsg = "E: LOGON_DENIED" Then
            'MsgBox "Incorrect password, user name or domain name! Please re-enter!"
            SendMsg "NOTVALIDONNETWORK", isocknum
            'frmServer.ServerSock.Item(iSockNum).SendData ("NOTVALIDONNETWORK")
            Exit Function
        End If
       
        If errmsg = "E: UNSUPPORTED_FUNCTION" Then
            SendMsg "NODCOM", isocknum
            'MsgBox "If you are running Win95/Win98 but haven't " & _
            "installed DCOM95/DCOM98, please do so and try again."
            Exit Function
        End If

        MsgBox "Please request help from the administrator. " & errmsg
    End If
   
End Function
0
 
LVL 6

Expert Comment

by:anthony_glenwright
Comment Utility
I'd suggest writing to a log file (text file) from lots of points in your code to try to narrow the problem down.
0
 
LVL 1

Author Comment

by:sharizod
Comment Utility

Hmm, well, I think I will comment out the code that uses the NTLogin class and see how that goes for a 1-2 week period.  I suppose the PO system doesn't HAVE TO do that.
I thought it would be easier on users to make their logins the same as their network password, but that hasn't proved to be the case as we force password changes every 6 weeks.
I'm fairly sure that the cause is in that class - somewhere!  That is the only code with API calls that is called from an action triggered by a remote client machine.
Further, the crash seems to happen when people are trying to login.  The login class  also supposedly requires all Win9x machines to use user-level Access control as opposed to share-Level, but I have seen machines that work on the default share-level??

I still do have a log file being written to the local drive on the server.  I put it in the DataArrival event of the winsock control array, so, if it does happen again (without the NTlogin class of course), then I can narrow down what may be the root cause.  If there are no crashes, then I will assume it was the class.  

If any WinNT network programming experts can see any potential problems with the class in the meantime, I'm sure we'd all like to know what they are! =)

Thanks all & Best Regards
Bob
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
Learning...
0
 
LVL 1

Author Comment

by:sharizod
Comment Utility
Sorry for the delay, I haven't been able to test the program sans the NTLogin stuff (API calls a plenty in there) until 2 weeks ago.  The server app has not crashed since I remmed it out!  

Thanks again,
Bob
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now