Log in

View Full Version : Adding code


KoKaInE
January 17th, 2001, 11:56
Im reversing a delphi crackme and decided to make it a keygen by adding some code. I was looking at the APIs and found SetWindowTextA
was already used. I need to push the serial and the hwnd of the editbox. I know where the valid serial is, but I dont know what to push for the hwnd. Any ideas how to find it?

Thanks for all the help.

JimmyClif
January 17th, 2001, 13:07
Go back to your disassembled code and have go to the SetWindowTextA function... the last push before the call is the hwnd. If this last push is for example "push eax" try to find out where eax got the hwnd from...

JimmyClif

JimmyClif
January 17th, 2001, 13:11
Oops sorry I was talking nonsense...

You have to find out the hwnd of the edit window (your want to post to) itself... so better use our beloved SoftIce and break on it posting messages to it or getting messages from it... then you have the correct hwnd...

Here is the API explained:

BOOL SetWindowText(

HWND hWnd, // handle of window or control
LPCTSTR lpString // address of string
);

Or getting text API:

int GetWindowText(

HWND hWnd, // handle of window or control with text
LPTSTR lpString, // address of buffer for text
int nMaxCount // maximum number of characters to copy
);


Otherwise you may get the hwnd from an completly different window/control,

Sorry if this was a little bit confusing.
JC

Kayaker
January 17th, 2001, 13:17
Hi,

Maybe you could use GetDlgItem

-------------------------------
The GetDlgItem function retrieves the handle of a control in the specified dialog box.

HWND GetDlgItem(

HWND hDlg, // handle of dialog box
int nIDDlgItem // identifier of control
----------------------------------

The Hwnd of the dialog box you should be able to get from its CreateWindowExA return value.

The ID of the edit box control you might be able to get with GetNextDlgGroupItem or GetNextDlgTabItem

-----------------------------------
The GetNextDlgGroupItem function retrieves the handle of the first control in a group of controls that precedes (or follows) the specified control in a dialog box.

HWND GetNextDlgGroupItem(

HWND hDlg, // handle of dialog box
HWND hCtl, // handle of control
BOOL bPrevious // direction flag

--------------------------------------------

The GetNextDlgTabItem function retrieves the handle of the first control that has the WS_TABSTOP style that precedes (or follows) the specified control.

HWND GetNextDlgTabItem(

HWND hDlg, // handle of dialog box
HWND hCtl, // handle of known control
BOOL bPrevious // direction flag


Hope this helps,

Kayaker

JimmyClif
January 17th, 2001, 13:20
Hi Kayaker,

Nice to see you around ;D

Kayaker
January 17th, 2001, 13:40
You too JClif ^_^

Kayaker

Kayaker
January 17th, 2001, 18:07
er, I guess I should have said GetDlgCtrlID to get the ID of a control, but between them all you should be able to make it work

The GetDlgCtrlID function returns the identifier of the specified control.

int GetDlgCtrlID(

HWND hwndCtl // handle of control