HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Hacking Jass Natives

01-18-2006, 01:14 AM#1
xttocs
I was able to add my own jass natives to War III with a little hacking and an extra dll. Not sure how useful people may find this...

Anyone interested?
01-18-2006, 01:42 AM#2
COOLer
I am what were you able to add anything for PR you know fourm is down?

Howabout reading a text file via jass native would be great?
01-18-2006, 01:46 AM#3
xttocs
Yea I know the forums are down. I can't really do anything about it...
Here's an example of me adding a native using the top level of abstraction:
Code:
// native xGetStr takes nothing returns string
int __stdcall xGetStr(char *n)
{
	return jMapStringToGame("testing fools");
}

// Called by the engine when native need to be initialized
void jInitializing()
{
	jAddNative(xGetStr, "xGetStr", "()S");
}

Map JASS:
Code:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    call DisplayTextToForce( GetPlayersAll(), xGetStr() )
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Untitled_Trigger_001, Player(0), "x", false )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction
What kinda natives do you want me to add? Get on IRC if you wanna talk 'bout it.
01-18-2006, 01:49 AM#4
COOLer
Im having irc problem i cant connect.
If you could get file reading natives get file path and returns all text in file or one line would be great. Also writing to a file would be great as well. my im is cooler2000k
01-18-2006, 05:47 AM#5
PitzerMike
Great breakthrough, xttocs!

May the native requests begin :)
01-18-2006, 06:54 AM#6
Jazradel
That is extremely cool. How about a native to get the damage of a unit? Or even better a explanation of how to do this.
01-18-2006, 07:13 AM#7
Extrarius
Personally, I think we should use the information xttocs figured out to make a metamod that has natives like 'LoadModDLL' so a map could come with DLLs (in the MPQ) and the base mod could open the map file, extract the dll, and load them as part of the mod. Of course, it should have some kind of dialog pop up asking the user if they want to allow it.
Or maybe instead of including the functions in the map, we could make a mod dll website and the base mod could connect and download a dll (to update it or if the user doesn't have it) and run it, and only certain authorized people could have access to upload dlls (to prevent random people from putting viruses etc into dlls).

Anyways, you get the idea - there could be a framework for making real use of this in a generic way so that each map doesn't need it's own special loader, custom libraries (unless it needs something new, but we could make tons of standard stuff in different modules like HTTP access for storing character codes, a dictionary type that stores data directly associated with a handle with no need for all kinds of conversions), etc.

Oh, also, the mod should disable all the options on battle.net for ladder play, since it'll probably be detected as some kind of cheat or something and users wouldn't use it if it caused anybody to get banned (but I think the cheat detection doesn't apply to custom games, right?).

I wonder if blizzard would finally get around to adding some natives if all they have to do is copy/paste =-P
01-18-2006, 11:36 AM#8
xttocs
Code:
int charmap[256] = {
	0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 
	23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
	43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
	63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
	83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
	102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
	118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133,
	134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
	150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165,
	166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181,
	182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
	198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213,
	214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
	230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245,
	246, 247, 248, 249, 250, 251, 252, 253, 254, 255};

// native xTranslate takes string input returns string
jString jNATIVE xTranslate(jString input, char *n)
{

	char *r = jGetString(input);
	char *c = r;
	while (*c != '\0')
		*c++ = charmap[*c];

	return jMapString(r);
}

void jInitializing()
{

	charmap['a'] = charmap['A'] = '4';
	charmap['e'] = charmap['E'] = '3';
	charmap['l'] = charmap['L'] = '1';
	charmap['o'] = charmap['O'] = '0';
	charmap['s'] = charmap['S'] = '5';
	charmap['t'] = charmap['T'] = '7';

	jBindNative(xTranslate, "xTranslate", "(S)S");
}
=)
They can already add their natives just as easily as I add then with my code. You can also make natives that return units, abilities, etc... anything that a real native can do. But if you're going to return a unit you probably need to do some more hacking into the game engine. Anyways, I'll release my source soon.
01-18-2006, 12:40 PM#9
Nantuko Husk
This is cool stuff. Although I wonder if we are limitted again?

so for example , can you do what vex dreams everynight? to change item tooltips at gametime?
01-18-2006, 12:59 PM#10
Zoxc
Quote:
Originally Posted by Extrarius
Personally, I think we should use the information xttocs figured out to make a metamod that has natives like 'LoadModDLL' so a map could come with DLLs (in the MPQ) and the base mod could open the map file, extract the dll, and load them as part of the mod. Of course, it should have some kind of dialog pop up asking the user if they want to allow it.
Or maybe instead of including the functions in the map, we could make a mod dll website and the base mod could connect and download a dll (to update it or if the user doesn't have it) and run it, and only certain authorized people could have access to upload dlls (to prevent random people from putting viruses etc into dlls).

Anyways, you get the idea - there could be a framework for making real use of this in a generic way so that each map doesn't need it's own special loader, custom libraries (unless it needs something new, but we could make tons of standard stuff in different modules like HTTP access for storing character codes, a dictionary type that stores data directly associated with a handle with no need for all kinds of conversions), etc.

Oh, also, the mod should disable all the options on battle.net for ladder play, since it'll probably be detected as some kind of cheat or something and users wouldn't use it if it caused anybody to get banned (but I think the cheat detection doesn't apply to custom games, right?).

I wonder if blizzard would finally get around to adding some natives if all they have to do is copy/paste =-P

Who will make the first map virus? ^^

It might be possible to use it thought local player to prevent natives to be used on DLL less WC3 installation. If not WC3 check the script first.

Instead of using a custom DLL we might make a scripting engine to create our own natives, with only limted harddisk access, and many restrictions. (To prevent virues) That might be stored in the map (or on a server if we don't find a way to read map MPQ)

Maybe we can make natives to emulate a hashtable for each unit.
01-18-2006, 01:26 PM#11
AnarkiNet
i'm pretty leery of executable code stored inside maps or mods. As far as i know, there is no virus scanner that exists yet which can scan inside mpq archives like some scan inside zips and such.
01-18-2006, 01:29 PM#12
Zoxc
Well AV's don't know any WC3 viruses so even if it could can MPQ files, it wouldn't find anything. If it knew these viruses, it would surely have a outdated listfile. (Thanks to Vex most of the better maps don't have a listfile)
01-18-2006, 01:35 PM#13
Jacek
Hack wc3c? Great
01-18-2006, 01:50 PM#14
Blade.dk
Hacking wc3c is not great, Jacek.

This seems like an interesting discovery, I'm sure this will be useful for something.
01-18-2006, 02:02 PM#15
Jacek
-.-