Go Back   BWHacks > Development > Reverse Engineering > Code Snippets and Tutorials

Code Snippets and Tutorials The place for open source releases, great information, and tutorials written by other members.

Reply
 
LinkBack Thread Tools

Old 08-09-2008, 08:42 PM   #1 (permalink)
nano351
Banned

Evangelist
 
Join Date: Dec 2007
Location: Pennsylvania
Posts: 1,181
nano351 is a jewel in the rough
Send a message via ICQ to nano351 Send a message via AIM to nano351 Send a message via MSN to nano351 Send a message via Yahoo to nano351 Send a message via Skype™ to nano351
Default [Starcraft] Getting the width of a string

I found the function starcraft uses to get the width of a character in the current font:
0041F7B0h

So I wrote two functions to get character widths and get string widths:
Code:
GetCharacterWidth proc character:byte ;returns the width of the character in the current font
    movzx ecx, character
    mov eax, 0041F7B0h
    call eax
    Ret
GetCharacterWidth EndP
Code:
GetStringWidth    proc text:DWORD ;returns the width of the string in the current font
    xor edx, edx
    xor ecx, ecx
    mov ebx, text
    add ebx, ecx
    mov bl, byte ptr ds:[ebx]
    .while bl != 0
        mov eax, text
        add eax, ecx
        mov al, byte ptr ds:[eax]
        .if al > 1Fh ;if you are using extended color characters you will need to add them to be filtered out
            invoke GetCharacterWidth,al
            add edx, eax
        .endif
        inc ecx
        mov ebx, text
        add ebx, ecx
        mov bl, byte ptr ds:[ebx]
    .endw
    mov eax, edx
    Ret
GetStringWidth EndP
I'm sure they can be cleaned up a bit but they work
nano351 15 0FF11|\|3   Reply With Quote
Advertisement
 
Advertisement
Advertisement Sponsored links

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic VB Stuff - String Manipulation, Variables, If Statments, For Statments. LCSBSSRHXXX Programming 22 05-27-2008 06:57 AM
Useful VB6 Functions bLueStar Starcraft Hacking Related 13 05-12-2008 01:40 PM
Aka, do your job. Mystic Videl Website Related 8 09-07-2006 07:09 AM
I've got another problem now. Dyndrilliac Programming 1 02-22-2006 02:18 PM


All times are GMT. The time now is 01:12 AM.


vBulletin style developed by Transverse Styles

Powered by vBulletin Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
Copyright © 2004-2008 BWHacksAd Management by RedTyger