Posted by Ignatz on 1/29/2000, 9:41 pm
, in reply to "Task4.2"
195.34.133.61
hi
i already read all solutions and am deeply impressed about how
easy and small they are. but i had to work out the initial idea i had in mind.
i wanted to find a free place in the program where i could put a copy routine for the serial. the only things to do is
A) find a place where you can jump to that routine
B) put the copy routine there
C) take care of what was damaged by the jumpi found the unused place for my routine starting at 83559
notes: you can save mch time if you push all the registers you use. this fault took me about 30 min to find out.
I am sure there are smaller solutions even for this approach
but take a look at it- here is the hex code for this thing.i sacrificed these 4 bytes for the jump to 83559(offs)
:00446BB7 8BE5 mov esp, ebp
:00446BB9 5D pop ebp
:00446BBA C3 retso this now looks like this
:00446BB7 E9now the routine
first save the regs
:00483F59 56 push esi ;
:00483F5A 57 push edi ; both used for movsb
:00483F5B 51 push ecx ; used as counter for movsb
:00483F5C BEE4F57300 mov esi, 73F5E4; ser addr to source
:00483F61 BE57A14900 mov edi, 049A157 ; msg-text to dest.
:00483F66 33C9 xor ecx, ecx
:00483F68 83C10B add ecx, 0B ; 11- the max number
of chars in the serial.
:00483F6B F3A4 repz movsb ; copy it (1)
:00483F6D 59 pop ecx ;
:00483F6E 5F pop edi ;
:00483F6F 5E pop esi ; restore valuesdon´t forget the 4 bytes used for the jump
:00483F70 8BE5 mov esp, ebp
:00483F72 5D pop ebp
:00493F73 C3 ret
i hope you like it.
(1) the MOVS command (from Intel Opcodes and Mnemonics)
MOVS - Move String (Byte or Word)
Usage: MOVS dest,src
MOVSB
MOVSW
MOVSD (386+)
Modifies flags: None
Copies data from addressed by DS:SI (even if operands are given) to the location ES:DI destination and updates SI and DI based on the size of the operand or instruction used. SI and DI are incremented when the Direction Flag is cleared and decremented when the Direction Flag is Set. Use with REP prefixes.
so just set esi to the place of the serial and edi to the place of text we want to replace.
the movsb is repeated as many times as ecx says. since the serial can be maximum 11 chars (AC200-XXXXX) we just have to put 11 to ecx. if the serial is smaller it doesn´t matter since the serial is ended with a '\0'. this terminates the string.so thats all folks
if you have any comments or questions tell me.
sunshine
-Ignatz