A hack file is just a simple zip with the following files:
-metadata*
-C++ header or source files.
What files do PolyLoader 3.* recognize as Source files?
Any file with the extension of ".cpp", ".c", or ".cc" are recognized as source files.
What files do PolyLoader 3.* recognize as Header files?
Any file with the extension of ".hpp", ".h", or ".inl" are recognized as source files.
So how do I make a hack file?
Step 1, modify your source code.
The PolyLoader uses a few tags to understand your file:
[swap_lines][/swap_lines] - Swap the lines between the 2 tags, useful for randomizing a structure.
Code:
struct Entity {
[swap_lines]
DWORD dwBase;
int id;
int hp;
int team;
int weapon_id;
int weapon_ammo;
[/swap_lines]
};
[junk_enable /] - Enables auto junk code addition, the PolyLoader will add junk code after every ;
You can give it 1 or 2 parameters
[junk_enable 5 /] - Will add 5 lines of junk code after every ;
[junk_enable 5 10 /] - Will add 5 to 10 lines of junk code after every;
[junk_disable /] - Disables auto junk code addition.
[junk_enable_declares /] - The auto junk code generator will now only make declares (useful for in header files).
[junk_function 5 /] - Will add 5 randomized functions
[junk_function 5 10 /] - Will add 5 to 10 randomized functions.
[add_junk /] - Adds a block of junk code at this position, it does NOT take junk_enable_declares into account.
[swap_blocks][/swap_blocks] - Works like swap_lines but instead it swaps blocks of code.
[block][/block] - Define a block
Code:
[swap_blocks]
[block]
if (x == 5) {
std::cout << "x == 5\n";
}
[/block]
[block]
if (y == 7) {
std::cout << "y == 7\n";
}
[/block]
[/swap_blocks]
[enc_string_enable /] - Scrambles all strings, when you are using this make sure you have Decrypt.h included (the loader will generate a randomized Decrypt.h file).
[enc_string_disable /] - Disables the auto string scrambler.
[enc_string_push /] - Pushes the current state to a stack, this is the recommended way to use enc_string_enable and enc_string_disable.
[enc_string_pop /] - Pops from the stack, then setting the current enc_string state to whatever was on the stack.
Example:
Code:
// at this point enc_string is disabled.
[enc_string_enable /]
// now it is enabled.
// however, if you didn't know if enc_string is currently enabled, or disabled, you might ruin the encryption for the rest of the file if, for example, you assume it is enabled.
// therefor the push/pop mechanic has been added, it is the encouraged way of using enc_string.
[enc_string_push /] // the state of enc_string [enabled] is pushed onto the stack.
[enc_string_disable /] // Now for this region encryption will be enabled.
// do shit
[enc_string_pop /] // Now we reset it back to it's original state, in this case enabled.
[rand_val /] - Generates a random value of any PolyEngine type.
[rand_val
type /] - Generates a random value of type
type.
[func_decl
function_name /] - Declares a PolyEngine function, this must be done to use
arg_* tags! (See usage later)
[arg_tuple
function_name /] - Generates a tuple of arguments, this is to be used in the declaration of a function
only.
[arg_tuple_put
function_name /] - Generates a set of arguments to be inserted for when you call a
func_decl'd function.
The following are only to be used within a function that has been declared using
[func_decl]:
[arg_tuple_use
function_name /] - Generates random code using the arguments from the tuple_set.
[arg_tuple_if
function_name type] - A parse-time if statement, use this to determine wether a desired type exists in the generated arg_tuple.
[/arg_tuple_if] - End the current
arg_tuple if statement.
[arg_tuple_rand
function_name type /] - Selects a random argument from the argument tuple in desired function. Only picked if the argument's type is
type. See
Types section for available types.
[arg_tuple_rand
function_name /] - Equivalent to [arg_tuple_rand
function_name Any /].
Types
There are 4 main data-types that PolyEngine uses, they can be seen as the following:
PolyEngine Macro Name <-> C++ Representation
Code:
Int <-> int
Char <-> char
String <-> std::string
Any <-> Any of the above.
Simple example using all the features above.
Code:
#include <iostream>
#include <string>
#include <Windows.h>
struct Entity
{
[swap_lines]
DWORD dwBase;
int id;
int hp;
int team;
int weapon_id;
int weapon_ammo;
[/swap_lines]
};
[enc_string_enable /]
[junk_enable 5 10 /]
void [func_decl function /]( int a, int b, [arg_tuple function /] )
{
std::cout << "a : " << a << " b : " << b << std::endl;
[arg_tuple_if function String]
std::cout << "random string: " << [arg_tuple_rand function Any /] << std::endl;
[/arg_tuple_if]
[arg_tuple_use function /]
// add_junk
[add_junk /]
// Swapping blocks
auto x = [rand_val Int /];
auto y = [rand_val Int /];
[swap_blocks]
[block]
if ( x == 5 )
{
std::cout << "x == 5\n";
}
[/block]
[block]
if ( y == 7 )
{
std::cout << "y == 7\n";
}
[/block]
[/swap_blocks]
}
void main( )
{
function( 10, 15, [arg_tuple_put function /] );
std::cin.get( );
}
[junk_function 1 /]
A possible outcome, would be the following:
https://pastebin.com/EVwUzfVC
metadata*
Here's an example of the new 'metadata' parser, which is the new encouraged way to define your command parameters, input, and output filenames:
Code:
// The PolyLoader version
version: 3.0
// The message displayed in File information, write a short description.
message: Hello MPGH!\nThis is just a test.
// The command line arguments given to vcvars32.bat, they can be the same as before except it is encouraged to skip the /Od flag (Debug).
command: /EHsc /MT *.cpp kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /link /FORCE:MULTIPLE /OUT:hack.exe
// set input as the specified /OUT flag
input: hack.exe
// Set output to what you want your distributed executabl as.
output: MPGH Test.exe
// Now you can also set HTML messages, like so:
// make sure html parsing is enabled
html: true
message: <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://use.fontawesome.com/f4250ed340.js"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway:200"> <link rel="stylesheet" href="https://i.yemiez.com/assets/css/gallery.css"> </head> <body> <button class="g-btn rest" poly-onclick="https://mpgh.net/"> <i class="fa fa-external-link"></i> Release thread </button> <br>Or if the above button doesn't work, <a href="https://www.mpgh.net/">press here</a> </body> </html>
// Note that links only work inside of an <a> tag or using the "poly-onclick" attribute.
// Files should now also be excluded using the exclude command.
exclude: file1.cpp
exclude: file1.h
// This does not exclude the file from compilation, only randomization.
// It is also encouraged to enter the date you released your file in, for simplicity there are 3 variables for it.
release-year: 2017
release-month: 01
release-day: 21
// set tasks
// This set the current 'TaskTypeState' to inlined C# code.
task-type: cs
// All the C# code must be on the same line if you use the cs tag.
// I'd recommend using cs-file and instead adding a file.
task. using PolyPlugin; namespace Test { class Hey : Plugin { public string GetAuthor() { return "Yemiez"; } public string GetName() { return "Hey"; } public string GetCompany() { return ""; } public void InitializePlugin(CSPluginManager pm) { pm.PolyNotification( "Hello world!", "Hey!" ); } public void Dispose() { } } };
// And this is how east it is to use a file instead.
task-type: cs-file
task: mycsfile.cs
// And that's it for the metadata file.
The above example could output the following when loaded:
And this as the developer message: