flat assembler
Message board for the users of flat assembler.

Index > Windows > My program send fasmIDE FEM_FINDFIRST. Crash.

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1840
Roman 01 Aug 2023, 05:35
I try send fasmwIDE FEM_FINDFIRST. But fasmwIDE crash
Code:
tmpVmem_ dd 0 ;in section data
FasmFeditHwnd dd 0

FM_GETSELECTED  = WM_USER + 6
FM_GETHANDLE    = WM_USER + 8

        invoke  FindWindow,    "FASMW_IDE32", 0
        test    eax,eax
        jz      .no_ide
        mov     ebx,eax

        invoke  SendMessage,    ebx, FM_GETSELECTED, 0, 0
        invoke  SendMessage,    ebx, FM_GETHANDLE, eax, 0
        mov     [FasmFeditHwnd],eax
.no_ide:
;section code
invoke VirtualAlloc,0,1000h,dword MEM_COMMIT,dword PAGE_READWRITE
mov    [tmpVmem_],eax
mov word [eax],"al"
Msg [tmpVmem_] ; ok show text al

;SendMessage crash fasmIDE. My program still work fine.
cmp [FasmFeditHwnd],0
jz @f
invoke SendMessage,[FasmFeditHwnd],dword FEM_FINDFIRST,dword 0,dword [tmpVmem_]
@@:
    


Last edited by Roman on 01 Aug 2023, 05:46; edited 2 times in total
Post 01 Aug 2023, 05:35
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 01 Aug 2023, 05:44
Each process has a separate address space. fasmw can't access the memory of your process.

You have to create a shareable memory region and transfer the handle.
Post 01 Aug 2023, 05:44
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1840
Roman 01 Aug 2023, 05:47
Quote:


You have to create a shareable memory region and transfer the handle.

How do this ? MapViewOfFile ?
Example.
What about ?
Code:
invoke  GlobalAlloc,GMEM_MOVEABLE+GMEM_DDESHARE,1024
mov     ebx,eax
invoke  GlobalLock,ebx
    
Post 01 Aug 2023, 05:47
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1840
Roman 01 Aug 2023, 06:42
Another variant get text from fasmwIDE and search in my program word in all text.
This variant work well.
Very strange fasmIDE set my text and not crash.

invoke SendMessage,[FasmFeditHwnd],dword WM_SETTEXT,dword 0,myTxt

myTxt db "Hi ! This is my text message to fasmwIDE.",0
Post 01 Aug 2023, 06:42
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1840
Roman 01 Aug 2023, 10:32
Code:
;procesTxts db "cmp ",0
;tmpVmem_ dd 0
invoke FindWindow,'FASMW_IDE32',0   
invoke  GetWindowThreadProcessId,eax,tmpVmem_
;invoke  GetWindowThreadProcessId,[FasmFeditHwnd],tmpVmem_
      ;mov     ebx,eax
      invoke  OpenProcess,PROCESS_ALL_ACCESS,0,[tmpVmem_]
      
      invoke  WriteProcessMemory,eax,0x601266,procesTxts,4,4 ;my program crash
invoke SendMessage,[FasmFeditHwnd],dword FEM_FINDFIRST,dword 0,dword 0x601266
    
Post 01 Aug 2023, 10:32
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 01 Aug 2023, 15:52
Roman wrote:
Another variant get text from fasmwIDE and search in my program word in all text.
This variant work well.
Very strange fasmIDE set my text and not crash.

invoke SendMessage,[FasmFeditHwnd],dword WM_SETTEXT,dword 0,myTxt

myTxt db "Hi ! This is my text message to fasmwIDE.",0
WM_SETTEXT is a system defined message so it will copy the text from one process to the other.

fasmw uses custom messages so the system has no idea what data it is.
Post 01 Aug 2023, 15:52
View user's profile Send private message Visit poster's website Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 727
Ali.Z 01 Aug 2023, 19:19
Roman wrote:
Code:
;procesTxts db "cmp ",0
;tmpVmem_ dd 0
invoke FindWindow,'FASMW_IDE32',0   
invoke  GetWindowThreadProcessId,eax,tmpVmem_
;invoke  GetWindowThreadProcessId,[FasmFeditHwnd],tmpVmem_
      ;mov     ebx,eax
      invoke  OpenProcess,PROCESS_ALL_ACCESS,0,[tmpVmem_]
      
      invoke  WriteProcessMemory,eax,0x601266,procesTxts,4,4 ;my program crash
invoke SendMessage,[FasmFeditHwnd],dword FEM_FINDFIRST,dword 0,dword 0x601266
    


sorry but WPM/RPM functions never crash/never generate exception.

_________________
Asm For Wise Humans
Post 01 Aug 2023, 19:19
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 01 Aug 2023, 22:19
Ali.Z wrote:
sorry but WPM/RPM functions never crash/never generate exception.
Probably not. But the receiving application can certainly crash if it interprets the incoming message as a memory address in its own space and tries to access it.
Post 01 Aug 2023, 22:19
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.