Tuts 4 You

# [c++]Problem with convert EAX

## Recommended Posts

Hi all!

I try to do the keygen: "2. Keygenning tut KeyGenMe_#1_cLoNeTrOnE TeAm FOFF"

https://forum.tuts4you.com/topic/36362-all-my-keygenning-tuts/?hl=%2Bkeygening+%2Btut

There was a moment which register EAX equal to : 00000275 (in my case).[its just take the string "baruch" and conclude every char]

And then was check : if(EAX == 00000275).

Now in my C++ program ,i have integer called "sum" which equal to 275.

The question is how i convert that number? I mean ,i need 00000275 not 275,so

how i convert from "integer look" to "register look"?

of course i can do very long way :

1.check the length of sum==3

2.do loop from 0 to 5 and fill with zero(char[] or char*)

3.do one more loop from 0 to 3 and fill with : 2,7,5.

It looks to me there is a "easy" way to do it and not so long...

i sorry for my english:(

If I understand your question right, you need to use printf with proper format string: http://stackoverflow.com/questions/14733761/printf-formatting-for-hex or http://www.codingunit.com/printf-format-specifiers-format-conversions-and-formatted-output

EDIT: auto-formatting broke URLs

Edited by kao (see edit history)

Mmm...no guys,its not what i meant to.

I use c++ not c,so printf not realy helpul.

I will try to explain myself better:

In that keygen for the string "baruch" the serial is

"GA-00000275-".

I did array of chars lets call him "pass",now im in state :

pass[0]=G,pass[1]=A,pass[2]='-'

I have integer "sum" which equal to 275.

Now i search an algorithm which will take the 275 which stored in "sum" and paste him in "pass" so after the algorithm "pass" will look like this: "GA-00000275".

if you have that problem,which commands in c++ you will use?what is your algorithm to do that??

i said before how i did it,but it looks to me too long and complex for so simple task...

int EAX = 275;

std::string CppString;

char Dest[30];

sprintf(Dest, "GA-00000%d", EAX);

CppString = Dest;

cout << CppString << "\r\n";

OK i guess this is more cpp but I prefer above way

std::string itoa(int Integer)

{

stringstream ss;

ss << Integer;

return ss.str();

}

std::string Prefix = "-GA-00000";

int Sum = 275;

std::string Final = Prefix + itoa(Sum);

cout << Final << "\r\n";

Edited by simple (see edit history)

But....

Its a keygen,if you enter another name the serial may look "00123456"....

So i realy sorry i spent your time,im not good in explanation in english....

So thank you guys for trying to help me ;(

sprintf(Dest, "GA-%08d", EAX);

• 1

the sum 0x275 or 00000275 comes from the name chars added together. b+a+r+u+c+h = 0x275.

by using sprintf(serial, "GA-%08x-", EAX); the output you are looking for is in the variable "serial".

• 1