Author Topic: Nerd's Corner  (Read 109216 times)

Offline Lambchops

  • Ogre Mage
  • ********
  • Posts: 1541
    • View Profile
Re: Nerd's Corner
« Reply #30 on: February 21, 2017, 03:02:50 AM »
hobby ;)
Heh... ya I've just been looking up some info from old posts. I collect em here so I don't have to search next time...  but OMG that lambchops goes on a bit doesn't he? Every time I look for some thingy I find another I find another 6 pages of his drivel  ;D
its gooder to hax hard and NEVER get caught!

Offline Lambchops

  • Ogre Mage
  • ********
  • Posts: 1541
    • View Profile
Re: Nerd's Corner
« Reply #31 on: February 28, 2017, 12:30:20 AM »
CHANGING THE MINIMAP PLAYER DISPLAY COLORS
(RE: Black to Pink)

I've never really looked at Messiah's black to pink mod, but from what I understand it is an edit of the graphics resources in the game MPQ data.

As far as just changing the color that appears on the mini-map, not the unit graphics here's the relevant info IIRC:

  The black player is rendered using the grey palette entry 0xE4 (228). You can edit this palette entry and change it to pink (or whatever), however this will also change any other pixels on the screen that are that shade of grey, which might look a bit weird.

 The palette entry that is used for each player is stored in an 8 element byte array at 0x004A48CC, this changes from game to game unless the game is fixed order, as the colors are randomly assigned to each player slot at game start.

The minimap black-to-pink in my anticrap prog works by finding the 0xE4 entry in these 8 bytes at the start of each game and writing 0xFD there instead.
its gooder to hax hard and NEVER get caught!

Offline Lambchops

  • Ogre Mage
  • ********
  • Posts: 1541
    • View Profile
Re: Nerd's Corner
« Reply #32 on: February 28, 2017, 04:04:31 AM »
Just had a look at the unit color display (haven't checked out this stuff for years), so its like this:

There are 4 palette entries for each of the 8 player colors that are used to display the units
i.e. 4 shades of red, 4 shades of blue, 4 shades of purple etc...

for 7 of the 8 colors these are all in a block from palette entries D0 thru EB. For some reason the yellow entries are at 0C -> 0F ... which is kinda weird but makes no difference really.

They look like this:



For 5 of the 8 players, the first of these 4 colors is also used for the mini-map color, but for blue, yellow and white the mini-map colors are different.

Here's the actual colors for all of it
Code: [Select]
           MM     UNITS
--------------------------
RED        D0      D0-D3
BLUE       01 *    D4-D7
TEAL       D8      D8-DB
PURP       DC      DC-DF
OJ         E0      E0-E3
BLACK      E4      E4-E7
WHITE      FF *    E8-EB
YELLOW     02 *    0C-0F


It looks like the mini-map colors are taken from a source list at 0x004A48AC

So if you hex edit the WC2 exe at 0xA48B1 you can permenantly set the palette entry for black i.e. you should find 0xE4 at this location, if you change that to 0xFD you will always have pink (just worked for me).

...or if you don't like pink so much you can change this to 0xEA and it will be a lighter shade of grey that much is easier to see than the original mini-map "black" color.

However this begs the question how does Messiah's B2P mod change the mm color if this is hard coded into the exe? I'm guessing there's a "[/]Use default data" thingy somewhere, so if you include modified graphics it will override these default colors.

(EDIT)
or more likely it's just changing the palette colors, but the entry indexes remain unchanged...



« Last Edit: March 25, 2018, 02:29:49 AM by Lambchops »
its gooder to hax hard and NEVER get caught!

Offline Lambchops

  • Ogre Mage
  • ********
  • Posts: 1541
    • View Profile
Re: Nerd's Corner
« Reply #33 on: February 28, 2017, 04:17:48 AM »
Here's what the 0xEA grey looks like on the mini-map



I like it  8)
its gooder to hax hard and NEVER get caught!

Offline Lambchops

  • Ogre Mage
  • ********
  • Posts: 1541
    • View Profile
