From bdd9a3634dc841a2a51974671122d2a0a3af7fbc Mon Sep 17 00:00:00 2001 From: "Rustem Gimadutdinov (rgimad)" Date: Thu, 7 May 2020 22:14:53 +0000 Subject: [PATCH] KWINE v0.0.3 into msvcrt.dll added: - putchar - strchr - strrchr - strcpy - strncpy - memset - memcpy - memcmp - time - mktime - localtime - difftime - srand - rand new samples - rnd_arr1.exe - string2.exe git-svn-id: svn://kolibrios.org@7894 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/emulator/kwine/bin/kwine | Bin 1414 -> 1413 bytes programs/emulator/kwine/bin/lib/msvcrt.dll | Bin 10300 -> 11367 bytes programs/emulator/kwine/bin/samples.zip | Bin 17009 -> 18474 bytes programs/emulator/kwine/kwine.asm | 2 +- programs/emulator/kwine/lib/conio.c | 8 ++--- programs/emulator/kwine/lib/conio.h | 11 ++++++ programs/emulator/kwine/lib/msvcrt.dll.c | 37 +++++++++++++++++++-- programs/emulator/kwine/lib/stdio.c | 4 +-- programs/emulator/kwine/lib/stdio.h | 14 ++++++++ programs/emulator/kwine/lib/stdlib.c | 14 ++++++++ programs/emulator/kwine/lib/stdlib.h | 12 +++++++ programs/emulator/kwine/lib/string.h | 23 +++++++++++++ 12 files changed, 115 insertions(+), 10 deletions(-) create mode 100644 programs/emulator/kwine/lib/conio.h create mode 100644 programs/emulator/kwine/lib/stdio.h create mode 100644 programs/emulator/kwine/lib/stdlib.h create mode 100644 programs/emulator/kwine/lib/string.h diff --git a/programs/emulator/kwine/bin/kwine b/programs/emulator/kwine/bin/kwine index 00afa7c99055bc4d71a2b60fc989d21644c2f87d..a42154446420f3ca5d47857d9b574d26d9bdc0a1 100644 GIT binary patch delta 628 zcmZqUZsq3nb@dB%4KXleWME)eJdt+-t9Q7kpXf!+#_P#{7^O@=($*m9|4a-FX^pn8f%3jlCH%)(K{DPTnWsP*WR349dod~0zXdAH zV#)%_ya%xuIv?+F12WD!01W}j1-QZtNdg(tie?BiP%w)ni(w&1ck_Xe03;K3FfceU zF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+cNQ}XBftuaYm$zN>c@D zhPqDuM2XX1L}FAIm8J@isUK#9w-AvhHR2AOlcF)Zw z*-Z^n=-llHEu~Z^!Q@_ObdHy!kj_vz>dc|)ljc)(k=!m0EAD9UoJ5ij+ zBxBT0vIoh>Ym#S_+4Q)15c$HIJc&f_1}fj}N22!ymE;%_y+g2*)QPvOXQ=lIl{Rmp zjsBrk+USAn{ezP{mrT5%>RZC0GiYfadOC`p(o-!B9yQe3t}e80YjoyIU&P%5%^cQ#}y9 diff --git a/programs/emulator/kwine/bin/samples.zip b/programs/emulator/kwine/bin/samples.zip index 5fab40f550ddd7d839ab9286d0db135a4733fd46..2d7bf9f994905f9db5ce36c4cf14715af4ca8553 100644 GIT binary patch delta 4239 zcmZu!2{@E(7oNoojWLNa2xG+9QZq4@hGC?#Me>PaFve1Z%Jz|Jge)z>D{K7rElbIg zE&IL{2}PtN%2JYK{b&6D_2>J)@0shp&hFe%2J%jjW!aG26UN zmrmmtIJaK3B;6^pUCk<(D*=g4O#V`DhYTRRGX+dztb$vNC15G9Qcvg=N!SGWhSv@} z5)4X^0>#I)mQ{LYK&AGD2^g3(o*C{nVFXaJMsD0triOhpD7;H4o>gsiZg|lr^odMI zFkZj&0rA%+H8=*%ox$2(lA=#B4Y1vPL!hj{AkXv?jZr*c#xQP`sO%}m4B+eIa;qoHnNIU-N9#5Pn9pJ{{blV_ zj=Oe;)GiBUAFIO!r}9)RmuG&7VpS18oV&xz z%I~r9Bn$&dk*cli&yVMp&UYd7550&lft zd$}TG2qGV|&*@-;}C~i2CZWU1D1R?9!n-fl&xW4pAYYt=qlCOZ4-ajV1Bmc4ZCc zo-RnH;fi43(_{^?9tE)z5yiI8B5yjkGgdAlqFvSqWLQDeCzxzyEy@pU&{0E^$ZNqP z!jBybzmF(KP>=EBvYU7Y;Uc3w{g30JdYqf8uv3IH+WKdeVQDuc`@j8o-9${9q9T70 zszB`^GL_U25P!r4{SLMV&Q;D6nG9+c&|}z8mpK4!RpFCxY5v?4F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ZWIE*Y|%U(^B!- zd&dPFw1)ONh^z{WTGpnq#TLStSVSLLorR*zP#6XYpGnqDE9gcy>kv~n4n`C z&}_VzJ#zJr-y~LLb0eD-f5MlRUF43+`fp0dxDBzpFoybmzb&4+5q$m)rO)Kn_a}HS zQ_LlAxZmY;b3_|$qeJ6sJna*l@MmQ9@AHhtD-Q~A{@OY%?}WMxgJzS=GrJrYdbKOKA~$2!5V8%Itr49e!58jS4K*BSMWo6PyR?SZE&_bdw~ zWka}w^l{sTpYX`7>;9Ofcr5QPr)2tE_&0~nA5Yx*&PI))B z))T2V_@KMR({VVab>}q|_K`6OuY*a>>~^_GMBLzC+s^3~3^$EDmrM4^Pw*v_Rb=2uxJ}rv zjq7c60JDtE8G&b@Io3Pk#5w(XJpkv#-Yh65(P#pSg2Hw{{(Bh#g-rBBCzp|P(kf$6 zdwryYmI_ESaR*jhiw%@jz)BNmV9v3WUllc#{>QCF*OX*VyewWR%WG=>oxNL`XML9S ztt5GtN#}R-j{^$2bzVWXLsWSce!=qI3*a47W!B=x-Fm*xllNs?I{!)O?>hgxBmZ3| z2>yTeXW^}GAP^`-1`>VUub}4VGbnDIKc-*lf-|NXFhwNz0xk>U%_ISeQW<~D6f+V` zNgj+eQw5GDSMbSg9uZdrxjZ6N zK`*Krkn(+tq)|!GonSW=2i&%~$Cp{=g)FOpYUXOde8(1HnvL9~H9SGjoB4;c}P?soi@{su6^}IT1~FE6Q6rJ& zErlaudlB6VV6~MN?2A4)>U6L$p8fwC!7tE6u5Z44wxhgE3ZkoN7b~f$yoPR=oY1 WXPI;%fdA_;yk{8!fdm@zzy1wHFUK|j diff --git a/programs/emulator/kwine/kwine.asm b/programs/emulator/kwine/kwine.asm index 0f3d665cac..e85ed39be2 100644 --- a/programs/emulator/kwine/kwine.asm +++ b/programs/emulator/kwine/kwine.asm @@ -117,7 +117,7 @@ lib dd 0 func dd 0 func_name dd 0 ; ------------------------------------------------------------- ; -sz_pe_load db "PELoad",0 +sz_pe_load db "KWINE",0 ; ------------------------------------------------------------- ; con_init dd 0 con_write_asciiz dd 0 diff --git a/programs/emulator/kwine/lib/conio.c b/programs/emulator/kwine/lib/conio.c index fbf60d2d56..a0b417fa71 100644 --- a/programs/emulator/kwine/lib/conio.c +++ b/programs/emulator/kwine/lib/conio.c @@ -42,12 +42,12 @@ void *load_library(char *name) { void *getprocaddress(void *exports, char *name) { if (exports == NULL) { return 0; } - while (*(uint32_t*)exports != NULL) + while (*(uint32_t*)exports != 0) { char *str1 = (char*)(*(uint32_t*)exports); if (strcmp(str1, name) == 0) { - void *ptr = *(uint32_t*)(exports + 4); + void *ptr = (void*)*(uint32_t*)(exports + 4); // important for debug /*debug_board_write_string(name); @@ -146,13 +146,13 @@ int con_init_console_dll(void) // -------------------------------------------------------------------- -int cdecl _getch() +int _getch() { con_init_console_dll(); return con_getch(); } -int cdecl _kbhit() +int _kbhit() { con_init_console_dll(); return con_kbhit(); diff --git a/programs/emulator/kwine/lib/conio.h b/programs/emulator/kwine/lib/conio.h new file mode 100644 index 0000000000..68fd648873 --- /dev/null +++ b/programs/emulator/kwine/lib/conio.h @@ -0,0 +1,11 @@ +#ifndef _CONIO_H +#define _CONIO_H + +int _getch(); +int _kbhit(); + +int con_init_console_dll(void); +int con_init_console_dll_param(uint32_t wnd_width, uint32_t wnd_height, uint32_t scr_width, uint32_t scr_height, const char* title); +void con_lib_link(void *exp, char** imports); + +#endif \ No newline at end of file diff --git a/programs/emulator/kwine/lib/msvcrt.dll.c b/programs/emulator/kwine/lib/msvcrt.dll.c index 55d6405c50..8eef7c93d0 100644 --- a/programs/emulator/kwine/lib/msvcrt.dll.c +++ b/programs/emulator/kwine/lib/msvcrt.dll.c @@ -6,15 +6,19 @@ #include #include "msvcrt.dll.h" +#include "string.h" +#include "conio.h" +#include "stdio.h" +#include "stdlib.h" +#include "time.h" + #include "string.c" -//#include "dlfcn.c" #include "conio.c" #include "stdio.c" #include "stdlib.c" - -#include "time.h" #include "time.c" +// note: by default all function in c are cdecl :D typedef struct { @@ -30,13 +34,23 @@ const char sz__kbhit[] = "_kbhit"; const char sz_printf[] = "printf"; const char sz_puts[] = "puts"; const char sz_gets[] = "gets"; +const char sz_putchar[] = "putchar"; //string const char sz_strlen[] = "strlen"; const char sz_strcmp[] = "strcmp"; const char sz_strcat[] = "strcat"; +const char sz_strchr[] = "strchr"; +const char sz_strrchr[] = "strrchr"; +const char sz_strcpy[] = "strcpy"; +const char sz_strncpy[] = "strncpy"; +const char sz_memset[] = "memset"; +const char sz_memcpy[] = "memcpy"; +const char sz_memcmp[] = "memcmp"; // stdlib +const char sz_srand[] = "srand"; +const char sz_rand[] = "rand"; const char sz_malloc[] = "malloc"; const char sz_free[] = "free"; const char sz_realloc[] = "realloc"; @@ -44,6 +58,9 @@ const char sz_realloc[] = "realloc"; // time const char sz_time[] = "time"; +const char sz_mktime[] = "mktime"; +const char sz_localtime[] = "localtime"; +const char sz_difftime[] = "difftime"; //uint32_t EXPORTS[] __asm__("EXPORTS") = @@ -55,16 +72,30 @@ export_t EXPORTS[] = {sz_printf, (void*)printf}, {sz_puts, (void*)puts}, {sz_gets, (void*)gets}, + {sz_putchar, (void*)putchar}, {sz_strlen, (void*)strlen}, {sz_strcmp, (void*)strcmp}, {sz_strcat, (void*)strcat}, + {sz_strchr, (void*)strchr}, + {sz_strrchr, (void*)strrchr}, + {sz_strcpy, (void*)strcpy}, + {sz_strncpy, (void*)strncpy}, + {sz_memset, (void*)memset}, + {sz_memcpy, (void*)memcpy}, + {sz_memcmp, (void*)memcmp}, + {sz_srand, (void*)srand}, + {sz_rand, (void*)rand}, {sz_malloc, (void*)malloc}, {sz_free, (void*)free}, {sz_realloc, (void*)realloc}, {sz_time, (void*)time}, + {sz_mktime, (void*)mktime}, + {sz_localtime, (void*)localtime}, + {sz_difftime, (void*)difftime}, + {NULL, NULL}, }; diff --git a/programs/emulator/kwine/lib/stdio.c b/programs/emulator/kwine/lib/stdio.c index c0ce829d52..882e332255 100644 --- a/programs/emulator/kwine/lib/stdio.c +++ b/programs/emulator/kwine/lib/stdio.c @@ -10,13 +10,13 @@ int putchar(int ch) return ch; } -void cdecl puts(const char *str) +void puts(const char *str) { con_init_console_dll(); con_write_asciiz(str); } -char* cdecl gets(char* str) +char* gets(char* str) { con_init_console_dll(); return con_gets(str, 256); diff --git a/programs/emulator/kwine/lib/stdio.h b/programs/emulator/kwine/lib/stdio.h new file mode 100644 index 0000000000..aacf30a940 --- /dev/null +++ b/programs/emulator/kwine/lib/stdio.h @@ -0,0 +1,14 @@ +#ifndef _STDIO_H +#define _STDIO_H + +int putchar(int ch); +void puts(const char *str); +char* gets(char* str); +void putuint(int i); +void putint(int i); +void puthex(uint32_t i); +void print(char *format, va_list args); +void printf(char *text, ... ); + + +#endif \ No newline at end of file diff --git a/programs/emulator/kwine/lib/stdlib.c b/programs/emulator/kwine/lib/stdlib.c index f86e1ce356..a2d77119da 100644 --- a/programs/emulator/kwine/lib/stdlib.c +++ b/programs/emulator/kwine/lib/stdlib.c @@ -1,4 +1,18 @@ + +unsigned long int __rnd_next = 1; + +int rand(void) // RAND_MAX assumed to be 32767 +{ + __rnd_next = __rnd_next * 1103515245 + 12345; + return (unsigned int)(__rnd_next/65536) % 32768; +} + +void srand(unsigned int seed) +{ + __rnd_next = seed; +} + void *malloc(size_t size) { void *val; diff --git a/programs/emulator/kwine/lib/stdlib.h b/programs/emulator/kwine/lib/stdlib.h new file mode 100644 index 0000000000..3f08447a1b --- /dev/null +++ b/programs/emulator/kwine/lib/stdlib.h @@ -0,0 +1,12 @@ +#ifndef _STDLIB_H +#define _STDLIB_H + +int rand(void); +void srand(unsigned int seed); + +void *malloc(size_t size); +int free(void *mem); +void* realloc(void *mem, size_t size); + + +#endif \ No newline at end of file diff --git a/programs/emulator/kwine/lib/string.h b/programs/emulator/kwine/lib/string.h new file mode 100644 index 0000000000..fc2f8cc8e1 --- /dev/null +++ b/programs/emulator/kwine/lib/string.h @@ -0,0 +1,23 @@ +#ifndef _STRING_H +#define _STRING_H + +void* memset(void *mem, int c, unsigned size); +void* memcpy(void *dst, const void *src, unsigned size); +int memcmp(const void* buf1, const void* buf2, int count); + +char *strcat(char strDest[], char strSource[]); +int strcmp(const char* s1, const char* s2); +char *strcpy(char strDest[], const char strSource[]); +char* strncpy(char *strDest, const char *strSource, unsigned n); +int strlen(const char* string); +char* strchr(const char* string, int c); +char* strrchr(const char* string, int c); + +void _itoa(int i, char *s); +void reverse(char s[]); +void itoa(int n, char s[]); +int atoi ( char *s ); + + + +#endif \ No newline at end of file