Incremental PrefixSet builder for Safe Browsing store.
[chromium-blink-merge.git] / chrome_elf / ntdll_cache.cc
blob2f4dbdf244315c4e6caca64a1eb4710a24ba93b1
1 // Copyright 2013 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.
5 #include <stdint.h>
6 #include <windows.h>
8 #include "base/win/pe_image.h"
9 #include "chrome_elf/ntdll_cache.h"
11 FunctionLookupTable g_ntdll_lookup;
13 namespace {
15 bool EnumExportsCallback(const base::win::PEImage& image,
16 DWORD ordinal,
17 DWORD hint,
18 LPCSTR name,
19 PVOID function_addr,
20 LPCSTR forward,
21 PVOID cookie) {
22 // Our lookup only cares about named functions that are in ntdll, so skip
23 // unnamed or forwarded exports.
24 if (name && function_addr)
25 g_ntdll_lookup[std::string(name)] = function_addr;
27 return true;
30 } // namespace
32 void InitCache() {
33 HMODULE ntdll_handle = ::GetModuleHandle(L"ntdll.dll");
35 base::win::PEImage ntdll_image(ntdll_handle);
37 ntdll_image.EnumExports(EnumExportsCallback, NULL);