Sign in to follow this  
Followers 0
Shyke

DLLCall

13 posts in this topic

Alright, welcome to another one of my ignorance related problems!!

We start with needed to call the windows "crypt32.dll" function "CryptProtectData". I start with:

DllCall("crypt32.dll", "int", "CryptProtectData")

Knowing that the shown code isn't gonna do crap all but unsure how to progress on it. I do a little bit of searching into this function and find this site with data on it although in Perl. I'm unsure of how to use this in AutoIt and come to you guys for help.

Share this post


Link to post
Share on other sites



The first step is knowing the parameters and what to substitute the MSDN params with:

http://msdn.microsoft.com/library/default....protectdata.asp

http://www.autoitscript.com/forum/index.php?showtopic=7072


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

My problem is that I don't know how to use those parameters with DLLCall.

Share this post


Link to post
Share on other sites

have you viewed the DllCall entry in the helpfile? It provides some excellent examples.

DllCall ( "dll", "return type", "function" [, "type1", param1 [, "type n", param n]] )

Type1 = type of parameter

param1 = first parameter

Share this post


Link to post
Share on other sites

Dim $data = "data", $desc = "description of data", $pass = "pass", $out = ""
$return = DllCall("crypt32.dll", "int", "CryptProtectData", "ptr", $data, "str", $desc, "ptr", $pass, "none", "", "none", "", "dword", "CRYPTPROTECT_LOCAL_MACHINE", "ptr", $out)

Alright, between AutoItSmith and I.. we got that. Of course it doesn't work how I want it to. It returns a 0... which was pretty much expected knowing my luck. Would anyone have any idea why?

Share this post


Link to post
Share on other sites

Sometimes DLLs return arrays. Check it with IsArray()

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

It's not an array.

EDIT: That DLL is supposed to return a one or a zero (success or failure) and set the protected data inside of $out.

Edited by Shyke

Share this post


Link to post
Share on other sites

can you post your sample code incl. the DATA_BLOB and CRYPTPROTECT_PROMPTSTRUCT structure?

paul

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I'm only currently working with:

Dim $data = "data", $desc = "description of data", $pass = "pass", $out = ""
$return = DllCall("crypt32.dll", "int", "CryptProtectData", "str", $data, "str", $desc, "ptr", $pass, "none", "", "none", "", "dword", "CRYPTPROTECT_LOCAL_MACHINE", "ptr", $out)

The MSDN thingy and the AutoIt DLLCall topic...

Edited by Shyke

Share this post


Link to post
Share on other sites

I'm only currently working with:

Dim $data = "data", $desc = "description of data", $pass = "pass", $out = ""
$return = DllCall("crypt32.dll", "int", "CryptProtectData", "str", $data, "str", $desc, "ptr", $pass, "none", "", "none", "", "dword", "CRYPTPROTECT_LOCAL_MACHINE", "ptr", $out)oÝ÷ Ù8^º¹

Dunno why I chose 1 and 0 but that link says they are ints.

Dunno how it wants you to get the size for the BLOB_DATA's, but in the example in that first link it calls the DLL with pointers set to 0 in order to get $prompt size, then it calls the DLL again with the correct structs. Not sure if you just set that one pointer to 0, or all of them.

Sorry if this doesn't help! :P

Share this post


Link to post
Share on other sites

What are the use of the "DllStructCreate()" calls in this???

Share this post


Link to post
Share on other sites

What are the use of the "DllStructCreate()" calls in this???

3 parameters require a struct. So you use that to create a struct, give it the data it needs, then get the pointer of that struct for the parameter. Look at the links.

Share this post


Link to post
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
Sign in to follow this  
Followers 0