already no.
Posted on 2003-11-10 16:59:21 by cakmak
1. Another one:

I removed all addins(added comment to all in section) and tried again. And i get another crash.

RADASM caused an invalid page fault in
module <unknown> at 0084:83776138.
Registers:
EAX=006cfc10 CS=015f EIP=83776138 EFLGS=00010282
EBX=000006f8 SS=0167 ESP=006cfbf4 EBP=006cfc20
ECX=cea062e0 DS=0167 ESI=005a0ee8 FS=4687
EDX=0001dce4 ES=0167 EDI=00000000 GS=0000
Bytes at CS:EIP:

Stack dump:
bfb88390 006cfc10 bfb897df 006cfc10 00000200
00000000 005a0ee8 00000010 00000002 000006f8
0001dce4 006cfc8c bfb7389a 00000000 000006f8
00000200

but lately i noticed, this is becomes while mouse is coming over toolbar, with or w/o any project.

Also i tested with addins too. I guess about last version.

2. Docking Project:

Intersting but if i remove "tools.asm" from project everything is alright. Nothing crashing. Except above situation. But this is not about any line in file. Because later i commented all file but nothing changed.

- not about content

- not about name (tried this)

my guess only huge. Only ~40KB.

...and yes i tested a little. "33875 bytes" ok but "33889 bytes" is crashing.
Posted on 2003-11-10 18:55:08 by cakmak
Hi cakmak

Will you try this version of RAEdit?
Another request. Could you install OllyDbg as a JIT debugger? Then you will get more info if something goes wrong.

KetilO
Posted on 2003-11-11 01:09:31 by KetilO
Hi KetilO,
I have some of feature requests :)
1. For the project's treeview:
key to select an item and
to go up one level

