Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // xmap_inst_v3.php
- ini_set('memory_limit', '900M');
- ini_set('display_errors', '1');
- $files = explode("\n", `dir /b /s *.xmap`);
- $section_const = "\x11\x11\x33\x33";
- $inst_code = "\xce\x50\x14\x83";
- $inst_token = "\x00\x00\x00\x00";
- foreach ($files as $file)
- {
- if (!is_file($file)) continue;
- $data = file_get_contents($file);
- if ($data !== false)
- {
- // parse section list
- $loffset = fix_offset(substr($data, 0x40, 4));
- while (substr($data, $loffset + 0xc, 4) == $section_const)
- {
- $code = substr($data, $loffset + 0x0, 4);
- $ssize = parse_int(substr($data, $loffset + 0x4, 4));
- $soffset = fix_offset(substr($data, $loffset + 0x8, 4));
- // parse inst section
- if ($code == $inst_code)
- {
- $size_parsed = 0;
- while ($size_parsed + 0x70 <= $ssize)
- {
- if (substr($data, $soffset + 0x0, 4) == $inst_token)
- {
- $h = "0x" . strtoupper( bin2hex(substr($data, $soffset + 0x4, 4)) );
- $x = parse_float(substr($data, $soffset + 0x10, 4));
- $y = parse_float(substr($data, $soffset + 0x14, 4));
- $z = parse_float(substr($data, $soffset + 0x18, 4));
- $rx = parse_float(substr($data, $soffset + 0x20, 4));
- $ry = parse_float(substr($data, $soffset + 0x24, 4));
- $rz = parse_float(substr($data, $soffset + 0x28, 4));
- $rw = parse_float(substr($data, $soffset + 0x2c, 4));
- // print
- printf("%.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %s\r\n", $x, $y, $z, $rx, $ry, $rz, $rw, $h);
- }
- $soffset += 0x70;
- $size_parsed += 0x70;
- }
- }
- $loffset += 0x10;
- }
- }
- }
- // takes 0x50XXXXXX offset and fixes it to file offset
- function fix_offset($data)
- {
- $data[0] = "\x00";
- return 0x10 + array_pop(unpack("N", $data));
- }
- function parse_int($data)
- {
- return array_pop(unpack("N", $data));
- }
- function parse_float($data)
- {
- return array_pop(unpack("f", strrev($data)));
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement