找回密码
 加入
搜索
查看: 3839|回复: 3

[系统综合] AutoIt3Wrapper嵌入Dll资源,如何调用

[复制链接]
发表于 2010-4-11 15:18:53 | 显示全部楼层 |阅读模式
本帖最后由 myloveqmx 于 2010-4-11 15:28 编辑

对于resources.au3调用的参数不太理解,希望大家能帮忙解答一下,O(∩_∩)O谢谢~
将dll内嵌到程序中,但调用Dll就是不能成功(是Ctrl+F7编译后)
用Fileinstall进行调用就可以成功
#AutoIt3Wrapper_outfile=..\123.exe
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, A.dll, rcdata, TEST_BIN_1, 0
#AutoIt3Wrapper_Run_After=upx.exe --best --compress-resources=0 "%out%"

#include <resources.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

$Dll_1=_ResourceGet("TEST_BIN_1", $RT_RCDATA) ;不知道是不是这句调用错误

$main_form = GUICreate("Form1", 400, 334, -1,-1)
$main_About = GUICtrlCreateButton("开始", 204, 292, 75, 30)
GUISetState(@SW_SHOW)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $main_About
                        DllCrack()
        EndSwitch
WEnd
Func DllCrack()
        $Dll2 = DllOpen($Dll_1)
        DllCall($Dll2, "int", "Cracker")
EndFunc
 楼主| 发表于 2010-4-16 17:14:35 | 显示全部楼层
自己再顶一下,希望大家能帮帮忙~
发表于 2010-4-16 17:18:29 | 显示全部楼层
#AutoIt3Wrapper_useupx=n
#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, test_1.txt, rcdata, TEST_TXT_1, 0
#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, image1.bmp, bitmap, TEST_BMP_1, 0
#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, image2.bmp, bitmap, TEST_BMP_2, 0
#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, image3.jpg, rcdata, TEST_JPG_3, 0
#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, binary1.dat, rcdata, TEST_BIN_1, 0
#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, C:\WINDOWS\Media\tada.wav, sound, TEST_WAV_1, 0
#AutoIt3Wrapper_run_after=upx.exe --best --compress-resources=0 "%out%"

#include "resources.au3"

$gui = GUICreate("Data from resources example",820,400)
$pic1 = GUICtrlCreatePic("",0,0,400,300)
$pic2 = GUICtrlCreatePic("",400,0,400,150)
$pic3 = GUICtrlCreatePic("",400,150,400,150)
$pic4 = GUICtrlCreatePic("",600,320,400,100)
$label1 = GUICtrlCreateLabel("",20,320,380,100)
$label2 = GUICtrlCreateLabel("",400,320,200,100)
GUISetState(@SW_SHOW)

; get string from resource
$string = _ResourceGetAsString("TEST_TXT_1")
GUICtrlSetData($label1, $string)

; set BMP image to picture control from resource  bitmap
_ResourceSetImageToCtrl($pic1, "TEST_BMP_1", $RT_BITMAP)

; get bitmap from resource (as pointer)
$hBmp = _ResourceGet("TEST_BMP_2", $RT_BITMAP)
; and use it for whatever you like
_SetBitmapToCtrl($pic2, $hBmp)

; set JPG image to picture control from resource
_ResourceSetImageToCtrl($pic3, "TEST_JPG_3")

; set image to picture control from external DLL resource
_ResourceSetImageToCtrl($pic4, "#14355", $RT_BITMAP, @SystemDir & "\shell32.dll")

; get/use picture from resources as hImage type
$size1 = _ResourceGetImageSize("TEST_BMP_1", $RT_BITMAP)
$size2 = _ResourceGetImageSize("TEST_JPG_3")
GUICtrlSetData($label2, $size1 & @CRLF & $size2)

; save binary data or another type (image) from resource to file and get its size in bytes
$size1 = _ResourceSaveToFile(@ScriptDir & "\binary_data1.dat", "TEST_BIN_1")
$size2 = _ResourceSaveToFile(@ScriptDir & "\binary_data2.bmp", "TEST_BMP_1", $RT_BITMAP)

; save binary data from resource to file (create not existing directory)
_ResourceSaveToFile("C:\Dir1\SubDir2\binary_data1.dat", "TEST_BIN_1", $RT_RCDATA, 0, 1)
_ResourceSaveToFile("C:\Dir1\SubDir2\binary_data2.bmp", "TEST_BMP_1", $RT_BITMAP, 0, 1)

; play WAV from resource (sync/async)
_ResourcePlaySound("TEST_WAV_1")
_ResourcePlaySound("TEST_WAV_1", $SND_ASYNC)

While 1
    If GUIGetMsg() = -3 Then Exit
WEnd

Func _ResourceGetImageSize($ResName, $ResType = 10) ; $RT_RCDATA = 10
    ; get/use picture from resources as hImage type
    $hImage = _ResourceGetAsImage($ResName, $ResType)
    $width =  _GDIPlus_ImageGetWidth ($hImage)
    $height = _GDIPlus_ImageGetHeight($hImage)
   
    Return "Size of " & $ResName & " is: " & $width & "x" & $height
EndFunc
 楼主| 发表于 2010-4-16 20:13:57 | 显示全部楼层
回复 3# 3mile


    这个<resource.au3>里的例子,但我找不到如何直接调用嵌入里面的DLL,现在只能通过_ResourceSaveToFile函数把嵌入的Dll保存到硬盘然后再调用,我想的是直接在内存里调用
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-20 20:22 , Processed in 0.080722 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表