And keyboard shortcuts to access output, properties and project windows (maybe there are already, but I haven't found yet).

This is to avoid using the mouse unnecessarily.

Thanks for your excellent program :alright:
Posted on 2003-11-11 04:03:02 by pelaillo
KetilO,

Sorry about "mouse over toolbar". It is not a problem now, really confused.

PS. i will test.
Posted on 2003-11-11 04:17:33 by cakmak
Hi pelaillo

Good idea. I will implement it.

KetilO
Posted on 2003-11-11 05:25:32 by KetilO
Hard to debug with olly. I can not step while crash because that proc is always in a loop and can not switch to radasm for trying crash. In first loop in proc, crashing is occur.

1000164B   8B5D 08          MOV EBX,DWORD PTR SS:[EBP+8]

1000164E 8BB3 AC000000 MOV ESI,DWORD PTR DS:[EBX+AC]
10001654 8BBB BC000000 MOV EDI,DWORD PTR DS:[EBX+BC]
1000165A 8B45 0C MOV EAX,DWORD PTR SS:[EBP+C]
1000165D 3B43 6C CMP EAX,DWORD PTR DS:[EBX+6C]
10001660 72 33 JB SHORT RAEDIT.10001695
10001662 8B43 6C MOV EAX,DWORD PTR DS:[EBX+6C]
10001665 8B4B 68 MOV ECX,DWORD PTR DS:[EBX+68]
10001668 EB 07 JMP SHORT RAEDIT.10001671
1000166A 8B148E MOV EDX,DWORD PTR DS:[ESI+ECX*4] ; <- first loop
1000166D 03043A ADD EAX,DWORD PTR DS:[EDX+EDI] ; <- Crashing here!
10001670 41 INC ECX
10001671 3B45 0C CMP EAX,DWORD PTR SS:[EBP+C]
10001674 ^72 F4 JB SHORT RAEDIT.1000166A ; <- jmp above
10001676 3B45 0C CMP EAX,DWORD PTR SS:[EBP+C]
10001679 76 01 JBE SHORT RAEDIT.1000167C
1000167B 49 DEC ECX
1000167C 8BC1 MOV EAX,ECX
1000167E C1E0 02 SHL EAX,2
10001681 3B83 B8000000 CMP EAX,DWORD PTR DS:[EBX+B8]
10001687 72 20 JB SHORT RAEDIT.100016A9
10001689 8B8B B8000000 MOV ECX,DWORD PTR DS:[EBX+B8]
1000168F C1E9 02 SHR ECX,2
10001692 49 DEC ECX
10001693 EB 14 JMP SHORT RAEDIT.100016A9

In loop, 2. parameter is comparing with eax.


while normal running, after loop finished

either,
eax = 100b
ecx = A04
or,
eax = 0
ecx = 0

but here in loop,

eax = 3ac2d
ecx = 1000

in
1000166D 03043A ADD EAX,DWORD PTR DS:

line trying to add nothing in eax. That address only includes "??????". Sorry but i can not commenting this situation, i do not know what for this proc and variables. And can not stepping before crash.

If may give more specific info i can notice that.
Posted on 2003-11-11 15:38:45 by cakmak
Hi cakmak

Thanks for your help.
I'm pretty shure I found the bug.

Will you try this version of RAEdit.dll?

KetilO

Edit: Attacment deleted
Posted on 2003-11-11 17:27:59 by KetilO
Congratulations :alright:
Posted on 2003-11-11 20:45:40 by cakmak
KetilO, I was looking over your code and maybe I found the source of a painting problem on NT based systems - Ranma_at's image above for example.
MakeBitmap proc

LOCAL hDC:HDC
LOCAL bicx:DWORD
LOCAL bicy:DWORD
LOCAL hBit:DWORD
LOCAL bi:BITMAPINFO
LOCAL pBits:DWORD
LOCAL nCol:DWORD

invoke CreateCompatibleDC,NULL
mov hDC,eax
mov eax,Gridcx
mov bicx,eax
.while bicx<8
add bicx,eax
.endw
mov eax,Gridcy
mov bicy,eax
.while bicy<8
add bicy,eax
.endw
mov bi.bmiHeader.biSize,sizeof BITMAPINFOHEADER
push bicx
pop bi.bmiHeader.biWidth
push bicy
pop bi.bmiHeader.biHeight
mov bi.bmiHeader.biPlanes,1
mov bi.bmiHeader.biBitCount,32
mov bi.bmiHeader.biCompression,BI_RGB
mov bi.bmiHeader.biXPelsPerMeter,0
mov bi.bmiHeader.biYPelsPerMeter,0
mov bi.bmiHeader.biClrUsed,0
mov bi.bmiHeader.biClrImportant,0
mov bi.bmiColors.rgbBlue,0
mov bi.bmiColors.rgbGreen,0
mov bi.bmiColors.rgbRed,0
mov bi.bmiColors.rgbReserved,0
invoke CreateDIBSection,hDC,addr bi,DIB_RGB_COLORS,addr pBits,0,0
mov hBit,eax
invoke GetSysColor,COLOR_BTNFACE
mov edx,eax
shr edx,16
xchg al,ah
shl eax,8
and eax,0FFFF00h
or eax,edx
mov nCol,eax
mov eax,bicx
mov ecx,bicy
mul ecx
mov ecx,eax
push edi
mov edi,pBits
mov eax,nCol
rep stosd
mov eax,bicx
shl eax,2
sub edi,eax
.while edi>pBits
push eax
call Ln
pop eax
mov ecx,Gridcy
.while ecx
sub edi,eax
dec ecx
.endw
.endw
invoke DeleteDC,hDC
pop edi
mov eax,hBit
ret

Ln:
mov eax,bicx
shl eax,2
mov ecx,Gridcx
shl ecx,2
push edi
.while eax
mov dword ptr [edi],0
add edi,ecx
sub eax,ecx
.endw
pop edi
retn

MakeBitmap endp

CreateGridBrush proc

mov eax,hGridBr
.if eax
invoke DeleteObject,eax
.endif
invoke MakeBitmap
push eax
invoke CreatePatternBrush,eax
mov hGridBr,eax
pop eax
invoke DeleteObject,eax
ret

CreateGridBrush endp
Notice how MakeBitmap returns a handle to the bitmap, but the BITMAPINFO is lost because it was on the LOCAL stack of MakeBitmap. The API states this structure must be constant for the life of the bitmap. Something that isn't clear to me: does the bitmap have to remain as long as the pattern is in use? The API says deleting the pattern brush does not delete the bitmap, but it does not explicitly state the pattern bruch does not use the bitmap.

Thank you for very easy to read code.
Posted on 2003-11-11 21:52:49 by bitRAKE
You can use a file mapping object to specify your DIB buffer, however if you put NULL in the last two parameters (file mapping object) Windows will allocate the memory for you. If you do not specify pDIBits you can get the offset to the bits as follows:

invoke CreateDIBSection,hDC,addr bi,DIB_RGB_COLORS,0,0,0

mov hBmp,eax
invoke GetObject,hBmp,SIZEOF DIBSECTION,ADDR sbmp
mov eax,sbmp.dsBm.bmBits

mov pDIBits,eax


In the case that you are refering to Bitrake, the file mapping object must exist during the life of the bitmap, The code above does not use file mapping. However in the case of NT4 I have found the value returned in pDIBits to be unreliable and prefer to use the GetObject method.

Toolbar Paint creates all of it's bitmaps using the following routine without exception (all bitmaps in TBPaint are 32 bit DIB sections):

CreateIndependantBitmap proc hDC:DWORD,SizeX:DWORD,SizeY:DWORD

LOCAL bmi :BITMAPINFO

mov bmi.bmiHeader.biSize,SIZEOF BITMAPINFOHEADER
mov eax,SizeX
mov bmi.bmiHeader.biWidth,eax
mov eax,SizeY
mov bmi.bmiHeader.biHeight,eax
mov bmi.bmiHeader.biPlanes,1
mov bmi.bmiHeader.biBitCount,32
mov bmi.bmiHeader.biCompression,BI_RGB
mov eax,SizeY
mul SizeX
shl eax,2
mov bmi.bmiHeader.biSizeImage,eax
invoke CreateDIBSection,hDC,ADDR bmi,DIB_RGB_COLORS,ADDR NULL,NULL,NULL
push eax
invoke GdiFlush
pop eax

ret

CreateIndependantBitmap endp
Posted on 2003-11-11 22:43:49 by donkey
Hi BitRake,

the reason why the GetOBject method is more reliable is that it cause the GDI to flush. For all NT based systems drawing to a newly created DIB Bitmap must be synchronized by performing a GdiFlush first. By using GetObject to obtain the address to the bits it will flush the GDI command buffer. You will always experience sporatic problems writing to a DIB in NT/2K/XP if you do not flush the GDI before doing direct to bit operations.
Posted on 2003-11-11 23:27:30 by donkey
donkey, you edited your post and now I look like an ass. :grin: I see the GDIFlush now - thanks for clarifying. Do you know if the PatternBrush needs the bitmap, or can we delete the bitmap after the PatternBrush is created?
Posted on 2003-11-11 23:46:27 by bitRAKE
Hi BitRake,

Actually, I don't do it in that routine in TBPaint, I flush before drawing each time, I forgot to put it in originally so I added it afterwards. I didn't think that anyone had replied to it yet as I guess you were typing at the same time as I did, the edit and your post have the exact same times. I am very sorry. And BTW you can never look like an ass, you are easily one of the best coders on this board.

I don't use pattern brushes prefering to paint myself but I think they have to have the bitmap for the life of the brush, can't be sure though the doc is not very clear.
Posted on 2003-11-11 23:54:37 by donkey

I am very sorry. And BTW you can never look like an ass, you are easily one of the best coders on this board.
I meant that in a playful way. :)
Posted on 2003-11-12 00:13:46 by bitRAKE
Hi bitRAKE

