flat assembler
Message board for the users of flat assembler.

Index > Windows > Altering a FASM example .ASM?

Author
Thread Post new topic Reply to topic
whakamaru



Joined: 03 Oct 2012
Posts: 20
Location: New Zealand
whakamaru
Using the example PEDEMO.ASM, I inserted my 32-bit syntax, (including a "mov edi,_message and a loop with a "stosb" in it) just after the start:, changed the name, compiled it. It runs from the C: prompt and the File list. The Window is displayed with the caption "Win32 assembly program" and "Hello World!" is replaced with the digits resulting from my program. Great.
But when I try the same process on PE64DEMO.ASM, with 64-bit syntax, nothing happens. No Window, no digits, no crash - just a short delay and then back to the C: prompt.
I have looked at the machine code and compared it to that of PE64DEMO.EXE. My additions are correctly compiled. The only differences are earlier on: the time/date stamp; the CheckSum digits (0xF495 for the original, 0xF213 for mine [odd?]); the virtual size of the section '.text'. 0x2D becomes 0xEE).
Am I doing something wrong?
Is there a better way to get my syntax to run and display?
I would prefer the know the correct directives to use that will produce an EXE file in 64-bit that simply display the answer at the C: prompt - using the ROM interrupt f(e) of int 10h. or similar?

_________________
watch this space
Post 16 Jan 2014, 00:31
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
Post your code so we can see what you did.
Post 16 Jan 2014, 00:40
View user's profile Send private message Visit poster's website Reply with quote
whakamaru



Joined: 03 Oct 2012
Posts: 20
Location: New Zealand
whakamaru
code is at https://sites.google.com/site/veryoddasm/
the FASM instructions for PEDEMO.ASM are very different from those in PE64DEMO.ASM?
I regret the delay... this library internet is 8 bicycle kilometres from "username", I don't come every day.
Post 19 Jan 2014, 20:32
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
That code is incomplete and doesn't compile as is.

To make it easier for us to help you perhaps you can post a complete example of your problem that compiles and does what you mentioned above. If we have to go about adding bits of code then we might add something different from what you did or just simply be too busy to spend so much time on it.

BTW: Rather than posting code like that into an external site you can post it here in your message and use the code tags.
Post 20 Jan 2014, 02:26
View user's profile Send private message Visit poster's website Reply with quote
whakamaru



Joined: 03 Oct 2012
Posts: 20
Location: New Zealand
whakamaru
As in the first post... I put the syntax into the PE64DEMO.ASM file, then ran
fasm my64.txt my64.exe
it compiled, but the resulting exe did not display anything.
Here is a short bit of syntax in 64 and 16 bit form
Code:
mov rax,0xabcd                ; mov ax,abcd
mov rbx,10                       ; mov bx,a
xor rcx,rcx                        ;xor cx,cx
@@: xor rdx,rdx               ;xor dx,dx
div rbx                              ;div bx
push rdx                            ;push dx         save remainder in reverse order
inc rcx                               ;inc cx             count the digits
or rax,rax                          ;or ax,ax    
jnz @b                               jnz 108
@@:  pop rax                    ;pop ax           get digit
add al,48                           ;add al,30       make it ASCII
mov ah,14                         ;mov ah,e       display...
int 16                                 ;int 10                    digit
loop @b                              ;loop 112
mov ah,76                          ;mov ah,4c       EXIT
int 33                                  ;int 21                   to OS
    

I would like to know what fasm directives to use to produce an executable 64-bit program.


Last edited by whakamaru on 28 Jan 2014, 04:23; edited 1 time in total
Post 27 Jan 2014, 22:36
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
revolution wrote:
That code is incomplete and doesn't compile as is.

To make it easier for us to help you perhaps you can post a complete example of your problem that compiles and does what you mentioned above. If we have to go about adding bits of code then we might add something different from what you did or just simply be too busy to spend so much time on it.
Help us to help you.
Post 27 Jan 2014, 22:50
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
whakamaru wrote:
I would like to know what fasm directives to use to produce an executable 64-bit program.
That depends. 64-bit PE can be produced using format PE64 directive, 64-bit ELF requires format ELF64 instead. Both of them need correct 64-bit code to produce executable that does something except fault.
whakamaru wrote:
it compiled, but the resulting exe did not display anything.
Do you really think 16-bit BIOS/DOS services can be used in 64-bit code?
Post 28 Jan 2014, 11:48
View user's profile Send private message Reply with quote
whakamaru



Joined: 03 Oct 2012
Posts: 20
Location: New Zealand
whakamaru
If ROM interrupts don't work in 64-bit, then how does one display the computed answer?
My alteration to PEDEMO.ASM worked, so why doesn't the alteration to PE64DEMO.ASM do similarly, to put the answer into the "Hello World" space?
I might try using an existing EXE header from Windows and adding my machine code that FASM has generated. That might work?
Post 29 Jan 2014, 22:22
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
whakamaru wrote:
If ROM interrupts don't work in 64-bit, then how does one display the computed answer?
invoke (and fastcall) are used to call the OS API. Format your number into the ASCII or UNICODE form that pleases you then use invoke to call MessageBox and display your answer.
Post 30 Jan 2014, 03:09
View user's profile Send private message Visit poster's website 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-2020, Tomasz Grysztar.

Powered by rwasa.