Care Unlock  
Your online unlock store
GSM-Forum  

Welcome to the GSM-Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   GSM-Forum > Other Gsm/Mobile Related Forums > GSM Programming & Reverse Engineering

GSM Programming & Reverse Engineering Here you can post all Kind of GSM Programming and Reverse Engineering tools and Secrets.

Reply
 
LinkBack Thread Tools Display Modes
Old 07-17-2012, 17:31   #1 (permalink)
Insane Poster
 
Join Date: Jun 2004
Location: Glasgow
Age: 32
Posts: 82
Member: 69993
Status: Offline
Thanks: 4
Thanked 4 Times in 4 Posts
BB Connect help C++

Hey all I wonder if anyone can help me with this issue. I am trying to connect to a BB and ping some bytes over I am using this code below.

Quote:
DCB dcb = {0};

char *portName = "\\\\.\\COM4";

HANDLE h = CreateFile(portName,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ, NULL,
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL);

if (h == INVALID_HANDLE_VALUE) {
fprintf(stderr, "Failed to open port %s\n", portName);
system ("pause");
exit(EXIT_FAILURE);
}
printf("Opened port %s\n", portName);

dcb.DCBlength = sizeof(dcb);
dcb.BaudRate = 9600;
dcb.fBinary = 1;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
dcb.ByteSize = 8;
//


DWORD write = 0;
DWORD Dummy=0;



unsigned char pWriteSequence12[] = {0x00,0x00,0x1A,0x00,0x07,0xFF,0x00,0x00,0x43,0x61 ,0x6C,0x74,0x61,0x73,0x6B,0x20,0x43,0x6F,0x6E,0x66 ,0x69,0x67,0x00,0x00,0xFF,0xFF};
WriteFile(h,pWriteSequence12, 24, &write, NULL);


printf("sending \n");


CloseHandle(h);
This will send the bytes from pWriteSequence12 but also sends 2 lines of ghost bytes before hand for example.

Send 0x1c bytes to the device (?????)
00 00 00 00 00 00 00 00 00 00 00 00 00 C2 01 00
43 6F 6E 66 69 67 00 00 78 56 34 12
.............Â..Config..xV4.

Send 0x1c bytes to the device (?????)
00 00 00 00 00 00 00 00 00 00 00 00 00 C2 01 00
43 6F 6E 66 69 67 00 00 78 56 34 12
.............Â..Config..xV4.


Send 0x22 bytes to the device (What i sent some incorrect)
00 00 1A 00 07 FF 00 00 43 61 6C 74 61 73 6B 20
43 6F 6E 66 69 67 00 00 FF FF 00 00 08 00 0A 02
00 01

Is this error because I am using the COM varriable for handle or is it the way I am sending these to the USB? I did the the PID connection method but none of the examples I found would work maybe because I am using a 9300 and its newer guid than the examples listed on here.

Thanks in advance

Last edited by Lombard; 07-17-2012 at 17:38.
  Reply With Quote
Old 07-17-2012, 18:40   #2 (permalink)
Freak Poster
 
Join Date: Jul 2011
Location: Australia/Melbourne
Posts: 100
Member: 1610809
Status: Offline
Sonork: 100.1616347
Thanks: 90
Thanked 20 Times in 18 Posts
try this

read bbpin
Quote:
00 00 0C 00 05 FF 00 00 08 00 04 00
calltask
Quote:
00 00 18 00 07 ff 00 01
52 49 4d 20 43 61 6c 20
74 61 73 6b 00 00 00 00
u must read write using usb device not com
writefile and readfile

corect this if i wrong

br
  Reply With Quote
The Following User Says Thank You to GTunlocker For This Useful Post:
Old 07-17-2012, 18:46   #3 (permalink)
Insane Poster
 
Join Date: Sep 2009
Age: 33
Posts: 64
Member: 1111849
Status: Offline
Thanks: 196
Thanked 17 Times in 12 Posts
Better use "fwrite".
  Reply With Quote
Old 07-17-2012, 20:13   #4 (permalink)
Insane Poster
 
Join Date: Jun 2004
Location: Glasgow
Age: 32
Posts: 82
Member: 69993
Status: Offline
Thanks: 4
Thanked 4 Times in 4 Posts
Guys thanks to much for the replys I will use fwrite from now on just reading up on it on MSDN now. My only other problem is connecting via USB I take it from examples in the forum so far its along the lines of
\\?\usb#vid_0fca&pid_8004&mi_00#7&34ebb32b&0&0000# {80375827-83b8-4a51-b39b-905fedd4f118}\MAIN
My USB device shows

