Sign in to follow this  
Followers 0
0000

_ResourceSaveToFile

19 posts in this topic

Hello. Im trying to write little program.

Project is in: 'C:\Project\'

main.au3 is in: C:\Project\main.au3

test.exe is in : C:\Project\test.exe

ResHacker.exe is in : C:\Project\ResHacker.exe

#AutoIt3Wrapper_UseUpx=n 
#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, test.exe, rcdata, EXE, 0  
#include "resources.au3" 
_ResourceGetAsBytes("EXE") 
_ResourceSaveToFile("working.exe", "EXE") 
if @error Then    
MsgBox(0,0,@error) ; returns only 1  or EXE Crash... 
EndIf

I am trying to compile it with Scite4AutoIt3, where could be a problem?

Also in my AutoIt Install Directory doesn't exist this one: AutoIt3Wrapper.exe

Share this post


Link to post
Share on other sites



It was inside in AutoIt3 package.

Share this post


Link to post
Share on other sites

It was inside in AutoIt3 package.

No it is not...

The lite version of SciTE is in there but not the full version with all the extra goodies.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

With new Scite package same problems..

Share this post


Link to post
Share on other sites

With new Scite package same problems..

You will have to provide better detailed information than this if you want us to help you.

Where is it going wrong?

What is shown in the SciTE output pane at compilation time?

Did you check with ResourceHacker is the test.exe was added?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Now I added everything in one dir: Au2Exe.

Source:

#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, test.exe, rcdata, EXE, 0
#include "resources.au3"
_ResourceGetAsBytes("EXE")
_ResourceSaveToFile("working.exe", "EXE")

if @error Then
MsgBox(0,0,@error) ; returns only 1  or EXE Crash...
EndIf

Scite4Autoit console output:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /prod /in "C:\Program Files\AutoIt3\Aut2Exe\split.au3" /autoit3dir "C:\Program Files\AutoIt3"
+>14:45:12 Starting AutoIt3Wrapper v.2.0.0.1    Environment(Language:0409  Keyboard:00000409  OS:WIN_XP/Service Pack 2  CPU:X64 OS:X86)
>Running AU3Check (1.54.9.0)  from:C:\Program Files\AutoIt3
+>14:45:12 AU3Check ended.rc:0
>Running:(3.2.8.0):C:\Program Files\AutoIt3\aut2exe\aut2exe.exe  /in "C:\Program Files\AutoIt3\Aut2Exe\split.au3" /out "C:\Program Files\AutoIt3\Aut2Exe\split.exe" /comp 2 /nopack /Bin C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\AutoItSC.bin
+>14:45:13 Aut2exe.exe ended.rc:0
+>14:45:13 Created program:C:\Program Files\AutoIt3\Aut2Exe\split.exe
->Warning: This is an Unicode compiled script and will not run on Win9x/ME.
>Running:ResHacker.exe -add C:\Program Files\AutoIt3\Aut2Exe\split.exe, C:\Program Files\AutoIt3\Aut2Exe\split.exe, test.exe, rcdata, EXE, 0
>ResHacker.exe -add C:\Program Files\AutoIt3\Aut2Exe\split.exe, C:\Program Files\AutoIt3\Aut2Exe\split.exe, test.exe, rcdata, EXE, 0 Ended   rc:0
+>14:45:13 AutoIt3Wrapper Finished
>Exit code: 0    Time: 2.003

Also I had some problems with WinAPI.au3 file.

Edited by 0

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

What does the Reshacker log file say?

or look at the output exe file with RH, does it actually add your chosen resource?

Ed: Thx dude, not a Reshacker issue then.

Edited by Mobius

Share this post


Link to post
Share on other sites

LogFile from ResHacker:

[02 Aug 2009, 15:04:42]
ResHacker.exe -add C:\Program Files\AutoIt3\Aut2Exe\split.exe, C:\Program Files\AutoIt3\Aut2Exe\split.exe, test.exe, rcdata, EXE, 0
  Added: RCDATA,EXE,0

Commands completed

Here is photo of ResHacker resources:

http://img198.imageshack.us/i/reshack.jpg/

here is photo, when I run script with F5 from Scite:

http://img36.imageshack.us/i/ifscite.jpg/

and here if I manual run .exe:

http://img530.imageshack.us/i/ifnormal.jpg/

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

The directory contains spaces so guess that could be an issue.

If paths are not included with filenames, then the operating systems’ current folder is presumed to contain the named file. It is generally good practise, though not required here, to enclose filenames contain spaces within double quotes.

Try:

#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_After=ResHacker.exe -add "%out%", "%out%", test.exe, rcdata, EXE, 0
#include "resources.au3"
_ResourceGetAsBytes("EXE")
_ResourceSaveToFile("working.exe", "EXE")

if @error Then
MsgBox(0,0,@error) ; returns only 1  or EXE Crash...
EndIf

... and check the reshacker.log as mentioned to see if it worked correctly.

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

@Jos:

ResHacker.log

[02 Aug 2009, 15:15:35]
ResHacker.exe -add "C:\Program Files\AutoIt3\Aut2Exe\split.exe", "C:\Program Files\AutoIt3\Aut2Exe\split.exe", test.exe, rcdata, EXE, 0
  Added: RCDATA,EXE,0

Commands completed

Running efect same as before >_<

Error code: 1 or .exe crash.

Share this post


Link to post
Share on other sites

I haven't played that much with this Include so maybe Zedna will stop by and help out.

