public static SWbemServices connect(JISession session, String hostName) throws UnknownHostException, JIException { JIComServer comStub = new JIComServer( JIClsid.valueOf("76A64158-CB41-11D1-8B02-00600806D9B6"),hostName, session); SWbemLocator loc = JInteropInvocationHandler.wrap(SWbemLocator.class,comStub.createInstance()); return loc.ConnectServer("localhost", null, null, null, null, null, 0, null); }
/** Execute a Method on the COM Interface identified by the IID. * * * @exclude * @param obj * @param targetIID * @return * @throws JIException */ Object[] call(JICallBuilder obj,String targetIID) throws JIException { return call(obj, targetIID, session.getGlobalSocketTimeout()); }
@Override public JIInterfacePointer internal_getInterfacePointer () { return this.ptr == null ? this.session.getStub ().getServerInterfacePointer () : this.ptr; }
public void startQTP() throws JIException{ System.out.println(comServer.getProperties()); unknown = comServer.createInstance(); dispatch = (IJIDispatch)JIObjectFactory.narrowObject(unknown.queryInterface(IJIDispatch.IID)); //System.out.println(((JIVariant)dispatch.get("Version")).getObjectAsString().getString()); }
return (IJIDispatch) JIObjectFactory.narrowObject( wbemLocatorComObj.createInstance().queryInterface( IJIDispatch.IID ) );
/** * Returns an Interface Pointer representation from raw bytes. * * @exclude * @param session * @param rawBytes * @return * @throws JIException */ public static IJIComObject instantiateComObject ( final JISession session, final byte[] rawBytes, final String ipAddress ) throws JIException { final NetworkDataRepresentation ndr = new NetworkDataRepresentation (); final NdrBuffer ndrBuffer = new NdrBuffer ( rawBytes, 0 ); ndr.setBuffer ( ndrBuffer ); ndrBuffer.length = rawBytes.length; //this is a brand new session. if ( session.getStub () == null ) { final JIComServer comServer = new JIComServer ( session, JIInterfacePointer.decode ( ndr, new ArrayList (), JIFlags.FLAG_REPRESENTATION_INTERFACEPTR_DECODE2, new HashMap () ), ipAddress ); return comServer.getInstance (); } else { final IJIComObject retval = instantiateComObject ( session, JIInterfacePointer.decode ( ndr, new ArrayList (), JIFlags.FLAG_REPRESENTATION_INTERFACEPTR_DECODE2, new HashMap () ) ); //increasing the reference count. retval.addRef (); return retval; } }
attach (); getEndpoint ().getSyntax ().setUuid ( new rpc.core.UUID ( "99fcfec4-5260-101b-bbcb-00aa0021347a" ) ); getEndpoint ().getSyntax ().setVersion ( 0, 0 ); ( (JIComEndpoint)getEndpoint () ).rebindEndPoint (); getEndpoint ().getSyntax ().setUuid ( new rpc.core.UUID ( "4d9f4ab8-7d1c-11cf-861e-0020af6e7c57" ) ); getEndpoint ().getSyntax ().setVersion ( 0, 0 ); ( (JIComEndpoint)getEndpoint () ).rebindEndPoint (); call ( Endpoint.IDEMPOTENT, this.remoteActivation ); detach (); JIStringBinding binding = null; JIStringBinding nameBinding = null; String targetAddress = getAddress (); targetAddress = targetAddress.substring ( targetAddress.indexOf ( ':' ) + 1, targetAddress.indexOf ( '[' ) ); while ( i < bindings.length ) setAddress ( "ncacn_ip_tcp:" + address ); this.remunknownIPID = this.remoteActivation.getIPID ();
public MSExcel(String address,String[] args) throws JIException, UnknownHostException { session = JISession.createSession(args[1],args[2],args[3]); comServer = new JIComServer(JIProgId.valueOf("Excel.Application"),address,session); }
setSocketTimeOut(socketTimeout); setSocketTimeOut(socketTimeout); attach(); if (!getEndpoint().getSyntax().getUuid().toString().equalsIgnoreCase(targetIID)) getEndpoint().getSyntax().setUuid(new rpc.core.UUID(targetIID)); getEndpoint().getSyntax().setVersion(0,0); ((JIComEndpoint)getEndpoint()).rebindEndPoint(); setObject(obj.getParentIpid()); call(Endpoint.IDEMPOTENT,obj);
if ( session.stub.getServerInterfacePointer () != null ) if ( !listOfFreeIPIDs.contains ( session.stub.getServerInterfacePointer ().getIPID () ) ) list.add ( session.prepareForReleaseRef ( session.stub.getServerInterfacePointer ().getIPID (), ( (JIStdObjRef)session.stub.getServerInterfacePointer ().getObjectReference ( JIInterfacePointer.OBJREF_STANDARD ) ).getPublicRefs () ) ); listOfFreeIPIDs.add ( session.stub.getServerInterfacePointer ().getIPID () ); try session.stub.closeStub (); //close the existing connection session.releaseRefs ( array, true ); listOfSessions.remove ( session ); if ( session.stub.getServerInterfacePointer () != null ) mapOfOxidsVsJISessions.remove ( new JIOxid ( session.stub.getServerInterfacePointer ().getOXID () ) ); session.stub.closeStub (); session.stub2.closeStub ();
/** <p>Refer {@link #JIComServer(JIClsid, JISession)} for details. * * * @param clsid 128 bit string such as "00024500-0000-0000-C000-000000000046". * @param address address of the host where the <code>COM</code> object resides.This should be in the IEEE IP format (e.g. 192.168.170.6) or a resolvable HostName. * @param session session to be associated with. * @throws JIException will <i>also</i> get thrown in case the <code>session</code> is associated with another server already. * @throws IllegalArgumentException raised when any of the parameters is <code>null</code>. * @throws UnknownHostException */ public JIComServer(JIClsid clsid,String address, JISession session) throws JIException, UnknownHostException { super(); if (clsid == null || address == null || session == null) { throw new IllegalArgumentException(JISystem.getLocalizedMessage(JIErrorCodes.JI_COMSTUB_ILLEGAL_ARGUMENTS)); } if (session.getStub() != null) { throw new JIException(JIErrorCodes.JI_SESSION_ALREADY_ESTABLISHED); } address = address.trim(); //address = address.replace(' ',''); address = "ncacn_ip_tcp:"+InetAddress.getByName(address).getHostAddress()+"[135]"; initialise(clsid,address,session); }
try init (); init (); this.session.setStub2 ( new JIRemUnknownServer ( session, this.remunknownIPID, getAddress () ) );
@Override public IJIComObject queryInterface ( final String iid ) throws JIException { checkLocal (); return this.session.getStub ().getInterface ( iid, this.ptr.getIPID () ); }
setSocketTimeOut(socketTimeout); setSocketTimeOut(socketTimeout);
public void getOPC() throws JIException { unknown = comStub.createInstance(); opcServer = (IJIComObject)unknown.queryInterface("39C13A4D-011E-11D0-9675-0020AFD8ADB3"); }
/** Returns an Interface Pointer representation from raw bytes. * * @exclude * @param session * @param rawBytes * @return * @throws JIException */ public static IJIComObject instantiateComObject(JISession session,byte[] rawBytes, String ipAddress) throws JIException { NetworkDataRepresentation ndr = new NetworkDataRepresentation(); NdrBuffer ndrBuffer = new NdrBuffer(rawBytes,0); ndr.setBuffer(ndrBuffer); ndrBuffer.length = rawBytes.length; //this is a brand new session. if (session.getStub() == null) { JIComServer comServer = new JIComServer(session,JIInterfacePointer.decode(ndr, new ArrayList(), JIFlags.FLAG_REPRESENTATION_INTERFACEPTR_DECODE2, new HashMap()),ipAddress); return comServer.getInstance(); } else { IJIComObject retval = instantiateComObject(session, JIInterfacePointer.decode(ndr, new ArrayList(), JIFlags.FLAG_REPRESENTATION_INTERFACEPTR_DECODE2, new HashMap())); //increasing the reference count. retval.addRef(); return retval; } }
try { syntax = "99fcfec4-5260-101b-bbcb-00aa0021347a:0.0"; attach(); getEndpoint().getSyntax().setUuid(new rpc.core.UUID("99fcfec4-5260-101b-bbcb-00aa0021347a")); getEndpoint().getSyntax().setVersion(0,0); ((JIComEndpoint)getEndpoint()).rebindEndPoint(); getEndpoint().getSyntax().setUuid(new rpc.core.UUID("4d9f4ab8-7d1c-11cf-861e-0020af6e7c57")); getEndpoint().getSyntax().setVersion(0,0); ((JIComEndpoint)getEndpoint()).rebindEndPoint(); call(Endpoint.IDEMPOTENT,remoteActivation); }catch(FaultException e) detach(); } catch (IOException e) { if (JISystem.getLogger().isLoggable(Level.WARNING)) JIStringBinding binding = null; JIStringBinding nameBinding = null; String targetAddress = getAddress(); targetAddress = targetAddress.substring(targetAddress.indexOf(':') + 1,targetAddress.indexOf('[')); while(i < bindings.length) setAddress("ncacn_ip_tcp:" + address); remunknownIPID = remoteActivation.getIPID();
public MSPowerPoint2(String address, String[] args) throws JIException, UnknownHostException { JISession session = JISession.createSession(args[1],args[2],args[3]); comStub = new JIComServer(JIProgId.valueOf("PowerPoint.Application"),address,session); }
setSocketTimeOut ( socketTimeout ); setSocketTimeOut ( socketTimeout ); attach (); if ( !getEndpoint ().getSyntax ().getUuid ().toString ().equalsIgnoreCase ( targetIID ) ) getEndpoint ().getSyntax ().setUuid ( new rpc.core.UUID ( targetIID ) ); getEndpoint ().getSyntax ().setVersion ( 0, 0 ); ( (JIComEndpoint)getEndpoint () ).rebindEndPoint (); setObject ( obj.getParentIpid () ); call ( Endpoint.IDEMPOTENT, obj );