News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

GetLastError error codes description (first 34 only)

Started by felipe, November 02, 2018, 10:59:35 AM

Previous topic - Next topic

felipe

Here is a more useful implementation of what i was doing before. .asm and .exe attached.  :icon14:

sinsi

For some error messages containing e.g. %1 you must supply an argument or use FORMAT_MESSAGE_IGNORE_INSERTS.
Leaving Arguments as a null pointer gives you a "parameter incorrect" error.

felipe

But i didn't have any error here (windows 8.1)...Did you have this error in windows 10?

felipe

Also, i think what are you saying it may be applicable to only those specific cases? (where the error messages contains this kind of formatting characters %1, etc). I think that in the case of the error messages retrieved from GetLastError, there are none of this formating characters, as can be appreciated here:
https://docs.microsoft.com/en-us/windows/desktop/debug/system-error-codes--0-499-

Is this correct sinsi or you mean another issue?

sinsi

Change one line to "mov         count,35" and try  :biggrin:

felipe

No, that error happens because (extrangenly) the windows error codes (check the link above) jump from 34 to 36, then 38, 39 then 50, 51...

That's the reason why i chose to show (for now) only the first 34  :P

sinsi

Error 34 (decimal)
"The wrong diskette is in the drive.
Insert %2 (Volume Serial Number: %3) into drive %1."

