flat assembler
Message board for the users of flat assembler.

Index > Main > The examples section

Goto page Previous  1, 2, 3, 4  Next
Author
Thread Post new topic Reply to topic
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 16 Dec 2006, 03:20
No more giving back...


Last edited by kohlrak on 07 Aug 2008, 15:03; edited 1 time in total
Post 16 Dec 2006, 03:20
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 20 Dec 2006, 13:22
personally i do not check examples each time i download next fasmw package, but they are changed.

as i do remember, long ago local labels there were used in window procedure there, i mean labels starting with one dot. now they have no dots, thus they are global. yes, it compiled without errors and work, but shows wrong way. modificated example in attach looks correct as it parent example, but it is not correct, and it fails compilation.

Code:
d:\projects\dialog_temp\DIALOG.ASM [103]:
  wminitdialog:
error: symbol already defined.

ERRORLEVEL: 2    


Description:
Download
Filename: DIALOG_2.zip
Filesize: 1.41 KB
Downloaded: 588 Time(s)


_________________
UNICODE forever!
Post 20 Dec 2006, 13:22
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 20 Dec 2006, 15:10
shoorick: see this
Post 20 Dec 2006, 15:10
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 20 Dec 2006, 15:49
vid: i mean labels, used to jump inside proc/endp, not arguments
you can see real error message Wink

you will meet these problems when you will use some proc with labels of same names without dots inside proc/endp, or mixing there "labels" with ".labels", or use local "labels" without dot in macro, and then use these macros inside proc/endp mixing with ".labels" - thus i use only "..labels" as local in macro.

think, it is a thing has to be explaned well in doc, otherwise it may misguide hard somebody Wink

_________________
UNICODE forever!
Post 20 Dec 2006, 15:49
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 20 Dec 2006, 16:37
shoorick: hey, you are right!

tomasz: that's terrible, fix it please. And also add the error checking to examples (testing return value of APIs)
Post 20 Dec 2006, 16:37
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 20 Dec 2006, 16:47
shoorick: my point of using global labels everywhere is that it forces you to use unique names for them, which is something I consider a good practice. But you're right that in this example this doesn't make much sense.
Post 20 Dec 2006, 16:47
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 20 Dec 2006, 18:35
there is nothing terrible and no bug in real. it is just wrong strategy. i do not mind meaningful names. wm_initdialog enough good for WM_INITDIALOG processing. but if application has, say, more then one window procedure, such labels will interference if they are global.
i just think local type of labels has to be preffered inside procedure. and there is need some tips about usage of global labels between local labels and in the macros.
thanks.
Post 20 Dec 2006, 18:35
View user's profile Send private message Visit poster's website Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: US
coconut 20 Dec 2006, 19:17
update of my old example. there's so little code to set window transparency, that this can be more of an example on using a scrollbar control


Description:
Download
Filename: layeredwin.asm
Filesize: 3.69 KB
Downloaded: 604 Time(s)

Post 20 Dec 2006, 19:17
View user's profile Send private message Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost 21 Dec 2006, 03:22
coconut wrote:
update of my old example. there's so little code to set window transparency, that this can be more of an example on using a scrollbar control


I am not too crazy about the TCHAR thing but SetLayeredWindowAttributes can do some nice tricks, I often use it to fade in/fade out.

_________________
redghost.ca
Post 21 Dec 2006, 03:22
View user's profile Send private message AIM Address MSN Messenger Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: US
coconut 21 Dec 2006, 13:27
i always use template example to start my projects. i dont remember when i noticed the TCHAR thing, i just figured it was the 'new' way to do things
Post 21 Dec 2006, 13:27
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1905
DOS386 01 Jan 2007, 02:24
Some suggestions for FASM examples (rather include into packages
than for separate download):

http://board.flatassembler.net/topic.php?t=6735

What I'd like to see are more DPMI examples of course ... Wink

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug


Last edited by DOS386 on 22 Feb 2007, 05:04; edited 2 times in total
Post 01 Jan 2007, 02:24
View user's profile Send private message Reply with quote
IceStudent



Joined: 19 Dec 2003
Posts: 60
Location: Ukraine
IceStudent 14 Jan 2007, 22:32
I wrote a simple mySQL example: see attach here.
Post 14 Jan 2007, 22:32
View user's profile Send private message Reply with quote
FrozenKnight



Joined: 24 Jun 2005
Posts: 128
FrozenKnight 15 Jan 2007, 22:14
RedGhost wrote:
Here is a Windows hooking (detouring) example with FASM. This example is very heavily commented, I also kept the source nice and aligned. It writes a detour to MessageBoxA with an insert_detour function I wrote. It shows maybe opcode modification during run-time and hooking an API for whatever reason. I remember looking for this way back in the day on the MASM forums and couldn't find any examples so I had to teach myself. I am very excited to be able to contribute to FASM.

Edit: Updated with disassembly after hook is inserted, added Windows 2000 compatibility.


RedGhost while your idea is nice and all it poses a few problems. especially in older versions of windows (EG: win9x) if you were to run your program on those versions you would have to restart windows after your program crashed because. all calls to MessageBoxA after your program was run would cause a crash. (even if the call eas made by the system). instead you could change the address of the call in the imports section of your program and everything would be fine allowing full computability with all versions of windows.

Example: first create a dword size varable called TempMessageBoxA in your data section. then execute the following code.
Code:
push [MessageBoxA]
pop  [TempMessageBoxA]
mov  [MessageBoxA], oMessageBoxA    


