Upload src
This commit is contained in:
parent
f6a3e0d485
commit
3a396f8fc3
|
@ -52,3 +52,4 @@ Module.symvers
|
|||
Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
build/*
|
|
@ -0,0 +1,35 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||
if(DEFINED ENV{VITASDK})
|
||||
set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
|
||||
else()
|
||||
message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
project(PythonWhiteFin)
|
||||
include("${VITASDK}/share/vita.cmake" REQUIRED)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O3 -nostdlib")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
|
||||
|
||||
add_executable(PythonWhiteFin
|
||||
packetlog.c
|
||||
pcap.c
|
||||
)
|
||||
|
||||
target_link_libraries(PythonWhiteFin
|
||||
taihenForKernel_stub
|
||||
SceIofilemgrForDriver_stub
|
||||
SceSdifForDriver_stub
|
||||
SceNpDrmForDriver_stub
|
||||
SceRtcForDriver_stub
|
||||
SceRegMgrForDriver_stub
|
||||
SceSblSsMgrForDriver_stub
|
||||
SceSysclibForDriver_stub
|
||||
SceDebugForDriver_stub
|
||||
SceThreadmgrForDriver_stub
|
||||
)
|
||||
|
||||
vita_create_self(PythonWhiteFin.skprx PythonWhiteFin CONFIG exports.yml UNSAFE)
|
|
@ -0,0 +1,8 @@
|
|||
packetlog:
|
||||
attributes: 0
|
||||
version:
|
||||
major: 1
|
||||
minor: 1
|
||||
main:
|
||||
start: module_start
|
||||
stop: module_stop
|
|
@ -0,0 +1,74 @@
|
|||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <vitasdkkern.h>
|
||||
#include <taihen.h>
|
||||
|
||||
#include "pcap.h"
|
||||
|
||||
static int sendHook = -1;
|
||||
static tai_hook_ref_t sendHookRef;
|
||||
|
||||
static int recvHook = -1;
|
||||
static tai_hook_ref_t recvHookRef;
|
||||
|
||||
static int kernelGetSysTime = -1;
|
||||
static tai_hook_ref_t kernelGetSysTimeRef;
|
||||
|
||||
uint64_t sceKernelGetSystemTimeWide_Patched(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SceSdifSendGcPacket_Patched(void* instance, char* buffer, int bufferSz) {
|
||||
write_pcap_packet(buffer, bufferSz, 1);
|
||||
int ret = TAI_CONTINUE(int, sendHookRef, instance, buffer, bufferSz);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SceSdifReceiveGcPacket_Patched(void* instance, char* buffer, int bufferSz) {
|
||||
int ret = TAI_CONTINUE(int, recvHookRef, instance, buffer, bufferSz);
|
||||
write_pcap_packet(buffer, bufferSz, 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void _start() __attribute__ ((weak, alias ("module_start")));
|
||||
int module_start(SceSize argc, const void *args)
|
||||
{
|
||||
|
||||
write_pcap_hdr();
|
||||
|
||||
sendHook = taiHookFunctionImportForKernel(KERNEL_PID,
|
||||
&sendHookRef,
|
||||
"SceSblGcAuthMgr",
|
||||
0x96D306FA, // SceSdifForDriver
|
||||
0xB0996641, // SceSdifSendGcPacket
|
||||
SceSdifSendGcPacket_Patched);
|
||||
ksceKernelPrintf("[started] %x %x\n", sendHook, sendHookRef);
|
||||
|
||||
recvHook = taiHookFunctionImportForKernel(KERNEL_PID,
|
||||
&recvHookRef,
|
||||
"SceSblGcAuthMgr",
|
||||
0x96D306FA, // SceSdifForDriver
|
||||
0x134E06C4, // SceSdifReceiveGcPacket
|
||||
SceSdifReceiveGcPacket_Patched);
|
||||
ksceKernelPrintf("[started] %x %x\n", recvHook, recvHookRef);
|
||||
|
||||
// undo cobra blackfin patch
|
||||
kernelGetSysTime = taiHookFunctionImportForKernel(KERNEL_PID,
|
||||
&kernelGetSysTimeRef,
|
||||
"SceSblGcAuthMgr",
|
||||
0xE2C40624, // SceThreadmgrForDriver
|
||||
0xF4EE4FA9, // sceKernelGetSystemTimeWide
|
||||
sceKernelGetSystemTimeWide_Patched);
|
||||
ksceKernelPrintf("[started] %x %x\n", kernelGetSysTime, kernelGetSysTimeRef);
|
||||
|
||||
return SCE_KERNEL_START_SUCCESS;
|
||||
}
|
||||
|
||||
int module_stop(SceSize argc, const void *args)
|
||||
{
|
||||
if (recvHook >= 0) taiHookReleaseForKernel(recvHook, recvHookRef);
|
||||
if (sendHook >= 0) taiHookReleaseForKernel(sendHook, sendHookRef);
|
||||
if (kernelGetSysTime >= 0) taiHookReleaseForKernel(kernelGetSysTime, kernelGetSysTimeRef);
|
||||
|
||||
return SCE_KERNEL_STOP_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
#include "pcap.h"
|
||||
#include <vitasdkkern.h>
|
||||
|
||||
static char* pcapFile = "ux0:/data/gc.pcap";
|
||||
|
||||
void write_pcap_hdr() {
|
||||
SceUID pcapfd = ksceIoOpen(pcapFile, SCE_O_WRONLY | SCE_O_CREAT , 0777);
|
||||
|
||||
pcap_hdr_t pcapHdr;
|
||||
pcapHdr.magic_number = 0xa1b2c3d4;
|
||||
pcapHdr.version_major = 0x2;
|
||||
pcapHdr.version_minor = 0x4;
|
||||
pcapHdr.thiszone = 0;
|
||||
pcapHdr.sigfigs = 0;
|
||||
pcapHdr.snaplen = 65535;
|
||||
pcapHdr.network = 147;
|
||||
|
||||
ksceIoWrite(pcapfd, &pcapHdr, sizeof(pcap_hdr_t));
|
||||
|
||||
ksceIoClose(pcapfd);
|
||||
return;
|
||||
}
|
||||
|
||||
void write_pcap_packet(char* packetData, size_t packetLength, int direction) {
|
||||
if(packetData == NULL) return;
|
||||
|
||||
SceRtcTick time;
|
||||
ksceRtcGetCurrentSecureTick(&time);
|
||||
|
||||
SceUID pcapfd = ksceIoOpen(pcapFile, SCE_O_WRONLY | SCE_O_APPEND , 0777);
|
||||
|
||||
pcaprec_hdr_t packetHdr;
|
||||
packetHdr.incl_len = packetLength + sizeof(int);
|
||||
packetHdr.orig_len = packetLength + sizeof(int);
|
||||
packetHdr.ts_sec = (uint32_t)((time.tick / 1000000) - 62135596800);
|
||||
packetHdr.ts_usec = (uint32_t)(time.tick % 1000000);
|
||||
|
||||
|
||||
ksceIoWrite(pcapfd, &packetHdr, sizeof(pcaprec_hdr_t));
|
||||
ksceIoWrite(pcapfd, &direction, sizeof(int));
|
||||
ksceIoWrite(pcapfd, packetData, packetLength);
|
||||
|
||||
ksceIoClose(pcapfd);
|
||||
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct pcap_hdr_s {
|
||||
uint32_t magic_number; /* magic number */
|
||||
uint16_t version_major; /* major version number */
|
||||
uint16_t version_minor; /* minor version number */
|
||||
int32_t thiszone; /* GMT to local correction */
|
||||
uint32_t sigfigs; /* accuracy of timestamps */
|
||||
uint32_t snaplen; /* max length of captured packets, in octets */
|
||||
uint32_t network; /* data link type */
|
||||
} pcap_hdr_t;
|
||||
|
||||
typedef struct pcaprec_hdr_s {
|
||||
uint32_t ts_sec; /* timestamp seconds */
|
||||
uint32_t ts_usec; /* timestamp microseconds */
|
||||
uint32_t incl_len; /* number of octets of packet saved in file */
|
||||
uint32_t orig_len; /* actual length of packet */
|
||||
} pcaprec_hdr_t;
|
||||
|
||||
|
||||
void write_pcap_hdr();
|
||||
void write_pcap_packet(char* packetData, size_t packetLength, int direction);
|
Loading…
Reference in New Issue