I have a major problem and this may be something that all of us may have not notice.
I think Hutch or f0dder has the answer to this or another serious Assembler Coder.
See Code Below:
There is 6 presumable Private Buffers.
There are 6 indiviualzed line text for each Buffer
If we use length of you will see that line ONLY in each buffers if you use MessageBox.
All is WELL is what we all BELIEVE...
Now lets Write that TEXT that is suppose to be in BUFFER1.
Now why in heck is it showing all of the text in the other 5 Buffers...
What I see is that length of is only a trick to point to what is suppose to be in the buffer but in reality you got All of this TEXT over and Over Again in Each Buffer... This has lead me to believe that MASM is only giving me one buffer and is dividing my shit up in it...while fooling me all the time....A bit extragate but heck I don't know what to think...
Now what is this All About.....Am I'm missing Something.....Is it true that each buffer should HOLD it own CONTEXT TOTALLY PRIVATELY.....Please Help.....
MY ONLY GOAL IS TO SEE TO IT THAT WHEN A BUFFER IS USED THAT NOTHING ELSE HAS NOTHING TO DO WITH IT what so ever
AS IT SHOULD BE OR AS MY PROJECT REQUIRE.
For the last time I ask you to please review this carefully...
PLEASE COPY THE FOLLOWING AND COMPLY IT TO GET AN TOTALLY UNDERSTANDING....
I thought i was in Buffer Heaven...But it been Buffer Hell for the past 3 weeks....Thanks
I think Hutch or f0dder has the answer to this or another serious Assembler Coder.
See Code Below:
There is 6 presumable Private Buffers.
There are 6 indiviualzed line text for each Buffer
If we use length of you will see that line ONLY in each buffers if you use MessageBox.
All is WELL is what we all BELIEVE...
Now lets Write that TEXT that is suppose to be in BUFFER1.
Now why in heck is it showing all of the text in the other 5 Buffers...
What I see is that length of is only a trick to point to what is suppose to be in the buffer but in reality you got All of this TEXT over and Over Again in Each Buffer... This has lead me to believe that MASM is only giving me one buffer and is dividing my shit up in it...while fooling me all the time....A bit extragate but heck I don't know what to think...
Now what is this All About.....Am I'm missing Something.....Is it true that each buffer should HOLD it own CONTEXT TOTALLY PRIVATELY.....Please Help.....
MY ONLY GOAL IS TO SEE TO IT THAT WHEN A BUFFER IS USED THAT NOTHING ELSE HAS NOTHING TO DO WITH IT what so ever
AS IT SHOULD BE OR AS MY PROJECT REQUIRE.
For the last time I ask you to please review this carefully...
PLEASE COPY THE FOLLOWING AND COMPLY IT TO GET AN TOTALLY UNDERSTANDING....
I thought i was in Buffer Heaven...But it been Buffer Hell for the past 3 weeks....Thanks
.386
.model flat,stdcall
option casemap:none
WinMain proto :DWORD,:DWORD,:DWORD,:SWORD
include \MASM32\INCLUDE\windows.inc
include \MASM32\INCLUDE\gdi32.inc
include \MASM32\INCLUDE\user32.inc
include \MASM32\INCLUDE\kernel32.inc
includelib \MASM32\LIB\gdi32.lib
includelib \MASM32\LIB\user32.lib
includelib \MASM32\LIB\kernel32.lib
MessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORD
wsprintfA PROTO C :DWORD,:VARARG
wsprintf equ <wsprintfA>
szText MACRO Name, Text:VARARG
LOCAL lbl
jmp lbl
Name db Text,0
lbl:
ENDM
.data
MyText db "C:\What is Really in This Buffer.txt",0
Caption1 db 'Buffer 1',0
Caption2 db 'Buffer 2',0
Caption3 db 'Buffer 3',0
Caption4 db 'Buffer 4',0
Caption5 db 'Buffer 5',0
Caption6 db 'Buffer 6',0
.data?
Buffer1 db 8 dup(?)
Buffer2 db 8 dup(?)
Buffer3 db 8 dup(?)
Buffer4 db 8 dup(?)
Buffer5 db 8 dup(?)
Buffer6 db 8 dup(?)
hFile dd ?
NumBytesWritten dd ?
.code
Main:
szText String1, "1111"
szText String2, "2222"
szText String3, "3333"
szText String4, "4444"
szText String5, "5555"
szText String6, "6666"
;................................... ; Copy String To Buffer WITHOUT lstrcpy 01
mov esi, offset String1
mov edi, offset Buffer1
mov ecx, lengthof String1
rep movsb
mov esi, offset String2
mov edi, offset Buffer2
mov ecx, lengthof String2
rep movsb
mov esi, offset String3
mov edi, offset Buffer3
mov ecx, lengthof String3
rep movsb
mov esi, offset String4
mov edi, offset Buffer4
mov ecx, lengthof String4
rep movsb
mov esi, offset String5
mov edi, offset Buffer5
mov ecx, lengthof String5
rep movsb
: NOW LETS WRITE IT TO FILE AND SEE THE TRUTH ABOUT WHAT IS REALLY IN THAT
; PRESUMBLY PRIVATE BUFFER
; NOTICE I USE 36 BYTE TO BE THE LENGTH BUT REMEMBER i'm only WRITING BUFFER 1..
; ( NOT 2, 3. 4. 5 )
; I did not order any Filler, if you get anything IT SHOULD ONLY BE BLANK SPACES
; AFTER THE TEXT 1111
end Main
invoke ExitProcess,0
end Main
.model flat,stdcall
option casemap:none
WinMain proto :DWORD,:DWORD,:DWORD,:SWORD
include \MASM32\INCLUDE\windows.inc
include \MASM32\INCLUDE\gdi32.inc
include \MASM32\INCLUDE\user32.inc
include \MASM32\INCLUDE\kernel32.inc
includelib \MASM32\LIB\gdi32.lib
includelib \MASM32\LIB\user32.lib
includelib \MASM32\LIB\kernel32.lib
MessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORD
wsprintfA PROTO C :DWORD,:VARARG
wsprintf equ <wsprintfA>
szText MACRO Name, Text:VARARG
LOCAL lbl
jmp lbl
Name db Text,0
lbl:
ENDM
.data
MyText db "C:\What is Really in This Buffer.txt",0
Caption1 db 'Buffer 1',0
Caption2 db 'Buffer 2',0
Caption3 db 'Buffer 3',0
Caption4 db 'Buffer 4',0
Caption5 db 'Buffer 5',0
Caption6 db 'Buffer 6',0
.data?
Buffer1 db 8 dup(?)
Buffer2 db 8 dup(?)
Buffer3 db 8 dup(?)
Buffer4 db 8 dup(?)
Buffer5 db 8 dup(?)
Buffer6 db 8 dup(?)
hFile dd ?
NumBytesWritten dd ?
.code
Main:
szText String1, "1111"
szText String2, "2222"
szText String3, "3333"
szText String4, "4444"
szText String5, "5555"
szText String6, "6666"
;................................... ; Copy String To Buffer WITHOUT lstrcpy 01
mov esi, offset String1
mov edi, offset Buffer1
mov ecx, lengthof String1
rep movsb
mov esi, offset String2
mov edi, offset Buffer2
mov ecx, lengthof String2
rep movsb
mov esi, offset String3
mov edi, offset Buffer3
mov ecx, lengthof String3
rep movsb
mov esi, offset String4
mov edi, offset Buffer4
mov ecx, lengthof String4
rep movsb
mov esi, offset String5
mov edi, offset Buffer5
mov ecx, lengthof String5
rep movsb
: NOW LETS WRITE IT TO FILE AND SEE THE TRUTH ABOUT WHAT IS REALLY IN THAT
; PRESUMBLY PRIVATE BUFFER
; NOTICE I USE 36 BYTE TO BE THE LENGTH BUT REMEMBER i'm only WRITING BUFFER 1..
; ( NOT 2, 3. 4. 5 )
; I did not order any Filler, if you get anything IT SHOULD ONLY BE BLANK SPACES
; AFTER THE TEXT 1111
end Main
invoke ExitProcess,0
end Main
cmax you are correct when you declare a buffer and then declare a buffer after it they are sored after each other. Remember that when you acces your first buffer you are using its offset so if you use a lenghth (36 in your case) that is larger then the length of the buffer you go on to the memory following it in this case the other buffers, the reason that message box dosen't show the other buffers is because of the 0 you put at the end. You could copy 36 letters to the offset of buffer1 and then display buffer1 in a message box and you'd see them all.
You are writing 36 bytes beginning at the address of a buffer that is only 8 bytes long. Write file does not care about null term.
Edit: You beat me Quantum. heehee.
Edit: You beat me Quantum. heehee.
cmax, i am curious: you declare each buffer as 8 bytes long, but where did you get the '36' figure from in your call to WriteFile?
WriteFile just writes the amount of bytes you tell it to, it diesn't rely on NULL termination, so you should consider it a binary write, not a text write.
Edit:rdaneel, and you beat me :) I loaded this thread up, then went to a short meeting, then came back and answered this..... next time i will refresh my browser page first :grin:
WriteFile just writes the amount of bytes you tell it to, it diesn't rely on NULL termination, so you should consider it a binary write, not a text write.
Edit:rdaneel, and you beat me :) I loaded this thread up, then went to a short meeting, then came back and answered this..... next time i will refresh my browser page first :grin:
Posted on 2002-01-24 16:21:16 by cmax
I meant to say stored :)
meaning that one buffer takes up 8 bytes and the byte after that is the start of the next buffer
meaning that one buffer takes up 8 bytes and the byte after that is the start of the next buffer
it took me 2 hours to line this question up properly... I was afraid to miss anything...and you guy gave me the solution with a few words.
That can frequently be a problem with bug finding: you are looking so hard for what must be a big bug that you don't see the tiny bug that is right under your nose..... that used to happen to me a bit when i started programming in C, i found it really infuriating that someone could check my source and point out the error within seconds :rolleyes:
But either way i still needed the help that you guys gave me. I did not know what was going on...But now i know...This was a 5 or 6 Post, From DWORDS, Strings to Buffers, 30 days of ripping my project from top to bottom many time, expecially everytime i got good news... ... Thank God THAT part is over... What a lesson.....Can't wait to get Back to the M32LIB for the next Head Buster...
It really do get easyer and easyer once you really know what the codes are doing....
It really do get easyer and easyer once you really know what the codes are doing....
I'm just a beginner, let alone all-knowing f0dder, and I knew what the problem was while reading the first 1/3 part of your message : - )
I don't know if i expained it right but i did put the 36byte there on propose. I just wanted to demostrate what i saw so someone could tell me why it had to be there which Quantum gave me the reason why... That's what that was all about....if I was to write it perfectly you would not know what the question was all about....
When the guys were talking about 36 i kind of over looked the thought. I was already happy that Quantum had deeper insight about my question...I feel no need to go into details anymore....Programmers are some very sensetive people....I am Too!!!
; NOTICE I USE 36 BYTE TO BE THE LENGTH BUT REMEMBER i'm only WRITING BUFFER 1..
It require a lot of thinking when i post a question...It take me days to even deside to go ahead and ask, and when i do, it's a one shot deal, because these guys don't play....
When the guys were talking about 36 i kind of over looked the thought. I was already happy that Quantum had deeper insight about my question...I feel no need to go into details anymore....Programmers are some very sensetive people....I am Too!!!
; NOTICE I USE 36 BYTE TO BE THE LENGTH BUT REMEMBER i'm only WRITING BUFFER 1..
It require a lot of thinking when i post a question...It take me days to even deside to go ahead and ask, and when i do, it's a one shot deal, because these guys don't play....
"all-knowing f0dder"... I'm flattered, but please realize that I am
not all-knowing - I just guess a lot ;).
not all-knowing - I just guess a lot ;).
You saved a lot of Butts out here...
"all-knowing f0dder"... I'm flattered, but please realize that I am not all-knowing - I just guess a lot ;).