Jump to content
Excelsior Forums
gadiga

INVALID_ACCESS_VIOLATION

Recommended Posts

Hi All

 I get this error when I am trying to access a winapi function. The code is as follows:

try {

     foo = new xFunction("Advapi32",

         "int GetUserNameA(CSTRING, int)");

     //foo = new xFunction("kernel32", "int Beep(int,int)");

   }

   catch (Exception xe) {

     System.out.println("XFunction Init Error:" + xe.toString());

   }

   try {

     Argument[] args = new Argument[2];

     StringBuffer sb = new StringBuffer();

     int iCount = 0;

     for (iCount=0; iCount < 1024; iCount++)

     {

       sb.append(" ");

     }

     uName = sb.toString();

     Argument CompName = new Argument(uName, Argument.CSTRING);

     Argument iSize = new Argument(iCount);

     args[0] = CompName;

     args[1] = iSize;

     foo.invoke(args);

     uName = (String) args[0].getValue();

     //int ret = ((Integer) foo.invoke(new Argument(463610), new Argument(1024), new Argument(0), new Argument(0))).intValue();

     //foo.invoke(new Argument(1770), new Argument(100));

   }

   catch (Exception xe) {

     System.out.println(

         "Could not get computer name." +  xe.toString());

     return err;

   }

The Error message is as follows:

An unexpected exception has been detected in native code outside the VM.

Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x77FE1DE8

Function=GetUserNameExA+0x14

Library=C:\WINDOWS\system32\Secur32.dll

Current Java thread:

     at com.excelsior.xFunction.xFunction.callFunc(Native Method)

     at com.excelsior.xFunction.xFunction.invoke(xFunction.java:120)

     at temsj2ee.notifications.ServerControl.GetComputerUserName(ServerControl.java:275)

     at temsj2ee.ProvisionerFunctions.Initialize(ProvisionerFunctions.java:115)

     at temsj2ee.ProvisionerFunctions.<init>(ProvisionerFunctions.java:85)

     at temsj2ee.ProvisionerFunctions.main(ProvisionerFunctions.java:1218)

Dynamic libraries:

0x00400000 - 0x00407000      C:\JBuilderX\jdk1.4\bin\javaw.exe

0x7C900000 - 0x7C9B0000      C:\WINDOWS\system32\ntdll.dll

0x7C800000 - 0x7C8F4000      C:\WINDOWS\system32\kernel32.dll

0x77DD0000 - 0x77E6B000      C:\WINDOWS\system32\ADVAPI32.dll

0x77E70000 - 0x77F01000      C:\WINDOWS\system32\RPCRT4.dll

0x77D40000 - 0x77DD0000      C:\WINDOWS\system32\USER32.dll

0x77F10000 - 0x77F56000      C:\WINDOWS\system32\GDI32.dll

0x77C10000 - 0x77C68000      C:\WINDOWS\system32\MSVCRT.dll

0x08000000 - 0x08136000      C:\JBuilderX\jdk1.4\jre\bin\client\jvm.dll

0x76B40000 - 0x76B6D000      C:\WINDOWS\system32\WINMM.dll

0x10000000 - 0x10007000      C:\JBuilderX\jdk1.4\jre\bin\hpi.dll

0x00830000 - 0x0083E000      C:\JBuilderX\jdk1.4\jre\bin\verify.dll

0x00840000 - 0x00858000      C:\JBuilderX\jdk1.4\jre\bin\java.dll

0x00860000 - 0x0086D000      C:\JBuilderX\jdk1.4\jre\bin\zip.dll

0x02B50000 - 0x02B6C000      C:\JBuilderX\jdk1.4\jre\bin\jdwp.dll

0x06B70000 - 0x06B75000      C:\oracle\ora92\jre\1.4.2\bin\dt_socket.dll

0x71AB0000 - 0x71AC7000      C:\WINDOWS\system32\ws2_32.dll

0x71AA0000 - 0x71AA8000      C:\WINDOWS\system32\WS2HELP.dll

0x71A50000 - 0x71A8F000      C:\WINDOWS\System32\mswsock.dll

0x76F20000 - 0x76F47000      C:\WINDOWS\system32\DNSAPI.dll

0x76FB0000 - 0x76FB8000      C:\WINDOWS\System32\winrnr.dll

0x76F60000 - 0x76F8C000      C:\WINDOWS\system32\WLDAP32.dll

0x76FC0000 - 0x76FC6000      C:\WINDOWS\system32\rasadhlp.dll

0x662B0000 - 0x66308000      C:\WINDOWS\system32\hnetcfg.dll

0x71A90000 - 0x71A98000      C:\WINDOWS\System32\wshtcpip.dll

0x06F60000 - 0x06F6F000      C:\JBuilderX\jdk1.4\jre\bin\net.dll

0x073D0000 - 0x073E1000      D:\xfunc-ext\xFunction.dll

0x07840000 - 0x078B8000      D:\jbproject\temsj2ee\ems.dll

0x77FE0000 - 0x77FF1000      C:\WINDOWS\system32\Secur32.dll

0x76C90000 - 0x76CB8000      C:\WINDOWS\system32\imagehlp.dll

0x59A60000 - 0x59B01000      C:\WINDOWS\system32\DBGHELP.dll

0x77C00000 - 0x77C08000      C:\WINDOWS\system32\VERSION.dll

0x76BF0000 - 0x76BFB000      C:\WINDOWS\system32\PSAPI.DLL

Share this post


Link to post
Share on other sites

The second argument to GetUserName function should be not a size, but a pointer to variable which holds size.

BTW, there is no need in complex StringBuffer creation in your code. Use

 CompName = new Argument("", Argument.CSTRING, 1024);

instead.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×