ISCSI Target Windows API - c++

I'm a newbie
My boss asked me make a iscsi target server by C++ using windows api (run on windows server 2012)
project requirements
- create iscsi target
- connect target with a vhd
I was find alot, but only fond
iSCSI Discovery Library Functions
Volume Shadow Copy API Interfaces
i was created a file .vhd anh truy with WINAPI AddIscsiStaticTarget windows api but cannot add into "File and storage service"
Thank you and Best Regards
Sr because my english

The first link in your question is to the API for configuring the iSCSI client component, not the iSCSI server component.
The second link is to the Volume Shadow Copy API, which I don't think is relevant either. That's used for the intelligent snapshotting of volumes, usually in order to run a backup.
To manipulate the iSCSI target server component, use the iSCSI Target Server Provider API.
Since you're dealing with a VHD file, you might also need the Virtual Hard Disk API.

It is a lot of work to write an iSCSI target. I have written both target and initiator ... the initiator and be very simple if it wants and can be written very easy. But if the target usually has to work with lots of initiators which make it much more difficult to write. Given that, if you write your own very simple initiator then you could write a simple target which only works with your initiator.

Related

C++: Remotely hibernate a PC

How can I hibernate a Windows machine that runs Windows 7 or 8 over my LAN from another PC?
Is there a WinAPI function for that? Or do I have to send special magic packets or something like this?
All I know is that PsShutdown.exe is able to do it (allegedly. I haven't tried it).
I don't want to use third party libraries and I also don't want to run a service on the computer that is supposed to get hibernated. I want to use the existing mechanism.
I'd also like to know if I need to change specific settings on the target computer.
I'm not sure if that's important, but shutdown /s /m \\ComputerName did not work on my target PC.
The TechNet document Restart or Shut Down a Remote Computer and Document the Reason describes the requirements to use the shutdown.exe command against a remote computer.
In order to use this feature, the Remote Registry service must be enabled on the remote computer.
Access to the Remote Registry or membership in the Administrators group on the remote computer is the minimum required to complete this procedure
To the best of my knowledge, the only way to remotely hibernate a machine is to use the same method that psshutdown does: copy an executable to the remote machine and install it as a system service.
The OpenSCManager API allows you to specify a target computer, and you can use the handle it returns to call CreateService and then StartService. The service can delete itself once it has done its work.

I need a Windows 8 WinRT application to communicate with a standalone application written in C

I have 2 application running on the same machine.
Editor, is a Windows 8 application developed with WinRT and is sand-boxed. (Client)
Integrator is a C++ application for reading hardware devices over serial COM ports. (Server)
I have done a lot of searches about how to get client/server communication to work on Windows 8,
and can only find posts that say it is not possible using standard WinRT classes, etc.
What I need is a solution where by the Windows 8 application works as a client, and the standalone
executable works as a server.
Can someone please suggest a mechanism that can be used to do client/server communication.
If we cannot find a good solution for this, then we will have to resort to using files, which
I would rather not have to do.
Clarification: I am aware of the many mechanism that can be used to do client/server communication.
What I am looking for is a workaround to the problem, where the these techniques will not work on
a Windows 8 application, developed with WinRT. As the sand-boxing explicitly prohibits the client
and server being on the same host machine.
Well, the posts stating that such communication is not possible, are mostly right. There are 2 reasons, why this is prevented:
Being able to communicate to an application outside the sandbox effectively breaks the sandbox. The Windows Store app is now suddenly able to do everything the desktop application can do: access file system, registry... Windows Store apps live in a sandbox for reason - to be safe for the user.
The Windows Store app won't work after it is installed from the the store or from a package. It needs to have a desktop application installed and set up correctly as well.
I would suggest you try to move your server part to a different machine and make it a proper server. If for some reason you really can't do that, you still have the following options available:
You can use TCP/IP to connect local network resources if you remove the isolation for your Windows Store app. You will need to use CheckNetIsolation.exe, but since you already need to separately install the desktop application, this shouldn't be that much of a problem.
You can create files with a specific extension. Then register the desktop app for one extension and the Windows Store app for another extension. You can now shell execute files with these extensions to use them as a message for the other app.

how to read certificate from USB device and send it to browser like firefox

I want to write a c++ dll that read certificate from my USB device and send that to browsers like Firefox.And I should mention that i have built my USB device with an ATMega32A which have 2K EEPROM and i stored a sample certificate on that.
I have read some about PKCS#11 standard but i cant figure out where to start. Could anyone help me on this?
It sounds like you're creating a PKI hardware device. I think your biggest hurdle will be accessing the ATMega32. It'll be up to you to implement an interface on the ATMega side, be that a RS232-usb bridge, USB Mass Storage, or proprietary with a custom driver.
A simple solution might be to use a USB Mass Storage interface to present a certificate as file on a pseudo disk.
Taking the custom driver route, Firefox (and other Mozilla products) use libraries that have interfaces for PKI hardware. See NSS and OpenSC.
At a guess it's possible that there's a PKI / PKCS11 driver API for Windows that you can implement.
You can not "add to Firefox" but you can expose your data to firefox and make them available for use. To do this you need to implement PKCS#11 API and create so-called PKCS#11 driver (the user-mode DLL which implements those 70 or so functions defined in PKCS#11 API). Those functions would talk to the hardware device in order to perform certain operations. Then you plug this PKCS#11 DLL to Firefox and Firefox can use certificates on your device.
Step 1: write a dll that can read data from the USB device. You could use Winusb. This will require the firmware to support it.
Step 2: write a dll that can add a certificate to Firefox
Step 3: combine previous steps into one dll
If you get stuck on something specific, write a new question and show us what you have done so far.

Detect devices on local network for client-server connection in C++

I'm trying to implement an auto-connect feature for my Android application DroidPad, which is basically a TCP server running on an Android phone which the PC application connects to.
To make the process easier for the user, is there any way in (portable?) C++ to scan the IP addresses on the local subnet, possibly ones with a certain open port? I've tried using UDP broadcasting, but couldn't get it to work. I'm currently using the wxWidgets toolkit for GUI and libraries.
Any ideas?
I found a solution: wxServDisc. It uses mDNS (aka Zeroconf / Bonjour) to discover devices on a subnet, and is also based on wxWidgets.

Secure file upload with Qt

I'm in the process of creating a utility to backup user's media files. The media isn't being shared etc its only a backup utility.
I'm trying to think of the best way to protect users from ISPs accusing them of downloading illegal media files by using some sort of secure connection.
The utility is written in C++ using the Qt lib and so far I've only been able to find the QtSslSocket component for secure connections. The domain already has a valid SSL certificate for the next few years.
Can anyone suggest the best way to go about implementing this from both the server and client side. i.e what does the server need to have in place and is there anything in particular the backup utility needs to implement from the client side to ensure secure transactions?
Are there any known, stable sftp or ftps servers available etc?
As far as I know, Qt doesn't have support for secure FTP transfers.
Not sure what other info. would be useful to make the question any clearer but any advice or help pointing me in the right direction will be most welcomed.
EDIT I'm also Java competent so a Java solution will work just as well...
As Martin wrote, you can wrap client. But if you don't want to do that, you can use libssh.
I searched for some sort of solution to this for a couple days and then forgot about the problem. Then today I stumbled across this little gem in the Qt-Creator source Utils::ssh, includes support for SFTP, plain-old SSH, and all sorts of goodies.
Disentangling stuff from Qt-Creator can be a pain, but having gone through this process it amounts to grabbing Botan (one of the other libs in QT-Creator) + Utils.
When it rains, it pours, I find two solutions to this problem in an hour - http://nullget.sourceforge.net/ (Requires Chinese translation), but from their summary:
NullGet is written with Qt, runs on
multiple platforms, the GUI interface
of the multi-threaded multi-protocol
HTTP download software. Use NullGet
can easily download a variety of
network protocol data stream, faster
download speeds, support for HTTP, the
protocol currently supported are:
HTTP, HTTPS, FTP, MMS, RTSP. And it
can run on most current popular
operating systems including Windows,
Linux, FreeBSD and so on.
Easiest way would be to just wrap a commandline sftp client with a Qt front end.
On the server any ftp server should do sftp pretty much out of the box.
As Synthesizerpatel says Qt Creator implements SFTP. So I have isolated the library that contains SSH and SFTP and I have created a new project named QSsh in Github (https://github.com/lvklabs/QSsh). The aim of the project is to provide SSH and SFTP support for any Qt Application.
I have written an example on how to upload a file using SFTP in examples/SecureUploader/
I hope it might be helpful