flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2, 3, 4 Next |
Author |
|
Tomasz Grysztar 13 Dec 2006, 12:09
As you all know, the official examples section of this website is terribly under-developed, though it already contains some nice sources.
At the same time some people may wonder why I haven't put some of the programs there, even though they were posted on board with such purpose in mind. The fact is: I just haven't found a time to prepare them to fulfill a set of rules I try to apply to all the packages I put there. Thus, if anyone would like to share some program this way, I here give a set of rules/hints how the package should be prepared - if they're followed, the package will be put into Examples page as soon as possible.
Also if you notice any such problems with the examples already available in that section, please let me know. |
|||
![]() |
|
vid 13 Dec 2006, 12:31
until we have enough examples, it's enough to mention OS in description.
|
|||
![]() |
|
Vasilev Vjacheslav 13 Dec 2006, 13:45
hi tomasz, i would like to add this example of creating custom windows and buttons
ps. there are you can find code to draw masked bitmaps ps. rgn-file can be created with this utility http://www.codeproject.com/gdi/rgncreator.asp
_________________ [not enough memory] |
|||||||||||
![]() |
|
Tomasz Grysztar 13 Dec 2006, 13:46
Really, please follow my guidelines when preparing a package.
|
|||
![]() |
|
Raedwulf 13 Dec 2006, 13:56
Rules Broken Vasilev:
![]() -The package should contain all the sources but also the executable. The documentation is optional. -The name of author should be noted somewhere - in the documentation, if packages has one, or in the comment in the beginning of main source file -The sources should assemble correctly with the latest version of fasm. If you use any includes or macros other than the standard headers, please put all those includes into package. If you use standard headers, assume that the INCLUDE variable is set up, don't use absolute paths or other environment variables. (%fasminc% used not %include%) -When posting an example package, please provide a short description explaining what it demonstrates, and also an author name (see the already existing entries for a hint how it may look like). 4/6 broken, only because 1 rule was optional lol (and you didn't comment) I can only guess that Vasilev was making a package to show us how to make a wrong package! ![]() Cheers LOL, good laugh ![]() _________________ Raedwulf |
|||
![]() |
|
Raedwulf 13 Dec 2006, 13:58
At least you didn't try and make an arj, zoo, ace, arc, lha package format!
|
|||
![]() |
|
Tomasz Grysztar 13 Dec 2006, 14:05
Raedwulf wrote: (%fasminc% used not %include%) You don't use INCLUDE variable this way (especially since it may contain more than one path), see the existing examples. |
|||
![]() |
|
LocoDelAssembly 13 Dec 2006, 14:59
Code: invoke CreateRoundRectRgn,\ 0,\ ;// x-coordinate of the region's upper-left corner 0,\ ;// y-coordinate of the region's upper-left corner WND_WIDTH,\ ;// x-coordinate of the region's lower-right corner WND_HEIGHT,\ ;// y-coordinate of the region's lower-right corner 9,\ ;// height of ellipse for rounded corners 9 ;// width of ellipse for rounded corners mov edi, eax invoke CreateRectRgn,\ 0,\ ;// x-coordinate of region's upper-left corner WND_HEIGHT/2,\ ;// y-coordinate of region's upper-left corner WND_WIDTH-1,\ ;// x-coordinate of region's lower-right corner *** WND_HEIGHT ;// y-coordinate of region's lower-right corner ;*** I don't know why I have to use WND_WIDTH-1 but if I use just WND_WIDTH the window is one pixel wider in the lower half push eax ;*** PARAM FOR DELETEOBJECT!! invoke CombineRgn,\ edi,\ ;// handle to destination region edi,\ ;// handle to source region eax,\ ;// handle to source region RGN_OR ;// region combining mode call [DeleteObject] This chunk creates a GoogleTalk like region. |
|||
![]() |
|
RedGhost 13 Dec 2006, 16:40
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.ca Last edited by RedGhost on 14 Dec 2006, 05:38; edited 1 time in total |
|||||||||||
![]() |
|
MichaelH 14 Dec 2006, 00:09
RedGhost, detour_example.exe crashes with access violations at both calls -
call [MessageBoxA] call [oMessageBoxA] on my winXP. Edit: After some more playing around with this example it appears it works fine on a freshly installed winXP with SP2. The winXP it crashes on has no SP...... Hmmmmmm? Last edited by MichaelH on 14 Dec 2006, 01:59; edited 1 time in total |
|||
![]() |
|
coconut 14 Dec 2006, 01:17
crashed on server 2003 no SP
|
|||
![]() |
|
RedGhost 14 Dec 2006, 02:12
I have XP SP2 so it worked as with you. Do me a favour and post the disassembly of MessageBoxA from the non-service packed versions. It's possible the first $5 bytes are not identical, this is why I use an LDE (Reverend's or virxasm), but not for a basic example. The only two possibilities are A) Instruction corruption with MessageBoxA not having a perfect $5 bytes to hook, or B) VirtualProtectEx incompatibilities.
Edit: My suspicion was right, there is no "mov edi, edi", I am updating for compatibility with the other OS I was able to test (Win2000 SP4). Edit: Updated first post. _________________ redghost.ca |
|||
![]() |
|
arafel 14 Dec 2006, 16:11
Hi,
Here is an example of USB devices enumeration. This is a port of a C example from the Windows DDK. (made it a while ago mostly as an exercise while studding the FASM syntax...) Not a well commented. But the main part responsible for enumeration is identical to the C version from the DDK, which is fully commented, so it can be looked up for a more detailed description of the process. ![]()
|
|||||||||||
![]() |
|
vid 14 Dec 2006, 17:40
arafael: nice example. I thought of commenting it, but first i would need to understand it
![]() there is one problem though - it uses "WriteConsole" to write to stdout. This doesn't work with redirected output. I believe we should spend some work on examples to make them all of some quality - not to teach newbies bad practices |
|||
![]() |
|
vid 14 Dec 2006, 18:04
Here is my try. It should be example of multiplatform 32bit programming with libc. However i didn't manage to link this 32bit object file on my 64bit linux, and i even don't know which is 32bit libc object file on gentoo.
Someone please try to link this on linux, and provide me binary and description how to link, i will finish this example. I also plan to make same example for FASMLIB, and for 64bit code with libc.
Last edited by vid on 14 Dec 2006, 18:48; edited 1 time in total |
|||||||||||
![]() |
|
arafel 14 Dec 2006, 18:26
vid wrote: there is one problem though - it uses "WriteConsole" to write to stdout. This doesn't work with redirected output. Bad practice would be not freeing allocated resources or neglecting error checking.. WriteConsole does exactly what it is supposed to do - display the output. In the given context the support for alterative output method is not really the essence of the example. ![]() But I guess, it could be changed to WriteFile if it brings some inconvenience. |
|||
![]() |
|
vid 14 Dec 2006, 18:48
arafael: It does. When you run the program from GUI environment (not from console), window closes immediately as the program ends. Typical solution is to redirect to file "usbenum >abc.txt". This causes WriteConsole to return error, this error is unchecked, and so program just continues running. Really not a best way to do it.
I think it really should be changed to WriteFile. arafael: could you please try to link my example on linux? |
|||
![]() |
|
arafel 14 Dec 2006, 20:09
There was a slight issue with names decoration.
Here is a linked binnary.
|
|||||||||||
![]() |
|
vid 14 Dec 2006, 21:23
thanks, i will repost it complete soon.
unfortunatelly, i am not sure if accessing "errno" can be done in portable way, without some "get_errno" macro ![]() |
|||
![]() |
|
Goto page 1, 2, 3, 4 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.