Re: Nerd's Corner
« Reply #34 on: February 28, 2017, 04:36:06 AM »
Here's a little app that will patch black to grey if you're not into hex editing.
GG
its gooder to hax hard and NEVER get caught!

Offline Incos

  • Axe Thrower
  • ****
  • Posts: 253
    • View Profile
Re: Nerd's Corner
« Reply #35 on: February 28, 2017, 09:57:51 AM »
Very nice follow through lamb. I love it. The gray looks good! Just looks black in game for some reason. Would hexing the war2.exe fix that as well or do you have to Olga through each individual unit and change color
https://www.twitch.tv/incoswc - my twitch. Streaming 9:30pm - 11pm est most days!!

Offline Lambchops

  • Ogre Mage
  • ********
  • Posts: 1541
    • View Profile
Re: Nerd's Corner
« Reply #36 on: February 28, 2017, 06:22:40 PM »
Very nice follow through lamb. I love it. The gray looks good!

Thanks mate  :)

Just looks black in game for some reason

How so? On my screen it looks exactly like the SS above. If you apply the patch does your mini-map not look like that?

I've noticed it sometimes looks like its got a slight purplish tint to it.. or maybe thats just my eyes playing tricks on me.. cos my brain is wired to expect certian colors up there from looking at it for so many years..

...or do you mean the on-screen unit graphics... like ogres or whatever? This is only intended to change the mini-map color... although possibly that could be changed too. IDK, havn't looked at it.
« Last Edit: February 28, 2017, 06:26:54 PM by Lambchops »
its gooder to hax hard and NEVER get caught!

Offline Incos

  • Axe Thrower
  • ****
  • Posts: 253
    • View Profile
Re: Nerd's Corner
« Reply #37 on: February 28, 2017, 06:40:06 PM »
That's cool mate, I haven't touched the computer in awhile. Work got me tied up.  I meant the onscreen as well. It's clear you found the code for the mini map which is awesome.  Now I wonder if he individually changed the palette of each bmp or if this is also in the war2.exe.. I will be looking at it tonight.

The only reason I ask is i want to learn. I would like to change the black ogres as well possibly some of the colors to dif variations.

It also opens the door for a bigger player Warcraft 2, such as 10 players or 12 players. Sc2 and wc3 both do it.  I just wonder if it's the engine holding it back as well.

I know some of the guys have looked into it already. And say it's impossible for a bigger map than 128x128
https://www.twitch.tv/incoswc - my twitch. Streaming 9:30pm - 11pm est most days!!

Offline shesycompany

  • Death Knight
  • *********
  • Posts: 3587
  • retired, be in music section
    • View Profile
Re: Nerd's Corner
« Reply #38 on: February 28, 2017, 09:05:26 PM »
u would want to make a new engine.
there's been quite a few of these dudes...get a little team together...

im using game maker, probably will piddle around somemore.

someone like lamb can possibly doit with bnets :o
« Last Edit: February 28, 2017, 09:23:25 PM by easycompany »

Offline Incos

  • Axe Thrower
  • ****
  • Posts: 253
    • View Profile
Re: Nerd's Corner
« Reply #39 on: February 28, 2017, 09:18:35 PM »
Yeah lamb seems really advanced. Probably one of the only people on server that could even implement that
https://www.twitch.tv/incoswc - my twitch. Streaming 9:30pm - 11pm est most days!!

Offline Incos

  • Axe Thrower
  • ****
  • Posts: 253
    • View Profile
Re: Nerd's Corner
« Reply #40 on: February 28, 2017, 09:48:26 PM »
Was able to recreate the hexing of the .exe file, i am curious on how you know which binary held the mini map file?
https://www.twitch.tv/incoswc - my twitch. Streaming 9:30pm - 11pm est most days!!

Offline Lambchops

  • Ogre Mage
  • ********
  • Posts: 1541
    • View Profile
