| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/logging.h" | |
| 6 #include "base/win/resource_util.h" | |
| 7 | |
| 8 namespace base { | |
| 9 namespace win { | |
| 10 | |
| 11 bool GetResourceFromModule(HMODULE module, | |
| 12 int resource_id, | |
| 13 LPCTSTR resource_type, | |
| 14 void** data, | |
| 15 size_t* length) { | |
| 16 if (!module) | |
| 17 return false; | |
| 18 | |
| 19 if (!IS_INTRESOURCE(resource_id)) { | |
| 20 NOTREACHED(); | |
| 21 return false; | |
| 22 } | |
| 23 | |
| 24 HRSRC hres_info = FindResource(module, MAKEINTRESOURCE(resource_id), | |
| 25 resource_type); | |
| 26 if (NULL == hres_info) | |
| 27 return false; | |
| 28 | |
| 29 DWORD data_size = SizeofResource(module, hres_info); | |
| 30 HGLOBAL hres = LoadResource(module, hres_info); | |
| 31 if (!hres) | |
| 32 return false; | |
| 33 | |
| 34 void* resource = LockResource(hres); | |
| 35 if (!resource) | |
| 36 return false; | |
| 37 | |
| 38 *data = resource; | |
| 39 *length = static_cast<size_t>(data_size); | |
| 40 return true; | |
| 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 | |
| 50 } // namespace win | |
| 51 } // namespace base | |
| OLD | NEW |