diff --git a/ProxyEdit.vcxproj b/ProxyEdit.vcxproj
index 2d1b767..f70d8c1 100644
--- a/ProxyEdit.vcxproj
+++ b/ProxyEdit.vcxproj
@@ -92,9 +92,14 @@
+
+
+
+
+
diff --git a/ProxyEdit.vcxproj.filters b/ProxyEdit.vcxproj.filters
index 27ca470..b9ebbf9 100644
--- a/ProxyEdit.vcxproj.filters
+++ b/ProxyEdit.vcxproj.filters
@@ -6,12 +6,59 @@
cpp;c;cc;cxx
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx
+ {93995380-89BD-4B04-88EB-625FBE52EBFC}
+ h;hpp;hxx
+
+
+ {93995380-89BD-4B04-88EB-625FBE52EBFB}
+ h;hpp
+
+
+ {67DA6AB6-F800-4C08-8B7A-83BB121AAD01}
+ txt;ini;md
+
+ ソース ファイル
+
+
+ ソース ファイル
+
+
+ ソース ファイル
+
+
+ ヘッダー ファイル
+
+
+ ヘッダー ファイル
+
+
+ SDK
+
+
+ SDK
+
+
+ SDK
+
+
+ SDK
+
+
+ SDK
+
+
+ SDK
+
+
+ SDK
+
+
+ SDK
+
diff --git a/src/HostContext.cpp b/src/HostContext.cpp
new file mode 100644
index 0000000..68663bc
--- /dev/null
+++ b/src/HostContext.cpp
@@ -0,0 +1,70 @@
+#include "HostContext.h"
+
+namespace pe {
+
+namespace {
+
+EDIT_HANDLE* g_edit = nullptr;
+CONFIG_HANDLE* g_config = nullptr;
+CACHE_HANDLE* g_cache = nullptr;
+HWND g_host = nullptr;
+HINSTANCE g_instance = nullptr;
+
+}
+
+void SetEditHandle(EDIT_HANDLE* handle) { g_edit = handle; }
+void SetConfigHandle(CONFIG_HANDLE* handle) { g_config = handle; }
+void SetCacheHandle(CACHE_HANDLE* handle) { g_cache = handle; }
+void SetHostWindow(HWND window) { g_host = window; }
+void SetModuleInstance(HINSTANCE instance) { g_instance = instance; }
+
+EDIT_HANDLE* Edit() { return g_edit; }
+CONFIG_HANDLE* Config() { return g_config; }
+CACHE_HANDLE* Cache() { return g_cache; }
+HWND HostWindow() { return g_host; }
+HINSTANCE ModuleInstance() { return g_instance; }
+
+EDIT_INFO EditInfo() {
+ EDIT_INFO info{};
+ if (g_edit) g_edit->get_edit_info(&info, sizeof(info));
+ return info;
+}
+
+int EditState() {
+ if (!g_edit) return EDIT_HANDLE::EDIT_STATE_EDIT;
+ return g_edit->get_edit_state();
+}
+
+bool Exporting() {
+ return EditState() == EDIT_HANDLE::EDIT_STATE_SAVE;
+}
+
+int LayoutSize(const char* key) {
+ if (!g_config) return 0;
+ return g_config->get_layout_size(g_config, key);
+}
+
+COLORREF ThemeColor(const char* key, COLORREF fallback) {
+ if (!g_config) return fallback;
+ int code = g_config->get_color_code(g_config, key);
+ if (code < 0) return fallback;
+ return RGB((code >> 16) & 0xFF, (code >> 8) & 0xFF, code & 0xFF);
+}
+
+const wchar_t* Translate(const wchar_t* text) {
+ if (!g_config) return text;
+ const wchar_t* translated = g_config->translate(g_config, text);
+ return translated ? translated : text;
+}
+
+bool CallEditSection(void* param, void (*proc)(void* param, EDIT_SECTION* edit)) {
+ if (!g_edit) return false;
+ return g_edit->call_edit_section_param(param, proc);
+}
+
+bool CallReadSection(void* param, void (*proc)(void* param, EDIT_SECTION* edit)) {
+ if (!g_edit) return false;
+ return g_edit->call_read_section_param(param, proc);
+}
+
+}
diff --git a/src/HostContext.h b/src/HostContext.h
new file mode 100644
index 0000000..6caa4d5
--- /dev/null
+++ b/src/HostContext.h
@@ -0,0 +1,36 @@
+#pragma once
+
+#include
+
+#include
+
+#include "plugin2.h"
+#include "config2.h"
+#include "cache2.h"
+
+namespace pe {
+
+void SetEditHandle(EDIT_HANDLE* handle);
+void SetConfigHandle(CONFIG_HANDLE* handle);
+void SetCacheHandle(CACHE_HANDLE* handle);
+void SetHostWindow(HWND window);
+void SetModuleInstance(HINSTANCE instance);
+
+EDIT_HANDLE* Edit();
+CONFIG_HANDLE* Config();
+CACHE_HANDLE* Cache();
+HWND HostWindow();
+HINSTANCE ModuleInstance();
+
+EDIT_INFO EditInfo();
+int EditState();
+bool Exporting();
+
+int LayoutSize(const char* key);
+COLORREF ThemeColor(const char* key, COLORREF fallback);
+const wchar_t* Translate(const wchar_t* text);
+
+bool CallEditSection(void* param, void (*proc)(void* param, EDIT_SECTION* edit));
+bool CallReadSection(void* param, void (*proc)(void* param, EDIT_SECTION* edit));
+
+}
diff --git a/src/Log.cpp b/src/Log.cpp
new file mode 100644
index 0000000..9b81891
--- /dev/null
+++ b/src/Log.cpp
@@ -0,0 +1,65 @@
+#include "Log.h"
+
+#include
+#include
+
+namespace pe {
+
+namespace {
+
+LOG_HANDLE* g_log = nullptr;
+
+#ifdef PE_DEBUG_LOG
+void WriteFileLog(const wchar_t* text) {
+ wchar_t path[MAX_PATH];
+ if (GetTempPathW(MAX_PATH, path) == 0) return;
+ wcsncat_s(path, L"ProxyEdit.log", _TRUNCATE);
+ FILE* file = nullptr;
+ if (_wfopen_s(&file, path, L"a+, ccs=UTF-8") != 0 || !file) return;
+ SYSTEMTIME now;
+ GetLocalTime(&now);
+ fwprintf(file, L"%02d:%02d:%02d.%03d [%lu] %s\n", now.wHour, now.wMinute, now.wSecond,
+ now.wMilliseconds, GetCurrentThreadId(), text);
+ fclose(file);
+}
+#endif
+
+void Emit(const wchar_t* text, bool warning) {
+ if (g_log) {
+ if (warning) g_log->warn(g_log, text);
+ else g_log->log(g_log, text);
+ }
+#ifdef PE_DEBUG_LOG
+ WriteFileLog(text);
+#else
+ (void)text;
+#endif
+}
+
+void Format(const wchar_t* format, va_list args, bool warning) {
+ wchar_t buffer[1024];
+ _vsnwprintf_s(buffer, _TRUNCATE, format, args);
+ Emit(buffer, warning);
+}
+
+}
+
+void SetLogHandle(LOG_HANDLE* handle) {
+ g_log = handle;
+}
+
+void Say(const wchar_t* format, ...) {
+ va_list args;
+ va_start(args, format);
+ Format(format, args, false);
+ va_end(args);
+}
+
+void Warn(const wchar_t* format, ...) {
+ va_list args;
+ va_start(args, format);
+ Format(format, args, true);
+ va_end(args);
+}
+
+}
diff --git a/src/Log.h b/src/Log.h
new file mode 100644
index 0000000..54fcf7f
--- /dev/null
+++ b/src/Log.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include
+
+#include "logger2.h"
+
+namespace pe {
+
+void SetLogHandle(LOG_HANDLE* handle);
+void Say(const wchar_t* format, ...);
+void Warn(const wchar_t* format, ...);
+
+}
diff --git a/src/Plugin.cpp b/src/Plugin.cpp
new file mode 100644
index 0000000..8caa9d3
--- /dev/null
+++ b/src/Plugin.cpp
@@ -0,0 +1,36 @@
+#include
+
+#include "HostContext.h"
+#include "Log.h"
+
+using namespace pe;
+
+COMMON_PLUGIN_TABLE common_plugin_table = {
+ L"プロキシ編集",
+ L"プロキシ編集 version 1.0.0",
+};
+
+EXTERN_C __declspec(dllexport) COMMON_PLUGIN_TABLE* GetCommonPluginTable(void) {
+ return &common_plugin_table;
+}
+EXTERN_C __declspec(dllexport) DWORD RequiredVersion() { return 2010000; }
+EXTERN_C __declspec(dllexport) void InitializeLogger(LOG_HANDLE* handle) { SetLogHandle(handle); }
+EXTERN_C __declspec(dllexport) void InitializeConfig(CONFIG_HANDLE* handle) { SetConfigHandle(handle); }
+EXTERN_C __declspec(dllexport) void InitializeCache(CACHE_HANDLE* handle) { SetCacheHandle(handle); }
+EXTERN_C __declspec(dllexport) bool InitializePlugin(DWORD) { return true; }
+
+EXTERN_C __declspec(dllexport) void RegisterPlugin(HOST_APP_TABLE* host) {
+ SetEditHandle(host->create_edit_handle());
+ SetHostWindow(Edit()->get_host_app_window());
+}
+
+EXTERN_C __declspec(dllexport) void UninitializePlugin() {
+}
+
+BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID) {
+ if (reason == DLL_PROCESS_ATTACH) {
+ DisableThreadLibraryCalls(module);
+ SetModuleInstance((HINSTANCE)module);
+ }
+ return TRUE;
+}