Este artículo es un artículo espejo de traducción automática, por favor haga clic aquí para saltar al artículo original.

Vista: 9441|Respuesta: 1

[VB] Pipeline anónimo implementa eco CMD

[Copiar enlace]
Publicado en 6/12/2014 0:05:15 | | |
Ya he escrito uno antesEl eco CMD se implementa usando pipelines anónimasAhora parece que el código en ese momento era realmente débil, y lo reescribí con enfado.


[mw_shl_code=c,true]void ExecuteCommand(WCHAR * pszCommand, WCHAR *pszResult, DWORD dwCount)
{
BOOL bRet = FALSO;
USES_CONVERSION;

WCHAR szCmdPath[MAX_PATH] = {0};
GetSystemDirectory(szCmdPath, sizeof(szCmdPath));
PathAppend(szCmdPath, L"cmd.exe");

SECURITY_ATTRIBUTES SecurityAttributes;
SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
SecurityAttributes.lpSecurityDescrip{filter}tor = NULL;
SecurityAttributes.bInheritHandle = TRUE;

HANDLE hRead = NULL;
HANDLE hWrite = NULL;

if(CreatePipe(&hRead, &hWrite, &SecurityAttributes, 0))
{
STARTUPINFO StartupInfo = {0};
StartupInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
StartupInfo.hStdOutput = hWrite;
StartupInfo.hStdError = hWrite;
StartupInfo.wShowWindow = SW_HIDE;

PROCESS_INFORMATION ProcesInformación = {0};

WCHAR szCurrentPath[MAX_PATH] = {0};
GetCurrentDirectory(sizeof(szCurrentPath), szCurrentPath);

if(CreateProcess(szCmdPath, pszCommand, NULL, NULL, TRUE, 0, NULL, szCurrentPath, & StartupInfo, &ProcesInformation))
{
CerrarHandle(hWrite);

char szBuffer[4096] = {0};
DWORD dwRead = 0;
if(pszResult)
{
pszResult[0] = 0;
while(VERDADERO)
{
memset(szBuffer, 0, sizeof(szBuffer));
bRet = ReadFile(hRead, szBuffer, sizeof(szBuffer), & dwRead, NULL);
if((FALSE == bRet) || (dwRead = 0))
pausa;

wcscat_s(pszResult, dwCount, A2W(szBuffer));
}
}
}

CerrarAsamblar (hRead);
}
}[/mw_shl_code]




Anterior:Detecta la tarjeta bancaria a través de Windows Phone
Próximo:Extrae rápidamente la imagen del emoticon de QQ eif
Publicado en 7/12/2014 17:24:30 |
Leer y responder es una virtud
Renuncia:
Todo el software, materiales de programación o artículos publicados por Code Farmer Network son únicamente para fines de aprendizaje e investigación; El contenido anterior no se utilizará con fines comerciales o ilegales; de lo contrario, los usuarios asumirán todas las consecuencias. La información de este sitio proviene de Internet, y las disputas de derechos de autor no tienen nada que ver con este sitio. Debes eliminar completamente el contenido anterior de tu ordenador en un plazo de 24 horas desde la descarga. Si te gusta el programa, por favor apoya el software genuino, compra el registro y obtén mejores servicios genuinos. Si hay alguna infracción, por favor contáctanos por correo electrónico.

Mail To:help@itsvse.com