Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.36 KB | None | 0 0
  1.  
  2. 1.using System;
  3. 2.using System.Collections.Generic;
  4. 3.using System.Linq;
  5. 4.using System.Text;
  6. 5.
  7. 6.namespace opcodefinder
  8. 7.{
  9. 8. public class Program
  10. 9. {
  11. 10. static void Main(string[] args)
  12. 11. {
  13. 12. Console.WriteLine("Opcode: ");
  14. 13. Console.WriteLine(CalcOffsetFromOpcode403(Convert.ToUInt32(Console.ReadLine())));
  15. 14. Console.WriteLine("Offset: ");
  16. 15. Console.WriteLine(CalcOpcodeFromOffset403(Convert.ToInt32(Console.ReadLine())));
  17. 16.
  18. 17. }
  19. 18.
  20. 19. public static uint CalcOffsetFromOpcode403(uint opcode)
  21. 20. {
  22. 21. // 4.0.3.13329 (Pseucode)
  23. 22. // v6 & 3 | ((v6 & 8 | ((v6 & 0x20 | ((v6 & 0x300 | (v6 >> 1) & 0x7C00) >> 2)) >> 1)) >> 1)
  24. 23. uint offset403a = opcode & 3 | ((opcode & 8 | ((opcode & 0x20 | ((opcode & 0x300 | (opcode >> 1) & 0x7C00) >> 2)) >> 1)) >> 1);
  25. 24. //return ((offset403a * 4) + 0x560);
  26. 25.
  27. 26. return ((offset403a * 4) + 0x560);
  28. 27. }
  29. 28.
  30. 29. public static int CalcOpcodeFromOffset403(uint offset)
  31. 30. {
  32. 31. // Count all OFFSETS for OPCODES to 0xFFFF
  33. 32. for (uint i = 0; i < 0xFFFF; ++i)
  34. 33. {
  35. 34. /* Here are additional conditions to calculate the
  36. 35. * OPCODE from the associated OFFSET.
  37. 36. */
  38. 37.
  39. 38. // Additional condition FROM 4.0.3.13329
  40. 39. if ((i & 0xCF07) != 0x800)
  41. 40. {
  42. 41. if ((i & 0x4D4) == 0x454 && CalcOffsetFromOpcode403(i) == offset)
  43. 42. return (int)i;
  44. 43. }
  45. 44. }
  46. 45. return -1;
  47. 46. }
  48. 47. }
  49. 48.}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement