Jump to content

Using DLLCALL function


Recommended Posts

I am trying to get the dll function to convert SID's, I did try all kinds ways for the DLL function to give me a converted SID back it doesn't seem to work. I have looked at similar dll calls but it didn't help much. Below the call I am trying to get done:

> > ConvertStringSidToSid function.

> >

> > BOOL ConvertSidToStringSid(

> > PSID Sid, // SID

> > LPTSTR *StringSid // SID string

> > );

> > Parameters

> > Sid

> > [in] Pointer to the SID to convert.

> > StringSid

> > [out] Pointer to a variable that receives a pointer to a null-terminated

> SID

> > string. To free the returned buffer, call the LocalFree function.

> > Return Values

> > If the function succeeds, the return value is nonzero.

> >

> > If the function fails, the return value is zero. To get extended error

> > information, call GetLastError. GetLastError may return one of the

> following

> > error codes.

> >

> > Error Code Meaning

> > ERROR_NOT_ENOUGH_MEMORY Insufficient memory.

> > ERROR_NONE_MAPPED The SID could not be found in an account lookup

> operation.

> >

Than there is also a reference to a localfree function, how do I use this?

The VB sample I found looks like this:

;~ 'VB Sample

;~ Public Shared Function ByteArrayToStringSid(ByRef bArray As Byte()) As String

;~ Dim ptrSID As IntPtr = Nothing

;~ Try

;~ Dim sSID As String = String.Empty

;~ If ConvertSidToStringSid(bArray, ptrSID) = True Then

;~ 'The PtrToStringXXX call here needs to match the CharSet used on your

;~ 'ConvertSidToStringSid DllImport. The default is CharSet.Ansi.

;~ sSID = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(ptrSID)

;~ End If

;~ Return sSID

;~ Finally

;~ LocalFree(ptrSID)

;~ End Try

;~ End Function

It doesn't make it any more clear how to get this done in AutoIt.

Is there any one around who can help me out here?

Link to comment
Share on other sites

ConvertStringSidToSid() returns a pointer to a SID struct.

[out] Pointer to a variable that receives a pointer to the converted SID.

typedef struct _SID {
   BYTE  Revision;
   BYTE  SubAuthorityCount;
   SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
   DWORD SubAuthority[ANYSIZE_ARRAY];
} SID, *PISID;

So, how could this pointer to the struct be used within AutoIT? Unfortunately I don't know a way. However, please tell me if you find one.

I think it would be best to write a DLL that handles all the "magic" for you and returns the binary SID somehow hex-coded. It all depends on what you want to do with the binary SID.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

I am trying to get the dll function to convert SID's, I did try all kinds ways for the DLL function to give me a converted SID back it doesn't seem to work. I have looked at similar dll calls but it didn't help much. Below the call I am trying to get done:

> > ConvertStringSidToSid function.

> >

> > BOOL ConvertSidToStringSid(

> >  PSID Sid,          // SID

> >  LPTSTR *StringSid  // SID string

> > );

> > Parameters

> > Sid

> > [in] Pointer to the SID to convert.

> > StringSid

> > [out] Pointer to a variable that receives a pointer to a null-terminated

> SID

> > string. To free the returned buffer, call the LocalFree function.

> > Return Values

> > If the function succeeds, the return value is nonzero.

> >

> > If the function fails, the return value is zero. To get extended error

> > information, call GetLastError. GetLastError may return one of the

> following

> > error codes.

> >

> > Error Code Meaning

> > ERROR_NOT_ENOUGH_MEMORY Insufficient memory.

> > ERROR_NONE_MAPPED The SID could not be found in an account lookup

> operation.

> >

Than there is also a reference to a localfree function, how do I use this?

The VB sample I found looks like this:

;~ 'VB Sample

;~ Public Shared Function ByteArrayToStringSid(ByRef bArray As Byte()) As String

;~    Dim ptrSID As IntPtr = Nothing

;~    Try

;~      Dim sSID As String = String.Empty

;~      If ConvertSidToStringSid(bArray, ptrSID) = True Then

;~        'The PtrToStringXXX call here needs to match the CharSet used on your

;~        'ConvertSidToStringSid DllImport.  The default is CharSet.Ansi.

;~        sSID = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(ptrSID)

;~      End If

;~      Return sSID

;~    Finally

;~      LocalFree(ptrSID)

;~    End Try

;~ End Function

It doesn't make it any more clear how to get this done in AutoIt.

Is there any one around who can  help me out here?

<{POST_SNAPBACK}>

have you tried implementing a dllstruct ? that worked for me when i had to work with dll's... check out the helpfile for better detail and explanation, or there was atleast one thread on here where it was shown to me for modifying the system time. it may only be in the beta...
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...