Windows Error Code values

I have written a C program to install/uninstall my driver.
The installation happens successfully.
During uninstall the function SetupUninstallOEMInf() fails.
The GetLastError() gives me a value of 2.
The code snippet is:

TCHAR infFileName[MAX_PATH];

if( ! SetupUninstallOEMInf( infFileName, SUOI_FORCEDELETE, NULL) )
{
//failure to delete the OEM File
_tprintf( _T("\nSetupUninstallOEMFile call failed. Code %u"), GetLastError() );
return;
}

How to find what does this 2 indicates and how to resolve this issue?
Can I get any list of error codes?
Is there any way to get descriptive message?

I got the reply to my 2 question at http://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx

Let me Google™* that for you:

https://www.google.co.uk/search?q=GetLastError

“For a complete list of error codes provided by the operating system, see System Error Codeshttp:.”

2 is everybody’s favourite File Not Found. Does infFileName exist?

* Other search engines available.

Tim Green

Senior Development Engineer

DisplayLink (UK) Limited

Registered in England No. 04811048

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: 20 April 2012 11:39
To: Windows System Software Devs Interest List
Subject: [ntdev] Windows Error Code values

I have written a C program to install/uninstall my driver.

The installation happens successfully.

During uninstall the function SetupUninstallOEMInf() fails.

The GetLastError() gives me a value of 2.

The code snippet is:



TCHAR infFileName[MAX_PATH];

if( ! SetupUninstallOEMInf( infFileName, SUOI_FORCEDELETE, NULL) )

{

//failure to delete the OEM File

_tprintf( _T(“\nSetupUninstallOEMFile call failed. Code %u”), GetLastError() );

return;

}




How to find what does this 2 indicates and how to resolve this issue?

Can I get any list of error codes?

Is there any way to get descriptive message?



NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:

http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</http:>

I recently ran across this tool: http://www.gunnerinc.com/welt.htm

Nice. The guy who wrote it has very receptive to implementing new feature suggestions. One thing he is working on now is also showing the define for the error code. I have run into extremities that it does not find, but I think it gets greater than 95%.

Nik Twerdochlib
Software Developer

+1.601.607.8309 O
+1.866.522.8678 F

BOMGAR | Enterprise Remote Support™

One of the Fastest-Growing Technology Companies in America | Technology Fast 500™

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Friday, April 20, 2012 6:39 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Windows Error Code values

I have written a C program to install/uninstall my driver.
The installation happens successfully.
During uninstall the function SetupUninstallOEMInf() fails.
The GetLastError() gives me a value of 2.
The code snippet is:

TCHAR infFileName[MAX_PATH];

if( ! SetupUninstallOEMInf( infFileName, SUOI_FORCEDELETE, NULL) )
{
//failure to delete the OEM File
_tprintf( _T("\nSetupUninstallOEMFile call failed. Code %u"), GetLastError() );
return;
}

How to find what does this 2 indicates and how to resolve this issue?
Can I get any list of error codes?
Is there any way to get descriptive message?


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

The start of this post is silly, but quickly being able to look up error
codes is always useful. Just to toss in my list of tricks:


* WinDBG of course has !error and !gle (GetLastError), which are handy and
provide the error text:

1: kd> !error 2
Error code: (Win32) 0x2 (2) - The system cannot find the file specified.


* Err.exe is the Microsoft, “look up any error code” tool, I always keep it
in my path for quick lookups:

http://www.microsoft.com/download/en/details.aspx?id=985

It can be a bit too thorough sometimes though (“2” shows up as 52 different
error codes with the default parameters).


* If you don’t happen to have err.exe handy (or an internet connection
available to go get it), Windows has a built in Win32 error code lookup
tool:

net helpmsg

For example:

E:&gt;net helpmsg 2

The system cannot find the file specified.

----------------------

* winerror.exe comes with the WDK and will translate Win32 error codes to
NTSTATUS codes (and vice versa):

E:&gt;winerror 2
2 ERROR_FILE_NOT_FOUND <–> 0xc000000e STATUS_NO_SUCH_DEVICE
2 ERROR_FILE_NOT_FOUND <–> 0xc000000f STATUS_NO_SUCH_FILE
2 ERROR_FILE_NOT_FOUND <–> 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
2 ERROR_FILE_NOT_FOUND <–> 0xc00002f0 STATUS_OBJECTID_NOT_FOUND
2 ERROR_FILE_NOT_FOUND <–> 0xc0010002 DBG_APP_NOT_IDLE

And now there’s Nik’s suggestion of WELT, for those that are GUI minded :slight_smile:

-scott


Scott Noone
Consulting Associate and Chief System Problem Analyst
OSR Open Systems Resources, Inc.
http://www.osronline.com

Besides the tools, you can look at winerror.h in the platform SDK.

When you are reporting problems like this, it is absolutlely necessary to
give the contents of the variables, that is, what is in the string
“infFileName”. The correct _tprintf would have been

_tprintf(_T(“nFile name "%s"\nSetupInstallOemFile call failed, code
%u”), infFilename, err);

It is generally a bad idea to put GetLastError() in the context you did,
because it can be damaged by any intervening calls you might add later.
For example, in C++

if(!..API call here…)
{
DWORD err = ::GetLastError();

SomeVariableDeclarationHere;

_tprintf(…);
}

By the time you get to _tprintf, the constructor of the variable may have
destoryed the value of GetLastError. I make sure that the very first line
that is executed after a failing API is a call of GetLastError(). Note
that a declaration can be executable code. That way, the special-case
scenario you show, where GetLastError just happens to work, will not be
invalidated by more sophisticated error response code.

That way, when you get error code 2, we know what the actual file name
was, and can therefore offer suggestions.

You might also investigate the use of FormatMessage for reporting errors.
If you use MFC, you can use the example I give on

http://www.flounder.com/errorstring.htm
joe

I have written a C program to install/uninstall my driver.
The installation happens successfully.
During uninstall the function SetupUninstallOEMInf() fails.
The GetLastError() gives me a value of 2.
The code snippet is:

> TCHAR infFileName[MAX_PATH];
>
> if( ! SetupUninstallOEMInf( infFileName, SUOI_FORCEDELETE, NULL) )
> {
> //failure to delete the OEM File
> _tprintf( _T("\nSetupUninstallOEMFile call failed. Code %u"),
> GetLastError() );
> return;
> }
>

How to find what does this 2 indicates and how to resolve this issue?
Can I get any list of error codes?
Is there any way to get descriptive message?


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Try this one:
http://www.resplendence.com/errorlookup

It supports decimal values, hexadecimal values, negative values, you can
grep for text on the error database plus it’s updated to the latest MS-ERREF
specfication. In believe the Windows ERR utility has not been updated for a
decade.

//Daniel

Hi Daniel ,

nice util errror lookup

on an offside tell your website people to redirect to the download
page on email submission :slight_smile:

i thought i did some thing wrong before realising i need to scroll
down and download directly :slight_smile:

On 4/21/12, xxxxx@resplendence.com wrote:
> Try this one:
> http://www.resplendence.com/errorlookup
>
> It supports decimal values, hexadecimal values, negative values, you can
> grep for text on the error database plus it’s updated to the latest MS-ERREF
> specfication. In believe the Windows ERR utility has not been updated for a
> decade.
>
> //Daniel
>
>
>
>
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

Thanks all for the replies.