本文整理汇总了C++中IOConnectCallMethod函数的典型用法代码示例。如果您正苦于以下问题:C++ IOConnectCallMethod函数的具体用法?C++ IOConnectCallMethod怎么用?C++ IOConnectCallMethod使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IOConnectCallMethod函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: enkript_prologue
void enkript_prologue(void)
{
if (IOConnectCallMethod == NULL) die("IOConnectCallMethod unavailable, require version >= 10.5");
/* get iterator to browse drivers of the chosen class
*/
io_iterator_t iterator;
if (IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching("com_enkript_driver_Service"), &iterator) != KERN_SUCCESS) die("IOServiceGetMatchingServices failed");
/* browse drivers
*/
for (io_service_t service = IOIteratorNext(iterator); service != IO_OBJECT_NULL; service = IOIteratorNext(iterator))
{
debug("com_enkript_driver_Service instance found!");
/* open service
*/
io_connect_t connect = IO_OBJECT_NULL;
if (IOServiceOpen(service, mach_task_self(), 0, &connect) != KERN_SUCCESS) die("IOServiceOpen failed");
/* call driver's open method
*/
if (IOConnectCallMethod(connect, 0 /* open, TOFIX */, NULL, 0, NULL, 0, NULL, NULL, NULL, NULL) != KERN_SUCCESS) die("IOConnectCallMethod failed");
/* call driver's hello method
*/
uint64_t buf = getpid();
if (IOConnectCallMethod(connect, 2 /* hello, TOFIX */, &buf, 1, NULL, 0, NULL, NULL, NULL, NULL) != KERN_SUCCESS) die("IOConnectCallMethod failed");
/* call driver's close method
*/
if (IOConnectCallMethod(connect, 1 /* close, TOFIX */, NULL, 0, NULL, 0, NULL, NULL, NULL, NULL) != KERN_SUCCESS) die("IOConnectCallMethod failed");
/* close service
*/
if (IOServiceClose(connect) != KERN_SUCCESS) die("IOServiceClose failed");
}
IOObjectRelease(iterator);
}
示例2: iSCSIKernelRecv
/*! Receives data over a kernel socket associated with iSCSI.
* @param sessionId the qualifier part of the ISID (see RFC3720).
* @param connectionId the connection associated with the session.
* @param bhs the basic header segment received over the connection.
* @param data the data segment of the PDU received over the connection.
* @param length the length of the data block received.
* @return error code indicating result of operation. */
errno_t iSCSIKernelRecv(SID sessionId,
CID connectionId,
iSCSIPDUTargetBHS * bhs,
void ** data,
size_t * length)
{
// Check parameters
if(sessionId == kiSCSIInvalidSessionId || connectionId == kiSCSIInvalidConnectionId || !bhs)
return EINVAL;
// Setup input scalar array
const UInt32 inputCnt = 2;
UInt64 inputs[] = {sessionId,connectionId};
size_t bhsLength = sizeof(iSCSIPDUTargetBHS);
// Call kernel method to determine how much data there is to receive
// The inputs are the sesssion qualifier and connection ID
// The output is the size of the buffer we need to allocate to hold the data
kern_return_t result;
result = IOConnectCallMethod(connection,kiSCSIRecvBHS,inputs,inputCnt,NULL,0,
NULL,NULL,bhs,&bhsLength);
if(result != kIOReturnSuccess)
return IOReturnToErrno(result);
// Determine how much data to allocate for the data buffer
*length = iSCSIPDUGetDataSegmentLength((iSCSIPDUCommonBHS *)bhs);
// If no data, were done at this point
if(*length == 0)
return 0;
*data = iSCSIPDUDataCreate(*length);
if(*data == NULL)
return EIO;
// Call kernel method to get data from a receive buffer
result = IOConnectCallMethod(connection,kiSCSIRecvData,inputs,inputCnt,NULL,0,
NULL,NULL,*data,length);
// If we failed, free the temporary buffer and quit with error
if(result != kIOReturnSuccess)
iSCSIPDUDataRelease(data);
return IOReturnToErrno(result);
}
示例3: IOAccelFlushSurfaceOnFramebuffers
/* Flush surface to visible region */
IOReturn IOAccelFlushSurfaceOnFramebuffers( IOAccelConnect connect, IOOptionBits options, UInt32 framebufferMask )
{
uint64_t inData[] = { framebufferMask, options };
return IOConnectCallMethod((io_connect_t) (uintptr_t) connect, kIOAccelSurfaceFlush,
inData, arrayCnt(inData), NULL, 0,// input
NULL, NULL, NULL, NULL); // output
}
示例4: IOAccelWriteUnlockSurfaceWithOptions
IOReturn IOAccelWriteUnlockSurfaceWithOptions( IOAccelConnect connect, IOOptionBits options )
{
uint64_t inData = options;
return IOConnectCallMethod((io_connect_t) (uintptr_t) connect, kIOAccelSurfaceWriteUnlockOptions,
&inData, 1, NULL, 0, // input
NULL, NULL, NULL, NULL); // output
}
示例5: connect_to_keystore
static io_connect_t connect_to_keystore(void)
{
io_registry_entry_t apple_key_bag_service;
kern_return_t result;
io_connect_t keystore = MACH_PORT_NULL;
apple_key_bag_service = IOServiceGetMatchingService(kIOMasterPortDefault,
IOServiceMatching(kAppleKeyStoreServiceName));
if (apple_key_bag_service == IO_OBJECT_NULL) {
fprintf(stderr, "Failed to get service.\n");
return keystore;
}
result = IOServiceOpen(apple_key_bag_service, mach_task_self(), 0, &keystore);
if (KERN_SUCCESS != result)
fprintf(stderr, "Failed to open keystore\n");
if (keystore != MACH_PORT_NULL) {
IOReturn kernResult = IOConnectCallMethod(keystore,
kAppleKeyStoreUserClientOpen, NULL, 0, NULL, 0, NULL, NULL,
NULL, NULL);
if (kernResult) {
fprintf(stderr, "Failed to open AppleKeyStore: %x\n", kernResult);
}
}
return keystore;
}
示例6: fake_IOConnectCallMethod
kern_return_t
fake_IOConnectCallMethod(
mach_port_t connection, // In
uint32_t selector, // In
/*const*/ uint64_t *input, // In
uint32_t inputCnt, // In
/*const*/ void *inputStruct, // In
size_t inputStructCnt, // In
uint64_t *output, // Out
uint32_t *outputCnt, // In/Out
void *outputStruct, // Out
size_t *outputStructCntP) // In/Out
{
kern_return_t ret = 0;
ret = IOConnectCallMethod(
connection,
selector,
input,
inputCnt,
inputStruct,
inputStructCnt,
output,
outputCnt,
outputStruct,
outputStructCntP);
return ret;
}
示例7: dumpLog0
// logging metadata, contains e.g. size of log1, pointer to current entry etc.
// 0xc == AGCDebug
static BOOL dumpLog0(io_connect_t connect) {
kern_return_t kernResult;
uint8_t buffer[0x100];
uint64_t scalarI_64[2] = { (uint64_t) buffer, 0x100 };
kernResult = IOConnectCallMethod(connect, // an io_connect_t returned from IOServiceOpen().
kGetAGCData, // selector of the function to be called via the user client.
scalarI_64, // array of scalar (64-bit) input values.
2, // the number of scalar input values.
NULL, // a pointer to the struct input parameter.
0, // the size of the input structure parameter.
NULL, // array of scalar (64-bit) output values.
NULL, // pointer to the number of scalar output values.
NULL, // pointer to the struct output parameter.
NULL // pointer to the size of the output structure parameter.
);
if (kernResult == KERN_SUCCESS) {
printf("getMuxState was successful.\n");
int i;
for (i=0; i < 0x100; i++) {
printf("0x%x: 0x%x\n", i, buffer[i]);
}
} else {
printf("getMuxState returned 0x%08x.\n", kernResult);
}
return kernResult == KERN_SUCCESS;
}
示例8: create_requests
void create_requests(io_connect_t port)
{
struct BluetoothCall a;
uint32_t i;
kern_return_t kr;
for (i = 0; i < 7; i++) {
a.args[i] = (uint64_t) calloc(SIZE, sizeof(char));
a.sizes[i] = SIZE;
}
/* DispatchHCIRequestCreate() */
a.index = 0x0;
*(uint64_t *)a.args[0] = 5*1000; /* Timeout */
memset((void *)a.args[1], 0x81, 0x1000);
memset((void *)a.args[2], 0x82, 0x1000);
memset((void *)a.args[3], 0x83, 0x1000);
memset((void *)a.args[4], 0x84, 0x1000);
memset((void *)a.args[5], 0x85, 0x1000);
memset((void *)a.args[6], 0x86, 0x1000);
for(i = 0; i < 500; i++) {
kr = IOConnectCallMethod((mach_port_t) port, /* Connection */
(uint32_t) 0, /* Selector */
NULL, 0, /* input, inputCnt */
(const void*) &a, /* inputStruct */
120, /* inputStructCnt */
NULL, NULL, NULL, NULL); /* Output stuff */
if(kr == 0xe00002bd) /* Full */
break;
}
}
示例9: iSCSIKernelGetConnectionIds
/*! Gets an array of connection identifiers for each session.
* @param sessionId session identifier.
* @param connectionIds an array of connection identifiers for the session.
* @param connectionCount number of connection identifiers.
* @return error code indicating result of operation. */
errno_t iSCSIKernelGetConnectionIds(SID sessionId,
CID * connectionIds,
UInt32 * connectionCount)
{
if(sessionId == kiSCSIInvalidSessionId || !connectionIds || !connectionCount)
return EINVAL;
const UInt32 inputCnt = 1;
UInt64 input = sessionId;
const UInt32 expOutputCnt = 1;
UInt64 output;
UInt32 outputCnt = expOutputCnt;
*connectionCount = 0;
size_t outputStructSize = sizeof(CID)*kiSCSIMaxConnectionsPerSession;
kern_return_t result =
IOConnectCallMethod(connection,kiSCSIGetConnectionIds,&input,inputCnt,0,0,
&output,&outputCnt,connectionIds,&outputStructSize);
if(result == kIOReturnSuccess && outputCnt == expOutputCnt)
*connectionCount = (UInt32)output;
return IOReturnToErrno(result);
}
示例10: kcm_create_key
krb5_error_code
kcm_create_key(krb5_uuid uuid)
{
io_connect_t conn;
createKeyGetUUID_InStruct_t createKey;
kern_return_t kr;
uuid_OutStruct_t key;
size_t outputStructSize = sizeof(key);
conn = openiodev();
if (conn == IO_OBJECT_NULL)
return EINVAL;
createKey.keySizeInBytes = V1_KEYSIZE;
createKey.algorithm = fDE_ALG_AESXTS;
memset(&key, 0, sizeof(key));
kr = IOConnectCallMethod(conn, kAppleFDEKeyStore_createKeyGetUUID,
NULL, 0,
&createKey, sizeof(createKey),
NULL, 0,
&key, &outputStructSize);
closeiodev(conn);
if (kr != KERN_SUCCESS)
return EINVAL;
memcpy(uuid, key.uuid, sizeof(key.uuid));
return 0;
}
示例11: iSCSIKernelSend
/*! Sends data over a kernel socket associated with iSCSI.
* @param sessionId the qualifier part of the ISID (see RFC3720).
* @param connectionId the connection associated with the session.
* @param bhs the basic header segment to send over the connection.
* @param data the data segment of the PDU to send over the connection.
* @param length the length of the data block to send over the connection.
* @return error code indicating result of operation. */
errno_t iSCSIKernelSend(SID sessionId,
CID connectionId,
iSCSIPDUInitiatorBHS * bhs,
void * data,
size_t length)
{
// Check parameters
if(sessionId == kiSCSIInvalidSessionId || connectionId == kiSCSIInvalidConnectionId || !bhs || (!data && length > 0))
return EINVAL;
// Setup input scalar array
const UInt32 inputCnt = 2;
const UInt64 inputs[] = {sessionId, connectionId};
// Call kernel method to send (buffer) bhs and then data
kern_return_t result;
result = IOConnectCallStructMethod(connection,kiSCSISendBHS,bhs,
sizeof(iSCSIPDUInitiatorBHS),NULL,NULL);
if(result != kIOReturnSuccess)
return IOReturnToErrno(result);
return IOReturnToErrno(IOConnectCallMethod(connection,kiSCSISendData,inputs,inputCnt,
data,length,NULL,NULL,NULL,NULL));
}
示例12: iSCSIKernelGetConnectionIdForPortalAddress
/*! Looks up the connection identifier associated with a particular portal address.
* @param sessionId the session identifier.
* @param portalAddress the address passed to iSCSIKernelCreateSession() or
* iSCSIKernelCreateConnection() when the connection was created.
* @return the associated connection identifier. */
CID iSCSIKernelGetConnectionIdForPortalAddress(SID sessionId,
CFStringRef portalAddress)
{
if(sessionId == kiSCSIInvalidSessionId || !portalAddress)
return EINVAL;
const UInt32 inputCnt = 1;
UInt64 input = sessionId;
const UInt32 expOutputCnt = 1;
UInt64 output[expOutputCnt];
UInt32 outputCnt = expOutputCnt;
kern_return_t result =
IOConnectCallMethod(connection,kiSCSIGetConnectionIdForPortalAddress,
&input,inputCnt,
CFStringGetCStringPtr(portalAddress,kCFStringEncodingASCII),
CFStringGetLength(portalAddress)+1,
output,&outputCnt,0,0);
if(result != kIOReturnSuccess || outputCnt != expOutputCnt)
return kiSCSIInvalidConnectionId;
return (CID)output[0];
}
示例13: test_io_connect_method
void test_io_connect_method(io_connect_t conn, int selector, uint64_t* scalar_input,
uint32_t scalar_input_cnt,
unsigned char* struct_input, size_t struct_input_cnt, int scalar_output_cnt,
int struct_output_cnt) {
uint64_t outputScalar[16];
uint32_t outputScalarCnt = scalar_output_cnt;
char outputStruct[4096];
size_t outputStructCnt = struct_output_cnt;
int index = selector;
printf("IOConnectCall (selector = %d)\n", index);
//getchar();
kern_return_t err = IOConnectCallMethod(
conn,
index,
scalar_input,
scalar_input_cnt,
struct_input,
struct_input_cnt,
outputScalar,
&outputScalarCnt,
outputStruct,
&outputStructCnt);
if (err != KERN_SUCCESS){
printf("IOConnectCall (%d) error: %x\n", index, err);
}
}
示例14: dumpLog1
static BOOL dumpLog1(io_connect_t connect) {
kern_return_t kernResult;
uint8_t buffer[LOGSIZE];
uint64_t scalarI_64[2] = { (uint64_t) buffer, LOGSIZE };
kernResult = IOConnectCallMethod(connect, // an io_connect_t returned from IOServiceOpen().
kGetAGCData_log1, // selector of the function to be called via the user client.
scalarI_64, // array of scalar (64-bit) input values.
2, // the number of scalar input values.
NULL, // a pointer to the struct input parameter.
0, // the size of the input structure parameter.
NULL, // array of scalar (64-bit) output values.
NULL, // pointer to the number of scalar output values.
NULL, // pointer to the struct output parameter.
NULL // pointer to the size of the output structure parameter.
);
if (kernResult == KERN_SUCCESS) {
printf("getMuxState was successful.\n");
FILE *logfile;
logfile = fopen("log.bin", "wb");
if (!logfile) {
printf("cannot open file\n");
} else {
fwrite(buffer, sizeof(uint8_t), LOGSIZE, logfile);
fclose(logfile);
}
} else {
printf("getMuxState returned 0x%08x.\n", kernResult);
}
return kernResult == KERN_SUCCESS;
}
示例15: IOHIDSetCursorEnable
kern_return_t
IOHIDSetCursorEnable( io_connect_t connect,
boolean_t enable )
{
uint64_t inData = enable;
return IOConnectCallMethod( connect, 2, // Index
&inData, 1, NULL, 0, // Input
NULL, NULL, NULL, NULL); // Output
}