Interface GUID: {893B6A96-0B7F-4D4D-BDB4-BBD4CEEBB31C}
Interface Size: 0x68 bytes
Interface Version: 0x1
Status: 0xc00000bb
Information: 0x0
Device ID: USB\VID_0FCA&PID_8004


So logic would tell me to try


\\?\usb#vid_0fca&pid_8004&mi_00#7&34ebb32b&0&0000# {893B6A96-0B7F-4D4D-BDB4-BBD4CEEBB31C}\MAIN
However this doesnt work either. Any help appreciated.
  Reply With Quote
Old 07-17-2012, 21:28   #5 (permalink)
Product Supporter
 
orbita's Avatar
 
Join Date: Apr 2002
Location: nckDongle
Posts: 1,979
Member: 11170
Status: Offline
Sonork: 1603694
Thanks: 230
Thanked 1,604 Times in 597 Posts
Quote:
Originally Posted by Lombard View Post
Guys thanks to much for the replys I will use fwrite from now on just reading up on it on MSDN now. My only other problem is connecting via USB I take it from examples in the forum so far its along the lines of
\\?\usb#vid_0fca&pid_8004&mi_00#7&34ebb32b&0&0000# {80375827-83b8-4a51-b39b-905fedd4f118}\MAIN
My USB device shows

Interface GUID: {893B6A96-0B7F-4D4D-BDB4-BBD4CEEBB31C}
Interface Size: 0x68 bytes
Interface Version: 0x1
Status: 0xc00000bb
Information: 0x0
Device ID: USB\VID_0FCA&PID_8004


So logic would tell me to try


\\?\usb#vid_0fca&pid_8004&mi_00#7&34ebb32b&0&0000# {893B6A96-0B7F-4D4D-BDB4-BBD4CEEBB31C}\MAIN
However this doesnt work either. Any help appreciated.
Get device path, some like this
Code:
BOOL GetDevicePath(LPGUID lpGuid, LPTSTR pszDevicePath)
{
	HDEVINFO hDevInfoSet;
	HANDLE hOut;
	SP_DEVICE_INTERFACE_DATA ifdata;
	SP_DEVINFO_DATA devInfoElem; 
	char szDevDesc[256]; 
	DWORD DataType,length;	
	GUID dvGuid=CLASS_GUID_SMARTCARD;
	int nCount;
	BOOL bResult;
	
	
	hDevInfoSet = SetupDiGetClassDevs((LPGUID)&dvGuid, 
		NULL,    
		NULL,     
		DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); 

	
	if(hDevInfoSet == INVALID_HANDLE_VALUE)
	{
		return FALSE;
	}
	nCount = 0;
	bResult = TRUE;
	
	
	while (bResult)
	{
		ifdata.cbSize=sizeof(ifdata);
		
		
		bResult = SetupDiEnumDeviceInterfaces(
			hDevInfoSet,  
			NULL,   
			lpGuid,   
			(ULONG)nCount,  
			&ifdata); 
		
		if(bResult)
		{
			hOut = OpenOneDevice (hDevInfoSet, &ifdata, pszDevicePath);
			if ( hOut != INVALID_HANDLE_VALUE )
			{				
				CloseHandle(hOut);
				
				::SetupDiDestroyDeviceInfoList(hDevInfoSet);
				return TRUE;
				
			}
			
			nCount++;
			
		}
	}	
	
	::SetupDiDestroyDeviceInfoList(hDevInfoSet);
	
	return FALSE;
}

handle created ok?


Code:
HANDLE OpenDev(char *devName)
{
	HANDLE h;			
	h = CreateFile(devName,
		GENERIC_WRITE | GENERIC_READ,
		FILE_SHARE_WRITE | FILE_SHARE_READ,
		NULL,
		OPEN_EXISTING,
		0,
		NULL);
	return h;
}
if (OpenDev(your_path) == INVALID_HANDLE_VALUE)
{
do here some
}
  Reply With Quote
The Following 3 Users Say Thank You to orbita For This Useful Post:
Old 07-17-2012, 22:43   #6 (permalink)
Insane Poster
 
Join Date: Jun 2004
Location: Glasgow
Age: 32
Posts: 82
Member: 69993
Status: Offline
Thanks: 4
Thanked 4 Times in 4 Posts
Thanks Orbita I amended the createflile to match yours however no luck with the GetDevicePath script. Is there a program that will display this path? maybe an .exe I dont need it to read by the program as its only an app for me to mess around with. So I can just manually enter it.
  Reply With Quote
