Jump to content
Tuts 4 You

Example Patch Delphi And Source Code


err0r

Recommended Posts

Posted (edited)

Hi all,

I created a patch in delphi which can help people who want to know how his works and that can improve the source :P ! !

I intend to work on the combobox to select application and patch directly ;)

I add a crackme as example

patch+source+crackme.

patch_and_crackmesource.rar

Edited by err0r
  • Like 3
Posted

Thank you for your comment

If you have any ideas for improving Please tell me :thumbsup:

Posted

Do you maybe know how to show a picture (loaded from resource) on the window i create using just API calls (e.g. CreateWindowEx).

Reason i try creating all parts (buttons, editboxex ets) on the fly using API calls is EXE size, it is kinda stupid to have almost a 1MB filesize to patch a byte..

Posted

Depends on the type of image you want to load. I dunno how to do that in Delphi but if you're trying to do it with the Windows API only there's hardly any difference between C and MASM.

Anyway, for loading bitmaps from 'real' resources (Delphi uses different ones if I remember correctly, no ?) you should use LoadBitmap and the res id of the bmp in the loword of the bmp name. Alternatively you could use LoadImage but that only makes sense if you want to map it to a different size.

Guess you'll need to use your delphi version for extracting it and get a valid HBITMAP handle, Delphi prolly uses its own format.

Now you have 2 options:

Either you load the bitmap to a bitmap static control by sending the STM_SETIMAGE message to the control which is the easiest way I suppose.

According to win32.hlp it only works for OS >= Win95 so if you're a compatibility freak you might want to draw it manually.

But I guess the app won't run on those OS's anyway...

If you're still interested you should have a look at the WM_PAINT message and BitBlt. Best way to get it done would be a tutorial because there is a lot to take care of...

Posted (edited)
..Best way to get it done would be a tutorial because there is a lot to take care of...

Woooww i feel some HQ tut's comin up ;?)

I have played with this but unsuccessfully as all sources i find are c++ and delphi does do things differently i guess.. if i manage to do it, i can post a how:to about it, but i woud apreciate if someone coud come up with a tutorial for this!

update:

i have tried what you said and i namaged to get "black" box but no image is shown in it :(

this is what i coded so far:

   Image1 := CreateWindowEx(WS_EX_TOPMOST,'STATIC',
'sample_bmp', // resource name of 256 colored bitmap
MFT_BITMAP or WS_CHILD or WS_VISIBLE,
7, // Xh
90, //Xv
138, //width
61, //heighta
Handle,
1,
Inst,
nil);
Image1:=LoadBitmap(Image1, 'sample_bmp');
SendDlgItemMessage(Handle,Image1, STM_SETIMAGE , 138 , 61);

Any ideas what is wrong?

Edited by ChupaChu
Posted

Thank you I knows not tros the delphi

your code is going to be very useful for me

Posted (edited)
STM_SETIMAGE

wParam = (WPARAM) fImageType; // image-type flag

lParam = (LPARAM) (HANDLE) hImage; // handle of the image

An application sends an STM_SETIMAGE message to associate a new image (icon or bitmap) with a static control.

Parameters

fImageType:

Value of wParam. Specifies the type if image to associate with the static control. This parameter can be one of the following values:

IMAGE_BITMAP

IMAGE_CURSOR

IMAGE_ENHMETAFILE

IMAGE_ICON

hImage:

Value of lParam. Identifies the image to associate with the static control.

Basically your code should look like this:

ImgHandle := LoadBitmap(Inst, 'meh.bmp'); // Loads bmp from disk! For loading from resources param 2 would be the res id of the bmp
SendDlgItemMessage(Handle, Image1, STM_SETIMAGE, IMAGE_BITMAP, ImgHandle);

Mind the first param of LoadBitmap, it is the hinstance of your program, not a window handle.

Dunno why the HBITMAP and the HWND have the same name, nehow they should have different names ;)

Sending STM_SETIMAGE to the control causes it to resize itself automatically, so no need to supply the image size :)

Edited by Killboy
Posted

I tried this you wrote, but all i get is black rectangle, no mather what i enter in loadbitmap - resource name or file name (even with full path) its the same :(

There mut be something else i dont see right now..

I found on example on the net, but it uses classess unit that increase file size factor 5 so i wont use that method, i will figure this one out eventualy but it will take some nervs ;)

Posted (edited)

Oh nice, I've always wanted to make a patch in Delphi :D

also, changing b: Byte to b: Word, then

 b := $740C;				  
seek(FB,$00066c37);

Would change the Jump just before good/bad messages, forcing it to be good :D

it would be nice if you could use address in delphi instead of offset, finding what you need in a hexeditor takes a bit :)

Edit: Er, nvm about the offset. Just new to this :)

Edited by ante0
Posted (edited)

Hi all,

Today I did as promised with a patch "combobox" :D

With two items, and two examples to try!

skin for ecliptic ;)

20071021102850vl7.png

crackme_exemple2.rar

Edited by err0r
Posted (edited)

You will need the BitmapToRegion function, included

bmp2reg.rar

//Loading Bitmap from resource

hBmp := LoadBitmap( hInstance, PChar(101));

if hBmp<>0 then begin

rgn := BitmapToRegion( hBmp,w, h, RGB(255,0,0), 0);

//Install size a window such either as beside Bitmap

SetWindowPos(hWin, 0, 0, 0, w, h, SWP_NOZORDER or SWP_NOMOVE );

//Assign region a window

SetWindowRgn(hWin, Rgn, TRUE );

Edited by Departure
Posted

could someone make a Nice and Simple patch in delphi please so i can learn how to make/use a patch please?

mnay thanks

Posted

@Departure:

Thanks to Departure, i havent seen your reply until now.. i have found a way around meanwhile.. if one includes a dialog(or similar) in a resource and adds needed picture using resource editor, it will work ,)

I will check out your solution in few days.. tnx for your effort!

BR, ChupaChu!

Posted
Hi all,

Today I did as promised with a patch "combobox" :D

With two items, and two examples to try!

skin for ecliptic ;)

20071021102850vl7.png

Great share, keep em comin.....

aNtRoBs

Posted

MFC and that delphi vcl $hit sucks...Look at the exe size....more than 750KB....lol a pretty good app can be coded in that much space...Just learn to use direct api's.

Here is a delphi template from scarebyte..

Greetz to all the contributers :)

sb_template.zip

Posted
MFC and that delphi vcl $hit sucks...Look at the exe size....more than 750KB....lol a pretty good app can be coded in that much space...Just learn to use direct api's.

Here is a delphi template from scarebyte..

Greetz to all the contributers :)

Using a compressor, like UPX fixes that, though I agree with you.

Just a Form in delphi = ~400kb.

direct api would leave it at... ~20-30kb :)

Posted

Well, the sense of all those high-level languages is, to make coding without direct API use possible.

The huge file increase is definitely a negative aspect though.

greetz

Guest crazy_v_k
Posted

thanks for the source code m8, very helpfull ;)

  • 2 weeks later...
  • 3 months later...
Posted

all content is good!!!! In fact VCL increase a lot of bytes and kbytes in the final EXE... like some bro have said, using API could become the final app very very fast and thin in its size!

thx all for sharing his knowledge!

Posted

Very good ! Thank you very much eRROR :biggrin:

Posted
Very good ! Thank you very much eRROR :biggrin:

welcome Pouya

bye

  • 1 month later...
Posted

It maybe a stupid question but whats the big deal about size these days? After all I think most people have a broad band connection and could download a vcl app in a matter of seconds right? even if they had dialup still, it would only take them something like 1 minute for a 400kb vcl app. I think I'll stick with the old saying "Bigger is Better" and alot less coding ;)

and if your thinkning about proformance loss, really how much quicker to patch a exe would it be using direct API calls compaired to vcl ?? milliseconds!!! if that.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...