Sign in to follow this  
Followers 0

Snipster - Updated 9/13/11

46 posts in this topic

#1 ·  Posted (edited)

Current Version - 1.6

Snipster is a place holder for all your common or uncommon autoit code that you want to be quickly accessible when your writing scripts. It is built to work along side SciTE, but can be used on its own also. Forever I used Gary Frosts cSnippet and was very happy with it, but for a while now the version that comes with autoit doesnt really work (one of my reasons for writing this). Snipster does a lot of the original features cSnippet did and many more.

Some of these features include:

  • Create new snippet from code selected in SciTE
  • Create new snippet from code on Clipboard
  • Send Snippet to Clipboard
  • Send Snippet to SciTE
  • Edit, Delete, Create New Snippets
  • Open Snippet in SciTE
Some new features include:
  • Syntax Highlighting
  • Customizable Hotkeys for the features given above
  • Launch Snippet (x86 or x64 preference)
  • Extra docking methods
  • Resizeable windows that automatically snap to each other and desktop edges
  • Import all snippets from cSnippet

Posted Image

More Snapshots:

Posted Image Posted Image

A little bit about how the program functions.. The syntax highlighting works by generating a RTF (Rich Text File) from the .au3 (snippet file). All of the syntax highlighting is done in a separate process so that it doesn't slow down the main program. Any time you select a different snippet, the program checks its RTF folder (hidden folder located @scripdir) to see if a RTF file exists for the selected snippet. If it does the RTF file is loaded. If not the .au3 file will be loaded and a message is sent to the syntax converter process to generate the RTF file. If the generator is busy it will be added to a queue. When the RTF file is complete a message will be sent back to the main program telling it that the RTF file is ready. If you are still viewing that same snippet the program will automatically switch to the newly generated RTF. This automatic switching Im talking about really worked out well I think. Even when your scrolling, the switch happens pretty seamlessly. Any kind of feedback will be most appreciated. I want to know about bugs, things you like, things you didn't like, things you would like. Seriously dont hold back and thanks for looking. :huh2:

Binary

Snipster_binary.html

Source Code

Snipster_source.html

Note: The .html links are just to help me keep track of downloads. Open the .html file and a download dialog will display.

Special Thanks go to:

Yashied - All hiswonderul UDF's (TVExplorer, Restart, HotKeyInput used here)

Ward - his MemoryDll and Hash Functions

trancexx - her MailSlot UDF

MrCreatoR - his original HTML Syntax Highlighter code that inspired my RTF Highlighter

Gary Frost - cSnippet

Updates

6/13/11 - Updated Wards MemoryDLL

6/13/11 - Added Drag and Drop for treeview. Any .au3 file you want to add just drop it on the treeview.

- Changed to different version of Wards MD5. MemoryDll no longer needed.

6/14/11 - Fixed bug in syntax highlighter that was copying and adding first line of file to end of script

6/21/11 - Rewrote syntax converter. This greatly increased speed and color syntax "consistancy."

- Fixed bug that was not coloring Function Keyword if it was the very first word of a script.

6/23/11 - Still had bug with function keyword being first. Think I got it this time..

9/10/11 - Made changes to the way edit and treeview windows hide themselves.

- Added window position checks at startup and settings gui.

- Fixed toolbar icons index numbers for win xp. (Thanks Tlem)

9/13/11 - Added cSnippet import function

- Added About Box

- Changed "Delete Snippet warning" default value to true

Edited by Beege
2 people like this

Share this post


Link to post
Share on other sites



#3 ·  Posted

When I load my snippets folder and click a snippet just once to try to load it then I receive a "this program has stopped working" message.

Windows 7 X64 Professional

Are you running the binary or the source? And did it give a line number of the error? Normally Autoit will if it crashes.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

The last function that it is in when it crashes is _CheckMD5().

Are you running the binary or the source?

I ran both now and the problem is the same on both.

And did it give a line number of the error?

Windows throws the error.

Edited by LaCastiglione

Share this post


Link to post
Share on other sites

#5 ·  Posted

The last function that it is in when it crashes is _CheckMD5().

I ran both now and the problem is the same on both.

Windows throws the error.

Ok this is puzzling... Does it do it when you load the example snippet folder?

Share this post


Link to post
Share on other sites

#6 ·  Posted

So far I haven't found a problem. Using Windows 7 x64 and the latest Beta.


UDF List:

 

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

 

 

Updated: 02/04/2015

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Actually I think narrowed it down to this line in MemoryDllOpen():

Local $Module = DllCall($_MDKernel32Dll, "uint", $_MFHookApi, "uint", $LoadLibraryA[0], "uint", $GetProcAddress[0], "ptr", DllStructGetPtr($DllBuffer))

[Does it do it when you load the example snippet folder?

Yes

So far I haven't found a problem. Using Windows 7 x64 and the latest Beta.

I must be using Dr. Who's machine. Edited by LaCastiglione

Share this post


Link to post
Share on other sites

#8 ·  Posted

So far I haven't found a problem. Using Windows 7 x64 and the latest Beta.

Thankyou guinness. I feel a little better now :huh2:

Actually I think narrowed it down to this line in MemoryDllOpen():

Local $Module = DllCall($_MDKernel32Dll, "uint", $_MFHookApi, "uint", $LoadLibraryA[0], "uint", $GetProcAddress[0], "ptr", DllStructGetPtr($DllBuffer))

Yes

I must be using Dr. Who's machine.

If its in wards memory dll then this is going to be harder... you are running v3.3.6.1 yes?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Something you could test is if you can run the original example code from The udf was untouched by me so in theory his Hash39 example should fail the same way...Posted Image

Edited by Beege

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Indeed, it fails the exact same way. My apologies.

It occurs on 3.3.6.1 and beta

No problem at all...lol I feel loads better. Its so weird how things work out sometimes. Last night I found a intermittent bug in that function _checkMD5() and spent a good hour working it out. the bug had nothing to do with your problem but with the dictionary objects attempting to remove items that didnt exist.. anyway naturally im thinking it is the same problem and I didnt fix it. Out of the loads of functions in this program you happen to have a problem in the very last function I was working on only completely unrealted to what I was doing .Posted Image But am still puzzled that a compiled version isnt working...I can understand any source not working but if it was compiled on a working system...I dont know.

Edited by Beege

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Works just fine compiled in WindowsXP Professional x32.

Also works fine when ran from the source under 3.3.6.1 and 3.3.7.9.

Excellent thats good to here! :huh2: Your right about that function being obsolete.. I can't understand how there are so many undocumented functions...who are they written for if not documented? Google comes up with nothing on what that function even does..

Edited by Beege

Share this post


Link to post
Share on other sites

#16 ·  Posted

I found this in a PDF: (Ecma-234-v2-1.pdf)

324 GlobalCompact, LocalCompact
324.1 Synopsis
DWORD GlobalCompact(DWORD MinFree);
DWORD LocalCompact(DWORD MinFree);
324.2 Description
The GlobalCompact() function rearranges the memory content until MinFree bytes of memory can no longer be
rearranged.
LocalCompact() calls GlobalCompact().
324.3 Returns
GlobalCompact() and  LocalCompact() return the number of bytes available in the largest contiguous memory
segment. If MinFree is zero,  GlobalCompact() returns the number of bytes available in the largest contiguous
memory segment if all discardable memory segments are removed.
GlobalCompact() and LocalCompact() currently do nothing and return 4194304 bytes.
324.4 Errors
None.
324.5 Cross-References
None.

Share this post


Link to post
Share on other sites

#17 ·  Posted

I found this in a PDF: (Ecma-234-v2-1.pdf)

324 GlobalCompact, LocalCompact
324.1 Synopsis
DWORD GlobalCompact(DWORD MinFree);
DWORD LocalCompact(DWORD MinFree);
324.2 Description
The GlobalCompact() function rearranges the memory content until MinFree bytes of memory can no longer be
rearranged.
LocalCompact() calls GlobalCompact().
324.3 Returns
GlobalCompact() and  LocalCompact() return the number of bytes available in the largest contiguous memory
segment. If MinFree is zero,  GlobalCompact() returns the number of bytes available in the largest contiguous
memory segment if all discardable memory segments are removed.
GlobalCompact() and LocalCompact() currently do nothing and return 4194304 bytes.
324.4 Errors
None.
324.5 Cross-References
None.

Ya thats over my head... I thought he was using it to return the address of the function loaded in memory...but that says it returns number of bytes available...

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

I'm cheating a little and having the function return 419430. =]

Ok, I replaced every instance of that DllCall in the memory udf and it works now!

Want the source?

Edited by LaCastiglione

Share this post


Link to post
Share on other sites

#19 ·  Posted

Sure thanks

Share this post


Link to post
Share on other sites

#20 ·  Posted

Here it is in case anyone else has the same problems.

#include-once

#AutoIt3Wrapper_AU3Check_Parameters=-w 4

Global $_MDCodeBuffer, $_MDLoadOffset, $_MDGetOffset
Global $_MDFreeOffset, $_MFHookPtr, $_MFHookBak
Global Const $_MFHookApi = "LocalCompact"
Global Const $_MDKernel32Dll = DllOpen("kernel32.dll")

Func MemoryFuncInit()
    Local $KernelHandle = DllCall($_MDKernel32Dll, "ptr", "LoadLibrary", "str", "kernel32.dll")
    Local $HookPtr = DllCall($_MDKernel32Dll, "ptr", "GetProcAddress", "ptr", $KernelHandle[0], "str", $_MFHookApi)
    $_MFHookPtr = $HookPtr[0]

    $_MFHookBak = DllStructCreate("ubyte[7]")
    DllCall($_MDKernel32Dll, "int", "WriteProcessMemory", "ptr", -1, "ptr", DllStructGetPtr($_MFHookBak), "ptr", $_MFHookPtr, "uint", 7, "uint*", 0)

    DllCall($_MDKernel32Dll, "int", "WriteProcessMemory", "ptr", -1, "ptr", $_MFHookPtr, "byte*", 0xB8, "uint", 1, "uint*", 0)
    DllCall($_MDKernel32Dll, "int", "WriteProcessMemory", "ptr", -1, "ptr", $_MFHookPtr + 5, "ushort*", 0xE0FF, "uint", 2, "uint*", 0)
EndFunc

Func MemoryFuncCall($RetType, $Address, $Type1 = "", $Param1 = 0, $Type2 = "", $Param2 = 0, $Type3 = "", $Param3 = 0, $Type4 = "", $Param4 = 0, $Type5 = "", $Param5 = 0, $Type6 = "", $Param6 = 0, $Type7 = "", $Param7 = 0, $Type8 = "", $Param8 = 0, $Type9 = "", $Param9 = 0, $Type10 = "", $Param10 = 0, $Type11 = "", $Param11 = 0, $Type12 = "", $Param12 = 0, $Type13 = "", $Param13 = 0, $Type14 = "", $Param14 = 0, $Type15 = "", $Param15 = 0, $Type16 = "", $Param16 = 0, $Type17 = "", $Param17 = 0, $Type18 = "", $Param18 = 0, $Type19 = "", $Param19 = 0, $Type20 = "", $Param20 = 0)
    #forceref $RetType, $Address, $Type1, $Param1, $Type2, $Param2, $Type3, $Param3, $Type4, $Param4, $Type5, $Param5, $Type6, $Param6, $Type7, $Param7, $Type8, $Param8, $Type9, $Param9, $Type10, $Param10, $Type11, $Param11, $Type12, $Param12, $Type13, $Param13, $Type14, $Param14, $Type15, $Param15, $Type16, $Param16, $Type17, $Param17, $Type18, $Param18, $Type19, $Param19, $Type20, $Param20

    If Not IsDllStruct($_MFHookBak) Then MemoryFuncInit()

    MemoryFuncSet($Address)
    Local $Ret
    Switch @NumParams
    Case 2
        $Ret = DllCall($_MDKernel32Dll, $RetType, $_MFHookApi)
    Case 4
        $Ret = DllCall($_MDKernel32Dll, $RetType, $_MFHookApi, $Type1, $Param1)
    Case 6
        $Ret = DllCall($_MDKernel32Dll, $RetType, $_MFHookApi, $Type1, $Param1, $Type2, $Param2)
    Case 8
        $Ret = DllCall($_MDKernel32Dll, $RetType, $_MFHookApi, $Type1, $Param1, $Type2, $Param2, $Type3, $Param3)
    Case 10
        $Ret = DllCall($_MDKernel32Dll, $RetType, $_MFHookApi, $Type1, $Param1, $Type2, $Param2, $Type3, $Param3, $Type4, $Param4)
    Case 12
        $Ret = DllCall($_MDKernel32Dll, $RetType, $_MFHookApi, $Type1, $Param1, $Type2, $Param2, $Type3, $Param3, $Type4, $Param4, $Type5, $Param5)
    Case Else
        Local $DllCallStr = 'DllCall($_MDKernel32Dll, $RetType, $_MFHookApi', $n, $i
        For $i = 4 To @NumParams Step 2
            $n = ($i - 2) / 2
            $DllCallStr &= ', $Type' & $n & ', $Param' & $n
        Next
        $DllCallStr &= ')'
        $Ret = Execute($DllCallStr)
    EndSwitch
    Return $Ret
EndFunc

Func MemoryFuncSet($Address)
    DllCall($_MDKernel32Dll, "bool", "WriteProcessMemory", "handle", -1, "ptr", $_MFHookPtr + 1, "ptr", $Address, "uint", 4, "uint*", 0)
EndFunc

Func MemoryFuncExit()
    DllCall($_MDKernel32Dll, "int", "WriteProcessMemory", "ptr", -1, "ptr", $_MFHookPtr, "ptr", DllStructGetPtr($_MFHookBak), "uint", 7, "uint*", 0)
    $_MFHookBak = 0
EndFunc

Func MemoryDllInit()
    If IsDllStruct($_MDCodeBuffer) Then Return

    Local $Opcode = '0xFFFFFFFFFFFFFFFFB800000000FFE0B800000000FFE0B800000000FFE0B800000000FFE0B800000000FFE0B800000000FFE0B800000000FFE0B800000000FFE0B800000000FFE0B800000000FFE0B800000000FFE0B800000000FFE0B800000000FFE0B800000000FFE0B800000000FFE0B800000000FFE05589E55156578B7D088B750C8B4D10FCF3A45F5E595DC35589E5578B7D088A450C8B4D10F3AA5F5DC359585A5153E8000000005B81EBAB114000898300114000899304114000E8000000005981E9C3114000518B9100114000E80B0000007573657233322E646C6C005850FFD2598B9104114000E80C0000004D657373616765426F784100595150FFD2898372114000E8000000005981E90D124000518B9100114000E80D0000006B65726E656C33322E646C6C005850FFD2598B9104114000E80A0000006C737472636D70694100595150FFD2898309114000E8000000005981E957124000518B9100114000E80D0000006B65726E656C33322E646C6C005850FFD2598B9104114000E80D0000005669727475616C416C6C6F6300595150FFD2898310114000E8000000005981E9A4124000518B9100114000E80D0000006B65726E656C33322E646C6C005850FFD2598B9104114000E80C0000005669727475616C4672656500595150FFD2898317114000E8000000005981E9F0124000518B9100114000E80D0000006B65726E656C33322E646C6C005850FFD2598B9104114000E80F0000005669727475616C50726F7465637400595150FFD289831E114000E8000000005981E93F134000518B9100114000E80D0000006B65726E656C33322E646C6C005850FFD2598B9104114000E80E00000052746C5A65726F4D656D6F727900595150FFD2898325114000E8000000005981E98D134000518B9100114000E80D0000006B65726E656C33322E646C6C005850FFD2598B9104114000E80D0000004C6F61644C6962726172794100595150FFD289832C114000E8000000005981E9DA134000518B9100114000E80D0000006B65726E656C33322E646C6C005850FFD2598B9104114000E80F00000047657450726F634164647265737300595150FFD2898333114000E8000000005981E929144000518B9100114000E80D0000006B65726E656C33322E646C6C005850FFD2598B9104114000E80D00000049734261645265616450747200595150FFD289833A114000E8000000005981E976144000518B9100114000E80D0000006B65726E656C33322E646C6C005850FFD2598B9104114000E80F00000047657450726F636573734865617000595150FFD2898341114000E8000000005981E9C5144000518B9100114000E80D0000006B65726E656C33322E646C6C005850FFD2598B9104114000E80A00000048656170416C6C6F6300'
        $Opcode &= '595150FFD2898348114000E8000000005981E90F154000518B9100114000E80D0000006B65726E656C33322E646C6C005850FFD2598B9104114000E809000000486561704672656500595150FFD289834F114000E8000000005981E958154000518B9100114000E80D0000006B65726E656C33322E646C6C005850FFD2598B9104114000E80C000000476C6F62616C416C6C6F6300595150FFD2898356114000E8000000005981E9A4154000518B9100114000E80D0000006B65726E656C33322E646C6C005850FFD2598B9104114000E80E000000476C6F62616C5265416C6C6F6300595150FFD2898364114000E8000000005981E9F2154000518B9100114000E80D0000006B65726E656C33322E646C6C005850FFD2598B9104114000E80B000000476C6F62616C4672656500595150FFD289835D114000E8000000005981E93D164000518B9100114000E80D0000006B65726E656C33322E646C6C005850FFD2598B9104114000E80C000000467265654C69627261727900595150FFD289836B1140005B59585150E80E04000059C35990585A515250E8CC0500005A5AC35A585250E88E06000059C35589E557565383EC1C8B45108B40048945EC8B55108B020FB750148D740218C745F00000000066837806000F84B0000000837E1000754C8B450C8B583885DB0F8E84000000C744240C04000000C744240800100000895C24048B45EC03460C890424E8FEF9FFFF83EC10894608895C2408C744240400000000890424E864FAFFFFEB46C744240C04000000C7442408001000008B4610894424048B45EC03460C890424E8BDF9FFFF83EC1089C78B55080356148B46108944240889542404893C24E808FAFFFF897E08FF45F083C6288B55108B020FB740063B45F00F8F50FFFFFF8D65F45B5E5F5DC35589E557565383EC1C8B55088B020FB750148D5C0218BF0000000066837806000F84E80000008B432489C2C1EA1D89D683E60189C2C1EA1E83E20189C1C1E91FA9000000027422C7442408004000008B4310894424048B4308890424E822F9FFFF83EC0CE99000000085F6741E85D2740D83F90119D283E2E083C240EB2983F90119D283E29083EA80EB1C85D2740D83F90119D283E2FE83C204EB0B83F90119D283E2F983C208F6432704740681CA000200008B4B1085C97522F6432440740A8B4D088B018B4820EB0EF643248074088B4D088B018B482485C9741D8D45F08944240C89542408894C24048B4308890424E894F8FFFF83EC104783C3288B55088B020FB7400639F80F8F18FFFFFF8D65F45B5E5F5DC35589E557565383EC048B45088B50048955F08B0083B8A400000000745789D30398A0000000833B00744A8B7DF0033B8D4B08BE000000008B430483E808D1E883F80076280FB70189C2C1EA0C25FF0F000083FA037506'
        $Opcode &= '8B550C0114074683C1028B430483E808D1E839F077D8035B04833B0075B683C4045B5E5F5DC35589E557565383EC1CC745F0010000008B45088B40048945EC8B55088B0283B884000000000F84410100008B7DEC03B880000000E9120100008B45EC03470C890424E8BFF7FFFF83EC048945E883F8FF750CC745F000000000E90E0100008B4D0883790800742EC7442408400000008B410C8D048504000000894424048B4108890424E8B6F7FFFF83EC0C8B550889420885C075268B4D088B410C8D04850400000089442404C7042440000000E87EF7FFFF83EC088B55088942088B4D088B510C8B41088B4DE8890C908B4508FF400C833F0074168B5DEC031F8B75EC037710EB11C745F000000000EB578B5DEC035F1089DE833B00744A833B0079190FB703894424048B55E8891424E8FEF6FFFF83EC088906EB1C8B45EC030383C002894424048B4DE8890C24E8E0F6FFFF83EC088906833E0074AB83C30483C604833B0075B6837DF000742483C714C744240414000000893C24E8B9F6FFFF83EC0885C0750A837F0C000F85CDFEFFFF8B45F08D65F45B5E5F5DC35589E557565383EC1C8B45088945F0B8000000008B550866813A4D5A0F85A20100008B75088B45F003703CB800000000813E504500000F8588010000C744240C04000000C7442408002000008B4650894424048B4634890424E815F6FFFF83EC1089C785C07535C744240C04000000C7442408002000008B465089442404C7042400000000E8E9F5FFFF83EC1089C7B80000000085FF0F8428010000E803F6FFFFC744240814000000C744240400000000890424E8F2F5FFFF83EC0C89C3897804C7400C00000000C7400800000000C7401000000000C744240C04000000C7442408001000008B465089442404893C24E87EF5FFFF83EC10C744240C04000000C7442408001000008B465489442404893C24E85CF5FFFF83EC108945EC8B55F08B423C03465489442408895424048B45EC890424E8A3F5FFFF8B45EC8B55F003423C8903897834895C2408897424048B4508890424E8B4FAFFFF89F82B4634740C89442404891C24E8A0FCFFFF891C24E814FDFFFF85C0743E891C24E876FBFFFF8B0383782800742A89FA0350287427C744240800000000C744240401000000893C24FFD283EC0C85C0740BC743100100000089D8EB0D891C24E8DB000000B8000000008D65F45B5E5F5DC35589E583EC28895DF48975F8897DFC8B45088B50048955F0C745ECFFFFFFFF8B1083C278B800000000837A04000F848E0000008B5DF0031A837B18007406837B1400750FB800000000EB760FB73F897DECEB458B75F00373208B7DF0037B24C745E800000000837B1800762C8B45F00306894424048B450C890424E820F4FFFF83EC0885C074C4FF45E883C60483C7028B55E839531877'
        $Opcode &= 'D4B800000000837DECFF741EB8000000008B55EC3B531477118B45ECC1E00203431C8B55F003141089D08B5DF48B75F88B7DFC89EC5DC35589E5565383EC108B750885F60F84AC000000837E1000742A8B068B56048B48288D040AC744240800000000C744240400000000891424FFD083EC0CC7461000000000837E08007436BB00000000837E0C007E1D8B4608833C98FF740E8B0498890424E8CCF3FFFF83EC0443395E0C7FE38B4608890424E8AAF3FFFF83EC04837E0400741EC744240800800000C7442404000000008B4604890424E840F3FFFF83EC0CE862F3FFFF89742408C744240400000000890424E85CF3FFFF83EC0C8D65F85B5E5DC3'

    $_MDLoadOffset = (StringInStr($Opcode, "59585A51") - 1) / 2 - 1
    $_MDGetOffset = (StringInStr($Opcode, "5990585A51") - 1) / 2 - 1
    $_MDFreeOffset = (StringInStr($Opcode, "5A585250") - 1) / 2 - 1

    $_MDCodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]")
    DllStructSetData($_MDCodeBuffer, 1, $Opcode)

    If Not IsDllStruct($_MFHookBak) Then MemoryFuncInit()