Old 07-17-2012, 22:50   #7 (permalink)
Product Supporter
 
orbita's Avatar
 
Join Date: Apr 2002
Location: nckDongle
Posts: 1,979
Member: 11170
Status: Offline
Sonork: 1603694
Thanks: 230
Thanked 1,604 Times in 597 Posts
Quote:
Originally Posted by Lombard View Post
Thanks Orbita I amended the createflile to match yours however no luck with the GetDevicePath script. Is there a program that will display this path? maybe an .exe I dont need it to read by the program as its only an app for me to mess around with. So I can just manually enter it.

I'am posted exe file here in this forum, just search for.
It display device path and also detect ondevice_insert and ondevice_remove
and display affected device path.
  Reply With Quote
The Following User Says Thank You to orbita For This Useful Post:
Old 07-17-2012, 23:09   #8 (permalink)
Insane Poster
 
Join Date: Jun 2004
Location: Glasgow
Age: 32
Posts: 82
Member: 69993
Status: Offline
Thanks: 4
Thanked 4 Times in 4 Posts
My friend good work with the .exe very good took me a second to work out you need to enter the GUID

Here is link for others Simple exe for detect device by guid and know his path

Now I get log

GUID:{80375827-83B8-4A51-B39B-905FEDD4F118}
Device detected: BlackBerry Smartphone
Path: \\?\usb#vid_0fca&pid_8004&mi_00#6&9f8cd&0&0000#{80 375827-83b8-4a51-b39b-905fedd4f118}\


So i try this

char *portName = "\\?\usb#vid_0fca&pid_8004&mi_00#6&9f8cd&0&0000#{8 0375827-83b8-4a51-b39b-905fedd4f118}";
HANDLE h;
h = CreateFile(portName,
GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_WRITE | FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
0,
NULL);

if (h == INVALID_HANDLE_VALUE) {
fprintf(stderr, "Failed to open port %s\n", portName);
system ("pause");
exit(EXIT_FAILURE);
}
else
printf("Opened port %s\n", portName);

Still no connect otherwise I notice the \ at the end this wont compile. Do I need to add the \ afterwards i.e portName+"\"

This is my first mess around with this language really just moved from php so sorry if my questions are dumb.
  Reply With Quote
Old 07-17-2012, 23:23   #9 (permalink)
Product Supporter
 
orbita's Avatar
 
Join Date: Apr 2002
Location: nckDongle
Posts: 1,979
Member: 11170
Status: Offline
Sonork: 1603694
Thanks: 230
Thanked 1,604 Times in 597 Posts
Blackberry need in this way path+"\MAIN"

Once you have valid handle must work.
See also if some blackberry software not keep buzy your port.
  Reply With Quote
Old 07-17-2012, 23:29   #10 (permalink)
Insane Poster
 
Join Date: Jun 2004
Location: Glasgow
Age: 32
Posts: 82
Member: 69993
Status: Offline
Thanks: 4
Thanked 4 Times in 4 Posts
Cheers was thinking that done so much messing tonight might have blocked ports. I will try a reboot I notice from my out put log

Failed to open port \?usb#vid_0fca&pid_8004&mi_00#6&9f8cd&0&0000#{8037 5827-83b8-
4a51-b39b-905fedd4f118>MAIN
Press any key to continue . . .

is the >main correct as I entered /main but output is different? Think this could be my problem now.

p.s your patience has been appreciated.
  Reply With Quote
Old 07-17-2012, 23:37   #11 (permalink)
Product Supporter
 
orbita's Avatar
 
Join Date: Apr 2002
Location: nckDongle
Posts: 1,979
Member: 11170
Status: Offline
Sonork: 1603694
Thanks: 230
Thanked 1,604 Times in 597 Posts
Quote:
Originally Posted by Lombard View Post
Cheers was thinking that done so much messing tonight might have blocked ports. I will try a reboot I notice from my out put log

Failed to open port \?usb#vid_0fca&pid_8004&mi_00#6&9f8cd&0&0000#{8037 5827-83b8-
4a51-b39b-905fedd4f118>MAIN
Press any key to continue . . .

is the >main correct as I entered /main but output is different? Think this could be my problem now.

p.s your patience has been appreciated.
Just hint here.
Try with Borland C++ it's more friendly with beginners and allow more easy to understand C++.

