Sign in to follow this  
Followers 0
moridin

dll help. converting a vb6 dll function to autoit....

5 posts in this topic

Hi, I am fairly new to autoit, and I want to use a dll function in one of my scripts. I am an experienced vb6 (Visual Basic) user, and i am trying to find out how to translate a vb6 function to autoit.

This is the vb6 function declaration;

Private Declare Function Desktop_Show_Hide Lib "dllname.dll" (ByVal bShowHide As Boolean) As Integer

And it is called by;

Desktop_Show_Hide (boolean value)

I cannot seem to make this work using the autoit dllcall function. I was wondering if someone could give me an exact code example?

This is the sort of thing I have tried so far;

$dll = DllOpen("dllname.dll")
$result = DllCall($dll,"none","Desktop_Show_Hide","BOOL","FALSE")
DllClose($dll)

The dll is written in c++, here is the code for this particular function;

int DLL_EXP_IMP WINAPI Desktop_Show_Hide(BOOL bShowHide)
{
    OSVERSIONINFO   osvi;
    BOOL            bIsWindowsNT4SP3orLater;
    int             iServicePack;
    char           *p;

    // Determine the current windows version
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    GetVersionEx(&osvi);
    for (p = osvi.szCSDVersion; *p  && !isdigit(*p); *p++);
    iServicePack = atoi(p); 
    bIsWindowsNT4SP3orLater = (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) && 
                              (((osvi.dwMajorVersion == 4) && (iServicePack >= 3)) || 
                              (osvi.dwMajorVersion > 4));

    if (!bShowHide)
    {
        if (!hHook)
        {
            hHook  = SetWindowsHookEx(bIsWindowsNT4SP3orLater ? WH_MOUSE_LL : WH_MOUSE, 
                                      bIsWindowsNT4SP3orLater ? (HOOKPROC)LowLevelMouseHookProc : (HOOKPROC)MouseHookProc, 
                                      hInst, 
                                      0);
            if (!hHook)
                return 0;
        }
    }
    else
    {
        UnhookWindowsHookEx(hHook);
        hHook = NULL;
    }

    return SetWindowPos(FindWindow(NULL, PROGRAM_MANAGER),
                        NULL,
                        0, 0, 0, 0,
                        bShowHide ? SWP_SHOWWINDOW : SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
}

Note: I know that this may seem to be malicious code to some, as it will hide the desktop, but I am making a "kiosk" style app designed to restrict users from running programs they are not authorized to, while allowing the to do what the need in a very restricted environment without me having to mess about with group policy.

I also have within this dll functions to disable ctrl+alt+del (yes, it can be done!) and task manager etc. If anybody would like to know how to do this I can link you to the site where I found it. But please do not be discouraged from answering me because this may seem like malicious coding.

Help would be much appreciated.

-Moridin

Share this post


Link to post
Share on other sites



Share this post


Link to post
Share on other sites

Thank you. I have only had one post, but I've been trying to ask this question for quite a while. The forum just does not seem to like me. :">

Would you like to know all the functions in the dll?

Share this post


Link to post
Share on other sites

$dll = DllOpen("dllname.dll")
$result = DllCall($dll,"none","Desktop_Show_Hide","BOOL","FALSE")
DllClose($dll)
Hello,

the code should be:

$dll = DllOpen( "dllname.dll" )
$result = DllCall( $dll, "int", "Desktop_Show_Hide", "int", 0 )
DllClose( $dll )

$result[ 0 ] then holds the return value. You want to check whether @error is set to something but zero too...

Share this post


Link to post
Share on other sites

Thank you so much, that works perfectly!!! I have been trying to figure this out for ages. And I wasn't too far off....

Anyway, for those of you (i.e. Bert) who would like to know how to implement these features into your autoit scripts, here is a list of the functions in the DLL, and how to use them with autoit;

Use 0 as the last parameter to hide/disable, 1 to unhide/re-enable.

WARNING, if you are stupid, you could screw up your computer. Well at least to the point of a reboot, so be CAREFUL! I take no responsibilty for anything.

Hide Desktop

DllCall("WinLockDLL.dll", "int", "Desktop_Show_Hide", "int", 0)oÝ÷ Øxy+Z®Ðn¶Ú'jëh×6DllCall("WinLockDLL.dll", "int", "StartButton_Show_Hide", "int", 0)oÝ÷ Øxy6¬¶«jëh×6DllCall("WinLockDLL.dll", "int", "Taskbar_Show_Hide", "int", 0)oÝ÷ Øxy,¬µé$jëh×6DllCall("WinLockDLL.dll", "int", "Clock_Show_Hide", "int", 0)oÝ÷ Ø8¬i¹^jYl¥ç"jYÊÊ',(®K"h§÷­)äjëh×6DllCall("WinLockDLL.dll", "int", "Keys_Enable_Disable", "int", 0)oÝ÷ Ø8¬i¹^[~M¦ç¢×¢z-r§ëayø«²Ý"    mM¦övàⱦå{}÷Ý«­¢+Ù±±
±° ÅÕ½Ðí]¥¹1½­10¹±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½Ðí±ÑQÅ}¹±}¥Í±ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°À¤)±±
±° ÅÕ½Ðí]¥¹1½­10¹±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½Ðí±ÑQÉ}¹±}¥Í±ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°À°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀoÝ÷ Ø8¬i¹^$K­r§§²±h§ì¾
§-¹©eÉ©òÂ)ä{/¬írëb¶§«­¢+Ù±±
±° ÅÕ½Ðí]¥¹1½­10¹±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíQÍ­Mݥѡ¥¹}¹±}¥Í±ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀoÝ÷ Ø8¬i¹^
Úåø  mø7¥
Úåù(b~߱Ʈ¶­sdFÆÄ6ÆÂgV÷CµväÆö6´DÄÂæFÆÂgV÷C²ÂgV÷C¶çBgV÷C²ÂgV÷C´7G&ÄÇDFVÅôVæ&ÆUôF6&ÆRgV÷C²ÂgV÷C¶çBgV÷C²Â

Here is the link to the VB6 and C++ Source code, exes and the DLL.

WinLock by A. Miguel Feijao

Sorry if this is inappropriate because of its possible maliciousness.

-Moridin

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