I have one problem with CORBA Asychronical invocation(AMI). The problem is that callback at client side is never invoked.
I simplify example in ACE_Wrappers\TAO\examples\Content_Server\AMI_Observer. The IDL:
module MyServer
{
interface Callback
{
void next_chunk (in string chunk, in boolean last_chunk);
};
interface ContentFactory
{
string register_callback (in string message, in Callback client_callback);
};
};
IN my code, the AMI call is only for ContentFactory. The code is:
//Client.cpp:
CORBA::ORB_var orb = CORBA::ORB_init (argc,argv, "Mighty ORB");
CORBA::Object_var obj1 = orb->string_to_object (argv[1]);
MyServer::ContentFactory_var factory = MyServer::ContentFactory::_narrow(obj1);
if (CORBA::is_nil (factory.in ())) { }
// Get the Root POA.
CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var poa =PortableServer::POA::_narrow (obj.in ());
// Activate the POA manager.
PortableServer::POAManager_var mgr = poa->the_POAManager ();
mgr->activate ();
// Variable used to keep track of when file retrieval has
// completed.
int request_count = 0;
// Activate and run the reply handlers.
//invoke_request(&request_count, factory.in());
////////////////////
MyServer_AMI_ContentFactoryHandler_i handler_i (&request_count);
MyServer::AMI_ContentFactoryHandler_var handler = handler_i._this ();
MyServer_Callback_i* callback_servant_ = new MyServer_Callback_i ();
// Pass ownership of the Callback servant to the POA.
PortableServer::ServantBase_var tmp (callback_servant_);
// Activate the Callback.
MyServer::Callback_ptr callback_ = callback_servant_->_this ();
factory->sendc_register_callback(handler.in(), "xushijie", callback_);
///////////////
// 1 millisecond delay to reduce "busy waiting" in ORB event
// loop.
ACE_Time_Value tv (0, 1000);
// Run the ORB event loop.
while (request_count > 0)
{
if (orb->work_pending ())
{
orb->perform_work ();
}
else
ACE_OS::sleep (tv);
}
orb->shutdown (0);
//serverI.h
class MyServer_AMI_ContentFactoryHandler_i
: public virtual POA_MyServer::AMI_ContentFactoryHandler
{
public:
// Constructor
MyServer_AMI_ContentFactoryHandler_i (int* requestCount);
// Destructor
virtual ~MyServer_AMI_ContentFactoryHandler_i (void);
virtual
void register_callback (
const char * ami_return_val);
virtual
void register_callback_excep (
::Messaging::ExceptionHolder * excep_holder);
public:
int* _request_count;
private:
void deactivated(void);
};
//serverI.cpp:
MyServer_AMI_ContentFactoryHandler_i::MyServer_AMI_ContentFactoryHandler_i (int* request_count)
{
_request_count = request_count;
(*this->_request_count)++;
std::cout<<" BUild AMI Content Factory Handle and request count: "<<(*this->_request_count)<<std::endl;
}
// Implementation skeleton destructor
MyServer_AMI_ContentFactoryHandler_i::~MyServer_AMI_ContentFactoryHandler_i (void)
{
}
void MyServer_AMI_ContentFactoryHandler_i::register_callback (
const char * ami_return_val)
{
(*this->_request_count)--;
std::cout<<" Reply from contentServer: "<<ami_return_val<<" "<<(*this->_request_count)<<std::endl;
this->deactivated();
}
The pointer request_count is passed to MyServer_AMI_ContentFactoryHandler_i construction and its pointed value increases. Once AMI callback register_callback is invoked, the pointed request_count value decreases which in turn while loop in main function completes.
The register_callback at servant side is only sleep for 5 seconds and then return a hello string. This code compile OK but MyServer_AMI_ContentFactoryHandler_i::register_callback is never invoked. During debuging, the orb->work_pending () keeps return false..
I also compared my code to AMI_Observer and original example at page: http://www.dre.vanderbilt.edu/~schmidt/DOC_ROOT/TAO/docs/tutorials/Quoter/AMI/index.html. This issue takes me one day and i am lost..
THanks if you could help pointer out my error...
////////////////////////////////////////////////////////////////////
UPDATE:
The LOG with Debug level 10:
TAO_Messaging (9056|2720) - Asynch_Invocation_Adapter::invoke
TAO (9056|2720) - Invocation_Adapter::invoke_i, making a TAO_CS_REMOTE_STRATEGY invocation
TAO (9056|2720) - Transport_Cache_Manager_T::fill_set_i, current_size = 0, cache_maximum = 512
TAO (9056|2720) - Transport_Cache_Manager_T::purge, Cache size after purging is [0]
TAO (9056|2720) - IIOP_Connector::begin_connection, to <192.168.1.143:13638> which should block
TAO (9056|2720) - TAO_LF_CH_Event[0]::state_changed_i, state LFS_IDLE->LFS_CONNECTION_WAIT
TAO (9056|2720) - IIOP_Connection_Handler[8353360]::IIOP_Connection_Handler, this=007F0370
TAO (9056|2720) - IIOP_Connection_Handler::open, The local addr is <192.168.1.143:13674>
TAO (9056|2720) - IIOP_Connection_Handler::open, IIOP connection to peer <192.168.1.143:13638> on 528
TAO (9056|2720) - Transport::post_open, tport id changed from 8353360 to 528
TAO (9056|2720) - Transport[528]::post_open, cache_map_entry_ is 0
TAO (9056|2720) - TAO_LF_CH_Event[528]::state_changed_i, state LFS_CONNECTION_WAIT->LFS_SUCCESS
TAO (9056|2720) - Cache_IntId_T::Cache_IntId_T, this=0034E670 Transport[528] is connected
TAO (9056|2720) - Cache_IntId_T::recycle_state, ENTRY_UNKNOWN->ENTRY_IDLE_AND_PURGABLE Transport[528] IntId=0034E670
TAO (9056|2720) - Transport_Cache_Manager_T::bind_i, Transport[528] # hash:index{-1062717739:0}
TAO (9056|2720) - Transport_Cache_Manager_T::bind_i: Success Transport[528] # hash:index{-1062717739:0}. Cache size is [1]
TAO (9056|2720) - IIOP_Connector::make_connection, new connected connection to <192.168.1.143:13638> on Transport[528]
TAO (9056|2720) - Transport[528]::register_handler
TAO (9056|2720) - Transport[528]::register_handler - registering event handler with reactor
TAO (9056|2720) - Transport_Connector::connect, opening Transport[528] in TAO_CLIENT_ROLE
TAO (9056|2720) - Transport_Cache_Manager_T::is_entry_available_i[528], true, state is ENTRY_IDLE_AND_PURGABLE
TAO (9056|2720) - Cache_IntId_T::recycle_state, ENTRY_IDLE_AND_PURGABLE->ENTRY_BUSY Transport[528] IntId=007B588C
TAO (9056|2720) - Transport_Cache_Manager_T::find_i, Found available Transport[528] #hash:index {-1062717739:0}
TAO (9056|2720) - Transport_Connector::connect, got an existing connected Transport[528] in role TAO_CLIENT_ROLE
TAO (9056|2720) - Codeset_Manager_i::set_tcs, setting char translator (00010001)
TAO (9056|2720) - Codeset_Manager_i::set_tcs, setting wchar translator (00010109)
TAO (9056|2720) - Muxed_TMS[528]::request_id, <1>
**//BEGIN DEVELIER DATA**
TAO (9056|2720) - Codeset_Manager_i::generate_service_context, using tcs_c <ISO8859_1> (00010001), tcs_w <UTF-16> (00010109)
TAO (9056|2720) - GIOP_Message_Base::dump_msg, send GIOP message v1.2, 260 data bytes, my endian, Type Request[1]
GIOP message - HEXDUMP 272 bytes
47 49 4f 50 01 02 01 00 04 01 00 00 01 00 00 00 GIOP............
03 00 00 00 00 00 cd cd 1b 00 00 00 14 01 0f 00 ................
52 53 54 54 0c e9 53 bb 33 0a 00 00 00 00 00 01 RSTT..S.3.......
00 00 00 01 00 00 00 cd 12 00 00 00 72 65 67 69 ............regi
73 74 65 72 5f 63 61 6c 6c 62 61 63 6b 00 cd cd ster_callback...
01 00 00 00 01 00 00 00 0c 00 00 00 01 cd cd cd ................
01 00 01 00 09 01 01 00 09 00 00 00 78 75 73 68 ............xush
69 6a 69 65 00 cd cd cd 1a 00 00 00 49 44 4c 3a ijie........IDL:
4d 79 53 65 72 76 65 72 2f 43 61 6c 6c 62 61 63 MyServer/Callbac
6b 3a 31 2e 30 00 cd cd 01 00 00 00 00 00 00 00 k:1.0...........
6c 00 00 00 01 01 02 cd 0e 00 00 00 31 39 32 2e l...........192.
31 36 38 2e 31 2e 31 34 33 00 69 35 1b 00 00 00 168.1.143.i5....
14 01 0f 00 52 53 54 c4 0c e9 53 61 3d 08 00 01 ....RST...Sa=...
00 00 00 01 00 00 00 02 00 00 00 cd 02 00 00 00 ................
00 00 00 00 08 00 00 00 01 cd cd cd 00 4f 41 54 .............OAT
01 00 00 00 18 00 00 00 01 cd cd cd 01 00 01 00 ................
01 00 00 00 01 00 01 05 09 01 01 00 00 00 00 00 ................
TAO (9056|2720) - Transport[528]::send_asynchronous_message_i, trying to send the message (ml = 272)
TAO (9056|2720) - Transport[528]::drain_queue_helper, sending 1 buffers
TAO (9056|2720) - Transport[528]::drain_queue_helper, buffer 0/1 has 272 bytes
TAO - Transport[528]::drain_queue_helper (0/272) - HEXDUMP 272 bytes
47 49 4f 50 01 02 01 00 04 01 00 00 01 00 00 00 GIOP............
03 00 00 00 00 00 cd cd 1b 00 00 00 14 01 0f 00 ................
52 53 54 54 0c e9 53 bb 33 0a 00 00 00 00 00 01 RSTT..S.3.......
00 00 00 01 00 00 00 cd 12 00 00 00 72 65 67 69 ............regi
73 74 65 72 5f 63 61 6c 6c 62 61 63 6b 00 cd cd ster_callback...
01 00 00 00 01 00 00 00 0c 00 00 00 01 cd cd cd ................
01 00 01 00 09 01 01 00 09 00 00 00 78 75 73 68 ............xush
69 6a 69 65 00 cd cd cd 1a 00 00 00 49 44 4c 3a ijie........IDL:
4d 79 53 65 72 76 65 72 2f 43 61 6c 6c 62 61 63 MyServer/Callbac
6b 3a 31 2e 30 00 cd cd 01 00 00 00 00 00 00 00 k:1.0...........
6c 00 00 00 01 01 02 cd 0e 00 00 00 31 39 32 2e l...........192.
31 36 38 2e 31 2e 31 34 33 00 69 35 1b 00 00 00 168.1.143.i5....
14 01 0f 00 52 53 54 c4 0c e9 53 61 3d 08 00 01 ....RST...Sa=...
00 00 00 01 00 00 00 02 00 00 00 cd 02 00 00 00 ................
00 00 00 00 08 00 00 00 01 cd cd cd 00 4f 41 54 .............OAT
01 00 00 00 18 00 00 00 01 cd cd cd 01 00 01 00 ................
01 00 00 00 01 00 01 05 09 01 01 00 00 00 00 00 ................
TAO (9056|2720) - Transport[528]::drain_queue_helper, end of data
TAO (9056|2720) - Transport[528]::cleanup_queue, byte_count = 272
TAO (9056|2720) - Transport[528]::cleanup_queue, after transfer, bc = 0, all_sent = 1, ml = 0
TAO (9056|2720) - Transport[528]::drain_queue_helper, byte_count = 272, head_is_empty = 1
TAO (9056|2720) - Transport[528]::drain_queue_i, helper retval = 1
TAO (9056|2720) - Transport[528]::make_idle
**//The data in buffer is sent then idle.......**
TAO (9056|2720) - Cache_IntId_T::recycle_state, ENTRY_BUSY->ENTRY_IDLE_AND_PURGABLE Transport[528] IntId=007B588C
I am not quite familar with TAO log, but according the log above, seems server has not response..
/////////////////////////////////////////
UPDATE:
Figure out the root cause now..
The servant
char * MyServer_ContentFactory_i::register_callback (const char * message, ::MyServer::Callback_ptr client_callback)
{
ACE_OS::sleep(5);
if (CORBA::is_nil (client_callback)) // ## Will it ever be nil?
throw CORBA::BAD_PARAM ();
..........
return "xushijie"; // >__< errors..
}
After changing return statement to:
CORBA::String_var str = CORBA::string_dup("xushijie");
return str._retn();
The example works now..
You didn't follow the IDL to C++ memory management rules, when you return memory the caller gets ownership so you must use string_dup, no need for the intermediate _var. The new IDL to C++11 language mapping is way easier, there the return of the constant string just works without problems, see https://www.taox11.org for TAOX11, it also supports AMI.
Related
I want to decode data (Temperature and %RH) from a BLE device.
I can get data from it. I know (guessed) where the data is (0x0028). But I don't know how to decode it.
Here is what I get when running :
sudo bettercap
ble.enum 60:77:71:60:d1:8f
I then guessed the data is on handles 0x0028.
And here is what I get when I run :
sudo gatttool -b 60:77:71:60:d1:8f -I
connect
char-read-hnd 0x0028
[60:77:71:60:D1:8F][LE]> char-read-hnd 0x0028
Characteristic value/descriptor: 1e 00 8e 41 00 00 00 00 ea 94 3b 42 00 00 00 00 01 01 01 01
[60:77:71:60:D1:8F][LE]> char-read-hnd 0x0028
Characteristic value/descriptor: c6 e4 8d 41 00 00 00 00 30 73 3b 42 00 00 00 00 01 01 01 01
[60:77:71:60:D1:8F][LE]> char-read-hnd 0x0028
Characteristic value/descriptor: c6 e4 8d 41 00 00 00 00 30 73 3b 42 00 00 00 00 01 01 01 01
[60:77:71:60:D1:8F][LE]> char-read-hnd 0x0028
Characteristic value/descriptor: c6 e4 8d 41 00 00 00 00 9a 40 3b 42 00 00 00 00 01 01 01 01
[60:77:71:60:D1:8F][LE]> char-read-hnd 0x0028
Characteristic value/descriptor: 1e 00 8e 41 00 00 00 00 56 2e 3b 42 00 00 00 00 01 01 01 01
[60:77:71:60:D1:8F][LE]> char-read-hnd 0x0028
Characteristic value/descriptor: 1e 00 8e 41 00 00 00 00 42 19 3b 42 00 00 00 00 01 01 01 01
[60:77:71:60:D1:8F][LE]> char-read-hnd 0x0028
Characteristic value/descriptor: c6 e4 8d 41 00 00 00 00 18 23 3b 42 00 00 00 00 01 01 01 01
I think the data (°C and %RH) I'm looking for is in there but I have no idea how to decipher it.
Can somebody help ?
I tried to convert it from hex to dec but I didn't get any conclusive results.
°C should be between 17 and 23 and %HR between 20 and 80.
Before warming up the sensor : 1e 00 8e 41 00 00 00 00 ea 94 3b 42 00 00 00 00 01 01 01 01
After warming up the sensor : c6 e4 8d 41 00 00 00 00 30 73 3b 42 00 00 00 00 01 01 01 01
I am struggling to get Windows to load the default WinUSB driver for my device. Please note that I am looking for a solution that is using BOS descriptor (and not the old 0xEE string index).
The device enumerates and Windows tells me that it is installing the device, but the WinUSB driver is not loaded. I have tried everything that I can think of, but still I can't get Windows to load the driver. I even uninstall the device and delete the USB flags in the registry whenever I re-try, but to no avail. Is there anyone who can help me to get this to work?
I don't want WebUSB capabilities or anything additional. This is a non-composite device.
This is my BOS descriptor (as sent over USB):
05 0F 21 00 01 1C 10 05 00 DF 60 DD D8 89
45 C7 4C 9C D2 65 9D 9E 64 8A 9F 00 00 03
06 B2 00 01 00
And this my BOS descriptor set:
0A 00 00 00 00 00 03 06 B2 00 08 00 01 00 ..............
00 00 A8 00 08 00 02 00 00 00 A0 00 14 00 ..............
03 00 57 49 4E 55 53 42 00 00 00 00 00 00 ..WINUSB......
00 00 00 00 84 00 04 00 07 00 2A 00 44 00 ..........*.D.
65 00 76 00 69 00 63 00 65 00 49 00 6E 00 e.v.i.c.e.I.n.
74 00 65 00 72 00 66 00 61 00 63 00 65 00 t.e.r.f.a.c.e.
47 00 55 00 49 00 44 00 73 00 00 00 50 00 G.U.I.D.s...P.
7B 00 46 00 37 00 32 00 46 00 45 00 30 00 {.F.7.2.F.E.0.
44 00 34 00 2D 00 43 00 42 00 43 00 42 00 D.4.-.C.B.C.B.
2D 00 34 00 30 00 37 00 44 00 2D 00 38 00 -.4.0.7.D.-.8.
38 00 31 00 34 00 2D 00 39 00 45 00 44 00 8.1.4.-.9.E.D.
36 00 37 00 33 00 44 00 30 00 44 00 44 00 6.7.3.D.0.D.D.
36 00 42 00 7D 00 00 00 00 00 6.B.}.....
The layout is:
typedef struct _SMSOS20DescriptorSet
{
SDeviceDescSetHeader sDescriptorSetHeader;
SConfigurationSubsetHeader sConfSubsetHeader;
SFunctionSubsetHeader sFuncSubsetHeader;
SDeviceCompatibleIdDescriptor sCompIdDescriptor;
SDeviceRegDescDeviceInterfaceGUID sRegistryDescDevInterfaceGuid;
} SMSOS20DescriptorSet;
I have follewed these guides and doc:
https://learn.microsoft.com/en-us/windows-hardware/drivers/usbcon/automatic-installation-of-winusb#winusb-device-installation-by-using-the-in-box-winusbinf
MS_OS_2_0_desc.docx
https://thewindowsupdate.com/2018/10/12/how-to-install-winusb-sys-without-a-custom-inf/
https://learn.microsoft.com/en-us/windows-hardware/drivers/usbcon/winusb-installation#automatic-installation-of--winusb-without-an-inf-file
UPDATE:
when you have a non-composite device that only has a single a configuration, then you are not use any subset headers (neither 'Configuration subset header' nor 'Function subset header'). So, the correct layout in this case is:
typedef struct _SMSOS20DescriptorSet
{
SDeviceDescSetHeader sDescriptorSetHeader;
SDeviceCompatibleIdDescriptor sCompIdDescriptor;
SDeviceRegDescDeviceInterfaceGUID sRegistryDescDevInterfaceGuid;
} SMSOS20DescriptorSet;
UPDATE: when you have a non-composite device that only has a single a configuration, then you are not use any subset headers (neither 'Configuration subset header' nor 'Function subset header'). So, the correct layout in this case is:
typedef struct _SMSOS20DescriptorSet
{
SDeviceDescSetHeader sDescriptorSetHeader;
SDeviceCompatibleIdDescriptor sCompIdDescriptor;
SDeviceRegDescDeviceInterfaceGUID sRegistryDescDevInterfaceGuid;
} SMSOS20DescriptorSet;
A wordpress website running on XAMPP which is accessible from the internet. Now since i only have a domain name and not a service with emails included I've setup my email under zoho.com...
Send emails from a email address to the setup address at zoho.com works just fine... Now comes the problem:
When I try to use a contact form on wordpress (Which is running on xampp) it fails to work.
I have adjusted my sendmail.ini and php.ini with the following:
In php.ini:
SMTP = smtp.zoho.com
smtp_port = 465
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" // This was commented with a ; in front and i uncommented it.
; sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe" // This was uncommented (did not have the ;) i commented it otherwise it would safe the mails on the drive
in sendmail.ini i adjusted the following:
smtp_server= smtp.zoho.com
smtp_port=465
smtp_ssl=ssl
error_logfile=error.log
debug_logfile=debug.log
auth_username=bla#mydomain.com // This is adjusted to dummydata in this post.
auth_password=mypassword // This is adjusted to dummydata in this post.
However i still get a crash file when i try the contact form saying the following:
(deleted some data out of here, which had nothing to do with the error, such as my pc name and my language etc etc.)
display mode : 1920x1080, 32 bit
process id : $c48
allocated memory : 26,24 MB
command line : "C:\xampp\sendmail\sendmail.exe" -t
executable : sendmail.exe
exec. date/time : 2011-06-18 01:10
compiled with : Delphi 2006/07
madExcept version : 3.0l
callstack crc : $1d5da2f6, $4f4b1b87, $4f4b1b87
exception number : 1
exception class : EIdSocketError
exception message : Socket Error # 10060 Connection timed out.
main thread ($1ac4):
00435e23 +0073 sendmail.exe IdStack 706 +42 TIdStack.RaiseSocketError
00435daa +0016 sendmail.exe IdStack 660 +1 TIdStack.RaiseLastSocketError
0045f2e8 +0100 sendmail.exe IdSSLOpenSSLHeaders 16464 +22 EIdOpenSSLAPISSLError.RaiseExceptionCode
0045f1d9 +0021 sendmail.exe IdSSLOpenSSLHeaders 16433 +1 EIdOpenSSLAPISSLError.RaiseException
00466686 +012a sendmail.exe IdSSLOpenSSL 2668 +17 TIdSSLSocket.Connect
00465a1c +00dc sendmail.exe IdSSLOpenSSL 2262 +21 TIdSSLIOHandlerSocketOpenSSL.OpenEncodedConnection
004655f6 +0062 sendmail.exe IdSSLOpenSSL 2106 +9 TIdSSLIOHandlerSocketOpenSSL.StartSSL
00465587 +006b sendmail.exe IdSSLOpenSSL 2093 +15 TIdSSLIOHandlerSocketOpenSSL.ConnectClient
00444a9f +0063 sendmail.exe IdIOHandlerSocket 335 +13 TIdIOHandlerSocket.Open
00465637 +0007 sendmail.exe IdSSLOpenSSL 2122 +1 TIdSSLIOHandlerSocketOpenSSL.Open
0044157d +0235 sendmail.exe IdTCPClient 318 +53 TIdTCPClientCustom.Connect
00445cc8 +00a4 sendmail.exe IdExplicitTLSClientServerBase 257 +23 TIdExplicitTLSClient.Connect
0045ab7b +0017 sendmail.exe IdSMTP 373 +2 TIdSMTP.Connect
004b5f14 +1060 sendmail.exe sendmail 808 +326 initialization
7773919d +000c KERNEL32.DLL BaseThreadInitThunk
stack dump:
0018fbac 28 5e 43 00 de fa ed 0e - 01 00 00 00 07 00 00 00 (^C.............
0018fbbc c0 fb 18 00 28 5e 43 00 - 80 cc 1d 02 ec 28 43 00 ....(^C......(C.
0018fbcc c0 3f 46 00 78 1d 1f 02 - fc fb 18 00 dc fb 18 00 .?F.x...........
0018fbdc 10 fc 18 00 c8 4b 40 00 - fc fb 18 00 05 00 00 00 .....K#.........
0018fbec 00 00 00 00 00 00 00 00 - 4c 27 00 00 30 50 1d 02 ........L'..0P..
0018fbfc 08 fc 18 00 ad 5d 43 00 - 30 50 1d 02 f0 fc 18 00 .....]C.0P......
0018fc0c ed f2 45 00 14 fd 18 00 - c8 4b 40 00 f0 fc 18 00 ..E......K#.....
0018fc1c f8 38 82 03 ff ff ff ff - c0 3f 46 00 00 00 00 00 .8.......?F.....
0018fc2c 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................
0018fc3c eb 61 ce 7c c0 f6 82 03 - e7 6c 74 c9 6f e6 00 12 .a.|.....lt.o...
0018fc4c e0 fa 82 03 20 11 00 00 - f8 38 82 03 f7 ec 00 12 .........8......
0018fc5c 00 00 00 00 00 00 00 00 - e0 fa 82 03 06 00 00 00 ................
0018fc6c 01 00 00 00 58 37 82 03 - f9 27 04 11 00 f3 03 12 ....X7...'......
0018fc7c 4b 6b 74 c9 38 fa 00 12 - f8 38 82 03 16 00 00 00 Kkt.8....8......
0018fc8c e0 fa 82 03 04 00 00 00 - 00 00 00 00 00 00 00 00 ................
0018fc9c f8 38 82 03 00 00 00 00 - f8 38 82 03 ce 86 00 12 .8.......8......
0018fcac f8 38 82 03 20 11 00 00 - 21 11 00 00 ff ff ff ff .8......!.......
0018fcbc 20 4e 00 00 d4 fc 18 00 - 20 11 00 00 00 00 00 00 .N..............
0018fccc 00 00 00 00 ff ff ff ff - ad d5 01 12 a0 3a 82 03 .............:..
0018fcdc 04 00 00 00 00 00 00 00 - ff ff ff ff 00 00 00 00 ................
disassembling:
[...]
00435e13 push eax
00435e14 mov ecx, [ebp-8]
00435e17 mov dl, 1
00435e19 mov eax, [$4352ac]
00435e1e call -$717 ($43570c) ; IdStack.EIdSocketError.CreateError
00435e23 > call -$3113c ($404cec) ; System.#RaiseExcept
00435e28 707 xor eax, eax
00435e2a pop edx
00435e2b pop ecx
00435e2c pop ecx
00435e2d mov fs:[eax], edx
[...]
I wrote a program for parsing SQLite file, i can parse all data from b-tree pages to record, column & values but i need to parse schema of tables, i found something like database schema stored in page 1 (root page) and i can see it with Hex Editor, and i found structure of sqlite_master, i read it exact as explain in http://sqlite.org/fileformat2.html
I want to know how can i found the first byte of sqlite_master table in db file, how can i detect starting byte of schema? is there anything related in SQLite DB Header?
Edit 1 (more info):
For example:
i opened sqlite db with hex editor, (if you check my page size is 4096 bytes and i marked page header in image):
i marked root page header that start with 05 means the page is an interior table b-tree page and please check B-tree Page Header Format (http://sqlite.org/fileformat2.html) and its have 5 cells that you can see it with this cell pointers array: 0FFB, 0FF6, 0FF1, 0FEC, 0FE7 (that start after ending header) and all cells have 5 bytes and start from 0FE7 then the schema that you can see it in picture ( in text part ) start from 232~240 and i check other dbs and schema in different place...
Edit 2:
You can download Example File from https://www.dropbox.com/s/lanky02kneyb74w/31bb7ba8914766d4ba40d6dfb6113c8b614be442
Edit 3:
In my file you can see
$ hexdump -C 31bb7ba8914766d4ba40d6dfb6113c8b614be442
00000000 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 |SQLite format 3.|
00000010 10 00 02 02 00 40 20 20 00 00 00 02 00 00 00 3f |.....# .......?|
00000020 00 00 00 00 00 00 00 00 00 00 00 47 00 00 00 04 |...........G....|
00000030 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 |................|
00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 |................|
00000060 00 2d e2 25 05 00 00 00 05 0f e7 00 00 00 00 3d |.-.%...........=|
00000070 0f fb 0f f6 0f f1 0f ec 0f e7 08 7f 07 9d 08 3c |...............<|
00000080 07 01 06 22 05 92 04 fe 03 fc 04 c1 03 4d 02 b8 |...".........M..|
00000090 02 0a 02 75 01 32 01 c7 00 e9 00 e9 00 00 00 00 |...u.2..........|
000000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000000e0 00 00 00 00 00 00 00 00 00 47 18 06 17 5b 35 01 |.........G...[5.|
000000f0 00 69 6e 64 65 78 73 71 6c 69 74 65 5f 61 75 74 |.indexsqlite_aut|
00000100 6f 69 6e 64 65 78 5f 41 42 4d 75 6c 74 69 56 61 |oindex_ABMultiVa|
00000110 6c 75 65 45 6e 74 72 79 4b 65 79 5f 31 41 42 4d |lueEntryKey_1ABM|
00000120 75 6c 74 69 56 61 6c 75 65 45 6e 74 72 79 4b 65 |ultiValueEntryKe|
Page Header ( offset 64)
05 <- interior table b-tree page
0000 <- Byte offset into the page of the first freeblock
0005 <- Number of cells on this page
0FE7 <- Offset to the first byte of the cell content area
00 <- Number of fragmented free bytes
0000003D (61) <- The right-most pointer
Cell Array Pointers & Cell Contents:
(Table Interior Cell Format)
Cell Pointer| Page number of left child | Rowid
------------|---------------------------|-------
0FFB | 0000001A (26) | 15
0FF6 | 0000001C (28) | 2D
0FF1 | 00000031 (49) | 3C
0FEC | 00000039 (57) | 48
0FE7 | 0000003C (60) | 4C <- equal to (Offset to the first byte of the cell content area) in page header
I realize your question was asked over a year ago and you probably resolved it, but I would like to submit an answer in case anyone else has this same question. I was in the same situation as you, Mehdi. I wanted to read a SQLite database file, and was looking for the master table / schema. It appeared to be in page 1, but the header was not pointing to it. There were two reasons for my confusion.
(1) There was a lot of "dead" data in my SQLite database file that was not being used. I believe as the database was created and grew, the location of the actual active data moved, and the old location was not overwritten with zeros. Doing a search for some of the "CREATE TABLE" statements found multiple results in different locations of the file. I later determined the actual schema was split up and located on pages 18, 10, and 8 (which the page 1 interior table pointed to). I would have detected this earlier, if not for reason #2.
(2) I had miscalculated the byte position of the page number, which confused me. Where p = page #, and s = page size, I thought it was [p * s] .... but actually it's [(p-1) * s] (except for page 1 which starts at byte 100). In other words, I thought the page numbering started at zero instead of 1.
As an additional note, I believe the http://sqlite.org/fileformat2.html page is missing some vital info. Specifically, it doesn't explain where the "root page" number is in the schema table (it's in field 4). I couldn't find this information on the sqlite.org page.
The documentation you linked to says in section 2.6:
Page 1 of a database file is the root page of a table b-tree that holds a special table named "sqlite_master"
and in section 1.5:
A b-tree page is divided into regions in the following order:
The 100-byte database file header (found on page 1 only)
The 8 or 12 byte b-tree page header …
For example, with this database:
$ sqlite3 test.db "create table hello(world);"
$ hexdump -C test.db
00000000 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 |SQLite format 3.|
00000010 04 00 01 01 00 40 20 20 00 00 00 01 00 00 00 02 |.....# ........|
00000020 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 04 |................|
00000030 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 |................|
00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 |................|
00000060 00 2d e6 03 0d 00 00 00 01 03 cf 00 03 cf 00 00 |.-æ.......Ï..Ï..|
00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000003c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2f |.............../|
000003d0 01 06 17 17 17 01 3f 74 61 62 6c 65 68 65 6c 6c |......?tablehell|
000003e0 6f 68 65 6c 6c 6f 02 43 52 45 41 54 45 20 54 41 |ohello.CREATE TA|
000003f0 42 4c 45 20 68 65 6c 6c 6f 28 77 6f 72 6c 64 29 |BLE hello(world)|
00000400 0d 00 00 00 00 04 00 00 00 00 00 00 00 00 00 00 |................|
00000410 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
... the page header at offset 0x64 has these values:
0d: page is a leaf table b-tree page
0000: freeblock offset
0001: number of cells
03cf: offset of cell content
00: fragmented free bytes
03cf: first cell pointer
And at offset 3cf, you have a standard table b-tree leaf cell, containing the only row of the sqlite_master table:
sqlite> select * from sqlite_master;
type name tbl_name rootpage sql
---------- ---------- ---------- ---------- -------------------------
table hello hello 2 CREATE TABLE hello(world)
I have a very long running task I need to take from my website and put into a web service however every time I try call the web service I get this error message The request failed with HTTP status 401: Unauthorized.
I assumed this could just be an issue with the credentials as I have seen something similar when sending emails so I did this:
Dim wsCustomer As New blueprintdev.RosterEmailService()
Dim basicAuthenticationInfo As New System.Net.NetworkCredential("user", "pass")
wsCustomer.UseDefaultCredentials = False
wsCustomer.PreAuthenticate = True
wsCustomer.Credentials = basicAuthenticationInfo
txtTestResult.Text = wsCustomer.Test()
This still gives me the same issue.
Also tried this using default credentials and that still does not help.
Now I have no idea how to properly do this, and so I have mostly worked off tutorials etc, can anyone tell me what im doing wrong here?
Thanks
Additional notes: the project im working on is one I inherited when I joined the company and cant be built in visual studio so breakpointing through the code is not an option for me without massively hacking the project and removing a lot of code.
Update: Running fiddler shows me 3 entries, when I look at the auth tab i see:
No Proxy-Authenticate Header is present.
WWW-Authenticate Header (Negotiate) appears to be a Kerberos reply:
A1 15 30 13 A0 03 0A 01 03 A1 0C 06 0A 2B 06 01 ¡.0. ....¡...+..
04 01 82 37 02 02 0A ..7...
Then
No Proxy-Authenticate Header is present.
WWW-Authenticate Header (Negotiate) appears to be a Kerberos reply:
A1 81 E2 30 81 DF A0 03 0A 01 01 A2 81 D7 04 81 ¡â0ß ....¢×.
D4 4E 54 4C 4D 53 53 50 00 02 00 00 00 0E 00 0E ÔNTLMSSP........
00 38 00 00 00 15 82 89 E2 C1 20 C3 44 5E 99 21 .8....âÁ ÃD^!
A0 00 00 00 00 00 00 00 00 8E 00 8E 00 46 00 00 ..........F..
00 06 01 B1 1D 00 00 00 0F 41 00 43 00 41 00 44 ...±.....A.C.A.D
00 45 00 4D 00 59 00 02 00 0E 00 41 00 43 00 41 .E.M.Y.....A.C.A
00 44 00 45 00 4D 00 59 00 01 00 06 00 44 00 45 .D.E.M.Y.....D.E
00 56 00 04 00 1A 00 6C 00 6F 00 63 00 61 00 6C .V.....l.o.c.a.l
00 2E 00 41 00 63 00 61 00 64 00 65 00 6D 00 79 ...A.c.a.d.e.m.y
00 03 00 22 00 44 00 45 00 56 00 2E 00 6C 00 6F ...".D.E.V...l.o
00 63 00 61 00 6C 00 2E 00 41 00 63 00 61 00 64 .c.a.l...A.c.a.d
00 65 00 6D 00 79 00 05 00 1A 00 6C 00 6F 00 63 .e.m.y.....l.o.c
00 61 00 6C 00 2E 00 41 00 63 00 61 00 64 00 65 .a.l...A.c.a.d.e
00 6D 00 79 00 07 00 08 00 2E 76 48 74 53 21 CD .m.y......vHtS!Í
01 00 00 00 00
.....
And finally this one highlighted in red
No Proxy-Authenticate Header is present.
No WWW-Authenticate Header is present.
Does this mean the authentication data is being lost somewhere between client and server? or that I am not passing anything to begin with?
If you can access the service through a browser I suggest passing in your username including domain as the credentials.
The username would look something like this: DOMAIN\USER
I've had a similar problem and the username and password had to be explicitly added.
ie.
wsCustomer.username = "something"
wsCustomer.password = "something else"
I guess you're already doing that with:
Dim basicAuthenticationInfo As New System.Net.NetworkCredential("user", "pass")
but maybe worth a try