"//MAIN"
Try in this way.
  Reply With Quote
Old 07-17-2012, 23:40   #12 (permalink)
Product Supporter
 
orbita's Avatar
 
Join Date: Apr 2002
Location: nckDongle
Posts: 1,979
Member: 11170
Status: Offline
Sonork: 1603694
Thanks: 230
Thanked 1,604 Times in 597 Posts
Just hint here.
Try with Borland C++ it's more friendly with beginners and allow more easy to understand C++.

"//MAIN"
Try in this way.

\?usb here also not corect.
  Reply With Quote
Old 07-17-2012, 23:44   #13 (permalink)
Product Supporter
 
orbita's Avatar
 
Join Date: Apr 2002
Location: nckDongle
Posts: 1,979
Member: 11170
Status: Offline
Sonork: 1603694
Thanks: 230
Thanked 1,604 Times in 597 Posts
sorry maked mistake.
need double each /
so will be "\\MAIN"
and "\\\\?usb"

Seems forum bug, instead of edit make new post .

Last edited by orbita; 07-17-2012 at 23:50.
  Reply With Quote
Old 07-17-2012, 23:57   #14 (permalink)
Insane Poster
 
Join Date: Jun 2004
Location: Glasgow
Age: 32
Posts: 82
Member: 69993
Status: Offline
Thanks: 4
Thanked 4 Times in 4 Posts
Thanks but still no joy I will give Borland a go just getting used to VS 2010 Pro though wasnt cheap :-(

My last error log
Failed to open port \?usb#vid_0fca&pid_8004&mi_00#6&9f8cd&0&0000#{8037 5827-83b8-4a51-b39b-905fedd4f118}\MAIN
Press any key to continue . . .

For others please compile and test with a Blackberry phone using the link provided for Orbitas GUID path locating tool. Would be interested to see if it works for anyone else.

Quote:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
//
int main()
{
// Get this info from .exe found here Simple exe for detect device by guid and know his path
char *portName = "\\?\usb#vid_0fca&pid_8004&mi_00#6&9f8cd&0&0000#{8 0375827-83b8-4a51-b39b-905fedd4f118}\\MAIN";

HANDLE h;
h = CreateFile(portName,
GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_WRITE | FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
0,
NULL);
//
if (h == INVALID_HANDLE_VALUE) {
fprintf(stderr, "Failed to open port %s\n", portName);
system ("pause");
exit(EXIT_FAILURE);
}
else
printf("Opened port %s\n", portName);
system("pause");
return 0;
}
Thanks for all the replys. Getting there slowly.
  Reply With Quote
Old 07-18-2012, 00:08   #15 (permalink)
Product Supporter
 
orbita's Avatar
 
Join Date: Apr 2002
Location: nckDongle
Posts: 1,979
Member: 11170
Status: Offline
Sonork: 1603694
Thanks: 230
Thanked 1,604 Times in 597 Posts
char *portName = "\\\\?\\usb#vid_0fca&pid_8004&mi_00#6&9f8cd&0&0000 #{80375827-83b8-4a51-b39b-905fedd4f118}\\MAIN";

In this way will be corect.

Last edited by orbita; 07-18-2012 at 00:13.
  Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
thread Thread Starter Forum Replies Last Post
my 8810 is phone locked ,can somebody please help duyphuc Nokia Legacy Phones ( DCT-1 , DCT-2 , DCT-3 , DCT-L ) 16 02-01-2012 05:18
HELP!!! BACKGROUND SCREEN LOGO Michael Go Nokia Legacy Phones ( DCT-1 , DCT-2 , DCT-3 , DCT-L ) 6 12-25-2011 23:56
Eeprom dump lost, help needed. CAMILO Nokia Legacy Phones ( DCT-1 , DCT-2 , DCT-3 , DCT-L ) 6 11-29-2010 18:04
Help with 6110 paulomt1 Nokia Legacy Phones ( DCT-1 , DCT-2 , DCT-3 , DCT-L ) 3 05-25-2009 16:29
Winlock 1.10 - Help rdmfs Nokia Legacy Phones ( DCT-1 , DCT-2 , DCT-3 , DCT-L ) 3 06-25-1999 08:21


All times are GMT +1. The time now is 14:22.



Powered by Searchlight © 2013 Axivo Inc.
- GSM Hosting Ltd. - 1999-2013 -
Page generated in 2.04908 seconds with 11 queries

SEO by vBSEO