Check the result of FormatMessage, EAX has the count of characters. If EAX is 0 then an error occurred (or the error code isn't one the system recognises).

jj2007

Quote from: felipe on November 02, 2018, 10:59:35 AM
Here is a more useful implementation of what i was doing before. .asm and .exe attached.  :icon14:

Wow, and everything with push & pop, no invoke :t

Here's one that goes up to code 39, pure Masm32:
include \masm32\include\masm32rt.inc
.code
start:
  xor ebx, ebx
  .Repeat
print str$(ebx), 9
invoke SetLastError, ebx
print LastError$()
inc ebx
  .Until ebx>39
  inkey "pure Masm32!!"
  exit
end start

aw27

As mentioned by sinsi if "If the function succeeds, the return value is the number of TCHARs stored in the output buffer, excluding the terminating null character". So, you can remove this code:


align 4
nextchar:
            inc         edx                   ; Count number of bytes of the string.
            cmp         byte ptr[ecx],0       ; Scan the whole string.
            je          lenghtready

            inc         ecx                   ; Next char.
            jmp         nextchar


Also you must use FORMAT_MESSAGE_IGNORE_INSERTS whenever you are not in control of the message. If you do that you can post any number of error messages, not only 34.


0: The operation completed successfully.
1: Incorrect function.
2: The system cannot find the file specified.
3: The system cannot find the path specified.
4: The system cannot open the file.
5: Access is denied.
6: The handle is invalid.
7: The storage control blocks were destroyed.
8: Not enough memory resources are available to process this command.
9: The storage control block address is invalid.
10: The environment is incorrect.
11: An attempt was made to load a program with an incorrect format.
12: The access code is invalid.
13: The data is invalid.
14: Not enough memory resources are available to complete this operation.
15: The system cannot find the drive specified.
16: The directory cannot be removed.
17: The system cannot move the file to a different disk drive.
18: There are no more files.
19: The media is write protected.
20: The system cannot find the device specified.
21: The device is not ready.
22: The device does not recognize the command.
23: Data error (cyclic redundancy check).
24: The program issued a command but the command length is incorrect.
25: The drive cannot locate a specific area or track on the disk.
26: The specified disk or diskette cannot be accessed.
27: The drive cannot find the sector requested.
28: The printer is out of paper.
29: The system cannot write to the specified device.
30: The system cannot read from the specified device.
31: A device attached to the system is not functioning.
32: The process cannot access the file because it is being used by another process.
33: The process cannot access the file because another process has locked a portion of the file.
34: The wrong diskette is in the drive.
Insert %2 (Volume Serial Number: %3) into drive %1.
35:
36: Too many files opened for sharing.
37:
38: Reached the end of the file.
39: The disk is full.
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50: The request is not supported.
51: Windows cannot find the network path. Verify that the network path is correct and the destination computer is not busy or turned off. If Windows still cannot find the network path, contact your network administrator.
52: You were not connected because a duplicate name exists on the network. If joining a domain, go to System in Control Panel to change the computer name and try again. If joining a workgroup, choose another workgroup name.
53: The network path was not found.
54: The network is busy.
55: The specified network resource or device is no longer available.
56: The network BIOS command limit has been reached.
57: A network adapter hardware error occurred.
58: The specified server cannot perform the requested operation.
59: An unexpected network error occurred.
60: The remote adapter is not compatible.
61: The printer queue is full.
62: Space to store the file waiting to be printed is not available on the server.
63: Your file waiting to be printed was deleted.
64: The specified network name is no longer available.
65: Network access is denied.
66: The network resource type is not correct.
67: The network name cannot be found.
68: The name limit for the local computer network adapter card was exceeded.
69: The network BIOS session limit was exceeded.
70: The remote server has been paused or is in the process of being started.
71: No more connections can be made to this remote computer at this time because there are already as many connections as the computer can accept.
72: The specified printer or disk device has been paused.
73:
74:
75:
76:
77:
78:
79:
80: The file exists.
81:
82: The directory or file cannot be created.
83: Fail on INT 24.
84: Storage to process this request is not available.
85: The local device name is already in use.
86: The specified network password is not correct.
87: The parameter is incorrect.
88: A write fault occurred on the network.
89: The system cannot start another process at this time.
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100: Cannot create another system semaphore.
101: The exclusive semaphore is owned by another process.
102: The semaphore is set and cannot be closed.
103: The semaphore cannot be set again.
104: Cannot request exclusive semaphores at interrupt time.
105: The previous ownership of this semaphore has ended.
106: Insert the diskette for drive %1.
107: The program stopped because an alternate diskette was not inserted.
108: The disk is in use or locked by another process.
109: The pipe has been ended.
110: The system cannot open the device or file specified.
111: The file name is too long.
112: There is not enough space on the disk.
113: No more internal file identifiers available.
114: The target internal file identifier is incorrect.
115:
116:
117: The IOCTL call made by the application program is not correct.
118: The verify-on-write switch parameter value is not correct.
119: The system does not support the command requested.
120: This function is not supported on this system.
121: The semaphore timeout period has expired.
122: The data area passed to a system call is too small.
123: The filename, directory name, or volume label syntax is incorrect.
124: The system call level is not correct.
125: The disk has no volume label.
126: The specified module could not be found.
127: The specified procedure could not be found.
128: There are no child processes to wait for.
129: The %1 application cannot be run in Win32 mode.
130: Attempt to use a file handle to an open disk partition for an operation other than raw disk I/O.
131: An attempt was made to move the file pointer before the beginning of the file.
132: The file pointer cannot be set on the specified device or file.
133: A JOIN or SUBST command cannot be used for a drive that contains previously joined drives.
134: An attempt was made to use a JOIN or SUBST command on a drive that has already been joined.
135: An attempt was made to use a JOIN or SUBST command on a drive that has already been substituted.
136: The system tried to delete the JOIN of a drive that is not joined.
137: The system tried to delete the substitution of a drive that is not substituted.
138: The system tried to join a drive to a directory on a joined drive.
139: The system tried to substitute a drive to a directory on a substituted drive.
140: The system tried to join a drive to a directory on a substituted drive.
141: The system tried to SUBST a drive to a directory on a joined drive.
142: The system cannot perform a JOIN or SUBST at this time.
143: The system cannot join or substitute a drive to or for a directory on the same drive.
144: The directory is not a subdirectory of the root directory.
145: The directory is not empty.
146: The path specified is being used in a substitute.
147: Not enough resources are available to process this command.
148: The path specified cannot be used at this time.
149: An attempt was made to join or substitute a drive for which a directory on the drive is the target of a previous substitute.
150: System trace information was not specified in your CONFIG.SYS file, or tracing is disallowed.
151: The number of specified semaphore events for DosMuxSemWait is not correct.
152: DosMuxSemWait did not execute; too many semaphores are already set.
153: The DosMuxSemWait list is not correct.
154: The volume label you entered exceeds the label character limit of the target file system.
155: Cannot create another thread.
156: The recipient process has refused the signal.
157: The segment is already discarded and cannot be locked.
158: The segment is already unlocked.
159: The address for the thread ID is not correct.
160: One or more arguments are not correct.
161: The specified path is invalid.
162: A signal is already pending.
163:
164: No more threads can be created in the system.
165:
166:
167: Unable to lock a region of a file.
168:
169:
170: The requested resource is in use.
171: Device's command support detection is in progress.
172:
173: A lock request was not outstanding for the supplied cancel region.
174: The file system does not support atomic changes to the lock type.
175:
176:
177:
178:
179:
180: The system detected a segment number that was not correct.
181:
182: The operating system cannot run %1.
183: Cannot create a file when that file already exists.
184:
185:
186: The flag passed is not correct.
187: The specified system semaphore name was not found.
188: The operating system cannot run %1.
189: The operating system cannot run %1.
190: The operating system cannot run %1.
191: Cannot run %1 in Win32 mode.
192: The operating system cannot run %1.
193: %1 is not a valid Win32 application.
194: The operating system cannot run %1.
195: The operating system cannot run %1.
196: The operating system cannot run this application program.
197: The operating system is not presently configured to run this application.
198: The operating system cannot run %1.
199: The operating system cannot run this application program.
200: The code segment cannot be greater than or equal to 64K.
201: The operating system cannot run %1.
202: The operating system cannot run %1.
203: The system could not find the environment option that was entered.
204:
205: No process in the command subtree has a signal handler.
206: The filename or extension is too long.
207: The ring 2 stack is in use.
208: The global filename characters, * or ?, are entered incorrectly or too many global filename characters are specified.
209: The signal being posted is not correct.
210: The signal handler cannot be set.
211:
212: The segment is locked and cannot be reallocated.
213:
214: Too many dynamic-link modules are attached to this program or dynamic-link module.
215: Cannot nest calls to LoadModule.
216: This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.
217: The image file %1 is signed, unable to modify.
218: The image file %1 is strong signed, unable to modify.
219:
220: This file is checked out or locked for editing by another user.
221: The file must be checked out before saving changes.
222: The file type being saved or retrieved has been blocked.
223: The file size exceeds the limit allowed and cannot be saved.
224: Access Denied. Before opening files in this location, you must first add the web site to your trusted sites list, browse to the web site, and select the option to login automatically.
225: Operation did not complete successfully because the file contains a virus or potentially unwanted software.
226: This file contains a virus or potentially unwanted software and cannot be opened. Due to the nature of this virus or potentially unwanted software, the file has been removed from this location.
227:
228:
229: The pipe is local.
230: The pipe state is invalid.
231: All pipe instances are busy.
232: The pipe is being closed.
233: No process is on the other end of the pipe.
234: More data is available.
235: The action requested resulted in no work being done. Error-style clean-up has been performed.
236:
237:
238:
239:
240: The session was canceled.
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254: The specified extended attribute name was invalid.
255: The extended attributes are inconsistent.



The code in the purest MASM32 insists that a few errors have the same message (they don't) or issue wrong messages (error 34 is not that as mentioned multiple times here):


....
31      A device attached to the system is not functioning.
32      The process cannot access the file because it is being used by another process.
33      The process cannot access the file because another process has locked a portion of the file.
34      The process cannot access the file because another process has locked a portion of the file.
35      The process cannot access the file because another process has locked a portion of the file.
36      Too many files opened for sharing.
37      Too many files opened for sharing.
38      Reached the end of the file.
  :badgrin:


sinsi


felipe

Quote from: sinsi on November 02, 2018, 01:43:53 PM
Error 34 (decimal)
"The wrong diskette is in the drive.
Insert %2 (Volume Serial Number: %3) into drive %1."

Check the result of FormatMessage, EAX has the count of characters. If EAX is 0 then an error occurred (or the error code isn't one the system recognises).

You are absolutely right sinsi... :icon14: Also as AW pointed...I wonder why i didn't see that instead of figuring out how to get the length of the buffer to display the description of the error... :redface: Ok, when i can write a window with scrolling capability i will use eax (the return value of FormatMessage and the flag FORMAT_MESSAGE_IGNORE_INSERTS)... ;)

jj thanks, but i have to confess, this time (probably because before starting to code the program yesterday i changed the color of the font and background of qeditor...i thought it will be a good idea... ::)) i was fighting with an untraceable bug for 2 hours approx...  :dazzled: When i was turning really crazy i found it:


            push        errcount
            push        offset errnumber
            push        offset numerrbuf
            call        wsprintf              ; Write the first column (error code numbers.)

            add         esp,12

            push        eax                   ; Lenght of the string.
            push        offset numerrbuf
            push        vertical
            push        horizontal
            push        hdc
            push        TextOut


PUSH TextOut!!!!!!!!!!... :biggrin: probably proto and invoke will had helped me with that one... :icon_mrgreen:

felipe

Here it's a corrected version. i.e. using the return value from FormatMessage to check for valid error codes and to show only descriptions for those ones. Also this return value, in the cases of correct error codes, is used to specify the length of the description string to TextOut... :icon14:

The program now will need to be able to scroll the window (client area actually ) horizontally and vertically... :idea:
Hopefully doesn't take me a year to incorporate this functionality... :redface:

.exe and .asm attached... :t

felipe

Oh, and also FORMAT_MESSAGE_IGNORE_INSERTS is used to avoid the mentioned problems above... :idea: