Saturday, October 14, 2017

C++ Code Log - activities that I've been learning or doing the past month #1

Things learned:
Zenwinx/Udefrag needs only ntdll.lib no semicolon after. W/ NODEFAULTLIB on.
STUXNET = winapi getprocaddress loadmodule dll on NTDLL kernel WINAPI32 functions.
Depends.exe dependency walker
lib.exe /list:DLL/LIB | findstr strtofind
Assembly: WebAssembly + Emscripten
Use godbolt.org for Compiler Explorer to analyse assembly code.
CPP React
CopperStone w/e
libfat/reactos

Things from the past:
LIB+DLL = Linked Libraries, Shared (DLLs)
LIB+EXP = Static Libraries.
Static Vs Shared. MT vs MD  vs Debug ( MTd vs MDd)
WXWidgets 3.1 Compilation in 8 configs = 32/64 * Debug/Release * Shared/Static
make sure you create the directories right. Its advised to open up the vc($PlatformToolsetVersion)</wxCompilerPrefix> which was actually mentioned in the readme.
WinDDK/WinSDK/NTNDK
MSVC 2010 + SDK 7
2013 = C+11
2015 = C+14
2017 = C+17 
uCRT/uCRTD/MSVCRT/vcruntime.lib

VC Project Files. 
SLN basically does nothing 
VCXPROJ does it all. Edit it carefully, its like XML but less tolerant. 
Things have to go in the right order.
There is also an inheritance system. That is the parent and you can import other .props files in that, based on the order they will inherit in various rates.
The MSVC dropdowns are finicky and you need to realize theres inheritance there, and clearing is not the same as defaulting.
Also theres multiple configurations, and sometimes brings up the wrong config page.
You can set up additonal property pages with the "Property Manager" window. 

There is a utility called SLN2CMake and now VS2017 supports CMake. That way you can convert over.

Intricacies:
/d2noftol3 on CL.exe Compiler switch to disable remade SSE2 functions. Otherwise Linker issue without the ucrt.
https://stackoverflow.com/questions/19556103/how-to-get-vs2013-to-stop-generating-calls-to-dtol3-dtoui3-and-other-funct/31691179#31691179
Its a SSE primitive of Cvtds2dsi?
Windows uses 16-bit(2 byte) chars. Linux is 32-bit. use w_char or wchar_t

C++ Frameworks
Boost165 (Boost Optional. Boost Threading)
Intel Threading Building Blocks https://www.threadingbuildingblocks.org/
QT
CopperSpice
WX
Nana is a library for cross-platform GUI programming in modern C++ style (on Windows/Linux)
LANGUAGE C++11/14
COMPILER Any Standard C++ compiler(Visual C++ 2013, GCC/MinGW and Clang)


Github Projects Cloned or Starred


C++ Videos watched:

CppCon 2016: Dan Gohman “C++ on the Web: Let's have some serious fun." (WebAssembly)
https://www.youtube.com/watch?v=jXMtQ2fTl4c
Unicode Strings: Why the Implementation Matters
https://www.youtube.com/watch?v=ysh2B6ZgNXk
CopperSpice - C++ GUI Framework
https://www.youtube.com/watch?v=LIiwBNvTllk

Friday, July 21, 2017

Compiling FSV - the Jurassic Park program - on Windows 10 with MSYS2

Download the Source Code From https://github.com/genbtc/fsv/archive/master.zip
Github Repository @ https://github.com/genbtc/fsv
If this is what you are going after: http://fsv.sourceforge.net/screenshots/
You came to the right place.

Compiling FSV (File System Visualizer) for Windows takes a bit of effort. This is the tutorial. You need to set up the "MSYS2" development environment, which you can consider similar to Cygwin, if you dont know, it basically sets up a linux environment, and entire filesystem, with windows compatible .exe's compiled of everything, on your Windows machine under a subdirectory like C:\Software\MSYS32

INSTRUCTIONS:
STEP 1 - MSYS

On my machine, I dont like making too many root folders, so I make a C:\Software or C:\Code or whatever name, to put all my dev environment stuff in. Dont make the name too long and MAKE SURE IT DOESNT HAVE SPACES.

Download this version of MSYS2: msys2-i686-20161025.exe (its the latest 32 bit version)
It is available from sourceforge. https://sourceforge.net/projects/msys2/files/Base/i686/msys2-i686-20161025.exe/download

