flat assembler
Message board for the users of flat assembler.

Index > Windows > SetDlgItemText fails.

Author
Thread Post new topic Reply to topic
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz 28 Jul 2011, 11:02
Hello everyone, I'm trying to write some program and I have to use SetDlgItemText API to show some informations from window but it fails..
handle of window --> OK
control ID --> OK
text --> OK
after executing SetDlgitemText API, debugger says everything is OK! even GetLastError doesn't show me anything, it says everything was done successfully but I don't see any text in edit box.. What's problem ? Sad
Here's code what I mean:
Code:
section '.code' code readable executable

entry $

    invoke GetModuleHandle,0
    mov [hInstance],eax
    invoke DialogBoxParam,eax,D_MAIN,0,dlg_proc,0
    invoke ExitProcess,0

proc dlg_proc, hWnd, uMsg, wParam, lParam
    cmp [uMsg],WM_CLOSE
    jne @F
.end_dlg:
    invoke EndDialog,[hWnd],0
.exit_true:
    mov eax,TRUE
    ret
@@:

    cmp [uMsg],WM_COMMAND
    jne .exit_false
    cmp [wParam],ATTACK
    jne @F
    invoke GetDlgItemText,[hWnd],EDIT_1,var1,0x100
    invoke SetDlgItemText,[hWnd],EDIT_2,var1
    jmp .exit_true
@@:
.exit_false:
    xor eax,eax
    ret
endp    

Thank you Sad
Post 28 Jul 2011, 11:02
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20355
Location: In your JS exploiting you and your system
revolution 28 Jul 2011, 11:05
Your code is incomplete. At least give us something that we can compile and test for you.

Anyhow: what is this line?
Code:
    cmp [wParam],ATTACK    
Are you expecting us to help you write malware?
Post 28 Jul 2011, 11:05
View user's profile Send private message Visit poster's website Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz 28 Jul 2011, 11:17
revolution
How many times should I say I'm not writing malwares ? I'm working to make some patch for game, to patch it in memory. I don't know what else should I write there and choosed "ATTACK".
P.S also, I don't think that GUI version malware would be nice.

Now about code, here's true example.
Code:
section '.code' code readable executable 

entry $ 

    invoke GetModuleHandle,0 
    mov [hInstance],eax 
    invoke DialogBoxParam,eax,D_MAIN,0,dlg_proc,0 
    invoke ExitProcess,0 

proc dlg_proc, hWnd, uMsg, wParam, lParam 
    cmp [uMsg],WM_CLOSE 
    jne @F 
.end_dlg: 
    invoke EndDialog,[hWnd],0 
.exit_true: 
    mov eax,TRUE 
    ret 
@@: 

    cmp [uMsg],WM_COMMAND 
    jne .exit_false 
    cmp [wParam],ATTACK 
    jne @F 
    invoke GetDlgItemText,[hWnd],EDIT_1,var1,0x100 
    invoke SetDlgItemText,[hWnd],EDIT_2,var1 
    jmp .exit_true 
@@: 
.exit_false: 
    xor eax,eax 
    ret 
endp
section '.data' data readable writeable
var1 rb 0x100    

EDIT_1 and EDIT_2 are EDIT boxes. after I'm working with GetDlgItemText, it saves first input successful to var1, and after SetDlgItemText to another dialog, it says OK but nothing is happening.. I wrote same variables but in second edit box it should write information like:
Opening Process..
Finding Offset..
and so on.. but none of them work.
Any other informations ?


Last edited by Overflowz on 28 Jul 2011, 11:23; edited 1 time in total
Post 28 Jul 2011, 11:17
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20355
Location: In your JS exploiting you and your system
revolution 28 Jul 2011, 11:22
Overflowz wrote:
Any other informations ?
Yes. Some code that can be compiled without us having to recreate and guess everything. Help us to help you.
Post 28 Jul 2011, 11:22
View user's profile Send private message Visit poster's website Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz 28 Jul 2011, 11:42
Found solution! I had infinite loop that was freezing program and thats the reason why it don't worked.. Thank you anyway for help! Smile
Post 28 Jul 2011, 11:42
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 28 Jul 2011, 11:45
Overflowz wrote:
How many times should I say I'm not writing malwares ? I'm working to make some patch for game, to patch it in memory. I don't know what else should I write there and choosed "ATTACK".
P.S also, I don't think that GUI version malware would be nice.

Fair point. But weren't you writing anti-malware last time I asked?
Post 28 Jul 2011, 11:45
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20355
Location: In your JS exploiting you and your system
revolution 28 Jul 2011, 11:45
Overflowz wrote:
Found solution! I had infinite loop that was freezing program and thats the reason why it don't worked..
Which is why we ask for all the code. One can never be sure where the fault is without it.
Post 28 Jul 2011, 11:45
View user's profile Send private message Visit poster's website Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz 28 Jul 2011, 12:05
vid
Yes, I'm also learning malware techniques what they does and so on to prevent their actions. I've asked this because I'm studying about memory patching and prevent some functions etc.. I need to study much before I'll start anti-malware things Smile I can beat "easy malwares" but not hard ones.. Smile I just don't have any other idea what should I write and just working with them because they're a lot Smile
revolution
I don't understand, you need the code ?
P.S also, I was using bad window handle when calling another procedure.. Smile I missed that CALL instruction pushes return address to stack and hWnd was lost + infinite loop did it's job, program was freezing and no results were shown. In debugger, after calling SetDlgItemText, it does not set text because of it's freezed I guess.. GUI applications have different style to work IMO.
Post 28 Jul 2011, 12:05
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20355
Location: In your JS exploiting you and your system
revolution 28 Jul 2011, 12:11
Overflowz wrote:
I don't understand, you need the code ?
P.S also, I was using bad window handle when calling another procedure.. Smile I missed that CALL instruction pushes return address to stack and hWnd was lost + infinite loop did it's job, program was freezing and no results were shown. In debugger, after calling SetDlgItemText, it does not set text because of it's freezed I guess.. GUI applications have different style to work IMO.
We could never have helped you discover that with just the code you posted. If you had not been able to solve it yourself then we would have been here for days trying to discover the problem.
Post 28 Jul 2011, 12:11
View user's profile Send private message Visit poster's website Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz 28 Jul 2011, 12:15
revolution
I though it was enough)) Sorry. Smile Next time, I'll post full code. Thanks! Solved now.
Post 28 Jul 2011, 12:15
View user's profile Send private message 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.