flat assembler
Message board for the users of flat assembler.

Index > Windows > Win64 and resources

Author
Thread Post new topic Reply to topic
TheColonial



Joined: 30 Dec 2005
Posts: 2
Location: UK - But Australia soon!
TheColonial 30 Dec 2005, 18:16
Hi everyone,

This is my first post, so HELLO! Smile

I've started playing with ASM again after a few years in the wonderful world of high-level languages Wink And I couldn't help but resist the temptation to start playing with 64Bit asm now that I'm finally running a 64bit OS.

I have a question about resources and the general structure of the source of Win64 FASM programs as opposed to Win32. While creating my own little template, I had a fiddle with using invoke instead of call and as a result was given an error on compilation. That's when I realised that I had to include the import64.inc and proc64.inc files that are in the macro folder. This was all fine, and the program compiled and work no problem. Since this was a template, I thought I'd add in an extra section for resources, and this is where the fun started.

After adding the .rsrc section and compiling, the program failed to run and the error message I got was:
Quote:
E:\64Bit\FASM164\PROJECTS\PE64Template\Template.exe is not a valid Win32 application.
I thought this was a little strange since the compiler didn't spit out any warnings, but something was definitely up! I admit that I had left the resource section blank, so I thought I'd stick something in there (using the good-old "copy'n'paste" coding method) that I ripped from the Dialog example that comes with the compiler. At this point the compiler whinged about the use of keywords such as directory. By the looks of it, the Win64 files/includes structure isn't as up to scratch as the Win32 one (ie. there is no include for Win64a/ax/axp/w/wx/wxp). I have since read the FAQ and know that there is an issue with Win2k/XP which appears to be an issue on Win64 too.

So to my questions Smile Firstly, am I right in thinking that there should be a selection of Win64XXX.INC files? If so, are they currently being developed/created? If so, is there a chance of getting an ETA? If I'm wrong in my assumption, can someone give me a few pointers on how to get resources working in 64bit since the keywords that the macros support aren't being supported yet?

Many thanks for your time. I'm more than happy to help out with this if work needs to be done to get the 64 bit structure up to the level of the 32 bit one.

Thanks for the great tool and nice site. Cool
Regards
TC.

_________________
In order to understand recursion, one must first understand recursion.
Currently using: FASM 1.64
WinXP x64 | AMD64 3800+ | ASUS A8N SLi Deluxe | 2GB GeiL DDR
Post 30 Dec 2005, 18:16
View user's profile Send private message Visit poster's website Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend 31 Dec 2005, 14:30
I don't have 64-bit processor, but you can always try the hardcore way Smile ie. to change every 'dd' to 'dq' in the resource macros Smile

But it is true, that any section cannot be blank. Also check if you gave readable properties to '.rsrc' section. I had once such mistake and it was pain to find it, as everything in my code seemed alright.
Post 31 Dec 2005, 14:30
View user's profile Send private message Visit poster's website Reply with quote
TheColonial



Joined: 30 Dec 2005
Posts: 2
Location: UK - But Australia soon!
TheColonial 02 Jan 2006, 10:47
Hrm, I'm not sure if that's going to fix it Smile I did try and include the win32a.inc file to see if that would just "work" but it didn't, so the macros must be doing something for 32 bit that needs to be different for 64. I guess I can give it another shot and post the error that comes up when I compile... then perhaps someone can show me the areas that need to be modified.

As I said, I don't mind helping out with this - and as soon as I have a working set of win64???.inc files I'm more than happy to share them up!.

Thanks for the response Reverend.

TC.
Post 02 Jan 2006, 10:47
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 02 Jan 2006, 10:54
That's strange, because, as far as I know (from the official PE/COFF specification) the resource format have stayed the same for the 64-bit executables. Have you tried it also with "resource from" construction?

The WIN64*.INC headers are not yet ready, since they would perhaps need the 64-bit equates (in the EQUATES subdir), too. I still do not have any 64-bit machine, what is the main reason why I haven't made such includes yet.
Post 02 Jan 2006, 10:54
View user's profile Send private message Visit poster's website Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 514
Location: Czech republic, Slovak republic
Feryno 02 Jan 2006, 14:18
I failed to add resource to win64 exe with macros for win32. So I use terrible but working method:
1. I compile resource to obj file with gorc
http://www.jorgon.freeserve.co.uk/Gorcjorgbeta.zip
2.Then I include binary part of resource.obj into win64 *.asm file in resource section:
section '.rsrc' resource data readable
file 'fdbg_resource.obj':3Ch,10BCh
(last value must be calculated for various resource.obj sizes)
3. I compile *.asm file with FASM
4. The most important is patching resource in exe:
e.g. for 8 entries (I'm not realy good programmer, so I don't know the exact name for resource "entry" - but it's e.g. 1 menu + 1 accelerator table + 6 dialogs = 8 "entries")
so patch for 8 entries looks like:
lea rdi,[file_buffer]; <-point to begin of EXE loaded in patcher after ReadFile - bytes 'MZ'
cmp word [rdi],'MZ'
jnz we_didnt_read_exe
mov rcx,400h/8
mov rax,'.rsrc'
cld
repnz scasq; terrible method for find .rsrc section, but it works...
jnz close_exit
mov eax,[rdi+4]; grab section memory relative offset from program memory base start
mov ecx,[rdi+12]; grab section RVA in *.exe
lea rdx,[file_buffer]
add dword [rdx + rcx + 158h],eax ; patch it !
add dword [rdx + rcx + 168h],eax ; patch it !
add dword [rdx + rcx + 178h],eax ; patch it !
add dword [rdx + rcx + 188h],eax ; patch it !
add dword [rdx + rcx + 198h],eax ; patch it !
add dword [rdx + rcx + 1A8h],eax ; patch it !
add dword [rdx + rcx + 1B8h],eax ; patch it !
add dword [rdx + rcx + 1C8h],eax ; patch it !


for 1 "entry" in rsrc patch is: add dword [rdx + rcx + 48h],eax ; patch it !
for 2 "entries":
add dword [rdx + rcx + 80h],eax ; patch it !
add dword [rdx + rcx + 90h],eax ; patch it !
for 3 "entries"
add dword [rdx + rcx + 0B8h],eax ; patch it !
add dword [rdx + rcx + 0C8h],eax ; patch it !
add dword [rdx + rcx + 0D8h],eax ; patch it !
for 4 entries:
add dword [rdx + rcx + 0D8h],eax ; patch it !
add dword [rdx + rcx + 0E8h],eax ; patch it !
add dword [rdx + rcx + 0F8h],eax ; patch it !
add dword [rdx + rcx + 108h],eax ; patch it !
now it's rule to create 5 and above, just remove first 2 and add 3 at the end, every higher by 10h - for 5 it's: F8,108,118,128,138

But I don't known if patch offsets arent different for other "entries", I use everytime this order: 1 menu, 1 accelerator table, x dialogs.

At this time I have resource with 13 "entries" in my project, and if somebody want it, I can send it...



Last sentence was a joke, and I know, that you are better coders and you are able to do it by macros. I'm not able to construct a macros, but I'm able to test everything if somebody create it.


Last edited by Feryno on 02 Jan 2006, 14:35; edited 4 times in total
Post 02 Jan 2006, 14:18
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 02 Jan 2006, 14:27
Do you have any information whether the resource format is changed in Win64?
Or please send me the sample of correct Win64 resources.
Post 02 Jan 2006, 14:27
View user's profile Send private message Visit poster's website Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 514
Location: Czech republic, Slovak republic
Feryno 02 Jan 2006, 14:37
Post 02 Jan 2006, 14:37
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 02 Jan 2006, 15:03
Well, just as I supposed, the format of resources is the same. Then it must be some problem with alignment or data order inside the resources. When you do resource from "fdbg_resource.res" does it also create the resources that are not accepted?
Post 02 Jan 2006, 15:03
View user's profile Send private message Visit poster's website Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 514
Location: Czech republic, Slovak republic
Feryno 05 Jan 2006, 05:51
I'm too sorry to gave you wrong informations about macros. As Tomasz said, there isn't difference between win64 and win32 resources. Macros for win32 can be used for win64 very well. Yesterday I tried macros again (more than half year since my unsucces with them) and everything was perfect.
Now I will have to rewrite 20 kB resource of my project to macros... and it will be my death!
Win64 porting of 1 sample with resource from fasmw.zip included samples:


Description: resource of win64 = resource of win32
Download
Filename: resource64_by_macro.zip
Filesize: 7.97 KB
Downloaded: 379 Time(s)

Post 05 Jan 2006, 05:51
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Garthower



Joined: 21 Apr 2006
Posts: 158
Location: Ukraine
Garthower 22 Jun 2006, 12:18
I have a question. How it is possible, using macroses, to dialogue to appoint a class? For example, in RC-resource it looks so:
Code:
Dialog1 DIALOG 0, 0, 388, 162
STYLE DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
CLASS "MyClass"
CAPTION ""
FONT 9, "MS Serif"
{
....
}
    
Post 22 Jun 2006, 12:18
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.