blob: 7da461d683f0409a2a3d3c2945dcab30fe98c744 [file] [log] [blame]
license.botf003cfe2008-08-24 09:55:55 +09001// 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.
initial.commit3f4a7322008-07-27 06:49:38 +09004
5#include "base/resource_util.h"
6
7#include "base/logging.h"
8
9namespace base {
10bool GetDataResourceFromModule(HMODULE module, int resource_id,
11 void** data, size_t* length) {
12 if (!module)
13 return false;
14
15 // Get a pointer to the data in the dll.
16 DCHECK(IS_INTRESOURCE(resource_id));
17 HRSRC hres_info = FindResource(module, MAKEINTRESOURCE(resource_id),
18 L"BINDATA");
19 if (NULL == hres_info)
20 return false;
21
22 DWORD data_size = SizeofResource(module, hres_info);
23
24 HGLOBAL hres = LoadResource(module, hres_info);
25 if (!hres_info)
26 return false;
27
28 *data = LockResource(hres);
29 *length = static_cast<size_t>(data_size);
30 return true;
31}
32} // namespace
license.botf003cfe2008-08-24 09:55:55 +090033