Page 2 of 2

Re: [App] - C++.NET Map Resigner (Source)

Posted: Fri Jan 30, 2009 4:00 pm
by DemonicSandwich
iBotPeaches wrote:Appears the move from phpbb2 to phpbb3. Messed up this download.

Anyone have it?
It was messed up well before that. :?

Re: [App] - C++.NET Map Resigner (Source)

Posted: Wed Mar 11, 2009 3:34 pm
by Domnio
despite the fact this topic is about 2 years old, I too would like to have a peek at it's source code. Could anyone reupload this please?

Re: [App] - C++.NET Map Resigner (Source)

Posted: Wed Mar 11, 2009 3:37 pm
by Eaton
Domnio wrote:despite the fact this topic is about 2 years old, I too would like to have a peek at it's source code. Could anyone reupload this please?
Read the posts before you. No one seems to have it. I too would like it, but no one has it. :|

Re: [App] - C++.NET Map Resigner (Source)

Posted: Wed Mar 11, 2009 3:57 pm
by grimdoomer
This isen't hard to recreate. All he did was goto 2048, and use assembly to xor every int.

Re: [App] - C++.NET Map Resigner (Source)

Posted: Wed Mar 11, 2009 5:25 pm
by SpecOp44
Here.

Re: [App] - C++.NET Map Resigner (Source)

Posted: Wed Mar 11, 2009 5:37 pm
by Eaton
SpecOp44 wrote:Here.
Thank you! :shock:

Re: [App] - C++.NET Map Resigner (Source)

Posted: Wed Mar 11, 2009 7:28 pm
by JacksonCougAr
Similar speed as what I already had from xbox7887, so meh.

Re: [App] - C++.NET Map Resigner (Source)

