Jump to content
Tuts 4 You

C to Delphi


Recommended Posts


I am having problems converting this coding form C to Delphi.

char* szMemDump = (char*)malloc(mbi.RegionSize+1);

malloc is ok. But I don't what's with all the "char*".

if( memcmp( (void*)(szMemDump+x), (void*)szBytes, strlen( szBytes ) ) == 0 )

I just cannot sum both szMemDump and x together?

Link to comment

1) C is quite strict on variable types, Delphi usually is more relaxed.

var szMemDump : pointer;
szMemDump := malloc(mbi.RegionSize+1);


if memcmp(pointer(dword(szMemDump)+x), szBytes, strlen(szBytes)) = 0 then

Anyway, I would suggest that you do not convert the code literally, instead think what the C code does and write new code using Delphi functions (eg. GetMem instead on malloc, CompareMem instead of memcmp, Length instead of strlen).

Link to comment

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...