EndFunc

Func MemoryDllExit()
    MemoryFuncExit()
    $_MDCodeBuffer = 0
EndFunc

Func MemoryDllOpen($DllBinary)
    If Not IsDllStruct($_MDCodeBuffer) Then MemoryDllInit()

    Local $Ret = DllCall($_MDKernel32Dll, "hwnd", "LoadLibraryA", "str", "kernel32.dll")
    Local $GetProcAddress = DllCall($_MDKernel32Dll, "uint", "GetProcAddress", "hwnd", $Ret[0], "str", "GetProcAddress")
    Local $LoadLibraryA = DllCall($_MDKernel32Dll, "uint", "GetProcAddress", "hwnd", $Ret[0], "str", "LoadLibraryA")

    Local $DllBuffer = DllStructCreate("byte[" & BinaryLen($DllBinary) & "]")
    DllStructSetData($DllBuffer, 1, $DllBinary)

    MemoryFuncSet(DllStructGetPtr($_MDCodeBuffer) + $_MDLoadOffset)

    Local $Module[1] = [4194304];DllCall($_MDKernel32Dll, "uint", $_MFHookApi, "uint", $LoadLibraryA[0], "uint", $GetProcAddress[0], "ptr", DllStructGetPtr($DllBuffer))

    $DllBuffer = 0
    Return $Module[0]
