News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Parts of a message

Started by shadow, March 25, 2006, 06:55:16 AM

Previous topic - Next topic

shadow

I am writing a program that implements the CTR block cipher mode.  I have a richedit box that contains a message, and I need to take consecutive N bit blocks out of that richedit box in order to encrypt.  I can't figure out how to store only specific pieces of the text into a buffer.  I feel like there are many ways to do this, but I can't seem to get any of my ideas to work.  Can anyone point me in the right direction?  I have all weekend to figure this out.   :bg

Thanks! :wink

hutch--

shadow,

Just read the contents of the edit control into memory then chomp through it a block at a time. Fishing it out of the edit control a block at a time would be a pain.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

shadow

hmm I have
mov gettextlength.flags,GTL_NUMBYTES
mov gettextlength.codepage,CP_ACP
invoke SendDlgItemMessage,hWin,d0_rte_message,EM_GETTEXTLENGTHEX,addr gettextlength,0
push eax
pop txtlength
invoke LocalAlloc,GPTR,eax
mov hMemory,eax
invoke GetDlgItemText,hWin,d0_rte_message,hMemory,txtlength

invoke LocalFree,hMemory


I'm not sure how I should break it up.   :red:  How does everyone learn all these tricks?  Did I miss reading something or did you learn by trial and error plus getting help from others?

hutch--

First I would stop using LOcalAlloc() as its a redundant function. You can still use GlobalAlloc() with the GMEM_FIXED flag otherwise use something like HeapAlloc().

For the text in the edit control, if you know its maximum size you can allocate a buffer that is larger then use either GetWindowText() or SendMessage with WM_GETTEXT. Once you have it in a buffer you then read it a block size at a time and process the data you wish that way.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

zcoder

shadow,
As Hutch has pointed out, you should put it all into a memory heap
then write a small proc to get one line of the text out and you
code your APP to decifer that line. you do this line by line so
you know what,and where you are in your data your parsing.

Now I don't know what your data is aranged as, but like any parsing
it has to have some form that you can detect, if not I would say you
have a BIG problem of knowing when you have a whole block that you need.

But getting it into a memory heap is a good start.

Zcoder....
Back in 1979, My computer ran so fine.
And there was no such thing,
As a Microsoft Crashed Machine.
http://zcoder.110mb.com
http://www.dietzel.com/partner/idevaffiliate.php?id=345_6  Free Domain Names

shadow

Thanks for the tips guys!  I'm still confused on how you would read a certain number of, for example 64 bits, from one buffer and put only those 64 into another.   :eek 

I supposed I could do


...
invoke GetDlgItemText,hWin,d0_rte_message,hMemory,txtlength
...
invoke SendDlgItemMessage,hWin,d0_rte_message,EM_GETTEXTLENGTHEX,addr gettextlength,0
add hMemory,eax
sub hMemory,8


repeatedly in order to get the last 8 characters (64 bits?), but is there a more efficient way?  Also, hutch mentions alternative ways of getting the text from the edit box.  Are these better than GetDlgItemText?

Thanks yet again   :red