flat assembler
Message board for the users of flat assembler.

Index > Tutorials and Examples > ERRORMSG.DLL

Author
Thread Post new topic Reply to topic
Sasha



Joined: 17 Nov 2011
Posts: 93
Sasha 24 Oct 2013, 01:54
I've written an enhanced version of the ERRORMSG.DLL that can be found in fasm examples. I had a less enhanced version for about a year, that helps me to catch bugs, but now I've added much more functionality. Since I've finished it just now, some bugs may still be there. Please, let me know about them and, in general, do you think it is useful? Is it clear how to use it, or a tutorial is needed?=)


Description:
Download
Filename: ERRORMSG.zip
Filesize: 4.61 KB
Downloaded: 774 Time(s)

Post 24 Oct 2013, 01:54
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 24 Oct 2013, 12:02
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 19:40; edited 1 time in total
Post 24 Oct 2013, 12:02
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20339
Location: In your JS exploiting you and your system
revolution 24 Oct 2013, 12:25
Agreed. We need more examples anyway IMO and this fits the description.

Sasha: If you wish to add a tutorial then please feel free to do that.
Post 24 Oct 2013, 12:25
View user's profile Send private message Visit poster's website Reply with quote
Sasha



Joined: 17 Nov 2011
Posts: 93
Sasha 24 Oct 2013, 14:09
This is the first steps for creating a more powerful error handler, with logging to files and displaying the error log at program termination or by calling a specific function (Like ShowErrorLog) while still running. There should be a console version prior to logfile version, also, but I can't force it to work.
The most typical usage of this library:
1. Show a messagebox with "Error" title and "Undefined error" text:
Code:
invoke  ShowError,HWND,NULL,NULL    

2. Show messagebox with your own caption and message
Code:
invoke  ShowError,HWND,"The place, where error happened","A description of the error"    

3. Retrieve the last error code and translate it to error text message
Code:
invoke  ShowError,HWND,"The place",1    

This is enough to handle the most cases, but I've made more. SetLastErrorMessage works similar to the windows SetLastError, but it also sets the error message string. This can be done by creating a message tables (see http://msdn.microsoft.com/en-us/library/windows/desktop/ms680357(v=vs.85).aspx), but my way is much simpler. And it is one of the reasons why this will not work in multithreaded environment.

4. This can be called somewhere inside the procedure
Code:
invoke  SetLastErrorMessage,"The message",APPLICATION_DEFINED_ERROR_CODE    

and then after it returns:
Code:
invoke  ShowError,HWND,"Caption",1    

5. SetLastErrorCaption function works the same, but you provide just the string, no error codes
Code:
invoke SetLastErrorCaption,"An error has occurred"    

and then
Code:
invoke  ShowError,HWND,1,"A description of the error"    

There are also miscellaneous functions that may be helpful in some situations.


Last edited by Sasha on 25 Oct 2013, 14:06; edited 2 times in total
Post 24 Oct 2013, 14:09
View user's profile Send private message Reply with quote
Sasha



Joined: 17 Nov 2011
Posts: 93
Sasha 24 Oct 2013, 14:18
In general: NULL means display the predefined message. 1 means display a message that was set by the call to the one of the SetLast... functions or provide your own string.


Last edited by Sasha on 25 Oct 2013, 14:14; edited 1 time in total
Post 24 Oct 2013, 14:18
View user's profile Send private message Reply with quote
Sasha



Joined: 17 Nov 2011
Posts: 93
Sasha 24 Oct 2013, 17:05
I thought a little and decided to remove all unnecessary things and to make the library really simple, but still more functional, than the original fasm example. So here it is ERRORMSG.DLL version 2.0
It seems to be multithread compatible.
This version has a different, much simplier usage and it is more close to the original dll. We have here 2 functions:
BOOL ShowLastError(HWND hWnd,LPCTSTR lpCaption,LPCTSTR lpErrorMessage);
BOOL ShowError(HWND hWnd,LPCTSTR lpCaption,DWORD dwErrCode);
Examples:
1. MessageBox with "Error" caption and retrieved last error message
Code:
        invoke  ShowLastError,HWND_DESKTOP,NULL,NULL    

2. No comments
Code:
invoke  ShowLastError,HWND_DESKTOP,"Hello World!","An error has occurred"    

3. If you set the last error code with 29 bit set you will get an "Undefined error" message. Until you specify the message table.
Code:
        invoke  SetLastError,APPLICATION_DEFINED_ERROR_CODE
        invoke  ShowLastError,HWND_DESKTOP,NULL,NULL    

4. You have an error code, and just want to format it to sring? Use ShowError
Code:
        invoke  ShowError,HWND_DESKTOP,"An error has occurred",1    


Description:
Download
Filename: ERRORMSG_2.zip
Filesize: 6.03 KB
Downloaded: 746 Time(s)

Post 24 Oct 2013, 17:05
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.