Compare commits
No commits in common. "3a396f8fc3dae1ed615989f5e77588ddd8cf86ba" and "329e47a1bab532c222051e3587d70cb9f05ffa57" have entirely different histories.
3a396f8fc3
...
329e47a1ba
|
@ -16,7 +16,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
|
|||
|
||||
add_executable(PythonWhiteFin
|
||||
packetlog.c
|
||||
pcap.c
|
||||
)
|
||||
|
||||
target_link_libraries(PythonWhiteFin
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# PythonWhiteFin
|
||||
|
||||
cmd56 packet logger, oh it also
|
||||
cmd56 packet logger, oh it also
|
||||
enables cobra blackfin on 3.60+
|
40
packetlog.c
40
packetlog.c
|
@ -3,14 +3,6 @@
|
|||
#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;
|
||||
|
||||
|
@ -18,40 +10,10 @@ 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,
|
||||
|
@ -66,8 +28,6 @@ int module_start(SceSize argc, const void *args)
|
|||
|
||||
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;
|
||||
|
|
46
pcap.c
46
pcap.c
|
@ -1,46 +0,0 @@
|
|||
#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;
|
||||
}
|
24
pcap.h
24
pcap.h
|
@ -1,24 +0,0 @@
|
|||
#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