-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathliveview.c
126 lines (102 loc) · 2.83 KB
/
liveview.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/** \file
* Replace the DlgLiveViewApp.
*
* Attempt to replace the DlgLiveViewApp with our own version.
* Uses the reloc tools to do this.
*
* \warning Only works for 5D Mark 2 with 1.1.0
*/
#include "reloc.h"
#include "dryos.h"
#include "bmp.h"
#include "gui.h"
#include "dialog.h"
#include "config.h"
// 0xffa96390
// 0xffa96b1c DlgLiveViewApp
#define DlgLiveViewApp 0xffa96b1c
#define reloc_start DlgLiveViewApp
#define reloc_end 0xFFA97FF8
#define reloc_len (reloc_end - reloc_start)
static void
change_hdmi_size( void )
{
int (*GUI_GetDisplayType)(void) = 0xff88a8d4;
bmp_printf( FONT_SMALL, 0, 40, "%s: gui type %d!", __func__, GUI_GetDisplayType() );
//prop_request_change( 0x8003002e, 0x37080, 0x20 );
bmp_hexdump( FONT_SMALL, 0, 52, 0x37080, 0x20 );
}
static uint8_t reloc_buf[ reloc_len + 16 ];
CONFIG_INT( "reloc.enabled", reloc_enabled, 0 );
static inline void
reloc_branch(
uintptr_t pc,
void * dest
)
{
*(uint32_t*) pc = BL_INSTR( pc, dest );
}
static void
reloc_dlgliveviewapp( void )
{
if( !reloc_enabled )
return;
uintptr_t new_DlgLiveViewApp = reloc(
0, // we have physical memory
0, // with no virtual offset
reloc_start,
reloc_end,
reloc_buf
);
const uintptr_t offset = (new_DlgLiveViewApp - (uintptr_t) reloc_buf)
- reloc_start;
// There are two add %pc that we can't fixup right now.
// NOP the DebugMsg() calls that they would make
*(uint32_t*) &reloc_buf[ 0xFFA97FAC + offset ] = NOP_INSTR;
*(uint32_t*) &reloc_buf[ 0xFFA97F28 + offset ] = NOP_INSTR;
// Fix up a few things, like the calls to ChangeHDMIOutputSizeToVGA
//*(uint32_t*) &reloc_buf[ 0xFFA97C6C + offset ] = LOOP_INSTR;
*(uint32_t*) &reloc_buf[ 0xFFA97D5C + offset ] = NOP_INSTR;
*(uint32_t*) &reloc_buf[ 0xFFA97D60 + offset ] = NOP_INSTR;
/*
reloc_branch(
(uintptr_t) &reloc_buf[ 0xFFA97D5C + offset ],
//change_hdmi_size
0xffa96260 // ChangeHDMIOutputToSizeToFULLHD
);
*/
msleep( 4000 );
// Search the gui task list for the DlgLiveViewApp
while(!shutdown_requested)
{
msleep( 1000 );
struct gui_task * current = gui_task_list.current;
int y = 150;
bmp_printf( FONT_SMALL, 400, y+=12,
"current %08x",
current
);
if( !current )
continue;
bmp_printf( FONT_SMALL, 400, y+=12,
"handler %08x\npriv %08x",
current->handler,
current->priv
);
if( (void*) current->handler != (void*) dialog_handler )
continue;
struct dialog * dialog = current->priv;
bmp_printf( FONT_SMALL, 400, y+=12,
"dialog %08x",
(unsigned) dialog->handler
);
if( dialog->handler == DlgLiveViewApp )
{
dialog->handler = (void*) new_DlgLiveViewApp;
bmp_printf( FONT_SMALL, 400, y+=12, "new %08x", new_DlgLiveViewApp );
bmp_hexdump( FONT_SMALL, 0, 300, new_DlgLiveViewApp, 128 );
//bmp_hexdump( FONT_SMALL, 0, 300, reloc_buf, 128 );
}
}
}
TASK_CREATE( __FILE__, reloc_dlgliveviewapp, 0, 0x1f, 0x1000 );