亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? win32_service.c

?? 著名的入侵檢測系統snort的最新版本的源碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* $Id$ *//*** Copyright (C) 2002 Chris Reid <chris.reid@codecraftconsulants.com>**** This program is free software; you can redistribute it and/or modify** it under the terms of the GNU General Public License Version 2 as** published by the Free Software Foundation.  You may not use, modify or** distribute this program under any other version of the GNU General** Public License.**** This program is distributed in the hope that it will be useful,** but WITHOUT ANY WARRANTY; without even the implied warranty of** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the** GNU General Public License for more details.**** You should have received a copy of the GNU General Public License** along with this program; if not, write to the Free Software** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*//* * win32_service.c v1.0 - 20 February 2002 *  * Purpose: Lets Snort register as a Win32 Service.  This includes both *          an installation an uninstallation aspect. * * Author:  Chris Reid (chris.reid@codecraftconsulants.com) * * Notes:   The Snort command-line arguments need to be *          saved into the registry when the snort service is *          being installed.  They are stored in: *              HKLM \ SOFTWARE \ Snort *           * Usage: *          snort.exe /SERVICE /INSTALL [regular command-line params] *           *          snort.exe /SERVICE /UNINSTALL *  *          snort.exe /SERVICE /SHOW *  * References  *          Microsoft has full docs on programming Win32 Services in their *          MSDN (Microsoft Developer Network) library. *          http://msdn.microsoft.com/ */#ifdef ENABLE_WIN32_SERVICE/* * Enable the next line to automatically assign a description to the Service. * According to the Microsoft documentation, the call to ChangeServiceConfig2() * which sets the description is only available on Windows 2000 or newer. * *  #define SET_SERVICE_DESCRIPTION */#ifdef HAVE_CONFIG_H#include "config.h"#endif#include <Windows.h>#include <Winsvc.h>  /* for Service stuff */#include <stdio.h>   /* for printf(), etc */#include <direct.h>  /* for _getcwd()     */#include "snort.h"#include "debug.h"#include "util.h"static LPTSTR g_lpszServiceName        = "SnortSvc";static LPTSTR g_lpszServiceDisplayName = "Snort";static LPTSTR g_lpszServiceDescription = "The Open Source Network Intrusion Detection System";static LPTSTR g_lpszRegistryKey        = "SOFTWARE\\Snort";static LPTSTR g_lpszRegistryCmdFormat  = "CmdLineParam_%03d";static LPTSTR g_lpszRegistryCountFormat= "CmdLineParamCount";static SERVICE_STATUS          g_SnortServiceStatus; static SERVICE_STATUS_HANDLE   g_SnortServiceStatusHandle; #define MAX_REGISTRY_KEY_LENGTH   255#define MAX_REGISTRY_DATA_LENGTH  1000 static VOID  SvcDebugOut(LPSTR String, DWORD Status);static VOID  SvcFormatMessage(LPSTR szString, int iCount);static VOID  ReadServiceCommandLineParams( int * piArgCounter, char** * pargvDynamic );static VOID  WINAPI SnortServiceStart (DWORD argc, LPTSTR *argv); static VOID  WINAPI SnortServiceCtrlHandler (DWORD opcode); static DWORD SnortServiceInitialization (DWORD argc, LPTSTR *argv, DWORD *specificError); static VOID  InstallSnortService(int argc, char* argv[]);static VOID  UninstallSnortService();static VOID  ShowSnortServiceParams();/******************************************************************************* * (This documentation was taken from Microsoft's own doc's on how to create * a Win32 Service.) * * Writing a Service Program's main Function * ----------------------------------------------------------------------------- *  * The main function of a service program calls the StartServiceCtrlDispatcher * function to connect to the SCM and start the control dispatcher thread. The * dispatcher thread loops, waiting for incoming control requests for the * services specified in the dispatch table. This thread does not return until * there is an error or all of the services in the process have terminated. When * all services in a process have terminated, the SCM sends a control request * to the dispatcher thread telling it to shut down. The thread can then return * from the StartServiceCtrlDispatcher call and the process can terminate. *  * The following example is a service process that supports only one service. It * takes two parameters: a string that can contain one formatted output * character and a numeric value to be used as the formatted character. The * SvcDebugOut function prints informational messages and errors to the debugger. * For information on writing the SnortServiceStart and SnortServiceInitialization * functions, see Writing a ServiceMain Function. For information on writing the * SnortServiceCtrlHandler function, see Writing a Control Handler Function.  *******************************************************************************//* this is the entry point which is called from main() */int SnortServiceMain(int argc, char* argv[]) {    int i;    /*    SERVICE_TABLE_ENTRY   steDispatchTable[] =     {         { g_lpszServiceName, SnortServiceStart },         { NULL,       NULL                     }     };     */    SERVICE_TABLE_ENTRY   steDispatchTable[2];     steDispatchTable[0].lpServiceName = g_lpszServiceName;    steDispatchTable[0].lpServiceProc = SnortServiceStart;    steDispatchTable[1].lpServiceName = NULL;    steDispatchTable[1].lpServiceProc = NULL;    for( i=1; i<argc; i++ )    {        if( _stricmp(argv[i],SERVICE_CMDLINE_PARAM) == 0)        {            /* Ignore param, because we already know that this is a service             * simply by the fact that we are already in this function.             * However, perform a sanity check to ensure that the user             * didn't just type "snort /SERVICE" without an indicator             * following.             */            if( (i+1) < argc &&                ( _stricmp(argv[(i+1)], SERVICE_INSTALL_CMDLINE_PARAM)!=0   ||                  _stricmp(argv[(i+1)], SERVICE_UNINSTALL_CMDLINE_PARAM)!=0 ||                  _stricmp(argv[(i+1)], SERVICE_SHOW_CMDLINE_PARAM)!=0       ) )            {                /* user entered correct command-line parameters, keep looping */                continue;            }        }        else if( _stricmp(argv[i],SERVICE_INSTALL_CMDLINE_PARAM) == 0)        {            DEBUG_WRAP(DebugMessage(DEBUG_INIT, "User wishes to install the Snort service\n"););            InstallSnortService(argc, argv);            exit(0);        }        else if( _stricmp(argv[i],SERVICE_UNINSTALL_CMDLINE_PARAM) == 0)        {            DEBUG_WRAP(DebugMessage(DEBUG_INIT, "User wishes to un-install the Snort service\n"););            UninstallSnortService();            exit(0);        }        else if( _stricmp(argv[i],SERVICE_SHOW_CMDLINE_PARAM) == 0)        {            DEBUG_WRAP(DebugMessage(DEBUG_INIT, "User wishes to show the Snort service command-line parameters\n"););            ShowSnortServiceParams();            exit(0);        }        else        {            break;  /* out of for() */        }    }    /* If we got to this point, then it's time to start up the Win32 Service */    if (!StartServiceCtrlDispatcher(steDispatchTable))     {        char szString[1024];        memset(szString, sizeof(szString), '\0');        SvcFormatMessage(szString, sizeof(szString));        SvcDebugOut(szString, 0);         SvcDebugOut(" [SNORT_SERVICE] StartServiceCtrlDispatcher error = %d\n", GetLastError());         FatalError (" [SNORT_SERVICE] StartServiceCtrlDispatcher error = %d\n%s\n", GetLastError(), szString);     }    return(0);}  VOID SvcDebugOut(LPSTR szString, DWORD dwStatus) {     CHAR  szBuffer[1024];     if (strlen(szString) < 1000)     {         sprintf(szBuffer, szString, dwStatus);         OutputDebugStringA(szBuffer);     } }/* Copy the system error message into the buffer provided. * The buffer length is indicated in iCount. */VOID SvcFormatMessage(LPSTR szString, int iCount){    LPVOID lpMsgBuf;    if( szString!=NULL && iCount>0)    {        memset(szString, 0, iCount);        FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |                        FORMAT_MESSAGE_FROM_SYSTEM |                        FORMAT_MESSAGE_IGNORE_INSERTS,                       NULL,                       GetLastError(),                       MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */                       (LPTSTR) &lpMsgBuf,                       0,                       NULL                      );        strncpy(szString, (LPCTSTR) lpMsgBuf, iCount-1);                szString[iCount-1]=0;                /* Free the buffer. */        LocalFree( lpMsgBuf );        lpMsgBuf = NULL;    }}VOID ReadServiceCommandLineParams( int * piArgCounter, char** * pargvDynamic ){    HKEY  hkSnort = NULL;    long  lRegRC = 0;    DWORD dwType;    DWORD dwDataSize;    BYTE  byData[MAX_REGISTRY_DATA_LENGTH];    int   i;    /**********     * Read the registry entries for Snort command line parameters     **********/    lRegRC = RegOpenKeyEx( HKEY_LOCAL_MACHINE,        /* handle to open key      */                           g_lpszRegistryKey,         /* subkey name             */                           0,                         /* reserved (must be zero) */                           KEY_READ,                  /* desired security access */                           &hkSnort                   /* key handle              */                         );    if( lRegRC != ERROR_SUCCESS )    {        TCHAR szMsg[1000];        SvcFormatMessage(szMsg, sizeof(szMsg));        FatalError(" [SNORT_SERVICE] Unable to open Snort registry entry. "                   " Perhaps Snort has not been installed as a service."                   " %s", szMsg);     }    memset(byData, 0, sizeof(byData));    dwDataSize = sizeof(byData);    lRegRC = RegQueryValueEx( hkSnort,                      /* handle to key       */                              g_lpszRegistryCountFormat,    /* value name          */                              NULL,                         /* reserved            */                              &dwType,                      /* type buffer         */                              byData,                       /* data buffer         */                              &dwDataSize                   /* size of data buffer */                            );    if( lRegRC != ERROR_SUCCESS )    {        TCHAR szMsg[1000];        SvcFormatMessage(szMsg, sizeof(szMsg));        FatalError(" [SNORT_SERVICE] Unable to read Snort registry entry '%s'."                   " Perhaps Snort has not been installed as a service."                   " %s", g_lpszRegistryCountFormat, szMsg);     }    (*piArgCounter) = * ((int*)&byData);    (*pargvDynamic) = SnortAlloc( ((*piArgCounter) + 2) * sizeof(char *) );    (*pargvDynamic)[0] = SnortStrdup(g_lpszServiceName);    DEBUG_WRAP(DebugMessage(DEBUG_INIT, "Preparing to use the following command-line arguments:\n"););    for( i=1; i<=(*piArgCounter); i++ )    {        TCHAR szName[MAX_REGISTRY_KEY_LENGTH];        sprintf(szName, g_lpszRegistryCmdFormat, i);        memset(byData, 0, sizeof(byData));        dwDataSize = sizeof(byData);        lRegRC = RegQueryValueEx( hkSnort,            /* handle to key       */                                  szName,             /* value name          */                                  NULL,               /* reserved            */                                  &dwType,            /* type buffer         */                                  byData,             /* data buffer         */                                  &dwDataSize         /* size of data buffer */                                );        if( lRegRC != ERROR_SUCCESS )        {            TCHAR szMsg[1000];            SvcFormatMessage(szMsg, sizeof(szMsg));            FatalError(" [SNORT_SERVICE] Unable to read Snort registry entry '%s'."                       " Perhaps Snort has not been installed as a service."                       " %s", szName, szMsg);         }        (*pargvDynamic)[i] = _strdup( (char*) byData );        DEBUG_WRAP(DebugMessage(DEBUG_INIT, "  %s\n", (*pargvDynamic)[i]););    }    lRegRC = RegCloseKey( hkSnort );    if( lRegRC != ERROR_SUCCESS )    {        TCHAR szMsg[1000];        SvcFormatMessage(szMsg, sizeof(szMsg));        FatalError(" [SNORT_SERVICE] Unable to close Snort registry entry."                   " Perhaps Snort has not been installed as a service."                   " %s", szMsg);     }    hkSnort = NULL;}/******************************************************************************* * (This documentation was taken from Microsoft's own doc's on how to create * a Win32 Service.) * * Writing a ServiceMain Function * ----------------------------------------------------------------------------- *  * The SnortServiceStart function in the following example is the entry point for * the service. SnortServiceStart has access to the command-line arguments, in the * way that the main function of a console application does. The first parameter * contains the number of arguments being passed to the service. There will * always be at least one argument. The second parameter is a pointer to an * array of string pointers. The first item in the array always points to the * service name.  *  * The SnortServiceStart function first fills in the SERVICE_STATUS structure * including the control codes that it accepts. Although this service accepts * SERVICE_CONTROL_PAUSE and SERVICE_CONTROL_CONTINUE, it does nothing * significant when told to pause. The flags SERVICE_ACCEPT_PAUSE_CONTINUE was * included for illustration purposes only; if pausing does not add value to * your service, do not support it.  *  * The SnortServiceStart function then calls the RegisterServiceCtrlHandler

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲最大成人综合| 国产99久久精品| 色噜噜久久综合| 国产精品污污网站在线观看| 精品亚洲成av人在线观看| 91精品国产综合久久福利软件| 亚洲免费在线视频一区 二区| 丰满亚洲少妇av| 精品国产露脸精彩对白| 中文字幕亚洲电影| 色婷婷国产精品| 亚洲视频一二三| 91成人国产精品| 亚洲国产精品一区二区久久| 欧洲国产伦久久久久久久| 亚洲另类在线制服丝袜| 一道本成人在线| 亚洲一区二区欧美日韩| 欧洲国产伦久久久久久久| 亚洲一区二区三区四区五区黄 | 成人精品gif动图一区| 久久久美女毛片| 成人av网站在线观看免费| 最新成人av在线| 91久久精品一区二区三| 亚洲一二三区不卡| 精品久久一区二区| 国产成人在线视频网站| 国产午夜三级一区二区三| 成人午夜精品在线| 中文字幕精品三区| 色综合久久久网| 五月天一区二区三区| 欧美mv日韩mv国产网站| 成人黄色小视频在线观看| 亚洲人被黑人高潮完整版| 欧美日韩大陆在线| 国产美女久久久久| 亚洲美女免费视频| 这里是久久伊人| 粉嫩av亚洲一区二区图片| 亚洲一区二区三区四区五区中文 | 国产精品美女久久久久aⅴ | 欧美成人伊人久久综合网| 国产黄色91视频| 亚洲成人资源网| 亚洲精品在线三区| 99re亚洲国产精品| 秋霞电影网一区二区| 久久精品亚洲国产奇米99| 欧美亚洲国产一区在线观看网站| 久久综合色综合88| 91免费看片在线观看| 蜜臀久久99精品久久久久久9| 欧美经典一区二区| 欧美日韩激情在线| 成人高清伦理免费影院在线观看| 亚洲国产日韩在线一区模特| 国产天堂亚洲国产碰碰| 欧美日韩aaaaaa| 91视频免费看| 国产很黄免费观看久久| 日韩专区中文字幕一区二区| 欧美国产国产综合| 色婷婷久久99综合精品jk白丝| 国产在线精品一区二区夜色| 亚洲女同一区二区| 久久久三级国产网站| 91精品国产入口在线| 91香蕉视频在线| 国产不卡视频在线观看| 欧美a一区二区| 亚洲成人精品影院| 亚洲蜜臀av乱码久久精品蜜桃| 久久久久久一二三区| 日韩一级片网站| 欧美日韩三级视频| 日本道精品一区二区三区 | 中文字幕中文字幕在线一区| 欧美成va人片在线观看| 欧美日本在线观看| 欧美在线一区二区三区| 99re亚洲国产精品| 99re这里只有精品首页| 成人性生交大片免费看在线播放| 久久国产欧美日韩精品| 亚洲精品欧美专区| 国产精品免费视频观看| 日韩免费电影一区| 日韩欧美国产一区二区在线播放 | 欧美日韩国产一级| 91成人免费在线| 91小视频在线| 色乱码一区二区三区88| 91黄视频在线| 日本高清无吗v一区| 日本精品一区二区三区四区的功能| 成人激情午夜影院| av电影在线观看一区| 91丨国产丨九色丨pron| av亚洲产国偷v产偷v自拍| 国产综合色精品一区二区三区| 极品少妇xxxx精品少妇| 国产精品亚洲专一区二区三区| 韩日精品视频一区| 国产99久久久精品| 99国产精品久| 欧美日韩一区中文字幕| 7777精品伊人久久久大香线蕉最新版 | 日韩美女天天操| 2014亚洲片线观看视频免费| 日韩一级大片在线| www成人在线观看| 国产日韩欧美一区二区三区乱码| 国产视频一区二区在线| 久久久久久久久免费| 久久亚洲一区二区三区明星换脸| 久久免费视频色| 亚洲另类春色校园小说| 日韩福利视频导航| 国产精品自在欧美一区| 91影视在线播放| 欧美日韩在线播| 精品久久国产97色综合| 国产精品私人影院| 伊人色综合久久天天| 五月综合激情婷婷六月色窝| 日本三级亚洲精品| 日本在线不卡视频一二三区| 国产一区三区三区| 国产在线精品一区二区夜色| fc2成人免费人成在线观看播放| 色就色 综合激情| 精品精品国产高清a毛片牛牛| 亚洲国产精品av| 亚洲电影中文字幕在线观看| 美女网站一区二区| 成人av电影在线观看| 欧美视频一区二区在线观看| 精品少妇一区二区三区| 中文无字幕一区二区三区| 亚洲图片自拍偷拍| 国产精品亚洲а∨天堂免在线| 91看片淫黄大片一级| 欧美videos中文字幕| 亚洲日本在线视频观看| 麻豆91小视频| 色中色一区二区| 欧美不卡视频一区| 亚洲色图视频免费播放| 老汉av免费一区二区三区| 国产一区二区三区美女| 成人av网址在线| 久久午夜色播影院免费高清 | fc2成人免费人成在线观看播放 | 美女视频网站黄色亚洲| 99国产精品久久久久久久久久久 | 日本伊人精品一区二区三区观看方式| 99re成人精品视频| 国产精品天干天干在观线| 国产一区在线精品| 久久亚洲春色中文字幕久久久| 裸体一区二区三区| 日韩一区二区三区三四区视频在线观看 | 亚洲欧美一区二区视频| 国产成人精品免费看| 久久久久久99久久久精品网站| 美脚の诱脚舐め脚责91| 日韩视频一区二区| 麻豆一区二区三区| 欧美大片免费久久精品三p| 久久激情综合网| 亚洲精品一区二区三区福利| 国产一区福利在线| 久久久不卡网国产精品二区| 国产一区二区美女| 国产日韩欧美a| 成人h动漫精品一区二区| 国产精品福利影院| 91豆麻精品91久久久久久| 亚洲一二三四区| 欧美顶级少妇做爰| 久草热8精品视频在线观看| 精品免费视频一区二区| 韩国视频一区二区| 国产日韩精品一区二区浪潮av| 国产91精品在线观看| 亚洲日本在线视频观看| 欧美日韩电影一区| 黄色资源网久久资源365| 欧美国产激情二区三区| 色综合天天狠狠| 日韩极品在线观看| 久久久久久久久久美女| 成人av电影观看| 污片在线观看一区二区 | 欧美激情一区二区三区不卡 | 国产精品综合av一区二区国产馆| 国产精品第四页| 欧美肥胖老妇做爰|