Jump to content

Protecting the code with a DLL any idea how ?


Recommended Posts

Hey , I spoke with a programmer that protected part of his code with a .DLL file

the main Idea is to keep some of the core functions inside a .DLL file , then this .DLL also checks the autoit .EXE size and compare it to the known Size and shut down the program if its not the right size.

can it be done ?

how do i create a .DLL file that contain DATA needed for the code, and how can i load it when my main code starts??

Link to comment
Share on other sites

Hey , I spoke with a programmer that protected part of his code with a .DLL file

the main Idea is to keep some of the core functions inside a .DLL file , then this .DLL also checks the autoit .EXE size and compare it to the known Size and shut down the program if its not the right size.

can it be done ?

how do i create a .DLL file that contain DATA needed for the code, and how can i load it when my main code starts??

I'd make a script of the same size. he he he

Link to comment
Share on other sites

Better build functions for the test and inside create the array and return the array.

I am not skilled in creating dlls that can be used in autoit as there was some tricky moments.

Search the forum for more information.

Link to comment
Share on other sites

If you want to do something like that then just have your code, check its own hash, and exit if its incorrect.

A dll file can be examined just as any other executable.

If your code is important enough for someone to want to steal it, you are buggered, you cannot stop them.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

AUTOIT_MFC_DLL.dll

#include "stdafx.h"
#include <afxdllx.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


#ifdef  AUTOIT_MFC_DLL_EXPORTS
#define  AUTOIT_MFC_DLL_API __declspec(dllexport)
#else
#define  AUTOIT_MFC_DLL_API __declspec(dllimport)
#endif


extern "C"
{
AUTOIT_MFC_DLL_API int AfxMsBox(LPCTSTR);
AUTOIT_MFC_DLL_API int CString_Find(int,LPSTR ,LPSTR);
AUTOIT_MFC_DLL_API LPSTR CString_Insert(int,LPSTR,LPSTR);
AUTOIT_MFC_DLL_API int CString_Get_Length(LPSTR);
AUTOIT_MFC_DLL_API LPSTR CString_Replace(LPSTR,LPCTSTR,LPCTSTR);
};



static AFX_EXTENSION_MODULE AUTOIT_MFC_DLLDLL = { NULL, NULL };

extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
    // Remove this if you use lpReserved
    UNREFERENCED_PARAMETER(lpReserved);

    if (dwReason == DLL_PROCESS_ATTACH)
    {
        TRACE0("AUTOIT_MFC_DLL.DLL Initializing!\n");

        // Extension DLL one-time initialization
        if (!AfxInitExtensionModule(AUTOIT_MFC_DLLDLL, hInstance))
            return 0;

        // Insert this DLL into the resource chain
        // NOTE: If this Extension DLL is being implicitly linked to by
        //  an MFC Regular DLL (such as an ActiveX Control)
        //  instead of an MFC application, then you will want to
        //  remove this line from DllMain and put it in a separate
        //  function exported from this Extension DLL.  The Regular DLL
        //  that uses this Extension DLL should then explicitly call that
        //  function to initialize this Extension DLL.  Otherwise,
        //  the CDynLinkLibrary object will not be attached to the
        //  Regular DLL's resource chain, and serious problems will
        //  result.

        new CDynLinkLibrary(AUTOIT_MFC_DLLDLL);
    }
    else if (dwReason == DLL_PROCESS_DETACH)
    {
        TRACE0("AUTOIT_MFC_DLL.DLL Terminating!\n");
        // Terminate the library before destructors are called
        AfxTermExtensionModule(AUTOIT_MFC_DLLDLL);
    }
    return 1;   // ok


}

int AfxMsBox(LPCTSTR TXT1)
{
if (AfxMessageBox(TXT1)) {return 1;}
return 0;
}

int CString_Find(int nStart ,LPSTR FSTR ,LPSTR FSUBSTR)
{
return CString(FSTR).Find(FSUBSTR,nStart);
}

LPSTR CString_Insert(int nIndex ,LPSTR ISTR ,LPSTR ISUBSTR)
{
CString ISTR2 = ISTR;
ISTR2.Insert(nIndex,ISUBSTR);
return (LPSTR) ISTR2.GetBuffer(ISTR2.GetLength());
}

int CString_Get_Length(LPSTR GLSTR)
{
return CString(GLSTR).GetLength();
}

LPSTR CString_Replace(LPSTR RSTR, LPCTSTR ipszOld , LPCTSTR ipszNew)
{
CString RSTR2 = RSTR;
RSTR2.Replace(ipszOld,ipszNew);
return (LPSTR) RSTR2.GetBuffer(RSTR2.GetLength());
}

Call AUTOIT_MFC_DLL.dll (Autoit Code)

$DllOpen = DllOpen(@ScriptDir & "\AUTOIT_MFC_DLL.dll")

AfxMsBox("Hello World")

MsgBox(0,"CString_Insert",CString_Insert(6 ,"AUTOIT" , "_MFC_DLL"))
MsgBox(0,"CString_Find",CString_Find(0 ,"Hello World" ,"World"))
MsgBox(0,"CString_Get_Length",CString_Get_Length("Hello World"))
MsgBox(0,"CString_Replace",CString_Replace("Hello World", "World" , "Test"))


Func AfxMsBox($TXT = "")
$DllCall = DllCall($DllOpen,"int:cdecl","AfxMsBox","str",$TXT)
Return $DllCall[0]
EndFunc


Func CString_Find($nStart = 0 ,$FSTR = "" ,$FSUBSTR = "")
$DllCall = DllCall($DllOpen,"int:cdecl","CString_Find","int",$nStart,"str",$FSTR,"str",$FSUBSTR)
Return $DllCall[0]
EndFunc

Func CString_Insert($nIndex = 0 ,$STR = "" ,$SUBSTR = "")
$DllCall = DllCall($DllOpen,"str:cdecl","CString_Insert","int",$nIndex ,"str",$STR ,"str",$SUBSTR)
Return $DllCall[0]
EndFunc

Func CString_Get_Length($GLSTR = "")
$DllCall = DllCall($DllOpen,"int:cdecl","CString_Get_Length","str",$GLSTR)
Return $DllCall[0]
EndFunc

Func CString_Replace($RSTR = "" , $ipszOld = "" , $ipszNew = "" )
$DllCall = DllCall($DllOpen,"str:cdecl","CString_Replace","str",$RSTR,"str",$ipszOld ,"str", $ipszNew)
Return $DllCall[0]
EndFunc

DllClose($DllOpen)

صرح السماء كان هنا

 

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