Guest User

Untitled

a guest
Mar 10th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. module Byteworks (* Bytes & Packets *)
  2.  
  3. open Memory
  4. open Memory.C
  5.  
  6. open BModel
  7.  
  8. open System
  9. open System.Text
  10.  
  11. let Authorize(user : string, password : string) =
  12. let mutable bufOut = Array.zeroCreate 44
  13.  
  14. let cpy = Hex.decode <| "0xAAAA0A80"
  15. let user = Encoding.ASCII.GetBytes user
  16. let pwd = Encoding.ASCII.GetBytes password
  17.  
  18. bufOut <++ cpy <| 0 <| cpy.Length
  19. bufOut <++ [|0x16uy|] <| 24 <| 1
  20. bufOut <++ user <| 26 <| Math.Min(8, user.Length)
  21. bufOut <++ pwd <| 34 <| Math.Min(8, pwd.Length)
  22.  
  23. new Packet(bufOut ++> 42)
  24.  
  25. let SyncTime dt =
  26. let mutable bufOut = Array.zeroCreate 32
  27.  
  28. let dtnows = BitConverter.GetBytes( (seconds dt) )
  29. let cpy = Hex.decode <| "0xAAAA1380"
  30.  
  31. bufOut <++ cpy <| 0 <| cpy.Length
  32. bufOut <++ [|0x4uy|] <| 24 <| 1
  33. bufOut <++ (dtnows) <| 26 <| 4
  34.  
  35. new Packet(bufOut ++> 30)
  36.  
  37. let GetCurrent idDev numInst =
  38. let mutable bufOut = Array.zeroCreate 32
  39.  
  40. let cpy = Hex.decode <| "0xAAAA2080"
  41. bufOut <++ cpy <| 0 <| cpy.Length
  42. bufOut <++ [|2uy|] <| 24 <| 1
  43. bufOut <++ [|idDev|] <| 26 <| 2
  44. bufOut <++ [|numInst|] <| 28 <| 2
  45.  
  46. new Packet(bufOut ++> 30)
  47.  
  48. let GetArchivet dev dt1 dt2 numIT numArh numID =
  49. let mutable bufOut = Array.zeroCreate 44
  50.  
  51. let cpy = Hex.decode <| "0xAAAA2180"
  52.  
  53. let dt1s = BitConverter.GetBytes( Convert.ToInt32(dt1 : int64) )
  54. let dt2s = BitConverter.GetBytes( (seconds dt2) )
  55.  
  56. bufOut <++ cpy <| 0 <| cpy.Length
  57. bufOut <++ [|14uy|] <| 24 <| 1
  58. bufOut <++ [|dev|] <| 26 <| 2
  59. bufOut <++ dt1s <| 28 <| 4
  60. bufOut <++ dt2s <| 32 <| 4
  61. bufOut <++ [|numIT|] <| 36 <| 2
  62. bufOut <++ [|numArh|] <| 38 <| 2
  63. bufOut <++ [|numID|] <| 40 <| 2
  64.  
  65. new Packet(bufOut ++> 42)
  66.  
  67. let GetPropContr n =
  68. let mutable bufOut = Array.zeroCreate 28
  69. let hex = Hex.decode <| match n with
  70. | 1 -> "0xAAAA0480"
  71. | 2 -> "0xAAAA0580"
  72. | 3 -> "0xAAAA0680"
  73. | _ -> "0xAAAA0480"
  74.  
  75. bufOut <++ hex <| 0 <| hex.Length
  76.  
  77. new Packet(bufOut ++> 26)
  78.  
  79. let SetPropContr n bytes hack configuration =
  80. let (hex, size, fin) = match n with
  81. | 1 -> Hex.decode "0xAAAA0180", 928, 928
  82. | 2 -> Hex.decode "0xAAAA0280", 928, 928
  83. | 3 -> Hex.decode "0xAAAA0380", 232, 318
  84. | _ -> Hex.decode "0xAAAA0180", 928, 928
  85.  
  86. let mutable bufOut = Array.zeroCreate 1024 //(fin + 28)
  87. let mutable bufX : byte array = Array.zeroCreate 928
  88. let finbytes = BitConverter.GetBytes(Convert.ToInt16(fin)) // 2 bytes
  89. bufOut <++ hex <| 0 <| hex.Length
  90. bufOut <++ finbytes <| 4 <| 2
  91. bufOut <++ bytes <| 26 <| size
  92.  
  93. if n = 3 then
  94. bufOut <++ hack <| 258 (*26+232*) <| 6
  95. bufOut <++ configuration <| 264 (*26+238*) <| 80
  96.  
  97. new Packet(bufOut ++> (fin + 26))
Add Comment
Please, Sign In to add comment