algiuxas

Number to VarInt

6 posts in this topic

#1 ·  Posted (edited)

Hello,
I'm making program(using AutoIt) that would connect to server.
I need help converting numbers to VarInt.

About VarInt:

Quote

Size (bytes):  ≥ 1, ≤ 5
Encodes: It's An integer between -2147483648 and 2147483647
Notes: Protocol buffer varint, encoding a two's complement signed 32-bit integer




About VarInt: https://developers.google.com/protocol-buffers/docs/encoding#varints

I can't understand how VarInt works, maybe somebody could help me? Thanks :)

Edited by algiuxas

42783.png

Share this post


Link to post
Share on other sites



Just pass an AutoIt integer, but keep the value within cited bounds (signed 32-bit).

How do you pass values?


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
2 minutes ago, jchd said:

How do you pass values?

What do you mean?


42783.png

Share this post


Link to post
Share on other sites
1 hour ago, algiuxas said:

I'm making program(using AutoIt) that would connect to server.
I need help converting numbers to VarIn

Simply explain what you need to do here!

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

@algiuxas you have been a member long enough to have read the Forum Rules by now. I suggest you do so before posting again. Especially this bullet point:

 

  • Launching, automation or script interaction with games or game servers, regardless of the game.
1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Similar Content

    • ZeroByDevide
      By ZeroByDevide
      i have this code running but it just would not start the code:
      Local $rndSleep = Int (Random(180000,240000,1000))
      MsgBox($MB_SYSTEMMODAL, "NaaaNuuu", "This message box will show the sleeptime after closing the tabs, you got " & $rndSleep & " seconds left.", $rndSleep)
       
      here is the error it shows me:
      "C:\Users\numan\Desktop\scipiie.au3" (23) : ==> Variable used without being declared.:
      MsgBox($MB_SYSTEMMODAL, "NaaaNuuu", "This message box will show the sleeptime after closing the tabs, you got " & $rndSleep & " seconds left.", $rndSleep)
      MsgBox(^ ERROR
    • AutID
      By AutID
      Hello,

      I will put it as simple as possible
      Why this code runs perfectly on 32bit and it fails on 64bit?
      Local $hWND = WinGetProcess("[CLASS:LSS_app]") ConsoleWrite($hWND & @LF) Local $hModuleList = _WinAPI_EnumProcessModules($hWND) If @error Then ConsoleWrite("Error: " & @error & @LF) For $i = 0 To $hModuleList[0][0] - 1 ;~ If StringInStr($hModuleList[$i][1], "sysCap64.dll") Then ConsoleWrite($hModuleList[$i][0] & @LF) ;~ EndIf Next As the title says EnumProcessModules returns error 10 which I have no clue what it is.
      It must be something with autoit or my lack of coding because a similar code in C# will work like a charm on both x86 and x64
      Process[] Processes = Process.GetProcessesByName("winLSS64Cap"); Process nProcess = Processes[0]; Handle = OpenProcess(0x10, true, (uint)nProcess.Id); for(int i = 0; i < nProcess.Modules.Count; i++) { Console.WriteLine(nProcess.Modules[i].ModuleName); }  
    • RaiNote
      By RaiNote
      Hi ^^,
      Just a little list of question:
      1. How to make an Var which defines everything like ' * ' Var of Windows
      2. How to add The Var(1.) within the a ComboBox or In the Menu
      3. How to load simply an *.au3 File wich adding a GUI and to the Main GUI a Button
      4. Using XML Files instead of 3. (I know the XMLDom or how it was named but Include file isn't anymore on my side avaible)
      5. Progressbar which is attached to Loading the File of 3./4.
      Thanks to everyone who helps :3
    • RaiNote
      By RaiNote
      I have a question About the Output from a Var which looks like :     34.32132312321   
      How to make it work that it looks like :      34.321
      I already searched through some AutoIt Includes >.< I hope somebody can help by this
      $Byte = InetGetSize(http://download853.mediafire.com/albf2b2g21bg/6tkd4gb68qdb7hd/Anime+Pics.rar,0);Download Size in Byte(Just an old Pic File) If $Byte > 1024 Then $Kilobyte = $Byte / 1024;Converting Byte to Kilobytes If $Kilobyte > 1024 Then $Megabyte = $Kilobyte / 1024;Converting Kilobyte to Megabyte If $Megabyte > 1024 Then $Gigabyte = $Megabyte / 1024;Converting Megabyte to Gigabyte If $Gigabyte > 1024 Then $Terabyte = $Gigabyte / 1024;Converting Gigabyte to Terabyte If $Terabyte > 1024 Then $Petabyte = $Terabyte / 1024;Converting Terabyte to Petabyte If $Petabyte > 1024 Then $Exabyte = $Petabyte / 1024;Converting Petabyte to Exabyte $_SIZE1 = $Exabyte & " EB" ElseIf $Petabyte < 1024 Then $Petabyte = $Terabyte / 1024 $_SIZE1 = $Petabyte & " PB" EndIf ElseIf $Terabyte < 1024 Then $Terabyte = $Gigabyte / 1024 $_SIZE1 = $Terabyte & " TB" EndIf ElseIf $Gigabyte < 1024 Then $Gigabyte = $Megabyte / 1024 $_SIZE1 = $Gigabyte & " GB" EndIf ElseIf $Megabyte < 1024 Then $Megabyte = $Kilobyte / 1024 $_SIZE1 = $Megabyte & " MB" EndIf ElseIf $Kilobyte < 1024 Then $Kilobyte = $Byte / 1024 $_SIZE1 = $Kilobyte & " KB" EndIf ElseIf $Byte < 1024 Then $_SIZE1 = $Byte & " Bytes" EndIf MsgBox(52,"Title","Size is: " & $_SIZE1)  
    • timsky
      By timsky
      Seems like Int function works incorrect sometimes.
       
      Int of binary data works fine on 1-byte data only. 2+ byte data always returns incorrect results.
       
      Int of 4-byte binary data and it's string representation:
        Int of 4-byte binary data returns bswap as result.
        Int64 of string representation of 4-byte binary data returns 32-bit signed integer.
      $bin = Binary('0xff'); 1 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd8'); 2 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd88d'); 3 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd88d8a'); 4 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd88d8abc'); 5 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd88d8abcd1'); 6 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd88d8abcd1e5'); 7 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd88d8abcd1e5ff'); 8 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) AutoIt 3.3.12.0 x86 and x64
      OS: Win 7 x64 SP1