dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: Help me

  1. #1
    Join Date
    Aug 2018
    Posts
    8

    Thumbs up Help me

    Hello codeguru community .. I'm New here and i need your help specially in c++ programming .

    I just want to ask if someone can help me to filter !@#$%^&*() in dll and make some Logs.txt on it .Im going to use this DLL in Tantra Online Game [ MMPORG]

    Please Help me


    Thank you very much ! God Bless everyone !

  2. #2
    Join Date
    Aug 2018
    Posts
    8

    Re: Help me

    bump........

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,521

    Re: Help me

    Your question is very vague. Try asking a specific question about where you're stuck.

  4. #4
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,411

    Re: Help me

    Just because you haven't had a reply within 1 hour, it's no good trying to 'bump' the thread. This achieves nothing and probably will alienate those who may be able to help. Considering that people give of their time freely to help - and the different time zones across the world, it might be a couple of days before you receive a reply. Be patient.

    Re your post #1.

    This does not make any sense. Filter what, produce files of what? Where does Tantra come into this? You need to provide much, much more information about what you are trying to do so that we can provide guidance.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2017 (15.8.4)

  5. #5
    Join Date
    Aug 2018
    Posts
    8

    Re: Help me

    Quote Originally Posted by 2kaud View Post
    Just because you haven't had a reply within 1 hour, it's no good trying to 'bump' the thread. This achieves nothing and probably will alienate those who may be able to help. Considering that people give of their time freely to help - and the different time zones across the world, it might be a couple of days before you receive a reply. Be patient.

    Re your post #1.

    This does not make any sense. Filter what, produce files of what? Where does Tantra come into this? You need to provide much, much more information about what you are trying to do so that we can provide guidance.
    I'm sorry for what i've done , just want to know how should i filter some strings in exe using dll .
    Here's a sample code that friend send me .

    Code:
    struct MSG_STANDARD
    { 
    WORD wType; 
    WORD wSeq; 
    WORD wPDULength; 
    WORD wDummy; 
    DWORD dwClientTick;
    int nID;
    };
    
    Code:
    bool ValidString(char * cString){
    	string lFilter = "!@#$^&*()_+-=[]{}|;:,./<>?`~ ";
    	int iResult = 1;
    	int i, j;
    	bool Continue = false;
    	const char * cFilter = "!@#$^&*()_+-=[]{}|;:,./<>?`~ ";
    
    
    	string sString = string(cString);
    
    
    	if(sString.size() == 0)
    	{
    		return true;
    	}
    
    
    	for ( i = 0; i <= sString.size() - 1 && iResult == 1; i++)
    	{
    		if(cString[i] < 0)
    		{
    			return false;
    		}
    		else if(!isalnum(cString[i]))
    		{
    			Continue = true;
    			for( j = 0; j <= lFilter.size() - 1 && Continue == true; j++)
    			{
    				Continue = true;
    				iResult = 0;
    				if(cFilter[j] == cString[i])
    				{
    					iResult = 1;
    					Continue = false;
    					break;
    				}
    			}
    		}
    	}
    
    
    	if(iResult == 1)
    	{
    		return true;
    	}
    	else
    	{
    		return false;
    	}
    };
    
    
    bool ValidName(char * cName, int cSize)
    {
    	int cResult = 0;
    	for (int i = 0; i <= cSize - 1; i++)
    	{
    		if(cName[i] < 0)
    		{
    			return false;
    		}
    		else if(!isalnum(cName[i]))
    		{
    			return false;
    		}
    	}
    	return true;
    Last edited by VictorN; September 2nd, 2018 at 04:32 AM. Reason: Adding CODE tags

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,225

    Re: Help me

    1. Please, use CODE tags while posting code snippets!
    2. What does this code snippet have to do with the "exe using dll"?
    3. Your friend appears to be a beginner in C++ programming...

    BTW, did you test the code you have posted? Does it work as expected (how?)?
    Last edited by VictorN; September 2nd, 2018 at 04:45 AM.
    Victor Nijegorodov

  7. #7
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,411

    Re: Help me

    OK. Now we know what you are trying to accomplish...

    Looking at ValidName() first, using your algorithm this would be coded as

    Code:
    bool ValidName(char * cName, size_t cSize)
    {
    	for (size_t i = 0; i < cSize; ++i)
    		if (cName[i] < 0 || !isalnum(cName[i]))
    			return false;
    
    	return true;
    }
    However, passing the size of a c-string as an argument is not good practice - as a c-string is null value terminated. The better way for this function would be

    Code:
    bool ValidName(const char* cName)
    {
            if (cName)
    	    for (; *cName; ++cName)
    		if ((*cName < 0) || !isalnum(*cName))
    			return false;
    
    	return true;
    }
    However, the above codes are c-style code. For c++, you'd code something like

    Code:
    #include <algorithm>
    #include <string_view>
    
    //...
    
    bool ValidName(std::string_view cName)
    {
    	return std::all_of(cName.begin(), cName.end(), [](auto ch) {return std::isalnum(ch);});
    }
    For ValidString(), your algorithm becomes

    Code:
    bool ValidString(char * cString) {
    	const static std::string lFilter = "!@#$^&*()_+-=[]{}|;:,./<>?`~ ";
    	bool iResult = true;
    
    	if (cString)
    		for (; *cString && iResult; ++cString) {
    			if (*cString < 0)
    				return false;
    
    			if (!isalnum(*cString)) {
    				iResult = false;
    
    				for (size_t j = 0; j < lFilter.size() && !iResult; ++j)
    					if (lFilter[j] == *cString)
    						iResult = true;
    			}
    		}
    
    	return iResult;
    }
    But for c++, as a first step this could be coded as

    Code:
    bool ValidString(char * cString) {
    	const static std::string lFilter = "!@#$^&*()_+-=[]{}|;:,./<>?`~ ";
    	bool iResult = true;
    
    	if (cString)
    		for (; *cString && iResult; ++cString) {
    			if (*cString < 0)
    				return false;
    
    			if (!isalnum(*cString))
    				iResult = (lFilter.find(*cString) != std::string::npos);
    		}
    
    	return iResult;
    }
    But for really c++, consider

    Code:
    bool ValidString1(std::string_view cString) {
    	const static std::string lFilter = "!@#$^&*()_+-=[]{}|;:,./<>?`~ ";
    
    	for (const auto& ch : cString)
    		if ((ch < 0) || (!isalnum(ch) && (lFilter.find(ch) == std::string::npos)))
    			return false;
    
    	return true;
    }
    which I think does what the original code in post #5 does!
    Last edited by 2kaud; September 2nd, 2018 at 06:06 AM.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2017 (15.8.4)

  8. #8
    Join Date
    Aug 2018
    Posts
    8

    Re: Help me

    Quote Originally Posted by VictorN View Post
    1. Please, use CODE tags while posting code snippets!
    2. What does this code snippet have to do with the "exe using dll"?
    3. Your friend appears to be a beginner in C++ programming...

    BTW, did you test the code you have posted? Does it work as expected (how?)?
    hmm . No i did not test because i'm not good in c++ i don't even have a compiler or a software of this codes.

  9. #9
    Join Date
    Aug 2018
    Posts
    8

    Re: Help me

    Quote Originally Posted by 2kaud View Post
    OK. Now we know what you are trying to accomplish...

    Looking at ValidName() first, using your algorithm this would be coded as

    Code:
    bool ValidName(char * cName, size_t cSize)
    {
    	for (size_t i = 0; i < cSize; ++i)
    		if (cName[i] < 0 || !isalnum(cName[i]))
    			return false;
    
    	return true;
    }
    However, passing the size of a c-string as an argument is not good practice - as a c-string is null value terminated. The better way for this function would be

    Code:
    bool ValidName(const char* cName)
    {
            if (cName)
    	    for (; *cName; ++cName)
    		if ((*cName < 0) || !isalnum(*cName))
    			return false;
    
    	return true;
    }
    However, the above codes are c-style code. For c++, you'd code something like

    Code:
    #include <algorithm>
    #include <string_view>
    
    //...
    
    bool ValidName(std::string_view cName)
    {
    	return std::all_of(cName.begin(), cName.end(), [](auto ch) {return std::isalnum(ch);});
    }
    For ValidString(), your algorithm becomes

    Code:
    bool ValidString(char * cString) {
    	const static std::string lFilter = "!@#$^&*()_+-=[]{}|;:,./<>?`~ ";
    	bool iResult = true;
    
    	if (cString)
    		for (; *cString && iResult; ++cString) {
    			if (*cString < 0)
    				return false;
    
    			if (!isalnum(*cString)) {
    				iResult = false;
    
    				for (size_t j = 0; j < lFilter.size() && !iResult; ++j)
    					if (lFilter[j] == *cString)
    						iResult = true;
    			}
    		}
    
    	return iResult;
    }
    But for c++, as a first step this could be coded as

    Code:
    bool ValidString(char * cString) {
    	const static std::string lFilter = "!@#$^&*()_+-=[]{}|;:,./<>?`~ ";
    	bool iResult = true;
    
    	if (cString)
    		for (; *cString && iResult; ++cString) {
    			if (*cString < 0)
    				return false;
    
    			if (!isalnum(*cString))
    				iResult = (lFilter.find(*cString) != std::string::npos);
    		}
    
    	return iResult;
    }
    But for really c++, consider

    Code:
    bool ValidString1(std::string_view cString) {
    	const static std::string lFilter = "!@#$^&*()_+-=[]{}|;:,./<>?`~ ";
    
    	for (const auto& ch : cString)
    		if ((ch < 0) || (!isalnum(ch) && (lFilter.find(ch) == std::string::npos)))
    			return false;
    
    	return true;
    }
    which I think does what the original code in post #5 does!
    Can you help me to compile this code?

  10. #10
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,411

    Re: Help me

    i'm not good in c++ i don't even have a compiler
    As this question is asked in the Visual c++ Programming forum, I assumed you were using Microsoft VS (Latest version is VS2017).

    To download/install MS VS2017 Community edition, go to https://visualstudio.microsoft.com/downloads/
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2017 (15.8.4)

  11. #11
    Join Date
    Aug 2018
    Posts
    8

    Re: Help me

    Quote Originally Posted by 2kaud View Post
    As this question is asked in the Visual c++ Programming forum, I assumed you were using Microsoft VS (Latest version is VS2017).

    To download/install MS VS2017 Community edition, go to https://visualstudio.microsoft.com/downloads/
    Thank you sir

  12. #12
    Join Date
    Aug 2018
    Posts
    8

    Re: Help me

    Quote Originally Posted by 2kaud View Post
    As this question is asked in the Visual c++ Programming forum, I assumed you were using Microsoft VS (Latest version is VS2017).

    To download/install MS VS2017 Community edition, go to https://visualstudio.microsoft.com/downloads/
    Can you help me to compile those codes sir ? pls?

  13. #13
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,411

    Re: Help me

    Quote Originally Posted by newbiedev View Post
    Can you help me to compile those codes sir ? pls?
    To compile these codes, you need a c++ compiler. What compiler are you using? Note that the code in the posts #5 and #7 are not full programs - just functions. So just compiling them by themselves will generate errors. These functions need to be incorporated into whatever program (for an .exe or .dll target) you're writing.

    i'm not good in c++ i don't even have a compiler or a software of this codes
    Have you ever written, compiled and run a c++ program?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2017 (15.8.4)

  14. #14
    Join Date
    Aug 2018
    Posts
    8

    Re: Help me

    Quote Originally Posted by 2kaud View Post
    To compile these codes, you need a c++ compiler. What compiler are you using? Note that the code in the posts #5 and #7 are not full programs - just functions. So just compiling them by themselves will generate errors. These functions need to be incorporated into whatever program (for an .exe or .dll target) you're writing.



    Have you ever written, compiled and run a c++ program?
    No this is my first time to use this kind of language .So probably i dont know some basic things to use this programming language ..My i know if this function can really filter packets?

    And this function or program is incorporated in dll target because i will hook this one into exe itself .

  15. #15
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,115

    Re: Help me

    If this is the first time you use C++, then I recommend you to start with the basics first.
    Have a look at the books listed here: http://forums.codeguru.com/showthrea...-books-about-C
    That should get you started.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)