FiringSquad: Home of the Hardcore Gamer - Games, Hardware, Reviews and NewsSubmit your own or view users' CPU overclocking results!

  
 Home   News   THE MATRIX   Deals   Hardware   Games   Features   Media   Products   Forums   FS China 
AddThis Social Bookmark Button

Home : Hardware : Video Cards : Benchmarking Ethics and the ATI Radeon
» Join the Greatest Gaming Community NOW! (It's free)

Already a member? Login
 



Random Gallery >> 
Click to view high-res Image!
Grand Theft Auto V August 2012 Screenshots [12] (0)

ENTRY FOR CONTEST (4) by Alexander470
My Entry For The Contest. (6) by D4rk Force
Crank THIS sH!t up! - 3DforREAL (71) by nGAGE
My crank that S#!T up entry (9) by iamcj
Whoz's Cranking that S#!T (13) by whozthisguy
Blow That S#!t Up! (8) by Synchronous Failure
[Entry] Crank That S#!t Up Video Contest (5) by Animehero
CRANG That S#!T Up! (15) by ElwinRansom
[FX] 3-Screen Effect - Guide (part-1) (0) by nGAGE
Drink That S#!t Up! (14) by p4l1ndr0m3

More Blogs >>




Benchmarking Ethics and the ATI Radeon
October 24, 2001   Brandon Sandman Bell > [View My Other Articles]
Kenn Hwang > [View My Other Articles]
Product Info | User Reviews | Article Images(15) | Image Gallery | Comments | Forum Thread
Naming Code

Quack Verification

When we first heard about the "quackifier" program over a week ago, our first impression was one of skepticism. All we knew was that this was a program that purported to change string values in an executable file. When run, it did create a new "quack3.exe" file, but what else did it do? It could have made more changes to the file than its claimed purpose, or even modify existing OpenGL drivers.

While we inquired into the quackifier source, we asked Andrew, our ace Gamers.com developer to create an application from scratch that does the same thing; namely, to search a single file for any string values containing "quake" or "Quake" and rename those to "quack". Within 5 minutes, we had a fully working version, shown below:



import java.io.*;
import java.util.*;

public class Test {

public static void main(String[] args) {

try {
//test string
String str = args[0];
String rep = args[1];
String inFile = args[2];
String outFile = args[3];

System.out.println( "Test String: " + str );
byte[] pattern = str.getBytes();
System.out.println( "Replace with: " + rep );
byte[] replace = rep.getBytes();

//read file into array
BufferedInputStream input = new BufferedInputStream
	(new FileInputStream(inFile));
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int b = input.read();
while (b != -1) {
	buffer.write(b);
	b = input.read();
}
byte [] file = buffer.toByteArray();
buffer.reset();
System.out.println(inFile + " size: " + file.length + " bytes.");

// search thru file & replace
byte [] test = new byte[pattern.length];
for (int i=0; i < file.length; i++) {
	if (file[i] == pattern[0] && (i + pattern.length) <= file.length ) {
		System.arraycopy( file, i, test, 0, pattern.length);
		if (Arrays.equals( pattern, test )) {
			System.out.println("Match at: " + i);
			buffer.write(replace, 0, replace.length);
			i += (pattern.length - 1);
			continue;
		}
	}
	buffer.write(file[i]);
}

byte [] newFile = buffer.toByteArray();
buffer.close();
// write out new file if changed
if (! Arrays.equals(file, newFile) && ! outFile.equals("null")) {
	BufferedOutputStream output = new BufferedOutputStream
		(new FileOutputStream(outFile));
	output.write(newFile, 0, newFile.length);
	output.close();
	System.out.println("Wrote new file: " + outFile);
} else {
	System.out.println("File not written");
}

} catch (Exception e) {
	e.printStackTrace();
}
}

public static void print(byte [] pattern) {
	for (int i=0; i < pattern.length; i++) {
		System.out.print( pattern[i] + " ");
	}
	System.out.println();
	System.out.println();
}
}
The code above was spaced to fit in our page template, but you can download the source and compiled class files here to experiment at home: Now that we have our quack, let's see what it does.

Back! Page 1     Running Quack3 Next!
Blog + Share: Digg Del.icio.us Reddit SU furl • More: AddThis Social Bookmark Button
Send This Article to a Friend!  
Table of Contents
  Print Entire Article  

MATRIX CONTENT » RANDOM MEDIA BLOG More Blogs >>
No ratings yet
» Please rate this
Read this Media-Blog entry!» Crank That PhysX UP! (10)
by mohawkade (35) Talk with this user on their Shout Box (My other blogs) Posted 34 months ago


 Hottest Topics
Two new GRID 2 gameplay trailers speeding your way (1)
Minecraft PC sales surpass the 8 million mark (0)
New Grand Theft Auto 5 trailer debuts main characters (0)
Crysis 3 'The Fields' campaign gameplay trailer (0)
New Far Cry 3 trailer focuses on co-op campaign (0)
Today's News >>
Today's Siteseeing >>


 Table of Contents


 Quick Fact
Download Java from http://java.sun.com


FiringSquad is powered by... Back to Top Site MapContact UsAdvertise With Us Privacy StatementAbout Us  
News RSSSiteseeing RSSArticle RSS   © 1998-2013 FS Media, Inc. All Rights Reserved