Hello, I've been working on a security based software from which I got the idea from another program. Here are the details:

Upon load of the software a 4 digit string is given (I.E: 1kfh). Then you're prompt for a password. To find your password you would use a Memory Editor (TSearch, Artmoney, etc) and search the 3 digits given to you. Out of all the thousands results given, you are to find your password. (obviously, very hard which is the point).

This is where I'm at in my program to do the same thing:
I give user a random string (they see 6 characters; the full string contains 12). They have to search the 6 characters using a ME. The correct password will be the remaining 6 characters will they will locate.

This is my problem:
When my code searches for the remaining code it comes back in UNICODE. I convert to text using wchar_t MyString = _T. After doing so, it still does not work. I think the search part is wrong, or I'm just REALLY bad at converting lol (which I sure I am).

My Question:
I'm familiar with ArtMoney so I don't know if other memory editors are the same. I'll set up an example to make the question make some sense (otherwise everything is very confusing).

Fun.exe gives me a random 3 characters out of 12. (Lets say it gives me, "The")
Full random string = TheFunString. (I dont know this)
Manualy, I search Fun.exe using ArtMoney, "The", there are 7 accurances. I locate the correct one and find the remaning 9 characters.
I enter the remaining characters in the Password box.

How can I search the full string in the program to to compare userinput with the correct value?

Hope this makes sense.. Thanks for any help IA.

Dani AI

Generated

Useful follow-up and practical checklist tying the thread together.

and were correct: comparing pointers (what == does for raw char*) will not compare string contents, and that class of bug is subtle because it compiles. ’s later discovery (dialog data never transferred) is also a common one in MFC — stale control variables will make every comparison fail even when the comparison logic is fine.

Recommended, reliable pattern for an MFC dialog:

  • Ensure control variables are updated from controls before any comparison (call UpdateData(TRUE) at the point of read).
  • Keep the data in CString while possible. CString comparisons compare contents when both operands are CString, so avoid casting LPCTSTR to char* in a UNICODE build.
  • Use CString helpers to extract the fragment to compare (Left/Mid/Right) rather than manually truncating buffers.

Example (Unicode-aware, avoids raw pointer casts):

UpdateData(TRUE);

CString expected = PreSerial.Left(6);   // get the six chars to compare
CString entered  = m_Password;

if (expected == entered) {
    m_Warning.SetWindowText(_T("Correct"));
} else {
    m_Warning.SetWindowText(expected);
}

If conversion to narrow (ANSI) bytes is needed (for a third‑party tool, file format, or legacy code), convert explicitly instead of casting. Use ATL conversion helpers or Win32 conversion APIs so the code is correct under both ANSI and UNICODE builds:

CT2A conv(PreSerial);            // wide -> ANSI
std::string expectedAscii(conv);

Quick debugging checklist if comparisons still fail:

  • Print both strings and their lengths (in characters and bytes) to confirm encoding and trailing/embedded nulls.
  • Confirm which build (UNICODE vs ANSI) and treat LPCTSTR accordingly.
  • Avoid modifying CString internal buffers directly; use CString methods.
  • When comparing C-style strings, use strcmp/strncmp only after a safe, explicit conversion.

These steps prevent the three root causes seen in the thread: pointer-vs-content comparison, encoding mismatch, and stale dialog data.

Recommended Answers

All 4 Replies

Sorry for double post, but I could not find the edit button. Anyways, I fixed the search so I do not need help with the question above anymore. I do have a new question which has come up.

char * Serial = (char*)(LPCTSTR)PreSerial;
		if (strlen(Serial) > 5) Serial[5] = 0;
//		PreSerial = (CString)Serial;
		char * Input = (char*)(LPCTSTR)m_Password;
		if (Serial == Input) m_Warning.SetWindowText("Correct");
		else m_Warning.SetWindowText(PreSerial);
	}

Some reason whether I compare CString or Char* it always returns to the else statement. My question is, how do I compare the strings so the IF Else statement will work properly.

Other ways I have tried:

if (m_Password.Compare(PreSerial) == 0) //correct
else // invalid

Again it would always return invalid.

I have also tried char * MyVar = (char*)MyCstring.GetString() but that is the same as LPCTSTR.

You defined Input and Serial as char *. You need to you strcmp to compare.

Hey, I figured out the problem. I forgot to add:

UpdateData();
		CString Password = int pID;
		UpdateData(FALSE);

Your post helped me with another problem I was having though. Thanks for the help.

You defined Input and Serial as char *. You need to you strcmp to compare.

Don't ignore this advice. The sytax bugs are easy to fix as they usually stop it compiling. The Symantic bugs like this (you are comparing if two memory addresses are equal rather than if the strings are the same!) are a lot harder to catch. The program will compile but it will do strange things.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.