flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
vbVeryBeginner 18 Aug 2004, 16:54
hi,
i am in the process to translate my previous IE Switch Image Utility written in VB into FASM. i face one problem currently and really hope if the gurus here willing to help. i am able to assemble the code below but once i run it, i got error message from Windows. This program has performed an "illegal" operation and will be shut down. If the problem persists, contact the program vendor. Details: E1 caused an invalid page fault in module <unknown> at 0000:00000001. Registers: EAX=00000001 CS=0137 EIP=00000001 EFLGS=00010202 EBX=00520000 SS=013f ESP=0053fe34 EBP=0053ff78 ECX=00402087 DS=013f ESI=818e4af8 FS=3c9f EDX=00000001 ES=013f EDI=818eacd8 GS=0000 Bytes at CS:EIP: 01 00 00 00 00 00 00 16 00 cf 08 65 04 70 00 65 Stack dump: 00401054 00000000 bff88e93 818eacd8 818e4af8 00520000 45003145 00004558 818e4af8 00520000 58003145 00504f45 00000000 00000000 00000000 00000000 i am able to see the "IE Switch Image Utility - Win32 Console Mode" text appeared in my command box in red color. below is my code, i suspect the problem is around the line -> invoke WriteConsole,[conHandleOut],conTitle,45,conReturn,0 Code: format PE console 4.0 entry start include '%fasminc%\win32a.inc' section '.code' code readable executable start: invoke AllocConsole invoke GetStdHandle,STD_INPUT_HANDLE mov [conHandleIn],eax invoke GetStdHandle,STD_OUTPUT_HANDLE mov [conHandleOut],eax invoke SetConsoleTextAttribute,[conHandleOut],[conColor] invoke WriteConsole,[conHandleOut],conTitle,45,conReturn,0 exit: invoke ExitProcess,0 section '.data' data readable writeable conTitle db 'IE Switch Image Utility - Win32 Console Mode',0 conColor dd 4 conReturn dd ? conHandleIn dd ? conHandleOut dd ? section '.idata' import data readable writeable library kernel32,'kernel32.dll' import kernel32,\ lstrlen, 'lstrlenA',\ AllocConsole, 'AllocConsole',\ GetStdHandle, 'GetStdHandle',\ SetConsoleTextAttribute, 'SetConsoleTextAttribute',\ WriteConsole, 'WriteConsoleA',\ ExitProcess, 'ExitProcess' sincerely, vbVeryBeginner d(.><)b http://sulaiman.thefreebizhost.com |
|||
![]() |
|
Vortex 18 Aug 2004, 17:37
vbVeryBeginner,
You can try this one: ( StdOut function from Hutch's masm32 package ) Code: format PE CONSOLE 4.0 entry start include '%fasminc%\win32a.inc' section '.code' code readable executable start: invoke GetStdHandle,STD_OUTPUT_HANDLE mov [conHandleOut],eax invoke SetConsoleTextAttribute,[conHandleOut],[conColor] stdcall StdOut,conTitle invoke ExitProcess,0 proc StdOut,lpszText bWritten dd ? sl dd ? enter invoke GetStdHandle,STD_OUTPUT_HANDLE mov [conHandleOut],eax invoke lstrlen,[lpszText] mov [sl],eax lea eax,[bWritten] invoke WriteFile,[conHandleOut],[lpszText],[sl],eax,NULL mov eax,[bWritten] return endp section '.data' data readable writeable conTitle db 'IE Switch Image Utility - Win32 Console Mode',0 conColor dd 4 conReturn dd ? conHandleIn dd ? conHandleOut dd ? section '.idata' import data readable writeable library kernel32,'kernel32.dll' import kernel32,\ ExitProcess,'ExitProcess',\ GetStdHandle,'GetStdHandle',\ SetConsoleTextAttribute,'SetConsoleTextAttribute',\ WriteFile,'WriteFile',\ lstrlen,'lstrlenA' _________________ Code it... That's all... |
|||
![]() |
|
coconut 18 Aug 2004, 18:43
privalov, what bug was this?
|
|||
![]() |
|
vbVeryBeginner 18 Aug 2004, 19:43
to : privalov
just about to download the new fixed 1.54. never realized it is a bug of fasm, coz i am just kinda start playing win32 using asm. so whenever things go wrong, i will suspect myself first instead of the application ... :p i guess i need to get some motivation class to increase my self confidence ![]() i discover a serious bug that even if explain to me, i guess i would not be able to understand. <- and that is funny :p to:vortex is AllocConcole unnecessary to invoke? i will try your nice piece later ![]() thank you. sincerely, vbVeryBeginner d(^.-)b http://sulaiman.thefreebizhost.com |
|||
![]() |
|
Tomasz Grysztar 18 Aug 2004, 19:58
coconut: in some situations it did not realize that the value of label has changed and one more pass should be done, this caused invalid address to occur in generated code.
|
|||
![]() |
|
Vortex 19 Aug 2004, 09:51
vbVeryBeginner,
You have no need to use the function allocating the console box, the statement Code:
format PE CONSOLE 4.0
is enough to create console based applications. _________________ Code it... That's all... |
|||
![]() |
|
vbVeryBeginner 19 Aug 2004, 12:12
ic, thanks... vortex
but does it means also, i dont have to invoke FreeConsole, does the console self-destroyed it self upon the end of application execution? sincerely, vbVeryBeginner d(*-*)b |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.