Update
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
// BlitzSteam - Steam wrapper for Blitz
|
||||
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "BlitzPointer.h"
|
||||
|
||||
DLL(intptr_t) BS_BlitzPointer_GetReturnAddress() {
|
||||
intptr_t BasePointer, ReturnAddress;
|
||||
|
||||
__asm { //ASM. Do touch if suicidal.
|
||||
mov BasePointer, ebp; // Store current BasePointer
|
||||
}
|
||||
|
||||
// Blitz uses X86 Call-Near (E8) instructions to call its own functions.
|
||||
// We can simply deduce the Return Address like this because of that.
|
||||
//-- Parent_EBP = *EBP
|
||||
//-- Parent_RP = Parent_EBP + 16
|
||||
ReturnAddress = *(intptr_t*)((*(intptr_t*)BasePointer) + 16);
|
||||
|
||||
return ReturnAddress;
|
||||
}
|
||||
|
||||
DLL(intptr_t) BS_BlitzPointer_GetFunctionPointer() {
|
||||
intptr_t BasePointer, ReturnAddress, FunctionPointer;
|
||||
|
||||
__asm { //ASM. Do touch if suicidal.
|
||||
mov BasePointer, ebp; // Store current BasePointer
|
||||
}
|
||||
|
||||
// Blitz uses X86 Call-Near (E8) instructions to call its own functions.
|
||||
// We can simply deduce the Return Address like this because of that.
|
||||
//-- Parent_EBP = *EBP
|
||||
//-- Parent_RP = Parent_EBP + 16
|
||||
ReturnAddress = *(intptr_t*)((*(intptr_t*)BasePointer) + 16);
|
||||
|
||||
// And since it's a Call-Near, the call is offset to the return address.
|
||||
FunctionPointer = ReturnAddress + *(intptr_t*)(ReturnAddress - 4);
|
||||
|
||||
return FunctionPointer;
|
||||
}
|
||||
+36
-32
@@ -1,32 +1,36 @@
|
||||
// BlitzSteam - Steam wrapper for Blitz
|
||||
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Types of Blitz Functions.
|
||||
typedef int32_t(__stdcall *BP_BlitzFunction0_t)();
|
||||
typedef int32_t(__stdcall *BP_BlitzFunction1_t)(int32_t);
|
||||
typedef int32_t(__stdcall *BP_BlitzFunction2_t)(int32_t, int32_t);
|
||||
typedef int32_t(__stdcall *BP_BlitzFunction3_t)(int32_t, int32_t, int32_t);
|
||||
typedef int32_t(__stdcall *BP_BlitzFunction4_t)(int32_t, int32_t, int32_t, int32_t);
|
||||
typedef int32_t(__stdcall *BP_BlitzFunction5_t)(int32_t, int32_t, int32_t, int32_t, int32_t);
|
||||
|
||||
#define BP_CallFunction0(ptr) (reinterpret_cast<BP_BlitzFunction0_t>(ptr))()
|
||||
#define BP_CallFunction1(ptr, p1) (reinterpret_cast<BP_BlitzFunction1_t>(ptr))(p1)
|
||||
#define BP_CallFunction2(ptr, p1, p2) (reinterpret_cast<BP_BlitzFunction2_t>(ptr))(p1, p2)
|
||||
#define BP_CallFunction3(ptr, p1, p2, p3) (reinterpret_cast<BP_BlitzFunction3_t>(ptr))(p1, p2, p3)
|
||||
#define BP_CallFunction4(ptr, p1, p2, p3, p4) (reinterpret_cast<BP_BlitzFunction4_t>(ptr))(p1, p2, p3, p4)
|
||||
#define BP_CallFunction5(ptr, p1, p2, p3, p4, p5) (reinterpret_cast<BP_BlitzFunction5_t>(ptr))(p1, p2, p3, p4, p5)
|
||||
// BlitzSteam - Steam wrapper for Blitz
|
||||
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
#include "BlitzSteamInternal.h"
|
||||
|
||||
DLL(intptr_t) BS_BlitzPointer_GetReturnAddress();
|
||||
DLL(intptr_t) BS_BlitzPointer_GetFunctionPointer();
|
||||
|
||||
// Types of Blitz Functions.
|
||||
typedef int32_t(__stdcall *BP_BlitzFunction0_t)();
|
||||
typedef int32_t(__stdcall *BP_BlitzFunction1_t)(int32_t);
|
||||
typedef int32_t(__stdcall *BP_BlitzFunction2_t)(int32_t, int32_t);
|
||||
typedef int32_t(__stdcall *BP_BlitzFunction3_t)(int32_t, int32_t, int32_t);
|
||||
typedef int32_t(__stdcall *BP_BlitzFunction4_t)(int32_t, int32_t, int32_t, int32_t);
|
||||
typedef int32_t(__stdcall *BP_BlitzFunction5_t)(int32_t, int32_t, int32_t, int32_t, int32_t);
|
||||
|
||||
#define BP_CallFunction0(ptr) (ptr)()
|
||||
#define BP_CallFunction1(ptr, p1) (ptr)(p1)
|
||||
#define BP_CallFunction2(ptr, p1, p2) (ptr)(p1, p2)
|
||||
#define BP_CallFunction3(ptr, p1, p2, p3) (ptr)(p1, p2, p3)
|
||||
#define BP_CallFunction4(ptr, p1, p2, p3, p4) (ptr)(p1, p2, p3, p4)
|
||||
#define BP_CallFunction5(ptr, p1, p2, p3, p4, p5) (ptr)(p1, p2, p3, p4, p5)
|
||||
+59
-89
@@ -1,90 +1,60 @@
|
||||
// BlitzSteam - Steam wrapper for Blitz
|
||||
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "Helper.h"
|
||||
|
||||
DLL(const char*) BS_Helper_FormatUnixTime(uint32_t unTime, const char* pchFormat) {
|
||||
char* output = new char[strlen(pchFormat) * 4];
|
||||
time_t t = unTime;
|
||||
struct tm *tm = localtime(&t);
|
||||
strftime(output, sizeof(output), pchFormat, tm);
|
||||
delete tm;
|
||||
return output;
|
||||
}
|
||||
|
||||
DLL(void) BS_Helper_CopyMemoryIntMangle(void* pSource, void* pDest, int32_t iMangling,
|
||||
uint32_t iSourceW, uint32_t iSourceH, uint32_t iDestW, uint32_t iDestH,
|
||||
uint32_t iAreaX, uint32_t iAreaY, uint32_t iAreaW, uint32_t iAreaH) {
|
||||
int8_t iMangleByte0 = static_cast<int8_t>((iMangling & 0xFF));
|
||||
int8_t iMangleByte1 = static_cast<int8_t>((iMangling & 0xFF00) >> 8);
|
||||
int8_t iMangleByte2 = static_cast<int8_t>((iMangling & 0xFF0000) >> 16);
|
||||
int8_t iMangleByte3 = static_cast<int8_t>((iMangling & 0xFF000000) >> 24);
|
||||
|
||||
if (pSource > pDest) {
|
||||
// Start at beginning
|
||||
for (uint32_t iY = iAreaY; iY < (iAreaY + iAreaH); iY++) {
|
||||
// Only do this once per loop
|
||||
for (uint32_t iX = iAreaX; iX < (iAreaX + iAreaW); iX++) {
|
||||
// Could technically optimize the following into single instructions, but this is fast enough for now.
|
||||
uint32_t* pSourceOff = reinterpret_cast<uint32_t*>(pSource) + ((iSourceW * iY) + iX);
|
||||
uint32_t* pDestOff = reinterpret_cast<uint32_t*>(pDest) + ((iDestW * iY) + iX);
|
||||
|
||||
// Allow Mangling using just a single integer and checking on the fly if it's positive or negative to branch out to the correct shift.
|
||||
*pDestOff =
|
||||
(iMangleByte0 > 0 ?
|
||||
(*pSourceOff & 0xFF) >> iMangleByte0 :
|
||||
(*pSourceOff & 0xFF) << -iMangleByte0)
|
||||
+ (iMangleByte1 > 0 ?
|
||||
(*pSourceOff & 0xFF00) >> iMangleByte1 :
|
||||
(*pSourceOff & 0xFF00) << -iMangleByte1)
|
||||
+ (iMangleByte2 > 0 ?
|
||||
(*pSourceOff & 0xFF0000) >> iMangleByte2 :
|
||||
(*pSourceOff & 0xFF0000) << -iMangleByte2)
|
||||
+ (iMangleByte3 > 0 ?
|
||||
(*pSourceOff & 0xFF000000) >> iMangleByte3 :
|
||||
(*pSourceOff & 0xFF000000) << -iMangleByte3);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//ToDo, mirror the above. Instead of adding we subtract.
|
||||
//// Start at end
|
||||
|
||||
//for (uint32_t iY = y + h; iY >= y; iY--) {
|
||||
// pSourceOff = reinterpret_cast<uint32_t*>(pSource) + ((tw * iY) + x);
|
||||
// pDestOff = reinterpret_cast<uint32_t*>(pDest) + ((tw * iY) + x);
|
||||
|
||||
// for (uint32_t iX = x + w; iX >= x; iX--) {
|
||||
// *pDestOff =
|
||||
// (iMangleByte0 > 0 ?
|
||||
// (*pSourceOff & 0xFF) >> iMangleByte0 :
|
||||
// (*pSourceOff & 0xFF) << -iMangleByte0)
|
||||
// + (iMangleByte1 > 0 ?
|
||||
// (*pSourceOff & 0xFF00) >> iMangleByte1 :
|
||||
// (*pSourceOff & 0xFF00) << -iMangleByte1)
|
||||
// + (iMangleByte2 > 0 ?
|
||||
// (*pSourceOff & 0xFF0000) >> iMangleByte2 :
|
||||
// (*pSourceOff & 0xFF0000) << -iMangleByte2)
|
||||
// + (iMangleByte3 > 0 ?
|
||||
// (*pSourceOff & 0xFF000000) >> iMangleByte3 :
|
||||
// (*pSourceOff & 0xFF000000) << -iMangleByte3);
|
||||
|
||||
// // Above is some mangling magic i learned in some source code. Allows you to define a byte bit shift using a single integer.
|
||||
// pSourceOff -= 1;
|
||||
// pDestOff -= 1;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
// BlitzSteam - Steam wrapper for Blitz
|
||||
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "Helper.h"
|
||||
|
||||
DLL(const char*) BS_Helper_FormatUnixTime(uint32_t unTime, const char* pchFormat) {
|
||||
char* output = new char[strlen(pchFormat) * 4];
|
||||
time_t t = unTime;
|
||||
struct tm *tm = localtime(&t);
|
||||
strftime(output, sizeof(output), pchFormat, tm);
|
||||
delete tm;
|
||||
return output;
|
||||
}
|
||||
|
||||
DLL(void) BS_Helper_CopyMemoryIntMangle(void* pSource, void* pDest, int32_t iMangling,
|
||||
uint32_t iSourceW, uint32_t iSourceH, uint32_t iDestW, uint32_t iDestH,
|
||||
uint32_t iAreaX, uint32_t iAreaY, uint32_t iAreaW, uint32_t iAreaH) {
|
||||
int8_t iMangleByte0 = static_cast<int8_t>((iMangling & 0xFF));
|
||||
int8_t iMangleByte1 = static_cast<int8_t>((iMangling & 0xFF00) >> 8);
|
||||
int8_t iMangleByte2 = static_cast<int8_t>((iMangling & 0xFF0000) >> 16);
|
||||
int8_t iMangleByte3 = static_cast<int8_t>((iMangling & 0xFF000000) >> 24);
|
||||
|
||||
// Start at beginning
|
||||
for (uint32_t iY = iAreaY; iY < (iAreaY + iAreaH); iY++) {
|
||||
// Only do this once per loop
|
||||
for (uint32_t iX = iAreaX; iX < (iAreaX + iAreaW); iX++) {
|
||||
// Could technically optimize the following into single instructions, but this is fast enough for now.
|
||||
uint32_t* pSourceOff = reinterpret_cast<uint32_t*>(pSource) + ((iSourceW * iY) + iX);
|
||||
uint32_t* pDestOff = reinterpret_cast<uint32_t*>(pDest) + ((iDestW * iY) + iX);
|
||||
|
||||
// Allow Mangling using just a single integer and checking on the fly if it's positive or negative to branch out to the correct shift.
|
||||
*pDestOff =
|
||||
(iMangleByte0 > 0 ?
|
||||
(*pSourceOff & 0xFF) >> iMangleByte0 :
|
||||
(*pSourceOff & 0xFF) << -iMangleByte0)
|
||||
+ (iMangleByte1 > 0 ?
|
||||
(*pSourceOff & 0xFF00) >> iMangleByte1 :
|
||||
(*pSourceOff & 0xFF00) << -iMangleByte1)
|
||||
+ (iMangleByte2 > 0 ?
|
||||
(*pSourceOff & 0xFF0000) >> iMangleByte2 :
|
||||
(*pSourceOff & 0xFF0000) << -iMangleByte2)
|
||||
+ (iMangleByte3 > 0 ?
|
||||
(*pSourceOff & 0xFF000000) >> iMangleByte3 :
|
||||
(*pSourceOff & 0xFF000000) << -iMangleByte3);
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
-20
@@ -1,21 +1,21 @@
|
||||
// BlitzSteam - Steam wrapper for Blitz
|
||||
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
#include "BlitzSteam.h"
|
||||
#include <time.h>
|
||||
|
||||
// BlitzSteam - Steam wrapper for Blitz
|
||||
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
#include "BlitzSteam.h"
|
||||
#include <time.h>
|
||||
|
||||
DLL(const char*) BS_Helper_FormatUnixTime(uint32_t unTime, const char* pchFormat);
|
||||
Reference in New Issue
Block a user