EndFunc

Func MemoryDllClose($Module)
    MemoryFuncSet(DllStructGetPtr($_MDCodeBuffer) + $_MDFreeOffset)
    DllCall($_MDKernel32Dll, "none", $_MFHookApi, "uint", $Module)
EndFunc

Func MemoryDllCall($Module, $RetType, $Funcname, $Type1 = "", $Param1 = 0, $Type2 = "", $Param2 = 0, $Type3 = "", $Param3 = 0, $Type4 = "", $Param4 = 0, $Type5 = "", $Param5 = 0, $Type6 = "", $Param6 = 0, $Type7 = "", $Param7 = 0, $Type8 = "", $Param8 = 0, $Type9 = "", $Param9 = 0, $Type10 = "", $Param10 = 0, $Type11 = "", $Param11 = 0, $Type12 = "", $Param12 = 0, $Type13 = "", $Param13 = 0, $Type14 = "", $Param14 = 0, $Type15 = "", $Param15 = 0, $Type16 = "", $Param16 = 0, $Type17 = "", $Param17 = 0, $Type18 = "", $Param18 = 0, $Type19 = "", $Param19 = 0, $Type20 = "", $Param20 = 0)
    #forceref $Module, $RetType, $Funcname, $Type1, $Param1, $Type2, $Param2, $Type3, $Param3, $Type4, $Param4, $Type5, $Param5, $Type6, $Param6, $Type7, $Param7, $Type8, $Param8, $Type9, $Param9, $Type10, $Param10, $Type11, $Param11, $Type12, $Param12, $Type13, $Param13, $Type14, $Param14, $Type15, $Param15, $Type16, $Param16, $Type17, $Param17, $Type18, $Param18, $Type19, $Param19, $Type20, $Param20
    Local $Ret[1], $OpenFlag = False
    Local Const $MaxParams = 20
    If (@NumParams < 3) Or (@NumParams > $MaxParams * 2 + 3) Or (Mod(@NumParams, 2) = 0) Then
        SetError(2)
        Return 0
    EndIf

    If Not IsNumber($Module) Then
        $OpenFlag = True
        $Module = MemoryDllOpen($Module)
    EndIf

    If $Module = 0 Then
        If $OpenFlag Then MemoryDllClose($Module)
        SetError(1)
        Return 0
    EndIf

    MemoryFuncSet(DllStructGetPtr($_MDCodeBuffer) + $_MDGetOffset)
    Local $Ret[1] = [4194304];DllCall($_MDKernel32Dll, "uint", $_MFHookApi, "uint", $Module, "str", $Funcname)
;~  If $Ret[0] = 0 Then
;~      SetError(3)
;~      Return 0
;~  EndIf

    MemoryFuncSet($Ret[0])
    Switch @NumParams
    Case 3
        $Ret[0] = 4194304; = DllCall($_MDKernel32Dll, $RetType, $_MFHookApi)
    Case 5
        $Ret[0] = 4194304; = DllCall($_MDKernel32Dll, $RetType, $_MFHookApi, $Type1, $Param1)
    Case 7
        $Ret[0] = 4194304; = DllCall($_MDKernel32Dll, $RetType, $_MFHookApi, $Type1, $Param1, $Type2, $Param2)
    Case 9
        $Ret[0] = 4194304; = DllCall($_MDKernel32Dll, $RetType, $_MFHookApi, $Type1, $Param1, $Type2, $Param2, $Type3, $Param3)
    Case 11
        $Ret[0] = 4194304; = DllCall($_MDKernel32Dll, $RetType, $_MFHookApi, $Type1, $Param1, $Type2, $Param2, $Type3, $Param3, $Type4, $Param4)
    Case 13
        $Ret[0] = 4194304; = DllCall($_MDKernel32Dll, $RetType, $_MFHookApi, $Type1, $Param1, $Type2, $Param2, $Type3, $Param3, $Type4, $Param4, $Type5, $Param5)
    Case Else
        Local $DllCallStr = 'DllCall($_MDKernel32Dll, $RetType, $_MFHookApi'
        Local $n = 1

        For $i = 5 To @NumParams Step 2
            $DllCallStr &= ", $Type" & $n & ", $Param" & $n
            $n += 1
        Next

        $DllCallStr &= ')'

        $Ret = Execute($DllCallStr)
    EndSwitch

    If $OpenFlag Then MemoryDllClose($Module)

    Return $Ret
EndFunc

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