Conversion Problems

Posts 1–15 of 20 · Page 1 of 2
Conversion Problems
Code:
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) 
			{
				NOPAddy = Convert::ToInt32(this->textBox2->Text);
				WriteProcessMemory(target,(LPVOID)NOPAddy,(LPVOID)0x90,1,NULL);
			}
private: System::Void Window_Load(System::Object^  sender, System::EventArgs^  e) 
			{
				target = GetCurrentProcess();
			}
private: System::Void checkBox1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
			{
				FreezeAddy = Convert::ToInt32(this->textBox1->Text);
				FreezeValue = Convert::ToInt32(this->textBox3->Text);
				FreezeValueSize = sizeof(FreezeValue);
				while(this->checkBox1->Checked)
				{
					WriteProcessMemory(target,(LPVOID)FreezeAddy,&FreezeValue,FreezeValueSize,NULL);
				}
			}
Basically when they press the checkbox, it gets the info entered in the first textbox and saves it as a DWORD for the address. Then it gets what is in textbox two and it saves it as a INT for the value. When I press the checkbox to freeze the value in the address, the program crashes. Is my conversion wrong? I think that is the problem.

Also I have the same issue when trying to NOP the address as well...
I believe its when you input the address its in hexadecimal but when you use Convert::ToInt32 it is trying to convert to decimal and Im assumnig this is why its crashing.
You can use sscanf to solve this.

Code:
 sscanf(this->textBox1->Text,"%X",&FreezeAddy);
FreezeValue = Convert::ToInt32(this->textBox3->Text);
FreezeValueSize = sizeof(FreezeValue);
while(this->checkBox1->Checked) writeProcessMemory(target,(LPVOID)FreezeAddy,&FreezeValue,FreezeValueSize,NULL);
				}
So do I input it like this:
0x123456

or this

123456
Both can work.

0xABC -> ABC
ABC -> ABC
Just type it with upper case characters. Like:
15AF8 not 15af8. Cause %X is for hex values with upper case characters.
error C2664: 'sscanf' : cannot convert parameter 1 from 'System::String ^' to 'const char *'
Quote Originally Posted by aanthonyz View Post
error C2664: 'sscanf' : cannot convert parameter 1 from 'System::String ^' to 'const char *'
I've never worked on C++ CLR, but have you tried to do:
(char*)textbox1->text ???
char* str2 = (char*)(void*)Marshal::StringToHGlobalAnsi(str);
to convert then use str2 for sscanf
This is what I have done so far:

Code:
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) 
			{
				char* str2 = (char*)(void*)Marshal::StringToHGlobalAnsi(this->textBox2->Text);
				//IntPtr p = Marshal::StringToHGlobalAnsi(this->textBox2->Text);
				//char *pNewCharStr = static_cast<char*>(p.ToPointer());
				sscanf_s(str2,"%X",&NOPAddy);
				//NOPAddy = Convert::ToInt32(this->textBox2->Text);
				WriteProcessMemory(target,(LPVOID)NOPAddy,(LPVOID)0x90,1,NULL);
			}
private: System::Void Window_Load(System::Object^  sender, System::EventArgs^  e) 
			{
				target = GetCurrentProcess();
			}
private: System::Void checkBox1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
			{
				char* str2 = (char*)(void*)Marshal::StringToHGlobalAnsi(this->textBox1->Text);
				//IntPtr p = Marshal::StringToHGlobalAnsi(this->textBox1->Text);
				//char *pNewCharStr = static_cast<char*>(p.ToPointer());
				sscanf_s(str2,"%X",&FreezeAddy);
				//FreezeAddy = Convert::ToInt32(this->textBox1->Text);
				FreezeValue = Convert::ToInt32(this->textBox3->Text);
				FreezeValueSize = sizeof(FreezeValue);
				while(this->checkBox1->Checked)
				{
					WriteProcessMemory(target,(LPVOID)FreezeAddy,&FreezeValue,FreezeValueSize,NULL);
					if(GetAsyncKeyState(VK_INSERT))
					{
						break;
					}
				}
			}
private: System

It compiles without error but when I try to freeze and address for example the minesweeper timer, it resets the timer to 0 and keeps it at zero even though I put 5 as a value and the program freezes as well.

I havent tried NOP yet
try this

#include <msclr/marshal.h>

msclr::interop::marshal_context mCxt;
sscanf(mCxt.marshal_as<char const*>(this->textBox1->Text),Blah);


Edit: you fix it i see
Yeah, now my only problem is actually using it.

EDIT:Stupid mistake on my end...the FreezeValue was set to double instead of int. So now my program along with minesweeper doesnt freeze at 0, it freezes at the value you put it but I cant unfreeze it because my DLL freezes along with it.

I am supplying the source code, because it would just be so messy posting windows forms code.
are you editing your own application?


target = GetCurrentProcess();
Even though this has Windows Forms its a DLL.
I use GetCurrentProcess, so that no matter what program I inject the DLL into, I can freeze and NOP addresses inside it.
Instead of making a while loop in that function just create a new thread to freeze it.

Code:
DWORD FreezeValue=0;
DWORD FreezeAddy  0xDEADBEEF


void freezeThread(){

   while(1){
       if(checkbox)WriteProcessMemory(target,(LPVOID)FreezeAddy,&FreezeValue,FreezeValueSize,NULL);

}

}

blahlbbalh 

void yourCheckboxfunc(){
    freezeValue = w/e
    freezeAdddy = w/e
}

Somewhere just call CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)freezeThread, NULL, NULL, NULL);
@aanthonyz
Virus-scans and screenshots are a requirement for approval
Posts 1–15 of 20 · Page 1 of 2

Post a Reply

Tags for this Thread

None

Talk with us