I would use FileInclude() for this normally. >_<


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

About 8 months ago this worked well for me, but the old source doesnt work too...

So I dunno what could be wrong >_<

P.S

With FileInstall() is smthing wrong...

test.exe : 35Kb

After using FileInstall() and running script it becomes: 51Kb...

P.S.S

! ***************************************************************************************************

! * Input file is UTF8 encoded with BOM, Au3Check does not support UNICODE and will be skipped. *

! ***************************************************************************************************

What should it mean?

Edited by 0

Share this post


Link to post
Share on other sites

With FileInstall() is smthing wrong...

test.exe : 35Kb

After using FileInstall() and running script it becomes: 51Kb...

mmm , thats new for me... I haven't seen that happening.

P.S.S

! ***************************************************************************************************

! * Input file is UTF8 encoded with BOM, Au3Check does not support UNICODE and will be skipped. *

! ***************************************************************************************************

What should it mean?

This means what is says: AutoIt3Wrapper will run au3check by default but only for ansi encoded file as au3check doesn;t support UNICODE encoded files.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi all,

I think I can help here. I mentioned to Zedna some time ago that his _FileGetAsBytes was not working correctly. The problem is that the function as written returns a struct, not the bytes. This is because Zedna was using the AsBytes function within other Resource* functions and needed the struct as a return value.

I suggest you open Resources.au3 and paste these 2 functions (_ResourceGetAsBytes and _ResourceSaveToFile) in place of the existing ones - I have marked the places where I modified the code. All should then work as expected - it certainly did for me:

; _ResourceGetAsBytes() doesn't work for RT_BITMAP type
; because _ResourceGet() returns hBitmap instead of memory pointer in this case
Func _ResourceGetAsBytes($ResName, $ResType = 10, $ResLang = 0, $DLL = -1) ; $RT_RCDATA = 10
    Local $ResPointer, $ResSize

    $ResPointer = _ResourceGet($ResName, $ResType, $ResLang, $DLL)
    If @error Then Return SetError(1, 0, 0)
    $ResSize = @extended
    $struct = DllStructCreate("byte[" & $ResSize & "]", $ResPointer) ; Old return value  <<<<<<<<<<<<<<<<<<<
    Return DllStructGetData($struct, 1) ; returns bytes              ; New return line   <<<<<<<<<<<<<<<<<<<
EndFunc

Func _ResourceSaveToFile($FileName, $ResName, $ResType = 10, $ResLang = 0, $CreatePath = 0, $DLL = -1) ; $RT_RCDATA = 10
    Local $ResStruct, $ResSize, $FileHandle
    
    If $CreatePath Then $CreatePath = 8 ; mode 8 = Create directory structure if it doesn't exist in FileOpen()

    If $ResType = $RT_BITMAP Then
        ; workaround: for RT_BITMAP _ResourceGetAsBytes() doesn't work so use _ResourceGetAsImage()
        $hImage = _ResourceGetAsImage($ResName, $ResType)
        If @error Then Return SetError(10, 0, 0)
        
        ; create filepath if doesn't exist
        $FileHandle = FileOpen($FileName, 2+16+$CreatePath)
        If @error Then Return SetError(11, 0, 0)
        FileClose($FileHandle)
        If @error Then Return SetError(12, 0, 0)
        
        _GDIPlus_ImageSaveToFile($hImage, $FileName)
        _GDIPlus_ImageDispose($hImage)

        $ResSize = FileGetSize($FileName)
    Else
        ; standard way
        $ResPointer = _ResourceGet($ResName, $ResType, $ResLang, $DLL)      ; New code from here <<<<<<<<<<<<<<<<<<<<<<<<<<<
        If @error Then Return SetError(1, 0, 0)
        $ResSize = @extended
        $ResStruct = DllStructCreate("byte[" & $ResSize & "]", $ResPointer) ; To here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        If @error Then Return SetError(1, 0, 0)
        $ResSize = DllStructGetSize($ResStruct)
        
        $FileHandle = FileOpen($FileName, 2+16+$CreatePath)
        If @error Then Return SetError(2, 0, 0)
        FileWrite($FileHandle, DllStructGetData($ResStruct, 1))
        If @error Then Return SetError(3, 0, 0)
        FileClose($FileHandle)
        If @error Then Return SetError(4, 0, 0)
    EndIf

    Return $ResSize
EndFunc

Zedna was looking to modify his UDF to something similar, but has not got round to it yet. More details can be found somewhere in the Resources topic in the Examples forum.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Thanks to Melba23, this suggestion fixxed resource problem.

Of FileInstall() problem: bytes were changing because I had a little virus which itselfs inejcts to all .exe >_<

So both methods are working for me, except I dont know if I can use UPX Packer with FileInstall()....

Edited by 0

Share this post


Link to post
Share on other sites

0000,

You most certainly can use upx with FileInstall. The compiled exe is expanded into memory when run, so when you call FileInstall , everything is ready to go.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Sorry to contradict you on this Melba23, but...

The contents of a FileInstall() function are stored within the A3x section which is the binary Tail of the AutoIt3 Interpreter stub.

Upx does not compress this data by default (And cannot for Au3 to work). That is why FileInstall is not affected by upx packing.

Quality mod of those Resource functions though dude. >_<

Share this post


Link to post
Share on other sites

Mobius,

Thanks for the clarification. I knew it would work, but not exactly why. Another little bit of knowledge imparted - that is why we are here, after all!

And thanks a second time for the compliments.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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