Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(636)

Unified Diff: rlz/win/lib/process_info.cc

Issue 177843009: Make GetUserName() return more specific error code, so that we could know how the function failed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add CHECK for debugging. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: rlz/win/lib/process_info.cc
diff --git a/rlz/win/lib/process_info.cc b/rlz/win/lib/process_info.cc
index 2511f54ab76ab3cefb12035ba5893e8a92ee1816..790561e2c59ce9a4c0eae4d798fc94a46d3fadd4 100644
--- a/rlz/win/lib/process_info.cc
+++ b/rlz/win/lib/process_info.cc
@@ -33,8 +33,15 @@ HRESULT GetCurrentUser(std::wstring* name,
// In which case, search for and use the process handle of a running
// Explorer.exe.)
HANDLE token;
- if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token))
- return E_FAIL;
+
+ HANDLE process_handle = ::GetCurrentProcess()
+ if (!process_handle)
+ CHECK(0)
jar (doing other things) 2014/02/26 00:27:08 Please try to compile code before sending for a re
+ return ::GetLastError()
jar (doing other things) 2014/02/26 00:27:08 Note that IF you used a semicolon (on line 39), si
+
+ if (!::OpenProcessToken(process_handle, TOKEN_QUERY, &token))
+ CHECK(0)
+ return ::GetLastError()
base::win::ScopedHandle scoped_process_token(token);
@@ -50,11 +57,13 @@ HRESULT GetCurrentUser(std::wstring* name,
token_user_bytes.reset(new char[token_user_size]);
if (!token_user_bytes.get())
+ CHECK(0)
return E_OUTOFMEMORY;
if (!::GetTokenInformation(token, TokenUser, token_user_bytes.get(),
token_user_size, &token_user_size2)) {
- return E_FAIL;
+ CHECK(0)
+ return ::GetLastError();
}
WCHAR user_name[UNLEN + 1]; // max username length
@@ -65,11 +74,13 @@ HRESULT GetCurrentUser(std::wstring* name,
TOKEN_USER* token_user =
reinterpret_cast<TOKEN_USER*>(token_user_bytes.get());
if (!token_user)
- return E_FAIL;
+ CHECK(0)
+ return ::GetLastError();
PSID user_sid = token_user->User.Sid;
if (!::LookupAccountSidW(NULL, user_sid, user_name, &user_name_size,
domain_name, &domain_name_size, &sid_type)) {
- return E_FAIL;
+ CHECK(0)
+ return ::GetLastError();
}
if (name != NULL) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698