Update: UltraVNC 1.4.3.6 and UltraVNC SC 1.4.3.6: https://forum.uvnc.com/viewtopic.php?t=37885
Important: Please update to latest version before to create a reply, a topic or an issue: https://forum.uvnc.com/viewtopic.php?t=37864

Join us on social networks and share our announcements:
- Website: https://uvnc.com/
- GitHub: https://github.com/ultravnc
- Mastodon: https://mastodon.social/@ultravnc
- Facebook: https://www.facebook.com/ultravnc1
- X/Twitter: https://x.com/ultravnc1
- Reddit community: https://www.reddit.com/r/ultravnc
- OpenHub: https://openhub.net/p/ultravnc

1scdll implementation

Post Reply
cicio
Posts: 5
Joined: 2007-01-22 11:50

1scdll implementation

Post by cicio »

how to implement 1scdll.dll in Visual Basic and Autoit?
Is there anyone that can explain me this?
cicio
Posts: 5
Joined: 2007-01-22 11:50

Re: 1scdll implementation

Post by cicio »

any news?
cicio
Posts: 5
Joined: 2007-01-22 11:50

Re: 1scdll implementation

Post by cicio »

up :roll:
linoter
8
8
Posts: 27
Joined: 2007-01-02 11:17
Location: Switzerland

Re: 1scdll implementation

Post by linoter »

Look at this thread: [topic=8974][/topic]

There are two examples in C++ and C#.
I can't tell you off-hand how to import a dll in VB. However, there are good docs from microsoft.
ctrlaltca
8
8
Posts: 10
Joined: 2007-02-20 17:08

Re: 1scdll implementation

Post by ctrlaltca »

I tried to implement this in vb6, but i've some problem in passing the "int port" argument to the function Start_server.
First of all, the code: create a new project and add a module to it; add the following function declarations:

Code: Select all

Public Declare Function Start_server Lib "1SCDLL.dll" _
(ID As String, repeater As String, direct As String, ByVal port As Integer, passwd As String, _
ByVal proxy As Boolean, classname As String, ByVal have_to_wait As Boolean) As Variant
Public Declare Sub Stop_server Lib "1SCDLL.dll" ()
Then, add 2 commandbuttons to the main form and paste into it this code:

Code: Select all

Private Sub Command1_Click()
Dim ID As String, repeater As String, direct As String, passwd As String, classname As String
Dim port As Integer, ret As Long
ID = "1234" & vbNullChar
repeater = "host.repeater.net" & vbNullChar
direct = "host.direct.net" & vbNullChar
passwd = "password" & vbNullChar
classname = "anything" & vbNullChar
port = 5500
On Error GoTo errz
ret = Start_server(ID, repeater, direct, port, passwd, False, classname, False)
GoTo fine
errz:
  MsgBox "error: " & Err.Description & "; ret value=" & ret
fine:
MsgBox "ok; ret value=" & ret
End Sub

Private Sub Command2_Click()
Stop_server
End Sub
Some more things to do:
1) you need to put the 3 dlls (1SCDLL, 1CHATDLL, SCHook.dll) in the project directory;
2) you can't run the project itself; you must compile it and run the result .exe file
3) if you want to run the project without compiling, you have to point the full path to the dlls in the function declarations, like this:

Code: Select all

Public Declare Sub Stop_server Lib "c:\i_luv_my_directory\1SCDLL.dll" ()
Does it works?
An half; it binds the dll function Start_server to a vb function; i spent some time finding the right combination of data types for the function arguments, but i still am not able to use the "port" argument. Software crashes saying it tried to access memory @ 0x157c (lol, this is the hex value of port 5500).

And so?
I gave up tring to make this thing works. Browsing the forum and source codes i found at least 5 different prototypes for Start_server(), each one with different numbers of parameters and returning void.
The example code at http://www.uvnc.com/pchelpware/dev/index.html is wrong, too. And the return type seems not to be void (this made me going crazy).
This .dll is really bad documented (or not documented at all), and it is closed source.
This makes me quite sad... can anyone provide better documentation for it? I can to do this work, if someone provides me with good information sources...
petoulachi
8
8
Posts: 20
Joined: 2007-02-18 11:22

Re: 1scdll implementation

Post by petoulachi »

I also try to use this DLL in my code. I'm using C# but the problem is the same : no documentation...

Do you know that there is an update for 1SCDLL.dll ? You can find it here : http://www.uvnc.com/pchelpware/download/SCDLL.zip

Be carefull, you also have to update your viewver to use the new 1SCVDLL.dll to make it work.

I have a lot of problem with SCHook.dll, when I call Stop_server this dll file stay locked, Windows sayed that it's used but some programs.

I think that the Stop_server method does not liberate the dll correctly, but i'm not sure.

If the developpers of PcHelpWare DLL could help us it would be great !
Last edited by petoulachi on 2007-02-20 18:24, edited 1 time in total.
petoulachi
8
8
Posts: 20
Joined: 2007-02-18 11:22

