Hello,
Is it possible to create or open a shared memory block like in php.
https://www.php.net/manual/en/function.shmop-open.php
Best regards,
Otto
Create or open a shared memory block
Create or open a shared memory block
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Create or open a shared memory block
Otto,
For Windows you could use GlobalAlloc()
https://docs.microsoft.com/en-us/window ... lobalalloc
To make it Linux and OSX compatible, then simply use malloc()
For Windows you could use GlobalAlloc()
https://docs.microsoft.com/en-us/window ... lobalalloc
To make it Linux and OSX compatible, then simply use malloc()
Re: Create or open a shared memory block
Dear Antonio,
thank you. Would you be so kind to post a little sample.
Best regards,
Otto
thank you. Would you be so kind to post a little sample.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Create or open a shared memory block
Code: Select all
#include <windows.h>
#include <hbapi.h>
HB_FUNC( MEMBLOCK )
{
hb_retptr( GlobalAlloc( hb_parnl( 1 ), ( SIZE_T ) hb_parnll( 2 ) ) );
}
Re: Create or open a shared memory block
Dear Antonio,
When I restart the server, I save a password in memory.
The data in the databases are encrypted with this password .
There are no saved passwords on the server hard drive.
I use a Form to insert the PW.
The programs read the password like this:
Can you please show how to do this.
Sample from WORDPRESS - I would like to use a similar security for my mod harbourPress.
Best regards,
Otto
When I restart the server, I save a password in memory.
The data in the databases are encrypted with this password .
There are no saved passwords on the server hard drive.
I use a Form to insert the PW.
Code: Select all
<?php
$shm_id = shmop_open(0xff3, "c", 0644, 100);
$shm_size = shmop_size($shm_id);
echo "SHM Block mit: ".$shm_size. " Bytes wurde erstellt.\n";
$shm_bytes_written = shmop_write($shm_id, "my key1234567890", 0);
$my_string = shmop_read($shm_id, 0, $shm_size);
echo "Data written: ".$my_string."\n";
shmop_close($shm_id);
?>
Code: Select all
<?php
$shm_id = shmop_open(0xff3, "c", 0644, 100);
$shm_size = shmop_size($shm_id);
echo "SHM Block mit: ".$shm_size. " Bytes wurde erstellt.\n";
$my_string = shmop_read($shm_id, 0, $shm_size);
echo "Data read(PW): ".$my_string."\n";
shmop_close($shm_id);
?>
Sample from WORDPRESS - I would like to use a similar security for my mod harbourPress.
Best regards,
Otto
Code: Select all
function require_wp_db() {
global $wpdb;
// Erstelle einen 100 Byte grossen gemeinsam genutzten Speicherblock
// mit mit der System_ID if 0xff3
$shm_id = shmop_open(0xff3, "c", 0644, 100);
if(!$shm_id) {
echo "Konnte kein gemeinsames Speichersegment erstellen\n";
}
// Hole die Gr�sse des gemeinsamen Speicherblocks
$shm_size = shmop_size($shm_id);
echo "SHM Block mit: ".$shm_size. " Bytes wurde erstellt.\n";
// Den Teststring wieder auslesen
$my_string = shmop_read($shm_id, 0, $shm_size);
if(!$my_string) {
echo "Konnte nicht aus dem gemeinsamen Speicher lesen\n";
}
echo "Die D a t e n im gemeinsamen Speicher waren (PW): |".$my_string."|\n";
// Den Speicherblock l�schen und den gemeinsamen Speicher schliessen
if(!shmop_delete($shm_id)) {
echo "Konnte den gemeinsamen Speicherblock nicht zum L�schen markieren.";
}
shmop_close($shm_id);
require_once( ABSPATH . WPINC . '/wp-db.php' );
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) )
require_once( WP_CONTENT_DIR . '/db.php' );
if ( isset( $wpdb ) ) {
return;
}
$wpdb = new wpdb( DB_USER, $my_string , DB_NAME, DB_HOST );
}
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Create or open a shared memory block
Dear Otto,
https://stackoverflow.com/questions/167 ... y-segments
Ok, here we have the full explanation and a working example:
https://nullprogram.com/blog/2016/04/10/
Thinking how to port this into mod_harbour
https://stackoverflow.com/questions/167 ... y-segments
Ok, here we have the full explanation and a working example:
https://nullprogram.com/blog/2016/04/10/
Thinking how to port this into mod_harbour
Re: Create or open a shared memory block
Dear Antonio,
thank you so much.
Best regards,
Otto
thank you so much.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Create or open a shared memory block
Dear Otto,
I have implemented a first version that is much easier to use (xbase style), you can download it from here:
https://github.com/FiveTechSoft/mod_har ... arbour.dll
https://github.com/FiveTechSoft/mod_har ... harbour.so
The implementation is quite easy:
MWrite( "pwd", "my password" ) // memory write
? MRead( "pwd" ) // memory read
from other browser tab or another user:
? MRead( "pwd" )
There is also a new MErase( "pwd" ) but it is not working fine yet
I have implemented a first version that is much easier to use (xbase style), you can download it from here:
https://github.com/FiveTechSoft/mod_har ... arbour.dll
https://github.com/FiveTechSoft/mod_har ... harbour.so
The implementation is quite easy:
MWrite( "pwd", "my password" ) // memory write
? MRead( "pwd" ) // memory read
from other browser tab or another user:
? MRead( "pwd" )
There is also a new MErase( "pwd" ) but it is not working fine yet
Re: Create or open a shared memory block
Dear Antonio,
Thank you. I will update my mod and test.
This opens so many possibilities.
Best regards,
Otto
Thank you. I will update my mod and test.
This opens so many possibilities.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************