Install it, Pointing the installer to your C:\Software\MSYS32 directory.

We want the "launch after install" button when its done. (otherwise launch it from "C:\Software\msys32\mingw32.exe")
Note: the terminology MSYS, MSYS2, MSYS32 are all the same thing.
Note: However, now we want mingw32.exe (gray icon) don't confuse it with msys2.exe (purple icon)
You should now have this running:

Note: The following commands start with $ to indicate its a command at a command prompt. Dont retype it...

$ pacman -Syu

Hit enter to install the updates. After its done, it asks you to terminate it but you have to click the X until End Process shows and force end it. Also make sure pacman.exe is not running in task manager. Close it if it is.
Note: This requires internet access. If you are using Windows Firewall, you are going to want to disable it during the process because theres just too many .exe's that needs access to manually allow all of them. Dont get stuck on this step trying to do that...

Once again, open back up the MINGW32 shell ("C:\Software\msys32\mingw32.exe") and run the same command again:

$ pacman -Syu

Continue Installing Stuff, these are development packages:

$ pacman -S base-devel unzip mingw-w64-i686-toolchain mingw-w64-i686-gtk2 mingw-w64-i686-freeglut mingw-w64-i686-gtkglext

It will ask you some things, use the default, just press enter each time. Then it will take a while.
base-devel = provides autoconf/automake/pkg-config/tons of stuff.
toolchain = provides GCC,G++ stuff to compile.
GTK2 = a pre-requisite for the user interface (window dressings, menus etc).
Freeglut = an open source version of GLUT which is an API to OpenGL.
GTKGLext = the OpenGL extensions for GTK which we also need.

INSTRUCTIONS:
STEP 2 - Source Code

Download the Source Code From https://github.com/genbtc/fsv/archive/master.zip
(It has to be my repository, because that is where the changes for the Win32 port are)
Extract the FSV source code .zip file from github to your Home dir @ C:\Software\msys32\home\...\ so it lives in C:\Software\msys32\home\...\fsv-master\ (where ... is your username) and has the src/ subdirectory underneath.
Note: the screenshots show fsv-orig (but yours can be fsv-master or fsv)

STEP 2a - Compiling the source code of a gtkglarea-release (pre-req)
Execute the following:
Extract the source of gtkglarea-release-2-0-0.zip to gtkglarea-release-2-0-0 by typing:

$ cd fsv
$ unzip gtkglarea-release-2-0-0.zip

This package provides the required source and the library, and is not available through pacman, so I have provided it in original unmodified form.

Execute the following:

$ cd gtk[TAB](to tab complete)[ENTER]
$ ./autogen.sh

It will run, auto-generate, and auto-execute the configure script for you.
You should see this now:


$ make

You will see a whole ton of stuff scrolling past, this is the actual compiler GCC being run on all the source files. It shows some errors about libtool, but no problem.


$ make install

This will copy the files outputted from "make": libgtkgl-2.0-1.dll and libgtkgl-2.0.a (the linux version of a .dll) to a linux system-wide directory (I could have just provided this file but you wanted to compile stuff)



$ cd ../
$ ./autogen.sh

autogen.sh is the program that checks the autoconf file (configure.ac) and automake file (Makefile.am) input files and parses them into a ./configure script and ./Makefile script
You should see this now:


Execute the configure script.

$ ./configure



If this produces some kind of error, instead of ending happily, refer to Troubleshooting Error #1 below.


$ make



It will compile a ton of stuff, and then end unceremoniously.
But its done now! Now you can install the program by typing:

$ cp fsv.exe /mingw32/bin/

And run the program by typing:
$ fsv







Note: Errors? Read Troubleshooting Below.

Troubleshooting:
ERROR 1:

You did not compile or install the gtkglarea-release-2-0-0.zip properly. Re-read the instructions.
As a last resort, you can override that check by removing the word gtkgl-2.0 from "C:\Software\fsv\configure.ac" (find and delete only that word) and rerunning ./autogen.sh and rerunning ./configure. HOWEVER since you need this package to continue, I doubt that will help.

ERROR2:

                                      OR
ERROR3:

If it says the libgtkgl-2.0-1.dll is missing or you receive the message: " The procedure entry point g_malloc_n could not be located in the dynamic link library C:\..\libgtkgl-2.0-1.dll "
Make sure you place your fsv.exe INSIDE the MSYS binary dll directory (ex: C:\Software\msys32\mingw32\bin\ )
Then you can just make a shortcut to it, and run that.
Alternatively, you can add this C:\Software\msys32\mingw32\bin\ directory to your system environment PATH variable, in System settings as shown:

Alternate to this, you can also create a launcher .bat file. such as "LaunchFSV.bat",  file as a launcher. This sets the required Windows' System Environment "PATH" variable. When you are inside MSYS, it sets the PATH for you, so you can launch it from there no problem by typing ./fsv or ./fsv.exe , But when you try to launch it from Windows, you get libgtkgl-2.0-1.dll errors because it cannot find the all the .dlls we installed through MSYS (in addition to that specific one).
LaunchFSV.bat
PATH=%PATH%;C:/Software/msys32/mingw32/bin;./;
start fsv.exe


ERROR 4:
Disregard this error. It has no impact on the final outcome, and can safely be ignored.

ERROR 5:
You downloaded the source from the wrong repository. You need the genBTC repository (mine), because that is where the win32 fork changes are located. https://github.com/genbtc/fsv and https://github.com/genbtc/fsv/archive/master.zip
OTHER ERRORS NOT LISTED:
Report any bugs on the github repo. Everything will be handled through Github.

Using FSV:
It takes a CONSIDERABLE amount of time for the program to traverse the entire directory structure, (at anywhere from 300-6000 per second) and it does not display much until it does. For your first run, you should point it to a folder with a small amount of files and subdirectories.  FSV.exe takes path arguments, and the bat file does too, so you can put the .BAT file in your Windows SendTo folder, and then right click any directory and Send To LaunchFSV.bat, and it will launch starting in that dir.


Theres a bug in the "Change Root" command, 
You have to delete everything in the bottom text box, THEN click OK, for it to work. It will open to what it says in: "Selection". If you fail to do this, it will just rescan whatever dir you're in, and that sucks. I will work on fixing this soon.

SCREENSHOTS:

This is how it looks in Tree View:
This is how it looks in Map View:
This is how it looks in Disc View (very experimental):


Enjoy. I have not done anything significant enough to claim a copyright on this project, please refer to the original owner's repository and license documentation @ https://github.com/mcuelenaere/fsv

Thursday, July 13, 2017

FSV Filesystem Navigator - from Jurassic Park - SGI IRIX Sun Solaris clone - running on Windows

Ive been working on porting this 3D Filesystem Viewer or FSV from Linux to Windows. It looks like this and was made by this guy: https://github.com/jtsiomb/fsnav

(little sample of errors to clear)






For some reason i decided to try to download this one https://github.com/mcuelenaere/fsv because it has a lot more to it, like a whole menu/window/status/UI :) and it was wayyy harder to compile, in fact its not even fully working, theres a few issues preventing me from distributing it. But as you can probably tell, the look is just NOT there, its all wrong, you cant move well. Its a pretty bad program, even if it was for all intents and purposes the most real "clone" of the original SGI code. Which I do have and its from 1992-03-19 which is where the visual aesthetic of the blue Sky, grass, desert, ocean, space, indigo themes come from. Nobody elses code really has that. And it probably has more stuff, but i dont think i have the actual source available, just half of it.


Coded by
-Abei Villafane

Monday, June 05, 2017

Github, Git, Git Extensions, using Git, Git Tips and Tricks, Git for Windows

Git Tutorial #1 - Reset current branch to delete local commits with no data loss, and replace with 1 better remote commit

When you are working on a project thats undergoing changes so rapidly that you have no chance to do milestones or take breaks to put out stable versions, you should still commit LOCALLY (Commit, not Commit&Push) often to back up your work, and have old code to go back to during troubleshooting. Taking the time is annoying so just write as little description as possible to save time. 
Then after you have gotten to a milestone or a stable point, you can throw all those away, and Commit and Push ONE single solid commit with complete description and thought put into it when you have time.
This is best to do with local commits only, otherwise there can be some weird situations.
I mean you can do it, but its bad practice to change the history.

Step 1 - Highlight the last commit you want to keep.



Step 2 - Right click on it and choose Reset current branch to here.



Step 3 - This is where you make important decisions. In this tutorial we want to leave our files unchanged, and just delete the commit indexes.



Step 4 - Now it will show the last commit as the past one you picked, and that "New" files can be committed. Still no file data has changed.  At this point you want to the final Commit, and (most likely Push to github too).



Step 5 - You see you've effectively turned all the junk into 1 well formatted commit.