Re: Nerd's Corner
« Reply #41 on: March 01, 2017, 04:19:58 AM »
Was able to recreate the hexing of the .exe file, i am curious on how you know which binary held the mini map file?


Well if you read through the posts above... and maybe on the black to pink thread... you can pretty much see my thought process because I wrote the posts as I was doing it.

However... just to add that plot twist that every good detective story needs: I was cheating - I didn't just work it all out now - I copied some work from a program written by some dude called ItMustBeLove in 2009 (aka Lambchops).... yeah me lol.

But what on earth I actually did 7 years ago I don't really know... i could guess - similar stuff to what I'm doing now.

I would guess that I probably first found the source list that I'm now patching, but at the time I was producing a small demo program to demonstrate that I could actually do stuff, not just get on the forum and talk crap. The plan was for a modified exe later on with all sorts of patches applied, the demo program was just an "instant" thing. So....

Now i've rediscovered it all, I'm pretty sure back then I followed the trail forwards from the source list to where it was implimented on a per game basis, then made a "live patch" that patched the current game colors in the active process memory. Still can't really remember, but that sounds about right.

So 7 years later when I wanted some info on this stuff, I knew I had worked it out before, so the first thing I did was disassemble my old app (lost the source  :-X but that's another story) and worked out what I did back then...

From my old anticrap app i knew I was searching the random array at 0x004A48CC for E4 and changing it to FD.. and I remember that this was hot pink not the nice pastel shade that comes with Messiah's B2P, because I remember Blid politely indicating that it was all but burning his retinas out lol...

Anyway this had me looking in the right places, so I poked around a bit and came up with this list:

Code: [Select]
RED        D0      D0-D3
BLUE       01 *    D4-D7
TEAL       D8      D8-DB
PURP       DC      DC-DF
OJ         E0      E0-E3
BLACK      E4      E4-E7
WHITE      FF *    E8-EB
YELLOW     02 *    0C-0F

Considering the list and the mechanism it seemed logical that if the game was randomising the entries for each player in a game (but not for fixed order games) then there must be a list of these entries somewhere IN ORDER i.e. Player 1 = Red, Player 2 = Blue, etc.  -  i.e. a source list.

.... at that point I just searched the PE image for that sequence of bytes: D0,01,08,DC,E0,E4,FF,02 and found it a stone's throw away from the randomised list.... obviously the I did a quick edit and test, and it worked  :)


Oh, and as for working out what palette indexes were being used so I had something to search for, they just came originally from good old fashioned, common or garden variety Screen-Shots. 8-bit palette based graphics are ideal for this sort of stuff.






Actually, here: you'll love this (well I do anyway). How technical is this stuff OMG! lol  ;)  not as technical as you might think sometimes, logic is always the best tool and there's HUGE bonus points for cheating and making stuff dead simple. Simple is Sexy. :fro:




--> Let's find what palette indicies are used to display the colors on BLUE units.

Ok so first we need to find a SS that displays a blue unit. Here's one:



Cool. If we zoom in on that little guy in the bottom right we can clearly see the 4 shades of blue that are used for him and his whole tribe.



So now we need to know what the actual numbers are in this PCX file that reference the palette entry that is used to render this little group of pixels....

... so we can work out the exact (x,y) co-ordinates of each pixel we want to test, then find it's source in the PCX file.

Ok so: 

The specs for PCX format are freely available online,

       * source these and work out the sizes for the various header structures

       * then locate the pixel data.

       * then we discover that (of course) all PCX files are RLE compressed... not a huge deal

       * decomopress the pixel data

       * finally we apply the love-child of our (x,y) co-ords and the (w,h) dimension of the PCX file to the decompressed data stream and....

.... hey presto! if we got our sums right we got the palette index of the RGB values for that pixel.
:)

Still that's a lot of sums, I could have messed something up  :(  ...  I would want to make sure it was the right value by writing back some kind of a test......   say altering this palette entry, or altering the pixmap by copying this entry to.......  um ....and by now we're half way through next week.......



....... hmmm






..... mmmm ......








                            ......  OR  ......


