NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: nobody on December 06, 2008, 04:14:23 PM
-
Hello...
I'm really stuck in what programming in asm reffers to... because I don't know what to get to keep learning...
apart from that
I just got into the idea of reading a string from a program and change it on the fly
e.g.:
I have this C code:
#include
int main()
{
int opt;
while (opt != 1)
{
printf("\nEnter the opt :) \n");
scanf("%i", &opt);
}
return 0;
}
And what I tried is, from debug.exe trying to modify the string "Enter the opt" for anything else... but I cannot even find where the exe stores in memory... hehehe ^^'
Anyway, I thought if it would be possible to do that with nasm, I mean, reading something from memory and change it on the fly.
May someone can tell me at which segment .exe's go or any tutorial about that topic.
Any information will be very apreciated.
S-029A
-
org 100h
; print the message
mov dx, msg
mov ah, 9
int 21h
; alter it
mov byte [msg], 'J'
; print altered message
mov dx, msg
mov ah, 9
int 21h
ret
msg db "Hello, World!", 13, 10, '$'
(untested) You mean like that???
Best,
Frank
-
My Harbison & Steele "C: A Reference Manual" (3rd Ed.) says this:
"ANSI C allows implementations to place string constants in regions of memory that are protected against modification." pg. 24
Could that be your problem?
Michael
-
First of all thanks for the time you took in answering my question...
Well, let's see if I can explain it much better...
I made the program in C which waits for the number 1 to be closed, right?
Well, what it does it's just to get into a loop by waiting untill 1 comes typed straight into the console.
It keeps showing a string that says "Enter the opt :)"
What I wanted to do is to find that string in memory at it's location, and with asm change it so it would be something like this:
Enter the opt :)
4
Enter the opt :)
353
Enter the opt :)
23
[at this point before pressing enter, I go to the location of memory where "Enter the opt :)" is stored and change it with asm]
Modified str opt :)
1
That's what I want to know, if that would be possible and may be how to... I'm getting a headache trying to learn nasm... there are no handy books =(
Thanks a lot again! =)