Jump to content

Advanced API DllCall Errors


Recommended Posts

Using all those constants from Winnt.h (included with my Dev-C++ install), they all produced the same errors as before: 87 when passing in $DACL_SECURITY_INFORMATION, 1314 when passing in a pointer to a dword (which is wrong, but actually produces "more correct" results). Very confusing...

Link to comment
Share on other sites

Has it occurred to you that the INVALID_PARAMETER error is the right error and that it's your SECURITY_DESCRIPTOR structure that's invalid? It makes sense to me that when you set the flag telling it to set DACL_SECURITY_INFORMATION it tries to but the structure is wrong or being passed wrong or something. But when you pass in a memory address, other bit flags are set and so the function does unknown actions (dangerous!) and produces a different error?

Given that you had mistakes in the DllCall()'s you're asking for help with, what makes you think the other DllCall()'s are any more correct?

Link to comment
Share on other sites

Very true, so I went back over all my other code, and so far, nothing with anything above where I set the path is wrong. However, I did find that my trickery with $apath was producing blank results *WHACKSELF*. Fixed that, made sure with debug consolewrites, and now, no matter what I pass in to RegSetKeySecurity, I get error 87.

As far as my SECURITY_DESCRIPTOR structure being valid, I'm having to hope on that one. According to MSDN, it can be different, so they say to initialize it using the function to do it. I couldn't figure out how to do that in AutoIt (doesn't AutoIt require knowing the structure's format ahead of time?), so I just copied the structure from the header files in my include folder from gcc. I also added the call to IsValidSecurityDescriptor to double check and see, and it doesn't return 0, which according to MSDN means error, so I can only assume it might be correct.

If anyone has a clue on how to create/initialize a security descriptor without knowing the structure before hand in AutoIt, I would gladly change to using that.

Link to comment
Share on other sites

According to the example, you allocate a buffer of size SECURITY_DESCRIPTOR_MIN_LENGTH. You then initialize that buffer using InitializeSecurityDescriptor(). After that, you use the Getters/Setters on the buffer which take care of setting the fields.

Link to comment
Share on other sites

Tried using Larry's method (both from his old post modified to newer code, and just by trying to emulate everything his code was doing using code from the newly imported Au3Lib stuff), nothing seemed to work. I'm at least consistent now, the only error I get now no matter what I pass into RegSetKeySecurity is 87. Gonna look into redoing my Security Descriptor init code at the top, and see if that does anything.

Link to comment
Share on other sites

  • 2 weeks later...

I have gotten it working, using the method that Valik pointed out to me. I'm still testing it in VMWare to make sure it's ok, and when I'm happy with it, and can clean it up a bit, I'll see if I can roll some kind of UDF for, if nothing else, adding rights to users/groups available.

Thanks for taking the time to help me, all of you.

Link to comment
Share on other sites

  • 1 year later...

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...