Difference between revisions of "UVSGXOR"

From Prevue Guide Wiki
Jump to navigation Jump to search
m (Reverted edits by YRUPOOPBANANS (Talk) to last revision by AriX)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
Shove it up your ass, since you are not allowed to see this page.  
+
This code simply returns the initial checksum of a UVSG command, provided you (1) give it a sample command that ends in $00 <checksum> and (2) strip off the 55 AA at the beginning. It's probably poorly written, but it works.
  
[[File:IPRC_Seized_2010_11.gif]]
+
<code>
 +
#import <stdio.h>
 +
 +
int main(int argc, char *argv[]) {
 +
    int i=0, j, checksum;
 +
    char *buf = "<PUT AN EXAMPLE COMMAND HERE>";
 +
    char *hexPtr = buf;
 +
   
 +
    unsigned int *result = calloc(strlen(buf)/2 + 1, sizeof *result);
 +
    while (sscanf(hexPtr, "%02x", &result[i++])) {
 +
        hexPtr += 2;
 +
        if (hexPtr >= buf + strlen(buf)) break;
 +
    }
 +
   
 +
    for (j = i; j > -1; j--) {
 +
        if (j == (i-1)) {
 +
            checksum = (int)result[j];
 +
        }
 +
        if (j < (i-1)) {
 +
            checksum = checksum ^ (int)result[j];           
 +
        }
 +
    }
 +
   
 +
    printf("\n%02x\n", checksum);
 +
}
 +
</code>

Latest revision as of 13:43, 25 January 2011

This code simply returns the initial checksum of a UVSG command, provided you (1) give it a sample command that ends in $00 <checksum> and (2) strip off the 55 AA at the beginning. It's probably poorly written, but it works.

#import <stdio.h>

int main(int argc, char *argv[]) {
   int i=0, j, checksum;
   char *buf = "<PUT AN EXAMPLE COMMAND HERE>";
   char *hexPtr = buf;
   
   unsigned int *result = calloc(strlen(buf)/2 + 1, sizeof *result);
   while (sscanf(hexPtr, "%02x", &result[i++])) {
       hexPtr += 2;
       if (hexPtr >= buf + strlen(buf)) break;
   }
   
   for (j = i; j > -1; j--) {
       if (j == (i-1)) {
           checksum = (int)result[j];
       }
       if (j < (i-1)) {
           checksum = checksum ^ (int)result[j];            
       }
   }
   
   printf("\n%02x\n", checksum);
}