Advertisement
John

IL .NET Menu Base

Sep 23rd, 2015
546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .assembly extern mscorlib {}    //adds our reference to mscorlib
  2. .assembly extern PS3Lib {}      //adds our reference to PS3Lib
  3. .assembly Test {}               //gives our project an assembly
  4. .module Test.exe                //gives our module a name
  5.  
  6. .class Test.Program            
  7. extends [mscorlib]System.Object
  8. {
  9.     .field private static class [PS3Lib]PS3Lib.PS3API PS3   //creates our PS3PI variable
  10.     .method static void Main (string[] args) cil managed    //this is our main function
  11.     {
  12.         .entrypoint                                         //entry point of our project, this is where your code gets executed first
  13.                
  14.         ldc.i4 1                                            //pushes 1 onto the stack like int r3 = 1
  15.         newobj instance void [PS3Lib]PS3Lib.PS3API::.ctor(valuetype [PS3Lib]PS3Lib.SelectAPI)   //calls our PS3API constructor
  16.         stsfld class [PS3Lib]PS3Lib.PS3API Test.Program::PS3//stores the class to our variable
  17.        
  18.         call int32 Test.Program::ConnectPS3()               //calls our ConnectPS3 function, which connects to the PS3, returns an int32   
  19.         ldc.i4 1                                            //pushes 1 onto the stack
  20.         ceq                                                 //checks if the variable that ConnectPS3 returned is equal to one
  21.         brfalse end                                         //if false, branches to end
  22.        
  23.         call void Test.Program::Controller()                //runs our controller for buttons monitoring
  24.        
  25.         end:                                                //label for end function
  26.         call string [mscorlib]System.Console::ReadLine()    //calls readline so program doesn't exit immediately
  27.         pop                                                 //clears values in stack, I think? I don't have a good explanation http://www.google.com
  28.         ret                                                 //returns
  29.     }
  30.     .method public static int32 ConnectPS3() cil managed    //declares new function, ConnectPS3 which returns and int32
  31.     {
  32.         ldsfld class [PS3Lib]PS3Lib.PS3API Test.Program::PS3//dunno how2 explain
  33.         ldc.i4 0                                            //pushes 0 onto stack, this will be called as the first arg in ConnectTarget, 0 = default console
  34.         callvirt instance bool [PS3Lib]PS3Lib.PS3API::ConnectTarget(int32)  //Connects to PS3, c# would look like PS3Lib.PS3API.ConnectTarget(0)
  35.         ldc.i4 1                                            //loads 1 into the stack
  36.         ceq                                                 //compares the two
  37.         brfalse failedconnect                               //if they're not equal, will branch to failedconnect
  38.        
  39.         ldstr "Successfully connected to PS3"               //loads string
  40.         call void [mscorlib]System.Console::WriteLine(string)//this will print the string we just loaded into the console
  41.         ldsfld class [PS3Lib]PS3Lib.PS3API Test.Program::PS3//loads our class or something, idk
  42.         callvirt instance bool [PS3Lib]PS3Lib.PS3API::AttachProcess()//calls AttachProcess, this returns a bool
  43.         ldc.i4 1                                            //push 1   
  44.         ceq                                                 //check if equal
  45.         brfalse failedattach                                //if not, goes to failedattach
  46.         ldstr "Successfully attached to process"            //loads string
  47.         call void [mscorlib]System.Console::WriteLine(string)//prints string
  48.         ldc.i4 1                                            //push 1
  49.         ret                                                 //return
  50.        
  51.         failedconnect:                                      //label for our branch if cannot connect
  52.         ldstr "Failed to connect to PS3"                    //loads string
  53.         call void [mscorlib]System.Console::WriteLine(string)//prints string
  54.         ldc.i4 0                                            //push 0, means we failed
  55.         ret                                                 //will return 0
  56.        
  57.         failedattach:                                       //label for our branch if cannot attach
  58.         ldstr "Failed to attach to process"                 //loads string
  59.         call void [mscorlib]System.Console::WriteLine(string)//prints string
  60.         ldc.i4 0                                            //push 0
  61.         ret                                                 //returns
  62.     }
  63.     .method public static int32 getButton() cil managed     //new method, returns an int
  64.     {
  65.         ldsfld class [PS3Lib]PS3Lib.PS3API Test.Program::PS3//something
  66.         callvirt instance class [PS3Lib]PS3Lib.Extension [PS3Lib]PS3Lib.PS3API::get_Extension()//dunno how to explain
  67.         ldc.i4 0x1FC7C90                                    //pushes our address
  68.         callvirt instance int32 [PS3Lib]PS3Lib.Extension::ReadInt32(uint32)//will read the int at the address we pushed
  69.         ret                                                 //returns value read from there
  70.     }
  71.     .method public static void DrawText(string[], int32) cil managed
  72.     {
  73.         .locals init([0] string[] strings, [1] string output, [2] int32 i)//initializes (?) some local variables
  74.        
  75.         ldloc output                                        //loads our output string
  76.         ldstr "~p~IL .net Menu Base\n\n~w~"                 //loads our string that we want to append on to the other string
  77.         call string [mscorlib]System.String::Concat(string, string) //concats the strings
  78.         stloc output                                        //stores it into output
  79.        
  80.         loop_s:                                             //label for when we branch
  81.         ldloc i                                             //pushes our int onto stack
  82.         ldarg.1                                             //loads argument 1, second one, our int32
  83.         ceq                                                 //check if equal
  84.         brfalse notselected                                 //if not, branches to notselected
  85.        
  86.         ldloc output                                        //already explained all of this stuff, all repetitive
  87.         ldstr "~r~"
  88.         call string [mscorlib]System.String::Concat(string, string)
  89.         stloc output
  90.         br appends
  91.        
  92.         notselected:
  93.         ldloc output
  94.         ldstr "~w~"
  95.         call string [mscorlib]System.String::Concat(string, string)
  96.         stloc output
  97.        
  98.         appends:
  99.         ldloc output                                        //pushes our output string onto stack
  100.         ldarg.0                                             //as well as our first argument
  101.         ldloc i                                             //then our int that we're using for this loop
  102.         ldelem.ref                                          //unsure how to explain this but basically does like 'ldstr ldarg.0[i]'
  103.         ldstr "\n"                                          //pushes a new line as well
  104.         call string [mscorlib]System.String::Concat(string, string, string) //will append all the string together
  105.         stloc output                                        //stores that string into output
  106.         ldloc i                                             //loads i
  107.         ldc.i4 1                                            //loads 1
  108.         add                                                 //adds them together
  109.         stloc i                                             //stores back into i, like i += 1
  110.         ldloc i                                             //loads i
  111.         ldarg.0                                             //loads arg 0
  112.         ldlen                                               //gets the length of the array
  113.         clt                                                 //conditional operator, if i < len(arg.0) do...
  114.         brtrue loop_s                                       //if true, branches to top of the loop and repeats
  115.        
  116.         ldsfld class [PS3Lib]PS3Lib.PS3API Test.Program::PS3//been through all this..
  117.         callvirt instance class [PS3Lib]PS3Lib.Extension [PS3Lib]PS3Lib.PS3API::get_Extension()
  118.         ldc.i4 0x02056B04
  119.         ldloc output
  120.         callvirt instance void [PS3Lib]PS3Lib.Extension::WriteString(uint32, string)
  121.        
  122.         ret
  123.     }
  124.     .method public static void ToggleText(int32) cil managed
  125.     {
  126.         .locals init([0] char input)
  127.        
  128.         ldc.i4 3                                            //pushes 3
  129.         stloc input                                         //stores 3 into input, input = 3
  130.        
  131.         ldc.i4 1                                            //push 1
  132.         ldarg.0                                             //loads arg 0, our int
  133.         ceq                                                 //checks if equal
  134.         brtrue end                                          //if our int is equal to 1, branches to end
  135.        
  136.         ldc.i4 2                                            //pushes 2 to stack
  137.         stloc input                                         //stores 2 into input
  138.        
  139.         end:
  140.         ldsfld class [PS3Lib]PS3Lib.PS3API Test.Program::PS3
  141.         callvirt instance class [PS3Lib]PS3Lib.Extension [PS3Lib]PS3Lib.PS3API::get_Extension()
  142.         ldc.i4 0x2057217                                    //loads address
  143.         ldloc input                                         //loads our variable, input
  144.         callvirt instance void [PS3Lib]PS3Lib.Extension::WriteByte(uint32, uint8)//writes it to memory
  145.         ret                                                 //returns nothing
  146.     }
  147.     .method public static void SelectOption(int32) cil managed
  148.     {
  149.         ldarg.0                                             //load arg 0
  150.         ldc.i4 0                                            //push 0
  151.         ceq                                                 //compares
  152.         brtrue dogodmode                                    //if equal goes to godmode
  153.        
  154.         ldarg.0                                             //repetitive, so skipping this stuff.
  155.         ldc.i4 1
  156.         ceq
  157.         brtrue option1
  158.        
  159.         ldarg.0
  160.         ldc.i4 2
  161.         ceq
  162.         brtrue option2
  163.        
  164.         ldarg.0
  165.         ldc.i4 3
  166.         ceq
  167.         brtrue option3
  168.        
  169.         ldarg.0
  170.         ldc.i4 4
  171.         ceq
  172.         brtrue option4
  173.        
  174.         ldarg.0
  175.         ldc.i4 5
  176.         ceq
  177.         brtrue option5
  178.                
  179.         dogodmode:
  180.         ldsfld class [PS3Lib]PS3Lib.PS3API Test.Program::PS3
  181.         callvirt instance class [PS3Lib]PS3Lib.Extension [PS3Lib]PS3Lib.PS3API::get_Extension()
  182.         ldc.i4 0x1185D08
  183.         ldc.i4 0x38607FFF
  184.         callvirt instance void [PS3Lib]PS3Lib.Extension::WriteUInt32(uint32, uint32)
  185.        
  186.         ldsfld class [PS3Lib]PS3Lib.PS3API Test.Program::PS3
  187.         callvirt instance class [PS3Lib]PS3Lib.Extension [PS3Lib]PS3Lib.PS3API::get_Extension()
  188.         ldc.i4 0x1185D0C
  189.         ldc.i4 0xB07F00B4
  190.         callvirt instance void [PS3Lib]PS3Lib.Extension::WriteUInt32(uint32, uint32)
  191.        
  192.         ldstr "Enabled godmode!"
  193.         call void [mscorlib]System.Console::WriteLine(string)
  194.         ret
  195.        
  196.         option1:
  197.         ldstr "Selected option 1"
  198.         call void [mscorlib]System.Console::WriteLine(string)
  199.         ret
  200.        
  201.         option2:
  202.         ldstr "Selected option 2"
  203.         call void [mscorlib]System.Console::WriteLine(string)
  204.         ret
  205.        
  206.         option3:
  207.         ldstr "Selected option 3"
  208.         call void [mscorlib]System.Console::WriteLine(string)
  209.         ret
  210.        
  211.         option4:
  212.         ldstr "Selected option 4"
  213.         call void [mscorlib]System.Console::WriteLine(string)
  214.         ret
  215.        
  216.         option5:
  217.         ldstr "Selected option 5"
  218.         call void [mscorlib]System.Console::WriteLine(string)
  219.         ret
  220.     }
  221.     .method public static void Controller() cil managed
  222.     {
  223.         .locals init([0] int32 button, [1] string[] strings, [2] int32 option, [3] int32 isopen)    //our variables, yeah already explained this
  224.        
  225.         ldc.i4 6                                            //pushes 6
  226.         newarr string                                       //will make a string array with length of 6
  227.         stloc strings                                       //stores into our strings variable. ex: string[] strings = new string[6] in c#
  228.        
  229.         ldloc strings                                       //loads our variable
  230.         ldc.i4 0                                            //pushes 0
  231.         ldstr "God mode"                                    //pushes our string
  232.         stelem.ref                                          //stores our string into our array, ex: strings[0] = "God mode"
  233.        
  234.         ldloc strings
  235.         ldc.i4 1
  236.         ldstr "Option 1"
  237.         stelem.ref
  238.        
  239.         ldloc strings
  240.         ldc.i4 2
  241.         ldstr "Option 2"
  242.         stelem.ref
  243.        
  244.         ldloc strings
  245.         ldc.i4 3
  246.         ldstr "Option 3"
  247.         stelem.ref
  248.        
  249.         ldloc strings
  250.         ldc.i4 4
  251.         ldstr "Option 4"
  252.         stelem.ref
  253.        
  254.         ldloc strings
  255.         ldc.i4 5
  256.         ldstr "Option 5"
  257.         stelem.ref
  258.        
  259.         loops:
  260.         call int32 Test.Program::getButton()                //gets the button we're pressing
  261.         stloc button                                        //stores into button
  262.        
  263.         ldloc strings                                       //loads our strings that we just made into an array
  264.         ldloc option                                        //pushes our option
  265.         call void Test.Program::DrawText(string[], int32)   //will draw our text
  266.        
  267.         ldc.i4 0                                            //push 0/false
  268.         ldloc isopen                                        //pushes isopen, one of our variables
  269.         ceq                                                 //check if equal
  270.         brtrue monitorup                                    //if menu isn't open, branch to monitorup
  271.        
  272.         ldloc button                                        //pushes our button that we press onto stack
  273.         ldc.i4 0x00000040                                   //this is the "index" for x button
  274.         ceq                                                 //compares
  275.         brtrue pressingx                                    //if x is pressed, branches to pressingx
  276.        
  277.         ldloc button                                        //skipping the rest
  278.         ldc.i4 0x00100000
  279.         ceq
  280.         brtrue pressingup
  281.        
  282.         ldloc button
  283.         ldc.i4 0x00400000
  284.         ceq
  285.         brtrue pressingdown
  286.        
  287.         ldloc button
  288.         ldc.i4 0x00000080
  289.         ceq
  290.         brtrue pressingsquare
  291.         br end
  292.        
  293.         pressingup:                                         //label for where we branch to
  294.         ldloc option                                        //loads our option
  295.         ldc.i4 0                                            //pushes 0
  296.         ceq                                                 //compares the two, this is so we don't like scroll to option -1, which doesnt exist
  297.         brtrue end                                          //if we're at option 0, will branch to end and
  298.         ldloc option                                        //otherwise pushes our value
  299.         ldc.i4 -1                                           //pushes -1
  300.         add                                                 //adds them together
  301.         stloc option                                        //stores back into option, like option -= 1. yeah ik I could use sub as well.
  302.         ldc.i4 200                                          //pushes 200
  303.         call void [mscorlib]System.Threading.Thread::Sleep(int32)   //sleeps for 200 ms
  304.         br end                                              //branch to end
  305.        
  306.         pressingdown:
  307.         ldloc option                                        //pushes our option num
  308.         ldloc strings                                       //pushes our strings
  309.         ldlen                                               //gets length of the array
  310.         ldc.i4 -1                                           //pushes 1
  311.         add                                                 //subtracts 1 from our length
  312.         ceq                                                 //compares
  313.         brtrue end                                          //if equal, branch to end
  314.         ldloc option                                        //loads option
  315.         ldc.i4 1                                            //push 1
  316.         add                                                 //adds the two
  317.         stloc option                                        //stores to option
  318.         ldc.i4 200                                          //push 200
  319.         call void [mscorlib]System.Threading.Thread::Sleep(int32)   //sleeps for 200ms
  320.         br end                                              //branch to end
  321.        
  322.         pressingx:                                          //rest of this should be understandable if you even made it this far
  323.         ldloc option
  324.         call void Test.Program::SelectOption(int32)
  325.         ldc.i4 100
  326.         call void [mscorlib]System.Threading.Thread::Sleep(int32)
  327.         br end
  328.        
  329.         pressingsquare:
  330.         ldc.i4 0
  331.         stloc isopen
  332.         ldc.i4 0
  333.         call void Test.Program::ToggleText(int32)
  334.         ldstr "Closed menu!"
  335.         call void [mscorlib]System.Console::WriteLine(string)
  336.         ldc.i4 100
  337.         call void [mscorlib]System.Threading.Thread::Sleep(int32)
  338.         br loops
  339.        
  340.         end:
  341.         ldc.i4 1                                //push 1
  342.         call void Test.Program::ToggleText(int32)//shows text, like toggletext(true)
  343.         ldc.i4 0
  344.         ldloc isopen
  345.         ceq
  346.         brtrue monitorup                        //checks if menu isn't open, if not, branches to monitor up button so we can re open it
  347.         br loops                                //branches back to top of loop
  348.        
  349.         monitorup:                              //already explain
  350.         ldloc button
  351.         ldc.i4 0x00100000
  352.         ceq
  353.         brtrue openmenu
  354.         br loops
  355.        
  356.         openmenu:                               //should be able to understand.
  357.         ldc.i4 1
  358.         stloc isopen
  359.         ldstr "Opened menu!"
  360.         call void [mscorlib]System.Console::WriteLine(string)
  361.         br loops
  362.     }
  363. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement