Assembly Errori Windows
From UIC
Error-handling in Win32
Contents |
| Infos | |
|---|---|
| Author: | Dracon |
| Email: | andreas.theDragon@gmx.net |
| Website: | |
| Date: | 01/01/2001 (dd/mm/yyyy) |
| Level: |
|
| Language: | English |
| Comments: | |
Link e Riferimenti
Introduzione
Hunting bugs is very annoying, especially if you use a Win32-Api function and it doesn't work for some reason. There is a way to get a nice formated error-message which will help in most cases...
Essay
Almost every api function sets, in case of failure, the global error variable to a special value. You can retrieve it with a call to "GetLastError()". This value alone is not very usefull, but you can use it to translate it into an error-string with "FormatMessage()". This function is quite complex, I will only concentrate on the things that are important for us:
DWORD dwFlags, // source and processing options
LPCVOID lpSource, // pointer to message source
DWORD dwMessageId, // requested message identifier
DWORD dwLanguageId, // language identifier for requested message
LPTSTR lpBuffer, // pointer to message buffer
DWORD nSize, // maximum size of message buffer
va_list *Arguments // pointer to array of message inserts
);
| | |
|---|---|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
Even an example is given in the doc how to use it in conjunction with GetLastError(). I have ported my old C-Code to asm which will display a nice messagebox with the error message. The only parameter is the title of the messagebox, usually the name of the function that has caused the error.
Sometimes the error message will be very strange, here are two examples and their meanings (unfortunately, I only know the german ones, but I have translated them roughly):
| 1) |
"The process was executed." (Der Vorgang wurde ausgeführt.)
|
|---|---|
| 2) |
"This is only possible in Win32 mode."
|
Check out "example.asm" for a short example how you can use "HandleError". I make use of the nice high-level features that Masm provides so you shouldn't have a problem to understand this "masterpiece". ;-)
Note Finali
Comments, hints or bugs can go to: andreas.theDragon@gmx.net
Greetings:
- Iczelion (win32asm.cjb.net)
- Knotty Dread (dread99.cjb.net)
Disclaimer
I documenti qui pubblicati sono da considerarsi pubblici e liberamente distribuibili, a patto che se ne citi la fonte di provenienza. Tutti i documenti presenti su queste pagine sono stati scritti esclusivamente a scopo di ricerca, nessuna di queste analisi è stata fatta per fini commerciali, o dietro alcun tipo di compenso. I documenti pubblicati presentano delle analisi puramente teoriche della struttura di un programma, in nessun caso il software è stato realmente disassemblato o modificato; ogni corrispondenza presente tra i documenti pubblicati e le istruzioni del software oggetto dell'analisi, è da ritenersi puramente casuale. Tutti i documenti vengono inviati in forma anonima ed automaticamente pubblicati, i diritti di tali opere appartengono esclusivamente al firmatario del documento (se presente), in nessun caso il gestore di questo sito, o del server su cui risiede, può essere ritenuto responsabile dei contenuti qui presenti, oltretutto il gestore del sito non è in grado di risalire all'identità del mittente dei documenti. Tutti i documenti ed i file di questo sito non presentano alcun tipo di garanzia, pertanto ne è sconsigliata a tutti la lettura o l'esecuzione, lo staff non si assume alcuna responsabilità per quanto riguarda l'uso improprio di tali documenti e/o file, è doveroso aggiungere che ogni riferimento a fatti cose o persone è da considerarsi PURAMENTE casuale. Tutti coloro che potrebbero ritenersi moralmente offesi dai contenuti di queste pagine, sono tenuti ad uscire immediatamente da questo sito.
Vogliamo inoltre ricordare che il Reverse Engineering è uno strumento tecnologico di grande potenza ed importanza, senza di esso non sarebbe possibile creare antivirus, scoprire funzioni malevoli e non dichiarate all'interno di un programma di pubblico utilizzo. Non sarebbe possibile scoprire, in assenza di un sistema sicuro per il controllo dell'integrità, se il "tal" programma è realmente quello che l'utente ha scelto di installare ed eseguire, né sarebbe possibile continuare lo sviluppo di quei programmi (o l'utilizzo di quelle periferiche) ritenuti obsoleti e non più supportati dalle fonti ufficiali.