Related
Hey people, I may be being a bit newb-ish here but I just cant get how this is done:
(Code is C++)
Im trying to fill a 3d array with values, for readability i am addressing the 3rd dimension of it manually but i have written the following. The syntax is identical to a 2d array (a 2d array of size 4x2).
Code:
int pattern1[11][4][2],pattern2[11][4][2];
...
pattern1[0]={{-1,0},{-2,-1},{-3,-2},{-4,-3}};
pattern1[1]={{-1,-1},{-2,-2},{-3,-3},{-4,-4}};
pattern1[2]={{0,-1},{-1,-2},{-2,-3},{-3,-4}};
pattern1[3]={{0,-1},{0,-2},{-1,-3},{-2,-4}};
pattern1[4]={{0,-1},{0,-2},{0,-3},{-1,-4}};
pattern1[5]={{0,-1},{0,-2},{0,-3},{0,-4}};
pattern1[6]={{0,-1},{0,-2},{0,-3},{1,-4}};
pattern1[7]={{0,-1},{0,-2},{1,-3},{2,-4}};
pattern1[8]={{0,-1},{1,-2},{2,-3},{3,-4}};
pattern1[9]={{1,-1},{2,-2},{3,-3},{4,-4}};
pattern1[10]={{1,0},{2,-1},{3,-2},{4,-3}};
pattern2[0]={{-1,-1},{-1,-2},{-1,-3},{-1,-4}};
pattern2[1]={{0,-1},{0,-2},{0,-3},{0,-4}};
pattern2[2]={{1,-1},{1,-2},{1,-3},{1,-4}};
pattern2[3]={{1,-1},{2,-2},{2,-3},{2,-4}};
pattern2[4]={{1,-1},{2,-2},{3,-3},{3,-4}};
pattern2[5]={{1,-1},{2,-2},{3,-3},{4,-4}};
pattern2[6]={{1,-1},{2,-2},{3,-3},{4,-3}};
pattern2[7]={{1,-1},{2,-2},{3,-2},{4,-2}};
pattern2[8]={{1,-1},{2,-1},{3,-1},{4,-1}};
pattern2[9]={{1,0},{2,0},{3,0},{4,0}};
pattern2[10]={{1,1},{2,1},{3,1},{4,1}};
However i am getting compiler errors!?! Is this the correct way to assign values or am i waaay off??
You can only do this kind of multiple initialization during variable declaration.
Later on in code you have to assign each component of the array seperatly, or use pointer tricks, memcpy etc.
So had you wrote something like:
Code:
int pattern1[11][4][2] = {{{1, 2}...
It might have worked.
for such things it's generaly a better path to init it with the content of
a file or DB
hardcoded init's are bad in general
Hi everyone.
I own a HTC Polaris with IBM J9 Midlet Manager.
Does anybody notice strange behaviours while loading Image data from filesystem and/or resources in JAR files?
It seems to me that images whose size >= ~5KB, no matter if they are in PNG or JPEG format, cannot be loaded into an Image object.
I can load plenty of small images (summing over 5KB total size) but I cannot load, say, a 200x100 image and this is quite strange. The same JAR works fine on a Nokia 6111.
Increasing the heap size (-Xm? options) seems not working, too.
Is it a problem with J9 ? I must use this manager, since I need Bluetooth and Filesystem APIs.
Thanks in advance.
Today I've figured out that it is not the size of the image, but its shape
In fact, I can use SQUARE images up to screen width, but not RECTANGULAR ones!
Does anybody confirm this?
Perhaps a useful detail: I'm using 8-bit indexed PNG files.
Hello all,
since I'm not allowed to post a reply in the thread where it would belong (http://forum.xda-developers.com/showthread.php?t=604140), I'm forced to open a new thread in another forum which I have access to. Sorry.
The patch provided in the above thread did not work for me. Instead it made things worse in that the program now occupies only quarter of the screen. Probably autoscaling has been disabled when compiling. So, by help of the provided source in the first post but lacking a development environment I identified the interesting constants in the binary and patched the executable, and when that worked, the CAB (luckily, the executable is there uncompressed albeit not in one continuous chunk). The patch makes Noterrific work on QWVGA (240x400) and, through autoscaling, on WVGA. I have tested it on HTC HD and HD2.
Only for those who are interested: The interesting parts in the code are the function ResizeWindow in NoteView.vb and the Size constants for TabControl1 and ProgramTab in PrefWin.vb. The load instructions are 0x20 (for 32 bit integers) and 0x1F (for 8 bit signed integers), the constants are little endian. We have to distribute 80 (0x50) more pixels vertically, so the full height of the note view changes from 260 (0x04 0x01) to 340 (0x54 0x01). In the split view I have distributed the 0x50 pixels as 0x18/0x38. So the other constants 80, 88, 180, 188, 268, 270 and 244 change accordingly. The code layout is straightfdorward, and you can find the constants in the order they are in the VB sources. EDh makes a great job for this!
BTW, if anyone has problems loading .ntn files on his new device, the problem might be the decimal separator in the version attribute of the file. I had "0.5" there, but on my new device it had to be "0,5"!
Hope you like the patch!
Cheers
profi48
hi all.
at first, sorry for my english - it's not my first language.
so...
you can find a few chines vendors with identical device named as "LA10 smartwatch" (Lige even not try to naming this model - just "smartwatch"), even you may order a lot with your own logo.
but all of it would have an identical characteristics, uses one app "ffit" and identifies via BT as "LA10_XXXX" where "XXXX" would be a last 2 bytes of a mac.
also all of vendors use an identical promo images, so you'll easily detect it. few of it:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
as I'd understood, the original developer was a Linwear, in case "LA" seems may means "Linwear AMOLED", also Linwear have as usual description in promo images, as manual, as link to all of applications. if you'll interesting, you can learn more here https://www.linwear.com/article/1321.html
btw. Lige have a variant with stainless steel strap (I have an exactly this).
ok. I'll think that's enough for intro, so let's start...
Spoiler: about watchfaces.
while default watchfaces with a clock hands, uploadable seems can be only a digital, or it must have a different structure. as I have no one of watchface (further "wf") with clock hands, I can talk about digitals only.
structure is a bit easy:
0000-0009header with bits of used options00A-019Fparameters of an options. every option have a personal offset and similar structure01A0-...graphical resources in rgb565 format (2 bytes per pixel)
structure of a parameters are:
2 bytesX position2 bytesY position2 bytesframe width2 bytesframe height (not of texture)1 byteframes count4 bytetexture offset. numerics of steps, pulse and calories have a few of offsets equal maximum possible digits, what theoretical may use different textures but with identical parameters
while I'd investigate wf structure, I'd make a little excel with full descriptions and wf model. all is automated, all what you need, just insert a sequence of first hex-bytes 0000-01F9.
feel free to use it if you want
Spoiler: images
excel
Spoiler: wf editor
a little tool, what allow you modify wf or make your own
I did not tried to make an integrated photoshop, so you must import/export bitmaps via clipboard.
keep in mind:
- a clear black (0, 0, 0) would be treated as a transparent color by your watch, while editor not support transparency.
- all unused resources would not be saved in wf file.
- parameters have no any correctness check (frames count for sample), so you may set any, but it may works incorrect.
- background layer must be exactly 454x454, or it'll be looks lake a damaged. but you may disable bg layer and get just a black screen as a bg.
- file open dialog would appear on right click of a text field.
Spoiler: images
LA10WFTool.zip
Spoiler: direct working via BT
original "ffit" app will not allow you to upload any wf, so you must upload it manually.
Spoiler: upload algorithm
at first, you must enable notifications of a "00001603-0000-1000-8000-00805f9b34fb" characteristic (further "1603")
all packets must be sent to a "00001602-0000-1000-8000-00805f9b34fb" characteristic (further "1602")
- prepare header:
00-02first 3 bytes are zero03-064 bytes of a wf file size07size of MTU08-09size of a "page"0Amust be = 1
- increase MTU. in original to 244
- split the file
- - at first, split by "pages". in original, page size is a 4096. so you must split your file on a chunks of 4096 bytes.
- - now split the pages on blocks with size of (MTU - 2) i.e. by 242 bytes (244-2=242). keep in mind, what last chunk in page would be a 224 byte of size instead of 242 in case 4096 mod 242 = 224.
- - for every block, add a 2 bytes counter (starts from "01") at forward.
now you are ready to send wf. all packets must be send at 1602, any callbacks catch at 1603.
- send a header.
- wait 4 changes at 1603. last two wold be a "00 00 13 00", then "00 00 12 00".
- start sending a blocks sequentially.
- after every 17 blocks, before sending a next, you'll must send "00 00 17" at 1602 and wait a response from 1603. usually it's a "00 00 14", but I don't check, just wait an any.
- after sending a last part, you must send "00 00 17" for the finish.
if all is ok, you'll see your wf else - default wf.
of course you need an app.
algorithm are described, so you may make your own app, or use my. but actually I'm not a programmer (just an angry customer), so don't blame me about rugged code, I write it as can. in excuse - I even never listen about kotlin before((
so I've got an existed sample as a base and add required functional. the best way what I'll found is a "BLE Starter" of a Punch Through (team?). very thanks them for it.
sources are here https://github.com/PunchThrough/ble-starter-android big article about BT working are here https://punchthrough.com/android-ble-guide/
Spoiler: the app
at first unbound your smartwatch in ffit. in case device may be bounded to only one app.
- bound via app and look at 1602 characteristic. you don't need to enable 1603 manually in app, it would be enabled automatically. MTU would be set automatically too.
- tap 1602 characteristic and chose any write method
- in payload dialog, type just only one letter "w" (w/o quotes). tap "ok" and select your wf in open file dialog.
- now just wait. I make it by callbacks, so process would have a long time ~15 minutes per megabyte. I'll try to rewrite it latter from callbacks to blind write (write with no response via timer), but not soon. just have no time for it now.
the app BLE_Starter_base.zip
source ble-starter-android_srs.zip
Spoiler: View and download watch faces directly from ffit server
I've finish a little tool, what allow you to discover watch faces directly on ffit server.
at this time, it have an only 100 of different sizes. useful as resources only and editable via my LA10WFTool
now you can scan ffit server for watch faces by ID. it's allow you to get over 45k items, but a lot of it are duplicated. seems not compatible with la10, but may be used as resources for customizing.
FFitWFDownloader.zip
I have a figured out how to send messages, so if someone interesting, I'll add later.
also all stuff would be available at my gdrive.
that's all. have fun. hope it would be useful for someone.
*********
LA10WFTool - updated (removed check for import image more than 454x454)
*********
LA10WFTool - minor bug fixes and ui improvement (mostly scrolls over nud's)
*********
16/11/22 - FFitWFDownloader
- added "Investigation" ability, to "discover" watch faces by ID. over 45k, but a lot of duplication.
*********
23/11/22 - FFitWFDownloader
- reworked "Investigation" section.
- added "Download Range" ability.
Hey VXSX, great stuff! I was exactly looking in this direction but I had still not much time and was just starting. I believe many of those smartwatches come from the same manufacturer or seem to have very similar HW. Your watch and mine seem very similar to those from the dtno1.com
Anyway, first of all. Can you say something about the filenames in use? In the app (FitCloudPro) used with my phone I can see a set of 4 files for every wf, they seem to be in pairs based on their sizes. One pair is quite large (e.g. hundreds of KB) and one is much smaller. Any idea? How is it for you?
Will look into our files and will try to use your findings as well.
Thanks and keep posting!
the_cipo said:
Can you say something about the filenames in use? In the app (FitCloudPro) used with my phone I can see a set of 4 files for every wf, they seem to be in pairs based on their sizes. One pair is quite large (e.g. hundreds of KB) and one is much smaller. Any idea? How is it for you?
Click to expand...
Click to collapse
at first time, I'd tried to replace wf file for ffit app "on the fly" via proxy, but had fail. app download my file, but didn't to upload in the watch. seems app check crc and treat my file as corrupted. manual uploading have no mater for the name of a file. anyway, watch even don't know about name in case you upload file data only, not the name.
vxsw said:
at first time, I'd tried to replace wf file for ffit app "on the fly" via proxy, but had fail. app download my file, but didn't to upload in the watch. seems app check crc and treat my file as corrupted. manual uploading have no mater for the name of a file. anyway, watch even don't know about name in case you upload file data only, not the name.
Click to expand...
Click to collapse
But do you also have more files in the app dir for every single wf?
app have no accesable dir. but seems have a some sort of hidden cache, in case it'll not redownload wf every time. as I've understood through sniffing, wf have stored on server "body" and "preview" image separatelly. both downloadable via direct http link both have a names, but it's actual for vendor app only. exactly device requires only content of a wf file ("body") what must be correctly prepeared and upload by algorithm what I've described above. device did not get any info about names and/or preview.
App has an accessible dir on the phone. In my case is "\Internal shared storage\Android\data\com.topstep.fitcloudpro\files\Download"
In this dir I can find 4 files for every wf:
Here I selected 4 belonging to the same wf. I did a few tests and this dir gets 4 more files for every new wf.
ffit have no similar dirs. and/or I had not find any method to get access to it.
looks pairs of files have an identical size. what about content? attach something pls, I would like to look at this. also some sort of preview would be nice too.
Sure, this is the smallest I found.
With its 4 files following. As you can see the wf (above pic) has a reported size of 192KB which matches the two files below. So this data is consistent.
And these are the small ones (related to the same wf). Maybe this file is the picture of the wf presented in the UI (attached above).
CONFIRMED: both the 2 small files are the PNG of the wf (res 368x368). Probably that one used in the preview.
vxsw said:
ffit have no similar dirs. and/or I had not find any method to get access to it.
looks pairs of files have an identical size. what about content? attach something pls, I would like to look at this. also some sort of preview would be nice too.
Click to expand...
Click to collapse
Do you have the phone USB set in sebug mode? It might help
first two looks like a wf, but seems have a some sort of compression. in case even 368*368=135424 and it's only bg pixels count, while file size is only 186496.
also pairs are identical, so not sure what name have meaning for device. may be for app only as some sort of check.
the_cipo said:
Do you have the phone USB set in sebug mode? It might help
Click to expand...
Click to collapse
I use a wi-fi debugging, but for why?
Yeah, the two pairs are identical. probably the name is used for some check.
I am looking with HEX editor and you can see some blocks (in the wf file). E.g. from 00x0 to 1ffx0 and from 200x0 to 5ffx0. One more starting at 4f00x0 (or 4f20x0) with many zeros before that.
The block 0600x0 starts with ASCI "TBUI" and ends with the last 4 ASCI bytes in the file (at 2d87fx0) with again "TBUI" string.
vxsw said:
I use a wi-fi debugging, but for why?
Click to expand...
Click to collapse
Just thinking about what would cause you not to see hidden files.
vxsw said:
first two looks like a wf, but seems have a some sort of compression. in case even 368*368=135424 and it's only bg pixels count, while file size is only 186496.
Click to expand...
Click to collapse
Why would you expect to be exactly 135242? I have bin wf files of almost 1 MB. I don't think it has to do with screen resolution. Can you try to identify the protocol and blocks inside the bin?
the_cipo said:
Why would you expect to be exactly 135242?
Click to expand...
Click to collapse
it's just a pixels count. you said:
the_cipo said:
(res 368x368)
Click to expand...
Click to collapse
so I'd suggest, what wf have a background with 368x368 resolution and it's an exactly square of a 135424 pixels (368x368=135424). if it would be a plaine bmp, it must have a [size] = [quantity of all pixels] x [bytes per pixel]. so even it would have at least 2 bytes per pixel, it'll must have size = 368x368x2 = 135424x2 = 270848 bytes only for bg texture. + header + some parameters. so as it have an only 184k bytes it must have a some sort of compression or it's something other, what at least have no bg texture.
the_cipo said:
Can you try to identify the protocol and blocks inside the bin?
Click to expand...
Click to collapse
I can try, but have no enough time at now. try to gather 5-10 wf with previews, each wf in personal folder. more prefer with easy elements on textures (less colors, even solid).
it would be easy, if it would be a plain bmp (in my case), but seems it's not for type of your wf.
so I would not promise anything, but I'll try.
I don't think so, I agree on the pixel count but the bin contains other info besides the bg data. So it must be bigger than 135424 bytes (considering 1 byte per pixel). As you found out, there are sections related to other clock info. In fact, I got the example with a simple bg image with a few colors to help that out. Will look for more
I liked your excel but I cannot still figure out all info there, for example, the column "S" in the second tab (to start with).
the_cipo said:
the column "S" in the second tab (to start with).
Click to expand...
Click to collapse
offset of a first byte of a parameter. one parameter is a red+green(+gray if exist). red is an exactly parameters, green is a main offset of a texture, grey is a "suboffsets" (offsets of a "sockets" - independent part of a layer. i.e. layer "steps num" is a numeric of steps, it have a 5 digidts ("sockets"). sockets draws sequential from left to right, defined position in red field is a position of a first socket.)
the_cipo said:
So it must be bigger than 135424 bytes (considering 1 byte per pixel
Click to expand...
Click to collapse
I tried to explain exactly this)) what 186k is to low size for wf with 368x368 resolution)) 186k is not enough even for bg texture.
Here are two sets of simple wf, will do more later.
the_cipo said:
Here are two sets of simple wf, will do more later.
Click to expand...
Click to collapse
it's just a png, not a wf file.
--------------
sorry, found it. didn't saw a prew. post.
as I understood it have an only by 3 clockhands and nothing more?
This is the popup that occurrs when you try to run a program. Maybe it's been more prevalent since the 22H2 update?
Windows (10) will be the death of me, opaque error messages and plenty of online advice telling you to do a dozen unrelated things.
There was a time (long ago) when you could look in the Event Viewer and actually find something concrete.
Why for goodness sake is there not a "Details" button that gives an exact description of the problem?
"Wacky heuristics has determined your program is evil" or "This program requires "boring.dll" that has been discontinued since Windows 3.1"
Instead it just says, "I dunno, just search on the internet and try all the fixes".
I don't want to get bogged down in the specifics of this particular incident. Suffice it to say that it was a C program that I built myself, that has worked fine for years and that the last build causes this popup. The previous build works fine. As a test I rebuilt 100 other programs and none of them flagged this.
it should work fine, being a C program.. i have made some modifications in my applications too and getting the same message on the last build..
@Eric_Mello
So, I narrowed it down and even have a work-around.
The first thing I did was to try to run the program through CreateProcess().
I got a GetLastError() of 0x000000c1, 193, "%1 is not a valid Win32 application."
Then I build my app without any resources. It ran (such as it could without resources).
BeginUpdateResource(), UpdateResource(), EndUpdateResource() have been around for over 20 years.
There have always been reports of problems with it.
When resources get inserted the fixup table gets moved past.
I see on my problem program that the fixup table is exactly 0x1000 bytes.
When the resources get inserted it gets moved 0x600 bytes to make room.
I've checked, the fixup table does not need to get modified when it moves.
The workaround: I took a case statement that I was using and added a case 99999: that will never be hit.
That actually dropped the size of the fixup table to 0xffc.
And the program works.
Edit: Ok, I have the real skivvy on it now.
The linker is dumb and when the rawdata size of the .reloc is 0x1000 it sets the virtual size to 0x2000
Because the linker is calculating (virtual) image size it is consistent.
Now we throw in the resource linker and it adds the resources.
It recalculates the (virtual) image size using calculations on the .reloc rawdata size (and not just using the .reloc virtual size).
The .reloc is moved, the section table is still the same with only the offset for the .reloc changed.
So now we have a discrepancy between the (virtual) image size and the sum of the virtual sizes for the sections.
There are two fixes, increment the (virtual) image size 0x1000 or decrement the .reloc virtual size 0x1000.
I've tried both and they both work.
If I get to it I'll write a little utility to check this.
Before adding resources (runs, kind of):
Code:
C:\>peclean v.exe
v.exe App, Intel 32 bit
Warning: Discrepancy in size of .reloc section
Raw size: 00001000
Calculated: 00001000
In table: 00002000
After adding resources (can't run):
Code:
C:\>peclean v.exe
v.exe App, Intel 32 bit
Warning: Discrepancy in size of .reloc section
Raw size: 00001000
Calculated: 00001000
In table: 00002000
Error: Discrepancy in size of image
Calculated: 00029000
In header: 00028000
Ho, hum.
So I added some code to my custom resource linker that fixes things when UpdateResource breaks things.
lol... windows is like having an entitled & spoiled 12 y/o, who got sent to live with you without an explanation... And you have survived 35+ years , leading a very independent lifestyle.... but here's the kid all of a sudden...
1. He wakes you up yelling at 7 am, cuz he wants cereal for breakfast and all you have is Whole Milk, and he cant do whole milk, cuz it upsets his stomach, so you have to rush out and buy other milk so he eats before school.......
BUT
2. You race BACK to the house, risking tickets and wrecks, to save the day, and there he is, pouting and screaming at you NOW because you got 2% Milk, but you bought BORDEN, and Borden is pasteurized, which might be made near a peanut company and he has a DEADLY peanut allergy! .... You are kinda angry... but more annoyed and head out again.
NOW
3. You got lucky cuz you remembered the corner store DID have organic milk, but its OUTRAGEOUSLY PRICED... though r/n you dont care as long as the kid leaves happy, and you enjoy some peace! MONEY WELL SPENT!.... ... As you open the door, he is running out, with milk running down his face and his mouth full saying BYE...
BUT YOU AINT HAVING THAT!... YOU SPIN AROUND AND ASK HIM WTF?? HOW DID HE EAT HIS CEREAL? And he tells you, that since the cereal was sweetened it actually weakened the lactose enough that it was fine and he ate 3 bowls while you were gone! ....
WHAAAAAAT! YOU HAD WHOLE MILK SITTING THERE TO BEGIN WITH, AND NONE OF THIS CIRQUE DO SOLEIL was necessary, so you scream and walk inside. Then a few min later the kid walks in and reminds you its Saturday... no school!
The moral of this story is, NEVER GIVE IN TO ANY DEMANDS THAT WINDOWS MAKES by throwing you the almighty blue screen, because chances are, you can edit a registry entry ... modify a file (like you did) .... or just FORCE windows to run the program and crash repeatedly until you can observe the activity monitor, and see the cpu spike that always happens directly before the crash... like sometimes 2 seconds... then trace back the process that threw a temper tantrum and sometimes just increase or decrease the priority of the process, and windows will first SLOWLY go past the error the 1st time... then faster and faster until it realizes that the Milk you already had was perfectly fine to use, and it better NEVER INTERRUPT YOU ON A SATURDAY AGAIN, IF IT VALUES ITS LIFE! ... lol
@Eric_Mello So, did you find that you had the same problem?
Since the virtual page size is 4096 bytes and a .reloc entry is 4 bytes you have an 0.1% chance of this happening.
Renate said:
@Eric_Mello So, did you find that you had the same problem?
Since the virtual page size is 4096 bytes and a .reloc entry is 4 bytes you have an 0.1% chance of this happening.
Click to expand...
Click to collapse
i really don't findyet.
i let my friend on this case and we still keep going on the tests.
i share this thread with him to discuss this information above.
thanks and good luck!
Eric_Mello said:
I let my friend on this case and we still keep going on the tests.
Click to expand...
Click to collapse
If you want a simple test/fix, try this. Use a hex editor on your .exe
Look at the little-end 32 bit value at 0x250. The hex value should end in three zeroes, like 0x00123000
Add to that the hex value 0x1000 and write it to that location. Try running it.