replace BitStream::ReadCompressed
This commit is contained in:
parent
6f436ead4d
commit
267301a7ba
59
bitstream.c
59
bitstream.c
|
@ -4,6 +4,7 @@
|
|||
#include "common.h"
|
||||
#include "bitstream.h"
|
||||
#include "packet.h"
|
||||
#include <stdio.h>
|
||||
|
||||
__declspec(naked)
|
||||
void __stdcall BitStream__ctor(
|
||||
|
@ -44,3 +45,61 @@ int __stdcall BitStream__Read(struct CBitStream *this, char *out)
|
|||
jmp eax
|
||||
}
|
||||
}
|
||||
|
||||
int __stdcall Hooked_BitStream__ReadCompressed(
|
||||
char *out,
|
||||
unsigned char a,
|
||||
unsigned char unsignedData)
|
||||
{
|
||||
struct CBitStream *this;
|
||||
unsigned char tmpa, tmpread;
|
||||
int myReadOffset;
|
||||
|
||||
_asm mov this, ecx
|
||||
|
||||
tmpa = (a >> 3) - 1;
|
||||
if (unsignedData) {
|
||||
unsignedData = 0;
|
||||
a = 0;
|
||||
} else {
|
||||
unsignedData = 0xFF;
|
||||
a = 0xF0;
|
||||
}
|
||||
|
||||
while (tmpa > 0) {
|
||||
myReadOffset = this->readOffset + 1;
|
||||
if (myReadOffset > this->numberOfBitsUsed) {
|
||||
return 0;
|
||||
}
|
||||
if ((0x80 >> this->readOffset) == this->ptrData[myReadOffset]) {
|
||||
this->readOffset = myReadOffset;
|
||||
return (int) thiscall3(
|
||||
(void*) 0x44DA70, this, (int) out, tmpa, 1);
|
||||
}
|
||||
|
||||
this->readOffset = myReadOffset;
|
||||
out[tmpa] = unsignedData;
|
||||
tmpa--;
|
||||
}
|
||||
|
||||
if (this->readOffset + 1 > this->numberOfBitsUsed) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!thiscall1((void*) 0x44D840, this, (int) &tmpread)) { /*readBit*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
out += 0; /*? esi + ebx but esi should be always 0?*/
|
||||
if (tmpread) {
|
||||
if (!thiscall3((void*) 0x44DA70, this, (int) out, 4, 1)) {
|
||||
return 0;
|
||||
}
|
||||
*out |= a;
|
||||
} else {
|
||||
if (!thiscall3((void*) 0x44DA70, this, (int) out, 8, 1)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -21,3 +21,7 @@ void __stdcall BitStream__ctor(
|
|||
void __stdcall BitStream__dtor();
|
||||
|
||||
int __stdcall BitStream__Read(struct CBitStream *this, char *out);
|
||||
int __stdcall Hooked_BitStream__ReadCompressed(
|
||||
char *out,
|
||||
unsigned char,
|
||||
unsigned char);
|
||||
|
|
61
common.c
61
common.c
|
@ -3,6 +3,67 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
__declspec(naked)
|
||||
void * __stdcall thiscall0(void *address, void *this)
|
||||
{
|
||||
_asm {
|
||||
add esp, 0xC
|
||||
mov ecx, [esp-0x4]
|
||||
mov eax, [esp-0x8]
|
||||
push [esp-0xC]
|
||||
jmp eax
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked)
|
||||
void * __stdcall thiscall1(void *address, void *this, int a)
|
||||
{
|
||||
_asm {
|
||||
add esp, 0xC
|
||||
mov ecx, [esp-0x4]
|
||||
mov eax, [esp-0x8]
|
||||
push [esp-0xC]
|
||||
jmp eax
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked)
|
||||
void * __stdcall thiscall2(void *address, void *this, int a, int b)
|
||||
{
|
||||
_asm {
|
||||
add esp, 0xC
|
||||
mov ecx, [esp-0x4]
|
||||
mov eax, [esp-0x8]
|
||||
push [esp-0xC]
|
||||
jmp eax
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked)
|
||||
void * __stdcall thiscall3(void *address, void *this, int a, int b, int c)
|
||||
{
|
||||
_asm {
|
||||
add esp, 0xC
|
||||
mov ecx, [esp-0x4]
|
||||
mov eax, [esp-0x8]
|
||||
push [esp-0xC]
|
||||
jmp eax
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked)
|
||||
void * __stdcall thiscall4(void *address, void *this,
|
||||
int a, int b, int c, int d)
|
||||
{
|
||||
_asm {
|
||||
add esp, 0xC
|
||||
mov ecx, [esp-0x4]
|
||||
mov eax, [esp-0x8]
|
||||
push [esp-0xC]
|
||||
jmp eax
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked)
|
||||
void __stdcall RangeList__ctor(struct CRangeList *this)
|
||||
{
|
||||
|
|
5
common.h
5
common.h
|
@ -131,6 +131,11 @@ struct CInternalPacket {
|
|||
EXPECT_SIZE(struct CInternalPacket, 0x38);
|
||||
#pragma pack(pop)
|
||||
|
||||
void * __stdcall thiscall0(void *address, void *this);
|
||||
void * __stdcall thiscall1(void *address, void *this, int);
|
||||
void * __stdcall thiscall2(void *address, void *this, int, int);
|
||||
void * __stdcall thiscall3(void *address, void *this, int, int, int);
|
||||
void * __stdcall thiscall4(void *address, void *this, int, int, int, int);
|
||||
void __stdcall RangeList__ctor(struct CRangeList *this);
|
||||
void __stdcall RangeList__dtor(struct CRangeList *this);
|
||||
int __stdcall BPlusTree__IsEmpty(void *this);
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
/* vim: set filetype=c ts=8 noexpandtab: */
|
||||
|
||||
#include "common.h"
|
||||
#include "bitstream.h"
|
||||
#include "rakpeer.h"
|
||||
#include "processnetworkpacket.h"
|
||||
#include "uncompress.h"
|
||||
#include "rangelist_deserialize.h"
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
@ -24,4 +26,6 @@ void nethandler_init()
|
|||
simple_redir_call(RP_PARSE_NETWORK_PACKET, ProcessNetworkPacket);
|
||||
simple_redir_call(RP_PARSE_CONNECTION_REQ,
|
||||
RakPeer__ParseConnectionRequestPacket);
|
||||
//simple_redir_call((void*) 0x45F951, RangeList__Deserialize_hooked);
|
||||
simple_redir_call((void*) 0x45E2EF, Hooked_BitStream__ReadCompressed);
|
||||
}
|
||||
|
|
51
rangelist_deserialize.c
Normal file
51
rangelist_deserialize.c
Normal file
|
@ -0,0 +1,51 @@
|
|||
|
||||
/* vim: set filetype=c ts=8 noexpandtab: */
|
||||
|
||||
#include "common.h"
|
||||
#include "rangelist_deserialize.h"
|
||||
#include "bitstream.h"
|
||||
|
||||
static
|
||||
__declspec(naked)
|
||||
int __stdcall RangeList__Deserialize(
|
||||
struct CRangeList *this,
|
||||
struct CBitStream *bitStream)
|
||||
{
|
||||
_asm {
|
||||
pop eax
|
||||
pop ecx
|
||||
push eax
|
||||
mov eax, 0x45E2D0
|
||||
jmp eax
|
||||
}
|
||||
}
|
||||
|
||||
int __stdcall RangeList__Deserialize_hooked(struct CBitStream *bitStream)
|
||||
{
|
||||
struct CRangleList *this;
|
||||
short result;
|
||||
char confusingVar;
|
||||
int value, valueshr3;
|
||||
|
||||
_asm mov this, ecx
|
||||
|
||||
thiscall0((void*) 0x45D820, this);
|
||||
thiscall3((void*) 0x44DB30, bitStream, (int) &result, 0x10, 1);
|
||||
|
||||
if (result == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
confusingVar = *((char*) bitStream); // ??
|
||||
|
||||
if (bitStream->readOffset + 1 <= bitStream->numberOfBitsUsed) {
|
||||
value = (int) bitStream->ptrData;
|
||||
valueshr3 = value >> 3;
|
||||
value &= 0x8000007;
|
||||
if (value & 0x80000000) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
8
rangelist_deserialize.h
Normal file
8
rangelist_deserialize.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
|
||||
/* vim: set filetype=c ts=8 noexpandtab: */
|
||||
|
||||
int __stdcall RangeList__Deserialize(
|
||||
struct CRangeList *this,
|
||||
struct CBitStream *bitStream);
|
||||
|
||||
int __stdcall RangeList__Deserialize_hooked(struct CBitStream *bitStream);
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
/* vim: set filetype=c ts=8 noexpandtab: */
|
||||
|
||||
#define CALL_ORIGINAL
|
||||
|
||||
#define RELIABILITY_PRINT
|
||||
|
||||
#ifdef RELIABILITY_PRINT
|
||||
|
@ -13,6 +15,7 @@
|
|||
#include "bitstream.h"
|
||||
#include "rakpeer.h"
|
||||
#include "reliability.h"
|
||||
#include "rangelist_deserialize.h"
|
||||
#include <stdio.h>
|
||||
|
||||
__declspec(naked)
|
||||
|
@ -74,21 +77,6 @@ __stdcall ReliabilityLayer__CreateInternalPacketFromBitStream(
|
|||
}
|
||||
}
|
||||
|
||||
static
|
||||
__declspec(naked)
|
||||
int __stdcall RangeList__Deserialize(
|
||||
struct CRangeList *this,
|
||||
struct CBitStream *bitStream)
|
||||
{
|
||||
_asm {
|
||||
pop eax
|
||||
pop ecx
|
||||
push eax
|
||||
mov eax, 0x45E2D0
|
||||
jmp eax
|
||||
}
|
||||
}
|
||||
|
||||
/*ReliabilityLayer__RemovePacketFromResendListAndDeleteOlderReliableSequenced*/
|
||||
__declspec(naked)
|
||||
int __stdcall ReliabilityLayer__RemovePacketsConfirmedByAck(
|
||||
|
@ -233,6 +221,9 @@ void AddBitsReceivedStatistic(struct CReliabilityLayer *this, int bits)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CALL_ORIGINAL
|
||||
__declspec(naked)
|
||||
#endif
|
||||
int __stdcall ReliabilityLayer__HandleSocketReceiveFromConnectedPlayer(
|
||||
struct CReliabilityLayer *this,
|
||||
char *buffer,
|
||||
|
@ -242,6 +233,15 @@ int __stdcall ReliabilityLayer__HandleSocketReceiveFromConnectedPlayer(
|
|||
int MTUSize,
|
||||
int *ptrOutIsPacketFlood)
|
||||
{
|
||||
#ifdef CALL_ORIGINAL
|
||||
_asm {
|
||||
pop eax
|
||||
pop ecx
|
||||
push eax
|
||||
mov eax, 0x45F7E0
|
||||
jmp eax
|
||||
}
|
||||
#else
|
||||
struct CInternalPacket *packet;
|
||||
struct CBitStream bitStream;
|
||||
struct CRaknetTimeNS timeNS;
|
||||
|
@ -281,4 +281,5 @@ int __stdcall ReliabilityLayer__HandleSocketReceiveFromConnectedPlayer(
|
|||
BitStream__dtor(&bitStream);
|
||||
dprintf("HandleSocketReceiveFromConnectedPlayerEnd\n");
|
||||
return returnValue;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -141,6 +141,14 @@
|
|||
RelativePath=".\rakpeer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\rangelist_deserialize.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\rangelist_deserialize.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\reliability.c"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue
Block a user