Posted: Wed Mar 11, 2009 9:26 pm
by OwnZ joO
Would you like to post that code for all to see? I think I remember you said it involved a buffered read or MemoryStream(can't remember which). I messed with a MemoryStream a while before you had mentioned that, but it didn't produce any faster results for me, I didn't extensively mess with it though because in reality it really doesn't take thaaaat long to resign a file, although faster is better.

Re: [App] - C++.NET Map Resigner (Source)

Posted: Wed Mar 11, 2009 10:10 pm
by JacksonCougAr

Code: Select all

public void Resign()
        {
            int size = (int)Length - 2048;
            int times = size / 4;
            int result = 0;
            int buffersize = 512;
            byte[] buffer;
            Position = 2048;
            for (int i = 0; i < times/buffersize; i++)
            {
                buffer = ReadBytes(buffersize);
                for(int x=0;x<buffersize;x+=4)
                {
                    result ^= BitConverter.ToInt32(buffer, x);
                }
            }
            Header.Checksum = result;
        }
I never really tested it, so the loops might fail, meh.

Re: [App] - C++.NET Map Resigner (Source)

Posted: Fri Mar 20, 2009 2:14 pm
by iBotPeaches
I did a search on my comp. Found this. I think its made by xbox7887. Not sure.

Code: Select all

#include <fstream>
#include <iostream>
#include <iomanip>

#include <io.h>
#include <fcntl.h>
#include <sys/stat.h>

#include <windows.h>

#include <malloc.h>
#include <stdio.h>

using namespace std;

// tune these to your specific processor for optimal performance
#define FILE_BUFFER_SIZE (1024 * 128)	// must be a multiple of 128
#define CACHE_LINE_SIZE 64	// your processors cache line size, must be a multiple of 16

void main(unsigned int argc, char* argv[])
{
	if (argc == 2)
	{
		// initialize local variables
		int mapHandle, hashSize, oldHash, readCount, hashCount, hashRemainder, finalSig = 0;

		// allocate file buffer
		void* fileBuffer = _aligned_malloc(FILE_BUFFER_SIZE, CACHE_LINE_SIZE);

		unsigned int before = GetTickCount();

		_asm
		{
			// define some static registers
			mov	esi, fileBuffer

			// open up map
			push	_S_IREAD
			push	_O_BINARY + _O_RDWR		// _O_SEQUENTIAL flag actually makes this a shit ton slower for some insane reason :X
			mov		eax, argv
			push	[eax + 4]
			call	dword ptr [_open]
			mov		mapHandle, eax

			// get some information from the header
			push	2048
			push	fileBuffer
			push	mapHandle
			call	dword ptr [_read]
			add		esp, 0Ch

			// calculate hash range size
			mov		ecx, [esi + 8]
			sub		ecx, 2048
			mov		hashSize, ecx

			// save old hash
			mov		ecx, [esi + 720]
			mov		oldHash, ecx

			// calculate iteration info
			//readCount = hashSize / FILE_BUFFER_SIZE;
			mov		eax, hashSize
			cdq
			and		edx,1FFFFh 
			add		eax,edx 
			sar		eax,11h 
			mov		readCount, eax 

			//hashRemainder = hashSize % FILE_BUFFER_SIZE;
			mov		eax, hashSize
			add		esp,8 
			and		eax,8001FFFFh 
			jns		Done
			dec		eax  
			or		eax,0FFFE0000h 
			inc		eax  
			Done:
			mov		hashRemainder,eax

			// initialize registers
			xorpd	xmm0, xmm0
			xorpd	xmm1, xmm1
			xorpd	xmm2, xmm2
			xorpd	xmm3, xmm3
			xorpd	xmm4, xmm4
			xorpd	xmm5, xmm5
			xorpd	xmm6, xmm6
			xorpd	xmm7, xmm7

			// initialize main loop info
			mov		ebx, readCount
			xor		edi, edi	// i counter
			MainReadLoop:
				cmp		edi, ebx
				jge		MainReadLoopExit

				//
				pushad
				push	FILE_BUFFER_SIZE
				push	fileBuffer
				push	mapHandle
				call	dword ptr [_read]
				add		esp, 0Ch
				popad

				xor		edx, edx	// j counter
				MainCalcLoop:
					cmp		edx, FILE_BUFFER_SIZE
					jge		MainCalcLoopExit
					xorpd	xmm0, [esi + edx]
					xorpd	xmm1, [esi + edx + 16]
					xorpd	xmm2, [esi + edx + 32]
					xorpd	xmm3, [esi + edx + 48]
					xorpd	xmm4, [esi + edx + 64]
					xorpd	xmm5, [esi + edx + 80]
					xorpd	xmm6, [esi + edx + 96]
					xorpd	xmm7, [esi + edx + 112]
					add		edx, 128
					jmp		MainCalcLoop
				MainCalcLoopExit:

				add		edi, 1
				jmp		MainReadLoop
			MainReadLoopExit:

			// skip if there is no remainder
			mov		ebx, hashRemainder
			test	ebx, ebx
			jz		RemainderCalcLoopExit

			//_read(mapHandle, fileBuffer, FILE_BUFFER_SIZE)
			pushad
			push	ebx
			push	fileBuffer
			push	mapHandle
			call	dword ptr [_read]
			add		esp, 0Ch
			popad

			// initialize main loop info
			xor		edx, edx			// i counter
			RemainderCalcLoop:
				cmp		edx, ebx
				jge		RemainderCalcLoopExit
				xorpd	xmm0, [esi + edx]
				xorpd	xmm1, [esi + edx + 16]
				xorpd	xmm2, [esi + edx + 32]
				xorpd	xmm3, [esi + edx + 48]
				xorpd	xmm4, [esi + edx + 64]
				xorpd	xmm5, [esi + edx + 80]
				xorpd	xmm6, [esi + edx + 96]
				xorpd	xmm7, [esi + edx + 112]
				add		edx, 128
				jmp		RemainderCalcLoop
			RemainderCalcLoopExit:

			// save registers to memory
			movdqa		[esi], xmm0
			movdqa		[esi + 16], xmm1
			movdqa		[esi + 32], xmm2
			movdqa		[esi + 48], xmm3
			movdqa		[esi + 64], xmm4
			movdqa		[esi + 80], xmm5
			movdqa		[esi + 96], xmm6
			movdqa		[esi + 112], xmm7

			// calculate final signature
			xor		eax, eax
			xor		ebx, ebx
			FinalCalcLoop:
				cmp		ebx, 128
				jge		FinalCalcLoopExit
				xor		eax, [esi + ebx]
				xor		eax, [esi + ebx + 4]
				xor		eax, [esi + ebx + 8]
				xor		eax, [esi + ebx + 12]
				xor		eax, [esi + ebx + 16]
				xor		eax, [esi + ebx + 20]
				xor		eax, [esi + ebx + 24]
				xor		eax, [esi + ebx + 28]
				add		ebx, 32
				jmp		FinalCalcLoop
			FinalCalcLoopExit:
			mov		finalSig, eax
		}
		unsigned int elapse = GetTickCount() - before;

		// only update the signature if it changed
		if (finalSig != oldHash)
		{
			lseek(mapHandle, 720, 0);
			_write(mapHandle, &finalSig, 4);
			cout << "The maps signature has now been updated." << endl;
		}
		else cout << "The old signature is already current. " << endl;

		// close the map
		_close(mapHandle);

		// specify its usage
		cout << "Elapsed time of " << elapse  << " milliseconds."<< endl;
		system("pause");
	}
	else 
	{
		// specify its usage
		cout << "To use you must drag and drop your map into\nthis executable or input the following command\ninto your command prompt window...\n\nLightningSigner.exe [Map Path]\n";
		system("pause");
	}
}