📜 ⬆️ ⬇️

Developing an application for an old PDA (Cybiko Xtreme) in 2019



Introduction


Hi Habr! I would like to share my experience of writing an application for a very old handheld computer, which was seriously ahead of its time, namely Cybiko Xtreme 2001 release. For those who are interested in how the mobile developer lived in the early 2000s, welcome to Cat.

About Cybiko Xtreme


So, this device came to me back in 2002 and caused complete delight. I could not appreciate the communication capabilities, since I no longer met people with such PDAs in my city, however, in general, the ability to play many games without having to sit at a computer was simply fiction. In many ways, the creators of the device focused on the network capabilities of the PDA. The developers chose the radio mesh network as the connection between the devices. Directly the devices were connected to each other at a distance of up to 100 meters, but it was possible to connect to each other through another device, and in theory, with a dense network coverage, the distance was unlimited. The device had the opportunity to fill out my profile (it seems even to attach a photo, although there would be little confusion on the display in grayscale), to communicate with other users with similar interests, to look for new acquaintances, etc. It resembles all this social network, although then such a term, as far as I know, did not yet exist. If there were a lot of devices, I think the project would have taken off, however, unfortunately, something went wrong with the creators.

Having found this PDA in my old stuff, I wanted to ponder over it. It wasn’t very interesting to play old games (after all, they don’t look very much compared to new ones), but it was much more interesting to try to develop an application and feel how the first mobile developers lived.
')

The idea of ​​the application


Since I, by the nature of my work, is connected with information security and this topic is extremely interesting to me, I decided to create an application in the same field. The simplest (and at least something useful?) Application seemed to me like the password manager application. This application allows you to see how to develop a graphical user interface, and work with the file system (storing the encrypted container with passwords).

As a cryptography to protect the container, I decided to use the so-called XOR encryption . The key is the master password. Crypto-resistance of this encryption strongly depends on the key length, and it is not recommended to use it in serious systems, however, this encryption has one serious advantage - it is very easy to implement. Since the application was created solely for entertainment purposes, such encryption fits perfectly.

Emulator


Connecting Cybiko Xtreme to a modern computer is a rather complicated process, so I decided to work on test launches of the application on an emulator (fortunately it is).
Appearance is shown below.



There are some features for downloading applications to the emulator. According to the instructions found here, the application can be sent using the "Send" button in the "Console" window, however, no matter how I tried, I did not succeed. On the Planet Cybiko forum (unfortunately, at the moment the forum is closed) there is a link to a tool that allows you to make your own Cybiko ram disks. Therefore, it is enough to create a ramdisk with the compiled application and restart the emulator with it.

Sdk


Find the SDK on the Internet was not very difficult. Having unpacked and analyzed the directory structure, I first of all paid attention to the doc directory, which contained quite useful help, explaining how to compile the application, in principle, and what structure the project should have.

In the demos directory, I found many examples of applications. Of particular interest were the applications from the tutorial directory, which, step by step, explained the design principles for Cybiko Xtreme. Everything is simple, accessible and understandable.

Code writing


The structure of the project’s minimum content is presented below:

Project structure
project res root.inf src source1.c … make.bat 


The root.inf file contains the meta-data of the application, namely, information about its type (application, game or library), version, minimum operating system version (just like in Android), unique name, etc.

The make.bat file contains commands for building the application using sdk. In fact, the entire assembly is performed by the Cybiko C Compiller call command:

 "C:\Program Files (x86)\Cybiko\Cybiko_SDK\bin\vcc" -R0 src/*.c res/*.help res/*.inf -o passwords_master.app 

Important note: when building on Windows 7 for vcc.exe, you need to install Windows XP compatibility mode (Service Pack 2), otherwise there are problems with running the compiler.

In the src directory are the source code of the program. The result of the compilation is the * .app file.

To describe the development of the entire application of one article is definitely not enough, so I will describe only the very beginning. If someone has any questions, ask in the comments or in PM.

It all starts with the initialization of the application context in the main function, by calling:

Initialization
 long init_module(struct module_t * main_module); 


After initialization, the main_module structure contains pointers to the graphics context and the current application process.

Next, you need to create the main form. This is done as follows:

Creating the main form
 struct cFrameForm * ptr_main_form = malloc(sizeof(struct cFrameForm)); cFrameForm_ctor(ptr_main_form, "Passwords Master", main_module.m_process); 


Check if there is a password container on the file system:

Check container availability
 int check_database() { struct FileInput * ptr_file_input = (struct FileInput *) malloc(sizeof(struct FileInput)); FileInput_ctor_Ex(ptr_file_input, DATABASE_FILE); if (FileInput_is_good(ptr_file_input)) { FileInput_dtor(ptr_file_input, FREE_MEMORY); return 0; } FileInput_dtor(ptr_file_input, FREE_MEMORY); return -1; } 


We will show the dialog box for entering the master password. If the container already exists, then try to decrypt it with the entered master password. If the container was not, then use the entered master password to create a new container.

Enter master password
 void get_master_password(struct cFrameForm * ptr_form, char * master_password) { // Show dialog enter master password struct cDialog * ptr_pass_dialog; ptr_pass_dialog = (struct cDialog *) malloc(sizeof(struct cDialog)); cDialog_ctor(ptr_pass_dialog, 0, "Enter master password", mbEdit | mbOk | mbCancel | mbs1, 15, ptr_form->CurrApplication); cDialog_SetEditText(ptr_pass_dialog, ""); do { // If pressed cancel - close application if (cDialog_ShowModal(ptr_pass_dialog) == mbOk) cDialog_GetEditText(ptr_pass_dialog, master_password); else { ptr_form->ModalResult = mrQuit; break; } } while (strlen(master_password) == 0); // Releases the dialog cDialog_dtor(ptr_pass_dialog, FREE_MEMORY); } 


All further work of the application is built around the message processing cycle from the operating system until the main form is closed.

Message handling
 while (ptr_form->ModalResult != mrQuit) { struct Message * ptr_message = cWinApp_get_message(ptr_form->CurrApplication, 0, 1, MSG_USER); switch(ptr_message->msgid) { case MSG_SHUTUP: // Processes the system exit signal. case MSG_QUIT: ptr_form->ModalResult = mrQuit; break; case MSG_KEYDOWN: // Processes keyboard input ptr_key_param = Message_get_key_param(ptr_message); switch(ptr_key_param->scancode) { case KEY_ESC: ... break; case KEY_ENTER: ... break; case KEY_DEL: ... break; default: cFrameForm_proc(ptr_form, ptr_message); } break; default: cWinApp_defproc(module.m_process, ptr_message); } Message_delete(ptr_message); } 


The result of the work at startup in the emulator is presented below:



With full source text if desired
can be found on the github link.

Run on a real device


As I said before, launching on a real device is difficult, as Cybiko’s software for synchronizing with a computer does not support modern operating systems. According to the instructions found here , I managed to synchronize Cybiko with Windows 2000 running in Virtual Box. From the nuances, I can note that the program saw Cybiko only when it was connected via USB and automatically forwarded to a virtual machine. This is probably why the author of the manual writes that he needs to be added as a permanent device for this machine in the USB Virtual Box settings.

The result of synchronization in the picture below:



The result of my application is presented in the following video:


Conclusion


I have a lot of wonderful memories with Cybiko Xtreme, and once again it was damn nice to touch this wonderful device. I want to say its creators many thanks for the work done. I would also like to thank the creators of the emulator, forums and websites on Cybiko, as well as my wife for the help in shooting the video and editing this article.

Thank you all for your attention!

Source: https://habr.com/ru/post/445686/


All Articles