We could have a nice refreshing glass of sanity and say: NAH .... there's got to be an easier way..

Here's what I did:

... for starters I used Irfanview to convert the PCX SS to a .BMP so I could easily edit it. Probably PaintshopPro or whatever else would work just as well, but the main thing is to MAKE SURE THAT IT STAYS AN 8 BIT PALETTIZED IMAGE (256 COLOR),  if it get's converted to 24-bit you're going nowhere. This takes about 6 or 7 seconds (throw the PCX at irfanview select "Save As" .BMP - done.

At this point we're already way ahead because .BMP files aren't (by default) RLE encoded, - although they can be, however ALL PCX files are, it's part of the spec. So, no need to worry about that, just the header files, let's see there's a BITMAP_INFO_HEADER... and blah blah blah... nuh-uh ... not if I dont have to  :P

 Hard work? No Problem Every time I have to, I'll kick it's ass... but when I don't have to? ..... I'll leave that for the fools and martyrs.... 



so I just opened the BMP in M$ Paint and used the magnifying glass thingy to zoom in on our little guy.... and then there's a little eye-dropper thingy that lets you select a color from the image.... and of course its a paint app, so we can draw a block of color.... so let's just get the lightest blue shade and make a Big Blue Blob




... damn, that was easy... let's do it again for the other 3 colors....





Sheesh, well that took all of 45 seconds. OK, so we get rid of our little magnifying-glass zoom-thingy and our SS looks like this:





Well I'm really in the mood for some graffitti today so let's do it again!

Now we've got those nice friendly pads of color to sample....

....... eye-dropper..... color rectangle,  .... eye-dropper..... color rectangle,  .... eye-dropper..... color rectangle....., .... eye-dropper..... color rectangle ......   

   ...AND TA-DAH! the finished product... what a materpiece!






Now we calculate the.... header sizes... pixmap offset... dword alignment... RLE encoding.... BAH!   ;D  Yall just KNOW I'm not gonna... hehe









  --> just toss it into a hex-editor and scroll down a few pages until:





Now I didn't do even one simple piece of arithmatic, but can there be any doubt whatsoever what the 4 palette entries are? I think no.

      If only everything about reverse engineering software was like this.

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

So I did this for each of the 8 player minimap colors, then as we know the player colors for a fixed order game order (if you can't remember just look at the menu from the Blizzard .PUD editor) I arranged the 8 bytes in that order, then did a search for those 8 bytes. BINGO!





  ...and call me a nerdy nutter, but i absolutely LOVE that such absolutely crude and uncalculated methods can pin-point the precise location to do exactly what I set out to do, in over 700,000 bytes of exe file . That shiz just makes me giggle like a school-girl  ;D





IDK, perhaps I should make out that it was all extremely complicated and it took me leading a team of NASA software engineers programming a network of helium cooled quantum processors to calculate all the variables because I'm such a freakin guru xD NAH... just 'cos I'm learning some GOW doesn't mean I have to be a complete tosser...



its gooder to hax hard and NEVER get caught!

Offline shesycompany

  • Death Knight
  • *********
  • Posts: 3587
  • retired, be in music section
    • View Profile
Re: Nerd's Corner
« Reply #42 on: March 01, 2017, 04:26:02 AM »
 :-*

Offline Lambchops

  • Ogre Mage
  • ********
  • Posts: 1541
    • View Profile
Re: Nerd's Corner
« Reply #43 on: March 01, 2017, 04:52:50 AM »
its gooder to hax hard and NEVER get caught!

Offline Incos

  • Axe Thrower
  • ****
  • Posts: 253
    • View Profile
Re: Nerd's Corner
« Reply #44 on: March 01, 2017, 07:34:32 PM »
Keeps giving meerrorinwar2 whenever I try to edit palette of specific unit. I tried the black lumber mill to lime green and didn't work... zzzz I need to get experienced. What code is Warcraft 2?maybe I can take a course
https://www.twitch.tv/incoswc - my twitch. Streaming 9:30pm - 11pm est most days!!