summaryrefslogtreecommitdiff
path: root/chromium/base/win/resource_util.cc
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@digia.com>2013-08-15 21:46:11 +0200
committerZeno Albisser <zeno.albisser@digia.com>2013-08-15 21:46:11 +0200
commit679147eead574d186ebf3069647b4c23e8ccace6 (patch)
treefc247a0ac8ff119f7c8550879ebb6d3dd8d1ff69 /chromium/base/win/resource_util.cc
downloadqtwebengine-chromium-679147eead574d186ebf3069647b4c23e8ccace6.tar.gz
Initial import.
Diffstat (limited to 'chromium/base/win/resource_util.cc')
-rw-r--r--chromium/base/win/resource_util.cc51
1 files changed, 51 insertions, 0 deletions
diff --git a/chromium/base/win/resource_util.cc b/chromium/base/win/resource_util.cc
new file mode 100644
index 00000000000..0c100785e7b
--- /dev/null
+++ b/chromium/base/win/resource_util.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/logging.h"
+#include "base/win/resource_util.h"
+
+namespace base {
+namespace win {
+
+bool GetResourceFromModule(HMODULE module,
+ int resource_id,
+ LPCTSTR resource_type,
+ void** data,
+ size_t* length) {
+ if (!module)
+ return false;
+
+ if (!IS_INTRESOURCE(resource_id)) {
+ NOTREACHED();
+ return false;
+ }
+
+ HRSRC hres_info = FindResource(module, MAKEINTRESOURCE(resource_id),
+ resource_type);
+ if (NULL == hres_info)
+ return false;
+
+ DWORD data_size = SizeofResource(module, hres_info);
+ HGLOBAL hres = LoadResource(module, hres_info);
+ if (!hres)
+ return false;
+
+ void* resource = LockResource(hres);
+ if (!resource)
+ return false;
+
+ *data = resource;
+ *length = static_cast<size_t>(data_size);
+ return true;
+}
+
+bool GetDataResourceFromModule(HMODULE module,
+ int resource_id,
+ void** data,
+ size_t* length) {
+ return GetResourceFromModule(module, resource_id, L"BINDATA", data, length);
+}
+
+} // namespace win
+} // namespace base