commit
2f8bbdf8e8
|
@ -33,6 +33,18 @@
|
||||||
<key>PostNotification</key>
|
<key>PostNotification</key>
|
||||||
<string>com.cosmosgenius.screendump/preferences.changed</string>
|
<string>com.cosmosgenius.screendump/preferences.changed</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>cell</key>
|
||||||
|
<string>PSSecureEditTextCell</string>
|
||||||
|
<key>defaults</key>
|
||||||
|
<string>com.cosmosgenius.screendump</string>
|
||||||
|
<key>key</key>
|
||||||
|
<string>CCSPassword</string>
|
||||||
|
<key>label</key>
|
||||||
|
<string>Password</string>
|
||||||
|
<key>PostNotification</key>
|
||||||
|
<string>com.cosmosgenius.screendump/preferences.changed</string>
|
||||||
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
40
Tweak.xm
40
Tweak.xm
|
@ -7,6 +7,7 @@
|
||||||
#define kSettingsPath [NSHomeDirectory() stringByAppendingPathComponent:@"/Library/Preferences/com.cosmosgenius.screendump.plist"]
|
#define kSettingsPath [NSHomeDirectory() stringByAppendingPathComponent:@"/Library/Preferences/com.cosmosgenius.screendump.plist"]
|
||||||
|
|
||||||
static bool CCSisEnabled = true;
|
static bool CCSisEnabled = true;
|
||||||
|
static NSString *CCSPassword = nil;
|
||||||
static rfbScreenInfoPtr screen;
|
static rfbScreenInfoPtr screen;
|
||||||
static bool isVNCRunning;
|
static bool isVNCRunning;
|
||||||
// static NSCondition *condition_;
|
// static NSCondition *condition_;
|
||||||
|
@ -42,14 +43,30 @@ extern "C" kern_return_t IOMobileFramebufferSwapSetLayer(
|
||||||
extern "C" void IOSurfaceFlushProcessorCaches(IOSurfaceRef buffer);
|
extern "C" void IOSurfaceFlushProcessorCaches(IOSurfaceRef buffer);
|
||||||
extern "C" int IOSurfaceLock(IOSurfaceRef surface, uint32_t options, uint32_t *seed);
|
extern "C" int IOSurfaceLock(IOSurfaceRef surface, uint32_t options, uint32_t *seed);
|
||||||
extern "C" int IOSurfaceUnlock(IOSurfaceRef surface, uint32_t options, uint32_t *seed);
|
extern "C" int IOSurfaceUnlock(IOSurfaceRef surface, uint32_t options, uint32_t *seed);
|
||||||
static void VNCUpdateRunState(bool shouldStart);
|
|
||||||
|
|
||||||
static IOSurfaceAcceleratorRef accelerator;
|
static IOSurfaceAcceleratorRef accelerator;
|
||||||
static IOSurfaceRef static_buffer;
|
static IOSurfaceRef static_buffer;
|
||||||
|
|
||||||
|
static void VNCSettings(bool shouldStart, NSString *password);
|
||||||
|
static void VNCUpdateRunState(bool shouldStart);
|
||||||
static void handleVNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client);
|
static void handleVNCKeyboard(rfbBool down, rfbKeySym key, rfbClientPtr client);
|
||||||
static void handleVNCPointer(int buttons, int x, int y, rfbClientPtr client);
|
static void handleVNCPointer(int buttons, int x, int y, rfbClientPtr client);
|
||||||
|
|
||||||
|
static rfbBool VNCCheck(rfbClientPtr client, const char *data, int size) {
|
||||||
|
NSString *password = reinterpret_cast<NSString *>(screen->authPasswdData);
|
||||||
|
if(!password) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
if ([password length] == 0) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
|
||||||
|
rfbEncryptBytes(client->authChallenge, const_cast<char *>([password UTF8String]));
|
||||||
|
bool good(memcmp(client->authChallenge, data, size) == 0);
|
||||||
|
[pool release];
|
||||||
|
return good;
|
||||||
|
}
|
||||||
|
|
||||||
static void VNCSetup() {
|
static void VNCSetup() {
|
||||||
int argc(1);
|
int argc(1);
|
||||||
char *arg0(strdup("ScreenDumpVNC"));
|
char *arg0(strdup("ScreenDumpVNC"));
|
||||||
|
@ -61,6 +78,7 @@ static void VNCSetup() {
|
||||||
screen->serverFormat.blueShift = bits_per_sample * 0;
|
screen->serverFormat.blueShift = bits_per_sample * 0;
|
||||||
screen->kbdAddEvent = &handleVNCKeyboard;
|
screen->kbdAddEvent = &handleVNCKeyboard;
|
||||||
screen->ptrAddEvent = &handleVNCPointer;
|
screen->ptrAddEvent = &handleVNCPointer;
|
||||||
|
screen->passwordCheck = &VNCCheck;
|
||||||
free(arg0);
|
free(arg0);
|
||||||
VNCUpdateRunState(CCSisEnabled);
|
VNCUpdateRunState(CCSisEnabled);
|
||||||
}
|
}
|
||||||
|
@ -116,10 +134,25 @@ static void initialBuffer() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void VNCSettings(bool shouldStart, NSString* password) {
|
||||||
|
CCSisEnabled = shouldStart;
|
||||||
|
if(password) {
|
||||||
|
CCSPassword = password;
|
||||||
|
}
|
||||||
|
NSString *sEnabled = CCSisEnabled ? @"YES": @"NO";
|
||||||
|
// NSLog(@"screendump: Settings(Enabled:%@, Password:%@)", sEnabled, CCSPassword);
|
||||||
|
VNCUpdateRunState(CCSisEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
static void VNCUpdateRunState(bool shouldStart) {
|
static void VNCUpdateRunState(bool shouldStart) {
|
||||||
if(screen == NULL) {
|
if(screen == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(CCSPassword && CCSPassword.length) {
|
||||||
|
screen->authPasswdData = (void *) CCSPassword;
|
||||||
|
} else {
|
||||||
|
screen->authPasswdData = NULL;
|
||||||
|
}
|
||||||
if(shouldStart == isVNCRunning) {
|
if(shouldStart == isVNCRunning) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -185,10 +218,11 @@ static void loadPrefs(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(prefs) {
|
if(prefs) {
|
||||||
CCSisEnabled = [prefs objectForKey:@"CCSisEnabled"] ? [[prefs objectForKey:@"CCSisEnabled"] boolValue] : CCSisEnabled;
|
bool isEnabled = [prefs objectForKey:@"CCSisEnabled"] ? [[prefs objectForKey:@"CCSisEnabled"] boolValue] : CCSisEnabled;
|
||||||
|
NSString *password = [prefs objectForKey:@"CCSPassword"];
|
||||||
[prefs release];
|
[prefs release];
|
||||||
|
VNCSettings(isEnabled, password);
|
||||||
}
|
}
|
||||||
VNCUpdateRunState(CCSisEnabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%hookf(kern_return_t, IOMobileFramebufferSwapSetLayer, IOMobileFramebufferRef fb, int layer, IOSurfaceRef buffer, CGRect bounds, CGRect frame, int flags) {
|
%hookf(kern_return_t, IOMobileFramebufferSwapSetLayer, IOMobileFramebufferRef fb, int layer, IOSurfaceRef buffer, CGRect bounds, CGRect frame, int flags) {
|
||||||
|
|
Loading…
Reference in New Issue