How to convert this on CSharp?

const char* data = "\x2D\x90\x01\x00\x00";
int version = 100;

// is this 1.0?
void* testAddress = (void*)0x4F77BB;

if (memcmp(testAddress, data, 5))

Recommended Answers

All 3 Replies

What are you actually testing?

I want to compare memory. How would I able to do that?

Why would you want to compare memory like that? If you want to get that low level use a different language.

If you really need this to work in C#, you will need to DllImport whatever windows library that contains memcmp, marshall each parameter and return value to conform to .Net datatypes (an often frustrating ordeal in itself). To use pointers (as it looks like you are wanting to do) you will need to use the Unsafe keyword to create an Unsafe scope in which pointers are allowed, then enable Unsafe contexts in the compilter options.

Or,

Just write the program in C.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.