Ads

Saturday 26 October 2013

Data Structures and Problem Solving "WORKING" PROGRAMS

AVL with file handling

AVL program with file handling.

https://drive.google.com/file/d/0BxZLLe3YK34xWE1qWE5FNlVnbkU/edit?usp=sharing

CREDITS -Omkar Patil

Root Your Android device #2

Hey there,
(This is just to clarify confusing terms)
Some people dont root there phones because they find it extremely complicated or dont understand the terms well, or are too afraid to take chances.
Well below i have explained a few terms which are normally used by android “FREAKS”

So when the first time you try rooting you’ll come across some “wierd terms”,
So lets get clear about what they are,
  1. Rooting
  2. Jailbreaking
  3. Rom
  4. NAND and Nandroid
  5. Operating System
  6. Mod(e.g. Cyanogenmod)
  7. Recovery(ClockworkMod, Amon Ra)
  8. Custom Kernel(e.g.Siyah Kernel->provides dual boot opt)
  9. Firmware
  10. Driver
  11. Over The Air(OTA)
  12. Fastboot
  13. Flashing

So this is the basic list, if ive missed out any more confusing terms just let me know.


Ive already explained rooting, just refer to post #1 rooting android phone.

Rooting and Jailbreaking are essentially the same things, Jailbreaking is the iPhone users' word for what Android users call Rooting. Rooting is when you gain "Root" access to the phone giving you the power to do anything you want to it. Normally you're prevented from being Root for your own good, as it's very easy to break your phone once you have root access, and quite hard to break it without.
Nandroid backup is a backup of your phone that is an exact image of the state of your phone. So you could make an exact copy of your current phone, then do major changes to it, and then restore to your previous backup by flashing the backup back to the phone. 

Flashing means to copy or to install.... you are essentially wiping the device and restoring a previous state (a backup) or you are flashing a new ROM. NAND is your device's flash storage, which is why copying files there is called "flashing".

The Android operating system is the software that manages the hardware in an Android phone such as the screen, data communications, storage, camera and GPS. It provides a common layer that allows applications the use of and access to these resources on a range of different devices without the app having to know anything special about the actual hardware that it is running on. The Android Operating System also includes a number of standard apps and services such as the Contacts, Camera, Photo Gallery and web browser apps and allows the user to do such things as control the screen brightness or connect to wifi networks.

Although the real definitions are different, in the Android world, ROMModCustom Kernel andFirmware are all used as if they mean essentially the same thing. They all refer to a customised version of the Android operating system that has been modified to work on a particular brand of phone with a specific set of customisations or changes. This can be done so that an old phone like the SGGS2 can be given a brand new version of Android, such as give it the XPERIA Z look, even if the manufacturer has decided not to provide it. Or could be to provide extra functionality not available in the manufacturer's supplied version of Android, or to fix problems in the manufacturer supplied version.
Driver is what tells the Android software operating system how to talk to all the different hardware that is in an Android phone. When someone is putting together a ROM for a particular phone model they will need to include of all that phone's drivers inside the ROM (for things like the cellular modem, WiFi access, the particular camera type, the specific processor, etc) otherwise the ROM either won't work on that phone, or will only be able to work certain parts of the phone and, for instance, may not be able to use the front-facing camera, or may not be able to connect to a WiFi network. This is exactly the same as when you plug something new into Windows and it runs the New Hardware Added wizard and goes looking for a new driver before you can use it.

An Over The Air (OTA) update is when your phone receives an update to its Android operating system "over the air", ie it is sent the files automatically over the cellular network from either Google or from your phone network without ever needing to be plugged into a PC. This contrasts with the way that, for example, the iPhone is updated where it has to be physically plugged into a computer running iTunes to get its updates.

The bootloader controls how the device boots. Google's PC-side tool for getting into the bootloader and other related tasks is called Fastboot, and running the bootloader interactively may be called "Fastboot mode". A locked bootloader will verify the Android system partition and restore it to stock if it doesn't match, whereas an unlocked bootloader doesn't do the same checking, which is why unlocking the bootloader is required to permanently root a device.

The bootloader may also play some part in flashing firmware, though this is usually part of recovery. While you normally don't want to mess with the bootloader, advanced users will often flash a custom recovery like ClockworkMod (though a locked bootloader may prevent this). This allows one to flash firmware that hasn't been signed by the manufacturer (such as custom ROMs), since stock recovery usually checks for the signature, and do advanced tasks like complete Nandroid backups. Recovery is a bit like the BIOS boot screen on PCs in that you get to it by pressing a special combination of buttons as the phone starts up. Recovery can also do things like run an update file from the phone's SD card, or let you connect from a PC via ADB (Android Debug Bridge) to manage the device from the command line.



