News:

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

Dialog Creation via DLL

Started by Ksbunker, January 02, 2007, 09:09:07 AM

Previous topic - Next topic

Ksbunker

Hopefully i'm not breaching any forum rules here, but i've seen several topics pertaining to DLL Injection removed and hopeing this one does not follow the same fate. I read the rules and from what I can understand, I don't beleive I am in breach of them... I not asking how to do it.

Anyway, background.... I'm making a DLL (plugin) for a chat application that reacts to certain commands when typed, such as '.google', '.wikipedia' and '.about'... and subsequently performs an action specific to the command. I have injected this DLL into the process using CreateThread and it contains a keyboard hook using SetWindowsHook.

Now my problem exists in that... for several of the commands, I require the use of dialog boxes to display various things. So basically, '.about' command is sent and what appears is the about dialog box. I have also included the DlgProc for it aswell and well as declared the PROTO. But It fails to do anything when the command is sent.

I have included within the DLL itself, *.rc resource with the dialogs. DialogBoxParam does not seem to work. Im unsure about the first parameter of the Function. Regularly in exe's I would use hWnd, or whatever the handle is... but I have never worked with DLL's before and so are unsure about the handle...

AboutProc PROTO :HWND, :DWORD, :DWORD, :DWORD

.const

IDD_ABOUT equ 3000 ;dialog id

.code

...

Invoke lstrcmp, ADDR sz___Buffer, CTEXT (".about")
.if eax==0

  Invoke SendMessage, ebx, WM_SETTEXT, 0, 0
  invoke DialogBoxParam, NULL, IDD_ABOUT, NULL, OFFSET AboutProc, NULL

.endif

...

AboutProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

mov eax,uMsg

.if eax == WM_CLOSE

invoke EndDialog, hWnd, NULL

.endif

xor eax,eax
ret

AboutProc endp

sluggy

As you probably guessed, you shouldn't use NULL as the first parameter in your DialogBoxParam call, instead you should use the HINSTANCE of the dll, this is the base address of the dll and is passed to you as part of your DllMain proc when the dll loads.


zooba

Also, have you considered and/or attempted using subclassing rather than system hooks? (I'm assuming the plugin API doesn't support intercepting the text) This sounds much more like a job for subclassing, and while both may achieve the same result, subclassing is better designed (and documented) for this sort of thing.

Cheers,

Zooba :U