Thanks for optimizing the code. A few adjustments was needed to make it compatible with old routine.

.data


bmiMakeBitmap BITMAPINFO <<SIZEOF BITMAPINFOHEADER,,,1,32,BI_RGB>,>

.code

CreateGridBrush proc
LOCAL hDC:HDC
LOCAL hBit:DWORD
LOCAL pBits:DWORD

mov eax,hGridBr
.if eax
invoke DeleteObject,eax
.endif
invoke CreateCompatibleDC,NULL
mov hDC,eax
mov eax,Gridcx
mov ecx,eax
.while ecx<8
add ecx,eax
.endw
mov eax,Gridcy
mov edx,eax
.while edx<8
add edx,eax
.endw
mov bmiMakeBitmap.bmiHeader.biWidth,ecx
mov bmiMakeBitmap.bmiHeader.biHeight,edx
invoke CreateDIBSection,hDC,addr bmiMakeBitmap,DIB_RGB_COLORS,addr pBits,0,0
mov hBit,eax
invoke GdiFlush
invoke GetSysColor,COLOR_BTNFACE
xchg al,ah ;ABDC
ror eax,16 ;DCAB
xchg al,ah ;DCBA
ror eax,8 ;ADCB
mov ecx,bmiMakeBitmap.bmiHeader.biWidth
mov edx,bmiMakeBitmap.bmiHeader.biHeight
imul ecx,edx ; total pixel count
push edi
mov edi,pBits
shl edx,2 ; bytes per line
rep stosd ; fill bitmap with COLOR_BTNFACE
mov ecx,Gridcy
sub edi,edx ; start on last line
imul ecx,edx
shr edx,2 ; pixels per line
.while edi>pBits
mov eax,edx
@@: sub eax,Gridcx ; next horizontal dot in grid
mov dword ptr [edi+eax*4],0 ; black pixel for grid dot
jne @b
sub edi,ecx
.endw
invoke DeleteDC,hDC
mov edi,hBit
invoke CreatePatternBrush,edi
mov hGridBr,eax
invoke DeleteObject,edi
pop edi
ret

CreateGridBrush endp


KetilO
Posted on 2003-11-12 04:04:30 by KetilO
Just a question for you Kjetil (a bit away from the topic but though): Can you edit RaEdit to trim (delete) spaces and tabs at the end of the lines when the WM_GETTEXT (or what message is used...?) message is sent? This will reduce the space when saving... For instance:
" mov eax,5 " => " mov eax,5"
and
" " => ""
You see what I mean?

Thanks!

Regards,
Tommy
Posted on 2003-11-12 05:12:33 by Tommy
Hi Tommy

REM_TRIMSPACE message does that. Just loop through the text before using WM_GETTEXT or streaming the text out.

KetilO
Posted on 2003-11-12 06:26:02 by KetilO
Ok, thanks... but I thought if you could add an option to do that in RadAsm (if it's not already exists)?
Posted on 2003-11-12 08:52:08 by Tommy
Just a small thing, "Show proc in statusbar" option is not working for fasm and the other assemblers if procedure is not finishing with the procedure name first at least.

Proc maybe

endp
;;
proc somebody

return
;;
proc solved

endp solved
;;
is working for first "proc" in entire file scope.
Posted on 2003-11-13 20:29:30 by cakmak