CREDITS- MBPV

Wednesday 16 October 2013

Rooting Your Android Phone #1

Some people have been asking around about how to root there android device and what is the advantage of rooting your phone.

Well for starters ill just explain what is rooting, its risks and advantages.

The first question that arises from a die hard android fan when they get hold of a new device is "how do i root it?".
WHAT IS ROOTING?-
Rooting a phone is the process of gaining root access of your device's O.S and provides you with full control, pretty simple definition . Obviously everything you do has some risks.
Every one hate the BLOATWARE, which clog up most network locked phones, apps you neither want or need, but can't delete because they're baked in the O.S. With a rooted phone you can get rid of them fast.
A rooted phone also lets us install custom versions of android also known as ROMS, which can bring all kinds of benefits -zero bloatware, smaller size, faster performance and a newer Android version not yet available from your phone provider.

THE RISKS INVOLVED-
You can take it to d bank tha t rooting your phone will void your warranty. although you can fool the representatives like i've done countless times :P. 
Though the odds are small, rooting gone wrong can come with a heavy price, it can damage your phone beyond repair( in other words your phone will be useless brick). 

BACKUP BEFORE YOU FLASH-(if you didn't do this,then my friend you just made a huge mistake)
You also need to back up your phone before you flash a new ROM. Flashing ROMs requires your phone’s flash storage to be wiped, so you need to back up everything — files, apps, contacts, SMSs, emails, the whole shebang — as they won’t be there when you launch your new ROM.
First, install MyBackup Root from Google Play. It’s an easy-to-use app for backing up your data. For backing up apps, the best option is Titanium Backup. It’s also free from Google Play. Other apps like SMS Backup and Restore are worth a look and don’t forget Google’s own Sync option.
And most importantly, don’t leave your backups on the phone storage — copy them to your computer.

ADVANTAGES OF ROOTING-
Android is one of the most open, versatile, and customizable mobile operating systems out there. You may think you don't need to root your phone, but you'd be surprised at how much more you can accomplish with a little work here. Here are 10 reasons rooting your phone is worth the hassle.
10.Unlock Hidden Features and Install "Incompatible" Apps
9. Automate Everything
8. Boost Your Phone's Speed and Battery Life
7. Block Ads in Any App
6. Back Up Your Phone for Seamless Transitions
5. Remove Preinstalled Crapware
4. Tweak the Dark Corners of Android
3. Flash a Custom Kernel
2. Flash a Custom ROM
1. Truly Own Your Device


PROCESS-
The process of rooting varies widely by device, but usually includes exploiting a security bug(s) in the firmware (i.e. in Android) of the device, and then copying the su binary to a location in the current process's PATH (e.g. /system/xbin/su) and granting it executable permissions with the chmod command. A supervisor application like SuperUser or SuperSU can regulate and log elevated permission requests from other applications. Many guides, tutorials, and automatic processes exist for popular Android devices facilitating a fast and easy rooting process.
For example, shortly after the HTC Dream was released, it was quickly discovered that anything typed using the keyboard was being interpreted as a command in a privileged (root) shell. Although Google quickly released a patch to fix this, a signed image of the old firmware leaked, which gave users the ability to downgrade and use the original exploit to gain root access. Once an exploit is discovered, a custom recovery image that skips the digital signature check of a firmware update package can be flashed. In turn, using the custom recovery, a modified firmware update can be installed that typically includes the utilities (for example the Superuser app) needed to run apps as root.
The Google-branded Android phones, the Nexus One, Nexus S, Galaxy Nexus and Nexus 4, as well as their tablet counterparts, the Nexus 7 and Nexus 10, can be boot-loader unlocked by simply connecting the device to a computer while in boot-loader mode and running the Fastboot program with the command "fastboot oem unlock". After accepting a warning, the boot-loader is unlocked, so a new system image can be written directly to flash without the need for an exploit.
Recently, Motorola, LG Electronics and HTC added security features to their devices at the hardware level in an attempt to prevent users from rooting retail Android devices. For instance, the Motorola Droid X has a security boot-loader that puts the phone in "recovery mode" if a user loads unsigned firmware onto the device, and the Samsung Galaxy S II displays a yellow triangle indicator if the device firmware has been modified
CHOOSE YOUR ROM CAREFULLY-
There are ROMs available for every phone, so it’s important you select a ROM that’s designed for your specific model. We can’t stress this enough. For example, ‘Galaxy S2’ is the generic name for up to five different models: the GT-I9100, GT-I9100G, GT-I777, SGH-T989 Hercules and Skyrocket. If you have a GT-I9100 (it’s shown on the Samsung splash screen when you boot up), you can’t use a ROM meant for the GT-I9100G because they’re not the same phone under the bonnet.

MORE ARTICLES WILL COME UP SHORTLY FOR DIFFERENT PHONES OF DIFFERENT BRANDS(ONLY POPULAR PHONES)

IF YOU HAVE ANY DOUBTS FEEL FREE TO ASK US.
CREDITS- M.B.P.V


Friday 11 October 2013

Microprocessor Architecture 5 changed OUTPUT

-------------------------------------------------------

SECTION .data
regmsg db 10,"REGISTER ADDRESSING MODE",10
regmsg_1 equ $-regmsg
immsg db 10,"IMMEDIATE ADDRESSING MODE",10
immsg_1 equ $-iimsg
memmsg db 10,"MEMORY ADDRESSING MODE",10
memmsg_1 equ $-memmsg

SECTION . bss
result resd 8
mem resd 8

%macro disp 2
mov eax,4
mov ebx,1
mov ecx,%1
mov edx,%2
int 80h
%endmacro

SECTION .text
 global _start
_start:

disp immsg,immsg_1
mov eax,10h
mov dword[result],eax
call disp32_proc

disp regmsg,regmsg_1
mov ebx,10h
mov eax,ebx
mov dword[result],10h
call disp32_proc

exit:
mov eax,1
mov ebx,0
int 80h

disp32_proc:

mov esi,result+7 ;load last byte address of result buffer in esi
mov ecx,8  ;number of digits
cnt: mov edx,0;make edx=0(as in div instruction)
mov ebx,16
div ebx
cmp dl,09h;check for remainder in edx
jbe add30
add dl,07h
add30:
add dl,30h;cdalcute ASCII code
mov [esi],dl;store it in buffer
dec esi;point to ont byte back

dec ecx;decrement count
jnz cnt;if not zero repeat

disp result,8;display result on screen
ret
--------------------------------------------
OUTPUT:
pict@pict-pc:~$ gedit asgn5.asm&
[1] 1910
pict@pict-pc:~$nasm -f elf asgn5.asm
pict@pict-pc:~$ld -oasgn5.o
pict@pict-pc:~$./asgn5
IMMEDIATE ADDRESSING MODE
00000010
REGISTER ADDRESSING MODE
00000010
MEMORY ADDRESSING MODE
00000010
pict@pict-pc:~$

Microprocessor Architecture assignment no 21 ASCII

; display characters and decimal ascii codes from a file
;Assignment no.:
;Name:
;Roll no.:

SECTION .data
    file_name db 'abc.txt'

SECTION .bss
    fd_in resd 1
    filecontent resb 250
    fbuff_len equ $-filecontent
    length_read resd 1


SECTION .text
global _start
_start:
    mov eax,5 ;open a file
    mov ebx,file_name
    mov ecx,0
    mov edx,777
    int 80h

; did open succeed?
    test eax, eax
    js exit


    mov dword[fd_in],eax

    mov eax,3 ;read from file
    mov ebx,[fd_in]
    mov ecx,filecontent
    mov edx,fbuff_len
    int 80h
; eax has length actually read
    mov [length_read], eax

    mov esi,filecontent

; point edi to end of file
    mov edi, esi
    add edi, [length_read]

    xor eax, eax ; just to make sure upper bytes are clear
nextnum:
    mov al,byte[esi]

dispnum:
    call showeaxd
    ;mov al, 10 ; linefeed
    ;call putc

    inc esi
    cmp esi, edi
jnz nextnum

    mov eax,6 ; __NR_close
    mov ebx,[fd_in]
    int 80h

; pretend no error
    xor eax, eax

exit:
    mov ebx, eax ; possible error number in ebx
    neg ebx  ; negate it for easier reading with "echo $?"
    mov eax,1
    int 80h

;---------------------------
; print character in al
putc:
    push edx
    push ecx
    push ebx
    push eax ;this serves as our buffer

    mov ecx, esp ; buffer
    mov edx, 1 ; just 1
    mov ebx, 1 ; stdout
    mov eax, 4 ; __NR_write
    int 80h

    pop eax
    pop ebx
    pop ecx
    pop edx
    ret
;------------------------------

;---------------------------------
; showeaxd - print a decimal representation of eax to stdout
; for "debug purposes only"... mostly
; expects: number in eax
; returns; nothing useful
showeaxd:
    push eax
    push ebx
    push ecx
    push edx
    push esi
 
    sub esp, 10h
    lea ecx, [esp + 12]
    mov ebx, 10
    xor esi, esi
 
.top:  
    dec ecx
    xor edx, edx
    div ebx
    add dl, '0'
    mov [ecx], dl
    inc esi
    or eax, eax
    jnz .top
 
    mov edx, esi
    mov ebx, 1
    mov eax, 4
    int 80h
 
    add esp, 10h

    pop esi
    pop edx
    pop ecx
    pop ebx
    pop eax

    ret
;---------------------------------


OUPUT:

[pict@localhost ~]$ nasm -f elf asgn21.asm
[pict@localhost ~]$ ld -o asgn21 asgn21.o
[pict@localhost ~]$ ./asgn21
9710
[pict@localhost ~]$

Data Structures and Problem Solving group C java multithreading

import java.util.*;
import java.util.Random;
class producer extends Thread
{
                 Queue q;
                  producer(Queue q1)
                    {
                        q = q1;
                    }
                   public void run()
                    {
                                 int i;
                         int [] a;
                                                int element;
                    //     while(true)
                      //  {
                             element = q.binarySearch(2);
                        //}
                          //   System.out.println(element);
                                             
                    if (element!=-1)
                    {
                                System.out.println("ELEMENT Found");
                    }
                    else
                    {
                                System.out.println("ELEMENT not Found");
                    }
}
}

 class consumer extends Thread
{
   
    Queue q;
   
    consumer(Queue q1)
    {
        q = q1;
    }
   
    public void run()
    {
        int i;
        int [] a;
                                int element;
      //  while(true)
       // {
                    System.out.println("Thread2 running");
                    System.out.println("enter the elements");
//             Scanner sc=new Scanner(System.in);
//             a[i]=sc.nextInt();
            element = q.binarySearch(67);
       // }
   // System.out.println(element);
    if (element!=-1)
    {
                System.out.println("ELEMENT Found");
    }
    else
    {
                System.out.println("ELEMENT not Found");
    }
    }
   }
   class Queue
 {
               
                int a[];
                // int f,r,n;


                    Queue()
                    {
                        a = new int[5];
                         a[0]=19;
                         a[1]=45;
                         a[2]=56;
                         a[3]=78;
                         a[4]=90;
                      //  n=10;
                     //   f=r=0;
                    }
//                 public void input(  )
//                 {
//                 for(int i=0;i<a.length - 1;i++)
//        {
//             System.out.println("enter the elements");
//             Scanner sc=new Scanner(System.in);
//             a[i]=sc.nextInt();
//        }
//       
//        for(int i=0;i<a.length - 1;i++)
//        {
//             System.out.println("The elements are");
//             Scanner sc=new Scanner(System.in);
//             System.out.println(a[i]);
//        }
//                 }
//                 
                 public int binarySearch(int x  )
  {
      int lowerVal = 0;
      int higherVal = a.length - 1;
      int midVal;
      while( lowerVal <= higherVal )
      {
          System.out.println("Lower val "+lowerVal+ " Higher val "+higherVal  );
          midVal = ( lowerVal + higherVal ) / 2; // Finding mid value using lower value plus higher value divided by two.
          System.out.println("Mid val :"+midVal );
          System.out.println("Search Item  : " + x );
          if( a[ midVal] < 0 ){ // Searching in lower half using compareTo method.
              System.out.println("Searching in lower half : " + lowerVal );
              lowerVal = midVal + 1;
          }
          else if( a[ midVal ] > 0 ){ // Searching in upper half using compareTo method
              higherVal = midVal - 1;
              System.out.println("Searching in upper half : " + higherVal );
          }
          else
              return midVal;
      }

      return -1;     // NOT_FOUND = -1

     }
 }
 
  public class one {

                    public static void main(String[] args)
                    {
                        Queue q1 = new Queue();
                        producer p = new producer(q1);
                        consumer c = new consumer(q1);
                      
                       // q1.input();
                        System.out.println("Thread1 running");
                        p.start();
                   
                        c.start();
                          
                    }

                }




OUTPUT:
Thread1 running
Lower val 0 Higher val 4
Mid val :2
Search Item  : 2
Searching in upper half : 1
Lower val 0 Higher val 1
Mid val :0
Search Item  : 2
Searching in upper half : -1
ELEMENT not Found
Thread2 running
enter the elements
Lower val 0 Higher val 4
Mid val :2
Search Item  : 67
Searching in upper half : 1
Lower val 0 Higher val 1
Mid val :0
Search Item  : 67
Searching in upper half : -1
ELEMENT not Found