And just add a call to TempMessageBoxA at the end of oMessageBoxA. this is a much safer method of using api hooks and it works for all versions of windows.

Note: if you get a memory access error with the above code. then use VirtualProtect to give your self write access to MessageBoxA, or alternatively you could just add writeable privileges to your imports table.
Post 15 Jan 2007, 22:14
View user's profile Send private message Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost 27 Jan 2007, 12:07
FrozenKnight wrote:
RedGhost wrote:
Here is a Windows hooking (detouring) example with FASM. This example is very heavily commented, I also kept the source nice and aligned. It writes a detour to MessageBoxA with an insert_detour function I wrote. It shows maybe opcode modification during run-time and hooking an API for whatever reason. I remember looking for this way back in the day on the MASM forums and couldn't find any examples so I had to teach myself. I am very excited to be able to contribute to FASM.

Edit: Updated with disassembly after hook is inserted, added Windows 2000 compatibility.


RedGhost while your idea is nice and all it poses a few problems. especially in older versions of windows (EG: win9x) if you were to run your program on those versions you would have to restart windows after your program crashed because. all calls to MessageBoxA after your program was run would cause a crash. (even if the call eas made by the system). instead you could change the address of the call in the imports section of your program and everything would be fine allowing full computability with all versions of windows.

Example: first create a dword size varable called TempMessageBoxA in your data section. then execute the following code.
Code:
push [MessageBoxA]
pop  [TempMessageBoxA]
mov  [MessageBoxA], oMessageBoxA    


And just add a call to TempMessageBoxA at the end of oMessageBoxA. this is a much safer method of using api hooks and it works for all versions of windows.

Note: if you get a memory access error with the above code. then use VirtualProtect to give your self write access to MessageBoxA, or alternatively you could just add writeable privileges to your imports table.


Hi, "detours" and "IAT patches" are two separate forms of hooking. I wanted to show an example of a detour, something like MS detours style, IAT patching is another example, one Matt Pietrek was kind enough to make for us years ago Smile

_________________
redghost.ca
Post 27 Jan 2007, 12:07
View user's profile Send private message AIM Address MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 14 Mar 2007, 16:52
Thanks for all posted so far, I added some of the examples to the website today - at least the ones that were correctly prepared or which I was able to correct myself.
Post 14 Mar 2007, 16:52
View user's profile Send private message Visit poster's website Reply with quote
Mac2004



Joined: 15 Dec 2003
Posts: 314
Mac2004 14 Mar 2007, 17:55
Quote:
Thanks for all posted so far, I added some of the examples to the website today - at least the ones that were correctly prepared or which I was able to correct myself.


Great! The examples section has improved quite a bit Very Happy
Post 14 Mar 2007, 17:55
View user's profile Send private message Reply with quote
white_wight



Joined: 03 Feb 2006
Posts: 24
white_wight 14 Mar 2007, 18:49


Description: Win32 standart application skeleton
Download
Filename: stdapp.zip
Filesize: 1.69 KB
Downloaded: 526 Time(s)

Description: Single section Dialog box application + shell32
Download
Filename: dlgapp.zip
Filesize: 2.85 KB
Downloaded: 522 Time(s)

Description: MDI application + version info
Download
Filename: mdiapp.zip
Filesize: 3.57 KB
Downloaded: 552 Time(s)



Last edited by white_wight on 03 Dec 2007, 21:01; edited 4 times in total
Post 14 Mar 2007, 18:49
View user's profile Send private message Reply with quote
Xorpd!



Joined: 21 Dec 2006
Posts: 161
Xorpd! 15 Mar 2007, 16:21
Quote:

Great! The examples section has improved quite a bit


Would it be possible to also improve the examples that are included with the FASM download? One example is the MANDEL program: the executable just draws a few diagonal dotted lines and then exits after a while. The DDRAW64.INC file that comes with that example clearly has mistakes. At least the Mandelbrot program on my website is tested and works. Comparison with that program should lead to fixing at least some of the errors in DDRAW64.INC.
Post 15 Mar 2007, 16:21
View user's profile Send private message Visit poster's website Reply with quote
SoLo2



Joined: 09 Mar 2007
Posts: 14
SoLo2 16 Mar 2007, 03:34
Hello!

There is the man pages and the
ioctl_list (very important, too! Smile)
for Linux.
For Windows I saw a 12MB Win32
system functions file...
Is this enough? Is here documented
how to call Windows functions
from assembler? Which registers
or stack space is used? Nothing
alike the ioctl list? Has someone
converted this file to be readable
from .html or plain ASCII...
I think this could be interesting in
this discussion... as it is probably
a "pattern-a-list". Cool

Saludos,
SoLo2
Post 16 Mar 2007, 03:34
View user's profile Send private message Visit poster's website Reply with quote
karl



Joined: 07 Feb 2006
Posts: 63
Location: South Africa
karl 20 Mar 2007, 10:33
Hi. This is an example of writing a Portable Executable out byte-for-byte using Fasm. It was made using other examples found in the fasm message board as references. It's well commented and clean. Settings are presented as equates at the beginning of the source and are currently set to work with all versions of windows.

-karl penzhorn


Description:
Download
Filename: manualpe.zip
Filesize: 1.43 KB
Downloaded: 559 Time(s)

Post 20 Mar 2007, 10:33
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4  Next

< 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.