If you had text in a DWORD how what sintex would i use to be able to have that value converted to 0 teminated so that you can write it to disk or whatever. I usually SendMessage to an edit or static box but i want to skip doing it this way.
The things i been trying only get me a black square and a letter in MyTest.txt Any clues will help...
MyTestInfo DD ? .........is not getting me anywhere...
MyTestInfo DD 25 dup (0) ...Something like this give same results as above.
MyTestInfo db 25 dup (?) ... sometimes to small or to big if so it don't show right
I forgot to add...it will read in a message box correctly so the text is there....
Happy Holidays Where ever you are
The things i been trying only get me a black square and a letter in MyTest.txt Any clues will help...
MyTestInfo DD ? .........is not getting me anywhere...
MyTestInfo DD 25 dup (0) ...Something like this give same results as above.
MyTestInfo db 25 dup (?) ... sometimes to small or to big if so it don't show right
I forgot to add...it will read in a message box correctly so the text is there....
Happy Holidays Where ever you are
listen cmax, if you would like to use strings, then please use Bytes and not DWORDs. That means, that you have to declare your string like this:
.data
mystring DB "My String",0
or
.data?
myemptystring DB 10 DUP(0)
Then you can simply write it to disk, cause it's NULL-Terminated. If you use DWORDs for string, it is obvious that there will be just one letter finally, in your file. because: if you declare your string like that:
.data
mystring DD "Hello",0
then it actually looks like this:
H,0,0,0,e,0,0,0,l,0,0,0,l,0,0,0,o,0,0,0,0,0,0,0
because a DWORD consists of 4 Bytes. If you try to write that string to file now, the API which writes that string to the file, finds the first zero after the first character, so that it thinks, that the whole string consists just of the "H". And this is because the API works in BYTES. If the API would work in DWORDs (waht is very unefficient), it would always take the fourth character, got it?
hope that helps.
nop
.data
mystring DB "My String",0
or
.data?
myemptystring DB 10 DUP(0)
Then you can simply write it to disk, cause it's NULL-Terminated. If you use DWORDs for string, it is obvious that there will be just one letter finally, in your file. because: if you declare your string like that:
.data
mystring DD "Hello",0
then it actually looks like this:
H,0,0,0,e,0,0,0,l,0,0,0,l,0,0,0,o,0,0,0,0,0,0,0
because a DWORD consists of 4 Bytes. If you try to write that string to file now, the API which writes that string to the file, finds the first zero after the first character, so that it thinks, that the whole string consists just of the "H". And this is because the API works in BYTES. If the API would work in DWORDs (waht is very unefficient), it would always take the fourth character, got it?
hope that helps.
nop
cmax,
MyTestInfo db 25 dup (?)
That should work perfectly. Put it in .data? section and if you would like to make the buffer bigger put a bigger value after db, like 256.
MyTestInfo db 25 dup (?)
That should work perfectly. Put it in .data? section and if you would like to make the buffer bigger put a bigger value after db, like 256.
Here's an better idea of what im trying to do....
......................................................................................................
.data
GatherText db 128 This line can be dd or db and it will still work
.data?
MyText dd ? This has to be declared this way... no db will work for me anywhere
......................................................................................................
Bla...Bla...Bla
invoke LocalAlloc, GMEM_FIXED, GatherText
mov MyText, eax
Bla...Bla...Bla
WriteFile ( directly to disk... no program edit or static box )
I can do write file but i can get the data out of either d's
......................................................................................................
.data
GatherText db 128 This line can be dd or db and it will still work
.data?
MyText dd ? This has to be declared this way... no db will work for me anywhere
......................................................................................................
Bla...Bla...Bla
invoke LocalAlloc, GMEM_FIXED, GatherText
mov MyText, eax
Bla...Bla...Bla
WriteFile ( directly to disk... no program edit or static box )
I can do write file but i can get the data out of either d's
invoke LocalAlloc, GMEM_FIXED, GatherText
mov MyText, eax
MyText is a pointer to an address so it will point to the first letter of your string wich should allready be null terminated if you wanted to write it to file you would just specify the lenghth, you probably don't want to write the NUll terminator to a file
invoke WriteFile, hFile, MyText, Lenghth, addr dwBytes, NULL
Length would be a dword containing the actualy length of your string.
I hope I have understood what you are trying to do correctly
H,0,0,0,e,0,0,0,l,0,0,0,l,0,0,0,o,0,0,0, 0,0,0, (0)
"And this is because the API works in BYTES."
First I want to say Thanks to NOP-erator, for showing me what DWORD is really all about. Instead of giving up and taking another routh I played with it and seen many strange things that Windows cause that processor to produce. Very Interesting.... I Should have learned about this in the first place.
________________________________________________________________________________________________________
"Put it in .data? section and if you would like to make the buffer
bigger put a bigger value after db, like 256."
Hey CodeLover,,, what happen is when i put it in .data section i get invalid instruction operants.... #A2070
I played with this so much that now i really see where stuff should go. With ASM i was like a guy who could strip a car apart and put it back together without knowing an single definition of parts other that the carburetor name.
Thanks CodeLove... your reply sent me exploring even deeper.
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
Bla...Bla...Bla
invoke LocalAlloc, GMEM_FIXED, GatherText
mov MyText, eax
Bla...Bla...Bla
mov Lenghth,eax ;@@@@@@@@@@@@@@@@@@ Quantum
invoke WriteFile, hFile, MyText, Lenghth, addr dwBytes, NULL
Quantum, What i did was to..... mov Lenghth,eax
so I guest after MyText run through my little proc than all is now in Lenghth
Now I write it....I WORKS More than BIG TIME
I GET EVERY WORD OF Mytext but at the end of the line and there after it add on a MegaByte worth of Little Squares or more....( Maybe junk added on because of my procedure )
BUT....Hey, Hey, Hey [ AT LEASE THE TEXT IS WRITTEN TO THE FILE ]
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1.
What am I missing to make it cut off all those useless squares.
2. My last character is :
The last character that is in All of MyText style files is :
I figure that all i have to do is, in memory, is to select all of MyText to the last character :
(since everything else is only Squares) dump the rest before writing to file.
This is the only code i know about when it come to manipulating strings, but this don't work here.
I don't know how to set it up for this type problem.
____________________________________________________________________________________________________________________________________________________________
it don't work here
lea ecx,
sub eax, 92 ; ;;;;; but this may limit me because the file might have more or less character in it
cld
lea edi, MyText
mov eax,":"
mov ecx,Lenghth
repne scasb
cmp ecx,0
________________________________________________________________________________________________________
Do anyone have any ideas....
And Thank very much Quantum.... THAT WAS A HECK OF A IDEA WITH SO LITTLE INFO TO WORK WITH.....
It's Fantactic. I have one special proc and to be able to do it all in memory would solve nearly all of my problems.
"And this is because the API works in BYTES."
First I want to say Thanks to NOP-erator, for showing me what DWORD is really all about. Instead of giving up and taking another routh I played with it and seen many strange things that Windows cause that processor to produce. Very Interesting.... I Should have learned about this in the first place.
________________________________________________________________________________________________________
"Put it in .data? section and if you would like to make the buffer
bigger put a bigger value after db, like 256."
Hey CodeLover,,, what happen is when i put it in .data section i get invalid instruction operants.... #A2070
I played with this so much that now i really see where stuff should go. With ASM i was like a guy who could strip a car apart and put it back together without knowing an single definition of parts other that the carburetor name.
Thanks CodeLove... your reply sent me exploring even deeper.
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
Bla...Bla...Bla
invoke LocalAlloc, GMEM_FIXED, GatherText
mov MyText, eax
Bla...Bla...Bla
mov Lenghth,eax ;@@@@@@@@@@@@@@@@@@ Quantum
invoke WriteFile, hFile, MyText, Lenghth, addr dwBytes, NULL
Quantum, What i did was to..... mov Lenghth,eax
so I guest after MyText run through my little proc than all is now in Lenghth
Now I write it....I WORKS More than BIG TIME
I GET EVERY WORD OF Mytext but at the end of the line and there after it add on a MegaByte worth of Little Squares or more....( Maybe junk added on because of my procedure )
BUT....Hey, Hey, Hey [ AT LEASE THE TEXT IS WRITTEN TO THE FILE ]
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1.
What am I missing to make it cut off all those useless squares.
2. My last character is :
The last character that is in All of MyText style files is :
I figure that all i have to do is, in memory, is to select all of MyText to the last character :
(since everything else is only Squares) dump the rest before writing to file.
This is the only code i know about when it come to manipulating strings, but this don't work here.
I don't know how to set it up for this type problem.
____________________________________________________________________________________________________________________________________________________________
it don't work here
lea ecx,
sub eax, 92 ; ;;;;; but this may limit me because the file might have more or less character in it
cld
lea edi, MyText
mov eax,":"
mov ecx,Lenghth
repne scasb
cmp ecx,0
________________________________________________________________________________________________________
Do anyone have any ideas....
And Thank very much Quantum.... THAT WAS A HECK OF A IDEA WITH SO LITTLE INFO TO WORK WITH.....
It's Fantactic. I have one special proc and to be able to do it all in memory would solve nearly all of my problems.
There is a function called StrLen wich is in masm32.inc and masm32.lib this function gives you the actual legth of the string so you could use that and then use the value it gives you in WriteFile that will get rid of the squares wich are caused by writing the extra zeros to the file
I been working with it all night and all day to the point to where i was doing the same thing over and over again afraid that i miss something...I was on the vergue of giving up. It wore me out. I'll try it and let you know what happen.
Thanks again Quantum
Thanks again Quantum
StrLen
It's Working
I cut whole thing out and put it under the lenghth. Changed Item to the word lenghth than I just had to change the number of byte needed to be skip to 92 and WOLA.
But that force me to keep one size....No probem... I'll just change MyMultiFile format to meet it, but i think i just have to work with it a little bit and make it work all the way....Or i just use it the right way and call the Procudure. Now that i see the light there enough stuff in M32Lib to rig something up.... I can now read thing a little better.
I will not forget where all of this came from....
See Ya
Here a pome i wrote while thinking about DWORDS and Win32 ASM Programmers post-er....Don't laugh please...I'll edit it latter
____________________________________________
There Nothing like hearing the roaring Wind Blow while trying to understand the Thundering Whispers.
Great ideas are not all the same even tho they may generate the same results.
There is no place to run once you find that ultimate position... The only thing you can do for that day on end is to Deal With T..Hat :-)
My 2DWORD
cmax
It's Working
I cut whole thing out and put it under the lenghth. Changed Item to the word lenghth than I just had to change the number of byte needed to be skip to 92 and WOLA.
But that force me to keep one size....No probem... I'll just change MyMultiFile format to meet it, but i think i just have to work with it a little bit and make it work all the way....Or i just use it the right way and call the Procudure. Now that i see the light there enough stuff in M32Lib to rig something up.... I can now read thing a little better.
I will not forget where all of this came from....
See Ya
Here a pome i wrote while thinking about DWORDS and Win32 ASM Programmers post-er....Don't laugh please...I'll edit it latter
____________________________________________
There Nothing like hearing the roaring Wind Blow while trying to understand the Thundering Whispers.
Great ideas are not all the same even tho they may generate the same results.
There is no place to run once you find that ultimate position... The only thing you can do for that day on end is to Deal With T..Hat :-)
My 2DWORD
cmax
cmax,
Your original question about how or where to use a DWORD shows that you don't fully understand how text data is stored. Lets try a few basics, in most instances text data is stored as a sequence of BYTEs. On x86 machines a BYTE sequence will start at an address and continue in sequence until you reach the end of a buffer that you have allocated in your program.
It can be allocated in the .DATA section,
MyText db "This is my text",0
Note that this line is terminated by zero.
You can also allocate a buffer dynamically with various memory functions and read text data from disk into that buffer. Also you can allocate small amounts of memory on the stack within a procedure by using the LOCAL directive. You basically select what best suites what you are doing.
The DATA sizes WORD and DWORD can store text data but they are not well suited for it.
DWORD is 4 BYTEs long and can store 4 characters but it will be written in reverse order to how you write it.
mov eax, "1234"
will be written to memory as "4321". It is because numeric data is written in the reverse order on x86 hardware while text data is written in ascending address order, (normal left to right).
Regards,
hutch@movsd.com
Your original question about how or where to use a DWORD shows that you don't fully understand how text data is stored. Lets try a few basics, in most instances text data is stored as a sequence of BYTEs. On x86 machines a BYTE sequence will start at an address and continue in sequence until you reach the end of a buffer that you have allocated in your program.
It can be allocated in the .DATA section,
MyText db "This is my text",0
Note that this line is terminated by zero.
You can also allocate a buffer dynamically with various memory functions and read text data from disk into that buffer. Also you can allocate small amounts of memory on the stack within a procedure by using the LOCAL directive. You basically select what best suites what you are doing.
The DATA sizes WORD and DWORD can store text data but they are not well suited for it.
DWORD is 4 BYTEs long and can store 4 characters but it will be written in reverse order to how you write it.
mov eax, "1234"
will be written to memory as "4321". It is because numeric data is written in the reverse order on x86 hardware while text data is written in ascending address order, (normal left to right).
Regards,
hutch@movsd.com
Hey Thanks everybody
Since all of this lead me to strings I put up a new post to keep confusion down .... Strings Unknown Size
I think bitRAKE put the icing on the cake.
Check it out
Yes, it all make a LOT of since NOP-erator, it just takes me longer. I guest we all got to go back to the bottom of it all sometimes just to make sure you did not miss anything and it's nothing like hearing it from someone first hand from (to me the experts) . After reading diffference stuff about stuff all over ther land from one Lang to the next guys like me never really know.... We got to be told...
Thanks Guy
My mind have been blown again
cmax over and out
Since all of this lead me to strings I put up a new post to keep confusion down .... Strings Unknown Size
I think bitRAKE put the icing on the cake.
Check it out
Yes, it all make a LOT of since NOP-erator, it just takes me longer. I guest we all got to go back to the bottom of it all sometimes just to make sure you did not miss anything and it's nothing like hearing it from someone first hand from (to me the experts) . After reading diffference stuff about stuff all over ther land from one Lang to the next guys like me never really know.... We got to be told...
Thanks Guy
My mind have been blown again
cmax over and out
I live in the USA.
Peope in this county don't have an real langauge. But we call it English. I heard that the people in England say American don't speak English they speak American.
.................................................................................................
""After reading diffference stuff about stuff all over ther land from
one Lang to the next guys like me never really know.... ""
i was talking about reading reviews and books back in the day when i was trying to pick the best programming lag to start learning and other stuff...Eveybody claim they were the best and voiced sometime false opions of why....Glad i don't have to worry about that anymore.
Peope in this county don't have an real langauge. But we call it English. I heard that the people in England say American don't speak English they speak American.
.................................................................................................
""After reading diffference stuff about stuff all over ther land from
one Lang to the next guys like me never really know.... ""
i was talking about reading reviews and books back in the day when i was trying to pick the best programming lag to start learning and other stuff...Eveybody claim they were the best and voiced sometime false opions of why....Glad i don't have to worry about that anymore.
I've always liked the east coast - people in the west are so disconnected and transient with their values. People in the east are rooted and this seems more secure to me, but I was quite younger when last I was there. My girlfriend is from NJ.
I too shopped around for a language. IMHO, the important thing is to practice playing with the mental pieces that make up the language to accomplish your goal. It's like building anything: you think of what you want and what you have to build it out of. It seems very hard when what you have looks nothing like what you want, but slowly it takes form. We increase the tools at our disposal and hence the dynamics of what we are capable of.
I too shopped around for a language. IMHO, the important thing is to practice playing with the mental pieces that make up the language to accomplish your goal. It's like building anything: you think of what you want and what you have to build it out of. It seems very hard when what you have looks nothing like what you want, but slowly it takes form. We increase the tools at our disposal and hence the dynamics of what we are capable of.
Winston Churchill describing the relationship
between the U.K. and U.S.:
Two people separated by a common language.
between the U.K. and U.S.:
Two people separated by a common language.