Re: 1scdll implementation

Post by petoulachi »

After more tests :
-I don't really understand why, but it seems that the StartServer is sometimes a blocking call, which mean I have to launch it in a thread (or my application will be blocked), and sometimes it's a non-blocking call ?
-the Stop_server method works fine, but it seems that often the DLL SCHook is still used by applications even if the server is stopped. I think that if I made a call of StartServer when the DLL is still used, the call is then a non blocking call.

I'm unable to hide the tray icon or to change it. That's quite boring because you can manually stop the server by right clicking the tray icon, which I don't want (I prefer that my application totally control the server).
ctrlaltca
8
8
Posts: 10
Joined: 2007-02-20 17:08

Re: 1scdll implementation

Post by ctrlaltca »

I made more tests to, ripping some code out of the GUI source;
Maybe the answer to your problem in Stop_server is in this comment:

Code: Select all

bool waiting_for_quit=false; //Stop_server need to wait until thread end (WM_APP+1)
I end up with a correct version of the "small example" to implement it using C; It lacks the handling of connection status, but at least it's a working codebase:

Code: Select all

// WM CODES
// WM_APP+1 disconnect
// WM_APP+2 waiting viewer
// WM_APP+3 connected
// WM_APP+4 disconnecting
// WM_APP+5 user press exit in tray

#include <windows.h>
#include <stdio.h>
#include "resource.h"

typedef void (/*__declspec(dllimport)*/ *Start_server_fn)(char *,char *,char *,int,char *,bool,char *,bool);
typedef void (/*__declspec(dllimport)*/ *Stop_server_fn)(void);
Start_server_fn Start_server=NULL;
Stop_server_fn Stop_server=NULL;
HMODULE hDLL=NULL;

/////////////////////////////////////////////////////////////////////////////
bool
ImportDLL_functions()
{
	hDLL = LoadLibrary ("1SCDLL.dll");
	if (!hDLL) return 0;
	Start_server = (Start_server_fn) GetProcAddress(hDLL,"Start_server");
	Stop_server = (Stop_server_fn) GetProcAddress(hDLL,"Stop_server");
	if (!Start_server || !Stop_server)
	{	
		// handle the error
		FreeLibrary(hDLL);
		return 0;		   
	}
	return 1;
}

void
Free_DLL_functions()
{
	if (hDLL)
		FreeLibrary(hDLL);
}
/////////////////////////////////////////////////////////////////////////////


int 
APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR     lpCmdLine,int       nCmdShow)
{
	if (!ImportDLL_functions())
	{
		MessageBox(NULL,"1SCDLL not found","Error ",MB_ICONWARNING);										
		return 0;
	}
	// void Start_server(char *ID, char *repeater,char *direct,int port,char *passwd,bool proxy,char *classname,bool have_to_wait);
	Start_server("ID","REPEATER HOST","DIRECT HOST",5500,"PASSWD", false, "CLASSNAME", false);
	
	// YOUR CODE HERE
	
	// void Stop_server(void);
	Stop_server();
	Free_DLL_functions();
	return 0;
}
ctrlaltca
8
8
Posts: 10
Joined: 2007-02-20 17:08

Re: 1scdll implementation

Post by ctrlaltca »

petoulachi wrote:I'm unable to hide the tray icon or to change it. That's quite boring because you can manually stop the server by right clicking the tray icon, which I don't want (I prefer that my application totally control the server).
It's easy to make it disappear: you have to know its hWND, declare a NOTIFYICONDATA struct and fill it; after that, use Shell_NotifyIcon (from shell32.dll) with NIM_DELETE;
A second easy method is patching the binary dll.. the "freeware" license seems to forgets to disallow this, but i'd prefer to spend my time helping ultravnc guys instead of reverse engineering their work...
petoulachi
8
8
Posts: 20
Joined: 2007-02-18 11:22

Re: 1scdll implementation

Post by petoulachi »

Thank you, you have a signature for start_server that i didn't know. I'll test the last bool paramater, and it seems that it control the comportment of the start_server : when set to true, the call is a blocking call, false it's a non blocking call.

I don't really understand the waiting_for_quit into the source code (it's been a long time that I don't use C++ and now i'm a little lost).

After more and more test, it seems that SCHook.dll is not completly stable : sometimes, after stoping the server, some process continue to use it (sometimes it's windows defender, sometimes it's dwm...).
More, it's seem that some application are not really compatible with PCHelpWare. I have an application for my avaya PABX (Phone Manager) and when the server is started the phone manager process used about 100% of my CPU). That causes the remote view to be quite buggy, as the refresh of the screen and display of new windows don't really work. Killing the faultly process fix it.
ctrlaltca wrote:It's easy to make it disappear: you have to know its hWND, declare a NOTIFYICONDATA struct and fill it; after that, use Shell_NotifyIcon (from shell32.dll) with NIM_DELETE;
A second easy method is patching the binary dll..
Well I know that calling some windows function can hide this, or I can replace the icon inside the DLL with something like ResHacker, but I want to know if there is a official way to do this ?
ctrlaltca wrote:the "freeware" license seems to forgets to disallow this, but i'd prefer to spend my time helping ultravnc guys instead of reverse engineering their work...
So am I, I just want to put my feedback using the DLL, and I hope that Rudi will give us some answer !
petoulachi
8
8
Posts: 20
Joined: 2007-02-18 11:22

Re: 1scdll implementation

Post by petoulachi »

Okay I think I found the official way to change the icon, in fact you just need to simply put icon1.ico & icon2.ico on the same folder than the DLL ;)
ctrlaltca
8
8
Posts: 10
Joined: 2007-02-20 17:08

Re: 1scdll implementation

Post by ctrlaltca »

Rudi said he'll answer when he'll be back (this weekend). Thank you Rudi!

Btw: finally i re-wrote a part of my project using vc++6;
Once i understood how the dll<->project communication works, implementing it has been a quite simple task.
Now both server and viewer dlls are working quite well. The only "bug" i found is related to file-transfer:
- the "max 100Mb" error sometimes shows up also with smaller files;
- the progressbar has a strange behaviour with big files (it starts.. then resets.. then restart); transfer complete correctly;
- if you transfer more than 1 file, every time you ctrl+v it pastes not only the latest one, but also all the previous.
- file trasfer uses a temp directory (c:\temp_phw) to trasfer files; maybe a better option is user temp directory?
Last edited by ctrlaltca on 2007-02-22 17:00, edited 1 time in total.
petoulachi
8
8
Posts: 20
Joined: 2007-02-18 11:22

Re: 1scdll implementation

Post by petoulachi »

Have you test the server on a Vista computer ? I have some display bug with it (Vista business). I think it's due to the graphic driver no (i don't talking about the driver given with phw, but with the manufacturer driver)? Well it's alway better than UVNC 1.2 that don't work at all on my vista computer (display on the viewer is very very very very slow, unusable).

Another problem found : I use both server and viewer with a Repeater (so with an ID). It's working great, except that I can't put a password. Have you experienced the same problem ?
Last edited by petoulachi on 2007-02-23 09:48, edited 2 times in total.
ctrlaltca
8
8
Posts: 10
Joined: 2007-02-20 17:08

Re: 1scdll implementation

Post by ctrlaltca »

I didn't test the phw server on Vista, but i remember that last time i tried UVncSc was working (well.. you can't see 3d surfaces). The main problem in Vista is when UAC freezes the screen to ask the administrator password..

I tested phw dlls using both the windows repeater and a linux repeater (you can find it here: http://koti.mbnet.fi/jtko/uvncrepeater/).
Both works until you specify no password. Using a password the viewer freezes for about a minute, then it shutdown. This is the repeater log:

Code: Select all

UltraVnc Fri Feb 23 13:50:23 2007 > acceptConnection(): connection accepted ok from ip: xx.xx.xx.xx
UltraVnc Fri Feb 23 13:50:33 2007 > acceptConnection(): connection accepted ok from ip: xx.xx.xx.xx
UltraVnc Fri Feb 23 13:51:37 2007 > cleanUpAfterRepeaterProcExit(): closing connection (server=7, viewer=8)
It seems that repeater correctly links the connection between server and viewer, but the viewer is not able to decrypt data...

Another question, i read that:
--== viewer require click "Start" before server "Connect" ==--
Why is there this limitation? Probably i cannot understand because i don't know how the new protocol works.. (it's not standard vnc)
Last edited by ctrlaltca on 2007-02-23 17:18, edited 2 times in total.
petoulachi
8
8
Posts: 20
Joined: 2007-02-18 11:22

Re: 1scdll implementation

Post by petoulachi »

Are you able tu use UVNC repeater with the phw dll ? normally it's not possible as Rudi made it from scratch, it's not compatible with any *VNC (viewer, server and repeater).
ctrlaltca
8
8
Posts: 10
Joined: 2007-02-20 17:08

Re: 1scdll implementation

Post by ctrlaltca »

Sorry, i clarify my previous sentence:
Windows phw repeater (included in phw package) works;
i did non test uvnc windows repeater;
linux uvnc repeater works too; it seems that the way phw handle IDs is the same as uvnc. Once the repeater create the logical link between server and viewer, it simply act as a proxy, so it works.
__pepsi__
Posts: 1
Joined: 2008-01-19 18:04

Re: 1scdll implementation

Post by __pepsi__ »

I found that this sorts the problems with 1scdll in C#

[DllImport("1SCDLL.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern void Start_server(string ID, string repeater, string direct, int port, string password, bool proxy);
Post Reply