Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 03:01

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



C++ DLL Lag ?

Discussion on C++ DLL Lag ? within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
blackout617's Avatar
 
elite*gold: 68
Join Date: Feb 2011
Posts: 401
Received Thanks: 96
Question C++ DLL Lag ?

Hallo ich bin neu in C++ bei meinen DLL Versuch habe ich ein problem Source:
Code:
// MyFirstDllExp.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>

BOOL Messages()
{
	MessageBoxA(0,"Message^^","Caption =)",0);
	return 1;
}

void Loop()
{
while(1)
{
	if(GetKeyState(VK_F11) < 0)
		{
		MessageBoxA(0,"Well Done You Pressed F11\n Now You will get a Second MsgBox.","Done !",0);
		Sleep(1);
		Messages();
		}
}
}

DWORD WINAPI dwHoThread(LPVOID)
{
Loop();
	return NULL;
}


BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
	DisableThreadLibraryCalls(hModule);
	if(dwReason == DLL_PROCESS_ATTACH) {
		MessageBoxA(0, "--> Injected", "Caption<--", MB_OK);
		CreateThread(NULL, NULL, &dwHoThread, NULL, NULL, NULL);
	}
	return TRUE;
}
Das problem ist ven ich die DLL Injecte der process benutzt meinen CPU %90 - %100 ohne die Dll %1 - %5 mit der Dll %90 - %100 warum ?wie kan ich es fixxen
blackout617 is offline  
Old 03/05/2014, 18:46   #2
 
Dr. Coxxy's Avatar
 
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
1. formatier den text mal ordentlich
2. hast du nen singlecore, dass du auf 90-100% kommst? O.o
3. hast vermutlich nen thread der i-was dauerhaft macht, ein kleiner sleep kann da helfen.
Dr. Coxxy is offline  
Old 03/05/2014, 18:47   #3

 
snow's Avatar
 
elite*gold: 724
Join Date: Mar 2011
Posts: 10,479
Received Thanks: 3,318
Code:
while (1)
Verwende GetMessage & schau, ob F11 gedrückt wurde.
snow is offline  
Old 03/05/2014, 19:10   #4


 
MrSm!th's Avatar
 
elite*gold: 7110
Join Date: Jun 2009
Posts: 28,902
Received Thanks: 25,407
Dein Sleep wird nur ausgeführt, wenn F11 gedrückt wurde, andernfalls wird der if-Block übersprungen und die Schleife beginnt ohne Pause von vorne.
Das zieht CPU Leistung.
MrSm!th is offline  
Old 03/05/2014, 19:15   #5
 
blackout617's Avatar
 
elite*gold: 68
Join Date: Feb 2011
Posts: 401
Received Thanks: 96
mein processor ist single core [AMD Athlon XP 2400+ 2.00Ghz]
danke MrSm!th
danke ich habe jetzt meinen fehler gefunden ich habe
Bei void Loop()
Code:
while(1)
{
	if(GetKeyState(VK_F11) < 0)
		{
		MessageBoxA(0,"Well Done You Pressed F11\n Now You will get a Second MsgBox.","Done !",0);
		Messages();
			Sleep(1);
		}
}
gemacht aber eigentlich habe ich den sleep an der falsche stelle geschrieben
das richtige würde:

Code:
while(1)
{
	if(GetKeyState(VK_F11) < 0)
		{
		MessageBoxA(0,"Well Done You Pressed F11\n Now You will get a Second MsgBox.","Done !",0);
		Messages();
		}
	Sleep(1);
}
und jetzt ist mein code besser

Code:
void dwHoThread();
void Messages();


BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
    if (dwReason == DLL_PROCESS_ATTACH)
    {
        CreateThread(0, 0, (LPTHREAD_START_ROUTINE)dwHoThread, 0, 0, 0);
		MessageBoxA(0, "--> Injected", "Caption<--", MB_OK);
    }
    return TRUE;
}

void dwHoThread()
{
    while (1)
    {
        if (GetKeyState(VK_F11) < 0)
        {
		MessageBoxA(0,"Well Done You Pressed F11	\n Now You will get a Second MsgBox","Done !",0);
        Messages();
		}
        Sleep(1);
    }
}  

void Messages()
{
	MessageBoxA(0,"Message^^","Caption =)",0);
}
blackout617 is offline  
Reply




All times are GMT +1. The time now is 03:02.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.