03:16
jcea has quit [Ping timeout: 268 seconds]
04:09
bonda_000 has joined ##raspberrypi-internals
07:25
Stromeko has quit [Ping timeout: 252 seconds]
07:30
Stromeko has joined ##raspberrypi-internals
10:25
f_ has joined ##raspberrypi-internals
12:16
<
bonda_000 >
any idea what this does? local_c._0_3_ = CONCAT12(*(undefined *)(param_1 + 0x198),*(undefined2 *)(param_1 + 0x19c));
12:18
<
clever >
bonda_000: feels like a 64bit load
12:19
<
clever >
double-check what the asm is doing in that area
12:19
<
bonda_000 >
CONCAT12
12:20
<
bonda_000 >
I'm not sure whether they left out functions that are not being used
12:20
<
bonda_000 >
or they are called in some weird way from a function table and Ghidra doesn't see it as it doesn't seem to go deep into recursion
12:20
<
bonda_000 >
isp_open seems to be an important one yet has no XREF
12:21
<
bonda_000 >
only from debug
12:22
<
clever >
try searching for the addr with s, rather then relying on xref's
12:22
<
bonda_000 >
I tried
12:22
<
bonda_000 >
it may just be a debug function
12:22
<
clever >
with that, i found a big fat function table with isp_open in it
12:23
<
clever >
the label is isp_module
12:23
<
bonda_000 >
the address where the function starts?
12:23
<
clever >
make sure to search both forwards and backwards
12:24
<
bonda_000 >
maybe that's what I didn't do
12:25
<
bonda_000 >
I'm trying to find where isp_globals is being set
12:25
<
bonda_000 >
or allocated
12:25
<
bonda_000 >
it seems to be an array of 72Kb large entries, seemingly one per frame
12:25
<
clever >
i also see a get_isp_module, that returns gp + 0x26f68
12:26
<
clever >
and isp_module (the function table) is at ef2ed68
12:26
<
clever >
youll notice, half the digits match
12:26
<
clever >
so get_isp_module is returning the function table
12:33
<
bonda_000 >
give me a sec
12:33
jcea has joined ##raspberrypi-internals
12:33
<
bonda_000 >
I've been saving this huge struct of 0x119ac bytes that I'm editing for isp_globals
12:34
<
bonda_000 >
Search for address tables?
12:34
<
clever >
ah, but get_isp_module might not be the right thing
12:34
<
clever >
yeah, search for the entry-point of isp_open
12:35
<
bonda_000 >
search for a scalar then?
12:35
<
bonda_000 >
Search for address tables gives me only three options as tick-boxes
12:39
<
bonda_000 >
oh, I see
12:40
<
bonda_000 >
it says Painting Field
12:41
<
bonda_000 >
Error Painting Field
12:41
<
clever >
that sounds like an internal error in ghidra
12:42
<
bonda_000 >
it blinks for a split second I see there is some Elf table
12:42
<
bonda_000 >
but when I try to scroll over it it's showing me this
12:43
<
clever >
try using `g` for goto, and `isp_module`
12:45
<
clever >
try restarting ghidra
12:45
<
bonda_000 >
yeah I have that
12:45
<
bonda_000 >
one sec
12:48
<
bonda_000 >
same thing
12:49
<
clever >
not sure what is going on then
12:49
<
bonda_000 >
but I can see isp_module
12:49
<
bonda_000 >
that one is ok
12:50
<
bonda_000 >
it's only blanking for isp_open
12:50
<
clever >
isp_module is a function table
12:50
<
bonda_000 >
and there is a reference to ed72264
12:50
<
bonda_000 >
within isp_module table
12:55
<
bonda_000 >
is that the reason I don't see any xrefs?
12:56
<
clever >
the reason is that ghidra mis-labeled isp_module as a byte array
12:56
<
clever >
when its a function pointer array
12:58
<
bonda_000 >
so the isp_open may also be something other than just plain bytes?
12:59
<
clever >
its a function
13:00
<
bonda_000 >
so that entry in the .symtab that doesn't paint in my window is just the .text of that function?
13:01
<
clever >
.symtab is the symbol table for the elf file
13:01
<
clever >
thats what gives a name to every address
13:02
<
bonda_000 >
memset(param_1,0,0x11aa0);
13:02
<
bonda_000 >
see that it zeroes out that huge struct that I was editing the last few days
13:02
<
bonda_000 >
it contains parameters that it then writes to hardware regs, among other things that I haven't figured out yet
13:02
<
clever >
yeah, thats a major hint about the size of a struct, and i use that a lot
13:03
<
bonda_000 >
most of the isp_ functions and especially isp_plat_ functions seem to take pointer to that struct as param_1
13:04
<
bonda_000 >
pardon, isp_plat_ add an offset to the beginning of that struct
13:04
<
clever >
that sounds like a struct within the struct
13:04
<
bonda_000 >
wish I knew where isp_open is getting called from
13:04
<
bonda_000 >
oh yeah
13:06
<
clever >
something likely uses the isp_module table to call isp_open
13:06
<
clever >
the question then, is how did isp_module get referenced
13:09
<
bonda_000 >
I dont get any references to that function table
13:10
<
clever >
yeah, thats what i havent figured out
13:11
<
bonda_000 >
that's some entry in the Elf header at .symtab + 0x1d480h
13:11
<
bonda_000 >
well if it's refernced via gp
13:11
<
bonda_000 >
then probably gotta look for certain operands
13:11
<
bonda_000 >
whatever is with gp ghidra doesn't go deep at all
13:11
<
bonda_000 >
that's why I'm doing this 0x119ac byte struct by hand
13:15
<
bonda_000 >
0ef2ed68 (func.table) - 0ef07e00 (gp) = 26f68
13:16
<
bonda_000 >
In fact, I had to increase my search limit to 50000 entries to get all gp references throughout the code
13:17
<
clever >
ah, if i search for that offset, i get the `get_isp_module()` function i mentioned earlier
13:18
<
bonda_000 >
mine isn't this fast, I'm searching Program text for operands "gp,26f68"
13:18
<
bonda_000 >
I'll look at that in the meanwhile
13:18
<
clever >
i did a byte search, same as my last screenshot
13:20
<
bonda_000 >
what's get_isp_pass
13:20
<
bonda_000 >
I will open as soon as its done it tends to crash when I use both firefox and ghidra
13:21
<
bonda_000 >
isp_globals the undefined8 entry in .sbss
13:22
<
bonda_000 >
seems to have an address of that 0x11a9c byte struct in its high 4 bytes
13:22
<
bonda_000 >
and then it iterates over by adding 0x11a9c to the iterator untill it equals a 0x0
13:23
<
bonda_000 >
linked list I guess?
13:23
<
bonda_000 >
of frames or more likely tile batches as each of these the isp_task runs through Isp_tiles_ready function
13:24
<
bonda_000 >
more like an array as it's just adding a constant offset on each iteration of the loop
13:25
<
bonda_000 >
first loop, it iterates over the whole array
13:26
<
bonda_000 >
second major loop, it stops at whichever isp_tiles_ready returns a '1'
13:26
<
bonda_000 >
isp_schedule() is the one I'm talking about
13:27
<
clever >
i still havent been able to make sense of all of that code
13:28
<
bonda_000 >
get_isp_tuner_ov5647
13:29
<
bonda_000 >
isn't ov5647 one of the cameras that raspberry pi supports?
13:31
<
clever >
the isp has some tuning profiles, to adjust for how sensitive the sensor is
13:31
<
bonda_000 >
the one that I got doesn't have any of those supported ones
13:31
<
bonda_000 >
sony icx415aq
13:32
<
bonda_000 >
compare the data sheet to that Sony one raspberry pi supports lol
13:32
<
bonda_000 >
imx219 or something
13:32
<
bonda_000 >
there's like a whole messaging systems over i2c and half the tuning is done on the camera side of hardware
13:33
<
bonda_000 >
I'm making a raw sensor
13:33
<
bonda_000 >
pure ADC input
13:34
<
clever >
there is also both analog and digital gain
13:34
<
clever >
the ISP will apply digital gain to the pixels, to fix the brightness
13:34
<
bonda_000 >
on the software side?
13:34
<
clever >
but there is a limit to how much it can do, so the ISP is also outputting stats on the average pre-gain brightness levels
13:35
<
clever >
and the software stack then sends i2c commands to the sensor, to adjust the analog gain
13:35
<
clever >
those i2c commands also have a lag on them
13:35
<
clever >
so the digital gain in the ISP can adjust every frame directly
13:35
<
clever >
while the analog gain has to take the stats from 1 frame, then change the sensor, then wait a few frames for the response
13:37
<
bonda_000 >
yeah in the datasheet I think they mean analog gain
13:38
<
bonda_000 >
but they also weirdly have dual adc
13:38
<
bonda_000 >
one adc channel to capture RgRb
13:38
<
bonda_000 >
the other adc channel for R/B
13:38
<
bonda_000 >
I don't know what's the benefit of that
13:39
<
bonda_000 >
presumably all effort to minimize noise on hardware so there is less to do in software
13:39
<
bonda_000 >
but that follows the C.D.S. block
13:40
<
bonda_000 >
so same C.D.S. block for R,B,Gr,Gb, but split ADCx
13:40
<
bonda_000 >
that's in the measurement section too, so it may just be the setup for measuring low/high levels
13:42
<
bonda_000 >
Plus I thought there was supposed to be a CDS per each column other than one CDS per frame
13:42
<
bonda_000 >
others say you don't need a CDS with CCD as it flushes the charge better than CMOS
14:01
<
bonda_000 >
I'm also searching in the Program text search for (gp+0x26f68) for loads/stores of isp function table
14:01
<
bonda_000 >
as an operand
14:02
<
bonda_000 >
and for gp,-195b9c and (gp-0x195b9c) for movs and loads/stores of isp_open respectively
15:35
dolphinana has joined ##raspberrypi-internals
15:42
dolphinana has quit [Ping timeout: 256 seconds]
15:47
f_ has joined ##raspberrypi-internals
16:44
bonda_000 has quit [Ping timeout: 260 seconds]
17:25
bonda_000 has joined ##raspberrypi-internals
17:25
bonda_000 has quit [Client Quit]
17:50
f_ is now known as f_|afk
17:51
f_|afk is now known as f_
19:11
bonda_000 has joined ##raspberrypi-internals
19:22
<
bonda_000 >
:clever
19:23
<
clever >
bonda_000: never seen that one before
19:23
<
bonda_000 >
it's saying something's wrong with r9 that keeps ping ponging a FILE *
19:24
<
clever >
that function disassembles just fine for me
19:24
<
bonda_000 >
also syntax's weird, mov param1, r9 as in mov r0, r9?
19:24
<
clever >
what addr is that opcode at?
19:25
<
bonda_000 >
0eea49ae 09 40 mov r9,param_1
19:26
<
bonda_000 >
0eea49bc 90 40 mov param_1,r9
19:26
<
clever >
thats just ghidra trying to help some, inserting the names from the decompile
19:27
<
bonda_000 >
that whole section of write_isp_ is broken for me
19:27
<
bonda_000 >
or most of it
19:34
<
bonda_000 >
so I realize the isp block probably doesn't run by itself
19:35
<
bonda_000 >
it is probably instantiated only when a program is run such as camplus_setup_isp
19:35
<
clever >
yeah, it seems to be heavily command driven, and software has to tell it what to do at every step
19:35
<
bonda_000 >
were you able to fix this
19:35
<
bonda_000 >
0eca4e56 87 90 8a fb bl logging_message undefined logging_message(uint p
19:35
<
bonda_000 >
-- Flow Override: CALL_RETURN (CALL_TERMINATOR)
19:36
<
bonda_000 >
it doesn't matter what return type it's always like this
19:37
<
clever >
what are the attributes on loggin_message?
19:37
<
bonda_000 >
just fixed it with un-ticking the "No return"
19:38
<
bonda_000 >
other places it's not behaving as good
19:38
<
bonda_000 >
but anyway
19:38
<
clever >
no return is only for very special functions like exit()
19:38
<
clever >
normally it should never be checked
19:39
<
bonda_000 >
now that there's no more "Flow override" two bytes after bl logging message are not interpreted
19:39
<
bonda_000 >
0eca4d3a 84 ?? 84h
19:39
<
bonda_000 >
0eca4d3b e6 ?? E6h
19:39
<
clever >
select the first byte and hit d
19:39
<
bonda_000 >
its very common in my decompile
19:39
<
bonda_000 >
nothing happens
19:40
<
clever >
right click the first byte, select decompile
19:40
<
bonda_000 >
"Disassemble" is what I have
19:42
<
bonda_000 >
E6 84 doesnt look like a valid two byte opcode anyway
19:42
<
clever >
screenshot?
19:43
<
bonda_000 >
I mean it somehow gets the rest of it sort of logically sound still
19:43
<
clever >
you need to clear the opcodes after it
19:43
<
clever >
that rsub is wrong
19:44
<
bonda_000 >
oh that fixed it
19:44
<
clever >
the opcode at 0eca4d3a is likely over 16 bits in size
19:44
<
clever >
and because the rsub is in the way, it cant fit the proper one
19:44
<
clever >
it should even tell you so in the status bar
19:46
<
bonda_000 >
yeah there was some sort of red banner
19:46
<
bonda_000 >
stuff like undefined4 extraout_r4_00;
19:47
<
bonda_000 >
still extraout r1, r2, r3, r4, r5 mean it depends on values of these regs set before we entered this function
19:48
<
bonda_000 >
this one also has no xref so another dead end
19:48
<
clever >
extraout mean something didnt decompile properly
19:57
<
bonda_000 >
I don't know it keeps graying it out for me
19:57
<
clever >
because ghidra got confused about where the function ends
19:57
<
clever >
select the first opcode in the function, hit the delete key once, and it will un-function it, then hit f
19:58
<
clever >
this happens a lot
19:58
<
clever >
due to the no-return, ghidra thinks the function ends at that logging_message, and only recreating the function will fix it
19:59
<
clever >
ah, there is also a re-create function option, in the right click menu
19:59
<
bonda_000 >
there is this $t as well as camplus_setup_isp
19:59
<
clever >
yeah, delete the function on that
19:59
<
bonda_000 >
so when I hit delete it removes the camplus_ but not the $t
19:59
<
clever >
it will cause the same problem
20:00
<
clever >
$t, $S, and $c are never functions, delete the function on sight
20:00
<
bonda_000 >
what Delete does is just remove the function name
20:00
<
clever >
what it does varies heavily, based on context
20:00
<
clever >
in this case, it removes just the function tag, on the first hit
20:01
<
clever >
if you hit it again, it will remove the label, undo that
20:01
<
bonda_000 >
it deletes camplus_setup_isp, then deletes $t, then I'm left with FUN_0eca4cf0
20:01
<
clever >
you hit it too many times, undo that
20:01
<
bonda_000 >
delete or C?
20:01
<
clever >
just use the undo button in the toolbar
20:02
<
bonda_000 >
oh i see
20:02
<
bonda_000 >
it depends on where you hover over
20:02
<
bonda_000 >
it can delete params, or the function
20:02
<
bonda_000 >
yeah I recreated, still with all the extraout_rN
20:02
<
clever >
if you right click, youll see the delete hotkey is on different things, depending on where you clicked
20:03
<
bonda_000 >
although its not grayed out anymore which is better
20:03
<
clever >
where do you see the extraout?
20:04
<
bonda_000 >
opcode at 0eca4cf0
20:05
<
bonda_000 >
camplus_setup_isp() do you also have all the extraout?
20:05
<
clever >
none at all
20:05
<
clever >
screenshot?
20:08
<
clever >
the arguments to logging_message are messed up
20:08
<
clever >
screenshot the edit function on that one
20:09
<
clever >
thats not the right window
20:10
<
bonda_000 >
I know I was doing that one before I read your message
20:10
<
clever >
yeah, you have too many arguments on there
20:10
<
clever >
it should look like my screenshot
20:13
<
bonda_000 >
that made it slighly better but still a lot of extraouts, 3 local_
20:14
<
bonda_000 >
undefined4 camplus_setup_isp(int param_1,int param_2)
20:15
<
clever >
now that i look, i notice i do have 3 extraout's
20:16
<
bonda_000 >
I wonder why it puts those as extraouts and not input arguments
20:16
<
clever >
because one of the functions that got called, has an extra output
20:16
<
clever >
and the decompiler cant figure out which one
20:16
<
bonda_000 >
extra output
20:16
<
bonda_000 >
what does that mean
20:17
<
bonda_000 >
isn't output just an r0?
20:17
<
clever >
an extra output, is when its more then just r0
20:17
<
clever >
thats what the extra means
20:17
<
bonda_000 >
what would that look like
20:17
<
clever >
a function that set both r0 and r1
20:17
<
bonda_000 >
a function with multiple outputs
20:17
<
clever >
and then whatever called it, used r1
20:18
<
bonda_000 >
and that function didnt stash r1?
20:18
<
clever >
the ABI says that a function is free to destroy the data in r0 thru r5
20:18
<
clever >
only r6 and above have to be stashed
20:19
<
bonda_000 >
so r1 was just a scratch variable then? how does the decompiler guesses that r1 has anything valuable
20:19
<
clever >
because something used r1, after it should have been clobbered
20:19
<
clever >
you will have to read the assembly, and figure out what is going on
20:21
<
clever >
just before a call to camplus_stabilise_compensate, i can see it mov'd into r2, r0, and r1
20:21
<
clever >
setting up 3 arguments
20:21
<
clever >
then it `bl camplus_stabilise_compensate`
20:22
<
clever >
afterwards, it loads r4 from ram, because r4 was clobbered
20:22
<
clever >
and it OR's that new r4, with r0, the return value
20:22
<
clever >
then stores that back to the same place r4 came from
20:23
<
clever >
which is basically just `foo |= r0`
20:23
<
clever >
and now i see, where the problem is
20:23
<
clever >
Ivar4 = extraout_r1_01;
20:24
<
clever >
(*pcVar5)(iVar9+offset, iVar4, pcVar5);
20:24
<
clever >
its calling a function pointer, and ghidra guessed wrong on how many args the function pointer wanted
20:24
<
clever >
ghidra assumed the function pointer takes 3 args
20:24
<
clever >
and nothing set r1 and r2
20:24
<
clever >
so ghidra imagined up an extra output, that never existed
20:26
<
clever >
so, on that function pointer line, right click, override signature, and type in something that only accepts 1 argument
20:26
<
bonda_000 >
pcVar5 = *(code **)(*(int *)(param_1 + 0x64fc) + 0xd4);
20:26
<
bonda_000 >
at the very beginning
20:26
<
clever >
yeah, so the problem is, you need to figure out what pcVar5 is pointing to
20:27
<
clever >
and then fix the args on that function
20:27
<
bonda_000 >
pcVar5 = *(code **)(*(int *)(param_1 + 0x64fc) + 0x24);
20:27
<
clever >
something wrote to offset 64fc
20:28
<
bonda_000 >
(*pcVar5)(iVar10 + 0x28594,iVar4,pcVar5);
20:28
<
bonda_000 >
code pointers
20:28
<
bonda_000 >
is why most important stuff has no xrefs, I guess
20:31
<
clever >
(*(code *)param_1->fun_table[9])(&pcVar10[5].field_0x5594,iVar4,param_1->fun_table[9]);
20:31
<
clever >
if i change `param_1` into a struct that is big enough (i just went 0x7000 bytes)
20:31
<
clever >
and then change the field at 64fc into a `void**`
20:31
<
clever >
then it becomes this
20:31
<
clever >
now you can clearly see, that param_1 is being passed to the function
20:31
<
clever >
param_2 is what ghidra just imagined out of nowhere
20:32
<
clever >
and param_3 is the function pointer itself, the reason ghidra imagined param_2
20:32
<
clever >
ghidra saw something set r0 and r2, so clearly its a function that takes 3 args, r0/r1/r2
20:32
<
clever >
and nothing set r1, so it must have been an extra output!
20:38
<
clever >
so if you just reduce the function at [5] to taking 1 arg, the imaginary extraout will vanish
20:44
<
clever >
bonda_000: and there it is, camplus_open, uses vclib_memset (vectorized memset) to zero out a 0x70810 byte struct, the camplus_state
20:46
<
clever >
bonda_000: oh, wow, it calls dlshared_get_vll_symbol!!
20:46
<
clever >
ive heard that the firmware still has dynamic module loading in place
20:47
<
clever >
and yep, i thought so!
20:47
<
clever >
that string is next to a reference of get_isp_module from hours ago!
20:47
<
clever >
which means, the fun_table above, is the isp_module
20:48
<
clever >
bingo, all of your xref questions are solved
20:52
<
bonda_000 >
no references to isp_open?
20:52
<
clever >
one refernece, in camplus_isp_open
20:54
<
clever >
first, look in camplus_open, you will see a call to rtos_malloc_priority, and vclib_memset, to create a "camplus ctrl object" that is 0x70810 bytes in size
20:54
<
clever >
create a struct for that, and re-type the pointer
20:55
<
clever >
next, in camplus_setup_isp, param_1 is a pointer of that type
20:55
<
bonda_000 >
I got this
20:55
<
bonda_000 >
(**(code **)(param_1 + 0x54))(param_1,0xfffffffe,0,*(undefined4 *)(param_1 + 0x58));
20:56
<
clever >
in which function?
20:56
<
bonda_000 >
in camplus_setup_isp()
20:56
<
bonda_000 >
right after camplus_unlock() call
20:56
<
clever >
i dont see that one
20:57
<
clever >
do you have the 0x70810 byte `struct camplus_state` yet?
20:58
<
bonda_000 >
I create this manually?
21:00
<
clever >
now create another struct, called isp_function_table, it is 388 bytes in size
21:00
<
clever >
and every word in there, is a function from the isp_module table
21:02
<
clever >
but ghidra is still wrong on the arg count, and imagined up the 2nd and 3rd param
21:03
<
bonda_000 >
done as well
21:03
<
clever >
but i can just go to that function, and see that its a uint foo(uint)
21:03
<
bonda_000 >
so param1 is camplus_ctrl_object?
21:03
<
clever >
so down in the data type manager, i can create a new function definition, i'll call it uint oneone(uint)
21:04
<
clever >
then in the `struct isp_function_table`, i change isp_mark_schedulable to be a `oneone*`
21:04
<
bonda_000 >
undefined4 camplus_setup_isp(camplus_ctrl_object *param_1,int param_2)
21:04
<
bonda_000 >
is what the signature is now
21:05
<
clever >
and now ghidra has stopped dreaming up args that dont exist
21:05
<
bonda_000 >
param2 must be deleted?
21:05
<
clever >
not on camplus_setup_isp
21:05
<
clever >
here, on line 153
21:06
<
bonda_000 >
so param1 at some offset has that second struct within it?
21:10
<
clever >
and did you fill that struct with the names i showed?
21:11
<
bonda_000 >
no but there seems to be another function table there
21:11
<
bonda_000 >
(**(code **)¶m_1->field_0x54)(param_1,0xfffffffe,0,*(undefined4 *)¶m_1->field_0x58);
21:12
<
bonda_000 >
thats line 96 in my decompile window
21:12
<
bonda_000 >
gonna do it right now
21:13
<
clever >
if you right click on 54, and search for references (after tagging the camplus_ctrl_object * in all related functions)
21:13
<
clever >
youll find its set in camplus_error
21:14
<
bonda_000 >
so just copy all the names from that function table we spoke earlier today?
21:14
<
clever >
and for bonus points, create a function type for each
21:14
<
clever >
2024-05-08 18:03:38 < clever> so down in the data type manager, i can create a new function definition, i'll call it uint oneone(uint)
21:14
<
bonda_000 >
at 0ef2ed68
21:15
<
clever >
2024-05-08 18:04:07 < clever> then in the `struct isp_function_table`, i change isp_mark_schedulable to be a `oneone*`
21:15
<
clever >
thats the one
21:16
<
bonda_000 >
isp_module to be exact
21:17
<
bonda_000 >
why such special attention to isp_mark_schedulable?
21:18
<
bonda_000 >
let me do this and see how that goes
21:18
<
clever >
because isp_mark_schedulable is being called, and ghidra imagined it took 3 args
21:18
<
clever >
and thats what caused the extraout
21:19
<
clever >
but if you correctly label it as taking 1 arg, the extraout vanishes
21:19
<
clever >
also, doing all of this, solves the question of where isp_open gets called
21:19
<
bonda_000 >
right here?
21:20
<
bonda_000 >
undefined4 __stdcall isp_mark_schedulable(int param_1)
21:20
<
bonda_000 >
mine takes only 1 arg
21:20
<
clever >
2024-05-08 17:48:01 < clever> bingo, all of your xref questions are solved
21:20
<
clever >
2024-05-08 17:52:12 < bonda_000> no references to isp_open?
21:20
<
clever >
2024-05-08 17:52:56 < clever> one refernece, in camplus_isp_open
21:20
<
clever >
bonda_000: yep, but after going thru a dozen pointers and function tables, ghidra lost track of that
21:20
<
bonda_000 >
I'm not done with the struct yet
21:20
<
clever >
and with the xref broken, ghidra is assuming it takes 3 args when it gets called
21:21
<
bonda_000 >
well it doesn't know what is getting called
21:21
<
clever >
yeah, you need to do everything i said above, then it will have the right type again
21:23
<
clever >
thats not right
21:23
<
clever >
you want to create a function in the data type manager, and then make it a pointer to a function
21:23
<
clever >
also, you have the offset entirely wrong
21:23
<
clever >
init is at 0, not 0x120
21:27
<
bonda_000 >
isn't there a better way to do it
21:27
<
clever >
i dont know of any better way
21:27
<
bonda_000 >
like map that isp_module array into this struct
21:28
<
clever >
you can change the type of isp_module to isp_function_table
21:28
<
bonda_000 >
so that the function names appear properly?
21:28
<
clever >
but you still need to create all of the fields
21:48
<
clever >
yep, looks good
21:49
<
clever >
now if you look back in the function where you saw the extraout's, they should be fixed
21:50
<
clever >
and if you label everything as using that camplus ctrl struct properly, you can right click on isp_open in the struct, and find all references
21:50
<
clever >
and it will lead you to the missing isp_open xref you couldnt find yesterday
21:53
<
bonda_000 >
i counted 14 extraouts before now 11
21:53
<
bonda_000 >
code * callouts now look like this
21:53
<
bonda_000 >
pcVar10 = (code *)param_1->field25852_0x64fc->isp_set_hresize;
21:54
<
bonda_000 >
well it's not yet pointing at the actual function
21:54
<
clever >
now if you goto isp_set_hresize, youll see its an uint isp_set_hresize(uint, void*)
21:55
<
clever >
create another function definition in the data manager, maybe `uint uint_ptr(uint, void*)`
21:55
<
clever >
and then fix the type in the function table struct
21:56
<
bonda_000 >
void isp_set_hresize(int param_1,void *param_2)
21:56
<
bonda_000 >
the actual function
21:56
<
clever >
mine returns uint
21:57
<
clever >
but always returns 0
21:57
<
bonda_000 >
undefined4 isp_set_hresize(int param_1,void *param_2)
21:57
<
bonda_000 >
memcpy was off
21:58
<
bonda_000 >
it doesn't know whether its signed or unsigned so it puts undefined4?
21:58
<
clever >
i generally use uint
21:58
<
clever >
but if it looks negative, i use int
21:59
<
clever >
also, looking at the call-site, where setup_isp calls set_hresize, i can see both args, are iVar10 plus an offset
21:59
<
clever >
so its actually 2 pointers
22:00
<
bonda_000 >
yeah it sometimes does that but arithmetic is corresponding to it
22:00
<
clever >
and then back in isp_set_hresize, the 2nd pointer is clearly a struct
22:00
<
clever >
so fixing the function definition (once we have that struct) would enable labeling things back in setup_isp
22:01
<
bonda_000 >
how adding another placeholder function definition
22:01
<
bonda_000 >
is going to help seeing the actual function at physical address 0ed74958
22:02
<
bonda_000 >
<clever> create another function definition in the data manager, maybe `uint uint_ptr(uint, void*)`
22:03
<
clever >
ive since changed that one, to `uint set_hresize(void*,void*)`
22:05
<
bonda_000 >
I guess it doesn't accept const
22:05
<
bonda_000 >
fixing that function table address in one of the structs
22:06
<
bonda_000 >
because you said the way you altered it made it see arguments correctly
22:06
<
bonda_000 >
oh right
22:06
<
bonda_000 >
void * is not giving it any hints
22:06
<
bonda_000 >
so right
22:06
<
clever >
but at least the number of arguments is set
22:07
<
bonda_000 >
that's why we need <clever> create another function definition in the data manager, maybe `uint uint_ptr(uint, void*)`
22:07
<
clever >
and that stops ghidra from dreaming up extraout's
22:07
<
clever >
if (*(char *)(iVar10 + 0x3b196) != '\0') {
22:07
<
bonda_000 >
so now go over that list and add correct function signatures
22:07
<
clever >
(*param_1->isp_module->set_hresize)((void *)(iVar10 + 0x28594),(void *)(iVar10 + 0x3a044));
22:07
<
clever >
and now that things are labeled better
22:07
<
clever >
i can clearly see, this is an if statement, that is checking if resizing is needed
22:08
<
clever >
and only if resizing is needed, does it set the resize params
22:08
<
clever >
iVar10 = ¶m_1->field_0x0 + param_2 * 0x35110;
22:09
<
clever >
i can also see, that the main camplus state contains an array at offset 0
22:09
<
clever >
each array element, is 0x35110 bytes long
22:09
<
clever >
i'll name that camera_channel in the structs
22:10
<
bonda_000 >
do I need to make a function placeholder each time or is there a more generic way
22:10
<
clever >
thats why i was using names like uint_ptr
22:10
<
clever >
for something that takes an uint and a pointer
22:10
<
clever >
then i can reuse that for every function taking an uint and a ptr
22:10
<
bonda_000 >
(uint *)(uint arg1, uint arg2) should work?
22:18
<
bonda_000 >
undefined is just a byte correct?
22:20
<
bonda_000 >
Unrecognized data type of (undefined*)(void)
22:20
<
clever >
you need to create it in the data type manager first
22:23
jcea has quit [Remote host closed the connection]
22:40
<
bonda_000 >
are "local_" variables also some sort of non-optimal decompilation?
22:41
<
clever >
just another name the decompiler seems to pick
22:44
<
bonda_000 >
it seems to put intermediate results of the "CONCAT" operations in "local_" variables
22:46
<
clever >
CONCAT is usually a sign that its decompiled things wrong
22:46
<
bonda_000 >
many of those isp_plat_write_ functions use CONCAT12, CONCAT13, CONCAT22 to assemble bit fields to write into peripheral registers
22:48
<
bonda_000 >
undefined4 isp_plat_write_defective_pixel_auto(int param_1)
22:49
<
bonda_000 >
undefined4 isp_plat_write_distortion(byte *param_1) this one has CONCAT22
22:49
<
bonda_000 >
undefined4 isp_plat_write_fringing(undefined2 *param_1) all CONCAT22
22:50
<
bonda_000 >
its using CONCAT22 to put together FFFF and FFFF bit fields
22:50
<
bonda_000 >
like in the FG_GR_POS register of an ISP block
22:51
<
bonda_000 >
as in, upper 16 bits and lower 16 bits of a 32 bit peripheral register
22:55
<
bonda_000 >
void * memcpy(void *__dest,void *__src,size_t __n)
22:55
<
bonda_000 >
is this the same as you have?
22:56
<
bonda_000 >
no return un-ticked
23:00
<
clever >
the conat22's in isp_plat_write_fringing, do look valid, but i would have just written that as a bunch of `foo || foo[8]<<16`
23:01
<
clever >
i'm not sure why it went with the concat instead, but it is valid
23:01
<
clever >
my memcpy does look the same
23:14
<
bonda_000 >
it's just the 22
23:14
<
bonda_000 >
it's concatenating 16 bits and 16bits so concat22 sounds like it's concatenating on a 22-bit boundary
23:16
<
clever >
you would need to check the ghidra docs to see what that means