Re: Serialize/marshal/reverse engineer unknown structure
- From: "Mike Schilling" <ap@xxxxxxxxxxxxxxxx>
- Date: Mon, 17 Aug 2009 01:04:55 -0700
Arne Vajhøj wrote:
Peter Duniho wrote:
On Sat, 15 Aug 2009 09:40:48 -0700, Arne Vajhøj <arne@xxxxxxxxxx>
wrote:
PJC wrote:
Is there a way to deserialize or marshal or somehow parse a byte
array back into a structure when you don't know what that
structure was in the first place? The structure probably came
from
C++. [...]
So, I can actually connect to the program and have gotten a
message with 13 bytes. Great. Now what.
In general, how would one reverse-engineer something like this?
If it does not contain meta data (which it sounds as if it does
not), then NO.
Well, that's not strictly true. People reverse-engineer
undocumented, unadorned data and code all the time.
But it definitely is a LOT more work (it's basically a lot of trial
and error),
True.
So let me correct the "NO" to "There is nothing in C#/.NET (or any
other language/platform for that matter) to help you".
If experimentation can reveal the structure used, then it can
obviously be implemented in C#/.NET (or any other language/platform
for that matter).
Let me ask this tangentially question (which I should probably know
the answer to, but don't.)
In C or C++, I can fill a structure with a single I/O call, e.g
struct point
{
int x;
int y;
} p;
read(fd, &p, sizeof(p));
I can almost do it portably, though in more complex examples padding
becomes an issue. So once the problem of "What are the fields in
this message?" is solved, all that's required is to define a struct
that reflects it.
In Java nothing this simple is possible. The layout of fields in an
object can't be discussed; even their order is undefined. The
corresponding code looks like:
void read(DataInputStream strm) throws IOException
{
x = strm.readInt();
y = strm.readInt();
}
After determining what the fields are, I need both to add them to the
class and to write the read method. (If there's padding I need to
code that in explicitly too.)
I know that I can write Java-like code in C# using BinaryReader. Can
I also write something C-like?
.
- Follow-Ups:
- Re: Serialize/marshal/reverse engineer unknown structure
- From: Arne Vajhøj
- Re: Serialize/marshal/reverse engineer unknown structure
- From: Peter Duniho
- Re: Serialize/marshal/reverse engineer unknown structure
- References:
- Serialize/marshal/reverse engineer unknown structure
- From: PJC
- Re: Serialize/marshal/reverse engineer unknown structure
- From: Arne Vajhøj
- Re: Serialize/marshal/reverse engineer unknown structure
- From: Peter Duniho
- Re: Serialize/marshal/reverse engineer unknown structure
- From: Arne Vajhøj
- Serialize/marshal/reverse engineer unknown structure
- Prev by Date: Re: Interpreting bit patterns as arbitrary types
- Next by Date: Re: Overload List<>.Add method
- Previous by thread: Re: Serialize/marshal/reverse engineer unknown structure
- Next by thread: Re: Serialize/marshal/reverse engineer unknown structure
- Index(es):
Relevant Pages
|