| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "chrome_elf/blacklist/blacklist.h" | 5 #include "chrome_elf/blacklist/blacklist.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "chrome/install_static/install_util.h" | 9 #include "chrome/install_static/install_util.h" |
| 10 #include "chrome_elf/nt_registry/nt_registry.h" | 10 #include "chrome_elf/nt_registry/nt_registry.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 void GetIpcOverrides() { | 14 void GetIpcOverrides() { |
| 15 DWORD buffer_size = ::GetEnvironmentVariableW(L"hkcu_override", nullptr, 0); | 15 DWORD buffer_size = ::GetEnvironmentVariableW(L"hkcu_override", nullptr, 0); |
| 16 if (buffer_size > 0) { | 16 if (buffer_size > 0) { |
| 17 wchar_t* content = new wchar_t[buffer_size]; | 17 std::wstring content(buffer_size, L'\0'); |
| 18 buffer_size = | 18 buffer_size = |
| 19 ::GetEnvironmentVariableW(L"hkcu_override", content, buffer_size); | 19 ::GetEnvironmentVariableW(L"hkcu_override", &content[0], buffer_size); |
| 20 if (buffer_size) | 20 if (buffer_size) |
| 21 ::wcsncpy(nt::HKCU_override, content, nt::g_kRegMaxPathLen - 1); | 21 nt::SetTestingOverride(nt::HKCU, content); |
| 22 delete[] content; | |
| 23 } | 22 } |
| 24 | 23 |
| 25 buffer_size = ::GetEnvironmentVariableW(L"hklm_override", nullptr, 0); | 24 buffer_size = ::GetEnvironmentVariableW(L"hklm_override", nullptr, 0); |
| 26 if (buffer_size > 0) { | 25 if (buffer_size > 0) { |
| 27 wchar_t* content = new wchar_t[buffer_size]; | 26 std::wstring content(buffer_size, L'\0'); |
| 28 buffer_size = | 27 buffer_size = |
| 29 ::GetEnvironmentVariableW(L"hklm_override", content, buffer_size); | 28 ::GetEnvironmentVariableW(L"hklm_override", &content[0], buffer_size); |
| 30 if (buffer_size) | 29 if (buffer_size) |
| 31 ::wcsncpy(nt::HKLM_override, content, nt::g_kRegMaxPathLen - 1); | 30 nt::SetTestingOverride(nt::HKLM, content); |
| 32 delete[] content; | |
| 33 } | 31 } |
| 34 | 32 |
| 35 return; | 33 return; |
| 36 } | 34 } |
| 37 | 35 |
| 38 } // namespace | 36 } // namespace |
| 39 | 37 |
| 40 extern "C" __declspec(dllexport) void InitTestDll() { | 38 extern "C" __declspec(dllexport) void InitTestDll() { |
| 41 // Make sure we've got the latest registry overrides. | 39 // Make sure we've got the latest registry overrides. |
| 42 GetIpcOverrides(); | 40 GetIpcOverrides(); |
| 43 } | 41 } |
| 44 | 42 |
| 45 BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) { | 43 BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) { |
| 46 if (reason == DLL_PROCESS_ATTACH) { | 44 if (reason == DLL_PROCESS_ATTACH) { |
| 47 GetIpcOverrides(); | 45 GetIpcOverrides(); |
| 48 install_static::InitializeProcessType(); | 46 install_static::InitializeProcessType(); |
| 49 blacklist::Initialize(true); // force always on, no beacon | 47 blacklist::Initialize(true); // force always on, no beacon |
| 50 } | 48 } |
| 51 | 49 |
| 52 return TRUE; | 50 return TRUE; |
| 53 } | 51 } |
| OLD | NEW |