News:

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

Passing strings to procedures.

Started by Ic3D4ne, April 29, 2005, 08:51:12 PM

Previous topic - Next topic

Ic3D4ne

I'm writing a "Leet-speak" converter using a GUI ( I know it's kind of lame, but it's intended to refresh my coding a bit)
And I'm having trouble passing strings.

The procedure takes in a DWORD argument, and I pass the "ADDR String" to it. It assembles fine, and I haven't found any faults in the code, but still the string remains untouched after it has been passed through the PROC.

Can ADDR and such directives not be used inside of procs?

All help greatly appreciated.

-Ic3D4ne

Mark Jones

Hello Ic3D4ne. Have you read ASMINTRO.HLP? Strings are a big misnomer in assember; there are only register/memory/stack pointers and values. ADDR "string" is the same thing as saying "use this memory pointer's VALUE." Does it pass a valid offset to the string in memory at runtime? If so, then the conversion proc must not be converting properly, or it is saving to a different string location. Can you post the full code?

A different (easier?) approach may be to implement two LocalAlloc buffers. Say the application has three controls, a "do it" button, and "text input" & "leet speek output" edit controls. When the "do it" button is pressed, perform the following:

1. Get length of edit1's contents.
2. GlobalAlloc buffer 1, size of edit1 contents + 100 (use GPTR as alloc type for both)
3. GlobalAlloc buffer 2, size of edit1 contents + 100 (oversized just to be safe)
4. Copy edit1 contents into GlobalAlloc1.
5. Pass the handles of GlobalAlloc1 and GlobalAlloc2 to the conversion procedure.
6. In the conversion procedure, read bytes from GlobalAlloc1(+n) and output "leet" bytes to GlobalAlloc2(+n).
7. Set the second edit control's contents to ADDR GlobalAlloc2 - the converted text will appear in it.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

thomasantony

Hi,
An even more l33t way of doing it will be without a 'do it ' button. You can change the chars by processing WM_COMMAND message from the edit control each time a character is typed in the edit control. I don't think this works in dialog boxes(only in windows). In dialogs you can subclass the editr control.  Change the leet text on-the-fly with the typing of each char in the WM_COMMAND processing.

Thomas :U
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free

hutch--

IceDane,

You would normally do a "l3Et0" conversion using a lookup table of 256 characters and either XLATB or manually swap the bytes to get when you are after. It is in fact an easy task to do once you understand character data.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php