RT~~~~
用CreateProcess这个函数创建了子进程之后,怎么限制这个子进程再创建进程呢???
通过CreateProcess传入什么参数??找了下,貌似没找到额
至于CreateProcessAsUser是否可以设置响应令牌权限什么的来限制??具体就不是很清楚了
望高手解答
用CreateProcess这个函数创建了子进程之后,怎么限制这个子进程再创建进程呢???
通过CreateProcess传入什么参数??找了下,貌似没找到额
至于CreateProcessAsUser是否可以设置响应令牌权限什么的来限制??具体就不是很清楚了
望高手解答
__in_opt LPCTSTR lpApplicationName,
__inout_opt LPTSTR lpCommandLine,
__in_opt LPSECURITY_ATTRIBUTES lpProcessAttributes,
__in_opt LPSECURITY_ATTRIBUTES lpThreadAttributes,
__in BOOL bInheritHandles,
__in DWORD dwCreationFlags,
__in_opt LPVOID lpEnvironment,
__in_opt LPCTSTR lpCurrentDirectory,
__in LPSTARTUPINFO lpStartupInfo,
__out LPPROCESS_INFORMATION lpProcessInformation
);CreateProcess 是个 Win32 API 函数。
你可以 hook API,不调用默认处理函数即可。
关于 hook api 的知识,这里有点相关:
http://blog.csdn.net/DavidHsing/archive/2009/05/27/4219226.aspx
用作业对象进行限制。
CreateJobObject然后BOOL SetInformationJobObject(
HANDLE hJob,
JOBOBJECTINFOCLASS JobObjectInformationClass,
PVOID pJobObjectInformation,
DWORD cbJobObjectInformationSize
);
JOBOBJECT_BASIC_LIMIT_INFORMATION 参数中的JobObjectInfoClass 使用JobObjectBasicLimitInformation常数,也就是基本配额。
然后分配了一个JOBOBJECT_BASIC_LIMIT_INFORMATION结构,对它进行初始化。
typedef struct _JOBOBJECT_BASIC_LIMIT_INFORMATION
{
LARGE_INTEGER PerProcessUserTimeLimit;
LARGE_INTEGER PerJobUserTimeLimit;
DWORD LimitFlags;
DWORD MinimumWorkingSetSize;
DWORD MaximumWorkingSetSize;
DWORD ActiveProcessLimit;//指定作业中能并发运行的进程的最大数量
/*超过此限额的任何尝试都会导致新进程终止,并报告一个“配额不足”错误。要设置这个限额,请在LimitFlags成员中指定JOB_OBJECT_LIMIT_ACTIVE_PROCESS标志
*/
DWORD_PTR Affinity;
DWORD PriorityClass;
DWORD SchedulingClass;
} JOBOBJECT_BASIC_LIMIT_INFORMATION, *PJOBOBJECT_BASIC_LIMIT_INFORMATION;
pConfigItem->iFailedTimes = 0;
// added by dsy. 每次登陆成功游戏服务器后发送touch消息保持连接。
m_SendStack.push_back(sID + " touch");
strRet = sID + " channel connect";
break;
case CHANNEL_READY_PARTY:
strRet = INIT_FINISH;
break;
case ERROR_STATUS:
{
strRet = MakingStop(id);
}
break;
case STOP_OK:
{
// 从就绪列表中删除该ID
ConfigItem* pCfg = GetConfigItem(id);
if (!pCfg)
{
pCfg->iStatus = 0;
} // 解除ID和ConfigItem的绑定
mapConnection.erase(id); // 如果不是用户停止的,且该ID未失效,需要重新创建连接
if (!bUserEnd && (mapConnection.find(id) != mapConnection.end()))
{ int iID = DispatchID();
char ch[10];
itoa(iID, ch, 10);
strRet = "start " + string(ch);
}
//else
//{
// // 用户取消,且所有连接已经断开,则发送exit消息
// if (vecReadyIDs.empty())
// {
// strRet = "exit";
// }
//} }
break;
case CHANNEL_CLOSED:
{
// 由于没有及时发送touch消息导致channel连接中断,需要断开整个连接,以重连
strRet = MakingStop(id);
}
break;
}
return strRet;
}
// 清空
static void InitData(); static string GetSendFromRecv(const string& strRecv, int& id); static int GetRecvType(const string& msg, int& id); static string GetPlayerName(); static void SetMainWndButtonStatus(BOOL bBeginStart);
static void GetServerList(string instruct, vector <STRU_GAME_SERVER>& servlist); static void GetCharList(string instruct, vector <string>& charlist); static int Init(); static bool CreateChildProcess(); static ConfigItem* GetConfigItem(int iID); static int DispatchConfigItem();
static string MakingStop(int id); static int GetIDFromInstruct(string strInstruct); static void GetUnReadyIDs(vector<int>& vec);