Can the text/descriptions for the old ones can be copied to the new text? No. There is no easy way to aggregate them all like some other git merge commands do. This is why I said dont put that much effort into the temp names. You could copy/paste em manually if it was that important.

Saturday, June 03, 2017

Synergy and Serial Number Activation Key for SSL security - Reverse Engineering the source code (easy)

Intro:

Synergy is a great program, marketed and sold by a company called Symless. It's like a network KVM w/ drag&drop files and clipboard support so you can use multiple computers at once. Point being, it also supports SSL encryption - but not for free.
Theres a Basic license for $19 (which from what I can tell does exactly nothing extra from what you already get without paying)
And a Pro license for $29. Pro gives full SSL (TLS through OpenSSL) AES-256 bit security for your connections. AES256-GCM-SHA384 TLSv1.2

You can't even download the free version from their website anymore. But it is Open Source @ https://github.com/symless/synergy-core
EDIT: They have since moved to calling it "Synergy-Core" as Open Source to distinguish from the paid.

It doesnt matter whether you download binaries somewhere (current version is 1.88 stable as of this writing), or compile it yourself (pretty difficult) - because it ends up installing essentially an unregistered, not activated version without SSL.

But we can fix that.... (without even tampering with the program file)!

Reading the Code:

Since the source code is public, we can reverse engineer their pointless activation scheme. To reverse engineer it, start by heading to the source: https://github.com/symless/synergy-core/
You can look through the source code and you will find this;

https://github.com/symless/synergy-core/blob/master/src/lib/shared/SerialKey.cpp#L126 = The SerialKey::toString() definition neatly shows us the basic format of the key.

https://github.com/symless/synergy-core/blob/master/src/lib/shared/SerialKey.cpp#L226 =  The SerialKey::parse() function actually has an example key in the comments, and is showing the validation routine.

This is what we can gather: a string needs to begin and end with a {  } and has 8 semi-colon ; seperated fields (or 9 but we dont want that one - thats for starting a trial of pro). For the last two fields we put 0 for unlimited.

Such as :
{v1;pro;YOURNAME;#userLimit#;EMAIL;BUSINESSNAME;0;0}

However you cant just paste that in, it needs to be encoded into hex....

Cracking the Code:

I've made it easy, automatic, non-intrusive, anonymous, and not sketchy at all. Visit this online C++ compiler and hit the "RUN" button to run the code (in the cloud) that I've created, (based on the source code). The code runs in the cloud not your machine and is totally safe.  Feed it any values you want for name/email - they dont even have to be real!:
Activation Key Number Generator Script Serial  for Synergy http://cpp.sh/3mjw3

NOW you can paste that Hex code in. Voila, its activated.

Afterword:

You should still donate the company some money when you get the chance so they can continue to provide this great software AND keep it open source.

Note= both machines need to have the license key for SSL handshaking to work, and they both need to be on the same version (or close). The OpenSSL accept fingerprint window will pop up, thats how you know its working.

Proof of Concept Picture:
https://puu.sh/w9y0h/b67ecae2fb.png

Theres no way they can know, I checked. Unless they read this :) If they do, PM me.

Wednesday, May 31, 2017

Windows 10 Restricted Traffic Limited Functionality Baseline


Theoretically this is what microsoft recommends for businsses to control what data gets out.
And you can do it to protect yourself.
It basically locks windows firewall down to absolute minimum, and turns on a ton of group policy settings to restrict stuff (that may or may not help - given what Mark Burnett has recently posted about)
And also probably disables a lot of excess windows features that you likely dont need.

Thats what me and burnett do, we also both use a program called Windows Firewall Control.
as a frontend for regular Windows Firewall.

Download the first link zip file from microsoft and read how to use it and apply it,
(it will kick you offline if you dont have firewall rules whitelist allowed for every program you use)

https://www.google.com/search?q=Restricted+Traffic+Limited+Functionality+Baseline

You also have to download this: https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/telligent.evolution.components.attachments/01/4062/00/00/03/65/94/11/LGPO.zip
seperately, and extract it to \1607\Tools and \1703\Tools dir. (The script relies on it and without having it you might think it worked if you're not careful, tho it does say one tiny error. )
This page explains LGPO if you're interested in group policy objects https://blogs.technet.microsoft.com/secguide/2016/01/21/lgpo-exe-local-group-policy-object-utility-v1-0/