Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "base/logging.h" | 5 #include "base/logging.h" | 
| 6 #include "base/win/resource_util.h" | 6 #include "base/win/resource_util.h" | 
| 7 | 7 | 
| 8 namespace base { | 8 namespace base { | 
| 9 namespace win { | 9 namespace win { | 
| 10 bool GetDataResourceFromModule(HMODULE module, int resource_id, | 10 | 
| 11 void** data, size_t* length) { | 11 bool GetResourceFromModule(HMODULE module, | 
| 
 
sky
2013/01/11 17:21:49
Change the header to match, by that I mean one par
 
Alexei Svitkine (slow)
2013/01/11 17:41:18
Done.
 
 | |
| 12 int resource_id, | |
| 13 LPCTSTR resource_type, | |
| 14 void** data, | |
| 15 size_t* length) { | |
| 12 if (!module) | 16 if (!module) | 
| 13 return false; | 17 return false; | 
| 14 | 18 | 
| 15 if (!IS_INTRESOURCE(resource_id)) { | 19 if (!IS_INTRESOURCE(resource_id)) { | 
| 16 NOTREACHED(); | 20 NOTREACHED(); | 
| 17 return false; | 21 return false; | 
| 18 } | 22 } | 
| 19 | 23 | 
| 20 HRSRC hres_info = FindResource(module, MAKEINTRESOURCE(resource_id), | 24 HRSRC hres_info = FindResource(module, MAKEINTRESOURCE(resource_id), | 
| 21 L"BINDATA"); | 25 resource_type); | 
| 22 if (NULL == hres_info) | 26 if (NULL == hres_info) | 
| 23 return false; | 27 return false; | 
| 24 | 28 | 
| 25 DWORD data_size = SizeofResource(module, hres_info); | 29 DWORD data_size = SizeofResource(module, hres_info); | 
| 26 HGLOBAL hres = LoadResource(module, hres_info); | 30 HGLOBAL hres = LoadResource(module, hres_info); | 
| 27 if (!hres) | 31 if (!hres) | 
| 28 return false; | 32 return false; | 
| 29 | 33 | 
| 30 void* resource = LockResource(hres); | 34 void* resource = LockResource(hres); | 
| 31 if (!resource) | 35 if (!resource) | 
| 32 return false; | 36 return false; | 
| 33 | 37 | 
| 34 *data = resource; | 38 *data = resource; | 
| 35 *length = static_cast<size_t>(data_size); | 39 *length = static_cast<size_t>(data_size); | 
| 36 return true; | 40 return true; | 
| 37 } | 41 } | 
| 42 | |
| 43 bool GetDataResourceFromModule(HMODULE module, | |
| 44 int resource_id, | |
| 45 void** data, | |
| 46 size_t* length) { | |
| 47 return GetResourceFromModule(module, resource_id, L"BINDATA", data, length); | |
| 48 } | |
| 49 | |
| 38 } // namespace win | 50 } // namespace win | 
| 39 } // namespace base | 51 } // namespace base | 
| OLD | NEW |