[ create a new paste ] login | about

Link: http://codepad.org/dBHDIU64    [ raw code | output | fork ]

Perl, pasted on Apr 28:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$dt = <<EOT
nt!_UNICODE_STRING
   +0x000 Length           : Uint2B
   +0x002 MaximumLength    : Uint2B
   +0x004 Buffer           : Ptr32 Uint2B
EOT
;

$dt =~ /(\w+)!_(\w+)\n/;
$module_name = $1;
$symbol_name = $2;

print "typedef struct /*" . $module_name . "!*/" . "_" . $symbol_name . "\n";
print "{" . "\n";
while ($' =~ /.*(\+0x\w\w\w) (\w+).*: (\w+)\n?/)
{
printf("  %-20s%-20s// %s\n", $3, ($2 . ";"), $1);
}
print "} " . $symbol_name . ", *P" . $symbol_name . ";\n";


Output:
1
2
3
4
5
6
typedef struct /*nt!*/_UNICODE_STRING
{
  Uint2B              Length;             // +0x000
  Uint2B              MaximumLength;      // +0x002
  Ptr32               Buffer;             // +0x004
} UNICODE_STRING, *PUNICODE_STRING;


Create a new paste based on this one


Comments: