Hello,
I am trying to call LsaOpenPolicy.
See my code below. When I run it, I get:
Exception c0000005, at 77DE1C38
Access violation: attempting to write memory at address 00000000
Native function stack data: 0,b0e2bd0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,ffff,b0e2df0,0,460050,2000000,3503f8,3503f8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
I assume there is a problem with the last parameter.
Can someone please help?
Regards
Anders
-
package jniwrapper;
import com.jniwrapper.DefaultLibraryLoader;
import com.jniwrapper.Function;
import com.jniwrapper.Library;
import com.jniwrapper.Parameter;
import com.jniwrapper.Pointer;
import com.jniwrapper.Structure;
import com.jniwrapper.UInt32;
import com.jniwrapper.ULongInt;
import com.jniwrapper.WideString;
/**
*
*/
/**
@author Anders Nilsson
*
*/
public class TestLsaOpenPolicy {
private static class LSA_OBJECT_ATTRIBUTES extends Structure
{
/*
typedef struct LSAOBJECT_ATTRIBUTES {
ULONG Length;
HANDLE RootDirectory;
PLSA_UNICODE_STRING ObjectName;
ULONG Attributes;
PVOID SecurityDescriptor;
PVOID SecurityQualityOfService;
} LSA_OBJECT_ATTRIBUTES, *PLSA_OBJECT_ATTRIBUTES;
*/
public ULongInt length = new ULongInt();
public Pointer.Void rootDirectory = new Pointer.Void();
public WideString objectName = new WideString();
public ULongInt attributes = new ULongInt();
public Pointer.Void securityDescriptor = new Pointer.Void();
public Pointer.Void securityQualityOfService = new Pointer.Void();
public LSA_OBJECT_ATTRIBUTES()
{
init(new Parameter[] {
length,
rootDirectory,
objectName,
attributes,
securityDescriptor,
securityQualityOfService
});
}
}
private Library _advapi;
private Library _kernel;
public TestLsaOpenPolicy() {
_kernel = new Library("kernel32");
_advapi = new Library("Advapi32");
}
/**
@param args
*/
public static void main(String[] args) {
TestLsaOpenPolicy t;
t = new TestLsaOpenPolicy();
t.execute(args);
}
protected void execute(String[] args) {
Parameter[] argn;
Pointer.Void rtrn;
DefaultLibraryLoader.getInstance().addPath(
"G:
eclipse
newton
MetaData
GenericMechanisms
extlib");
// Open Policy
Function openPolicy = _advapi.getFunction("LsaOpenPolicy");
UInt32 lsaHandle;
lsaHandle = new UInt32(0);
rtrn = new Pointer.Void(0);
argn = new Parameter[4];
argn[0] = new WideString();
argn[1] = new LSA_OBJECT_ATTRIBUTES();
argn[2] = new UInt32(0x0000FFFF);
argn[3] = new Pointer(lsaHandle);
openPolicy.invoke(rtrn, argn);
System.out.println(rtrn);
}
private long getLastError(boolean clear)
{
UInt32 r = new UInt32();
Function getLE = _kernel.getFunction("GetLastError");
getLE.invoke(r);
long errCode = r.getValue();
if (clear)
{
UInt32 zero = new UInt32(0);
Function setLE = _kernel.getFunction("SetLastError");
setLE.invoke(null, zero);
}
return errCode;
}
}