flat assembler
Message board for the users of flat assembler.

Index > Windows > Need an exorcist for this code :(

Author
Thread Post new topic Reply to topic
StakFallT



Joined: 19 Jan 2006
Posts: 50
StakFallT 19 Jan 2006, 04:27
Ok so I been working on this little pet-project of mine. The first time I seen this example, I said to myself, [this has ALOT of potential]. The example I'm referring to is an MASM32 example, more specifically the LCD cd-player

(
(C) 2000 by Thomas Bleeker [exagone]. http://exagone.cjb.net -- Awesome work man, if your reading this.. It's one of the things that really intrigued me to start writting in asm)


I started out with it by stripping out almost all of the cd stuff, pasting in some mp3 code I found off the net, and modifying it a little to fit my needs, then managing to get scrolling text (just in a straight line though and somewhat buggy at that). I then posted in the Win32ASM community asking why things weren't behaving properly, and someone suggested to take out all the HLL statements as certain registers don't get preserved, etc.. I also noticed that [] didn't seem to matter in MASM which I did not like at all .. The more and more I looked at fasm the more I liked, but was kind of turned off by it being a) Open Source and b) the version number being so low.. Nothing personal just at the time it seemed like the two combined factors gave me the impression it wasn't developed enough to be worth the effort to re--get-used-to.. Long story short, I got tired of masm so much that I finally decided to make the jump to fasm and I converted the lcd code as best as I could given my fairly limited knowledge and experience in asm.. Problem is it just does not want to seem to show the window at all.. It loads and I see it in my process tab in my task manager but no window and no application tab on my task bar, and I am using ws+visible and what not.. Anyhow both the original code and my butchered and modified code (lol) is attached to this thread. I was really hoping to be able to fix it myself and surprise the community by releasing it in hopes that it'd greatly help someone. I found the examples that come with FASM way to basic (simple msg box stuff) or way too advanced (multi formed code; code that has code for individual dialogs, etc and links them all together through the code; ex.. Teeth [the image/music previewer]).

In a way I feel like I failed but I know it's been a long time I been trying to get it to work right, and it's long past that time I think that I just ask for help on it :/ There's just so much I still don't undertsand yet, like some documentation I read says edx is data, ecx is integer (a counter) ebx is a base pointer, eax is a return value, but it seems almost like it's more of a convention than anything, as I've seen some stuff that doesn't seem to follow that Confused

-- StakFallT


Description: my butchered and modified code
Download
Filename: asmdemo1.zip
Filesize: 204.31 KB
Downloaded: 263 Time(s)

Description: Original MASM32 LCD cd player example
Download
Filename: LCD.zip
Filesize: 18.04 KB
Downloaded: 258 Time(s)

Post 19 Jan 2006, 04:27
View user's profile Send private message Reply with quote
KRA



Joined: 14 Jun 2005
Posts: 24
KRA 19 Jan 2006, 07:38
Hav't compiled and tested but I think your problem is here:
line 419 -> 421
Code:
    mov   [hwnd],eax
    invoke ShowWindow,hwnd,SW_SHOWNORMAL
    invoke UpdateWindow, hwnd    

should probably be:
Code:
    mov   [hwnd],eax
    invoke ShowWindow,[hwnd],SW_SHOWNORMAL
    invoke UpdateWindow, [hwnd]    

You sent in the address of the window handle, not the handle value.
Hope this will get you back on track
Post 19 Jan 2006, 07:38
View user's profile Send private message Reply with quote
StakFallT



Joined: 19 Jan 2006
Posts: 50
StakFallT 19 Jan 2006, 13:44
Well in my code line 419->421 acctually was not the showwindow stuff but interestingly enough I did have my showwindow stuff rem'ed out for some reason, unfortunatly un-rem'ing them out and changing them to have the []'s didn't help it any Sad
Post 19 Jan 2006, 13:44
View user's profile Send private message Reply with quote
StakFallT



Joined: 19 Jan 2006
Posts: 50
StakFallT 20 Jan 2006, 06:22
ok I reworked ALOT of my code, unfortunately same result.. so. I decided to fire up OllyDbg (My disassembler/debugger of choice.. on a side note man that is one sick little debugger... sux the guy doesn't work on it anymore Sad ) Anyhow I opened the file and got some message about the PE header and breakpoints possibly causing disasterious effects because the code uncompiles itself of some weird claim that the prog definately desn't do lol so I figured w/e.. I continued and told the debugger to "analyze" the code (I also have the MS Symbol collection installed on my machine [windoze xp] and Olly pointed to that directory for it's symbol lookups). I then "Run Trace | Add Entry of all procedures" and then "Animate Into" and I notice it constantly loops through

Code:
00401723   >  6A 00         PUSH    0                                ; /MsgFilterMax = 0
00401725   . |6A 00         PUSH    0                                ; |MsgFilterMin = 0
00401727   . |6A 00         PUSH    0                                ; |hWnd = NULL
00401729   . |68 70164000   PUSH    Demo1_-_.00401670                ; |pMsg = Demo1_-_.00401670
0040172E   . |FF15 29234000 CALL    [<&USER32.GetMessageA>]          ; \GetMessageA
00401734   . |09C0          OR      EAX, EAX
00401736   . |74 18         JE      SHORT Demo1_-_.00401750
00401738   . |68 70164000   PUSH    Demo1_-_.00401670                ; /pMsg = WM_NULL
0040173D   . |FF15 55234000 CALL    [<&USER32.TranslateMessage>]     ; \TranslateMessage
00401743   . |68 70164000   PUSH    Demo1_-_.00401670                ; /pMsg = WM_NULL
00401748   . |FF15 1D234000 CALL    [<&USER32.DispatchMessageA>]     ; \DispatchMessageA
0040174E   .^\EB D3         JMP     SHORT Demo1_-_.00401723
    


Not really sure how that helps me, but it sems like it should... Again I have the task running in the background, no task bar tab just the process in memory, and no window... I tried adding in an InvalidateRect api call (no phun intended) to force a repain afx message thereby forcing the prog to jump into the WndProc::wm_paint section.. but then I quickly realized that won't work because my hWnd is declared on my WndProc procedure entry line:
proc WndProc hWnd, uMsg, wParam, lParam

and I kind of need that to stay there because the stuff inside WndProc works off of that formal hWnd paramater so... nuless there's some way to grab the correct hWnd at the right time outside of the WndProc procedure there's no way for me to take that out of there.. so I'm kinda back to square one except that I now know it's looping like mad through my msgloop-loop *puzzled*

-- StakFallT
Post 20 Jan 2006, 06:22
View user's profile Send private message Reply with quote
wisepenguin



Joined: 30 Mar 2005
Posts: 129
wisepenguin 20 Jan 2006, 06:49
ive just had a quick look and it kept on crashing initially.

i fixed that, and now it is doing what you said.
the program is running but nothing is shown on the screen.

the CreateWindowEx function is failing as i added a check after it.
so im trying to figure out why.
Post 20 Jan 2006, 06:49
View user's profile Send private message Reply with quote
wisepenguin



Joined: 30 Mar 2005
Posts: 129
wisepenguin 20 Jan 2006, 06:57
i get it to create the window properly, but it is still not shown.

but now it crashes again.
i suspect its using nameofvariable instead of [nameofvariable]
and vice versa for the windows calls.

change WNDCLASS to WNDCLASSEX
and uncomment the [wc.cbSize] line.
Post 20 Jan 2006, 06:57
View user's profile Send private message Reply with quote
wisepenguin



Joined: 30 Mar 2005
Posts: 129
wisepenguin 20 Jan 2006, 07:21
ok, i commented everything out apart from the code that creates the window.
i needed FASMW to have comment/uncomment blocks of code quite badly.


RegisterClass function was causing the crash. you need to use wc and not [wc].

so its your job now to make it look pretty with all that code i commented out Smile

good luck StakFallT, post a copy when its finished.

ive uploaded the zip, for you.


Description:
Download
Filename: mine.zip
Filesize: 199.12 KB
Downloaded: 265 Time(s)

Post 20 Jan 2006, 07:21
View user's profile Send private message 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.