{"id":1042,"date":"2022-05-21T02:44:12","date_gmt":"2022-05-21T02:44:12","guid":{"rendered":"https:\/\/262235.xyz\/?p=1042"},"modified":"2022-05-21T02:44:12","modified_gmt":"2022-05-21T02:44:12","slug":"1042","status":"publish","type":"post","link":"https:\/\/lyvba.com\/index.php\/2022\/05\/21\/1042\/","title":{"rendered":"\u81ea\u5199CorelVBA_GMS\u6e05\u9664\u5bc6\u7801\u5de5\u5177"},"content":{"rendered":"<h2>\u81ea\u5199CorelVBA_GMS\u6e05\u9664\u5bc6\u7801\u5de5\u5177 \u4e0b\u8f7d<\/h2>\n<h3><a href=\"https:\/\/lyvba.com\/CorelVBA_GMS_NOPASSWORD.zip\">https:\/\/lyvba.com\/CorelVBA_GMS_NOPASSWORD.zip<\/a><\/h3>\n<hr \/>\n<h2>\u53ef\u4ee5\u7528\u6765\u6e05\u9664 \u862d\u96c5CorelVBA\u5de5\u5177\u7bb1 0520\u5b8c\u6574\u7248 \u4e2d\u7684\u5bc6\u7801 \uff0c\u7136\u540e\u4f60\u53ef\u4ee5\u9b54\u8be5\u6539\u6210\u5b9a\u7f6e\u7684\u7248\u672c<\/h2>\n<hr \/>\n<h2>VBA_GMS_NOPASSWORD.cpp \u6e90\u7801<\/h2>\n<pre><code>#include &lt;stdio.h&gt;\n#include &lt;stdlib.h&gt;\n#include &lt;string.h&gt;\n#include &lt;windows.h&gt;\n\nsize_t get_fileSize(const char* filename);\nconst char* GetFileBaseName(const char* szPath);\nchar* memfind(const char* buf, const char* tofind, size_t len);\nvoid helpinfo(void);\nint  GetFilePath(HWND hWnd, char* szFile);\n\nint main(int argc, char* argv[])\n{\n    const char* filename = argv[1];\n    if (argc == 1) {\n        char* fbuf = new char[1024];\n        GetFilePath(0, fbuf);\n        filename = fbuf;\n        fputs(filename, stderr);\n    }\n    const char* savefile = GetFileBaseName(filename);\n\n    FILE* psdfile = fopen(filename, \"rb\");\n    if (psdfile == NULL) {\n        fputs(\"File error\", stderr);\n        exit(1);\n    }\n\n    long filesize = get_fileSize(filename);\n    size_t result;\n\n    char* buf = new char[filesize];\n    result = fread(buf, 1, filesize, psdfile);\n\n    if (filesize &gt; 10 * 1024 * 1024)\n        printf(\"\u6587\u4ef6\u5927\u5c0f: %d MB        \u6587\u4ef6\u540d:%s\n\",  filesize \/ 1024 \/ 1024, savefile);\n    else\n        printf(\"\u6587\u4ef6\u5927\u5c0f: %d KB        \u6587\u4ef6\u540d:%s\n\",  filesize \/ 1024 + 1, savefile);\n\n    fclose(psdfile);\n\n    const char* flag = \"CMG=\" ;\n    const char* fix_flag = \"CMG.\" ;\n\n    char* pch = NULL;\n    bool flag_found = false;\n\n    pch = memfind(buf, flag, result);\n\n\n    if (pch != NULL) {\n        memcpy(pch, fix_flag, 4);\n        flag_found = true;\n    }\n\n    flag = \"DPB=\" ;\n    fix_flag = \"DPB.\" ;\n\n    pch = NULL;\n    pch = memfind(buf, flag, result);\n\n    if (pch != NULL) {\n        memcpy(pch, fix_flag, 4);\n        flag_found = true;\n    }\n\n    if (!flag_found) {\n        fputs(\"GMS\u6587\u4ef6\u53ef\u80fd\u4e0d\u7528\u7834\u89e3!\", stderr);\n        exit(1);\n    }\n\n    \/\/ \u9ed8\u8ba4\u4fee\u590d\u6587\u4ef6\u540d\uff0c\u524d\u7f00 Fix_\n    char fix_name[256];\n    if (argc == 2) {\n        strcpy(fix_name, \"Fix_\");\n        strcat(fix_name, savefile);\n        savefile = fix_name;\n    }\n\n    if (argc == 3) {\n        strcpy(fix_name, argv[2]);\n        strcat(fix_name, \"\\\");\n        strcat(fix_name, savefile);\n        savefile = fix_name;\n    }\n\n\n    FILE* pFile = fopen(savefile, \"wb\");\n    fwrite(buf, sizeof(char), result, pFile);\n\n    delete [] buf;\n    fclose(pFile);\n    return 0;\n}\n\n\/\/ \u83b7\u5f97\u6587\u4ef6\u5927\u5c0f\nsize_t get_fileSize(const char* filename)\n{\n    FILE* pfile = fopen(filename, \"rb\");\n    fseek(pfile, 0, SEEK_END);\n    size_t size = ftell(pfile);\n    fclose(pfile);\n    return size;\n\n}\n\n\n\/\/ \u5f97\u5230\u5168\u8def\u5f84\u6587\u4ef6\u7684\u6587\u4ef6\u540d\nconst char* GetFileBaseName(const char* szPath)\n{\n    const char* ret = szPath + strlen(szPath);\n    while (!((*ret == '\\') || (*ret == '\/'))\n            &amp;&amp; (ret != (szPath - 1))) \/\/ \u5f97\u5230\u6587\u4ef6\u540d\n        ret--;\n    ret++;\n    return ret;\n}\n\n\/\/ \u5185\u5b58\u67e5\u627e\u5b57\u7b26 memfind\nchar* memfind(const char* buf, const char* tofind, size_t len)\n{\n    size_t findlen = strlen(tofind);\n    if (findlen &gt; len) {\n        return ((char*)NULL);\n    }\n    if (len &lt; 1) {\n        return ((char*)buf);\n    }\n\n    {\n        const char* bufend = &amp;buf[len - findlen + 1];\n        const char* c = buf;\n        for (; c &lt; bufend; c++) {\n            if (*c == *tofind) { \/\/ first letter matches\n                if (!memcmp(c + 1, tofind + 1, findlen - 1)) { \/\/ found\n                    return ((char*)c);\n                }\n            }\n        }\n    }\n\n    return ((char*)NULL);\n}\n\n\n\/\/ \u9009\u62e9\u4e00\u4e2a\u6587\u4ef6\nint   GetFilePath(HWND hWnd, char* szFile)\n{\n\n    OPENFILENAME ofn;       \/\/ common dialog box structure\n    \/\/ Initialize OPENFILENAME\n    ZeroMemory(&amp;ofn, sizeof(ofn));\n    ofn.lStructSize = sizeof(ofn);\n    ofn.hwndOwner = hWnd;\n    ofn.lpstrFile = szFile;\n    \/\/ Set lpstrFile[0] to '\u0000' so that GetOpenFileName does not\n    \/\/ use the contents of szFile to initialize itself.\n    ofn.lpstrFile[0] = '\u0000';\n    ofn.nMaxFile = 260; \/\/ \u672c\u6765sizeof(szFile);\n    ofn.lpstrFilter = \"CorelVBA GMS\u6587\u4ef6(*.gms)\u0000*.gms\u0000\u0000\";\n    ofn.nFilterIndex = 1;\n    ofn.lpstrFileTitle = NULL;\n    ofn.nMaxFileTitle = 0;\n    ofn.lpstrInitialDir = NULL;\n    ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;\n\n    \/\/ Display the Open dialog box.\n    GetOpenFileName(&amp;ofn);\n    return   lstrlen(szFile);\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u81ea\u5199CorelVBA_GMS\u6e05\u9664\u5bc6\u7801\u5de5\u5177 \u4e0b\u8f7d https:\/\/lyvba.com\/CorelVBA [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[31,67],"class_list":["post-1042","post","type-post","status-publish","format-standard","hentry","category-default","tag-cpp","tag-vba"],"_links":{"self":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/1042","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/comments?post=1042"}],"version-history":[{"count":0,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/1042\/revisions"}],"wp:attachment":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/media?parent=1042"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/categories?post=1042"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/tags?post=1042"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}