okay when the user selects a certain thing in a combobox i have set up, I want to writeprocessmemory based on their selection. How do I do this? HEre is what I have so far..



.if wParam == 1022
invoke SendMessage,hList1,CB_GETCURSEL,0,0
mov Current1,eax
invoke SendMessage,hList2,CB_GETCURSEL,0,0
mov Current2,eax
invoke SendMessage,hList3,CB_GETCURSEL,0,0
mov Current3,eax
invoke SendMessage,hList4,CB_GETCURSEL,0,0
mov Current4,eax
invoke SendMessage,hList5,CB_GETCURSEL,0,0
mov Current5,eax
invoke SendMessage,hList6,CB_GETCURSEL,0,0
mov Current6,eax
invoke SendMessage,hList7,CB_GETCURSEL,0,0
mov Current7,eax
invoke SendMessage,hList8,CB_GETCURSEL,0,0
mov Current8,eax
invoke SendMessage,hList9,CB_GETCURSEL,0,0
mov Current9,eax
invoke SendMessage,hList0,CB_GETCURSEL,0,0
mov Current0,eax

.if Current1 == 00
invoke WriteProcessMemory,theprocess,offset key1,offset key11,1,NULL
.elseif Current1 == 01
invoke WriteProcessMemory,theprocess,offset key1,offset key22,1,NULL
.elseif Current1 == 02
invoke WriteProcessMemory,theprocess,offset key1,offset key33,1,NULL
.endif
.endif


As you can see, different selections write different values. But this code doesnt seem to work. Any thoughts or help is greatly appreciated.

RIF
Posted on 2003-01-05 22:36:40 by resistance_is_futile
try using the CBN_SELCHANGE notification
something like this... ( i haven't tested it )

.if(uMsg == WM_COMMAND)

mov eax, lParam ; eax now = handle to combo sending msg
.if(eax == hList1)
mov eax, wParam
shr eax, 16 ; eax now = notification
.if(ax == CBN_SELCHANGE)
invoke SendMessage,hList1,CB_GETCURSEL,0,0
mov Current,eax
.if(Current == 00)
invoke WriteProcessMemory,theprocess,offset key1,offset key11,1,NULL
.elseif(Current == 01)
invoke WriteProcessMemory,theprocess,offset key1,offset key22,1,NULL
.elseif(Current == 02)
invoke WriteProcessMemory,theprocess,offset key1,offset key33,1,NULL
.endif

.endif
.elseif(eax == hList2)
mov eax, wParam
shr eax, 16 ; eax now = notification
.if(ax == CBN_SELCHANGE)
invoke SendMessage,hList2,CB_GETCURSEL,0,0
mov Current,eax
.if(Current == 00)
invoke WriteProcessMemory,theprocess,offset key1,offset key11,1,NULL
.elseif(Current == 01)
invoke WriteProcessMemory,theprocess,offset key1,offset key22,1,NULL
.elseif(Current == 02)
invoke WriteProcessMemory,theprocess,offset key1,offset key33,1,NULL
.endif

.endif
; keep adding elseif's for each combo box
.endif
.endif


hope this helps =)
Posted on 2003-01-05 22:54:56 by BubbaFate
btw, u could use the loword of wParam and test it for the combo box ID... then use lParam for the handle to the combo, this would eliminate the need to store each's combos handle in a global variable
Posted on 2003-01-05 22:57:34 by BubbaFate
okay well did I get the ids right?



Current == 01


are those ids right?
Posted on 2003-01-05 23:27:49 by resistance_is_futile
no those are list indexes of the combo box
Posted on 2003-01-05 23:29:35 by BubbaFate
sorry thats what i meant.. are those the right list indexes? If they are, it should work the way i have it right?
Posted on 2003-01-05 23:46:58 by resistance_is_futile
When the user changes the selection in a combo box a CBN_SELCHANGE notification is sent to the parent window, so using that WM_COMMAND handler i posted will extract which combo box the user modified. I just cut and pasted that writeprocessmemory code, so I do not know if that is going to work like u want it to. BUT the 'Current' variable will be set to the index that the user changed the combo box to..., which combo box was modified is of course determined by the elseif (eax == hlist?) statements
Posted on 2003-01-05 23:54:04 by BubbaFate
okay well I did try your method and it didnt seem to work the way I wanted it to. I dont know how to explain it but when the user selects an option from the combo box, I want to writeprocessmemory based on their selection. Like if they selected oranges, I would do:

invoke WriteProcessMemory,theprocess,offset oranges, offset oranges1,1,NULL

or of they selected oranges2 i would do:

invoke WriteProcessMemory,theprocess,offset oranges2,offset oranges3,1,NULL
Posted on 2003-01-06 00:03:57 by resistance_is_futile
heh, ure oranges example just screwed up my head... i dont know enough about what you are trying to accomplish to really help u much with the actual writeproccessmemory calls... if u want u can icq/aim me at 72415266/rect69 and I could try and work through it with u =)
Posted on 2003-01-06 00:15:24 by BubbaFate
okay well probably tomorrow. Right now, Im a bit fustrated so have decided to quit for the night. I am now having trouble with other things as well (programming related). I had everything working except the writeprocessmemory part but now its all screwed up..
Posted on 2003-01-06 00:35:54 by resistance_is_futile
btw, one thing about your writeprocessmemory call that bothers me is the second parameter, you are passing the address of a variable in your program. Ill use this line as an example
invoke WriteProcessMemory,theprocess,offset key1,offset key11,1,NULL

This is the same thing as saying "I want you to copy 1 byte of whatever is contained in the variable 'key11' to the variable 'key1'. Now that means that that function call is the equivilent to the following code
mov al, byte ptr[key11]

mov byte ptr[key1], al

Im pretty sure that is not what you meant because if it is, then u wouldn't use writeprocessmemory in the first place. Of course thats only true if 'theprocess' is a handle to your process, which isn't likely... but even if thats the case it doesn't make since unless 'theprocess' is a handle to a process that is another instance of your program
Posted on 2003-01-06 00:48:52 by BubbaFate
Maybe the memory isn't writeable? If so then you'll have to call VirtualProtectEx first.
Posted on 2003-01-06 05:53:17 by stormix
What are key1 and key11? How are they defined? If key11 follows key1, maybe you should write (OFFSET key11-OFFSET key1) instead to get its size.
Posted on 2003-01-06 07:16:22 by comrade
key 1 is the memory address of the number 1 on your keyboard for a certain process. Key11 is just the byte I am trying to write to that address.



invoke WriteProcessMemory,theprocess,offset key1,offset key11,1,NULL



This is the same thing as saying "I want you to copy 1 byte of whatever is contained in the variable 'key11' to the variable 'key1'. Now that means that that function call is the equivilent to the following code


So what instead of using offset key11, I would just put whatever im writing to the addres (014h ??) like this:

 

invoke WriteProcessMemory,theprocess,offset key1,014h,1,NULL
Posted on 2003-01-06 11:58:40 by resistance_is_futile
no the second parameter is the problem, try
invoke WriteProcessMemory,theprocess,[B]key1[/B],offset key11,1,NULL
Posted on 2003-01-06 12:00:32 by BubbaFate
okay this is what I tried:



.if wParam == 1022 ;If button is pushed
invoke WriteProcessMemory,theprocess,0079A5E4h,offset key11,1,NULL
.endif


I tried that and it worked. So it must be something in this area:



invoke SendMessage,hList2,CB_GETCURSEL,0,0
mov Current2,eax
invoke SendMessage,hList3,CB_GETCURSEL,0,0
mov Current3,eax
invoke SendMessage,hList4,CB_GETCURSEL,0,0
mov Current4,eax
invoke SendMessage,hList5,CB_GETCURSEL,0,0
mov Current5,eax
invoke SendMessage,hList6,CB_GETCURSEL,0,0
mov Current6,eax
invoke SendMessage,hList7,CB_GETCURSEL,0,0
mov Current7,eax
invoke SendMessage,hList8,CB_GETCURSEL,0,0
mov Current8,eax
invoke SendMessage,hList9,CB_GETCURSEL,0,0
mov Current9,eax
invoke SendMessage,hList0,CB_GETCURSEL,0,0
mov Current0,eax


.if (Current1 == 00)
invoke WriteProcessMemory,gameprocess,0079A5E4h,offset knife1,1,NULL
.elseif (Current1 == 01)
invoke WriteProcessMemory,gameprocess,0079A5E4h,offset knifethrown1,1,NULL
.elseif (Current1 == 02)
invoke WriteProcessMemory,gameprocess,0079A5E4h,offset suppressed451,1,NULL
.endif
.endif


How can I get the Zero Based Index of a list item and display it like in a messagebox or something? I have no idea of 00 and 01 and 02 are the correct ones and i think thats where my problem is.
Posted on 2003-01-06 12:16:16 by resistance_is_futile
szFormat db "Current index is: %lu"

szBuffer db 100h dup(?)

invoke SendMessage,hList2,CB_GETCURSEL,0,0 ; get current index
invoke wsprintf, szBuffer, szFormat, eax ; convert to string
invoke MessageBox, NULL, szBuffer, NULL, MB_OK ; display messagebox


much easier to just step through it with a debugger though =/
Posted on 2003-01-06 12:23:24 by BubbaFate


szFormat db "Current index is: %lu"
szBuffer db 100h dup(?)


invoke SendMessage,hList2,CB_GETCURSEL,0,0 ; get current index
invoke wsprintf, addr szBuffer, addr szFormat, eax ; convert to string
invoke MessageBox, hWin, addr szBuffer, addr szBuffer, MB_OK ; display messagebox


This works. I would use a debugger if i knew how lol. Well I am familiar with debuggers and I know how to use ollydbg fairly well but I do not know how to debug programs because I never really had to. Anyway, I know I am getting the right ids for the combo boxes. Wait I just now found my problem lol:



.if wParam == 1022
invoke RtlZeroMemory,addr Current2,10
invoke SendMessage,hList2,CB_GETCURSEL,0,0 ; get current index
mov Current2, eax
invoke wsprintf, addr szBuffer, addr szFormat, addr Current2 ; convert to string
invoke MessageBox, hWin, addr szBuffer, addr szBuffer, MB_OK ; display messagebox


See the mov Current2,eax? Well when I display that in a message box it gives me this HUGE number like 423567890 (not that big but thats just an example. not the real number.). Thats where the problem is in my program. How can I get eax into a buffer (preferablly Current2) because I am doing multiple invoke SendMessage,hList2,CB_GETCURSEL,0,0 in my program. I have 10 combo boxes in my program. And Im getting all of their selections all at once.
Posted on 2003-01-06 12:53:16 by resistance_is_futile
heh, that hugh number that your seeing is really -1 (aka CB_ERR) that means that nothing is selected in the combo box... there is nothing wrong with the code

try using...

szFormat db "Current index is: %li" so that it will display -1 correctly
Posted on 2003-01-06 12:59:09 by BubbaFate
no no no lol.. Even when there is something selected, it still doesnt work right.. It displays the same number every time when Im trying to get it from Current1...It works if I read it from eax but when I try to put eax into a buffer, it reads out that big number regardless if something is selected or not...
Posted on 2003-01-06 18:58:23 by resistance_is_futile