[jcifs] SVCCTL.idl/Remote Execution Working!
michaelm
michaelm at managesoft.com
Tue Sep 21 13:12:00 GMT 2004
Hi Mike,
We have managed to get several of the SVCCTL APIs working.
namely:
OpenSCManagerW()
OpenServiceW()
CreateServceW()
StartServiceW()
We had to play with the generated code from the idlc. So I think you are
right about the idlc compiler being a little out of wack. We also needed
to tweek the IDL API.
I have attached the generated svrctl.java code plus the adjusted
srvctl.java so that you can get a diff of the changes. I have also
attached the idl we used.
Hope that helps with the new idlc.
cheers,
Michael
On Fri, 2004-09-17 at 20:51, Michael B Allen wrote:
> On Fri, 17 Sep 2004 17:25:29 +0200
> michaelm <michaelm at managesoft.com> wrote:
>
> > Hi Mike, and jcifs mailing list gang,
> >
> > Following on from our previous discussion, I think the the IDL
> > interaface for OpenServiceW is as follows
> >
> > [op(0x10)]
> > int OpenServiceW([in] policy_handle *scmanager_handle,
> > [in,string] wchat_t *ServiceName,
> > [in] uint32_t access_mask,
> > [out] policy_handle *service_handle);
> >
> > Note that I added the an extra [out] argument for the service handle.
> > The windows API has a SC_HANDLE return value instead:
> >
> > SC_HANDLE OpenService(
> > SC_HANDLE hSCManager,
> > LPCTSTR lpServiceName,
> > DWORD dwDesiredAccess);
>
> Wait for the next version of the idl compiler. I think you might have better
> luck with that. After I release that I'll take a look at svcctl too. I have
> no eta on the compiler. I know how I want the stubs to look but I'm not
> certain how I'm going to emit the code in a generic way. It will take a few
> days.
>
> Mike
-------------- next part --------------
import ndr.*;
import rpc.*;
public class svcctl extends Stub {
protected String getSyntax() {
return "367abb81-9844-35f1-ad32-98f038001003:2.0";
}
public static class uuid_t extends NdrObject {
public int time_low;
public short time_mid;
public short time_hi_and_version;
public byte clock_seq_hi_and_reserved;
public byte clock_seq_low;
public byte[] node;
public void encode(NetworkDataRepresentation ndr, NdrBuffer dst) throws NdrException {
int _size_is;
dst.enc_ndr_long(time_low);
dst.enc_ndr_short(time_mid);
dst.enc_ndr_short(time_hi_and_version);
dst.enc_ndr_small(clock_seq_hi_and_reserved);
dst.enc_ndr_small(clock_seq_low);
for (int i = 0; i < 6; i++) {
dst.enc_ndr_small(node[i]);
}
}
public void decode(NetworkDataRepresentation ndr, NdrBuffer src) throws NdrException {
int _size_is;
time_low = (int)src.dec_ndr_long();
time_mid = (short)src.dec_ndr_short();
time_hi_and_version = (short)src.dec_ndr_short();
clock_seq_hi_and_reserved = (byte)src.dec_ndr_small();
clock_seq_low = (byte)src.dec_ndr_small();
if (node == null) {
node = new byte[6];
}
for (int i = 0; i < 6; i++) {
node[i] = (byte)src.dec_ndr_small();
}
}
}
public static class policy_handle extends NdrObject {
public int type;
public uuid_t uuid;
public void encode(NetworkDataRepresentation ndr, NdrBuffer dst) throws NdrException {
dst.enc_ndr_long(type);
dst.deferred.align(4);
uuid.encode(ndr, dst.getDeferred(16));
}
public void decode(NetworkDataRepresentation ndr, NdrBuffer src) throws NdrException {
type = (int)src.dec_ndr_long();
src.align(4);
uuid.decode(ndr, src);
}
}
public static class sid_t extends NdrObject {
public byte revision;
public byte sub_authority_count;
public byte[] identifier_authority;
public int[] sub_authority;
public void encode(NetworkDataRepresentation ndr, NdrBuffer dst) throws NdrException {
int _size_is;
dst.enc_ndr_small(revision);
dst.enc_ndr_small(sub_authority_count);
for (int i = 0; i < 6; i++) {
dst.enc_ndr_small(identifier_authority[i]);
}
_size_is = sub_authority_count;
dst.deferred.enc_ndr_long(_size_is);
NdrBuffer deferred = dst.getDeferred(_size_is * 4);
for (int i = 0; i < _size_is; i++) {
deferred.enc_ndr_long(sub_authority[i]);
}
}
public void decode(NetworkDataRepresentation ndr, NdrBuffer src) throws NdrException {
int _size_is;
revision = (byte)src.dec_ndr_small();
sub_authority_count = (byte)src.dec_ndr_small();
if (identifier_authority == null) {
identifier_authority = new byte[6];
}
for (int i = 0; i < 6; i++) {
identifier_authority[i] = (byte)src.dec_ndr_small();
}
_size_is = src.deferred.dec_ndr_long();
NdrBuffer deferred = src.getDeferred(_size_is * 4);
if (sub_authority == null) {
sub_authority = new int[_size_is];
}
for (int i = 0; i < _size_is; i++) {
sub_authority[i] = (int)deferred.dec_ndr_long();
}
}
}
public static class sid2_t extends NdrObject {
public int count;
public sid_t sid;
public void encode(NetworkDataRepresentation ndr, NdrBuffer dst) throws NdrException {
dst.enc_ndr_long(count);
dst.deferred.align(4);
sid.encode(ndr, dst.getDeferred(12));
}
public void decode(NetworkDataRepresentation ndr, NdrBuffer src) throws NdrException {
count = (int)src.dec_ndr_long();
src.align(4);
sid.decode(ndr, src);
}
}
public static class CloseServiceHandle extends NdrObject {
public int getOpnum() { return 0x00; }
public int retval;
public policy_handle handle;
public CloseServiceHandle(policy_handle handle) {
this.handle = handle;
}
public void encode(NetworkDataRepresentation ndr, NdrBuffer dst) throws NdrException {
dst.deferred.align(4);
handle.encode(ndr, dst.getDeferred(20));
}
public void decode(NetworkDataRepresentation ndr, NdrBuffer src) throws NdrException {
src.align(4);
handle.decode(ndr, src);
retval = (int)src.dec_ndr_long();
}
}
public static class CreateServiceW extends NdrObject {
public int getOpnum() { return 0x0c; }
public int retval;
public policy_handle handle;
public String ServiceName;
public String DisplayName;
public int desired_access;
public int type;
public int start_type;
public int error_control;
public String binary_path;
public String LoadOrderGroupKey;
public String TagId;
public String dependencies;
public String service_start_name;
public String password;
public CreateServiceW(policy_handle handle,
String ServiceName,
String DisplayName,
int desired_access,
int type,
int start_type,
int error_control,
String binary_path,
String LoadOrderGroupKey,
String TagId,
String dependencies,
String service_start_name,
String password) {
this.handle = handle;
this.ServiceName = ServiceName;
this.DisplayName = DisplayName;
this.desired_access = desired_access;
this.type = type;
this.start_type = start_type;
this.error_control = error_control;
this.binary_path = binary_path;
this.LoadOrderGroupKey = LoadOrderGroupKey;
this.TagId = TagId;
this.dependencies = dependencies;
this.service_start_name = service_start_name;
this.password = password;
}
public void encode(NetworkDataRepresentation ndr, NdrBuffer dst) throws NdrException {
dst.deferred.align(4);
//handle.encode(ndr, dst.getDeferred(20));
handle.encode(ndr, dst.getDeferred(4));
if (ServiceName == null) {
dst.enc_ndr_long(0);
} else {
//dst.enc_ndr_long(System.identityHashCode(ServiceName));
dst.deferred.enc_ndr_string(ServiceName);
}
if (DisplayName == null) {
dst.enc_ndr_long(0);
} else {
dst.enc_ndr_long(System.identityHashCode(DisplayName));
dst.deferred.enc_ndr_string(DisplayName);
}
dst.enc_ndr_long(desired_access);
dst.enc_ndr_long(type);
dst.enc_ndr_long(start_type);
dst.enc_ndr_long(error_control);
if (binary_path == null) {
dst.enc_ndr_long(0);
} else {
//dst.enc_ndr_long(System.identityHashCode(binary_path));
dst.deferred.enc_ndr_string(binary_path);
}
if (LoadOrderGroupKey == null) {
dst.enc_ndr_long(0);
} else {
dst.enc_ndr_long(System.identityHashCode(LoadOrderGroupKey));
dst.deferred.enc_ndr_string(LoadOrderGroupKey);
}
if (dependencies == null) {
dst.enc_ndr_long(0);
} else {
dst.enc_ndr_long(System.identityHashCode(dependencies));
dst.deferred.enc_ndr_string(dependencies);
}
if (service_start_name == null) {
dst.enc_ndr_long(0);
} else {
dst.enc_ndr_long(System.identityHashCode(service_start_name));
dst.deferred.enc_ndr_string(service_start_name);
}
if (password == null) {
dst.enc_ndr_long(0);
} else {
dst.enc_ndr_long(System.identityHashCode(password));
dst.deferred.enc_ndr_string(password);
}
dst.enc_ndr_long(0);
dst.enc_ndr_long(0);
dst.enc_ndr_long(0);
}
public void decode(NetworkDataRepresentation ndr, NdrBuffer src) throws NdrException {
//TagId = (int)src.dec_ndr_long(0);
retval = (int)src.dec_ndr_long();
}
}
public static class OpenSCManagerW extends NdrObject {
public int getOpnum() { return 0x0f; }
public int retval;
public String MachineName;
public String DatabaseName;
public int access_mask;
public policy_handle handle;
public OpenSCManagerW(String MachineName,
String DatabaseName,
int access_mask,
policy_handle handle) {
this.MachineName = MachineName;
this.DatabaseName = DatabaseName;
this.access_mask = access_mask;
this.handle = handle;
}
public void encode(NetworkDataRepresentation ndr, NdrBuffer dst) throws NdrException {
if (MachineName == null) {
dst.enc_ndr_long(0);
} else {
dst.enc_ndr_long(System.identityHashCode(MachineName));
dst.deferred.enc_ndr_string(MachineName);
}
if (DatabaseName == null) {
dst.enc_ndr_long(0);
} else {
dst.enc_ndr_long(System.identityHashCode(DatabaseName));
dst.deferred.enc_ndr_string(DatabaseName);
}
dst.enc_ndr_long(access_mask);
}
public void decode(NetworkDataRepresentation ndr, NdrBuffer src) throws NdrException {
src.align(4);
handle.decode(ndr, src);
retval = (int)src.dec_ndr_long();
}
}
public static class OpenServiceW extends NdrObject {
public int getOpnum() { return 0x10; }
public int retval;
public policy_handle scmanager_handle;
public String ServiceName;
public int access_mask;
public policy_handle handle;
public OpenServiceW(policy_handle scmanager_handle,
String ServiceName,
int access_mask,
policy_handle handle) {
this.scmanager_handle = scmanager_handle;
this.ServiceName = ServiceName;
this.access_mask = access_mask;
this.handle = handle;
}
public void encode(NetworkDataRepresentation ndr, NdrBuffer dst) throws NdrException {
dst.deferred.align(4);
scmanager_handle.encode(ndr, dst.getDeferred(4));
dst.enc_ndr_string(ServiceName);
dst.enc_ndr_long(access_mask);
}
public void decode(NetworkDataRepresentation ndr, NdrBuffer src) throws NdrException {
src.align(4);
handle.decode(ndr, src);
retval = (int)src.dec_ndr_long();
}
}
public static class StartServiceW extends NdrObject {
public int getOpnum() { return 19; }
public int retval;
public policy_handle handle;
public int NumArgs;
public String[] Arguments;
public StartServiceW(policy_handle handle, int NumArgs, String [] Arguments) {
this.handle = handle;
this.NumArgs = NumArgs;
this.Arguments = Arguments;
}
public void encode(NetworkDataRepresentation ndr, NdrBuffer dst) throws NdrException {
int _size_is;
int _length_is;
dst.deferred.align(4);
handle.encode(ndr, dst.getDeferred(4));
dst.enc_ndr_long(NumArgs);
if (Arguments == null) {
dst.enc_ndr_long(0);
} else {
dst.enc_ndr_long(System.identityHashCode(Arguments));
dst.enc_ndr_long(Arguments.length);
for (int i = 0; i < Arguments.length; i++) {
dst.enc_ndr_long(System.identityHashCode(Arguments[i]));
}
for (int i = 0; i < Arguments.length; i++) {
dst.deferred.enc_ndr_string(Arguments[i]);
}
}
}
public void decode(NetworkDataRepresentation ndr, NdrBuffer src) throws NdrException {
retval = (int)src.dec_ndr_long();
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: svcctl.java
Type: text/x-java
Size: 12695 bytes
Desc: not available
Url : http://lists.samba.org/archive/jcifs/attachments/20040921/4c01196a/svcctl-0002.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: svcctl.idl
Type: text/x-idl
Size: 2437 bytes
Desc: not available
Url : http://lists.samba.org/archive/jcifs/attachments/20040921/4c01196a/svcctl-0003.bin
More information about the jcifs
mailing list